[PATCH] D121744: [SCCP] Update ValueLatticeElement blockaddresses when removing unreachable BasicBlocks
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 15:23:58 PDT 2022
nickdesaulniers added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SCCPSolver.cpp:424-426
+ if (New->getType()->isPointerTy() && Old->getType()->isPointerTy() &&
+ New->getType() != Old->getType())
+ New = ConstantExpr::getBitCast(New, Old->getType());
----------------
nickdesaulniers wrote:
> This added bitcast is a bit curious, I'd like to clean it up, but I'm not sure yet how best to do so.
>
> Basically, we know we want to replace `i8* blockaddress(@fn, %bb)` with `i8* inttoptr (i32 1 to i8*)`, but the `User` of the BA and entry in `ValueState` is `%1 = bitcast i8* blockaddress(@fn, %bb) to i64*`.
>
> Maybe I should be doing an operand replacement? As in take `Old` and replace its operand with `New`?
Looks like `User::replaceUsesOfWith` can't be called with a `Constant`. Maybe I need to construct a new `Instruction` to replace the prior use, with the new operand?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121744/new/
https://reviews.llvm.org/D121744
More information about the llvm-commits
mailing list