1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[IRTranslator] Update getOrCreateBB API to use references.

A null basic block is invalid, so just pass a reference.

llvm-svn: 263260
This commit is contained in:
Quentin Colombet 2016-03-11 17:27:43 +00:00
parent 99e21558cf
commit 4c20724407
2 changed files with 7 additions and 5 deletions

View File

@ -114,7 +114,9 @@ private:
/// Get the sequence of VRegs for that \p Val.
unsigned getOrCreateVReg(const Value *Val);
MachineBasicBlock &getOrCreateBB(const BasicBlock *BB);
/// Get the MachineBasicBlock that represents \p BB.
/// If such basic block does not exist, it is created.
MachineBasicBlock &getOrCreateBB(const BasicBlock &BB);
public:
// Ctor, nothing fancy.

View File

@ -51,8 +51,8 @@ unsigned IRTranslator::getOrCreateVReg(const Value *Val) {
return ValReg;
}
MachineBasicBlock &IRTranslator::getOrCreateBB(const BasicBlock *BB) {
MachineBasicBlock *&MBB = BBToMBB[BB];
MachineBasicBlock &IRTranslator::getOrCreateBB(const BasicBlock &BB) {
MachineBasicBlock *&MBB = BBToMBB[&BB];
if (!MBB) {
MachineFunction &MF = MIRBuilder.getMF();
MBB = MF.CreateMachineBasicBlock();
@ -111,7 +111,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &MF) {
MIRBuilder.setFunction(MF);
MRI = &MF.getRegInfo();
// Setup the arguments.
MachineBasicBlock &MBB = getOrCreateBB(&F.front());
MachineBasicBlock &MBB = getOrCreateBB(F.front());
MIRBuilder.setBasicBlock(MBB);
SmallVector<unsigned, 8> VRegArgs;
for (const Argument &Arg: F.args())
@ -122,7 +122,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &MF) {
report_fatal_error("Unable to lower arguments");
for (const BasicBlock &BB: F) {
MachineBasicBlock &MBB = getOrCreateBB(&BB);
MachineBasicBlock &MBB = getOrCreateBB(BB);
MIRBuilder.setBasicBlock(MBB);
for (const Instruction &Inst: BB) {
bool Succeeded = translate(Inst);