Skip to content

Commit 9eb0020

Browse files
jmorsenikic
andauthored
[DebugInfo][RemoveDIs] Remove a swathe of debug-intrinsic code (#144389)
Seeing how we can't generate any debug intrinsics any more: delete a variety of codepaths where they're handled. For the most part these are plain deletions, in others I've tweaked comments to remain coherent, or added a type to (what was) type-generic-lambdas. This isn't all the DbgInfoIntrinsic call sites but it's most of the simple scenarios. Co-authored-by: Nikita Popov <github@npopov.com>
1 parent 7ec103a commit 9eb0020

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+104
-400
lines changed

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,6 @@ struct IRInstructionMapper {
545545
// dependent.
546546
InstrType visitLandingPadInst(LandingPadInst &LPI) { return Illegal; }
547547
InstrType visitFuncletPadInst(FuncletPadInst &FPI) { return Illegal; }
548-
// DebugInfo should be included in the regions, but should not be
549-
// analyzed for similarity as it has no bearing on the outcome of the
550-
// program.
551-
InstrType visitDbgInfoIntrinsic(DbgInfoIntrinsic &DII) { return Invisible; }
552548
InstrType visitIntrinsicInst(IntrinsicInst &II) {
553549
// These are disabled due to complications in the CodeExtractor when
554550
// outlining these instructions. For instance, It is unclear what we

llvm/include/llvm/Analysis/PtrUseVisitor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ class PtrUseVisitor : protected InstVisitor<DerivedT>,
285285

286286
// No-op intrinsics which we know don't escape the pointer to logic in
287287
// some other function.
288-
void visitDbgInfoIntrinsic(DbgInfoIntrinsic &I) {}
289288
void visitMemIntrinsic(MemIntrinsic &I) {}
290289
void visitIntrinsicInst(IntrinsicInst &II) {
291290
switch (II.getIntrinsicID()) {

llvm/include/llvm/IR/InstVisitor.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,6 @@ class InstVisitor {
199199
RetTy visitCatchPadInst(CatchPadInst &I) { DELEGATE(FuncletPadInst); }
200200
RetTy visitFreezeInst(FreezeInst &I) { DELEGATE(Instruction); }
201201

202-
// Handle the special intrinsic instruction classes.
203-
RetTy visitDbgDeclareInst(DbgDeclareInst &I) { DELEGATE(DbgVariableIntrinsic);}
204-
RetTy visitDbgValueInst(DbgValueInst &I) { DELEGATE(DbgVariableIntrinsic);}
205-
RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I)
206-
{ DELEGATE(DbgInfoIntrinsic);}
207-
RetTy visitDbgLabelInst(DbgLabelInst &I) { DELEGATE(DbgInfoIntrinsic);}
208-
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I){ DELEGATE(IntrinsicInst); }
209202
RetTy visitMemSetInst(MemSetInst &I) { DELEGATE(MemIntrinsic); }
210203
RetTy visitMemSetPatternInst(MemSetPatternInst &I) {
211204
DELEGATE(IntrinsicInst);
@@ -286,9 +279,6 @@ class InstVisitor {
286279
if (const Function *F = I.getCalledFunction()) {
287280
switch (F->getIntrinsicID()) {
288281
default: DELEGATE(IntrinsicInst);
289-
case Intrinsic::dbg_declare: DELEGATE(DbgDeclareInst);
290-
case Intrinsic::dbg_value: DELEGATE(DbgValueInst);
291-
case Intrinsic::dbg_label: DELEGATE(DbgLabelInst);
292282
case Intrinsic::memcpy:
293283
case Intrinsic::memcpy_inline:
294284
DELEGATE(MemCpyInst);

llvm/include/llvm/Transforms/Utils/Local.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,9 @@ handleUnreachableTerminator(Instruction *I,
394394
SmallVectorImpl<Value *> &PoisonedValues);
395395

396396
/// Remove all instructions from a basic block other than its terminator
397-
/// and any present EH pad instructions. Returns a pair where the first element
398-
/// is the number of instructions (excluding debug info intrinsics) that have
399-
/// been removed, and the second element is the number of debug info intrinsics
397+
/// and any present EH pad instructions. Returns the number of instructions
400398
/// that have been removed.
401-
LLVM_ABI std::pair<unsigned, unsigned>
402-
removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
399+
LLVM_ABI unsigned removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
403400

404401
/// Insert an unreachable instruction before the specified
405402
/// instruction, making it and the rest of the code in the block dead.

llvm/lib/Analysis/AliasSetTracker.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,6 @@ void AliasSetTracker::add(AnyMemTransferInst *MTI) {
343343
}
344344

345345
void AliasSetTracker::addUnknown(Instruction *Inst) {
346-
if (isa<DbgInfoIntrinsic>(Inst))
347-
return; // Ignore DbgInfo Intrinsics.
348-
349346
if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
350347
// These intrinsics will show up as affecting memory, but they are just
351348
// markers.

llvm/lib/Analysis/CallGraph.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ CallGraph::CallGraph(Module &M)
3434
CallsExternalNode(std::make_unique<CallGraphNode>(this, nullptr)) {
3535
// Add every interesting function to the call graph.
3636
for (Function &F : M)
37-
if (!isDbgInfoIntrinsic(F.getIntrinsicID()))
38-
addToCallGraph(&F);
37+
addToCallGraph(&F);
3938
}
4039

4140
CallGraph::CallGraph(CallGraph &&Arg)
@@ -101,7 +100,7 @@ void CallGraph::populateCallGraphNode(CallGraphNode *Node) {
101100
const Function *Callee = Call->getCalledFunction();
102101
if (!Callee)
103102
Node->addCalledFunction(Call, CallsExternalNode.get());
104-
else if (!isDbgInfoIntrinsic(Callee->getIntrinsicID()))
103+
else
105104
Node->addCalledFunction(Call, getOrInsertFunction(Callee));
106105

107106
// Add reference to callback functions.

llvm/lib/Analysis/DemandedBits.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ using namespace llvm::PatternMatch;
4646
#define DEBUG_TYPE "demanded-bits"
4747

4848
static bool isAlwaysLive(Instruction *I) {
49-
return I->isTerminator() || isa<DbgInfoIntrinsic>(I) || I->isEHPad() ||
50-
I->mayHaveSideEffects();
49+
return I->isTerminator() || I->isEHPad() || I->mayHaveSideEffects();
5150
}
5251

5352
void DemandedBits::determineLiveOperandBits(

llvm/lib/Analysis/Loads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Align Alignment, const APInt &S
434434
// If we see a free or a call which may write to memory (i.e. which might do
435435
// a free) the pointer could be marked invalid.
436436
if (isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
437-
!isa<LifetimeIntrinsic>(BBI) && !isa<DbgInfoIntrinsic>(BBI))
437+
!isa<LifetimeIntrinsic>(BBI))
438438
return false;
439439

440440
Value *AccessedPtr;

llvm/lib/Analysis/MemoryDependenceAnalysis.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ MemDepResult MemoryDependenceResults::getCallDependencyFrom(
188188
// Walk backwards through the block, looking for dependencies.
189189
while (ScanIt != BB->begin()) {
190190
Instruction *Inst = &*--ScanIt;
191-
// Debug intrinsics don't cause dependences and should not affect Limit
192-
if (isa<DbgInfoIntrinsic>(Inst))
193-
continue;
194191

195192
// Limit the amount of scanning we do so we don't end up with quadratic
196193
// running time on extreme testcases.
@@ -432,11 +429,6 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
432429
while (ScanIt != BB->begin()) {
433430
Instruction *Inst = &*--ScanIt;
434431

435-
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst))
436-
// Debug intrinsics don't (and can't) cause dependencies.
437-
if (isa<DbgInfoIntrinsic>(II))
438-
continue;
439-
440432
// Limit the amount of scanning we do so we don't end up with quadratic
441433
// running time on extreme testcases.
442434
--*Limit;

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7846,8 +7846,6 @@ bool llvm::isGuaranteedToTransferExecutionToSuccessor(
78467846
iterator_range<BasicBlock::const_iterator> Range, unsigned ScanLimit) {
78477847
assert(ScanLimit && "scan limit must be non-zero");
78487848
for (const Instruction &I : Range) {
7849-
if (isa<DbgInfoIntrinsic>(I))
7850-
continue;
78517849
if (--ScanLimit == 0)
78527850
return false;
78537851
if (!isGuaranteedToTransferExecutionToSuccessor(&I))
@@ -8050,8 +8048,6 @@ static bool programUndefinedIfUndefOrPoison(const Value *V,
80508048
// well-defined operands.
80518049

80528050
for (const auto &I : make_range(Begin, End)) {
8053-
if (isa<DbgInfoIntrinsic>(I))
8054-
continue;
80558051
if (--ScanLimit == 0)
80568052
break;
80578053

@@ -8076,8 +8072,6 @@ static bool programUndefinedIfUndefOrPoison(const Value *V,
80768072

80778073
while (true) {
80788074
for (const auto &I : make_range(Begin, End)) {
8079-
if (isa<DbgInfoIntrinsic>(I))
8080-
continue;
80818075
if (--ScanLimit == 0)
80828076
return false;
80838077
if (mustTriggerUB(&I, YieldsPoison))

0 commit comments

Comments
 (0)