-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SimplifyCFG] Teach mergeEmptyReturnBlocks() to preserve DomTree
A first real transformation that didn't already knew how to do that, but it's pretty tame - either change successor of all the predecessors of a block and carefully delay deletion of the block until afterwards the DomTree updates are appled, or add a successor to the block. There wasn't a great test coverage for this, so i added extra, to be sure.
- Loading branch information
Showing
4 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
llvm/test/Transforms/SimplifyCFG/merge-empty-return-blocks.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s | ||
|
||
define void @t0(i1 %c) { | ||
; CHECK-LABEL: @t0( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br i1 %c, label %end0, label %end1 | ||
|
||
end0: | ||
ret void | ||
|
||
end1: | ||
ret void | ||
} | ||
|
||
define i8 @t1(i1 %c, i8 %v) { | ||
; CHECK-LABEL: @t1( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: ret i8 [[V:%.*]] | ||
; | ||
entry: | ||
br i1 %c, label %end0, label %end1 | ||
|
||
end0: | ||
ret i8 %v | ||
|
||
end1: | ||
ret i8 %v | ||
} | ||
|
||
define i8 @t2(i1 %c, i8 %v0, i8 %v1) { | ||
; CHECK-LABEL: @t2( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], i8 [[V0:%.*]], i8 [[V1:%.*]] | ||
; CHECK-NEXT: ret i8 [[SPEC_SELECT]] | ||
; | ||
entry: | ||
br i1 %c, label %end0, label %end1 | ||
|
||
end0: | ||
ret i8 %v0 | ||
|
||
end1: | ||
ret i8 %v1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters