aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Debugify.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-12-14 22:13:40 -0500
committerNico Weber <thakis@chromium.org>2020-12-14 22:14:48 -0500
commit841f9c937f6e593c926a26aedf054436eb807fe6 (patch)
treefe4baeddc2ed91dbf96e8a5f8e78b2372fc1f890 /llvm/lib/Transforms/Utils/Debugify.cpp
parentda2551f3d191c1f0a32a3c9e3a26d2a236825871 (diff)
downloadllvm-841f9c937f6e593c926a26aedf054436eb807fe6.zip
llvm-841f9c937f6e593c926a26aedf054436eb807fe6.tar.gz
llvm-841f9c937f6e593c926a26aedf054436eb807fe6.tar.bz2
Revert "[MachineDebugify] Insert synthetic DBG_VALUE instructions"
This reverts commit 2a5675f11d3bc803a245c0e2a3b47491c8f8a065. The tests it adds fail: https://reviews.llvm.org/D78135#2453736
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Debugify.cpp40
1 files changed, 9 insertions, 31 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index cb6985f..f5fdeac 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -76,7 +76,6 @@ bool llvm::applyDebugifyMetadata(
DIBuilder DIB(M);
LLVMContext &Ctx = M.getContext();
- auto *Int32Ty = Type::getInt32Ty(Ctx);
// Get a DIType which corresponds to Ty.
DenseMap<uint64_t, DIType *> TypeCache;
@@ -101,7 +100,6 @@ bool llvm::applyDebugifyMetadata(
if (isFunctionSkipped(F))
continue;
- bool InsertedDbgVal = false;
auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
DISubprogram::DISPFlags SPFlags =
DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized;
@@ -110,23 +108,6 @@ bool llvm::applyDebugifyMetadata(
auto SP = DIB.createFunction(CU, F.getName(), F.getName(), File, NextLine,
SPType, NextLine, DINode::FlagZero, SPFlags);
F.setSubprogram(SP);
-
- // Helper that inserts a dbg.value before \p InsertBefore, copying the
- // location (and possibly the type, if it's non-void) from \p TemplateInst.
- auto insertDbgVal = [&](Instruction &TemplateInst,
- Instruction *InsertBefore) {
- std::string Name = utostr(NextVar++);
- Value *V = &TemplateInst;
- if (TemplateInst.getType()->isVoidTy())
- V = ConstantInt::get(Int32Ty, 0);
- const DILocation *Loc = TemplateInst.getDebugLoc().get();
- auto LocalVar = DIB.createAutoVariable(SP, Name, File, Loc->getLine(),
- getCachedDIType(V->getType()),
- /*AlwaysPreserve=*/true);
- DIB.insertDbgValueIntrinsic(V, LocalVar, DIB.createExpression(), Loc,
- InsertBefore);
- };
-
for (BasicBlock &BB : F) {
// Attach debug locations.
for (Instruction &I : BB)
@@ -161,19 +142,15 @@ bool llvm::applyDebugifyMetadata(
if (!isa<PHINode>(I) && !I->isEHPad())
InsertBefore = I->getNextNode();
- insertDbgVal(*I, InsertBefore);
- InsertedDbgVal = true;
+ 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,
+ InsertBefore);
}
}
- // Make sure we emit at least one dbg.value, otherwise MachineDebugify may
- // not have anything to work with as it goes about inserting DBG_VALUEs.
- // (It's common for MIR tests to be written containing skeletal IR with
- // empty functions -- we're still interested in debugifying the MIR within
- // those tests, and this helps with that.)
- if (DebugifyLevel == Level::LocationsAndVariables && !InsertedDbgVal) {
- auto *Term = findTerminatingInstruction(F.getEntryBlock());
- insertDbgVal(*Term, Term);
- }
if (ApplyToMF)
ApplyToMF(DIB, F);
DIB.finalizeSubprogram(SP);
@@ -182,9 +159,10 @@ bool llvm::applyDebugifyMetadata(
// Track the number of distinct lines and variables.
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.debugify");
+ auto *IntTy = Type::getInt32Ty(Ctx);
auto addDebugifyOperand = [&](unsigned N) {
NMD->addOperand(MDNode::get(
- Ctx, ValueAsMetadata::getConstant(ConstantInt::get(Int32Ty, N))));
+ Ctx, ValueAsMetadata::getConstant(ConstantInt::get(IntTy, N))));
};
addDebugifyOperand(NextLine - 1); // Original number of lines.
addDebugifyOperand(NextVar - 1); // Original number of variables.