Skip to content

Commit 2e1ad93

Browse files
committed
[AMDGPU] Fix copying a machine operand
Without this I get: *** Bad machine code: Instruction has operand with wrong parent set *** - function: available_externally_test - basic block: %bb.0 (0x7dad598) - instruction: %0:r600_treg32_x = MOV 1, 0, 0, 0, $alu_literal_x, 0, 0, 0, -1, 1, $pred_sel_off, @available_externally, 0 Differential Revision: https://reviews.llvm.org/D111549
1 parent 7af6a44 commit 2e1ad93

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/Target/AMDGPU/R600ISelLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ R600TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
336336
*BB, MI, R600::MOV, MI.getOperand(0).getReg(), R600::ALU_LITERAL_X);
337337
int Idx = TII->getOperandIdx(*MIB, R600::OpName::literal);
338338
//TODO: Ugh this is rather ugly
339-
MIB->getOperand(Idx) = MI.getOperand(1);
339+
const MachineOperand &MO = MI.getOperand(1);
340+
MIB->getOperand(Idx).ChangeToGA(MO.getGlobal(), MO.getOffset(),
341+
MO.getTargetFlags());
340342
break;
341343
}
342344

llvm/test/CodeGen/AMDGPU/global-constant.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; RUN: llc -mtriple=amdgcn-- -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
33
; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
44
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
5-
; RUN: llc -mtriple=r600-- -mcpu=cypress < %s | FileCheck -check-prefix=R600 %s
5+
; RUN: llc -mtriple=r600-- -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=R600 %s
66

77
@private1 = private unnamed_addr addrspace(4) constant [4 x float] [float 0.0, float 1.0, float 2.0, float 3.0]
88
@private2 = private unnamed_addr addrspace(4) constant [4 x float] [float 4.0, float 5.0, float 6.0, float 7.0]

0 commit comments

Comments
 (0)