[PATCH] D130642: [GlobalISel] Handle IntToPtr constants in dbg.value
Felipe de Azevedo Piovezan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 27 14:05:43 PDT 2022
fdeazeve added inline comments.
================
Comment at: llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp:103
+ if (CE->getOpcode() == Instruction::IntToPtr)
+ return cast<const Constant>(CE->getOperand(0));
+ return &C;
----------------
nikic wrote:
> What's the `cast<const Constant>()` for?
This was done to drive the lambda return type deduction to `const Constant*`, which is the type of `&C`.
I thought `getOperand` would return a `Value`, but now that you mentioned it, I see that I was wrong, it already returns a `Constant`.
So I think this code could have been rewritten with an explicit return type of the lambda and the cast removed?
```cpp
auto *NumericConstant = [&] () -> const Constant* {
if (const auto *CE = dyn_cast<ConstantExpr>(&C))
if (CE->getOpcode() == Instruction::IntToPtr)
return CE->getOperand(0);
return &C;
}();
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130642/new/
https://reviews.llvm.org/D130642
More information about the llvm-commits
mailing list