Preserve DbgLoc when DeadArgumentElimination rewrites a 'ret'.

Fixes PR46002.
This commit is contained in:
Paul Robinson 2020-05-28 13:19:52 -07:00
parent a01c0049b1
commit 8c2d2d971b
2 changed files with 3 additions and 1 deletions

View File

@ -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);
}

View File

@ -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
}