[llvm] [GlobalOpt] Do not fold away addrspacecasts which may be runtime operations (PR #153753)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 01:53:28 PDT 2025
================
@@ -1133,8 +1133,9 @@ static bool
optimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
const DataLayout &DL,
function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
- // Ignore no-op GEPs and bitcasts.
- StoredOnceVal = StoredOnceVal->stripPointerCasts();
+ // Ignore no-op GEPs and bitcasts, but not addrspacecasts that may be runtime
+ // operations.
+ StoredOnceVal = StoredOnceVal->stripPointerCastsSameRepresentation();
----------------
nikic wrote:
Yes, but both bitcasts and 0-index GEPs get optimized away.
https://github.com/llvm/llvm-project/pull/153753
More information about the llvm-commits
mailing list