This is an archive of the discontinued LLVM Phabricator instance.

StackProtector: Use PointerMayBeCaptured
ClosedPublic

Authored by arsenm on Jun 11 2019, 12:50 PM.

Details

Reviewers
void
jdoerfert
Summary

This was using its own, outdated list of possible captures. This was
at minimum not catching cmpxchg and addrspacecast captures.

One change is now any volatile access is treated as capturing. The
test coverage for this pass is quite inadequate, but this required
removing volatile in the lifetime capture test.

Also fixes some infrastructure issues to allow running just the IR
pass.

Fixes bug 42238.

Diff Detail

Event Timeline

arsenm created this revision.Jun 11 2019, 12:50 PM

Generally fine, three smaller comments though.

lib/CodeGen/StackProtector.cpp
179

VisitedPHIs is not needed anymore.

267

Are we sure we want return to capture?

And could you add the /* StoreCaptures */ comments so ppl know what the booleans are.

test/CodeGen/X86/stack-protector.ll
4091

Was the problem we assume volatile stores cause the addrs to escape (=be captured)?
If so, can we add a comment, maybe even a negative test (with the volatile accesses)?

arsenm marked 2 inline comments as done.Jun 11 2019, 4:58 PM
arsenm added inline comments.
lib/CodeGen/StackProtector.cpp
267

I don't know, I just figured it should be more conservative

test/CodeGen/X86/stack-protector.ll
4091

I think the interpretation of volatile capturing the address is absurd, but I don't care enough to fight that battle. The volatiles were irrelevant for the test here

jdoerfert added inline comments.Jun 11 2019, 5:32 PM
lib/CodeGen/StackProtector.cpp
267

I see. My reasoning was: The original code new about the existence of return and it did not consider it as "address taken" so, ...

test/CodeGen/X86/stack-protector.ll
4091

Fair point.

arsenm updated this revision to Diff 204207.Jun 11 2019, 7:18 PM

Make return not capture

jdoerfert accepted this revision.Jun 11 2019, 9:24 PM

This looks good to me (LGTM). Give it a bit of time though for people familiar with this code to take a look if they want.

test/CodeGen/X86/stack-protector.ll
4091

At least the change is now "documented" in this review ;)

This revision is now accepted and ready to land.Jun 11 2019, 9:24 PM
arsenm closed this revision.Jun 12 2019, 7:20 AM

r363169

ychen added a subscriber: ychen.Sep 12 2019, 5:16 PM