Skip to content

Commit 0705143

Browse files
committed
[Annotate][DLCov] Annotate intentionally-blank DebugLocs in existing code
Following the work in PR #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 a no-op in ordinary LLVM builds (each function `get<Type>` simply expands to `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.
1 parent 9c52b3c commit 0705143

19 files changed

+80
-36
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
15061506
auto *NewRHS = CastInst::Create(
15071507
Instruction::Trunc, RHS, LHSOp->getType(), "",
15081508
L->getLoopPreheader()->getTerminator()->getIterator());
1509+
NewRHS->setDebugLoc(DebugLoc::getDropped());
15091510
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
15101511
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
15111512
// 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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
17221722
Instruction *New = sinkThroughTriviallyReplaceablePHI(
17231723
PN, &I, LI, SunkCopies, SafetyInfo, CurLoop, MSSAU);
17241724
// As we sink the instruction out of the BB, drop its debug location.
1725-
New->dropLocation();
1725+
New->setDebugLoc(DebugLoc::getDropped());
17261726
PN->replaceAllUsesWith(New);
17271727
eraseInstruction(*PN, *SafetyInfo, MSSAU);
17281728
Changed = true;
@@ -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->dropLocation();
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: 5 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
@@ -3361,6 +3364,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
33613364
} else if (!CB.use_empty()) {
33623365
// No returns, but something is using the return value of the call. Just
33633366
// nuke the result.
3367+
if (CreatedBranchToNormalDest)
3368+
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getUnknown());
33643369
CB.replaceAllUsesWith(PoisonValue::get(CB.getType()));
33653370
}
33663371

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,8 @@ static bool markAliveBlocks(Function &F,
31363136
BasicBlock *UnreachableNormalDest = BasicBlock::Create(
31373137
Ctx, OrigNormalDest->getName() + ".unreachable",
31383138
II->getFunction(), OrigNormalDest);
3139-
new UnreachableInst(Ctx, UnreachableNormalDest);
3139+
auto *UI = new UnreachableInst(Ctx, UnreachableNormalDest);
3140+
UI->setDebugLoc(DebugLoc::getTemporary());
31403141
II->setNormalDest(UnreachableNormalDest);
31413142
if (DTU)
31423143
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ class SSAUpdaterTraits<SSAUpdater> {
318318
SSAUpdater *Updater) {
319319
PHINode *PHI =
320320
PHINode::Create(Updater->ProtoType, NumPreds, Updater->ProtoName);
321+
PHI->setDebugLoc(DebugLoc::getUnknown());
321322
PHI->insertBefore(BB->begin());
322323
return PHI;
323324
}

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: 12 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,7 @@ 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, DebugLoc DL = DebugLoc::getUnknown(),
169169
const Twine &Name = "") {
170170
return tryInsertInstruction(
171171
new VPInstruction(Opcode, Operands, Flags, DL, Name));
@@ -174,45 +174,45 @@ class VPBuilder {
174174
VPInstruction *createNaryOp(unsigned Opcode,
175175
std::initializer_list<VPValue *> Operands,
176176
Type *ResultTy, const VPIRFlags &Flags = {},
177-
DebugLoc DL = {}, const Twine &Name = "") {
177+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "") {
178178
return tryInsertInstruction(
179179
new VPInstructionWithType(Opcode, Operands, ResultTy, Flags, DL, Name));
180180
}
181181

182182
VPInstruction *createOverflowingOp(unsigned Opcode,
183183
std::initializer_list<VPValue *> Operands,
184184
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags,
185-
DebugLoc DL = {}, const Twine &Name = "") {
185+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "") {
186186
return tryInsertInstruction(
187187
new VPInstruction(Opcode, Operands, WrapFlags, DL, Name));
188188
}
189189

190-
VPValue *createNot(VPValue *Operand, DebugLoc DL = {},
190+
VPValue *createNot(VPValue *Operand, DebugLoc DL = DebugLoc::getUnknown(),
191191
const Twine &Name = "") {
192192
return createInstruction(VPInstruction::Not, {Operand}, DL, Name);
193193
}
194194

195-
VPValue *createAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
195+
VPValue *createAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = DebugLoc::getUnknown(),
196196
const Twine &Name = "") {
197197
return createInstruction(Instruction::BinaryOps::And, {LHS, RHS}, DL, Name);
198198
}
199199

200-
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
200+
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = DebugLoc::getUnknown(),
201201
const Twine &Name = "") {
202202

203203
return tryInsertInstruction(new VPInstruction(
204204
Instruction::BinaryOps::Or, {LHS, RHS},
205205
VPRecipeWithIRFlags::DisjointFlagsTy(false), DL, Name));
206206
}
207207

208-
VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
208+
VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = DebugLoc::getUnknown(),
209209
const Twine &Name = "") {
210210
return tryInsertInstruction(
211211
new VPInstruction(VPInstruction::LogicalAnd, {LHS, RHS}, DL, Name));
212212
}
213213

214214
VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal,
215-
DebugLoc DL = {}, const Twine &Name = "",
215+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "",
216216
std::optional<FastMathFlags> FMFs = std::nullopt) {
217217
auto *Select =
218218
FMFs ? new VPInstruction(Instruction::Select, {Cond, TrueVal, FalseVal},
@@ -226,20 +226,20 @@ class VPBuilder {
226226
/// and \p B.
227227
/// TODO: add createFCmp when needed.
228228
VPValue *createICmp(CmpInst::Predicate Pred, VPValue *A, VPValue *B,
229-
DebugLoc DL = {}, const Twine &Name = "") {
229+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "") {
230230
assert(Pred >= CmpInst::FIRST_ICMP_PREDICATE &&
231231
Pred <= CmpInst::LAST_ICMP_PREDICATE && "invalid predicate");
232232
return tryInsertInstruction(
233233
new VPInstruction(Instruction::ICmp, {A, B}, Pred, DL, Name));
234234
}
235235

236-
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
236+
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = DebugLoc::getUnknown(),
237237
const Twine &Name = "") {
238238
return tryInsertInstruction(
239239
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},
240240
GEPNoWrapFlags::none(), DL, Name));
241241
}
242-
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
242+
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = DebugLoc::getUnknown(),
243243
const Twine &Name = "") {
244244
return tryInsertInstruction(
245245
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
@@ -775,7 +775,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
775775
/// Look for a meaningful debug location on the instruction or its operands.
776776
static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
777777
if (!I)
778-
return DebugLoc();
778+
return DebugLoc::getUnknown();
779779

780780
DebugLoc Empty;
781781
if (I->getDebugLoc() != Empty)
@@ -1884,13 +1884,15 @@ class GeneratedRTChecks {
18841884
if (SCEVCheckBlock) {
18851885
SCEVCheckBlock->getTerminator()->moveBefore(
18861886
Preheader->getTerminator()->getIterator());
1887-
new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1887+
auto *UI = new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1888+
UI->setDebugLoc(DebugLoc::getTemporary());
18881889
Preheader->getTerminator()->eraseFromParent();
18891890
}
18901891
if (MemCheckBlock) {
18911892
MemCheckBlock->getTerminator()->moveBefore(
18921893
Preheader->getTerminator()->getIterator());
1893-
new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1894+
auto *UI = new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1895+
UI->setDebugLoc(DebugLoc::getTemporary());
18941896
Preheader->getTerminator()->eraseFromParent();
18951897
}
18961898

0 commit comments

Comments
 (0)