[clang] [Clang][CodeGen] Make UnqualPtrTy match llvm::PointerType::getUnqual (PR #163207)

Juan Manuel Martinez CaamaƱo via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 14 07:23:15 PDT 2025


jmmartinez wrote:

> So on LLVM side it is (often) assumed that the "default address space" always is AS=0. But on clang side targets can map DefaultAS to a non zero address space. I wonder if that inconsistency is a bigger problem than addressed by this patch.

I agree. The problem is certainly bigger and it happens to work since, most of the time, the default-AS is 0.
This patch is just a small step into making "unqual" the same on clang and llvm.

> We for example have this in DerivedTypes.h:
> 
> ```cpp
>   /// This constructs an opaque pointer to an object in the
>   /// default address space (address space zero).
>   static PointerType *getUnqual(LLVMContext &C) {
>     return PointerType::get(C, 0);
>   }
> ```

I should rewrite that comment. What do you think about `"This constructs an opaque pointer to an object in the zero address space (which is often, but not always, the target's generic address space)"` ?

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


More information about the cfe-commits mailing list