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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254519
91177308-0d34-0410-b5e6-
96231b3b80d8
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.
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;
//
//===----------------------------------------------------------------------===//
#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"
ELF::SHF_AMDGPU_HSA_CODE);
}
+bool isGroupSegment(const GlobalValue *GV) {
+ return GV->getType()->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS;
+}
+
} // End namespace AMDGPU
} // End namespace llvm
namespace llvm {
class FeatureBitset;
+class GlobalValue;
class MCContext;
class MCSection;
const FeatureBitset &Features);
MCSection *getHSATextSection(MCContext &Ctx);
+bool isGroupSegment(const GlobalValue *GV);
+
} // end namespace AMDGPU
} // end namespace llvm
--- /dev/null
+; RUN: llc < %s -mtriple=amdgcn--amdhsa -mcpu=kaveri | FileCheck --check-prefix=HSA %s
+
+@internal_group = internal addrspace(3) global i32 undef
+@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: