[PATCH] D20162: [MSP430] PR27500 CodeGen: Rework branch-select pass
Anton Korobeynikov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 30 12:59:52 PDT 2016
asl added inline comments.
================
Comment at: lib/Target/MSP430/MSP430BranchSelector.cpp:31
@@ -29,1 +30,3 @@
+static const int WordSize = 2;
+static const int DisplacementBits = 10;
----------------
Why these are ints? And not inside namespace { ?
================
Comment at: lib/Target/MSP430/MSP430BranchSelector.cpp:49
@@ -41,1 +48,3 @@
+ /// the beginning of each basic block.
+ SmallVector<int, 16> BlockOffsets;
----------------
Why this should be a member variable? It's effectively only used inside "expandBranches". Make it local there and you won't need all that error-prone BlockOffsets.clear() dance.
================
Comment at: lib/Target/MSP430/MSP430BranchSelector.cpp:79
@@ -59,1 +78,3 @@
+ int Words = DistanceInBytes / WordSize;
+ return isInt<DisplacementBits>(Words);
}
----------------
DisplacementBits is only used here. Why should it be static const variable after all?
================
Comment at: lib/Target/MSP430/MSP430BranchSelector.cpp:102
@@ +101,3 @@
+/// Renumber blocks and recompute all BlockOffsets, starting from BB
+void MSP430BSel::correctBlockOffsets(MachineBasicBlock *FromBB) {
+ MF->RenumberBlocks(FromBB);
----------------
This is pretty similar to measureFunction(). Please merge into a single one to reduce code duplication.
http://reviews.llvm.org/D20162
More information about the llvm-commits
mailing list