Avoid redundant split aggregate memory checks#829
Merged
Conversation
9504532 to
391c254
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #710.
Problem
SplitAggregateValuelowers one aggregate load/store into several scalarGEP+load/store operations. Since it runs before
MemorySafetyChecker, thosesynthetic scalar operations were each instrumented independently. For example,
a 16-byte aggregate access could become two 8-byte memory-safety checks even
though the source operation was one aggregate access.
Approach
This keeps the original memory-safety obligation but avoids checking every
scalarized piece:
SplitAggregateValuetags the scalar loads/stores it creates with internalmetadata.
the representative whole-aggregate access.
MemorySafetyCheckerturns that representative access into one check on theoriginal aggregate base pointer and aggregate type size.
are skipped without adding a source-level memory-safety obligation.
This is intentionally not a blanket suppression of all split aggregate memory
operations. Aggregate accesses through arbitrary pointers still get checked;
they are just checked once at the original aggregate size.
Regression
Adds a C memory-safety regression for aggregate return lowering. The test uses
-O2 -Xclang -disable-llvm-passes: optimized frontend lowering produces theaggregate return shape, while disabling later LLVM passes prevents that shape
from being lowered away before SMACK sees it.
The regression checks that
funemits the two real scalar stores into the localstruct plus exactly one 16-byte check for the split aggregate load used to
return the value. Before this change, the same case emitted four 8-byte checks.
Validation
ninja -C build -j2git diff --checkpython3 test/regtest.py --folder c/memory-safety/split-aggregate --languages c --threads 1 --log INFO --all-examples