llvm.org GIT mirror llvm / 9f22831
Merging r340417: ------------------------------------------------------------------------ r340417 | hakzsam | 2018-08-22 18:08:48 +0200 (Wed, 22 Aug 2018) | 14 lines AMDGPU: bump AS.MAX_COMMON_ADDRESS to 6 since 32-bit addr space 32-bit constant address space is declared as 6, so the maximum number of address spaces is 6, not 5. Fixes "LLVM ERROR: Pointer address space out of range". v5: rename MAX_COMMON_ADDRESS to MAX_AMDGPU_ADDRESS v4: - fix compilation issues - fix out of bounds access v3: use static_assert() v2: add a very simple test for 32-bit addr space Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106630 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@341041 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
4 changed file(s) with 48 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
228228
229229 enum : unsigned {
230230 // The maximum value for flat, generic, local, private, constant and region.
231 MAX_COMMON_ADDRESS = 5,
231 MAX_AMDGPU_ADDRESS = 6,
232232
233233 GLOBAL_ADDRESS = 1, ///< Address space for global memory (RAT0, VTX0).
234234 CONSTANT_ADDRESS = 4, ///< Address space for constant memory (VTX2)
4949 AMDGPUAAResult::ASAliasRulesTy::ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_)
5050 : Arch(Arch_), AS(AS_) {
5151 // These arrarys are indexed by address space value
52 // enum elements 0 ... to 5
53 static const AliasResult ASAliasRulesPrivIsZero[6][6] = {
54 /* Private Global Constant Group Flat Region*/
55 /* Private */ {MayAlias, NoAlias , NoAlias , NoAlias , MayAlias, NoAlias},
56 /* Global */ {NoAlias , MayAlias, MayAlias, NoAlias , MayAlias, NoAlias},
57 /* Constant */ {NoAlias , MayAlias, MayAlias, NoAlias , MayAlias, NoAlias},
58 /* Group */ {NoAlias , NoAlias , NoAlias , MayAlias, MayAlias, NoAlias},
59 /* Flat */ {MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias},
60 /* Region */ {NoAlias , NoAlias , NoAlias , NoAlias , MayAlias, MayAlias}
52 // enum elements 0 ... to 6
53 static const AliasResult ASAliasRulesPrivIsZero[7][7] = {
54 /* Private Global Constant Group Flat Region Constant 32-bit */
55 /* Private */ {MayAlias, NoAlias , NoAlias , NoAlias , MayAlias, NoAlias , NoAlias},
56 /* Global */ {NoAlias , MayAlias, MayAlias, NoAlias , MayAlias, NoAlias , MayAlias},
57 /* Constant */ {NoAlias , MayAlias, MayAlias, NoAlias , MayAlias, NoAlias , MayAlias},
58 /* Group */ {NoAlias , NoAlias , NoAlias , MayAlias, MayAlias, NoAlias , NoAlias},
59 /* Flat */ {MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias},
60 /* Region */ {NoAlias , NoAlias , NoAlias , NoAlias , MayAlias, MayAlias, NoAlias},
61 /* Constant 32-bit */ {NoAlias , MayAlias, MayAlias, NoAlias , MayAlias, NoAlias , MayAlias}
6162 };
62 static const AliasResult ASAliasRulesGenIsZero[6][6] = {
63 /* Flat Global Region Group Constant Private */
64 /* Flat */ {MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias},
65 /* Global */ {MayAlias, MayAlias, NoAlias , NoAlias , MayAlias, NoAlias},
66 /* Region */ {MayAlias, NoAlias , NoAlias , NoAlias, MayAlias, NoAlias},
67 /* Group */ {MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , NoAlias},
68 /* Constant */ {MayAlias, MayAlias, MayAlias, NoAlias , NoAlias, NoAlias},
69 /* Private */ {MayAlias, NoAlias , NoAlias , NoAlias , NoAlias , MayAlias}
63 static const AliasResult ASAliasRulesGenIsZero[7][7] = {
64 /* Flat Global Region Group Constant Private Constant 32-bit */
65 /* Flat */ {MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias, MayAlias},
66 /* Global */ {MayAlias, MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , MayAlias},
67 /* Region */ {MayAlias, NoAlias , NoAlias , NoAlias, MayAlias, NoAlias , MayAlias},
68 /* Group */ {MayAlias, NoAlias , NoAlias , MayAlias, NoAlias , NoAlias , NoAlias},
69 /* Constant */ {MayAlias, MayAlias, MayAlias, NoAlias , NoAlias, NoAlias , MayAlias},
70 /* Private */ {MayAlias, NoAlias , NoAlias , NoAlias , NoAlias , MayAlias, NoAlias},
71 /* Constant 32-bit */ {MayAlias, MayAlias, MayAlias, NoAlias , MayAlias, NoAlias , NoAlias}
7072 };
71 assert(AS.MAX_COMMON_ADDRESS <= 5);
73 static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 6, "Addr space out of range");
7274 if (AS.FLAT_ADDRESS == 0) {
73 assert(AS.GLOBAL_ADDRESS == 1 &&
74 AS.REGION_ADDRESS == 2 &&
75 AS.LOCAL_ADDRESS == 3 &&
76 AS.CONSTANT_ADDRESS == 4 &&
77 AS.PRIVATE_ADDRESS == 5);
75 assert(AS.GLOBAL_ADDRESS == 1 &&
76 AS.REGION_ADDRESS == 2 &&
77 AS.LOCAL_ADDRESS == 3 &&
78 AS.CONSTANT_ADDRESS == 4 &&
79 AS.PRIVATE_ADDRESS == 5 &&
80 AS.CONSTANT_ADDRESS_32BIT == 6);
7881 ASAliasRules = &ASAliasRulesGenIsZero;
7982 } else {
80 assert(AS.PRIVATE_ADDRESS == 0 &&
81 AS.GLOBAL_ADDRESS == 1 &&
82 AS.CONSTANT_ADDRESS == 2 &&
83 AS.LOCAL_ADDRESS == 3 &&
84 AS.FLAT_ADDRESS == 4 &&
85 AS.REGION_ADDRESS == 5);
83 assert(AS.PRIVATE_ADDRESS == 0 &&
84 AS.GLOBAL_ADDRESS == 1 &&
85 AS.CONSTANT_ADDRESS == 2 &&
86 AS.LOCAL_ADDRESS == 3 &&
87 AS.FLAT_ADDRESS == 4 &&
88 AS.REGION_ADDRESS == 5 &&
89 AS.CONSTANT_ADDRESS_32BIT == 6);
8690 ASAliasRules = &ASAliasRulesPrivIsZero;
8791 }
8892 }
8993
9094 AliasResult AMDGPUAAResult::ASAliasRulesTy::getAliasResult(unsigned AS1,
9195 unsigned AS2) const {
92 if (AS1 > AS.MAX_COMMON_ADDRESS || AS2 > AS.MAX_COMMON_ADDRESS) {
96 if (AS1 > AS.MAX_AMDGPU_ADDRESS || AS2 > AS.MAX_AMDGPU_ADDRESS) {
9397 if (Arch == Triple::amdgcn)
9498 report_fatal_error("Pointer address space out of range");
9599 return AS1 == AS2 ? MayAlias : NoAlias;
6262 private:
6363 Triple::ArchType Arch;
6464 AMDGPUAS AS;
65 const AliasResult (*ASAliasRules)[6][6];
65 const AliasResult (*ASAliasRules)[7][7];
6666 } ASAliasRules;
6767 };
6868
1818 ret void
1919 }
2020
21 ; CHECK: MayAlias: i8 addrspace(1)* %p1, i8 addrspace(6)* %p
22
23 define void @test_constant_32bit_vs_global(i8 addrspace(6)* %p, i8 addrspace(1)* %p1) {
24 ret void
25 }
26
27 ; CHECK: MayAlias: i8 addrspace(4)* %p1, i8 addrspace(6)* %p
28
29 define void @test_constant_32bit_vs_constant(i8 addrspace(6)* %p, i8 addrspace(4)* %p1) {
30 ret void
31 }
32