]> granicus.if.org Git - llvm/commit
Re-land r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg...
authorReid Kleckner <rnk@google.com>
Thu, 21 Sep 2017 19:52:03 +0000 (19:52 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 21 Sep 2017 19:52:03 +0000 (19:52 +0000)
commit0e1ce271574ac0f9097000a08f13736c45352ced
tree9837a72ed491a1f347b31cf0724d3dd0ce97a749
parent1efe4ef3109d9ce19fd44e19ab47ca7fa61d4d20
Re-land r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare"

The fix is to avoid invalidating our insertion point in
replaceDbgDeclare:
     Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, InsertBefore);
+    if (DII == InsertBefore)
+      InsertBefore = &*std::next(InsertBefore->getIterator());
     DII->eraseFromParent();

I had to write a unit tests for this instead of a lit test because the
use list order matters in order to trigger the bug.

The reduced C test case for this was:
  void useit(int*);
  static inline void inlineme() {
    int x[2];
    useit(x);
  }
  void f() {
    inlineme();
    inlineme();
  }

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313905 91177308-0d34-0410-b5e6-96231b3b80d8
20 files changed:
docs/SourceLevelDebugging.rst
include/llvm/IR/IntrinsicInst.h
include/llvm/IR/Intrinsics.td
include/llvm/Transforms/Utils/Local.h
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/IR/DIBuilder.cpp
lib/IR/Verifier.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
lib/Transforms/Scalar/SROA.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp
test/DebugInfo/X86/dbg-addr-dse.ll [new file with mode: 0644]
test/DebugInfo/X86/dbg-addr.ll [new file with mode: 0644]
test/DebugInfo/X86/sroasplit-5.ll
test/DebugInfo/X86/sroasplit-dbg-declare.ll [new file with mode: 0644]
test/Transforms/Mem2Reg/dbg-addr-inline-dse.ll [new file with mode: 0644]
test/Transforms/Mem2Reg/dbg-addr.ll [new file with mode: 0644]
test/Transforms/SROA/dbg-addr-diamond.ll [new file with mode: 0644]
unittests/Transforms/Utils/CMakeLists.txt
unittests/Transforms/Utils/Local.cpp