-
Notifications
You must be signed in to change notification settings - Fork 6
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
array cookie support #73
Conversation
Instead of collecting all bitcasts and filtering them, we observe that in case a GEP instruction is applied to an allocation it usually is used to calculate the pointer of the actual array. In case two GEP instructions are present, the first is used to add necessary padding to the array cookie and it's bitcast instructions can be safely ignored.
Introduces a new data structure for array cookie information that stores the store instruction that writes to the cookie and the value of the padding passed to the GEP instruction that computes the array pointer passed to the user. This commit also introduces several asserts to catch cases which are not expected and should be further investigated.
This makes these two command line arguments available in both the MemInstFinderPass and TypeARTPass. This allows the MemInstFinder to only collect the necessary instructions. As heap allocations are only collected on unoptimized code this in turn allows for a stricter analysis of the given code. To share the command line arguments, the cl::opt instances have been shared between the two passes. As the TypeARTPass depends on the MemInstFinderPass to already be loaded, the instances have been moved to the MemInstFinderPass and are now referenced with external linkage in the TypeARTPass.
If an array cookie is present, the value of the arrary cookie store instruction will be used as the element count of the array.
Pull Request Test Coverage Report for Build 853856281
💛 - Coveralls |
In case of array cookies, TypeART previously instrumented the address of the full memory block including the cookie. With this commit this is changed s.t. the memory address of the actual array is instrumented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some minor comments/changes. Overall great patch.
Eventually, we should do a rebase of the branch w.r.t. new changes in devel and then I will squash merge.
Seems like the assert triggers in
|
When ASAN is enabled, it will track array cookies using instrumentation by passing the array cookie-related bitcast. This triggered an assert of TypeART in "expectSingleUser", as we expected only a single user of the bitcast (the store of the array length) This patch explicitly handles the ASAN cookie instrumentation.
@alexanderlinne I fixed the ASAN issue w.r.t. expectSingleUser and renamed the function. |
@ahueck "get" implies that this function behaves like a normal getter, i.e. I would expect it to not assert. I usually use |
use llvm's Expected type to handle errors using some macros that simplify control flow
b1376d2
to
32a498f
Compare
* return_error_if merged to always use formatv version * typeart::error namespace lowercase * some minor code format
closes #71