[PATCH] D46770: [AMDGPU] Fix compilation failure when IR contains comdat

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 11 13:17:52 PDT 2018


yaxunl created this revision.
yaxunl added reviewers: arsenm, rampitec.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, kzhuravl.

Remove a useless SwitchSection which also causes compilation failure
when IR contains comdat.

The SwitchSection is useless because the current section is already
correct text section for the function therefore no need to switch.

It causes compilation failure for comdat because functions with comdat
has specific text section, not the default .text section.

Since HIP uses comdat, this bug caused failures for HIP.


https://reviews.llvm.org/D46770

Files:
  lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  test/CodeGen/AMDGPU/comdat.ll


Index: test/CodeGen/AMDGPU/comdat.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/comdat.ll
@@ -0,0 +1,19 @@
+; RUN: llc -mtriple amdgcn-amd-amdhsa -filetype=obj <%s \
+; RUN:   | llvm-readobj -symbols - | FileCheck %s
+
+; CHECK: Name: func1
+; CHECK: Section: .text.func1
+
+; CHECK: Name: func2
+; CHECK: Section: .text.func2
+
+$func1 = comdat any
+$func2 = comdat any
+
+define amdgpu_kernel void @func1() local_unnamed_addr comdat {
+  ret void
+}
+
+define amdgpu_kernel void @func2() local_unnamed_addr comdat {
+  ret void
+}
Index: lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -197,8 +197,6 @@
   amd_kernel_code_t KernelCode;
   if (STM.isAmdCodeObjectV2(*MF)) {
     getAmdKernelCode(KernelCode, CurrentProgramInfo, *MF);
-
-    OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
     getTargetStreamer()->EmitAMDKernelCodeT(KernelCode);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46770.146400.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180511/71888a84/attachment.bin>


More information about the llvm-commits mailing list