[PATCH] D103920: [amdgpu] Add `-enable-ocl-mangling-mismatch-workaround`.

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 11:42:13 PDT 2021


hliao created this revision.
hliao added reviewers: yaxunl, msearles, kzhuravl, b-sumner, rampitec.
Herald added subscribers: foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, nhaehnle, jvesely, arsenm.
hliao requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

- Add `-enable-ocl-mangling-mismatch-workaround` to work around the mismatch on OCL name mangling so far.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103920

Files:
  llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
  llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll


Index: llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
+++ llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
@@ -1,8 +1,8 @@
 ; RUN: opt -S -O1 -mtriple=amdgcn-- -amdgpu-simplify-libcall < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-POSTLINK %s
-; RUN: opt -S -O1 -mtriple=amdgcn-- -amdgpu-simplify-libcall -amdgpu-prelink  <%s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-PRELINK %s
+; RUN: opt -S -O1 -mtriple=amdgcn-- -amdgpu-simplify-libcall -amdgpu-prelink -enable-ocl-mangling-mismatch-workaround=0 <%s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-PRELINK %s
 ; RUN: opt -S -O1 -mtriple=amdgcn-- -amdgpu-use-native -amdgpu-prelink < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-NATIVE %s
 ; RUN: opt -S -passes='default<O1>' -mtriple=amdgcn-- -amdgpu-simplify-libcall < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-POSTLINK %s
-; RUN: opt -S -passes='default<O1>' -mtriple=amdgcn-- -amdgpu-simplify-libcall -amdgpu-prelink  <%s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-PRELINK %s
+; RUN: opt -S -passes='default<O1>' -mtriple=amdgcn-- -amdgpu-simplify-libcall -amdgpu-prelink -enable-ocl-mangling-mismatch-workaround=0 <%s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-PRELINK %s
 ; RUN: opt -S -passes='default<O1>' -mtriple=amdgcn-- -amdgpu-use-native -amdgpu-prelink < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GCN-NATIVE %s
 
 ; GCN-LABEL: {{^}}define amdgpu_kernel void @test_sincos
Index: llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
@@ -19,10 +19,15 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ValueSymbolTable.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 
+static cl::opt<bool> EnableOCLManglingMismatchWA(
+    "enable-ocl-mangling-mismatch-workaround", cl::init(true), cl::ReallyHidden,
+    cl::desc("Enable the workaround for OCL name mangling mismatch."));
+
 namespace {
 
 enum EManglingParam {
@@ -826,7 +831,8 @@
       unsigned AS = UseAddrSpace
                         ? AMDGPULibFuncBase::getAddrSpaceFromEPtrKind(p.PtrKind)
                         : 0;
-      if (AS != 0) os << "U3AS" << AS;
+      if (EnableOCLManglingMismatchWA || AS != 0)
+        os << "U3AS" << AS;
       Ptr = p;
       p.PtrKind = 0;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103920.350677.patch
Type: text/x-patch
Size: 2696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210608/1c9c1400/attachment.bin>


More information about the llvm-commits mailing list