Skip to content

Commit 589fc62

Browse files
SLTozertomtor
authored andcommitted
[DLCov][NFC] Annotate intentionally-blank DebugLocs in existing code (llvm#136192)
Following the work in PR llvm#107279, this patch applies the annotative DebugLocs, which indicate that a particular instruction is intentionally missing a location for a given reason, to existing sites in the compiler where their conditions apply. This is NFC in ordinary LLVM builds (each function `DebugLoc::getFoo()` is inlined as `DebugLoc()`), but marks the instruction in coverage-tracking builds so that it will be ignored by Debugify, allowing only real errors to be reported. From a developer standpoint, it also communicates the intentionality and reason for a missing DebugLoc. Some notes for reviewers: - The difference between `I->dropLocation()` and `I->setDebugLoc(DebugLoc::getDropped())` is that the former _may_ decide to keep some debug info alive, while the latter will always be empty; in this patch, I always used the latter (even if the former could technically be correct), because the former could result in some (barely) different output, and I'd prefer to keep this patch purely NFC. - I've generally documented the uses of `DebugLoc::getUnknown()`, with the exception of the vectorizers - in summary, they are a huge cause of dropped source locations, and I don't have the time or the domain knowledge currently to solve that, so I've plastered it all over them as a form of "fixme".
1 parent 33ecdbc commit 589fc62

19 files changed

+101
-37
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,14 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
14941494
// FIXME: Pass Global's alignment when globals have alignment
14951495
AllocaInst *Alloca = new AllocaInst(ElemTy, DL.getAllocaAddrSpace(),
14961496
nullptr, GV->getName(), FirstI);
1497-
if (!isa<UndefValue>(GV->getInitializer()))
1498-
new StoreInst(GV->getInitializer(), Alloca, FirstI);
1497+
Alloca->setDebugLoc(DebugLoc::getCompilerGenerated());
1498+
if (!isa<UndefValue>(GV->getInitializer())) {
1499+
auto *SI = new StoreInst(GV->getInitializer(), Alloca, FirstI);
1500+
// FIXME: We're localizing a global and creating a store instruction for
1501+
// the initial value of that global. Could we logically use the global
1502+
// variable's (if one exists) line for this?
1503+
SI->setDebugLoc(DebugLoc::getCompilerGenerated());
1504+
}
14991505

15001506
GV->replaceAllUsesWith(Alloca);
15011507
GV->eraseFromParent();

llvm/lib/Transforms/IPO/IROutliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static void moveFunctionData(Function &Old, Function &New,
730730
// other outlined instructions.
731731
if (!isa<CallInst>(&Val)) {
732732
// Remove the debug information for outlined functions.
733-
Val.setDebugLoc(DebugLoc());
733+
Val.setDebugLoc(DebugLoc::getDropped());
734734

735735
// Loop info metadata may contain line locations. Update them to have no
736736
// value in the new subprogram since the outlined code could be from
@@ -1864,7 +1864,7 @@ replaceArgumentUses(OutlinableRegion &Region,
18641864
Value *ValueOperand = SI->getValueOperand();
18651865

18661866
StoreInst *NewI = cast<StoreInst>(I->clone());
1867-
NewI->setDebugLoc(DebugLoc());
1867+
NewI->setDebugLoc(DebugLoc::getDropped());
18681868
BasicBlock *OutputBB = VBBIt->second;
18691869
NewI->insertInto(OutputBB, OutputBB->end());
18701870
LLVM_DEBUG(dbgs() << "Move store for instruction " << *I << " to "

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,14 @@ Instruction *InstCombinerImpl::foldPHIArgZextsIntoPHI(PHINode &Phi) {
870870
NewPhi->addIncoming(NewIncoming[I], Phi.getIncomingBlock(I));
871871

872872
InsertNewInstBefore(NewPhi, Phi.getIterator());
873-
return CastInst::CreateZExtOrBitCast(NewPhi, Phi.getType());
873+
auto *CI = CastInst::CreateZExtOrBitCast(NewPhi, Phi.getType());
874+
875+
// We use a dropped location here because the new ZExt is necessarily a merge
876+
// of ZExtInsts and at least one constant from incoming branches; the presence
877+
// of the constant means we have no viable DebugLoc from that branch, and
878+
// therefore we must use a dropped location.
879+
CI->setDebugLoc(DebugLoc::getDropped());
880+
return CI;
874881
}
875882

876883
/// If all operands to a PHI node are the same "unary" operator and they all are

llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
432432
BasicBlock *NewUnreachableBB =
433433
BasicBlock::Create(BB->getContext(), "default.unreachable",
434434
BB->getParent(), DefaultDest);
435-
new UnreachableInst(BB->getContext(), NewUnreachableBB);
435+
auto *UI = new UnreachableInst(BB->getContext(), NewUnreachableBB);
436+
UI->setDebugLoc(DebugLoc::getTemporary());
436437

437438
DefaultDest->removePredecessor(BB);
438439
SI->setDefaultDest(NewUnreachableBB);

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,9 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
15061506
auto *NewRHS = CastInst::Create(
15071507
Instruction::Trunc, RHS, LHSOp->getType(), "",
15081508
L->getLoopPreheader()->getTerminator()->getIterator());
1509+
// NewRHS is an operation that has been hoisted out of the loop, and
1510+
// therefore should have a dropped location.
1511+
NewRHS->setDebugLoc(DebugLoc::getDropped());
15091512
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
15101513
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
15111514
// Samesign flag cannot be preserved after narrowing the compare.

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3001,8 +3001,10 @@ bool JumpThreadingPass::tryToUnfoldSelectInCurrBB(BasicBlock *BB) {
30013001
continue;
30023002
// Expand the select.
30033003
Value *Cond = SI->getCondition();
3004-
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI))
3004+
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI)) {
30053005
Cond = new FreezeInst(Cond, "cond.fr", SI->getIterator());
3006+
cast<FreezeInst>(Cond)->setDebugLoc(DebugLoc::getTemporary());
3007+
}
30063008
MDNode *BranchWeights = getBranchWeightMDNode(*SI);
30073009
Instruction *Term =
30083010
SplitBlockAndInsertIfThen(Cond, SI, false, BranchWeights);

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ bool llvm::promoteLoopAccessesToScalars(
22482248
if (SawUnorderedAtomic)
22492249
PreheaderLoad->setOrdering(AtomicOrdering::Unordered);
22502250
PreheaderLoad->setAlignment(Alignment);
2251-
PreheaderLoad->setDebugLoc(DebugLoc());
2251+
PreheaderLoad->setDebugLoc(DebugLoc::getDropped());
22522252
if (AATags && LoadIsGuaranteedToExecute)
22532253
PreheaderLoad->setAAMetadata(AATags);
22542254

@@ -2808,6 +2808,7 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
28082808
auto *NewBO =
28092809
BinaryOperator::Create(Ins->getOpcode(), LHS, RHS,
28102810
Ins->getName() + ".reass", Ins->getIterator());
2811+
NewBO->setDebugLoc(DebugLoc::getDropped());
28112812
NewBO->copyIRFlags(Ins);
28122813
if (VariantOp == Ins)
28132814
VariantOp = NewBO;
@@ -2864,6 +2865,7 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
28642865

28652866
auto *NewBO = BinaryOperator::Create(
28662867
Opcode, LV, Inv, BO->getName() + ".reass", BO->getIterator());
2868+
NewBO->setDebugLoc(DebugLoc::getDropped());
28672869

28682870
if (Opcode == Instruction::FAdd || Opcode == Instruction::FMul) {
28692871
// Intersect FMF flags for FADD and FMUL.

llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,15 @@ class LoadEliminationForLoop {
442442
assert(PH && "Preheader should exist!");
443443
Value *InitialPtr = SEE.expandCodeFor(PtrSCEV->getStart(), Ptr->getType(),
444444
PH->getTerminator());
445-
Value *Initial =
445+
Instruction *Initial =
446446
new LoadInst(Cand.Load->getType(), InitialPtr, "load_initial",
447447
/* isVolatile */ false, Cand.Load->getAlign(),
448448
PH->getTerminator()->getIterator());
449449
// We don't give any debug location to Initial, because it is inserted
450450
// into the loop's preheader. A debug location inside the loop will cause
451451
// a misleading stepping when debugging. The test update-debugloc-store
452452
// -forwarded.ll checks this.
453+
Initial->setDebugLoc(DebugLoc::getDropped());
453454

454455
PHINode *PHI = PHINode::Create(Initial->getType(), 2, "store_forwarded");
455456
PHI->insertBefore(L->getHeader()->begin());

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static void buildPartialUnswitchConditionalBranch(
274274
BasicBlock &UnswitchedSucc, BasicBlock &NormalSucc, bool InsertFreeze,
275275
const Instruction *I, AssumptionCache *AC, const DominatorTree &DT) {
276276
IRBuilder<> IRB(&BB);
277+
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());
277278

278279
SmallVector<Value *> FrozenInvariants;
279280
for (Value *Inv : Invariants) {
@@ -330,6 +331,7 @@ static void buildPartialInvariantUnswitchConditionalBranch(
330331
}
331332

332333
IRBuilder<> IRB(&BB);
334+
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());
333335
Value *Cond = VMap[ToDuplicate[0]];
334336
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
335337
Direction ? &NormalSucc : &UnswitchedSucc);
@@ -2369,6 +2371,7 @@ static void unswitchNontrivialInvariants(
23692371
// BI (`dyn_cast<BranchInst>(TI)`) is an in-loop instruction hoisted
23702372
// out of the loop.
23712373
Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator());
2374+
cast<Instruction>(Cond)->setDebugLoc(DebugLoc::getDropped());
23722375
}
23732376
BI->setCondition(Cond);
23742377
DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});

llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ void TailRecursionEliminator::createTailRecurseLoopHeader(CallInst *CI) {
515515
BasicBlock *NewEntry = BasicBlock::Create(F.getContext(), "", &F, HeaderBB);
516516
NewEntry->takeName(HeaderBB);
517517
HeaderBB->setName("tailrecurse");
518-
BranchInst::Create(HeaderBB, NewEntry);
518+
auto *BI = BranchInst::Create(HeaderBB, NewEntry);
519+
BI->setDebugLoc(DebugLoc::getCompilerGenerated());
519520
// If the new branch preserves the debug location of CI, it could result in
520521
// misleading stepping, if CI is located in a conditional branch.
521522
// So, here we don't give any debug location to the new branch.
@@ -801,6 +802,7 @@ void TailRecursionEliminator::cleanupAndFinalize() {
801802
SelectInst *SI =
802803
SelectInst::Create(RetKnownPN, RetPN, RI->getOperand(0),
803804
"current.ret.tr", RI->getIterator());
805+
SI->setDebugLoc(DebugLoc::getCompilerGenerated());
804806
RetSelects.push_back(SI);
805807
RI->setOperand(0, SI);
806808
}

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
17751775
AllocaInst *NewAlloca =
17761776
new AllocaInst(ByValType, Arg->getType()->getPointerAddressSpace(),
17771777
nullptr, Alignment, Arg->getName());
1778+
NewAlloca->setDebugLoc(DebugLoc::getCompilerGenerated());
17781779
NewAlloca->insertBefore(Caller->begin()->begin());
17791780
IFI.StaticAllocas.push_back(NewAlloca);
17801781

@@ -3258,6 +3259,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
32583259

32593260
// Add an unconditional branch to make this look like the CallInst case...
32603261
CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), CB.getIterator());
3262+
// We intend to replace this DebugLoc with another later.
3263+
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getTemporary());
32613264

32623265
// Split the basic block. This guarantees that no PHI nodes will have to be
32633266
// updated due to new incoming edges, and make the invoke case more
@@ -3359,6 +3362,12 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
33593362
Returns[0]->eraseFromParent();
33603363
ReturnBB->eraseFromParent();
33613364
} else if (!CB.use_empty()) {
3365+
// In this case there are no returns to use, so there is no clear source
3366+
// location for the "return".
3367+
// FIXME: It may be correct to use the scope end line of the function here,
3368+
// since this likely means we are falling out of the function.
3369+
if (CreatedBranchToNormalDest)
3370+
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getUnknown());
33623371
// No returns, but something is using the return value of the call. Just
33633372
// nuke the result.
33643373
CB.replaceAllUsesWith(PoisonValue::get(CB.getType()));

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3127,7 +3127,8 @@ static bool markAliveBlocks(Function &F,
31273127
BasicBlock *UnreachableNormalDest = BasicBlock::Create(
31283128
Ctx, OrigNormalDest->getName() + ".unreachable",
31293129
II->getFunction(), OrigNormalDest);
3130-
new UnreachableInst(Ctx, UnreachableNormalDest);
3130+
auto *UI = new UnreachableInst(Ctx, UnreachableNormalDest);
3131+
UI->setDebugLoc(DebugLoc::getTemporary());
31313132
II->setNormalDest(UnreachableNormalDest);
31323133
if (DTU)
31333134
DTU->applyUpdates(

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
348348
NewUnreachableBB =
349349
BasicBlock::Create(DefaultDest->getContext(), "default.unreachable",
350350
DefaultDest->getParent(), DefaultDest);
351-
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
351+
auto *UI =
352+
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
353+
UI->setDebugLoc(DebugLoc::getTemporary());
352354
}
353355

354356
DefaultDest->removePredecessor(BB);

llvm/lib/Transforms/Utils/SSAUpdater.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ class SSAUpdaterTraits<SSAUpdater> {
318318
SSAUpdater *Updater) {
319319
PHINode *PHI =
320320
PHINode::Create(Updater->ProtoType, NumPreds, Updater->ProtoName);
321+
// FIXME: Ordinarily we don't care about or try to assign DebugLocs to PHI
322+
// nodes, but loop optimizations may try to use a PHI node as a DebugLoc
323+
// source (e.g. if this is an induction variable), and it's not clear what
324+
// location we could attach here, so mark this unknown for now.
325+
PHI->setDebugLoc(DebugLoc::getUnknown());
321326
PHI->insertBefore(BB->begin());
322327
return PHI;
323328
}

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ static void cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
11371137
// branch, drop it. When we fold the bonus instructions we want to make
11381138
// sure we reset their debug locations in order to avoid stepping on
11391139
// dead code caused by folding dead branches.
1140-
NewBonusInst->setDebugLoc(DebugLoc());
1140+
NewBonusInst->setDebugLoc(DebugLoc::getDropped());
11411141
} else if (const DebugLoc &DL = NewBonusInst->getDebugLoc()) {
11421142
mapAtomInstance(DL, VMap);
11431143
}
@@ -2821,7 +2821,8 @@ static void mergeCompatibleInvokesImpl(ArrayRef<InvokeInst *> Invokes,
28212821
// so just form a new block with unreachable terminator.
28222822
BasicBlock *MergedNormalDest = BasicBlock::Create(
28232823
Ctx, II0BB->getName() + ".cont", Func, InsertBeforeBlock);
2824-
new UnreachableInst(Ctx, MergedNormalDest);
2824+
auto *UI = new UnreachableInst(Ctx, MergedNormalDest);
2825+
UI->setDebugLoc(DebugLoc::getTemporary());
28252826
MergedInvoke->setNormalDest(MergedNormalDest);
28262827
}
28272828

@@ -3389,7 +3390,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
33893390
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
33903391
// Don't update the DILocation of dbg.assign intrinsics.
33913392
if (!isa<DbgAssignIntrinsic>(&I))
3392-
I.setDebugLoc(DebugLoc());
3393+
I.setDebugLoc(DebugLoc::getDropped());
33933394
}
33943395
I.dropUBImplyingAttrsAndMetadata();
33953396

@@ -5707,7 +5708,8 @@ static void createUnreachableSwitchDefault(SwitchInst *Switch,
57075708
BasicBlock *NewDefaultBlock = BasicBlock::Create(
57085709
BB->getContext(), BB->getName() + ".unreachabledefault", BB->getParent(),
57095710
OrigDefaultBlock);
5710-
new UnreachableInst(Switch->getContext(), NewDefaultBlock);
5711+
auto *UI = new UnreachableInst(Switch->getContext(), NewDefaultBlock);
5712+
UI->setDebugLoc(DebugLoc::getTemporary());
57115713
Switch->setDefaultDest(&*NewDefaultBlock);
57125714
if (DTU) {
57135715
SmallVector<DominatorTree::UpdateType, 2> Updates;

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class VPBuilder {
153153
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
154154
Instruction *Inst = nullptr,
155155
const Twine &Name = "") {
156-
DebugLoc DL;
156+
DebugLoc DL = DebugLoc::getUnknown();
157157
if (Inst)
158158
DL = Inst->getDebugLoc();
159159
VPInstruction *NewVPInst = createInstruction(Opcode, Operands, DL, Name);
@@ -165,7 +165,8 @@ class VPBuilder {
165165
return createInstruction(Opcode, Operands, DL, Name);
166166
}
167167
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
168-
const VPIRFlags &Flags, DebugLoc DL = {},
168+
const VPIRFlags &Flags,
169+
DebugLoc DL = DebugLoc::getUnknown(),
169170
const Twine &Name = "") {
170171
return tryInsertInstruction(
171172
new VPInstruction(Opcode, Operands, Flags, DL, Name));
@@ -174,45 +175,51 @@ class VPBuilder {
174175
VPInstruction *createNaryOp(unsigned Opcode,
175176
std::initializer_list<VPValue *> Operands,
176177
Type *ResultTy, const VPIRFlags &Flags = {},
177-
DebugLoc DL = {}, const Twine &Name = "") {
178+
DebugLoc DL = DebugLoc::getUnknown(),
179+
const Twine &Name = "") {
178180
return tryInsertInstruction(
179181
new VPInstructionWithType(Opcode, Operands, ResultTy, Flags, DL, Name));
180182
}
181183

182184
VPInstruction *createOverflowingOp(unsigned Opcode,
183185
std::initializer_list<VPValue *> Operands,
184186
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags,
185-
DebugLoc DL = {}, const Twine &Name = "") {
187+
DebugLoc DL = DebugLoc::getUnknown(),
188+
const Twine &Name = "") {
186189
return tryInsertInstruction(
187190
new VPInstruction(Opcode, Operands, WrapFlags, DL, Name));
188191
}
189192

190-
VPValue *createNot(VPValue *Operand, DebugLoc DL = {},
193+
VPValue *createNot(VPValue *Operand, DebugLoc DL = DebugLoc::getUnknown(),
191194
const Twine &Name = "") {
192195
return createInstruction(VPInstruction::Not, {Operand}, DL, Name);
193196
}
194197

195-
VPValue *createAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
198+
VPValue *createAnd(VPValue *LHS, VPValue *RHS,
199+
DebugLoc DL = DebugLoc::getUnknown(),
196200
const Twine &Name = "") {
197201
return createInstruction(Instruction::BinaryOps::And, {LHS, RHS}, DL, Name);
198202
}
199203

200-
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
204+
VPValue *createOr(VPValue *LHS, VPValue *RHS,
205+
DebugLoc DL = DebugLoc::getUnknown(),
201206
const Twine &Name = "") {
202207

203208
return tryInsertInstruction(new VPInstruction(
204209
Instruction::BinaryOps::Or, {LHS, RHS},
205210
VPRecipeWithIRFlags::DisjointFlagsTy(false), DL, Name));
206211
}
207212

208-
VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
213+
VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS,
214+
DebugLoc DL = DebugLoc::getUnknown(),
209215
const Twine &Name = "") {
210216
return tryInsertInstruction(
211217
new VPInstruction(VPInstruction::LogicalAnd, {LHS, RHS}, DL, Name));
212218
}
213219

214220
VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal,
215-
DebugLoc DL = {}, const Twine &Name = "",
221+
DebugLoc DL = DebugLoc::getUnknown(),
222+
const Twine &Name = "",
216223
std::optional<FastMathFlags> FMFs = std::nullopt) {
217224
auto *Select =
218225
FMFs ? new VPInstruction(Instruction::Select, {Cond, TrueVal, FalseVal},
@@ -226,20 +233,23 @@ class VPBuilder {
226233
/// and \p B.
227234
/// TODO: add createFCmp when needed.
228235
VPValue *createICmp(CmpInst::Predicate Pred, VPValue *A, VPValue *B,
229-
DebugLoc DL = {}, const Twine &Name = "") {
236+
DebugLoc DL = DebugLoc::getUnknown(),
237+
const Twine &Name = "") {
230238
assert(Pred >= CmpInst::FIRST_ICMP_PREDICATE &&
231239
Pred <= CmpInst::LAST_ICMP_PREDICATE && "invalid predicate");
232240
return tryInsertInstruction(
233241
new VPInstruction(Instruction::ICmp, {A, B}, Pred, DL, Name));
234242
}
235243

236-
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
244+
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset,
245+
DebugLoc DL = DebugLoc::getUnknown(),
237246
const Twine &Name = "") {
238247
return tryInsertInstruction(
239248
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},
240249
GEPNoWrapFlags::none(), DL, Name));
241250
}
242-
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
251+
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset,
252+
DebugLoc DL = DebugLoc::getUnknown(),
243253
const Twine &Name = "") {
244254
return tryInsertInstruction(
245255
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
772772
/// Look for a meaningful debug location on the instruction or its operands.
773773
static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
774774
if (!I)
775-
return DebugLoc();
775+
return DebugLoc::getUnknown();
776776

777777
DebugLoc Empty;
778778
if (I->getDebugLoc() != Empty)
@@ -1881,13 +1881,15 @@ class GeneratedRTChecks {
18811881
if (SCEVCheckBlock) {
18821882
SCEVCheckBlock->getTerminator()->moveBefore(
18831883
Preheader->getTerminator()->getIterator());
1884-
new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1884+
auto *UI = new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1885+
UI->setDebugLoc(DebugLoc::getTemporary());
18851886
Preheader->getTerminator()->eraseFromParent();
18861887
}
18871888
if (MemCheckBlock) {
18881889
MemCheckBlock->getTerminator()->moveBefore(
18891890
Preheader->getTerminator()->getIterator());
1890-
new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1891+
auto *UI = new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1892+
UI->setDebugLoc(DebugLoc::getTemporary());
18911893
Preheader->getTerminator()->eraseFromParent();
18921894
}
18931895

0 commit comments

Comments
 (0)