Skip to content

Commit f849034

Browse files
authored
[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.
1 parent d1dae1e commit f849034

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
120120
toTargetAddressSpace(A) == llvm::AMDGPUAS::FLAT_ADDRESS)) &&
121121
isTargetAddressSpace(B) &&
122122
toTargetAddressSpace(B) >= llvm::AMDGPUAS::FLAT_ADDRESS &&
123-
toTargetAddressSpace(B) <= llvm::AMDGPUAS::PRIVATE_ADDRESS);
123+
toTargetAddressSpace(B) <= llvm::AMDGPUAS::PRIVATE_ADDRESS &&
124+
toTargetAddressSpace(B) != llvm::AMDGPUAS::REGION_ADDRESS);
124125
}
125126

126127
uint64_t getMaxPointerWidth() const override {

clang/test/Sema/amdgcn-address-spaces.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define _AS999 __attribute__((address_space(999)))
1010

1111
void *p1(void _AS1 *p) { return p; }
12-
void *p2(void _AS2 *p) { return p; }
12+
void *p2(void _AS2 *p) { return p; } // expected-error {{returning '_AS2 void *' from a function with result type 'void *' changes address space of pointer}}
1313
void *p3(void _AS3 *p) { return p; }
1414
void *p4(void _AS4 *p) { return p; }
1515
void *p5(void _AS5 *p) { return p; }

0 commit comments

Comments
 (0)