From deba150c2750717bc3c83877f74099c8578e8f30 Mon Sep 17 00:00:00 2001 From: Yaxun Liu Date: Fri, 11 May 2018 20:40:14 +0000 Subject: [PATCH] [AMDGPU] Fix compilation failure when IR contains comdat 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. Differential Revision: https://reviews.llvm.org/D46770 llvm-svn: 332137 --- llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 2 -- llvm/test/CodeGen/AMDGPU/comdat.ll | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/AMDGPU/comdat.ll diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp index 2a05e3b..c550af3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -197,8 +197,6 @@ void AMDGPUAsmPrinter::EmitFunctionBodyStart() { amd_kernel_code_t KernelCode; if (STM.isAmdCodeObjectV2(*MF)) { getAmdKernelCode(KernelCode, CurrentProgramInfo, *MF); - - OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); getTargetStreamer()->EmitAMDKernelCodeT(KernelCode); } diff --git a/llvm/test/CodeGen/AMDGPU/comdat.ll b/llvm/test/CodeGen/AMDGPU/comdat.ll new file mode 100644 index 0000000..5933159 --- /dev/null +++ b/llvm/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 +} -- 2.7.4