Skip to content

Commit c211568

Browse files
committed
Don't targ kernarg and implicitarg nonnull, update comments
(Kernarg and implicitarg have complexities I didn't know of, so move them to a different PR.)
1 parent 1cb0e20 commit c211568

File tree

5 files changed

+161
-159
lines changed

5 files changed

+161
-159
lines changed

llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ def global_ptr_ty : LLVMQualPointerType<1>;
1515
// The amdgpu-no-* attributes (ex amdgpu-no-workitem-id-z) typically inferred
1616
// by the backend cause whole-program undefined behavior when violated, such as
1717
// 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`.
18+
// values. In non-entry-point functions, attempting to call a function that needs
19+
// some preloaded register from a function that is known to not need it is a violation
20+
// of the calling convention and also program-level UB. Outside of such IR-level UB,
21+
// these preloaded registers are always set to a well-defined value and are thus `noundef`.
2022
class AMDGPUReadPreloadRegisterIntrinsic
2123
: DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
2224

@@ -159,12 +161,12 @@ def int_amdgcn_queue_ptr :
159161
def int_amdgcn_kernarg_segment_ptr :
160162
ClangBuiltin<"__builtin_amdgcn_kernarg_segment_ptr">,
161163
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
162-
[Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
164+
[Align<RetIndex, 4>, NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
163165

164166
def int_amdgcn_implicitarg_ptr :
165167
ClangBuiltin<"__builtin_amdgcn_implicitarg_ptr">,
166168
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
167-
[Align<RetIndex, 4>, NoUndef<RetIndex>, NonNull<RetIndex>, IntrNoMem, IntrSpeculatable]>;
169+
[Align<RetIndex, 4>, NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
168170

169171
// Returns the amount of LDS statically allocated for this program.
170172
// This is no longer guaranteed to be a compile-time constant due to linking
@@ -184,8 +186,7 @@ def int_amdgcn_lds_kernel_id :
184186
def int_amdgcn_implicit_buffer_ptr :
185187
ClangBuiltin<"__builtin_amdgcn_implicit_buffer_ptr">,
186188
DefaultAttrsIntrinsic<[LLVMQualPointerType<4>], [],
187-
[Align<RetIndex, 4>, Dereferenceable<RetIndex, 16>,
188-
NoUndef<RetIndex>, NonNull<RetIndex>,
189+
[Align<RetIndex, 4>, NoUndef<RetIndex>,
189190
IntrNoMem, IntrSpeculatable]>;
190191

191192
// Set EXEC to the 64-bit value given.

llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static bool lowerKernelArguments(Function &F, const TargetMachine &TM) {
277277
}
278278
}
279279

280+
KernArgSegment->addRetAttr(Attribute::NonNull);
280281
KernArgSegment->addRetAttr(
281282
Attribute::getWithAlignment(Ctx, std::max(KernArgBaseAlign, MaxAlign)));
282283

0 commit comments

Comments
 (0)