[llvm] r263260 - [IRTranslator] Update getOrCreateBB API to use references.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 09:27:43 PST 2016
Author: qcolombet
Date: Fri Mar 11 11:27:43 2016
New Revision: 263260
URL: http://llvm.org/viewvc/llvm-project?rev=263260&view=rev
Log:
[IRTranslator] Update getOrCreateBB API to use references.
A null basic block is invalid, so just pass a reference.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h?rev=263260&r1=263259&r2=263260&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h Fri Mar 11 11:27:43 2016
@@ -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.
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=263260&r1=263259&r2=263260&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Fri Mar 11 11:27:43 2016
@@ -51,8 +51,8 @@ unsigned IRTranslator::getOrCreateVReg(c
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(
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(
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);
More information about the llvm-commits
mailing list