[PATCH] D24865: AMDGPU/SI: Don't crash on anonymous GlobalValues
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 10:38:23 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282420: AMDGPU/SI: Don't crash on anonymous GlobalValues (authored by tstellar).
Changed prior to commit:
https://reviews.llvm.org/D24865?vs=72303&id=72527#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24865
Files:
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.h
llvm/trunk/test/CodeGen/AMDGPU/anonymous-gv.ll
Index: llvm/trunk/test/CodeGen/AMDGPU/anonymous-gv.ll
===================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/anonymous-gv.ll
+++ llvm/trunk/test/CodeGen/AMDGPU/anonymous-gv.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -mtriple=amdgcn--amdhsa -mcpu=fiji | FileCheck %s
+
+; Make sure we don't crash on a global variable with no name.
+ at 0 = external addrspace(1) global i32
+
+; CHECK-LABEL: {{^}}test:
+; CHECK: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, __unnamed_1
+; CHECK: s_endpgm
+define void @test() {
+ store i32 1, i32 addrspace(1)* @0
+ ret void
+}
+
+; CHECK-LABEL: {{^}}__unnamed_2:
+; CHECK: s_endpgm
+define void @1() {
+ ret void
+}
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.h
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.h
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.h
@@ -13,16 +13,19 @@
namespace llvm {
class AMDGPUSubtarget;
+class AsmPrinter;
class MachineInstr;
class MCContext;
class MCInst;
class AMDGPUMCInstLower {
MCContext &Ctx;
const AMDGPUSubtarget &ST;
+ const AsmPrinter &AP;
public:
- AMDGPUMCInstLower(MCContext &ctx, const AMDGPUSubtarget &ST);
+ AMDGPUMCInstLower(MCContext &ctx, const AMDGPUSubtarget &ST,
+ const AsmPrinter &AP);
/// \brief Lower a MachineInstr to an MCInst
void lower(const MachineInstr *MI, MCInst &OutMI) const;
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -36,8 +36,9 @@
using namespace llvm;
-AMDGPUMCInstLower::AMDGPUMCInstLower(MCContext &ctx, const AMDGPUSubtarget &st):
- Ctx(ctx), ST(st) { }
+AMDGPUMCInstLower::AMDGPUMCInstLower(MCContext &ctx, const AMDGPUSubtarget &st,
+ const AsmPrinter &ap):
+ Ctx(ctx), ST(st), AP(ap) { }
static MCSymbolRefExpr::VariantKind getVariantKind(unsigned MOFlags) {
switch (MOFlags) {
@@ -75,7 +76,9 @@
break;
case MachineOperand::MO_GlobalAddress: {
const GlobalValue *GV = MO.getGlobal();
- MCSymbol *Sym = Ctx.getOrCreateSymbol(StringRef(GV->getName()));
+ SmallString<128> SymbolName;
+ AP.getNameWithPrefix(SymbolName, GV);
+ MCSymbol *Sym = Ctx.getOrCreateSymbol(SymbolName);
const MCExpr *SymExpr =
MCSymbolRefExpr::create(Sym, getVariantKind(MO.getTargetFlags()),Ctx);
const MCExpr *Expr = MCBinaryExpr::createAdd(SymExpr,
@@ -97,7 +100,7 @@
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const AMDGPUSubtarget &STI = MF->getSubtarget<AMDGPUSubtarget>();
- AMDGPUMCInstLower MCInstLowering(OutContext, STI);
+ AMDGPUMCInstLower MCInstLowering(OutContext, STI, *this);
StringRef Err;
if (!STI.getInstrInfo()->verifyInstruction(*MI, Err)) {
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -135,8 +135,9 @@
if (MFI->isKernel() && STM.isAmdCodeObjectV2()) {
AMDGPUTargetStreamer *TS =
static_cast<AMDGPUTargetStreamer *>(OutStreamer->getTargetStreamer());
- TS->EmitAMDGPUSymbolType(CurrentFnSym->getName(),
- ELF::STT_AMDGPU_HSA_KERNEL);
+ SmallString<128> SymbolName;
+ getNameWithPrefix(SymbolName, MF->getFunction()),
+ TS->EmitAMDGPUSymbolType(SymbolName, ELF::STT_AMDGPU_HSA_KERNEL);
}
AsmPrinter::EmitFunctionEntryLabel();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24865.72527.patch
Type: text/x-patch
Size: 3704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160926/ee1d8ce5/attachment.bin>
More information about the llvm-commits
mailing list