This is an archive of the discontinued LLVM Phabricator instance.

[SafeStack] Don't create SCEV min between pointer and integer (PR54784)
ClosedPublic

Authored by nikic on Apr 7 2022, 6:37 AM.

Details

Summary

Rather than rewriting the alloca pointer to zero, use removePointerBase() to drop the base pointer. This will simply bail if the base pointer is not the alloca. We could try doing something more fancy here (like dropping the sources not based on the alloca on the premise that they aren't SafeStack-relevant or something), but I don't think that's worthwhile.

Fixes https://github.com/llvm/llvm-project/issues/54784.

Diff Detail

Event Timeline

nikic created this revision.Apr 7 2022, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 6:37 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Apr 7 2022, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 6:37 AM
gulfem added a subscriber: gulfem.Apr 7 2022, 9:51 AM
efriedma accepted this revision.Apr 7 2022, 1:31 PM

LGTM

In some cases, we could prove that the access is either in-range, or not based on the alloca. (For example, given an alloca "a" and an access "min(a,b)+1", the pointer is either "a+1", or "b+1". "a+1" is in range, and "b" is unrelated to the alloca, so the access is safe.) But it seems unlikely to be important.

This revision is now accepted and ready to land.Apr 7 2022, 1:31 PM
This revision was landed with ongoing or failed builds.Apr 8 2022, 12:44 AM
This revision was automatically updated to reflect the committed changes.