[AMDGPU] Emit read-only data to .rodata for hsa
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Thu, 21 Jul 2016 15:59:23 +0000 (15:59 +0000)
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Thu, 21 Jul 2016 15:59:23 +0000 (15:59 +0000)
Differential Revision: https://reviews.llvm.org/D22538

llvm-svn: 276298

llvm/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
llvm/test/CodeGen/AMDGPU/global-constant.ll
llvm/test/CodeGen/AMDGPU/hsa-globals.ll

index 03d1e2c..02e9d18 100644 (file)
@@ -24,7 +24,8 @@ MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
                                                           SectionKind Kind,
                                                           Mangler &Mang,
                                                 const TargetMachine &TM) const {
-  if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV))
+  if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV) &&
+      TM.getTargetTriple().getOS() != Triple::AMDHSA)
     return TextSection;
 
   return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM);
index 0f2fc83..9eb5819 100644 (file)
@@ -12,7 +12,7 @@
 ; GCN-NEXT: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], readonly
 ; GCN: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], 0
 ; NOHSA: .text
-; HSA: .text
+; HSA: .section .rodata
 ; GCN: readonly:
 ; GCN: readonly2:
 define void @main(i32 %index, float addrspace(1)* %out) {
index df478fb..2820b30 100644 (file)
@@ -38,7 +38,7 @@ define void @test() {
 ; ASM: .size external_global_program, 4
 
 ; ASM: .type internal_readonly,@object
-; ASM: .text
+; ASM: .section .rodata.cst4,"aM",@progbits,4
 ; ASM: internal_readonly:
 ; ASM: .long 0
 ; ASM: .size internal_readonly, 4