mirror of
https://github.com/obfuscator-llvm/obfuscator
synced 2026-06-08 16:28:34 +00:00
Initial commit of LLVM 3.4
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "llvm/CodeGen/LiveVariables.h"
|
||||
#include "llvm/CodeGen/MachineDominators.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/SlotIndexes.h"
|
||||
@@ -51,7 +52,7 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
|
||||
if (!CachedMCSymbol) {
|
||||
const MachineFunction *MF = getParent();
|
||||
MCContext &Ctx = MF->getContext();
|
||||
const char *Prefix = Ctx.getAsmInfo().getPrivateGlobalPrefix();
|
||||
const char *Prefix = Ctx.getAsmInfo()->getPrivateGlobalPrefix();
|
||||
CachedMCSymbol = Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" +
|
||||
Twine(MF->getFunctionNumber()) +
|
||||
"_" + Twine(getNumber()));
|
||||
@@ -341,6 +342,38 @@ bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
|
||||
return I != livein_end();
|
||||
}
|
||||
|
||||
unsigned
|
||||
MachineBasicBlock::addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC) {
|
||||
assert(getParent() && "MBB must be inserted in function");
|
||||
assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) && "Expected physreg");
|
||||
assert(RC && "Register class is required");
|
||||
assert((isLandingPad() || this == &getParent()->front()) &&
|
||||
"Only the entry block and landing pads can have physreg live ins");
|
||||
|
||||
bool LiveIn = isLiveIn(PhysReg);
|
||||
iterator I = SkipPHIsAndLabels(begin()), E = end();
|
||||
MachineRegisterInfo &MRI = getParent()->getRegInfo();
|
||||
const TargetInstrInfo &TII = *getParent()->getTarget().getInstrInfo();
|
||||
|
||||
// Look for an existing copy.
|
||||
if (LiveIn)
|
||||
for (;I != E && I->isCopy(); ++I)
|
||||
if (I->getOperand(1).getReg() == PhysReg) {
|
||||
unsigned VirtReg = I->getOperand(0).getReg();
|
||||
if (!MRI.constrainRegClass(VirtReg, RC))
|
||||
llvm_unreachable("Incompatible live-in register class.");
|
||||
return VirtReg;
|
||||
}
|
||||
|
||||
// No luck, create a virtual register.
|
||||
unsigned VirtReg = MRI.createVirtualRegister(RC);
|
||||
BuildMI(*this, I, DebugLoc(), TII.get(TargetOpcode::COPY), VirtReg)
|
||||
.addReg(PhysReg, RegState::Kill);
|
||||
if (!LiveIn)
|
||||
addLiveIn(PhysReg);
|
||||
return VirtReg;
|
||||
}
|
||||
|
||||
void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
|
||||
getParent()->splice(NewAfter, this);
|
||||
}
|
||||
@@ -828,7 +861,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
|
||||
LiveInterval &LI = LIS->getInterval(Reg);
|
||||
VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
|
||||
assert(VNI && "PHI sources should be live out of their predecessors.");
|
||||
LI.addRange(LiveRange(StartIndex, EndIndex, VNI));
|
||||
LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -847,9 +880,9 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
|
||||
if (isLiveOut && isLastMBB) {
|
||||
VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
|
||||
assert(VNI && "LiveInterval should have VNInfo where it is live.");
|
||||
LI.addRange(LiveRange(StartIndex, EndIndex, VNI));
|
||||
LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
|
||||
} else if (!isLiveOut && !isLastMBB) {
|
||||
LI.removeRange(StartIndex, EndIndex);
|
||||
LI.removeSegment(StartIndex, EndIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user