[PATCH] D130719: [GlobalISEL][nfc] Remove unnecessary cast

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 11:02:18 PDT 2022


fdeazeve created this revision.
Herald added subscribers: hiraditya, rovka.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130719

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


Index: llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -97,10 +97,10 @@
       "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;
   }();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130719.448388.patch
Type: text/x-patch
Size: 671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220728/eaf6e10e/attachment.bin>


More information about the llvm-commits mailing list