This is an archive of the discontinued LLVM Phabricator instance.

[safestack] Fix handling of array allocas.
ClosedPublic

Authored by eugenis on Nov 25 2015, 4:33 PM.

Details

Reviewers
eugenis
pcc
Summary

The current code does not take alloca array size into account and,
as a result, considers any access past the first array element to be
unsafe.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis updated this revision to Diff 41197.Nov 25 2015, 4:33 PM
eugenis retitled this revision from to [safestack] Fix handling of array allocas..
eugenis updated this object.
eugenis added a reviewer: pcc.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: llvm-commits.
pcc added inline comments.Nov 25 2015, 5:00 PM
lib/Transforms/Instrumentation/SafeStack.cpp
187

AI can be a dynamic alloca at this point, I believe (see findInsts -> IsSafeStackAlloca -> IsAccessSafe -> getStaticAllocaAllocationSize), so this may not be a constant.

eugenis updated this revision to Diff 41203.Nov 25 2015, 5:07 PM
eugenis added inline comments.
lib/Transforms/Instrumentation/SafeStack.cpp
187

Right. Returning 0 for unknown size allocas.

eugenis added inline comments.Nov 25 2015, 5:12 PM
lib/Transforms/Instrumentation/SafeStack.cpp
187

This would check such allocas for safety as if they are size 0, i.e. some operations are still allowed, but not any loads or stores.
We could actually do better by passing down the size as a Value and applying the SCEV magic to it. But (a) one thing at a time and (b) I doubt it actually matters.

pcc edited edge metadata.Nov 25 2015, 6:13 PM
pcc added a subscriber: pcc.

Lgtm

eugenis accepted this revision.Nov 30 2015, 4:09 PM
eugenis added a reviewer: eugenis.
This revision is now accepted and ready to land.Nov 30 2015, 4:09 PM
eugenis closed this revision.Nov 30 2015, 4:09 PM

r254350