12
12
13
13
def global_ptr_ty : LLVMQualPointerType<1>;
14
14
15
+ // The amdgpu-no-* attributes (ex amdgpu-no-workitem-id-z) typically inferred
16
+ // by the backend cause whole-program undefined behavior when violated, such as
17
+ // by causing all other preload register intrinsics to return arbitrarily incorrect
18
+ // values. Outside of such IR-level UB, these preloaded registers are always set
19
+ // to a well-defined value and are thus `noundef`.
15
20
class AMDGPUReadPreloadRegisterIntrinsic
16
- : DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>;
21
+ : DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
17
22
18
23
class AMDGPUReadPreloadRegisterIntrinsicNamed<string name>
19
- : DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>, ClangBuiltin<name>;
24
+ : DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>, ClangBuiltin<name>;
20
25
21
26
// Used to tag image and resource intrinsics with information used to generate
22
27
// mem operands.
@@ -56,7 +61,7 @@ def int_r600_group_barrier : ClangBuiltin<"__builtin_r600_group_barrier">,
56
61
def int_r600_implicitarg_ptr :
57
62
ClangBuiltin<"__builtin_r600_implicitarg_ptr">,
58
63
DefaultAttrsIntrinsic<[LLVMQualPointerType<7>], [],
59
- [IntrNoMem, IntrSpeculatable]>;
64
+ [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
60
65
61
66
def int_r600_rat_store_typed :
62
67
// 1st parameter: Data
@@ -144,39 +149,44 @@ defm int_amdgcn_workgroup_id : AMDGPUReadPreloadRegisterIntrinsic_xyz_named
144
149
145
150
def int_amdgcn_dispatch_ptr :
146
151
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
147
- [Align<RetIndex, 4>, IntrNoMem, IntrSpeculatable]>;
152
+ [Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
148
153
149
154
def int_amdgcn_queue_ptr :
150
155
ClangBuiltin<"__builtin_amdgcn_queue_ptr">,
151
156
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
152
- [Align<RetIndex, 4>, IntrNoMem, IntrSpeculatable]>;
157
+ [Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
153
158
154
159
def int_amdgcn_kernarg_segment_ptr :
155
160
ClangBuiltin<"__builtin_amdgcn_kernarg_segment_ptr">,
156
161
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
157
- [Align<RetIndex, 4>, IntrNoMem, IntrSpeculatable]>;
162
+ [Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
158
163
159
164
def int_amdgcn_implicitarg_ptr :
160
165
ClangBuiltin<"__builtin_amdgcn_implicitarg_ptr">,
161
166
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
162
- [Align<RetIndex, 4>, IntrNoMem, IntrSpeculatable]>;
167
+ [Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
163
168
169
+ // Returns the amount of LDS statically allocated for this program.
170
+ // This is no longer guaranteed to be a compile-time constant due to linking
171
+ // support.
164
172
def int_amdgcn_groupstaticsize :
165
173
ClangBuiltin<"__builtin_amdgcn_groupstaticsize">,
166
- DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>;
174
+ DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
167
175
168
176
def int_amdgcn_dispatch_id :
169
177
ClangBuiltin<"__builtin_amdgcn_dispatch_id">,
170
- DefaultAttrsIntrinsic<[llvm_i64_ty], [], [IntrNoMem, IntrSpeculatable]>;
178
+ DefaultAttrsIntrinsic<[llvm_i64_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
171
179
172
180
// For internal use. Coordinates LDS lowering between IR transform and backend.
173
181
def int_amdgcn_lds_kernel_id :
174
- DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>;
182
+ DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
175
183
176
184
def int_amdgcn_implicit_buffer_ptr :
177
185
ClangBuiltin<"__builtin_amdgcn_implicit_buffer_ptr">,
178
186
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
179
- [Align<RetIndex, 4>, IntrNoMem, IntrSpeculatable]>;
187
+ [Align<RetIndex, 4>, Dereferenceable<RetIndex, 16>,
188
+ NoUndef<RetIndex>, NonNull<RetIndex>,
189
+ IntrNoMem, IntrSpeculatable]>;
180
190
181
191
// Set EXEC to the 64-bit value given.
182
192
// This is always moved to the beginning of the basic block.
@@ -199,7 +209,7 @@ def int_amdgcn_init_exec_from_input : Intrinsic<[],
199
209
200
210
def int_amdgcn_wavefrontsize :
201
211
ClangBuiltin<"__builtin_amdgcn_wavefrontsize">,
202
- DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>;
212
+ DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
203
213
204
214
// Represent a relocation constant.
205
215
def int_amdgcn_reloc_constant : DefaultAttrsIntrinsic<
@@ -1923,8 +1933,8 @@ def int_amdgcn_s_setreg :
1923
1933
// s_getpc_b64 instruction returns a zero-extended value.
1924
1934
def int_amdgcn_s_getpc :
1925
1935
ClangBuiltin<"__builtin_amdgcn_s_getpc">,
1926
- DefaultAttrsIntrinsic<[llvm_i64_ty], [], [IntrNoMem, IntrSpeculatable ,
1927
- IntrWillReturn]>;
1936
+ DefaultAttrsIntrinsic<[llvm_i64_ty], [], [NoUndef<RetIndex>, IntrNoMem ,
1937
+ IntrSpeculatable, IntrWillReturn]>;
1928
1938
1929
1939
// __builtin_amdgcn_interp_mov <param>, <attr_chan>, <attr>, <m0>
1930
1940
// param values: 0 = P10, 1 = P20, 2 = P0
@@ -2044,7 +2054,7 @@ def int_amdgcn_ps_live : DefaultAttrsIntrinsic <
2044
2054
// Query currently live lanes.
2045
2055
// Returns true if lane is live (and not a helper lane).
2046
2056
def int_amdgcn_live_mask : DefaultAttrsIntrinsic <[llvm_i1_ty],
2047
- [], [IntrReadMem, IntrInaccessibleMemOnly]
2057
+ [], [NoUndef<RetIndex>, IntrReadMem, IntrInaccessibleMemOnly]
2048
2058
>;
2049
2059
2050
2060
def int_amdgcn_mbcnt_lo :
@@ -2517,7 +2527,7 @@ def int_amdgcn_mov_dpp8 :
2517
2527
def int_amdgcn_s_get_waveid_in_workgroup :
2518
2528
ClangBuiltin<"__builtin_amdgcn_s_get_waveid_in_workgroup">,
2519
2529
Intrinsic<[llvm_i32_ty], [],
2520
- [IntrNoMem, IntrHasSideEffects, IntrWillReturn, IntrNoCallback, IntrNoFree]>;
2530
+ [NoUndef<RetIndex>, IntrNoMem, IntrHasSideEffects, IntrWillReturn, IntrNoCallback, IntrNoFree]>;
2521
2531
2522
2532
class AMDGPUAtomicRtn<LLVMType vt, LLVMType pt = llvm_anyptr_ty> : Intrinsic <
2523
2533
[vt],
@@ -2751,7 +2761,7 @@ def int_amdgcn_global_load_tr_b128 : AMDGPULoadIntrinsic<global_ptr_ty>;
2751
2761
2752
2762
// i32 @llvm.amdgcn.wave.id()
2753
2763
def int_amdgcn_wave_id :
2754
- DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrSpeculatable]>;
2764
+ DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
2755
2765
2756
2766
//===----------------------------------------------------------------------===//
2757
2767
// Deep learning intrinsics.
0 commit comments