summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2016-05-06 13:23:51 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2016-05-06 13:23:51 +0000
commitf9d8b8ccc5f01023c8a990b71f1e6f5daf755869 (patch)
tree7e7ee919befc7157fc76e74c978050412e96875b /llvm/lib
parenta6cda12179b881731106ee86ee9600e45f6db5d6 (diff)
downloadbcm5719-llvm-f9d8b8ccc5f01023c8a990b71f1e6f5daf755869.tar.gz
bcm5719-llvm-f9d8b8ccc5f01023c8a990b71f1e6f5daf755869.zip
[mips][mips16] Use isUnconditionalBranch() in AnalyzeBranch() and constant island pass.
Summary: This stops it misidentifying unconditional branches as conditional branches which fixes a -verify-machineinstrs error about exiting a function via fall through. Reviewers: sdardis Subscribers: dsanders, sdardis, llvm-commits Differential Revision: http://reviews.llvm.org/D19864 llvm-svn: 268731
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Mips/MipsConstantIslandPass.cpp12
-rw-r--r--llvm/lib/Target/Mips/MipsInstrInfo.cpp6
2 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
index a3ea1526629..3b8d3a2ef7d 100644
--- a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
+++ b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
@@ -97,16 +97,6 @@ static unsigned int branchTargetOperand(MachineInstr *MI) {
llvm_unreachable("Unknown branch type");
}
-static bool isUnconditionalBranch(unsigned int Opcode) {
- switch (Opcode) {
- default: return false;
- case Mips::Bimm16:
- case Mips::BimmX16:
- case Mips::JalB16:
- return true;
- }
-}
-
static unsigned int longformBranchOpcode(unsigned int Opcode) {
switch (Opcode) {
case Mips::Bimm16:
@@ -1615,7 +1605,7 @@ MipsConstantIslands::fixupConditionalBr(ImmBranch &Br) {
++NumCBrFixed;
if (BMI != MI) {
if (std::next(MachineBasicBlock::iterator(MI)) == std::prev(MBB->end()) &&
- isUnconditionalBranch(BMI->getOpcode())) {
+ BMI->isUnconditionalBranch()) {
// Last MI in the BB is an unconditional branch. Can we simply invert the
// condition and swap destinations:
// beqz L1
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.cpp b/llvm/lib/Target/Mips/MipsInstrInfo.cpp
index a1bfba0c354..e5c602f35e6 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.cpp
@@ -216,7 +216,7 @@ MipsInstrInfo::BranchType MipsInstrInfo::AnalyzeBranch(
// If there is only one terminator instruction, process it.
if (!SecondLastOpc) {
// Unconditional branch.
- if (LastOpc == UncondBrOpc) {
+ if (LastInst->isUnconditionalBranch()) {
TBB = LastInst->getOperand(0).getMBB();
return BT_Uncond;
}
@@ -235,7 +235,7 @@ MipsInstrInfo::BranchType MipsInstrInfo::AnalyzeBranch(
// If second to last instruction is an unconditional branch,
// analyze it and remove the last instruction.
- if (SecondLastOpc == UncondBrOpc) {
+ if (SecondLastInst->isUnconditionalBranch()) {
// Return if the last instruction cannot be removed.
if (!AllowModify)
return BT_None;
@@ -248,7 +248,7 @@ MipsInstrInfo::BranchType MipsInstrInfo::AnalyzeBranch(
// Conditional branch followed by an unconditional branch.
// The last one must be unconditional.
- if (LastOpc != UncondBrOpc)
+ if (!LastInst->isUnconditionalBranch())
return BT_None;
AnalyzeCondBr(SecondLastInst, SecondLastOpc, TBB, Cond);
OpenPOWER on IntegriCloud