diff options
author | Alex Voicu <alexandru.voicu@amd.com> | 2024-05-19 16:59:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-19 14:59:03 +0100 |
commit | 10edb4991c12738e60843d55cd9edbf6d702d9eb (patch) | |
tree | e75a23d05c4f3b8186bdba58f669cf59b86523f9 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | c587483da0b50efa04146fde205da1d16731e12e (diff) | |
download | llvm-10edb4991c12738e60843d55cd9edbf6d702d9eb.zip llvm-10edb4991c12738e60843d55cd9edbf6d702d9eb.tar.gz llvm-10edb4991c12738e60843d55cd9edbf6d702d9eb.tar.bz2 |
[Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (#88182)
At the moment, Clang is rather liberal in assuming that 0 (and by extension unqualified) is always a safe default. This does not work for targets that actually use a different value for the default / generic AS (for example, the SPIRV that obtains from HIPSPV or SYCL). This patch is a first, fairly safe step towards trying to clear things up by querying a modules' default AS from the target, rather than assuming it's 0, alongside fixing a few places where things break / we encode the 0 == DefaultAS assumption. A bunch of existing tests are extended to check for non-zero default AS usage.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 489c08a..227813a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext &C, IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth()); IntPtrTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getMaxPointerWidth()); - Int8PtrTy = llvm::PointerType::get(LLVMContext, 0); + Int8PtrTy = llvm::PointerType::get(LLVMContext, + C.getTargetAddressSpace(LangAS::Default)); const llvm::DataLayout &DL = M.getDataLayout(); AllocaInt8PtrTy = llvm::PointerType::get(LLVMContext, DL.getAllocaAddrSpace()); |