[llvm] r254519 - AMDGPU/SI: Don't emit group segment global variables
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 09:00:43 PST 2015
Author: tstellar
Date: Wed Dec 2 11:00:42 2015
New Revision: 254519
URL: http://llvm.org/viewvc/llvm-project?rev=254519&view=rev
Log:
AMDGPU/SI: Don't emit group segment global variables
Summary: Only global or readonly segment variables should appear in object files.
Reviewers: arsenm
Subscribers: arsenm, llvm-commits
Differential Revision: http://reviews.llvm.org/D15111
Added:
llvm/trunk/test/CodeGen/AMDGPU/hsa-group-segment.ll
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp?rev=254519&r1=254518&r2=254519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Wed Dec 2 11:00:42 2015
@@ -123,6 +123,13 @@ void AMDGPUAsmPrinter::EmitFunctionEntry
AsmPrinter::EmitFunctionEntryLabel();
}
+void AMDGPUAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
+
+ if (TM.getTargetTriple().getOS() != Triple::AMDHSA ||
+ !AMDGPU::isGroupSegment(GV))
+ return AsmPrinter::EmitGlobalVariable(GV);
+}
+
bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// The starting address of all shader programs must be 256 bytes aligned.
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h?rev=254519&r1=254518&r2=254519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.h Wed Dec 2 11:00:42 2015
@@ -103,6 +103,8 @@ public:
void EmitFunctionEntryLabel() override;
+ void EmitGlobalVariable(const GlobalVariable *GV) override;
+
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant, const char *ExtraCode,
raw_ostream &O) override;
Modified: llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp?rev=254519&r1=254518&r2=254519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp Wed Dec 2 11:00:42 2015
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
#include "AMDGPUBaseInfo.h"
+#include "AMDGPU.h"
+#include "llvm/IR/GlobalValue.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/SubtargetFeature.h"
@@ -66,5 +68,9 @@ MCSection *getHSATextSection(MCContext &
ELF::SHF_AMDGPU_HSA_CODE);
}
+bool isGroupSegment(const GlobalValue *GV) {
+ return GV->getType()->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
+}
+
} // End namespace AMDGPU
} // End namespace llvm
Modified: llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h?rev=254519&r1=254518&r2=254519&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h Wed Dec 2 11:00:42 2015
@@ -15,6 +15,7 @@
namespace llvm {
class FeatureBitset;
+class GlobalValue;
class MCContext;
class MCSection;
@@ -31,6 +32,8 @@ void initDefaultAMDKernelCodeT(amd_kerne
const FeatureBitset &Features);
MCSection *getHSATextSection(MCContext &Ctx);
+bool isGroupSegment(const GlobalValue *GV);
+
} // end namespace AMDGPU
} // end namespace llvm
Added: llvm/trunk/test/CodeGen/AMDGPU/hsa-group-segment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/hsa-group-segment.ll?rev=254519&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/hsa-group-segment.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/hsa-group-segment.ll Wed Dec 2 11:00:42 2015
@@ -0,0 +1,14 @@
+; RUN: llc < %s -mtriple=amdgcn--amdhsa -mcpu=kaveri | FileCheck --check-prefix=HSA %s
+
+ at internal_group = internal addrspace(3) global i32 undef
+ at external_group = addrspace(3) global i32 undef
+
+define void @test() {
+entry:
+ store i32 0, i32 addrspace(3)* @internal_group
+ store i32 0, i32 addrspace(3)* @external_group
+ ret void
+}
+
+; HSA-NOT: internal_group:
+; HSA-NOT: external_group:
More information about the llvm-commits
mailing list