Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate redundant assertion in doPtrAddOffset when offset = 0. #344

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions crucible-llvm/src/Lang/Crucible/LLVM/MemModel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,14 @@ doPtrAddOffset ::
LLVMPtr sym wptr {- ^ base pointer -} ->
SymBV sym wptr {- ^ offset -} ->
IO (LLVMPtr sym wptr)
doPtrAddOffset sym m x off = do
x' <- ptrAdd sym PtrWidth x off
v <- isValidPointer sym x' m
assertUndefined sym v $
UB.PtrAddOffsetOutOfBounds (UB.pointerView x) (RV off)
return x'
doPtrAddOffset sym m x off
| asUnsignedBV off == Just 0 = return x
| otherwise =
do x' <- ptrAdd sym PtrWidth x off
v <- isValidPointer sym x' m
assertUndefined sym v $
UB.PtrAddOffsetOutOfBounds (UB.pointerView x) (RV off)
return x'

-- | This predicate tests if the pointer is a valid, live pointer
-- into the heap, OR is the distinguished NULL pointer.
Expand Down