diff options
| author | Sayan Nandan <17377258+sntdevco@users.noreply.github.com> | 2019-08-09 13:01:05 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-09 13:01:05 +0530 |
| commit | fb3a01354ffecc41d7a189e4dd225d706387a522 (patch) | |
| tree | 41492dfe93f1dccba847dadb56ac6aa079edaaa9 /src/test/codegen | |
| parent | 33445aea509cadcd715009c79795d289268daa7c (diff) | |
| parent | 5aa3d9a7b5d3a46a7f158e8881146331a6bc9243 (diff) | |
| download | rust-fb3a01354ffecc41d7a189e4dd225d706387a522.tar.gz rust-fb3a01354ffecc41d7a189e4dd225d706387a522.zip | |
Merge pull request #1 from rust-lang/master
Merge recent changes into master
Diffstat (limited to 'src/test/codegen')
54 files changed, 543 insertions, 83 deletions
diff --git a/src/test/codegen/adjustments.rs b/src/test/codegen/adjustments.rs index b8398f6ac84..ae2ff9994fd 100644 --- a/src/test/codegen/adjustments.rs +++ b/src/test/codegen/adjustments.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/align-enum.rs b/src/test/codegen/align-enum.rs index 2251c54229e..4241fcea804 100644 --- a/src/test/codegen/align-enum.rs +++ b/src/test/codegen/align-enum.rs @@ -3,7 +3,6 @@ // min-llvm-version 7.0 #![crate_type = "lib"] -#![feature(repr_align_enum)] #[repr(align(64))] pub enum Align64 { diff --git a/src/test/codegen/box-maybe-uninit.rs b/src/test/codegen/box-maybe-uninit.rs index ad1d259a0da..5004f787cde 100644 --- a/src/test/codegen/box-maybe-uninit.rs +++ b/src/test/codegen/box-maybe-uninit.rs @@ -1,6 +1,5 @@ // compile-flags: -O #![crate_type="lib"] -#![feature(maybe_uninit)] use std::mem::MaybeUninit; @@ -12,5 +11,8 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> { // CHECK-NOT: alloca // CHECK-NOT: memcpy // CHECK-NOT: memset - Box::new(MaybeUninit::uninitialized()) + Box::new(MaybeUninit::uninit()) } + +// FIXME: add a test for a bigger box. Currently broken, see +// https://github.com/rust-lang/rust/issues/58201. diff --git a/src/test/codegen/c-variadic-copy.rs b/src/test/codegen/c-variadic-copy.rs new file mode 100644 index 00000000000..4c61c4fcf68 --- /dev/null +++ b/src/test/codegen/c-variadic-copy.rs @@ -0,0 +1,16 @@ +// Tests that `VaListImpl::clone` gets inlined into a call to `llvm.va_copy` + +#![crate_type = "lib"] +#![feature(c_variadic)] +#![no_std] +use core::ffi::VaList; + +extern "C" { + fn foreign_c_variadic_1(_: VaList, ...); +} + +pub unsafe extern "C" fn clone_variadic(ap: VaList) { + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + foreign_c_variadic_1(ap2.as_va_list(), 42i32); +} diff --git a/src/test/codegen/c-variadic-opt.rs b/src/test/codegen/c-variadic-opt.rs index 8594d309b0a..969dce80f58 100644 --- a/src/test/codegen/c-variadic-opt.rs +++ b/src/test/codegen/c-variadic-opt.rs @@ -10,10 +10,21 @@ extern "C" { } // Ensure that `va_start` and `va_end` are properly injected even -// when the "spoofed" `VaList` is not used. +// when the "spoofed" `VaListImpl` is not used. #[no_mangle] pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 { // CHECK: call void @llvm.va_start - vprintf(fmt, ap) + vprintf(fmt, ap.as_va_list()) + // CHECK: call void @llvm.va_end +} + +// Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy` +#[no_mangle] +pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 { + // CHECK: call void @llvm.va_start + let mut ap2 = ap.clone(); + // CHECK: call void @llvm.va_copy + let res = vprintf(fmt, ap2.as_va_list()); + res // CHECK: call void @llvm.va_end } diff --git a/src/test/codegen/c-variadic.rs b/src/test/codegen/c-variadic.rs index 09c18ed90b2..13be5ced27f 100644 --- a/src/test/codegen/c-variadic.rs +++ b/src/test/codegen/c-variadic.rs @@ -23,7 +23,7 @@ pub unsafe extern "C" fn use_foreign_c_variadic_0() { } // Ensure that we do not remove the `va_list` passed to the foreign function when -// removing the "spoofed" `VaList` that is used by Rust defined C-variadics. +// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics. pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) { // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap) foreign_c_variadic_1(ap); diff --git a/src/test/codegen/dllimports/main.rs b/src/test/codegen/dllimports/main.rs index 40bbd2821ef..73631b92c1f 100644 --- a/src/test/codegen/dllimports/main.rs +++ b/src/test/codegen/dllimports/main.rs @@ -1,6 +1,5 @@ // This test is for *-windows-msvc only. // ignore-android -// ignore-bitrig // ignore-cloudabi // ignore-dragonfly // ignore-emscripten @@ -13,6 +12,7 @@ // ignore-netbsd // ignore-openbsd // ignore-solaris +// ignore-sgx no dynamic linking // aux-build:dummy.rs // aux-build:wrapper.rs diff --git a/src/test/codegen/drop.rs b/src/test/codegen/drop.rs index 7e6f8eaaa30..307c4e2c1e2 100644 --- a/src/test/codegen/drop.rs +++ b/src/test/codegen/drop.rs @@ -19,15 +19,18 @@ pub fn droppy() { // that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the // regular function exit. We used to have problems with quadratic growths of drop calls in such // functions. -// CHECK-NOT: invoke{{.*}}drop{{.*}}SomeUniqueName -// CHECK: call{{.*}}drop{{.*}}SomeUniqueName -// CHECK: call{{.*}}drop{{.*}}SomeUniqueName -// CHECK-NOT: call{{.*}}drop{{.*}}SomeUniqueName -// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName -// CHECK: call{{.*}}drop{{.*}}SomeUniqueName -// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName -// CHECK: call{{.*}}drop{{.*}}SomeUniqueName -// CHECK-NOT: {{(call|invoke).*}}drop{{.*}}SomeUniqueName +// FIXME(eddyb) the `void @` forces a match on the instruction, instead of the +// comment, that's `; call core::ptr::real_drop_in_place::<drop::SomeUniqueName>` +// for the `v0` mangling, should switch to matching on that once `legacy` is gone. +// CHECK-NOT: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK-NOT: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName +// CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName // The next line checks for the } that ends the function definition // CHECK-LABEL: {{^[}]}} let _s = SomeUniqueName; diff --git a/src/test/codegen/enum-debug-clike.rs b/src/test/codegen/enum-debug-clike.rs index 62cfef5a845..f268c8bcbcc 100644 --- a/src/test/codegen/enum-debug-clike.rs +++ b/src/test/codegen/enum-debug-clike.rs @@ -4,7 +4,7 @@ // ignore-tidy-linelength // ignore-windows -// min-system-llvm-version 7.0 +// min-system-llvm-version 8.0 // compile-flags: -g -C no-prepopulate-passes diff --git a/src/test/codegen/enum-debug-niche-2.rs b/src/test/codegen/enum-debug-niche-2.rs index 369fa1fcfda..0f17976ef49 100644 --- a/src/test/codegen/enum-debug-niche-2.rs +++ b/src/test/codegen/enum-debug-niche-2.rs @@ -4,7 +4,7 @@ // ignore-tidy-linelength // ignore-windows -// min-system-llvm-version 7.0 +// min-system-llvm-version 8.0 // compile-flags: -g -C no-prepopulate-passes @@ -13,7 +13,6 @@ // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} #![feature(never_type)] -#![feature(nll)] #[derive(Copy, Clone)] pub struct Entity { diff --git a/src/test/codegen/enum-debug-niche.rs b/src/test/codegen/enum-debug-niche.rs index 1273a785ba4..2272488375f 100644 --- a/src/test/codegen/enum-debug-niche.rs +++ b/src/test/codegen/enum-debug-niche.rs @@ -2,9 +2,8 @@ // before 7.0, then backported to the Rust LLVM fork. It tests that // optimized enum debug info accurately reflects the enum layout. -// ignore-tidy-linelength // ignore-windows -// min-system-llvm-version 7.0 +// min-system-llvm-version 8.0 // compile-flags: -g -C no-prepopulate-passes diff --git a/src/test/codegen/enum-debug-tagged.rs b/src/test/codegen/enum-debug-tagged.rs index 5c37e40c270..3539aae42ea 100644 --- a/src/test/codegen/enum-debug-tagged.rs +++ b/src/test/codegen/enum-debug-tagged.rs @@ -2,9 +2,8 @@ // before 7.0, then backported to the Rust LLVM fork. It tests that // debug info for tagged (ordinary) enums is properly emitted. -// ignore-tidy-linelength // ignore-windows -// min-system-llvm-version 7.0 +// min-system-llvm-version 8.0 // compile-flags: -g -C no-prepopulate-passes diff --git a/src/test/codegen/external-no-mangle-fns.rs b/src/test/codegen/external-no-mangle-fns.rs index 79d5dc2400c..90288214499 100644 --- a/src/test/codegen/external-no-mangle-fns.rs +++ b/src/test/codegen/external-no-mangle-fns.rs @@ -33,7 +33,9 @@ const HIDDEN: () = { }; // The surrounding item should not accidentally become external -// CHECK: define internal{{.*}} void @_ZN22external_no_mangle_fns1x +// CHECK-LABEL: ; external_no_mangle_fns::x +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define internal #[inline(never)] fn x() { // CHECK: define void @g() diff --git a/src/test/codegen/external-no-mangle-statics.rs b/src/test/codegen/external-no-mangle-statics.rs index 2998000180e..e44373926b7 100644 --- a/src/test/codegen/external-no-mangle-statics.rs +++ b/src/test/codegen/external-no-mangle-statics.rs @@ -75,4 +75,6 @@ fn x() { #[no_mangle] pub static mut P: u8 = 0; } -// CHECK: define internal void @_ZN26external_no_mangle_statics1x{{.*$}} +// CHECK-LABEL: ; external_no_mangle_statics::x +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define internal diff --git a/src/test/codegen/fn-impl-trait-self.rs b/src/test/codegen/fn-impl-trait-self.rs new file mode 100644 index 00000000000..f9113d50197 --- /dev/null +++ b/src/test/codegen/fn-impl-trait-self.rs @@ -0,0 +1,15 @@ +// compile-flags: -g +// +// CHECK-LABEL: @main +// CHECK: {{.*}}DIDerivedType(tag: DW_TAG_pointer_type, name: "fn() -> <recursive_type>",{{.*}} +// +// CHECK: {{.*}}DISubroutineType{{.*}} +// CHECK: {{.*}}DIBasicType(name: "<recur_type>", encoding: DW_ATE_unsigned) + +pub fn foo() -> impl Copy { + foo +} + +fn main() { + let my_res = foo(); +} diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index c2d697fd046..bd121ef24ad 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -2,7 +2,7 @@ // ignore-tidy-linelength #![crate_type = "lib"] -#![feature(custom_attribute)] +#![feature(rustc_attrs)] pub struct S { _field: [i32; 8], @@ -146,7 +146,7 @@ pub fn enum_id_2(x: Option<u8>) -> Option<u8> { // CHECK: noalias i8* @allocator() #[no_mangle] -#[allocator] +#[rustc_allocator] pub fn allocator() -> *const i8 { std::ptr::null() } diff --git a/src/test/codegen/generic-debug.rs b/src/test/codegen/generic-debug.rs index 0bee2a1a868..eea16805c59 100644 --- a/src/test/codegen/generic-debug.rs +++ b/src/test/codegen/generic-debug.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-windows // compile-flags: -g -C no-prepopulate-passes diff --git a/src/test/codegen/i686-macosx-deployment-target.rs b/src/test/codegen/i686-macosx-deployment-target.rs new file mode 100644 index 00000000000..dad376d6677 --- /dev/null +++ b/src/test/codegen/i686-macosx-deployment-target.rs @@ -0,0 +1,26 @@ +// +// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. +// See issue #60235. + +// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "i686-apple-macosx10.9.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/src/test/codegen/i686-no-macosx-deployment-target.rs b/src/test/codegen/i686-no-macosx-deployment-target.rs new file mode 100644 index 00000000000..1cebc49236f --- /dev/null +++ b/src/test/codegen/i686-no-macosx-deployment-target.rs @@ -0,0 +1,26 @@ +// +// Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. +// See issue #60235. + +// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "i686-apple-macosx10.7.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/src/test/codegen/instrument-mcount.rs b/src/test/codegen/instrument-mcount.rs new file mode 100644 index 00000000000..c72d09f7a03 --- /dev/null +++ b/src/test/codegen/instrument-mcount.rs @@ -0,0 +1,7 @@ +// ignore-tidy-linelength +// compile-flags: -Z instrument-mcount + +#![crate_type = "lib"] + +// CHECK: attributes #{{.*}} "instrument-function-entry-inlined"="{{.*}}mcount{{.*}}" "no-frame-pointer-elim"="true" +pub fn foo() {} diff --git a/src/test/codegen/internalize-closures.rs b/src/test/codegen/internalize-closures.rs index 3434820aa8a..8d9192c6fa0 100644 --- a/src/test/codegen/internalize-closures.rs +++ b/src/test/codegen/internalize-closures.rs @@ -4,7 +4,11 @@ pub fn main() { // We want to make sure that closures get 'internal' linkage instead of // 'weak_odr' when they are not shared between codegen units - // CHECK: define internal {{.*}}_ZN20internalize_closures4main{{.*}}$u7b$$u7b$closure$u7d$$u7d$ + // FIXME(eddyb) `legacy` mangling uses `{{closure}}`, while `v0` + // uses `{closure#0}`, switch to the latter once `legacy` is gone. + // CHECK-LABEL: ; internalize_closures::main::{{.*}}closure + // CHECK-NEXT: ; Function Attrs: + // CHECK-NEXT: define internal let c = |x:i32| { x + 1 }; let _ = c(1); } diff --git a/src/test/codegen/exact_div.rs b/src/test/codegen/intrinsics/exact_div.rs index 6a55b492cb1..68eaa39997a 100644 --- a/src/test/codegen/exact_div.rs +++ b/src/test/codegen/intrinsics/exact_div.rs @@ -8,13 +8,13 @@ use std::intrinsics::exact_div; // CHECK-LABEL: @exact_sdiv #[no_mangle] pub unsafe fn exact_sdiv(x: i32, y: i32) -> i32 { -// CHECK: sdiv exact + // CHECK: sdiv exact exact_div(x, y) } // CHECK-LABEL: @exact_udiv #[no_mangle] pub unsafe fn exact_udiv(x: u32, y: u32) -> u32 { -// CHECK: udiv exact + // CHECK: udiv exact exact_div(x, y) } diff --git a/src/test/codegen/likely.rs b/src/test/codegen/intrinsics/likely.rs index c56cf718f98..c5a0185bd48 100644 --- a/src/test/codegen/likely.rs +++ b/src/test/codegen/intrinsics/likely.rs @@ -28,4 +28,3 @@ pub fn check_unlikely(x: i32, y: i32) -> Option<i32> { } } } - diff --git a/src/test/codegen/move-val-init.rs b/src/test/codegen/intrinsics/move-val-init.rs index 6222536b506..6222536b506 100644 --- a/src/test/codegen/move-val-init.rs +++ b/src/test/codegen/intrinsics/move-val-init.rs diff --git a/src/test/codegen/nontemporal.rs b/src/test/codegen/intrinsics/nontemporal.rs index 3a41fb4fab3..3a41fb4fab3 100644 --- a/src/test/codegen/nontemporal.rs +++ b/src/test/codegen/intrinsics/nontemporal.rs diff --git a/src/test/codegen/prefetch.rs b/src/test/codegen/intrinsics/prefetch.rs index 4cd38e14282..4cd38e14282 100644 --- a/src/test/codegen/prefetch.rs +++ b/src/test/codegen/intrinsics/prefetch.rs diff --git a/src/test/codegen/intrinsics/unchecked_math.rs b/src/test/codegen/intrinsics/unchecked_math.rs new file mode 100644 index 00000000000..419c120ede9 --- /dev/null +++ b/src/test/codegen/intrinsics/unchecked_math.rs @@ -0,0 +1,46 @@ +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::*; + +// CHECK-LABEL: @unchecked_add_signed +#[no_mangle] +pub unsafe fn unchecked_add_signed(a: i32, b: i32) -> i32 { + // CHECK: add nsw + unchecked_add(a, b) +} + +// CHECK-LABEL: @unchecked_add_unsigned +#[no_mangle] +pub unsafe fn unchecked_add_unsigned(a: u32, b: u32) -> u32 { + // CHECK: add nuw + unchecked_add(a, b) +} + +// CHECK-LABEL: @unchecked_sub_signed +#[no_mangle] +pub unsafe fn unchecked_sub_signed(a: i32, b: i32) -> i32 { + // CHECK: sub nsw + unchecked_sub(a, b) +} + +// CHECK-LABEL: @unchecked_sub_unsigned +#[no_mangle] +pub unsafe fn unchecked_sub_unsigned(a: u32, b: u32) -> u32 { + // CHECK: sub nuw + unchecked_sub(a, b) +} + +// CHECK-LABEL: @unchecked_mul_signed +#[no_mangle] +pub unsafe fn unchecked_mul_signed(a: i32, b: i32) -> i32 { + // CHECK: mul nsw + unchecked_mul(a, b) +} + +// CHECK-LABEL: @unchecked_mul_unsigned +#[no_mangle] +pub unsafe fn unchecked_mul_unsigned(a: u32, b: u32) -> u32 { + // CHECK: mul nuw + unchecked_mul(a, b) +} diff --git a/src/test/codegen/issue-45222.rs b/src/test/codegen/issue-45222.rs index da65f2dfca5..7f99ca724cf 100644 --- a/src/test/codegen/issue-45222.rs +++ b/src/test/codegen/issue-45222.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] diff --git a/src/test/codegen/issue-45466.rs b/src/test/codegen/issue-45466.rs index 7d6e31cc740..c7954276777 100644 --- a/src/test/codegen/issue-45466.rs +++ b/src/test/codegen/issue-45466.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type="rlib"] diff --git a/src/test/codegen/issue-58881.rs b/src/test/codegen/issue-58881.rs new file mode 100644 index 00000000000..de451324f03 --- /dev/null +++ b/src/test/codegen/issue-58881.rs @@ -0,0 +1,21 @@ +// compile-flags: -C no-prepopulate-passes +// +// only-x86_64 +// ignore-windows + +#![crate_type = "lib"] + +extern "C" { + fn variadic_fn(_: i32, ...); +} + +#[repr(C)] +struct Foo(u8); +#[repr(C)] +struct Bar(u64, u64, u64); + +// Ensure that emit arguments of the correct type. +pub unsafe fn test_call_variadic() { + // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, %Bar* {{.*}}) + variadic_fn(0, Foo(0), Bar(0, 0, 0)) +} diff --git a/src/test/codegen/link-dead-code.rs b/src/test/codegen/link-dead-code.rs index cb3dd07a2a7..de5a237c5f8 100644 --- a/src/test/codegen/link-dead-code.rs +++ b/src/test/codegen/link-dead-code.rs @@ -5,12 +5,18 @@ // This test makes sure that, when -Clink-dead-code is specified, we generate // code for functions that would otherwise be skipped. -// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code8const_fn +// CHECK-LABEL: ; link_dead_code::const_fn +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define hidden const fn const_fn() -> i32 { 1 } -// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code9inline_fn +// CHECK-LABEL: ; link_dead_code::inline_fn +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define hidden #[inline] fn inline_fn() -> i32 { 2 } -// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code10private_fn +// CHECK-LABEL: ; link_dead_code::private_fn +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define hidden fn private_fn() -> i32 { 3 } diff --git a/src/test/codegen/local-generics-in-exe-internalized.rs b/src/test/codegen/local-generics-in-exe-internalized.rs index 6bdbf929193..e5430fbf17a 100644 --- a/src/test/codegen/local-generics-in-exe-internalized.rs +++ b/src/test/codegen/local-generics-in-exe-internalized.rs @@ -2,7 +2,9 @@ // Check that local generics are internalized if they are in the same CGU -// CHECK: define internal {{.*}} @_ZN34local_generics_in_exe_internalized3foo{{.*}} +// CHECK-LABEL: ; local_generics_in_exe_internalized::foo +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define internal pub fn foo<T>(x: T, y: T) -> (T, T) { (x, y) } diff --git a/src/test/codegen/mainsubprogram.rs b/src/test/codegen/mainsubprogram.rs index d886cb88004..790db33437b 100644 --- a/src/test/codegen/mainsubprogram.rs +++ b/src/test/codegen/mainsubprogram.rs @@ -1,14 +1,13 @@ // This test depends on a patch that was committed to upstream LLVM // before 4.0, formerly backported to the Rust LLVM fork. -// ignore-tidy-linelength // ignore-windows // ignore-macos // compile-flags: -g -C no-prepopulate-passes // CHECK-LABEL: @main -// CHECK: {{.*}}DISubprogram{{.*}}name: "main",{{.*}}DIFlagMainSubprogram{{.*}} +// CHECK: {{.*}}DISubprogram{{.*}}name: "main",{{.*}}DI{{(SP)?}}FlagMainSubprogram{{.*}} pub fn main() { } diff --git a/src/test/codegen/mainsubprogramstart.rs b/src/test/codegen/mainsubprogramstart.rs index d91f91ee7ab..d4de9f59ac2 100644 --- a/src/test/codegen/mainsubprogramstart.rs +++ b/src/test/codegen/mainsubprogramstart.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-windows // ignore-macos @@ -7,7 +6,7 @@ #![feature(start)] // CHECK-LABEL: @main -// CHECK: {{.*}}DISubprogram{{.*}}name: "start",{{.*}}DIFlagMainSubprogram{{.*}} +// CHECK: {{.*}}DISubprogram{{.*}}name: "start",{{.*}}DI{{(SP)?}}FlagMainSubprogram{{.*}} #[start] fn start(_: isize, _: *const *const u8) -> isize { diff --git a/src/test/codegen/match.rs b/src/test/codegen/match.rs index 1b46bb3b25f..145d4ba6b4c 100644 --- a/src/test/codegen/match.rs +++ b/src/test/codegen/match.rs @@ -14,12 +14,12 @@ pub fn exhaustive_match(e: E, unit: ()) { // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]] // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]] // CHECK-NEXT: ] +// CHECK: [[B]]: +// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] // CHECK: [[OTHERWISE]]: // CHECK-NEXT: unreachable // CHECK: [[A]]: // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] -// CHECK: [[B]]: -// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] match e { E::A => unit, E::B => unit, diff --git a/src/test/codegen/noreturn-uninhabited.rs b/src/test/codegen/noreturn-uninhabited.rs new file mode 100644 index 00000000000..49f93cf62c7 --- /dev/null +++ b/src/test/codegen/noreturn-uninhabited.rs @@ -0,0 +1,31 @@ +// compile-flags: -g -C no-prepopulate-passes + +#![crate_type = "lib"] + +#[derive(Clone, Copy)] +pub enum EmptyEnum {} + +#[no_mangle] +pub fn empty(x: &EmptyEnum) -> EmptyEnum { + // CHECK: @empty({{.*}}) unnamed_addr #0 + // CHECK-NOT: ret void + // CHECK: call void @llvm.trap() + // CHECK: unreachable + *x +} + +pub struct Foo(String, EmptyEnum); + +#[no_mangle] +pub fn foo(x: String, y: &EmptyEnum) -> Foo { + // CHECK: @foo({{.*}}) unnamed_addr #0 + // CHECK-NOT: ret %Foo + // CHECK: call void @llvm.trap() + // CHECK: unreachable + Foo(x, *y) +} + +// CHECK: attributes #0 = {{{.*}} noreturn {{.*}}} + +// CHECK: DISubprogram(name: "empty", {{.*}} DIFlagNoReturn +// CHECK: DISubprogram(name: "foo", {{.*}} DIFlagNoReturn diff --git a/src/test/codegen/noreturnflag.rs b/src/test/codegen/noreturnflag.rs index fc288eb0cf1..95c100571ce 100644 --- a/src/test/codegen/noreturnflag.rs +++ b/src/test/codegen/noreturnflag.rs @@ -1,5 +1,4 @@ // compile-flags: -g -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/nounwind.rs b/src/test/codegen/nounwind.rs index 49a74ef7ab4..f639c60b893 100644 --- a/src/test/codegen/nounwind.rs +++ b/src/test/codegen/nounwind.rs @@ -14,4 +14,3 @@ pub fn foo() { // CHECK: @bar() unnamed_addr #0 // CHECK: attributes #0 = { {{.*}}nounwind{{.*}} } } - diff --git a/src/test/codegen/packed.rs b/src/test/codegen/packed.rs index b42161db98a..3c8ff394849 100644 --- a/src/test/codegen/packed.rs +++ b/src/test/codegen/packed.rs @@ -152,4 +152,3 @@ pub fn pkd2_nested_pair(pair1: &mut Packed2NestedPair, pair2: &mut Packed2Nested // CHECK: call void @llvm.memcpy.{{.*}}(i8* align 2 %{{.*}}, i8* align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false) *pair2 = *pair1; } - diff --git a/src/test/codegen/panic-abort-windows.rs b/src/test/codegen/panic-abort-windows.rs index e2d942e8699..8e38245267d 100644 --- a/src/test/codegen/panic-abort-windows.rs +++ b/src/test/codegen/panic-abort-windows.rs @@ -1,8 +1,5 @@ -// ignore-tidy-linelength - // This test is for *-windows-msvc only. // ignore-android -// ignore-bitrig // ignore-cloudabi // ignore-dragonfly // ignore-emscripten @@ -14,6 +11,7 @@ // ignore-netbsd // ignore-openbsd // ignore-solaris +// ignore-sgx // compile-flags: -C no-prepopulate-passes -C panic=abort -O diff --git a/src/test/codegen/pgo-instrumentation.rs b/src/test/codegen/pgo-instrumentation.rs new file mode 100644 index 00000000000..c085f3c829e --- /dev/null +++ b/src/test/codegen/pgo-instrumentation.rs @@ -0,0 +1,23 @@ +// Test that `-Cprofile-generate` creates expected instrumentation artifacts in LLVM IR. +// Compiling with `-Cpanic=abort` because PGO+unwinding isn't supported on all platforms. + +// needs-profiler-support +// compile-flags: -Cprofile-generate -Ccodegen-units=1 -Cpanic=abort + +// CHECK: @__llvm_profile_raw_version = +// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global +// CHECK-DAG: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global +// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = {{.*}}global +// CHECK-DAG: @__profd_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = {{.*}}global +// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}} + +#![crate_type="lib"] + +#[inline(never)] +fn some_function() { + +} + +pub fn some_other_function() { + some_function(); +} diff --git a/src/test/codegen/refs.rs b/src/test/codegen/refs.rs index 9583730e9dd..cbb99423476 100644 --- a/src/test/codegen/refs.rs +++ b/src/test/codegen/refs.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/remap_path_prefix/xcrate-generic.rs b/src/test/codegen/remap_path_prefix/xcrate-generic.rs index 70d29577b2f..30d6112fd02 100644 --- a/src/test/codegen/remap_path_prefix/xcrate-generic.rs +++ b/src/test/codegen/remap_path_prefix/xcrate-generic.rs @@ -1,5 +1,4 @@ // ignore-windows -// ignore-tidy-linelength // compile-flags: -g -C metadata=foo -C no-prepopulate-passes // aux-build:xcrate-generic.rs diff --git a/src/test/codegen/repr-transparent-aggregates-1.rs b/src/test/codegen/repr-transparent-aggregates-1.rs index fb88f2a69ca..1c8959619d3 100644 --- a/src/test/codegen/repr-transparent-aggregates-1.rs +++ b/src/test/codegen/repr-transparent-aggregates-1.rs @@ -1,42 +1,85 @@ // compile-flags: -C no-prepopulate-passes +// ignore-tidy-linelength +// min-system-llvm-version: 9.0 // ignore-arm // ignore-mips // ignore-mips64 // ignore-powerpc // ignore-powerpc64 +// ignore-windows // See repr-transparent.rs +#![feature(transparent_enums, transparent_unions)] + #![crate_type="lib"] +#[derive(Clone, Copy)] #[repr(C)] -pub struct Big([u32; 16]); +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} #[repr(transparent)] -pub struct BigW(Big); +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], %BigS* [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], %TsBigS* [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) +#[no_mangle] +pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_Big(%Big* [[BIG_RET_ATTRS:.*]], %Big* [[BIG_ARG_ATTRS:.*]]) +// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], %TuBigS* [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] -pub extern fn test_Big(_: Big) -> Big { loop {} } +pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_BigW(%BigW* [[BIG_RET_ATTRS]], %BigW* [[BIG_ARG_ATTRS]]) +// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) #[no_mangle] -pub extern fn test_BigW(_: BigW) -> BigW { loop {} } +pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } +#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], } #[repr(transparent)] -pub struct BigUw(BigU); +pub struct TsBigU(BigU); -// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS:.*]]) +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} + +// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_BigUw(%BigUw* [[BIGU_RET_ATTRS]], %BigUw* [[BIGU_ARG_ATTRS]]) +// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], %TsBigU* [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) +#[no_mangle] +pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], %TuBigU* [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) +#[no_mangle] +pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) #[no_mangle] -pub extern fn test_BigUw(_: BigUw) -> BigUw { loop {} } +pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/src/test/codegen/repr-transparent-aggregates-2.rs b/src/test/codegen/repr-transparent-aggregates-2.rs index 6c628ac035f..5521c3c849f 100644 --- a/src/test/codegen/repr-transparent-aggregates-2.rs +++ b/src/test/codegen/repr-transparent-aggregates-2.rs @@ -14,36 +14,76 @@ // ignore-x86_64 // See repr-transparent.rs +#![feature(transparent_enums, transparent_unions)] + #![crate_type="lib"] +#[derive(Clone, Copy)] #[repr(C)] -pub struct Big([u32; 16]); +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} #[repr(transparent)] -pub struct BigW(Big); +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], [16 x i32] +#[no_mangle] +pub extern fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], [16 x i32] +#[no_mangle] +pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_Big(%Big* [[BIG_RET_ATTRS:.*]], [16 x i32] +// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], [16 x i32] #[no_mangle] -pub extern fn test_Big(_: Big) -> Big { loop {} } +pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_BigW(%BigW* [[BIG_RET_ATTRS]], [16 x i32] +// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], [16 x i32] #[no_mangle] -pub extern fn test_BigW(_: BigW) -> BigW { loop {} } +pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } +#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], } #[repr(transparent)] -pub struct BigUw(BigU); +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} // CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], [16 x i32] #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_BigUw(%BigUw* [[BIGU_RET_ATTRS]], [16 x i32] +// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], [16 x i32] +#[no_mangle] +pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], [16 x i32] +#[no_mangle] +pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], [16 x i32] #[no_mangle] -pub extern fn test_BigUw(_: BigUw) -> BigUw { loop {} } +pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/src/test/codegen/repr-transparent-aggregates-3.rs b/src/test/codegen/repr-transparent-aggregates-3.rs index cd740dc9b82..1a59c9b48b9 100644 --- a/src/test/codegen/repr-transparent-aggregates-3.rs +++ b/src/test/codegen/repr-transparent-aggregates-3.rs @@ -3,36 +3,76 @@ // only-mips64 // See repr-transparent.rs +#![feature(transparent_enums, transparent_unions)] + #![crate_type="lib"] +#[derive(Clone, Copy)] #[repr(C)] -pub struct Big([u32; 16]); +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} #[repr(transparent)] -pub struct BigW(Big); +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], [8 x i64] +#[no_mangle] +pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_Big(%Big* [[BIG_RET_ATTRS:.*]], [8 x i64] +// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], [8 x i64] #[no_mangle] -pub extern fn test_Big(_: Big) -> Big { loop {} } +pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_BigW(%BigW* [[BIG_RET_ATTRS]], [8 x i64] +// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], [8 x i64] #[no_mangle] -pub extern fn test_BigW(_: BigW) -> BigW { loop {} } +pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } +#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], } #[repr(transparent)] -pub struct BigUw(BigU); +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} // CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], [8 x i64] #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_BigUw(%BigUw* [[BIGU_RET_ATTRS]], [8 x i64] +// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], [8 x i64] +#[no_mangle] +pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], [8 x i64] #[no_mangle] -pub extern fn test_BigUw(_: BigUw) -> BigUw { loop {} } +pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/src/test/codegen/repr-transparent.rs b/src/test/codegen/repr-transparent.rs index fd655261ab8..c9f38375658 100644 --- a/src/test/codegen/repr-transparent.rs +++ b/src/test/codegen/repr-transparent.rs @@ -1,13 +1,16 @@ // compile-flags: -C no-prepopulate-passes #![crate_type="lib"] -#![feature(repr_simd)] +#![feature(repr_simd, transparent_enums, transparent_unions)] use std::marker::PhantomData; +#[derive(Copy, Clone)] pub struct Zst1; +#[derive(Copy, Clone)] pub struct Zst2(()); +#[derive(Copy, Clone)] #[repr(transparent)] pub struct F32(f32); @@ -112,6 +115,44 @@ pub struct StructWithProjection(<f32 as Mirror>::It); #[no_mangle] pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } +#[repr(transparent)] +pub enum EnumF32 { + Variant(F32) +} + +// CHECK: define float @test_EnumF32(float %arg0) +#[no_mangle] +pub extern fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} } + +#[repr(transparent)] +pub enum EnumF32WithZsts { + Variant(Zst1, F32, Zst2) +} + +// CHECK: define float @test_EnumF32WithZsts(float %arg0) +#[no_mangle] +pub extern fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} } + +#[repr(transparent)] +pub union UnionF32 { + field: F32, +} + +// CHECK: define float @test_UnionF32(float %arg0) +#[no_mangle] +pub extern fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } + +#[repr(transparent)] +pub union UnionF32WithZsts { + zst1: Zst1, + field: F32, + zst2: Zst2, +} + +// CHECK: define float @test_UnionF32WithZsts(float %arg0) +#[no_mangle] +pub extern fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} } + // All that remains to be tested are aggregates. They are tested in separate files called repr- // transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR diff --git a/src/test/codegen/slice-iter-len-eq-zero.rs b/src/test/codegen/slice-iter-len-eq-zero.rs new file mode 100644 index 00000000000..a5516833900 --- /dev/null +++ b/src/test/codegen/slice-iter-len-eq-zero.rs @@ -0,0 +1,14 @@ +// no-system-llvm +// compile-flags: -O +#![crate_type = "lib"] + +type Demo = [u8; 3]; + +// CHECK-LABEL: @slice_iter_len_eq_zero +#[no_mangle] +pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { + // CHECK-NOT: sub + // CHECK: %2 = icmp eq i8* %1, %0 + // CHECK: ret i1 %2 + y.len() == 0 +} diff --git a/src/test/codegen/swap-small-types.rs b/src/test/codegen/swap-small-types.rs index c8466fed7d1..6205e6a6559 100644 --- a/src/test/codegen/swap-small-types.rs +++ b/src/test/codegen/swap-small-types.rs @@ -1,5 +1,6 @@ // compile-flags: -O // only-x86_64 +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] diff --git a/src/test/codegen/target-cpu-on-functions.rs b/src/test/codegen/target-cpu-on-functions.rs index 3fdf6ab6d00..523216deb84 100644 --- a/src/test/codegen/target-cpu-on-functions.rs +++ b/src/test/codegen/target-cpu-on-functions.rs @@ -13,7 +13,9 @@ pub extern fn exported() { not_exported(); } -// CHECK-LABEL: define {{.*}} @_ZN23target_cpu_on_functions12not_exported{{.*}}() {{.*}} #0 +// CHECK-LABEL: ; target_cpu_on_functions::not_exported +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define {{.*}}() {{.*}} #0 fn not_exported() {} // CHECK: attributes #0 = {{.*}} "target-cpu"="{{.*}}" diff --git a/src/test/codegen/union-abi.rs b/src/test/codegen/union-abi.rs index 03b55eb52a2..b7baffe1669 100644 --- a/src/test/codegen/union-abi.rs +++ b/src/test/codegen/union-abi.rs @@ -73,4 +73,3 @@ pub union UnionBool { b:bool } #[no_mangle] pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } } // CHECK: %0 = trunc i8 %b to i1 - diff --git a/src/test/codegen/vtabletype.rs b/src/test/codegen/vtabletype.rs index 70b97a67bbc..82d65b101b0 100644 --- a/src/test/codegen/vtabletype.rs +++ b/src/test/codegen/vtabletype.rs @@ -1,7 +1,6 @@ // This test depends on a patch that was committed to upstream LLVM // after 5.0, then backported to the Rust LLVM fork. -// ignore-tidy-linelength // ignore-windows // ignore-macos diff --git a/src/test/codegen/x86_64-macosx-deployment-target.rs b/src/test/codegen/x86_64-macosx-deployment-target.rs new file mode 100644 index 00000000000..8e291b7b298 --- /dev/null +++ b/src/test/codegen/x86_64-macosx-deployment-target.rs @@ -0,0 +1,26 @@ +// +// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. +// See issue #60235. + +// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "x86_64-apple-macosx10.9.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} diff --git a/src/test/codegen/x86_64-no-macosx-deployment-target.rs b/src/test/codegen/x86_64-no-macosx-deployment-target.rs new file mode 100644 index 00000000000..c5ac73b54e1 --- /dev/null +++ b/src/test/codegen/x86_64-no-macosx-deployment-target.rs @@ -0,0 +1,26 @@ +// +// Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. +// See issue #60235. + +// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } + +#[repr(C)] +pub struct Bool { + b: bool, +} + +// CHECK: target triple = "x86_64-apple-macosx10.7.0" +#[no_mangle] +pub extern "C" fn structbool() -> Bool { + Bool { b: true } +} |
