[PATCH] D81939: [deadargelim] Attach dbg info to the insert/extractvalue instructions
Djordje Todorovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 01:35:23 PDT 2020
djtodoro updated this revision to Diff 274711.
djtodoro added a comment.
- Check the actual instructions instead of final debugify result in the test provided
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81939/new/
https://reviews.llvm.org/D81939
Files:
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/test/Transforms/DeadArgElim/multdeadretval.ll
Index: llvm/test/Transforms/DeadArgElim/multdeadretval.ll
===================================================================
--- llvm/test/Transforms/DeadArgElim/multdeadretval.ll
+++ llvm/test/Transforms/DeadArgElim/multdeadretval.ll
@@ -4,6 +4,25 @@
; any remaining dead stuff.
; RUN: opt < %s -deadargelim -instcombine -dce -S | not grep i16
+; RUN: opt < %s -enable-debugify=synthetic -deadargelim -S 2>&1 \
+; RUN: | FileCheck %s -check-prefix=DEBUG
+
+; Check that every instruction inserted by -deadargelim has a debug location.
+; DEBUG: %oldret = extractvalue { i16, i32 } %B, 1, !dbg
+; DEBUG: %oldret = extractvalue { i32, i16 } %B, 0, !dbg
+; DEBUG: %oldret = insertvalue { i16, i32 } undef, i32 %ret, 1, !dbg
+; DEBUG: %oldret = extractvalue { i32, i32, i16 } %C, 0, !dbg
+; DEBUG: %newret = insertvalue { i32, i32 } undef, i32 %oldret, 0, !dbg
+; DEBUG: %oldret1 = extractvalue { i32, i32, i16 } %C, 1, !dbg
+; DEBUG: %newret2 = insertvalue { i32, i32 } %newret, i32 %oldret1, 1, !dbg
+; DEBUG: %oldret = extractvalue { { i32 }, { i16, i16 } } %C, 0, !dbg
+; DEBUG: %oldret = insertvalue { i32, i16 } undef, i32 %ret, 0, !dbg
+; DEBUG: %newret = extractvalue { i32, i32 } %ret1, 0, !dbg
+; DEBUG: %oldret1 = insertvalue { i32, i32, i16 } undef, i32 %newret, 0, !dbg
+; DEBUG: %newret2 = extractvalue { i32, i32 } %ret1, 1, !dbg
+; DEBUG: %oldret3 = insertvalue { i32, i32, i16 } %oldret1, i32 %newret2, 1, !dbg
+; DEBUG: %oldret4 = insertvalue { { i32 }, { i16, i16 } } undef, { i32 } %ret2, 0, !dbg
+
define internal {i16, i32} @test(i16 %DEADARG) {
%A = insertvalue {i16,i32} undef, i16 1, 0
%B = insertvalue {i16,i32} %A, i32 1001, 1
Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
===================================================================
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -967,16 +967,19 @@
for (unsigned Ri = 0; Ri != RetCount; ++Ri)
if (NewRetIdxs[Ri] != -1) {
Value *V;
- if (RetTypes.size() > 1)
+ if (RetTypes.size() > 1) {
// We are still returning a struct, so extract the value from our
// return value
V = ExtractValueInst::Create(NewCB, NewRetIdxs[Ri], "newret",
InsertPt);
- else
+ cast<Instruction>(V)->setDebugLoc(InsertPt->getDebugLoc());
+ } else {
// We are now returning a single element, so just insert that
V = NewCB;
+ }
// Insert the value at the old position
RetVal = InsertValueInst::Create(RetVal, V, Ri, "oldret", InsertPt);
+ cast<Instruction>(RetVal)->setDebugLoc(InsertPt->getDebugLoc());
}
// Now, replace all uses of the old call instruction with the return
// struct we built
@@ -1035,12 +1038,14 @@
if (NewRetIdxs[RetI] != -1) {
ExtractValueInst *EV =
ExtractValueInst::Create(OldRet, RetI, "oldret", RI);
+ EV->setDebugLoc(RI->getDebugLoc());
if (RetTypes.size() > 1) {
// We're still returning a struct, so reinsert the value into
// our new return value at the new index
RetVal = InsertValueInst::Create(RetVal, EV, NewRetIdxs[RetI],
"newret", RI);
+ cast<Instruction>(RetVal)->setDebugLoc(RI->getDebugLoc());
} else {
// We are now only returning a simple value, so just return the
// extracted value.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81939.274711.patch
Type: text/x-patch
Size: 3715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200701/385a8d8b/attachment-0001.bin>
More information about the llvm-commits
mailing list