[clang] clang: Do not implicitly addrspacecast in EmitAggExprToLValue (PR #129837)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 21:37:57 PST 2025


yxsamliu wrote:

I have some doubt whether this will work for CUDA/HIP since their AST is not aware of address space. When translated to IR, any pointer is expected to pointing to default addr space. That is why alloca is immediately casted to generic pointer and used as generic pointer to match other parts of AST. For example:

```
__device__ void f(int*);
__device__ void g() {
  int a[10];
  int *p = a;
  f(a);
}
```
both p and f is expecting generic pointer in IR. Actually anywhere a is used, it is expected to be a generic pointer. That's why we need to cast it to generic pointer and use it as a generic pointer in the beginning.

https://github.com/llvm/llvm-project/pull/129837


More information about the cfe-commits mailing list