aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCHazardRecognizers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/PowerPC/PPCHazardRecognizers.cpp')
-rw-r--r--lib/Target/PowerPC/PPCHazardRecognizers.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCHazardRecognizers.cpp b/lib/Target/PowerPC/PPCHazardRecognizers.cpp
index c90e2951a3..ae317af482 100644
--- a/lib/Target/PowerPC/PPCHazardRecognizers.cpp
+++ b/lib/Target/PowerPC/PPCHazardRecognizers.cpp
@@ -61,6 +61,7 @@ void PPCHazardRecognizer440::EmitInstruction(SUnit *SU) {
PPCHazardRecognizer970::PPCHazardRecognizer970(const TargetInstrInfo &tii)
: TII(tii) {
+ LastWasBL8_ELF = false;
EndDispatchGroup();
}
@@ -132,6 +133,14 @@ getHazardType(SUnit *SU, int Stalls) {
unsigned Opcode = MI->getOpcode();
+ // If the last instruction was a BL8_ELF, then the NOP must follow it
+ // directly (this is strong requirement from the linker due to the ELF ABI).
+ // We return only Hazard (and not NoopHazard) because if the NOP is necessary
+ // then it will already be in the instruction stream (it is not always
+ // necessary; tail calls, for example, do not need it).
+ if (LastWasBL8_ELF && Opcode != PPC::NOP)
+ return Hazard;
+
bool isFirst, isSingle, isCracked, isLoad, isStore;
PPCII::PPC970_Unit InstrType =
GetInstrType(Opcode, isFirst, isSingle, isCracked,
@@ -190,6 +199,7 @@ void PPCHazardRecognizer970::EmitInstruction(SUnit *SU) {
return;
unsigned Opcode = MI->getOpcode();
+ LastWasBL8_ELF = (Opcode == PPC::BL8_ELF);
bool isFirst, isSingle, isCracked, isLoad, isStore;
PPCII::PPC970_Unit InstrType =
@@ -230,6 +240,7 @@ void PPCHazardRecognizer970::AdvanceCycle() {
}
void PPCHazardRecognizer970::Reset() {
+ LastWasBL8_ELF = false;
EndDispatchGroup();
}