This is an archive of the discontinued LLVM Phabricator instance.

ASAN: Provide reliable debug info for local variables at -O0.
ClosedPublic

Authored by aprantl on Dec 8 2017, 2:36 PM.

Details

Summary

The function stack poisioner conditionally stores local variables
either in an alloca or in malloc'ated memory, which has the
unfortunate side-effect, that the actual address of the variable is
only materialized when the variable is accessed, which means that
those variables are mostly invisible to the debugger even when
compiling without optimizations.

This patch stores the address of the local stack base into an alloca,
which can be referred to by the debug info and is available throughout
the function. This adds one extra pointer-sized alloca to each stack
frame where the transformation is applied to (but mem2reg can optimize
it away again when optimizations are enabled, yielding roughly the
same debug info quality as before in optimized code).

rdar://problem/30433661

Diff Detail

Repository
rL LLVM

Event Timeline

aprantl created this revision.Dec 8 2017, 2:36 PM
davide added a subscriber: davide.Dec 9 2017, 12:40 PM
eugenis accepted this revision.Dec 11 2017, 9:57 AM
eugenis added inline comments.
lib/Transforms/Instrumentation/AddressSanitizer.cpp
2913 ↗(On Diff #126211)

Could this be expressed in less lines of code by creating an AllocaInst directly, without saving and restoring IRBuilder state?

This revision is now accepted and ready to land.Dec 11 2017, 9:57 AM
This revision was automatically updated to reflect the committed changes.
aprantl added inline comments.Dec 11 2017, 12:44 PM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
2913 ↗(On Diff #126211)

Done.