[clang] f849034 - [AMDGPU] Do not allow the region address space to be converted to generic (#117171)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 05:13:53 PST 2024
Author: Joseph Huber
Date: 2024-11-22T07:13:49-06:00
New Revision: f84903486cd174e39fb36fa88c98c9563b671c7e
URL: https://github.com/llvm/llvm-project/commit/f84903486cd174e39fb36fa88c98c9563b671c7e
DIFF: https://github.com/llvm/llvm-project/commit/f84903486cd174e39fb36fa88c98c9563b671c7e.diff
LOG: [AMDGPU] Do not allow the region address space to be converted to generic (#117171)
Summary:
Previous changes relaxed the address space rules based on what the
target says about them. This accidentally included the AS(2) region as
convertible to generic. Simply check for AS(2) and reject it.
Added:
Modified:
clang/lib/Basic/Targets/AMDGPU.h
clang/test/Sema/amdgcn-address-spaces.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index db7a095ba2a4fe..ea4189cdea47da 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -120,7 +120,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
toTargetAddressSpace(A) == llvm::AMDGPUAS::FLAT_ADDRESS)) &&
isTargetAddressSpace(B) &&
toTargetAddressSpace(B) >= llvm::AMDGPUAS::FLAT_ADDRESS &&
- toTargetAddressSpace(B) <= llvm::AMDGPUAS::PRIVATE_ADDRESS);
+ toTargetAddressSpace(B) <= llvm::AMDGPUAS::PRIVATE_ADDRESS &&
+ toTargetAddressSpace(B) != llvm::AMDGPUAS::REGION_ADDRESS);
}
uint64_t getMaxPointerWidth() const override {
diff --git a/clang/test/Sema/amdgcn-address-spaces.c b/clang/test/Sema/amdgcn-address-spaces.c
index 50c12993ac69b8..70545db920c807 100644
--- a/clang/test/Sema/amdgcn-address-spaces.c
+++ b/clang/test/Sema/amdgcn-address-spaces.c
@@ -9,7 +9,7 @@
#define _AS999 __attribute__((address_space(999)))
void *p1(void _AS1 *p) { return p; }
-void *p2(void _AS2 *p) { return p; }
+void *p2(void _AS2 *p) { return p; } // expected-error {{returning '_AS2 void *' from a function with result type 'void *' changes address space of pointer}}
void *p3(void _AS3 *p) { return p; }
void *p4(void _AS4 *p) { return p; }
void *p5(void _AS5 *p) { return p; }
More information about the cfe-commits
mailing list