This is an archive of the discontinued LLVM Phabricator instance.

Teach SROA to handle allocas with more than one dbg.declare.
ClosedPublic

Authored by aprantl on Aug 3 2020, 4:18 PM.

Details

Summary

It is technically legal for optimizations to create an alloca that is
used by more than one dbg.declare, if one or both of them are inlined
instances of aliasing variables.

Diff Detail

Event Timeline

aprantl created this revision.Aug 3 2020, 4:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2020, 4:18 PM
aprantl requested review of this revision.Aug 3 2020, 4:18 PM
compnerd accepted this revision.Aug 3 2020, 5:47 PM
compnerd added inline comments.
llvm/lib/Transforms/Scalar/SROA.cpp
4534

I wonder if its better to define a helper equality check function:

auto IdenticalInlinedFragment = [](const DbgVariableInstric *LHS, const DbgVariableIntrinsic *RHS) -> Bool {
  return LHS->getVariable() == RHS->getVariable() &&
    LHS->getDebugLoc()->getInlinedAt() == RHS->getDebugLoc()->getInlinedAt();
}
This revision is now accepted and ready to land.Aug 3 2020, 5:47 PM
davide accepted this revision.Aug 4 2020, 1:52 PM

LGTM with Saleem's comment addressed.