mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-27 07:12:06 +00:00
AMDGPU/SI: Don't crash on anonymous GlobalValues
Summary: We need to call AsmPrinter::getNameWithPrefix() in order to handle anonymous GlobalValues (e.g. @0, @1). Reviewers: arsenm, b-sumner Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, tony-tye, llvm-commits Differential Revision: https://reviews.llvm.org/D24865 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282420 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a50e80efdf
commit
ccb1190aeb
@ -135,8 +135,9 @@ void AMDGPUAsmPrinter::EmitFunctionEntryLabel() {
|
||||
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();
|
||||
|
@ -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 @@ void AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
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 AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
|
||||
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)) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace llvm {
|
||||
|
||||
class AMDGPUSubtarget;
|
||||
class AsmPrinter;
|
||||
class MachineInstr;
|
||||
class MCContext;
|
||||
class MCInst;
|
||||
@ -20,9 +21,11 @@ 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;
|
||||
|
18
test/CodeGen/AMDGPU/anonymous-gv.ll
Normal file
18
test/CodeGen/AMDGPU/anonymous-gv.ll
Normal file
@ -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.
|
||||
@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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user