diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2016-04-14 17:42:35 +0000 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2016-04-14 17:42:35 +0000 |
commit | 05b127da063133a2702c4399d97e14f43492a596 (patch) | |
tree | 0cf7cee370ad197cb13fc8ee1012570bab58985b /llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | |
parent | 723b73b4eb70d4015bb32ec94c6a782608c5112b (diff) | |
download | llvm-05b127da063133a2702c4399d97e14f43492a596.zip llvm-05b127da063133a2702c4399d97e14f43492a596.tar.gz llvm-05b127da063133a2702c4399d97e14f43492a596.tar.bz2 |
[StructurizeCFG] Annotate branches that were treated as uniform
Summary:
This fully solves the problem where the StructurizeCFG pass does not
consider the same branches as uniform as the SIAnnotateControlFlow pass.
The patch in D19013 helps with this problem, but is not sufficient
(and, interestingly, causes a "regression" with one of the existing
test cases).
No tests included here, because tests in D19013 already cover this.
Reviewers: arsenm, tstellarAMD
Subscribers: arsenm, llvm-commits
Differential Revision: http://reviews.llvm.org/D19018
llvm-svn: 266346
Diffstat (limited to 'llvm/lib/Transforms/Scalar/StructurizeCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index d456832..675614d 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -951,6 +951,21 @@ bool StructurizeCFG::runOnRegion(Region *R, RGPassManager &RGM) { // TODO: We could probably be smarter here with how we handle sub-regions. if (hasOnlyUniformBranches(R)) { DEBUG(dbgs() << "Skipping region with uniform control flow: " << *R << '\n'); + + // Mark all direct child block terminators as having been treated as + // uniform. To account for a possible future in which non-uniform + // sub-regions are treated more cleverly, indirect children are not + // marked as uniform. + MDNode *MD = MDNode::get(R->getEntry()->getParent()->getContext(), {}); + Region::element_iterator E = R->element_end(); + for (Region::element_iterator I = R->element_begin(); I != E; ++I) { + if (I->isSubRegion()) + continue; + + if (Instruction *Term = I->getEntry()->getTerminator()) + Term->setMetadata("structurizecfg.uniform", MD); + } + return false; } } |