[clang] [clang] remove lots of "innocuous" addrspacecasts (PR #197745)
Jameson Nash via cfe-commits
cfe-commits at lists.llvm.org
Fri May 15 12:59:43 PDT 2026
================
@@ -480,7 +479,6 @@ kernel void test_target_features_kernel(global int *i) {
// GFX900-NEXT: [[BLOCK_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[BLOCK]] to ptr
// GFX900-NEXT: [[BLOCK3_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[BLOCK3]] to ptr
// GFX900-NEXT: [[BLOCK12_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[BLOCK12]] to ptr
-// GFX900-NEXT: [[BLOCK_SIZES_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[BLOCK_SIZES]] to ptr
----------------
vtjnash wrote:
hmm, yeah, it looks like it was even called out there that that `CreateMemTemp` returns the wrong thing (note the comment is wrong, it is used for first the call and then the lifetime end, although the call needed the alloca too):
```
auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
llvm::Value *TmpPtr = Tmp.getPointer();
// The EmitLifetime* pair expect a naked Alloca as their last argument,
// however for cases where the default AS is not the Alloca AS, Tmp is
// actually the Alloca ascasted to the default AS, hence the
// stripPointerCasts()
llvm::Value *Alloca = TmpPtr->stripPointerCasts();
...
// Return the Alloca itself rather than a potential ascast as this is only
// used by the paired EmitLifetimeEnd.
return {ElemPtr, Alloca};
```
https://github.com/llvm/llvm-project/pull/197745
More information about the cfe-commits
mailing list