Skip to content

Commit 241b3b5

Browse files
committed
[Annotate][DLCov] Annotate intentionally-blank DebugLocs in existing code
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 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 06963fb commit 241b3b5

19 files changed

+83
-37
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1482,8 +1482,14 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
14821482
// FIXME: Pass Global's alignment when globals have alignment
14831483
AllocaInst *Alloca = new AllocaInst(ElemTy, DL.getAllocaAddrSpace(),
14841484
nullptr, GV->getName(), FirstI);
1485-
if (!isa<UndefValue>(GV->getInitializer()))
1486-
new StoreInst(GV->getInitializer(), Alloca, FirstI);
1485+
Alloca->setDebugLoc(DebugLoc::getCompilerGenerated());
1486+
if (!isa<UndefValue>(GV->getInitializer())) {
1487+
auto *SI = new StoreInst(GV->getInitializer(), Alloca, FirstI);
1488+
// FIXME: We're localizing a global and creating a store instruction for
1489+
// the initial value of that global. Could we logically use the global
1490+
// variable's (if one exists) line for this?
1491+
SI->setDebugLoc(DebugLoc::getCompilerGenerated());
1492+
}
14871493

14881494
GV->replaceAllUsesWith(Alloca);
14891495
GV->eraseFromParent();

llvm/lib/Transforms/IPO/IROutliner.cpp

+2-2
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

+8-1
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
419419
BasicBlock *NewUnreachableBB =
420420
BasicBlock::Create(BB->getContext(), "default.unreachable",
421421
BB->getParent(), DefaultDest);
422-
new UnreachableInst(BB->getContext(), NewUnreachableBB);
422+
auto *UI = new UnreachableInst(BB->getContext(), NewUnreachableBB);
423+
UI->setDebugLoc(DebugLoc::getTemporary());
423424

424425
DefaultDest->removePredecessor(BB);
425426
SI->setDefaultDest(NewUnreachableBB);

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
15271527
auto *NewRHS = CastInst::Create(
15281528
Instruction::Trunc, RHS, LHSOp->getType(), "",
15291529
L->getLoopPreheader()->getTerminator()->getIterator());
1530+
NewRHS->setDebugLoc(DebugLoc::getDropped());
15301531
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
15311532
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
15321533
// Samesign flag cannot be preserved after narrowing the compare.

llvm/lib/Transforms/Scalar/JumpThreading.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2976,8 +2976,10 @@ bool JumpThreadingPass::tryToUnfoldSelectInCurrBB(BasicBlock *BB) {
29762976
continue;
29772977
// Expand the select.
29782978
Value *Cond = SI->getCondition();
2979-
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI))
2979+
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI)) {
29802980
Cond = new FreezeInst(Cond, "cond.fr", SI->getIterator());
2981+
cast<FreezeInst>(Cond)->setDebugLoc(DebugLoc::getTemporary());
2982+
}
29812983
MDNode *BranchWeights = getBranchWeightMDNode(*SI);
29822984
Instruction *Term =
29832985
SplitBlockAndInsertIfThen(Cond, SI, false, BranchWeights);

llvm/lib/Transforms/Scalar/LICM.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
17241724
Instruction *New = sinkThroughTriviallyReplaceablePHI(
17251725
PN, &I, LI, SunkCopies, SafetyInfo, CurLoop, MSSAU);
17261726
// As we sink the instruction out of the BB, drop its debug location.
1727-
New->dropLocation();
1727+
New->setDebugLoc(DebugLoc::getDropped());
17281728
PN->replaceAllUsesWith(New);
17291729
eraseInstruction(*PN, *SafetyInfo, MSSAU);
17301730
Changed = true;
@@ -2249,7 +2249,7 @@ bool llvm::promoteLoopAccessesToScalars(
22492249
if (SawUnorderedAtomic)
22502250
PreheaderLoad->setOrdering(AtomicOrdering::Unordered);
22512251
PreheaderLoad->setAlignment(Alignment);
2252-
PreheaderLoad->setDebugLoc(DebugLoc());
2252+
PreheaderLoad->dropLocation();
22532253
if (AATags && LoadIsGuaranteedToExecute)
22542254
PreheaderLoad->setAAMetadata(AATags);
22552255

@@ -2802,6 +2802,7 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
28022802
auto *NewBO =
28032803
BinaryOperator::Create(Ins->getOpcode(), LHS, RHS,
28042804
Ins->getName() + ".reass", Ins->getIterator());
2805+
NewBO->setDebugLoc(DebugLoc::getDropped());
28052806
NewBO->copyIRFlags(Ins);
28062807
if (VariantOp == Ins)
28072808
VariantOp = NewBO;
@@ -2858,6 +2859,7 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
28582859

28592860
auto *NewBO = BinaryOperator::Create(
28602861
Opcode, LV, Inv, BO->getName() + ".reass", BO->getIterator());
2862+
NewBO->setDebugLoc(DebugLoc::getDropped());
28612863

28622864
// Copy NUW for ADDs if both instructions have it.
28632865
if (Opcode == Instruction::Add && BO->hasNoUnsignedWrap() &&

llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp

+2-1
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

+3
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) {
@@ -326,6 +327,7 @@ static void buildPartialInvariantUnswitchConditionalBranch(
326327
}
327328

328329
IRBuilder<> IRB(&BB);
330+
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());
329331
Value *Cond = VMap[ToDuplicate[0]];
330332
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
331333
Direction ? &NormalSucc : &UnswitchedSucc);
@@ -2365,6 +2367,7 @@ static void unswitchNontrivialInvariants(
23652367
// BI (`dyn_cast<BranchInst>(TI)`) is an in-loop instruction hoisted
23662368
// out of the loop.
23672369
Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator());
2370+
cast<Instruction>(Cond)->setDebugLoc(DebugLoc::getDropped());
23682371
}
23692372
BI->setCondition(Cond);
23702373
DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});

llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp

+3-1
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

+5
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
17701770
AllocaInst *NewAlloca =
17711771
new AllocaInst(ByValType, Arg->getType()->getPointerAddressSpace(),
17721772
nullptr, Alignment, Arg->getName());
1773+
NewAlloca->setDebugLoc(DebugLoc::getCompilerGenerated());
17731774
NewAlloca->insertBefore(Caller->begin()->begin());
17741775
IFI.StaticAllocas.push_back(NewAlloca);
17751776

@@ -3240,6 +3241,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
32403241

32413242
// Add an unconditional branch to make this look like the CallInst case...
32423243
CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), CB.getIterator());
3244+
// We intend to replace this DebugLoc with another later.
3245+
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getTemporary());
32433246

32443247
// Split the basic block. This guarantees that no PHI nodes will have to be
32453248
// updated due to new incoming edges, and make the invoke case more
@@ -3343,6 +3346,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
33433346
} else if (!CB.use_empty()) {
33443347
// No returns, but something is using the return value of the call. Just
33453348
// nuke the result.
3349+
if (CreatedBranchToNormalDest)
3350+
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getUnknown());
33463351
CB.replaceAllUsesWith(PoisonValue::get(CB.getType()));
33473352
}
33483353

llvm/lib/Transforms/Utils/Local.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -3131,7 +3131,8 @@ static bool markAliveBlocks(Function &F,
31313131
BasicBlock *UnreachableNormalDest = BasicBlock::Create(
31323132
Ctx, OrigNormalDest->getName() + ".unreachable",
31333133
II->getFunction(), OrigNormalDest);
3134-
new UnreachableInst(Ctx, UnreachableNormalDest);
3134+
auto *UI = new UnreachableInst(Ctx, UnreachableNormalDest);
3135+
UI->setDebugLoc(DebugLoc::getTemporary());
31353136
II->setNormalDest(UnreachableNormalDest);
31363137
if (DTU)
31373138
DTU->applyUpdates(

llvm/lib/Transforms/Utils/SCCPSolver.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
322322
NewUnreachableBB =
323323
BasicBlock::Create(DefaultDest->getContext(), "default.unreachable",
324324
DefaultDest->getParent(), DefaultDest);
325-
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
325+
auto *UI =
326+
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
327+
UI->setDebugLoc(DebugLoc::getTemporary());
326328
}
327329

328330
DefaultDest->removePredecessor(BB);

llvm/lib/Transforms/Utils/SSAUpdater.cpp

+1
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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ static void cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
11351135
// branch, drop it. When we fold the bonus instructions we want to make
11361136
// sure we reset their debug locations in order to avoid stepping on
11371137
// dead code caused by folding dead branches.
1138-
NewBonusInst->setDebugLoc(DebugLoc());
1138+
NewBonusInst->setDebugLoc(DebugLoc::getDropped());
11391139
}
11401140

11411141
RemapInstruction(NewBonusInst, VMap,
@@ -2811,7 +2811,8 @@ static void mergeCompatibleInvokesImpl(ArrayRef<InvokeInst *> Invokes,
28112811
// so just form a new block with unreachable terminator.
28122812
BasicBlock *MergedNormalDest = BasicBlock::Create(
28132813
Ctx, II0BB->getName() + ".cont", Func, InsertBeforeBlock);
2814-
new UnreachableInst(Ctx, MergedNormalDest);
2814+
auto *UI = new UnreachableInst(Ctx, MergedNormalDest);
2815+
UI->setDebugLoc(DebugLoc::getTemporary());
28152816
MergedInvoke->setNormalDest(MergedNormalDest);
28162817
}
28172818

@@ -3376,7 +3377,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
33763377
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
33773378
// Don't update the DILocation of dbg.assign intrinsics.
33783379
if (!isa<DbgAssignIntrinsic>(&I))
3379-
I.setDebugLoc(DebugLoc());
3380+
I.setDebugLoc(DebugLoc::getDropped());
33803381
}
33813382
I.dropUBImplyingAttrsAndMetadata();
33823383

@@ -5694,7 +5695,8 @@ static void createUnreachableSwitchDefault(SwitchInst *Switch,
56945695
BasicBlock *NewDefaultBlock = BasicBlock::Create(
56955696
BB->getContext(), BB->getName() + ".unreachabledefault", BB->getParent(),
56965697
OrigDefaultBlock);
5697-
new UnreachableInst(Switch->getContext(), NewDefaultBlock);
5698+
auto *UI = new UnreachableInst(Switch->getContext(), NewDefaultBlock);
5699+
UI->setDebugLoc(DebugLoc::getTemporary());
56985700
Switch->setDefaultDest(&*NewDefaultBlock);
56995701
if (DTU) {
57005702
SmallVector<DominatorTree::UpdateType, 2> Updates;

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class VPBuilder {
152152
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
153153
Instruction *Inst = nullptr,
154154
const Twine &Name = "") {
155-
DebugLoc DL;
155+
DebugLoc DL = DebugLoc::getUnknown();
156156
if (Inst)
157157
DL = Inst->getDebugLoc();
158158
VPInstruction *NewVPInst = createInstruction(Opcode, Operands, DL, Name);
@@ -166,7 +166,7 @@ class VPBuilder {
166166
VPInstruction *createNaryOp(unsigned Opcode,
167167
std::initializer_list<VPValue *> Operands,
168168
std::optional<FastMathFlags> FMFs = {},
169-
DebugLoc DL = {}, const Twine &Name = "") {
169+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "") {
170170
if (FMFs)
171171
return tryInsertInstruction(
172172
new VPInstruction(Opcode, Operands, *FMFs, DL, Name));
@@ -184,37 +184,37 @@ class VPBuilder {
184184
VPInstruction *createOverflowingOp(unsigned Opcode,
185185
std::initializer_list<VPValue *> Operands,
186186
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags,
187-
DebugLoc DL = {}, const Twine &Name = "") {
187+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "") {
188188
return tryInsertInstruction(
189189
new VPInstruction(Opcode, Operands, WrapFlags, DL, Name));
190190
}
191191

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

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

202-
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
202+
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = DebugLoc::getUnknown(),
203203
const Twine &Name = "") {
204204

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

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

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

238-
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
238+
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = DebugLoc::getUnknown(),
239239
const Twine &Name = "") {
240240
return tryInsertInstruction(
241241
new VPInstruction(Ptr, Offset, GEPNoWrapFlags::none(), DL, Name));
242242
}
243-
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
243+
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = DebugLoc::getUnknown(),
244244
const Twine &Name = "") {
245245
return tryInsertInstruction(
246246
new VPInstruction(Ptr, Offset, GEPNoWrapFlags::inBounds(), DL, Name));

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
799799
/// Look for a meaningful debug location on the instruction or its operands.
800800
static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
801801
if (!I)
802-
return DebugLoc();
802+
return DebugLoc::getUnknown();
803803

804804
DebugLoc Empty;
805805
if (I->getDebugLoc() != Empty)
@@ -1924,13 +1924,15 @@ class GeneratedRTChecks {
19241924
if (SCEVCheckBlock) {
19251925
SCEVCheckBlock->getTerminator()->moveBefore(
19261926
Preheader->getTerminator()->getIterator());
1927-
new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1927+
auto *UI = new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
1928+
UI->setDebugLoc(DebugLoc::getTemporary());
19281929
Preheader->getTerminator()->eraseFromParent();
19291930
}
19301931
if (MemCheckBlock) {
19311932
MemCheckBlock->getTerminator()->moveBefore(
19321933
Preheader->getTerminator()->getIterator());
1933-
new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1934+
auto *UI = new UnreachableInst(Preheader->getContext(), MemCheckBlock);
1935+
UI->setDebugLoc(DebugLoc::getTemporary());
19341936
Preheader->getTerminator()->eraseFromParent();
19351937
}
19361938

@@ -8511,7 +8513,8 @@ void VPRecipeBuilder::createHeaderMask() {
85118513
Builder.setInsertPoint(HeaderVPBB, NewInsertionPoint);
85128514
VPValue *BlockMask = nullptr;
85138515
VPValue *BTC = Plan.getOrCreateBackedgeTakenCount();
8514-
BlockMask = Builder.createICmp(CmpInst::ICMP_ULE, IV, BTC);
8516+
BlockMask =
8517+
Builder.createICmp(CmpInst::ICMP_ULE, IV, BTC, DebugLoc::getUnknown());
85158518
BlockMaskCache[Header] = BlockMask;
85168519
}
85178520

@@ -8546,7 +8549,8 @@ void VPRecipeBuilder::createBlockInMask(BasicBlock *BB) {
85468549
continue;
85478550
}
85488551

8549-
BlockMask = Builder.createOr(BlockMask, EdgeMask, {});
8552+
BlockMask =
8553+
Builder.createOr(BlockMask, EdgeMask, DebugLoc::getCompilerGenerated());
85508554
}
85518555

85528556
BlockMaskCache[BB] = BlockMask;

0 commit comments

Comments
 (0)