[llvm] 2e1ad93 - [AMDGPU] Fix copying a machine operand
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 11 12:26:36 PDT 2021
Author: Jay Foad
Date: 2021-10-11T20:22:47+01:00
New Revision: 2e1ad93201e51ae0fc4529ac7a877443e2a5bd82
URL: https://github.com/llvm/llvm-project/commit/2e1ad93201e51ae0fc4529ac7a877443e2a5bd82
DIFF: https://github.com/llvm/llvm-project/commit/2e1ad93201e51ae0fc4529ac7a877443e2a5bd82.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
llvm/test/CodeGen/AMDGPU/global-constant.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
index 67eae960cf5e..c18b230c4b65 100644
--- a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -336,7 +336,9 @@ R600TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
*BB, MI, R600::MOV, MI.getOperand(0).getReg(), R600::ALU_LITERAL_X);
int Idx = TII->getOperandIdx(*MIB, R600::OpName::literal);
//TODO: Ugh this is rather ugly
- MIB->getOperand(Idx) = MI.getOperand(1);
+ const MachineOperand &MO = MI.getOperand(1);
+ MIB->getOperand(Idx).ChangeToGA(MO.getGlobal(), MO.getOffset(),
+ MO.getTargetFlags());
break;
}
diff --git a/llvm/test/CodeGen/AMDGPU/global-constant.ll b/llvm/test/CodeGen/AMDGPU/global-constant.ll
index cc02980e997f..e422853b1c4d 100644
--- a/llvm/test/CodeGen/AMDGPU/global-constant.ll
+++ b/llvm/test/CodeGen/AMDGPU/global-constant.ll
@@ -2,7 +2,7 @@
; RUN: llc -mtriple=amdgcn-- -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
-; RUN: llc -mtriple=r600-- -mcpu=cypress < %s | FileCheck -check-prefix=R600 %s
+; RUN: llc -mtriple=r600-- -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=R600 %s
@private1 = private unnamed_addr addrspace(4) constant [4 x float] [float 0.0, float 1.0, float 2.0, float 3.0]
@private2 = private unnamed_addr addrspace(4) constant [4 x float] [float 4.0, float 5.0, float 6.0, float 7.0]
More information about the llvm-commits
mailing list