summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorVincent Lejeune <vljn@ovi.com>2013-12-07 01:49:19 +0000
committerVincent Lejeune <vljn@ovi.com>2013-12-07 01:49:19 +0000
commit92b0a64906757ded834bc6e9f8915d889402f3c2 (patch)
treec9a69c1fb74d053799bf2bfa187cdc9541c7ccaa /llvm/lib
parentae7e96062cd49436cee8fa8459c0e9e316fb9fd1 (diff)
downloadbcm5719-llvm-92b0a64906757ded834bc6e9f8915d889402f3c2.tar.gz
bcm5719-llvm-92b0a64906757ded834bc6e9f8915d889402f3c2.zip
Add a RequireStructuredCFG Field to TargetMachine.
llvm-svn: 196634
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp6
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp5
-rw-r--r--llvm/lib/CodeGen/Passes.cpp5
-rw-r--r--llvm/lib/Target/R600/AMDGPUTargetMachine.cpp1
-rw-r--r--llvm/lib/Target/TargetMachine.cpp1
5 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 9cd4208d646..a4a3712de8b 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -83,7 +83,11 @@ INITIALIZE_PASS(BranchFolderPass, "branch-folder",
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
- BranchFolder Folder(PassConfig->getEnableTailMerge(), /*CommonHoist=*/true);
+ // TailMerge can create jump into if branches that make CFG irreducible for
+ // HW that requires structurized CFG.
+ bool EnableTailMerge = !MF.getTarget().requiresStructuredCFG() &&
+ PassConfig->getEnableTailMerge();
+ BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true);
return Folder.OptimizeFunction(MF,
MF.getTarget().getInstrInfo(),
MF.getTarget().getRegisterInfo(),
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index ca71e3bf806..3d36dc18e38 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -677,6 +677,11 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
MachineFunction *MF = getParent();
DebugLoc dl; // FIXME: this is nowhere
+ // Performance might be harmed on HW that implements branching using exec mask
+ // where both sides of the branches are always executed.
+ if (MF->getTarget().requiresStructuredCFG())
+ return NULL;
+
// We may need to update this's terminator, but we can't do that if
// AnalyzeBranch fails. If this uses a jump table, we won't touch it.
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
diff --git a/llvm/lib/CodeGen/Passes.cpp b/llvm/lib/CodeGen/Passes.cpp
index f4ffd03ec3e..db7021372bc 100644
--- a/llvm/lib/CodeGen/Passes.cpp
+++ b/llvm/lib/CodeGen/Passes.cpp
@@ -725,7 +725,10 @@ void TargetPassConfig::addMachineLateOptimization() {
printAndVerify("After BranchFolding");
// Tail duplication.
- if (addPass(&TailDuplicateID))
+ // Note that duplicating tail just increases code size and degrades
+ // performance for targets that require Structured Control Flow.
+ // In addition it can also make CFG irreducible. Thus we disable it.
+ if (!TM->requiresStructuredCFG() && addPass(&TailDuplicateID))
printAndVerify("After TailDuplicate");
// Copy propagation.
diff --git a/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp b/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp
index bc4f5d720ae..b42728550aa 100644
--- a/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/R600/AMDGPUTargetMachine.cpp
@@ -72,6 +72,7 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, StringRef TT,
InstrInfo.reset(new SIInstrInfo(*this));
TLInfo.reset(new SITargetLowering(*this));
}
+ setRequiresStructuredCFG(true);
initAsmInfo();
}
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 9ba78bce7f9..a2350352071 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -55,6 +55,7 @@ TargetMachine::TargetMachine(const Target &T,
MCUseLoc(true),
MCUseCFI(true),
MCUseDwarfDirectory(false),
+ RequireStructuredCFG(false),
Options(Options) {
}
OpenPOWER on IntegriCloud