diff options
| author | bors <bors@rust-lang.org> | 2024-02-26 09:50:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-26 09:50:51 +0000 |
| commit | ee933f6795d2eebcb68417f270162dcae8326f0e (patch) | |
| tree | 12d8304e88f5ab5f585159bfae367d6095d2e5dc /tests/codegen | |
| parent | dc00e8cdb6cfb6c75b4e98cdc181583cb7d11749 (diff) | |
| parent | 76f303d6588bbcf044849f0b3f297173fc9e291c (diff) | |
| download | rust-ee933f6795d2eebcb68417f270162dcae8326f0e.tar.gz rust-ee933f6795d2eebcb68417f270162dcae8326f0e.zip | |
Auto merge of #121627 - GuillaumeGomez:rollup-udp3m0k, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #120656 (Allow tests to specify a `//@ filecheck-flags:` header) - #120840 (Split Diagnostics for Uncommon Codepoints: Add Individual Identifier Types) - #121554 (Don't unnecessarily change `SIGPIPE` disposition in `unix_sigpipe` tests) - #121590 (Correctly handle if rustdoc JS script hash changed) - #121620 (Fix more #121208 fallout (round 3)) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/instrument-coverage/instrument-coverage-off.rs (renamed from tests/codegen/instrument-coverage-off.rs) | 0 | ||||
| -rw-r--r-- | tests/codegen/instrument-coverage/instrument-coverage.rs (renamed from tests/codegen/instrument-coverage.rs) | 0 | ||||
| -rw-r--r-- | tests/codegen/instrument-coverage/testprog.rs | 120 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/check-prefix.rs | 4 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/filecheck-flags.rs | 8 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/msvc-prefix-bad.rs | 7 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/msvc-prefix-good.rs | 7 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/no-directives.rs | 5 | ||||
| -rw-r--r-- | tests/codegen/meta-filecheck/revision-prefix.rs | 8 |
9 files changed, 159 insertions, 0 deletions
diff --git a/tests/codegen/instrument-coverage-off.rs b/tests/codegen/instrument-coverage/instrument-coverage-off.rs index fda3c541a25..fda3c541a25 100644 --- a/tests/codegen/instrument-coverage-off.rs +++ b/tests/codegen/instrument-coverage/instrument-coverage-off.rs diff --git a/tests/codegen/instrument-coverage.rs b/tests/codegen/instrument-coverage/instrument-coverage.rs index f7d96ea3467..f7d96ea3467 100644 --- a/tests/codegen/instrument-coverage.rs +++ b/tests/codegen/instrument-coverage/instrument-coverage.rs diff --git a/tests/codegen/instrument-coverage/testprog.rs b/tests/codegen/instrument-coverage/testprog.rs new file mode 100644 index 00000000000..b352cbdb755 --- /dev/null +++ b/tests/codegen/instrument-coverage/testprog.rs @@ -0,0 +1,120 @@ +//@ edition: 2021 +//@ needs-profiler-support +//@ compile-flags: -Cinstrument-coverage -Copt-level=0 +//@ revisions: LINUX DARWIN WINDOWS + +//@ [LINUX] only-linux +//@ [LINUX] filecheck-flags: -DINSTR_PROF_DATA=__llvm_prf_data +//@ [LINUX] filecheck-flags: -DINSTR_PROF_NAME=__llvm_prf_names +//@ [LINUX] filecheck-flags: -DINSTR_PROF_CNTS=__llvm_prf_cnts +//@ [LINUX] filecheck-flags: -DINSTR_PROF_COVMAP=__llvm_covmap +//@ [LINUX] filecheck-flags: -DINSTR_PROF_COVFUN=__llvm_covfun +//@ [LINUX] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat' + +//@ [DARWIN] only-macos +//@ [DARWIN] filecheck-flags: -DINSTR_PROF_DATA=__DATA,__llvm_prf_data,regular,live_support +//@ [DARWIN] filecheck-flags: -DINSTR_PROF_NAME=__DATA,__llvm_prf_names +//@ [DARWIN] filecheck-flags: -DINSTR_PROF_CNTS=__DATA,__llvm_prf_cnts +//@ [DARWIN] filecheck-flags: -DINSTR_PROF_COVMAP=__LLVM_COV,__llvm_covmap +//@ [DARWIN] filecheck-flags: -DINSTR_PROF_COVFUN=__LLVM_COV,__llvm_covfun +//@ [DARWIN] filecheck-flags: -DCOMDAT_IF_SUPPORTED= + +//@ [WINDOWS] only-windows +//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_DATA=.lprfd$M +//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_NAME=.lprfn$M +//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_CNTS=.lprfc$M +//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_COVMAP=.lcovmap$M +//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_COVFUN=.lcovfun$M +//@ [WINDOWS] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat' + +// ignore-tidy-linelength + +pub fn will_be_called() -> &'static str { + let val = "called"; + println!("{}", val); + val +} + +pub fn will_not_be_called() -> bool { + println!("should not have been called"); + false +} + +pub fn print<T>(left: &str, value: T, right: &str) +where + T: std::fmt::Display, +{ + println!("{}{}{}", left, value, right); +} + +pub fn wrap_with<F, T>(inner: T, should_wrap: bool, wrapper: F) +where + F: FnOnce(&T) +{ + if should_wrap { + wrapper(&inner) + } +} + +fn main() { + let less = 1; + let more = 100; + + if less < more { + wrap_with(will_be_called(), less < more, |inner| print(" ***", inner, "*** ")); + wrap_with(will_be_called(), more < less, |inner| print(" ***", inner, "*** ")); + } else { + wrap_with(will_not_be_called(), true, |inner| print("wrapped result is: ", inner, "")); + } +} + +// Check for metadata, variables, declarations, and function definitions injected +// into LLVM IR when compiling with -Cinstrument-coverage. + +// WINDOWS: $__llvm_profile_runtime_user = comdat any + +// CHECK: @__llvm_coverage_mapping = private constant +// CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8 + +// CHECK: @__covrec_{{[A-F0-9]+}}u = linkonce_odr hidden constant +// CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8 + +// WINDOWS: @__llvm_profile_runtime = external{{.*}}global i32 + +// CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global +// CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8 + +// CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global +// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called +// CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8 + +// CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global +// CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8 + +// CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global +// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main +// CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8 + +// CHECK: @__llvm_prf_nm = private constant +// CHECK-SAME: section "[[INSTR_PROF_NAME]]", align 1 + +// CHECK: @llvm.used = appending global +// CHECK-SAME: @__llvm_coverage_mapping +// CHECK-SAME: @__llvm_prf_nm +// CHECK-SAME: section "llvm.metadata" + +// CHECK: define internal { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} { +// CHECK-NEXT: start: +// CHECK-NOT: define internal +// CHECK: atomicrmw add ptr +// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, + +// CHECK: declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] + +// WINDOWS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat { +// WINDOWS-NEXT: %1 = load i32, ptr @__llvm_profile_runtime +// WINDOWS-NEXT: ret i32 %1 +// WINDOWS-NEXT: } + +// CHECK: attributes #[[LLVM_INSTRPROF_INCREMENT_ATTR]] = { nounwind } +// WINDOWS: attributes #[[LLVM_PROFILE_RUNTIME_USER_ATTR]] = { noinline } diff --git a/tests/codegen/meta-filecheck/check-prefix.rs b/tests/codegen/meta-filecheck/check-prefix.rs new file mode 100644 index 00000000000..98bec68627e --- /dev/null +++ b/tests/codegen/meta-filecheck/check-prefix.rs @@ -0,0 +1,4 @@ +// Simple test that uses the default CHECK prefix and should always succeed. + +// CHECK: main +fn main() {} diff --git a/tests/codegen/meta-filecheck/filecheck-flags.rs b/tests/codegen/meta-filecheck/filecheck-flags.rs new file mode 100644 index 00000000000..8e451cf4fdc --- /dev/null +++ b/tests/codegen/meta-filecheck/filecheck-flags.rs @@ -0,0 +1,8 @@ +// Arguments provided via `filecheck-flags` should be passed to `filecheck`. + +//@ revisions: good bad +//@ [good] filecheck-flags: --check-prefix=CUSTOM +//@ [bad] should-fail + +// CUSTOM: main +fn main() {} diff --git a/tests/codegen/meta-filecheck/msvc-prefix-bad.rs b/tests/codegen/meta-filecheck/msvc-prefix-bad.rs new file mode 100644 index 00000000000..f9984c74e2a --- /dev/null +++ b/tests/codegen/meta-filecheck/msvc-prefix-bad.rs @@ -0,0 +1,7 @@ +// This is exactly like `msvc-prefix-good.rs`, except that it should always fail. + +//@ should-fail + +// MSVC: text that should not match +// NONMSVC: text that should not match +fn main() {} diff --git a/tests/codegen/meta-filecheck/msvc-prefix-good.rs b/tests/codegen/meta-filecheck/msvc-prefix-good.rs new file mode 100644 index 00000000000..580d20d5438 --- /dev/null +++ b/tests/codegen/meta-filecheck/msvc-prefix-good.rs @@ -0,0 +1,7 @@ +// One of MSVC or NONMSVC should always be defined, so this test should pass. + +// (one of these should always be present) + +// MSVC: main +// NONMSVC: main +fn main() {} diff --git a/tests/codegen/meta-filecheck/no-directives.rs b/tests/codegen/meta-filecheck/no-directives.rs new file mode 100644 index 00000000000..2cab263604e --- /dev/null +++ b/tests/codegen/meta-filecheck/no-directives.rs @@ -0,0 +1,5 @@ +// A test that doesn't include any filecheck directives should fail. + +//@ should-fail + +fn main() {} diff --git a/tests/codegen/meta-filecheck/revision-prefix.rs b/tests/codegen/meta-filecheck/revision-prefix.rs new file mode 100644 index 00000000000..431066e3acc --- /dev/null +++ b/tests/codegen/meta-filecheck/revision-prefix.rs @@ -0,0 +1,8 @@ +// The current revision name is registered as a filecheck prefix. + +//@ revisions: GOOD BAD +//@ [BAD] should-fail + +// GOOD: main +// BAD: text that should not match +fn main() {} |
