Skip to content

[DLCov][NFC] Annotate intentionally-blank DebugLocs in existing code #136192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions llvm/lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,8 +1494,14 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
// FIXME: Pass Global's alignment when globals have alignment
AllocaInst *Alloca = new AllocaInst(ElemTy, DL.getAllocaAddrSpace(),
nullptr, GV->getName(), FirstI);
if (!isa<UndefValue>(GV->getInitializer()))
new StoreInst(GV->getInitializer(), Alloca, FirstI);
Alloca->setDebugLoc(DebugLoc::getCompilerGenerated());
if (!isa<UndefValue>(GV->getInitializer())) {
auto *SI = new StoreInst(GV->getInitializer(), Alloca, FirstI);
// FIXME: We're localizing a global and creating a store instruction for
// the initial value of that global. Could we logically use the global
// variable's (if one exists) line for this?
SI->setDebugLoc(DebugLoc::getCompilerGenerated());
}

GV->replaceAllUsesWith(Alloca);
GV->eraseFromParent();
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/IPO/IROutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ static void moveFunctionData(Function &Old, Function &New,
// other outlined instructions.
if (!isa<CallInst>(&Val)) {
// Remove the debug information for outlined functions.
Val.setDebugLoc(DebugLoc());
Val.setDebugLoc(DebugLoc::getDropped());

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

StoreInst *NewI = cast<StoreInst>(I->clone());
NewI->setDebugLoc(DebugLoc());
NewI->setDebugLoc(DebugLoc::getDropped());
BasicBlock *OutputBB = VBBIt->second;
NewI->insertInto(OutputBB, OutputBB->end());
LLVM_DEBUG(dbgs() << "Move store for instruction " << *I << " to "
Expand Down
9 changes: 8 additions & 1 deletion llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,14 @@ Instruction *InstCombinerImpl::foldPHIArgZextsIntoPHI(PHINode &Phi) {
NewPhi->addIncoming(NewIncoming[I], Phi.getIncomingBlock(I));

InsertNewInstBefore(NewPhi, Phi.getIterator());
return CastInst::CreateZExtOrBitCast(NewPhi, Phi.getType());
auto *CI = CastInst::CreateZExtOrBitCast(NewPhi, Phi.getType());

// We use a dropped location here because the new ZExt is necessarily a merge
// of ZExtInsts and at least one constant from incoming branches; the presence
// of the constant means we have no viable DebugLoc from that branch, and
// therefore we must use a dropped location.
CI->setDebugLoc(DebugLoc::getDropped());
return CI;
}

/// If all operands to a PHI node are the same "unary" operator and they all are
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
BasicBlock *NewUnreachableBB =
BasicBlock::Create(BB->getContext(), "default.unreachable",
BB->getParent(), DefaultDest);
new UnreachableInst(BB->getContext(), NewUnreachableBB);
auto *UI = new UnreachableInst(BB->getContext(), NewUnreachableBB);
UI->setDebugLoc(DebugLoc::getTemporary());

DefaultDest->removePredecessor(BB);
SI->setDefaultDest(NewUnreachableBB);
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,9 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
auto *NewRHS = CastInst::Create(
Instruction::Trunc, RHS, LHSOp->getType(), "",
L->getLoopPreheader()->getTerminator()->getIterator());
// NewRHS is an operation that has been hoisted out of the loop, and
// therefore should have a dropped location.
NewRHS->setDebugLoc(DebugLoc::getDropped());
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
// Samesign flag cannot be preserved after narrowing the compare.
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3001,8 +3001,10 @@ bool JumpThreadingPass::tryToUnfoldSelectInCurrBB(BasicBlock *BB) {
continue;
// Expand the select.
Value *Cond = SI->getCondition();
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI))
if (!isGuaranteedNotToBeUndefOrPoison(Cond, nullptr, SI)) {
Cond = new FreezeInst(Cond, "cond.fr", SI->getIterator());
cast<FreezeInst>(Cond)->setDebugLoc(DebugLoc::getTemporary());
}
MDNode *BranchWeights = getBranchWeightMDNode(*SI);
Instruction *Term =
SplitBlockAndInsertIfThen(Cond, SI, false, BranchWeights);
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Scalar/LICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ bool llvm::promoteLoopAccessesToScalars(
if (SawUnorderedAtomic)
PreheaderLoad->setOrdering(AtomicOrdering::Unordered);
PreheaderLoad->setAlignment(Alignment);
PreheaderLoad->setDebugLoc(DebugLoc());
PreheaderLoad->setDebugLoc(DebugLoc::getDropped());
if (AATags && LoadIsGuaranteedToExecute)
PreheaderLoad->setAAMetadata(AATags);

Expand Down Expand Up @@ -2808,6 +2808,7 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
auto *NewBO =
BinaryOperator::Create(Ins->getOpcode(), LHS, RHS,
Ins->getName() + ".reass", Ins->getIterator());
NewBO->setDebugLoc(DebugLoc::getDropped());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous comment said

it should be the other way around (i.e. this uses getDropped() and the above keeps using dropLocation()

"the above" referring to this one here, I think? maybe I'm confused about which we're talking about now though (thanks github for evaporating my comments)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an instance of dropLocation that got replaced by getDropped in this patch - I've just fixed that, such that we're now only adding getDropped and not adding or removing any dropLocations!

NewBO->copyIRFlags(Ins);
if (VariantOp == Ins)
VariantOp = NewBO;
Expand Down Expand Up @@ -2864,6 +2865,7 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,

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

if (Opcode == Instruction::FAdd || Opcode == Instruction::FMul) {
// Intersect FMF flags for FADD and FMUL.
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,15 @@ class LoadEliminationForLoop {
assert(PH && "Preheader should exist!");
Value *InitialPtr = SEE.expandCodeFor(PtrSCEV->getStart(), Ptr->getType(),
PH->getTerminator());
Value *Initial =
Instruction *Initial =
new LoadInst(Cand.Load->getType(), InitialPtr, "load_initial",
/* isVolatile */ false, Cand.Load->getAlign(),
PH->getTerminator()->getIterator());
// We don't give any debug location to Initial, because it is inserted
// into the loop's preheader. A debug location inside the loop will cause
// a misleading stepping when debugging. The test update-debugloc-store
// -forwarded.ll checks this.
Initial->setDebugLoc(DebugLoc::getDropped());

PHINode *PHI = PHINode::Create(Initial->getType(), 2, "store_forwarded");
PHI->insertBefore(L->getHeader()->begin());
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ static void buildPartialUnswitchConditionalBranch(
BasicBlock &UnswitchedSucc, BasicBlock &NormalSucc, bool InsertFreeze,
const Instruction *I, AssumptionCache *AC, const DominatorTree &DT) {
IRBuilder<> IRB(&BB);
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());

SmallVector<Value *> FrozenInvariants;
for (Value *Inv : Invariants) {
Expand Down Expand Up @@ -330,6 +331,7 @@ static void buildPartialInvariantUnswitchConditionalBranch(
}

IRBuilder<> IRB(&BB);
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());
Value *Cond = VMap[ToDuplicate[0]];
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
Direction ? &NormalSucc : &UnswitchedSucc);
Expand Down Expand Up @@ -2369,6 +2371,7 @@ static void unswitchNontrivialInvariants(
// BI (`dyn_cast<BranchInst>(TI)`) is an in-loop instruction hoisted
// out of the loop.
Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator());
cast<Instruction>(Cond)->setDebugLoc(DebugLoc::getDropped());
}
BI->setCondition(Cond);
DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ void TailRecursionEliminator::createTailRecurseLoopHeader(CallInst *CI) {
BasicBlock *NewEntry = BasicBlock::Create(F.getContext(), "", &F, HeaderBB);
NewEntry->takeName(HeaderBB);
HeaderBB->setName("tailrecurse");
BranchInst::Create(HeaderBB, NewEntry);
auto *BI = BranchInst::Create(HeaderBB, NewEntry);
BI->setDebugLoc(DebugLoc::getCompilerGenerated());
// If the new branch preserves the debug location of CI, it could result in
// misleading stepping, if CI is located in a conditional branch.
// So, here we don't give any debug location to the new branch.
Expand Down Expand Up @@ -801,6 +802,7 @@ void TailRecursionEliminator::cleanupAndFinalize() {
SelectInst *SI =
SelectInst::Create(RetKnownPN, RetPN, RI->getOperand(0),
"current.ret.tr", RI->getIterator());
SI->setDebugLoc(DebugLoc::getCompilerGenerated());
RetSelects.push_back(SI);
RI->setOperand(0, SI);
}
Expand Down
9 changes: 9 additions & 0 deletions llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
AllocaInst *NewAlloca =
new AllocaInst(ByValType, Arg->getType()->getPointerAddressSpace(),
nullptr, Alignment, Arg->getName());
NewAlloca->setDebugLoc(DebugLoc::getCompilerGenerated());
NewAlloca->insertBefore(Caller->begin()->begin());
IFI.StaticAllocas.push_back(NewAlloca);

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

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

// Split the basic block. This guarantees that no PHI nodes will have to be
// updated due to new incoming edges, and make the invoke case more
Expand Down Expand Up @@ -3359,6 +3362,12 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
Returns[0]->eraseFromParent();
ReturnBB->eraseFromParent();
} else if (!CB.use_empty()) {
// In this case there are no returns to use, so there is no clear source
// location for the "return".
// FIXME: It may be correct to use the scope end line of the function here,
// since this likely means we are falling out of the function.
if (CreatedBranchToNormalDest)
CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getUnknown());
// No returns, but something is using the return value of the call. Just
// nuke the result.
CB.replaceAllUsesWith(PoisonValue::get(CB.getType()));
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3136,7 +3136,8 @@ static bool markAliveBlocks(Function &F,
BasicBlock *UnreachableNormalDest = BasicBlock::Create(
Ctx, OrigNormalDest->getName() + ".unreachable",
II->getFunction(), OrigNormalDest);
new UnreachableInst(Ctx, UnreachableNormalDest);
auto *UI = new UnreachableInst(Ctx, UnreachableNormalDest);
UI->setDebugLoc(DebugLoc::getTemporary());
II->setNormalDest(UnreachableNormalDest);
if (DTU)
DTU->applyUpdates(
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Utils/SCCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
NewUnreachableBB =
BasicBlock::Create(DefaultDest->getContext(), "default.unreachable",
DefaultDest->getParent(), DefaultDest);
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
auto *UI =
new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
UI->setDebugLoc(DebugLoc::getTemporary());
}

DefaultDest->removePredecessor(BB);
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Transforms/Utils/SSAUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ class SSAUpdaterTraits<SSAUpdater> {
SSAUpdater *Updater) {
PHINode *PHI =
PHINode::Create(Updater->ProtoType, NumPreds, Updater->ProtoName);
// FIXME: Ordinarily we don't care about or try to assign DebugLocs to PHI
// nodes, but loop optimizations may try to use a PHI node as a DebugLoc
// source (e.g. if this is an induction variable), and it's not clear what
// location we could attach here, so mark this unknown for now.
PHI->setDebugLoc(DebugLoc::getUnknown());
PHI->insertBefore(BB->begin());
return PHI;
}
Expand Down
10 changes: 6 additions & 4 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ static void cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
// branch, drop it. When we fold the bonus instructions we want to make
// sure we reset their debug locations in order to avoid stepping on
// dead code caused by folding dead branches.
NewBonusInst->setDebugLoc(DebugLoc());
NewBonusInst->setDebugLoc(DebugLoc::getDropped());
} else if (const DebugLoc &DL = NewBonusInst->getDebugLoc()) {
mapAtomInstance(DL, VMap);
}
Expand Down Expand Up @@ -2821,7 +2821,8 @@ static void mergeCompatibleInvokesImpl(ArrayRef<InvokeInst *> Invokes,
// so just form a new block with unreachable terminator.
BasicBlock *MergedNormalDest = BasicBlock::Create(
Ctx, II0BB->getName() + ".cont", Func, InsertBeforeBlock);
new UnreachableInst(Ctx, MergedNormalDest);
auto *UI = new UnreachableInst(Ctx, MergedNormalDest);
UI->setDebugLoc(DebugLoc::getTemporary());
MergedInvoke->setNormalDest(MergedNormalDest);
}

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

Expand Down Expand Up @@ -5707,7 +5708,8 @@ static void createUnreachableSwitchDefault(SwitchInst *Switch,
BasicBlock *NewDefaultBlock = BasicBlock::Create(
BB->getContext(), BB->getName() + ".unreachabledefault", BB->getParent(),
OrigDefaultBlock);
new UnreachableInst(Switch->getContext(), NewDefaultBlock);
auto *UI = new UnreachableInst(Switch->getContext(), NewDefaultBlock);
UI->setDebugLoc(DebugLoc::getTemporary());
Switch->setDefaultDest(&*NewDefaultBlock);
if (DTU) {
SmallVector<DominatorTree::UpdateType, 2> Updates;
Expand Down
34 changes: 22 additions & 12 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class VPBuilder {
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
Instruction *Inst = nullptr,
const Twine &Name = "") {
DebugLoc DL;
DebugLoc DL = DebugLoc::getUnknown();
if (Inst)
DL = Inst->getDebugLoc();
VPInstruction *NewVPInst = createInstruction(Opcode, Operands, DL, Name);
Expand All @@ -165,7 +165,8 @@ class VPBuilder {
return createInstruction(Opcode, Operands, DL, Name);
}
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
const VPIRFlags &Flags, DebugLoc DL = {},
const VPIRFlags &Flags,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstruction(Opcode, Operands, Flags, DL, Name));
Expand All @@ -174,45 +175,51 @@ class VPBuilder {
VPInstruction *createNaryOp(unsigned Opcode,
std::initializer_list<VPValue *> Operands,
Type *ResultTy, const VPIRFlags &Flags = {},
DebugLoc DL = {}, const Twine &Name = "") {
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstructionWithType(Opcode, Operands, ResultTy, Flags, DL, Name));
}

VPInstruction *createOverflowingOp(unsigned Opcode,
std::initializer_list<VPValue *> Operands,
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags,
DebugLoc DL = {}, const Twine &Name = "") {
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstruction(Opcode, Operands, WrapFlags, DL, Name));
}

VPValue *createNot(VPValue *Operand, DebugLoc DL = {},
VPValue *createNot(VPValue *Operand, DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return createInstruction(VPInstruction::Not, {Operand}, DL, Name);
}

VPValue *createAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
VPValue *createAnd(VPValue *LHS, VPValue *RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return createInstruction(Instruction::BinaryOps::And, {LHS, RHS}, DL, Name);
}

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

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

VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
VPValue *createLogicalAnd(VPValue *LHS, VPValue *RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstruction(VPInstruction::LogicalAnd, {LHS, RHS}, DL, Name));
}

VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal,
DebugLoc DL = {}, const Twine &Name = "",
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "",
std::optional<FastMathFlags> FMFs = std::nullopt) {
auto *Select =
FMFs ? new VPInstruction(Instruction::Select, {Cond, TrueVal, FalseVal},
Expand All @@ -226,20 +233,23 @@ class VPBuilder {
/// and \p B.
/// TODO: add createFCmp when needed.
VPValue *createICmp(CmpInst::Predicate Pred, VPValue *A, VPValue *B,
DebugLoc DL = {}, const Twine &Name = "") {
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
assert(Pred >= CmpInst::FIRST_ICMP_PREDICATE &&
Pred <= CmpInst::LAST_ICMP_PREDICATE && "invalid predicate");
return tryInsertInstruction(
new VPInstruction(Instruction::ICmp, {A, B}, Pred, DL, Name));
}

VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},
GEPNoWrapFlags::none(), DL, Name));
}
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL = {},
VPValue *createInBoundsPtrAdd(VPValue *Ptr, VPValue *Offset,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine &Name = "") {
return tryInsertInstruction(
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
/// Look for a meaningful debug location on the instruction or its operands.
static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
if (!I)
return DebugLoc();
return DebugLoc::getUnknown();

DebugLoc Empty;
if (I->getDebugLoc() != Empty)
Expand Down Expand Up @@ -1884,13 +1884,15 @@ class GeneratedRTChecks {
if (SCEVCheckBlock) {
SCEVCheckBlock->getTerminator()->moveBefore(
Preheader->getTerminator()->getIterator());
new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
auto *UI = new UnreachableInst(Preheader->getContext(), SCEVCheckBlock);
UI->setDebugLoc(DebugLoc::getTemporary());
Preheader->getTerminator()->eraseFromParent();
}
if (MemCheckBlock) {
MemCheckBlock->getTerminator()->moveBefore(
Preheader->getTerminator()->getIterator());
new UnreachableInst(Preheader->getContext(), MemCheckBlock);
auto *UI = new UnreachableInst(Preheader->getContext(), MemCheckBlock);
UI->setDebugLoc(DebugLoc::getTemporary());
Preheader->getTerminator()->eraseFromParent();
}

Expand Down
Loading
Loading