[llvm] [CGP] Undo constant propagation of pointers across calls (PR #102926)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 05:39:57 PDT 2024
================
@@ -2686,6 +2686,47 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, ModifyDT &ModifiedDT) {
return true;
}
+ // SCCP may have propagated C++ static variables across calls. If this happens
+ // to be the case, we may want to undo it in order to avoid redundant pointer
+ // computation of the constant, as the function method returning the constant
+ // needs to be executed anyways.
+ auto GetUniformReturnValue = [](const Function *F) -> Constant * {
+ if (!F->getReturnType()->isPointerTy())
+ return nullptr;
+
+ Constant *UniformValue = nullptr;
+ for (auto &BB : llvm::reverse(*F)) {
----------------
antoniofrighetto wrote:
Might have made sense at the beginning, no longer now.
https://github.com/llvm/llvm-project/pull/102926
More information about the llvm-commits
mailing list