1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[Debugify] Add debug intrinsics before terminating musttail calls

After r333856, opt -debugify would just stop emitting debug value
intrinsics after encountering a musttail call. This wasn't sufficient to
avoid verifier failures.

Debug value intrinicss for all instructions preceding a musttail call
must also be emitted before the musttail call.

llvm-svn: 333866
This commit is contained in:
Vedant Kumar 2018-06-04 03:33:01 +00:00
parent 8b2aa5885a
commit 04624fb1e5
2 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,5 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
; RUN: opt -debugify-each -instcombine -S < %s | FileCheck %s
; These are both direct calls, but make sure instcombine leaves the casts
; alone.

View File

@ -91,28 +91,32 @@ bool applyDebugifyMetadata(Module &M,
if (BB.isEHPad())
continue;
// Debug values must be inserted before a musttail call (if one is
// present), or before the block terminator otherwise.
Instruction *LastInst = BB.getTerminatingMustTailCall();
if (!LastInst)
LastInst = BB.getTerminator();
// Attach debug values.
for (Instruction &I : BB) {
for (auto It = BB.begin(), End = LastInst->getIterator(); It != End;
++It) {
Instruction &I = *It;
// Skip void-valued instructions.
if (I.getType()->isVoidTy())
continue;
// Skip the terminator instruction and any just-inserted intrinsics.
if (isa<TerminatorInst>(&I) || isa<DbgValueInst>(&I))
// Skip any just-inserted intrinsics.
if (isa<DbgValueInst>(&I))
break;
// Don't insert instructions after a musttail call.
if (auto *Call = dyn_cast<CallInst>(&I))
if (Call->isMustTailCall())
break;
std::string Name = utostr(NextVar++);
const DILocation *Loc = I.getDebugLoc().get();
auto LocalVar = DIB.createAutoVariable(SP, Name, File, Loc->getLine(),
getCachedDIType(I.getType()),
/*AlwaysPreserve=*/true);
DIB.insertDbgValueIntrinsic(&I, LocalVar, DIB.createExpression(), Loc,
BB.getTerminator());
LastInst);
}
}
DIB.finalizeSubprogram(SP);