From b5983a38cbf4eb405fe9583ab89e15db1dcfa173 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 23 May 2023 10:27:34 -0400 Subject: [PATCH] [IRTranslator][NFC] Refactor if/else chain into early returns This will make it easier to add more cases in a subsequent commit and also better conforms to the coding guidelines. Differential Revision: https://reviews.llvm.org/D151328 --- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index f090a0a..d128de9 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2026,11 +2026,14 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, // DI cannot produce a valid DBG_VALUE, so produce an undef DBG_VALUE to // terminate any prior location. MIRBuilder.buildIndirectDbgValue(0, DI.getVariable(), DI.getExpression()); - } else if (const auto *CI = dyn_cast(V)) { + return true; + } + if (const auto *CI = dyn_cast(V)) { MIRBuilder.buildConstDbgValue(*CI, DI.getVariable(), DI.getExpression()); - } else if (auto *AI = dyn_cast(V); - AI && AI->isStaticAlloca() && - DI.getExpression()->startsWithDeref()) { + return true; + } + if (auto *AI = dyn_cast(V); + AI && AI->isStaticAlloca() && DI.getExpression()->startsWithDeref()) { // If the value is an alloca and the expression starts with a // dereference, track a stack slot instead of a register, as registers // may be clobbered. @@ -2039,14 +2042,14 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, DIExpression::get(AI->getContext(), ExprOperands.drop_front()); MIRBuilder.buildFIDbgValue(getOrCreateFrameIndex(*AI), DI.getVariable(), ExprDerefRemoved); - } else { - for (Register Reg : getOrCreateVRegs(*V)) { - // FIXME: This does not handle register-indirect values at offset 0. The - // direct/indirect thing shouldn't really be handled by something as - // implicit as reg+noreg vs reg+imm in the first place, but it seems - // pretty baked in right now. - MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression()); - } + return true; + } + for (Register Reg : getOrCreateVRegs(*V)) { + // FIXME: This does not handle register-indirect values at offset 0. The + // direct/indirect thing shouldn't really be handled by something as + // implicit as reg+noreg vs reg+imm in the first place, but it seems + // pretty baked in right now. + MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression()); } return true; } -- 2.7.4