[llvm] 8c2d2d9 - Preserve DbgLoc when DeadArgumentElimination rewrites a 'ret'.
Paul Robinson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 29 10:00:44 PDT 2020
Author: Paul Robinson
Date: 2020-05-29T10:00:33-07:00
New Revision: 8c2d2d971b2a221786e29380666d9900adeaee6a
URL: https://github.com/llvm/llvm-project/commit/8c2d2d971b2a221786e29380666d9900adeaee6a
DIFF: https://github.com/llvm/llvm-project/commit/8c2d2d971b2a221786e29380666d9900adeaee6a.diff
LOG: Preserve DbgLoc when DeadArgumentElimination rewrites a 'ret'.
Fixes PR46002.
Added:
Modified:
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/test/Transforms/DeadArgElim/dbginfo-preserve-dbgloc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 5dc1a6ff6327..00fcba40c36f 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -1056,7 +1056,8 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
}
// Replace the return instruction with one returning the new return
// value (possibly 0 if we became void).
- ReturnInst::Create(F->getContext(), RetVal, RI);
+ auto *NewRet = ReturnInst::Create(F->getContext(), RetVal, RI);
+ NewRet->setDebugLoc(RI->getDebugLoc());
BB.getInstList().erase(RI);
}
diff --git a/llvm/test/Transforms/DeadArgElim/dbginfo-preserve-dbgloc.ll b/llvm/test/Transforms/DeadArgElim/dbginfo-preserve-dbgloc.ll
index de5082d99bf5..ab7645ecf610 100644
--- a/llvm/test/Transforms/DeadArgElim/dbginfo-preserve-dbgloc.ll
+++ b/llvm/test/Transforms/DeadArgElim/dbginfo-preserve-dbgloc.ll
@@ -63,6 +63,7 @@ if.end3: ; preds = %if.end
cleanup: ; preds = %if.end3, %if.then2, %if.then
%retval.0 = phi i1 [ false, %if.then2 ], [ true, %if.end3 ], [ false, %if.then ]
+; CHECK: ret void, !dbg
ret i1 %retval.0, !dbg !56
}
More information about the llvm-commits
mailing list