[PATCH] D115283: [AMDGPU] Set "amdgpu_hostcall" module flag if an AMDGPU function has calls to device lib functions that use hostcalls.

Konstantin Pyzhov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 7 13:53:02 PST 2021


kpyzhov created this revision.
kpyzhov added a reviewer: yaxunl.
kpyzhov added a project: AMDGPU.
Herald added subscribers: t-tye, tpr, dstuttard, kzhuravl.
kpyzhov requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115283

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9194,6 +9194,11 @@
                             llvm::Value *BlockLiteral) const override;
   bool shouldEmitStaticExternCAliases() const override;
   void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
+
+  virtual void checkFunctionCallABI(CodeGenModule &CGM, SourceLocation CallLoc,
+                                    const FunctionDecl *Caller,
+                                    const FunctionDecl *Callee,
+                                    const CallArgList &Args) const override;
 };
 }
 
@@ -9417,6 +9422,24 @@
       FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
 }
 
+void AMDGPUTargetCodeGenInfo::checkFunctionCallABI(CodeGenModule &CGM,
+                                                   SourceLocation CallLoc,
+                                                   const FunctionDecl *Caller,
+                                                   const FunctionDecl *Callee,
+                                                   const CallArgList &Args) const
+{
+  // Set the "amdgpu_hostcall" module flag if "Callee" is a library function
+  // that uses AMDGPU hostcall mechanism.
+  if (Callee &&
+      (Callee->getName() == "__ockl_call_host_function" ||
+       Callee->getName() == "__ockl_fprintf_stderr_begin")) {
+    llvm::Module &M = CGM.getModule();
+    if (!M.getModuleFlag("amdgpu_hostcall")) {
+      M.addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+    }
+  }
+}
+
 //===----------------------------------------------------------------------===//
 // SPARC v8 ABI Implementation.
 // Based on the SPARC Compliance Definition version 2.4.1.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115283.392527.patch
Type: text/x-patch
Size: 1810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211207/a0a7787f/attachment.bin>


More information about the cfe-commits mailing list