This is an archive of the discontinued LLVM Phabricator instance.

[GWP-ASan] Change unreachable -> trap to work around DCE bug.
ClosedPublic

Authored by hctim on Jul 8 2021, 12:52 PM.

Details

Summary

trapOnAddress is designed to SEGV on a specific address. Unfortunately,
with an IR change, __builtin_unreachable() ends up doing DCE on things
that have side effects, like the load that causes the trap.

Change to __builtin_trap() to avoid the optimisation.

Root cause is still an LLVM bug, and tracked in
https://bugs.llvm.org/show_bug.cgi?id=47480.

Diff Detail

Event Timeline

hctim requested review of this revision.Jul 8 2021, 12:52 PM
hctim created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2021, 12:52 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
lebedev.ri added inline comments.Jul 8 2021, 1:01 PM
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
258–265

Not commenting on the rest of the comment, but volatile *store*.

eugenis accepted this revision.Jul 8 2021, 1:05 PM

LGTM

This revision is now accepted and ready to land.Jul 8 2021, 1:05 PM
hctim marked an inline comment as done.Jul 8 2021, 1:05 PM
hctim added inline comments.
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
258–265

fixed, thanks

hctim updated this revision to Diff 357335.Jul 8 2021, 1:06 PM
hctim marked an inline comment as done.

/s/load/store

This revision was landed with ongoing or failed builds.Jul 8 2021, 1:07 PM
This revision was automatically updated to reflect the committed changes.