[llvm-branch-commits] [llvm] 72cb90b - [PhaseOrdering] Add test for DAE/GlobalDCE interaction (NFC)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 23 07:34:53 PDT 2023
Author: Nikita Popov
Date: 2023-03-23T15:32:38+01:00
New Revision: 72cb90bd7b628022d822215dd4b38a36f2802fbd
URL: https://github.com/llvm/llvm-project/commit/72cb90bd7b628022d822215dd4b38a36f2802fbd
DIFF: https://github.com/llvm/llvm-project/commit/72cb90bd7b628022d822215dd4b38a36f2802fbd.diff
LOG: [PhaseOrdering] Add test for DAE/GlobalDCE interaction (NFC)
(cherry picked from commit 8df140c860f16706ee34935f95cab391bbd19627)
Added:
llvm/test/Transforms/PhaseOrdering/dae-dce.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/PhaseOrdering/dae-dce.ll b/llvm/test/Transforms/PhaseOrdering/dae-dce.ll
new file mode 100644
index 0000000000000..8a0a36ef6cff9
--- /dev/null
+++ b/llvm/test/Transforms/PhaseOrdering/dae-dce.ll
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes='default<O3>' < %s | FileCheck %s --check-prefixes=CHECK,DEFAULT
+; RUN: opt -S -passes='lto<O3>' < %s | FileCheck %s --check-prefixes=CHECK,LTO
+
+declare void @llvm.trap()
+
+define void @do_trap(ptr %ptr) {
+; CHECK-LABEL: @do_trap(
+; CHECK-NEXT: tail call void @llvm.trap()
+; CHECK-NEXT: unreachable
+;
+ call void @llvm.trap()
+ unreachable
+}
+
+define internal void @capture_and_trap(ptr %ptr) noinline {
+; CHECK-LABEL: @capture_and_trap(
+; CHECK-NEXT: tail call void @llvm.trap()
+; CHECK-NEXT: unreachable
+;
+ %alloca = alloca ptr, align 4
+ store ptr %ptr, ptr %alloca, align 4
+ call void @do_trap(ptr noundef nonnull %alloca)
+ unreachable
+}
+
+define internal void @dead_fn1() {
+; LTO-LABEL: @dead_fn1(
+; LTO-NEXT: ret void
+;
+ ret void
+}
+
+define internal void @dead_fn2() {
+; LTO-LABEL: @dead_fn2(
+; LTO-NEXT: ret void
+;
+ ret void
+}
+
+define void @test(i1 %c) {
+; DEFAULT-LABEL: @test(
+; DEFAULT-NEXT: tail call fastcc void @capture_and_trap()
+; DEFAULT-NEXT: unreachable
+;
+; LTO-LABEL: @test(
+; LTO-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
+; LTO: if:
+; LTO-NEXT: tail call fastcc void @capture_and_trap(ptr nonnull @dead_fn1)
+; LTO-NEXT: unreachable
+; LTO: else:
+; LTO-NEXT: tail call fastcc void @capture_and_trap(ptr nonnull @dead_fn2)
+; LTO-NEXT: unreachable
+;
+ br i1 %c, label %if, label %else
+
+if:
+ call void @capture_and_trap(ptr @dead_fn1)
+ unreachable
+
+else:
+ call void @capture_and_trap(ptr @dead_fn2)
+ unreachable
+}
More information about the llvm-branch-commits
mailing list