[llvm] r182063 - [Sparc] Prevent instructions that defines or uses %o7 to be in call's delay slot.
Venkatraman Govindaraju
venkatra at cs.wisc.edu
Thu May 16 16:53:29 PDT 2013
Author: venkatra
Date: Thu May 16 18:53:29 2013
New Revision: 182063
URL: http://llvm.org/viewvc/llvm-project?rev=182063&view=rev
Log:
[Sparc] Prevent instructions that defines or uses %o7 to be in call's delay slot.
Modified:
llvm/trunk/lib/Target/Sparc/DelaySlotFiller.cpp
llvm/trunk/test/CodeGen/SPARC/2011-01-19-DelaySlot.ll
Modified: llvm/trunk/lib/Target/Sparc/DelaySlotFiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/DelaySlotFiller.cpp?rev=182063&r1=182062&r2=182063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/DelaySlotFiller.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/DelaySlotFiller.cpp Thu May 16 18:53:29 2013
@@ -61,8 +61,9 @@ namespace {
bool isDelayFiller(MachineBasicBlock &MBB,
MachineBasicBlock::iterator candidate);
- void insertCallUses(MachineBasicBlock::iterator MI,
- SmallSet<unsigned, 32>& RegUses);
+ void insertCallDefsUses(MachineBasicBlock::iterator MI,
+ SmallSet<unsigned, 32>& RegDefs,
+ SmallSet<unsigned, 32>& RegUses);
void insertDefsUses(MachineBasicBlock::iterator MI,
SmallSet<unsigned, 32>& RegDefs,
@@ -150,7 +151,7 @@ Filler::findDelayInstr(MachineBasicBlock
//Call's delay filler can def some of call's uses.
if (slot->isCall())
- insertCallUses(slot, RegUses);
+ insertCallDefsUses(slot, RegDefs, RegUses);
else
insertDefsUses(slot, RegDefs, RegUses);
@@ -230,9 +231,12 @@ bool Filler::delayHasHazard(MachineBasic
}
-void Filler::insertCallUses(MachineBasicBlock::iterator MI,
- SmallSet<unsigned, 32>& RegUses)
+void Filler::insertCallDefsUses(MachineBasicBlock::iterator MI,
+ SmallSet<unsigned, 32>& RegDefs,
+ SmallSet<unsigned, 32>& RegUses)
{
+ //Call defines o7, which is visible to the instruction in delay slot.
+ RegDefs.insert(SP::O7);
switch(MI->getOpcode()) {
default: llvm_unreachable("Unknown opcode.");
Modified: llvm/trunk/test/CodeGen/SPARC/2011-01-19-DelaySlot.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2011-01-19-DelaySlot.ll?rev=182063&r1=182062&r2=182063&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/2011-01-19-DelaySlot.ll (original)
+++ llvm/trunk/test/CodeGen/SPARC/2011-01-19-DelaySlot.ll Thu May 16 18:53:29 2013
@@ -87,4 +87,21 @@ entry:
ret i32 0
}
+define i32 @prevent_o7_in_call_delay_slot(i32 %i0) {
+entry:
+;CHECK: prevent_o7_in_call_delay_slot
+;CHECK: add %i0, 2, %o5
+;CHECK: add %i0, 3, %o7
+;CHECK: add %o5, %o7, %o0
+;CHECK: call bar
+;CHECK-NEXT: nop
+ %0 = add nsw i32 %i0, 2
+ %1 = add nsw i32 %i0, 3
+ tail call void asm sideeffect "", "r,r,~{l0},~{l1},~{l2},~{l3},~{l4},~{l5},~{l6},~{l7},~{i0},~{i1},~{i2},~{i3},~{i4},~{i5},~{i6},~{i7},~{o0},~{o1},~{o2},~{o3},~{o4}"(i32 %0, i32 %1)
+ %2 = add nsw i32 %0, %1
+ %3 = tail call i32 @bar(i32 %2)
+ ret i32 %3
+}
+
+
declare i32 @func(i32*)
More information about the llvm-commits
mailing list