From 04f2f635fb21a444806f85cbcd3eb34909d6ffe2 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 19 Sep 2024 20:03:06 -0400 Subject: [PATCH] Improve test clarity --- tests/codegen/constant-branch.rs | 12 ++++++------ tests/codegen/no-alloca-inside-if-false.rs | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/codegen/constant-branch.rs b/tests/codegen/constant-branch.rs index 8f8438b0b1a45..8fc8fb4f57a20 100644 --- a/tests/codegen/constant-branch.rs +++ b/tests/codegen/constant-branch.rs @@ -7,18 +7,19 @@ // CHECK-LABEL: @if_bool #[no_mangle] pub fn if_bool() { - // CHECK: br label %{{.+}} + // CHECK-NOT: br i1 + // CHECK-NOT: switch _ = if true { 0 } else { 1 }; - // CHECK: br label %{{.+}} _ = if false { 0 } else { 1 }; } // CHECK-LABEL: @if_constant_int_eq #[no_mangle] pub fn if_constant_int_eq() { + // CHECK-NOT: br i1 + // CHECK-NOT: switch let val = 0; - // CHECK: br label %{{.+}} _ = if val == 0 { 0 } else { 1 }; // CHECK: br label %{{.+}} @@ -28,20 +29,19 @@ pub fn if_constant_int_eq() { // CHECK-LABEL: @if_constant_match #[no_mangle] pub fn if_constant_match() { - // CHECK: br label %{{.+}} + // CHECK-NOT: br i1 + // CHECK-NOT: switch _ = match 1 { 1 => 2, 2 => 3, _ => 4, }; - // CHECK: br label %{{.+}} _ = match 1 { 2 => 3, _ => 4, }; - // CHECK: br label %{{.+}} _ = match -1 { -1 => 1, _ => 0, diff --git a/tests/codegen/no-alloca-inside-if-false.rs b/tests/codegen/no-alloca-inside-if-false.rs index 1bfbf71da4d03..187b1460cacb5 100644 --- a/tests/codegen/no-alloca-inside-if-false.rs +++ b/tests/codegen/no-alloca-inside-if-false.rs @@ -1,4 +1,5 @@ //@ compile-flags: -Cno-prepopulate-passes -Copt-level=0 +// Check that there's an alloca for the reference and the vector, but nothing else. #![crate_type = "lib"] @@ -6,9 +7,9 @@ fn test() { // CHECK-LABEL: no_alloca_inside_if_false::test // CHECK: start: - // CHECK-NEXT: %0 = alloca - // CHECK-NEXT: %vec = alloca - // CHECK-NOT: %arr = alloca + // CHECK-NEXT: alloca [{{8|16}} x i8] + // CHECK-NEXT: alloca [{{12|24}} x i8] + // CHECK-NOT: alloca if const { SIZE < 4096 } { let arr = [0u8; SIZE]; std::hint::black_box(&arr); @@ -18,6 +19,8 @@ fn test() { } } +// CHECK-LABEL: @main +#[no_mangle] pub fn main() { test::<8192>(); }