Index: lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp +++ lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp @@ -24,7 +24,8 @@ 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: test/CodeGen/AMDGPU/global-constant.ll =================================================================== --- test/CodeGen/AMDGPU/global-constant.ll +++ test/CodeGen/AMDGPU/global-constant.ll @@ -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: test/CodeGen/AMDGPU/hsa-globals.ll =================================================================== --- test/CodeGen/AMDGPU/hsa-globals.ll +++ test/CodeGen/AMDGPU/hsa-globals.ll @@ -38,7 +38,7 @@ ; 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