diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp @@ -35,6 +35,8 @@ StringRef SectionName = GO->getSection(); if (SectionName.startswith(".AMDGPU.comment.")) SK = SectionKind::getMetadata(); + else if (SectionName.startswith(".text")) + SK = SectionKind::getText(); return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); } diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -4648,7 +4648,8 @@ const Triple &TT = getTargetMachine().getTargetTriple(); return (GV->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS || GV->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT) && - AMDGPU::shouldEmitConstantsToTextSection(TT); + (AMDGPU::shouldEmitConstantsToTextSection(TT) || + GV->getSection().startswith(".text")); } bool SITargetLowering::shouldEmitGOTReloc(const GlobalValue *GV) const { diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -568,7 +568,7 @@ } bool shouldEmitConstantsToTextSection(const Triple &TT) { - return TT.getOS() == Triple::AMDPAL || TT.getArch() == Triple::r600; + return TT.getArch() == Triple::r600; } int getIntegerAttribute(const Function &F, StringRef Name, int Default) { diff --git a/llvm/test/CodeGen/AMDGPU/elf.rodata.ll b/llvm/test/CodeGen/AMDGPU/elf.rodata.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/elf.rodata.ll @@ -0,0 +1,25 @@ +; RUN: llc < %s -march=amdgcn -mcpu=fiji -filetype=obj | llvm-readobj --symbols -S --sd - | FileCheck %s + +; CHECK: Section { +; CHECK: Name: .text +; CHECK: Type: SHT_PROGBITS (0x1) +; CHECK: Flags [ (0x6) +; CHECK: Size: 16 +; CHECK: SectionData ( +; CHECK: 0000: 414D4431 414D4431 414D4431 414D4431 |AMD1AMD1AMD1AMD1| +; CHECK: ) +; CHECK: } + +; CHECK: Section { +; CHECK: Name: .rodata +; CHECK: Type: SHT_PROGBITS (0x1) +; CHECK: Flags [ (0x2) +; CHECK: Size: 16 +; CHECK: SectionData ( +; CHECK: 0000: 414D4432 414D4432 414D4432 414D4432 |AMD2AMD2AMD2AMD2| +; CHECK: ) +; CHECK: } + + +@rodata_info_var_1 = internal global [4 x i32][i32 826559809, i32 826559809, i32 826559809, i32 826559809], section ".text" +@rodata_info_var_2 = constant [4 x i32][i32 843337025, i32 843337025, i32 843337025, i32 843337025]