[llvm] Prevent GlobalOpt from folding away addrspacecasts which may be runtime operations. (PR #153753)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 01:42:51 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:
With opaque pointers, I think you can just drop this entirely at this point?
https://github.com/llvm/llvm-project/pull/153753
More information about the llvm-commits
mailing list