From b4694229aa9d7a09d58a8e59339d14570437daf2 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 4 Jul 2022 09:25:26 +0100 Subject: [PATCH] [LV] Simplify setDebugLocFromInst by using early exit (NFC). Suggested as separate improvement in D128657. --- llvm/lib/Transforms/Vectorize/VPlan.cpp | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index 4d709097c306..6c0cca7ebc82 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -248,25 +248,27 @@ void VPTransformState::addMetadata(ArrayRef To, Instruction *From) { } void VPTransformState::setDebugLocFromInst(const Value *V) { - if (const Instruction *Inst = dyn_cast_or_null(V)) { - const DILocation *DIL = Inst->getDebugLoc(); - - // When a FSDiscriminator is enabled, we don't need to add the multiply - // factors to the discriminators. - if (DIL && Inst->getFunction()->isDebugInfoForProfiling() && - !isa(Inst) && !EnableFSDiscriminator) { - // FIXME: For scalable vectors, assume vscale=1. - auto NewDIL = - DIL->cloneByMultiplyingDuplicationFactor(UF * VF.getKnownMinValue()); - if (NewDIL) - Builder.SetCurrentDebugLocation(*NewDIL); - else - LLVM_DEBUG(dbgs() << "Failed to create new discriminator: " - << DIL->getFilename() << " Line: " << DIL->getLine()); - } else - Builder.SetCurrentDebugLocation(DIL); - } else + const Instruction *Inst = dyn_cast(V); + if (!Inst) { Builder.SetCurrentDebugLocation(DebugLoc()); + return; + } + + const DILocation *DIL = Inst->getDebugLoc(); + // When a FSDiscriminator is enabled, we don't need to add the multiply + // factors to the discriminators. + if (DIL && Inst->getFunction()->isDebugInfoForProfiling() && + !isa(Inst) && !EnableFSDiscriminator) { + // FIXME: For scalable vectors, assume vscale=1. + auto NewDIL = + DIL->cloneByMultiplyingDuplicationFactor(UF * VF.getKnownMinValue()); + if (NewDIL) + Builder.SetCurrentDebugLocation(*NewDIL); + else + LLVM_DEBUG(dbgs() << "Failed to create new discriminator: " + << DIL->getFilename() << " Line: " << DIL->getLine()); + } else + Builder.SetCurrentDebugLocation(DIL); } BasicBlock *