aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp6
-rw-r--r--lib/Target/ARM/ARMExpandPseudoInsts.cpp34
2 files changed, 31 insertions, 9 deletions
diff --git a/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index a2887aa81895..8e312dcf276f 100644
--- a/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -853,9 +853,11 @@ AArch64LoadStoreOpt::promoteLoadFromStore(MachineBasicBlock::iterator LoadI,
.addImm(Imms);
}
}
- StoreI->clearRegisterKills(StRt, TRI);
- (void)BitExtMI;
+ // Clear kill flags between store and load.
+ for (MachineInstr &MI : make_range(StoreI->getIterator(),
+ BitExtMI->getIterator()))
+ MI.clearRegisterKills(StRt, TRI);
DEBUG(dbgs() << "Promoting load by replacing :\n ");
DEBUG(StoreI->print(dbgs()));
diff --git a/lib/Target/ARM/ARMExpandPseudoInsts.cpp b/lib/Target/ARM/ARMExpandPseudoInsts.cpp
index 95fcc8dcb453..baa4e0330cf4 100644
--- a/lib/Target/ARM/ARMExpandPseudoInsts.cpp
+++ b/lib/Target/ARM/ARMExpandPseudoInsts.cpp
@@ -1225,16 +1225,36 @@ bool ARMExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
}
case ARM::tTPsoft:
case ARM::TPsoft: {
+ const bool Thumb = Opcode == ARM::tTPsoft;
+
MachineInstrBuilder MIB;
- if (Opcode == ARM::tTPsoft)
+ if (STI->genLongCalls()) {
+ MachineFunction *MF = MBB.getParent();
+ MachineConstantPool *MCP = MF->getConstantPool();
+ unsigned PCLabelID = AFI->createPICLabelUId();
+ MachineConstantPoolValue *CPV =
+ ARMConstantPoolSymbol::Create(MF->getFunction()->getContext(),
+ "__aeabi_read_tp", PCLabelID, 0);
+ unsigned Reg = MI.getOperand(0).getReg();
MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
- TII->get( ARM::tBL))
- .addImm((unsigned)ARMCC::AL).addReg(0)
- .addExternalSymbol("__aeabi_read_tp", 0);
- else
+ TII->get(Thumb ? ARM::tLDRpci : ARM::LDRi12), Reg)
+ .addConstantPoolIndex(MCP->getConstantPoolIndex(CPV, 4));
+ if (!Thumb)
+ MIB.addImm(0);
+ MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
+
MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
- TII->get( ARM::BL))
- .addExternalSymbol("__aeabi_read_tp", 0);
+ TII->get(Thumb ? ARM::tBLXr : ARM::BLX));
+ if (Thumb)
+ MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
+ MIB.addReg(Reg, RegState::Kill);
+ } else {
+ MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
+ TII->get(Thumb ? ARM::tBL : ARM::BL));
+ if (Thumb)
+ MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
+ MIB.addExternalSymbol("__aeabi_read_tp", 0);
+ }
MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
TransferImpOps(MI, MIB, MIB);