diff options
author | Vincent Lejeune <vljn@ovi.com> | 2013-12-07 01:49:19 +0000 |
---|---|---|
committer | Vincent Lejeune <vljn@ovi.com> | 2013-12-07 01:49:19 +0000 |
commit | d254d3111e6a1b2dfc31bbfb3abb7cc589d5800b (patch) | |
tree | 27e61aee5fbf363bf04a434b4fabb0e30fc59a35 /lib/CodeGen | |
parent | 7c8fbdac728f104981880783cfb1857796b5e1a2 (diff) | |
download | llvm-d254d3111e6a1b2dfc31bbfb3abb7cc589d5800b.tar.gz llvm-d254d3111e6a1b2dfc31bbfb3abb7cc589d5800b.tar.bz2 llvm-d254d3111e6a1b2dfc31bbfb3abb7cc589d5800b.tar.xz |
Add a RequireStructuredCFG Field to TargetMachine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/MachineBasicBlock.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/Passes.cpp | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 9cd4208d64..a4a3712de8 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/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/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index ca71e3bf80..3d36dc18e3 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/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/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index f4ffd03ec3..db7021372b 100644 --- a/lib/CodeGen/Passes.cpp +++ b/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. |