Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 83260f2

Browse files
author
Marina Yatsina
committed
Fix for PR29010
This is a fix for https://llvm.org/bugs/show_bug.cgi?id=29010 Root cause of the bug is that the register class of the machine instruction operand does not fully reflect if this registers that can be allocated. Both for i386 and x86_64 the operand's register class is VR128RegClass and thus contains xmm0-xmm15, though in i386 we can only use xmm0-xmm8. In order to get the actual allocable registers of the class we need to use RegisterClassInfo. Differential Revision: https://reviews.llvm.org/D23613 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278954 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 79d1008 commit 83260f2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/CodeGen/ExecutionDepsFix.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/CodeGen/LivePhysRegs.h"
2727
#include "llvm/CodeGen/MachineFunctionPass.h"
2828
#include "llvm/CodeGen/MachineRegisterInfo.h"
29+
#include "llvm/CodeGen/RegisterClassInfo.h"
2930
#include "llvm/Support/Allocator.h"
3031
#include "llvm/Support/Debug.h"
3132
#include "llvm/Support/raw_ostream.h"
@@ -137,6 +138,7 @@ class ExeDepsFix : public MachineFunctionPass {
137138
MachineFunction *MF;
138139
const TargetInstrInfo *TII;
139140
const TargetRegisterInfo *TRI;
141+
RegisterClassInfo RegClassInfo;
140142
std::vector<SmallVector<int, 1>> AliasMap;
141143
const unsigned NumRegs;
142144
LiveReg *LiveRegs;
@@ -509,7 +511,8 @@ void ExeDepsFix::pickBestRegisterForUndef(MachineInstr *MI, unsigned OpIdx,
509511
// max clearance or clearance higher than Pref.
510512
unsigned MaxClearance = 0;
511513
unsigned MaxClearanceReg = OriginalReg;
512-
for (auto Reg : OpRC->getRegisters()) {
514+
ArrayRef<MCPhysReg> Order = RegClassInfo.getOrder(OpRC);
515+
for (auto Reg : Order) {
513516
assert(AliasMap[Reg].size() == 1 &&
514517
"Reg is expected to be mapped to a single index");
515518
int RCrx = *regIndices(Reg).begin();
@@ -785,6 +788,7 @@ bool ExeDepsFix::runOnMachineFunction(MachineFunction &mf) {
785788
MF = &mf;
786789
TII = MF->getSubtarget().getInstrInfo();
787790
TRI = MF->getSubtarget().getRegisterInfo();
791+
RegClassInfo.runOnMachineFunction(mf);
788792
LiveRegs = nullptr;
789793
assert(NumRegs == RC->getNumRegs() && "Bad regclass");
790794

test/CodeGen/X86/pr29010.ll

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llc < %s -mtriple=i386-linux -mattr=+avx | FileCheck %s
2+
3+
; In i386 there are only 8 XMMs (xmm0-xmm7), make sure we we are not creating illegal XMM
4+
define float @only_xmm0_7(i32 %arg) {
5+
top:
6+
tail call void asm sideeffect "", "~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{dirflag},~{fpsr},~{flags}"()
7+
tail call void asm sideeffect "", "~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{dirflag},~{fpsr},~{flags}"()
8+
%tmp1 = sitofp i32 %arg to float
9+
ret float %tmp1
10+
;CHECK-LABEL:@only_xmm0_7
11+
;CHECK: vcvtsi2ssl {{.*}}, {{%xmm[0-7]+}}, {{%xmm[0-7]+}}
12+
}

0 commit comments

Comments
 (0)