[PATCH] D110337: [AMDGPU] Use "hostcall" module flag instead of searching for ockl_hostcall_internal() declaration.
Konstantin Pyzhov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 5 06:56:29 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG095c48fdf3d2: [AMDGPU] Use "hostcall" module flag instead of searching for… (authored by kpyzhov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110337/new/
https://reviews.llvm.org/D110337
Files:
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3.ll
Index: llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3.ll
+++ llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3.ll
@@ -29,8 +29,6 @@
; CHECK: .name: test_kernel
; CHECK: .symbol: test_kernel.kd
-declare <2 x i64> @__ockl_hostcall_internal(i8*, i32, i64, i64, i64, i64, i64, i64, i64, i64)
-
define amdgpu_kernel void @test_kernel(i8 %a) #0
!kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3
!kernel_arg_base_type !3 !kernel_arg_type_qual !4 {
@@ -51,4 +49,7 @@
!opencl.ocl.version = !{!90}
!90 = !{i32 2, i32 0}
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"amdgpu_hostcall", i32 1}
+
; PARSER: AMDGPU HSA Metadata Parser Test: PASS
Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===================================================================
--- llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -63,6 +63,7 @@
auto Int64Ty = Builder.getInt64Ty();
auto M = Builder.GetInsertBlock()->getModule();
auto Fn = M->getOrInsertFunction("__ockl_printf_begin", Int64Ty, Int64Ty);
+ M->addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
return Builder.CreateCall(Fn, Version);
}
Index: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
@@ -798,7 +798,8 @@
if (!HiddenArgNumBytes)
return;
- auto &DL = Func.getParent()->getDataLayout();
+ const Module *M = Func.getParent();
+ auto &DL = M->getDataLayout();
auto Int64Ty = Type::getInt64Ty(Func.getContext());
if (HiddenArgNumBytes >= 8)
@@ -814,16 +815,16 @@
auto Int8PtrTy =
Type::getInt8PtrTy(Func.getContext(), AMDGPUAS::GLOBAL_ADDRESS);
- // Emit "printf buffer" argument if printf is used, otherwise emit dummy
- // "none" argument.
+ // Emit "printf buffer" argument if printf is used, emit "hostcall buffer"
+ // if "hostcall" module flag is set, otherwise emit dummy "none" argument.
if (HiddenArgNumBytes >= 32) {
- if (Func.getParent()->getNamedMetadata("llvm.printf.fmts"))
+ if (M->getNamedMetadata("llvm.printf.fmts"))
emitKernelArg(DL, Int8PtrTy, Align(8), "hidden_printf_buffer", Offset,
Args);
- else if (Func.getParent()->getFunction("__ockl_hostcall_internal")) {
+ else if (M->getModuleFlag("amdgpu_hostcall")) {
// The printf runtime binding pass should have ensured that hostcall and
// printf are not used in the same module.
- assert(!Func.getParent()->getNamedMetadata("llvm.printf.fmts"));
+ assert(!M->getNamedMetadata("llvm.printf.fmts"));
emitKernelArg(DL, Int8PtrTy, Align(8), "hidden_hostcall_buffer", Offset,
Args);
} else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110337.377205.patch
Type: text/x-patch
Size: 3034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211005/83df3356/attachment.bin>
More information about the llvm-commits
mailing list