Index: llvm/lib/Transforms/Utils/SCCPSolver.cpp =================================================================== --- llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -1249,6 +1249,14 @@ if (AI->hasByValAttr() && !F->onlyReadsMemory()) { markOverdefined(&*AI); continue; + } else if (const BlockAddress *BA = dyn_cast(CAI)) { + markBlockExecutable(BA->getBasicBlock()); + } else if (const ConstantExpr *CE = dyn_cast(CAI)) { + for (Value *Op : CE->operands()) { + const BlockAddress *BA = dyn_cast(Op); + if (BA != nullptr) + markBlockExecutable(BA->getBasicBlock()); + } } if (auto *STy = dyn_cast(AI->getType())) { Index: llvm/test/Transforms/SCCP/issue54238.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/SCCP/issue54238.ll @@ -0,0 +1,18 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes +; RUN: opt -passes=ipsccp -S %s | FileCheck %s +; https://github.com/llvm/llvm-project/issues/54238 + +define i32 @main() { + call void @set_return_addr(i64* bitcast (i8* blockaddress(@main, %redirected) to i64*)) + ret i32 0 + +redirected: + ret i32 0 +} + +define internal void @set_return_addr(i64* %addr) { + %addr.addr = alloca i64*, i32 0, align 8 +; CHECK: redirected + store i64* %addr, i64** %addr.addr, align 8 + ret void +}