[llvm] b9d8719 - [NFC][SimplifyCFG] Add test for SimplifyCondBranchToTwoReturns() mishandling
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 22 14:37:23 PDT 2021
Author: Roman Lebedev
Date: 2021-07-23T00:36:59+03:00
New Revision: b9d8719a04350c27eb5542f4da579a8ad62c8c0b
URL: https://github.com/llvm/llvm-project/commit/b9d8719a04350c27eb5542f4da579a8ad62c8c0b
DIFF: https://github.com/llvm/llvm-project/commit/b9d8719a04350c27eb5542f4da579a8ad62c8c0b.diff
LOG: [NFC][SimplifyCFG] Add test for SimplifyCondBranchToTwoReturns() mishandling
Added:
Modified:
llvm/test/Transforms/SimplifyCFG/return-merge.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SimplifyCFG/return-merge.ll b/llvm/test/Transforms/SimplifyCFG/return-merge.ll
index 0b7aede886fb..44c218399d54 100644
--- a/llvm/test/Transforms/SimplifyCFG/return-merge.ll
+++ b/llvm/test/Transforms/SimplifyCFG/return-merge.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=CHECK %s
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=CHECK,NODUPRET %s
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-dup-ret -S | FileCheck --check-prefixes=CHECK,DUPRET %s
; RUN: opt < %s -debugify -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=DBGINFO %s
define i32 @test1(i1 %C) {
@@ -23,9 +24,12 @@ F: ; preds = %entry
}
define void @test2(i1 %C) {
-; CHECK-LABEL: @test2(
-; CHECK-NEXT: common.ret:
-; CHECK-NEXT: ret void
+; NODUPRET-LABEL: @test2(
+; NODUPRET-NEXT: common.ret:
+; NODUPRET-NEXT: ret void
+;
+; DUPRET-LABEL: @test2(
+; DUPRET-NEXT: ret void
;
; DBGINFO-LABEL: @test2(
; DBGINFO-NEXT: common.ret:
@@ -39,3 +43,66 @@ F: ; preds = %0
ret void
}
+declare void @sideeffect0()
+declare void @sideeffect1()
+declare void @sideeffect2()
+
+define i32 @test3(i1 %C0, i1 %C1, i32 %v0, i32 %v1, i32 %v2) {
+; NODUPRET-LABEL: @test3(
+; NODUPRET-NEXT: entry:
+; NODUPRET-NEXT: call void @sideeffect0()
+; NODUPRET-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]]
+; NODUPRET: T:
+; NODUPRET-NEXT: call void @sideeffect1()
+; NODUPRET-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]]
+; NODUPRET-NEXT: ret i32 [[SPEC_SELECT]]
+; NODUPRET: F:
+; NODUPRET-NEXT: call void @sideeffect2()
+; NODUPRET-NEXT: ret i32 [[V2:%.*]]
+;
+; DUPRET-LABEL: @test3(
+; DUPRET-NEXT: entry:
+; DUPRET-NEXT: call void @sideeffect0()
+; DUPRET-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]]
+; DUPRET: T:
+; DUPRET-NEXT: call void @sideeffect1()
+; DUPRET-NEXT: [[RETVAL:%.*]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]]
+; DUPRET-NEXT: ret i32 [[RETVAL]]
+; DUPRET: F:
+; DUPRET-NEXT: call void @sideeffect2()
+; DUPRET-NEXT: ret i32 [[V2:%.*]]
+;
+; DBGINFO-LABEL: @test3(
+; DBGINFO-NEXT: entry:
+; DBGINFO-NEXT: call void @sideeffect0(), !dbg [[DBG21:![0-9]+]]
+; DBGINFO-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]], !dbg [[DBG22:![0-9]+]]
+; DBGINFO: T:
+; DBGINFO-NEXT: call void @sideeffect1(), !dbg [[DBG23:![0-9]+]]
+; DBGINFO-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]], !dbg [[DBG24:![0-9]+]]
+; DBGINFO-NEXT: ret i32 [[SPEC_SELECT]], !dbg [[DBG24]]
+; DBGINFO: F:
+; DBGINFO-NEXT: call void @sideeffect2(), !dbg [[DBG25:![0-9]+]]
+; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 [[V2:%.*]], metadata [[META20:![0-9]+]], metadata !DIExpression()), !dbg [[DBG26:![0-9]+]]
+; DBGINFO-NEXT: ret i32 [[V2]], !dbg [[DBG27:![0-9]+]]
+;
+entry:
+ call void @sideeffect0()
+ br i1 %C0, label %T, label %F
+
+T.cont:
+ ; empty block with single predecessor
+ br label %end
+
+end:
+ %r = phi i32 [ %v0, %T.cont ], [ %v1, %T ], [ %v2, %F ]
+ ; empty block
+ ret i32 %r
+
+T:
+ call void @sideeffect1()
+ br i1 %C1, label %T.cont, label %end
+
+F:
+ call void @sideeffect2()
+ br label %end
+}
More information about the llvm-commits
mailing list