[llvm] a3573f2 - Fix a bug in 67a3331e (cast instead of dyn_cast)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 7 08:25:07 PST 2022
Author: Philip Reames
Date: 2022-01-07T08:25:02-08:00
New Revision: a3573f203e1780e2d8739e15a823f5de9c81f505
URL: https://github.com/llvm/llvm-project/commit/a3573f203e1780e2d8739e15a823f5de9c81f505
DIFF: https://github.com/llvm/llvm-project/commit/a3573f203e1780e2d8739e15a823f5de9c81f505.diff
LOG: Fix a bug in 67a3331e (cast instead of dyn_cast)
The original commit was expected to be NFC, but I didn't account for the fact that invokes could be considered allocation functions. Interestingly, only one builder caught the problem.
Added:
Modified:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 2ae08f77639d0..6a2e173d6c0c6 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1221,12 +1221,13 @@ optimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, DL, GetTLI))
return true;
} else if (isMallocLikeFn(StoredOnceVal, GetTLI)) {
- auto *CI = cast<CallInst>(StoredOnceVal);
- auto *TLI = &GetTLI(*CI->getFunction());
- Type *MallocType = getMallocAllocatedType(CI, TLI);
- if (MallocType && tryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType,
- Ordering, DL, TLI))
- return true;
+ if (auto *CI = dyn_cast<CallInst>(StoredOnceVal)) {
+ auto *TLI = &GetTLI(*CI->getFunction());
+ Type *MallocType = getMallocAllocatedType(CI, TLI);
+ if (MallocType && tryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType,
+ Ordering, DL, TLI))
+ return true;
+ }
}
}
More information about the llvm-commits
mailing list