mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Fix PR3701. 1. X86 target renamed eflags register to flags. This matches what llvm-gcc generates so codegen knows flags register is being clobbered by inline asm. 2. BURR scheduler should also check if inline asm nodes can clobber "live" physical registers. Previously it was only checking target nodes with implicit defs.
llvm-svn: 65996
This commit is contained in:
parent
94ef615585
commit
db402a7a49
@ -580,6 +580,30 @@ static MVT getPhysicalRegisterVT(SDNode *N, unsigned Reg,
|
||||
return N->getValueType(NumRes);
|
||||
}
|
||||
|
||||
/// CheckForLiveRegDef - Return true and update live register vector if the
|
||||
/// specified register def of the specified SUnit clobbers any "live" registers.
|
||||
static bool CheckForLiveRegDef(SUnit *SU, unsigned Reg,
|
||||
std::vector<SUnit*> &LiveRegDefs,
|
||||
SmallSet<unsigned, 4> &RegAdded,
|
||||
SmallVector<unsigned, 4> &LRegs,
|
||||
const TargetRegisterInfo *TRI) {
|
||||
bool Added = false;
|
||||
if (LiveRegDefs[Reg] && LiveRegDefs[Reg] != SU) {
|
||||
if (RegAdded.insert(Reg)) {
|
||||
LRegs.push_back(Reg);
|
||||
Added = true;
|
||||
}
|
||||
}
|
||||
for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias)
|
||||
if (LiveRegDefs[*Alias] && LiveRegDefs[*Alias] != SU) {
|
||||
if (RegAdded.insert(*Alias)) {
|
||||
LRegs.push_back(*Alias);
|
||||
Added = true;
|
||||
}
|
||||
}
|
||||
return Added;
|
||||
}
|
||||
|
||||
/// DelayForLiveRegsBottomUp - Returns true if it is necessary to delay
|
||||
/// scheduling of the given node to satisfy live physical register dependencies.
|
||||
/// If the specific node is the last one that's available to schedule, do
|
||||
@ -593,39 +617,44 @@ bool ScheduleDAGRRList::DelayForLiveRegsBottomUp(SUnit *SU,
|
||||
// If this node would clobber any "live" register, then it's not ready.
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->isAssignedRegDep()) {
|
||||
unsigned Reg = I->getReg();
|
||||
if (LiveRegDefs[Reg] && LiveRegDefs[Reg] != I->getSUnit()) {
|
||||
if (RegAdded.insert(Reg))
|
||||
LRegs.push_back(Reg);
|
||||
}
|
||||
for (const unsigned *Alias = TRI->getAliasSet(Reg);
|
||||
*Alias; ++Alias)
|
||||
if (LiveRegDefs[*Alias] && LiveRegDefs[*Alias] != I->getSUnit()) {
|
||||
if (RegAdded.insert(*Alias))
|
||||
LRegs.push_back(*Alias);
|
||||
}
|
||||
}
|
||||
if (I->isAssignedRegDep())
|
||||
CheckForLiveRegDef(I->getSUnit(), I->getReg(), LiveRegDefs,
|
||||
RegAdded, LRegs, TRI);
|
||||
}
|
||||
|
||||
for (SDNode *Node = SU->getNode(); Node; Node = Node->getFlaggedNode()) {
|
||||
if (Node->getOpcode() == ISD::INLINEASM) {
|
||||
// Inline asm can clobber physical defs.
|
||||
unsigned NumOps = Node->getNumOperands();
|
||||
if (Node->getOperand(NumOps-1).getValueType() == MVT::Flag)
|
||||
--NumOps; // Ignore the flag operand.
|
||||
|
||||
for (unsigned i = 2; i != NumOps;) {
|
||||
unsigned Flags =
|
||||
cast<ConstantSDNode>(Node->getOperand(i))->getZExtValue();
|
||||
unsigned NumVals = Flags >> 3;
|
||||
|
||||
++i; // Skip the ID value.
|
||||
if ((Flags & 7) == 2 || (Flags & 7) == 6) {
|
||||
// Check for def of register or earlyclobber register.
|
||||
for (; NumVals; --NumVals, ++i) {
|
||||
unsigned Reg = cast<RegisterSDNode>(Node->getOperand(i))->getReg();
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
CheckForLiveRegDef(SU, Reg, LiveRegDefs, RegAdded, LRegs, TRI);
|
||||
}
|
||||
} else
|
||||
i += NumVals;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Node->isMachineOpcode())
|
||||
continue;
|
||||
const TargetInstrDesc &TID = TII->get(Node->getMachineOpcode());
|
||||
if (!TID.ImplicitDefs)
|
||||
continue;
|
||||
for (const unsigned *Reg = TID.ImplicitDefs; *Reg; ++Reg) {
|
||||
if (LiveRegDefs[*Reg] && LiveRegDefs[*Reg] != SU) {
|
||||
if (RegAdded.insert(*Reg))
|
||||
LRegs.push_back(*Reg);
|
||||
}
|
||||
for (const unsigned *Alias = TRI->getAliasSet(*Reg);
|
||||
*Alias; ++Alias)
|
||||
if (LiveRegDefs[*Alias] && LiveRegDefs[*Alias] != SU) {
|
||||
if (RegAdded.insert(*Alias))
|
||||
LRegs.push_back(*Alias);
|
||||
}
|
||||
}
|
||||
for (const unsigned *Reg = TID.ImplicitDefs; *Reg; ++Reg)
|
||||
CheckForLiveRegDef(SU, *Reg, LiveRegDefs, RegAdded, LRegs, TRI);
|
||||
}
|
||||
return !LRegs.empty();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ let Namespace = "X86" in {
|
||||
def ST7 : Register<"st(7)">, DwarfRegNum<[40, 19, 18]>;
|
||||
|
||||
// Status flags register
|
||||
def EFLAGS : Register<"eflags">;
|
||||
def EFLAGS : Register<"flags">;
|
||||
}
|
||||
|
||||
|
||||
|
17
test/CodeGen/X86/pr3701.ll
Normal file
17
test/CodeGen/X86/pr3701.ll
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: llvm-as < %s | llc -march=x86-64 | %prcontext test 1 | grep j
|
||||
; PR3701
|
||||
|
||||
define i64 @t(i64* %arg) nounwind {
|
||||
br i1 true, label %1, label %5
|
||||
|
||||
; <label>:1 ; preds = %0
|
||||
%2 = icmp eq i64* null, %arg ; <i1> [#uses=1]
|
||||
%3 = tail call i64* asm sideeffect "movl %fs:0,$0", "=r,~{dirflag},~{fpsr},~{flags}"() nounwind ; <%struct.thread*> [#uses=0]
|
||||
br i1 %2, label %4, label %5
|
||||
|
||||
; <label>:4 ; preds = %1
|
||||
ret i64 1
|
||||
|
||||
; <label>:5 ; preds = %1
|
||||
ret i64 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user