[llvm] 0ef6809 - [GlobalISel][nfc] Remove unnecessary cast

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 14:55:45 PDT 2022


Author: Felipe de Azevedo Piovezan
Date: 2022-07-28T14:55:07-07:00
New Revision: 0ef6809c48515e5ae2c7cb1ad34fa2169a40b0fa

URL: https://github.com/llvm/llvm-project/commit/0ef6809c48515e5ae2c7cb1ad34fa2169a40b0fa
DIFF: https://github.com/llvm/llvm-project/commit/0ef6809c48515e5ae2c7cb1ad34fa2169a40b0fa.diff

LOG: [GlobalISel][nfc] Remove unnecessary cast

The getOperand method already returns a Constant when it is called on
a ConstantExpression, as such the cast is not needed. To prevent a type
mismatch between the different return statements of the lambda, the
lambda return type is explicitly provided.

Differential Revision: https://reviews.llvm.org/D130719

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 4ecfda15d0323..7328ea4eed25e 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -97,10 +97,10 @@ MachineInstrBuilder MachineIRBuilder::buildConstDbgValue(const Constant &C,
       "Expected inlined-at fields to agree");
   auto MIB = buildInstrNoInsert(TargetOpcode::DBG_VALUE);
 
-  auto *NumericConstant = [&] {
+  auto *NumericConstant = [&] () -> const Constant* {
     if (const auto *CE = dyn_cast<ConstantExpr>(&C))
       if (CE->getOpcode() == Instruction::IntToPtr)
-        return cast<const Constant>(CE->getOperand(0));
+        return CE->getOperand(0);
     return &C;
   }();
 


        


More information about the llvm-commits mailing list