[llvm] [SCCP] Remove LoadInst if it loaded from Constant GlobalVariable (PR #107245)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 00:33:09 PDT 2024
================
@@ -357,8 +357,11 @@ static bool runIPSCCP(
LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName()
<< "' is constant!\n");
while (!GV->use_empty()) {
- StoreInst *SI = cast<StoreInst>(GV->user_back());
- SI->eraseFromParent();
+ auto User = GV->user_back();
+ // We can remove LoadInst at here, because we already replace user of this
+ // to constant.
+ if (isa<StoreInst>(User) || isa<LoadInst>(User))
----------------
nikic wrote:
I think this check can be an assertion?
https://github.com/llvm/llvm-project/pull/107245
More information about the llvm-commits
mailing list