From d775d79a01ea65c8a9fb52d1f9011070d044e15e Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 25 Nov 2017 07:20:33 -0800 Subject: [PATCH 1/4] Update compiler-builtins and use it the 128-bit lowering MIR test --- src/libcompiler_builtins | 2 +- src/test/mir-opt/lower_128bit_debug_test.rs | 62 ++++++--------------- src/test/mir-opt/lower_128bit_test.rs | 61 ++++++-------------- 3 files changed, 33 insertions(+), 92 deletions(-) diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins index 02b3734a5ba..18feaccbfd0 160000 --- a/src/libcompiler_builtins +++ b/src/libcompiler_builtins @@ -1 +1 @@ -Subproject commit 02b3734a5ba6de984eb5a02c50860cc014e58d56 +Subproject commit 18feaccbfd0dfbd5ab5d0a2a6eac9c04be667266 diff --git a/src/test/mir-opt/lower_128bit_debug_test.rs b/src/test/mir-opt/lower_128bit_debug_test.rs index 134a868f933..5a0805ce1b7 100644 --- a/src/test/mir-opt/lower_128bit_debug_test.rs +++ b/src/test/mir-opt/lower_128bit_debug_test.rs @@ -13,36 +13,6 @@ #![feature(i128_type)] #![feature(lang_items)] -#[lang="i128_div"] -fn i128_div(_x: i128, _y: i128) -> i128 { 3 } -#[lang="u128_div"] -fn u128_div(_x: u128, _y: u128) -> u128 { 4 } -#[lang="i128_rem"] -fn i128_rem(_x: i128, _y: i128) -> i128 { 5 } -#[lang="u128_rem"] -fn u128_rem(_x: u128, _y: u128) -> u128 { 6 } - -#[lang="i128_addo"] -fn i128_addo(_x: i128, _y: i128) -> (i128, bool) { (0, false) } -#[lang="u128_addo"] -fn u128_addo(_x: u128, _y: u128) -> (u128, bool) { (1, false) } -#[lang="i128_subo"] -fn i128_subo(_x: i128, _y: i128) -> (i128, bool) { (2, false) } -#[lang="u128_subo"] -fn u128_subo(_x: u128, _y: u128) -> (u128, bool) { (3, false) } -#[lang="i128_mulo"] -fn i128_mulo(_x: i128, _y: i128) -> (i128, bool) { (4, false) } -#[lang="u128_mulo"] -fn u128_mulo(_x: u128, _y: u128) -> (u128, bool) { (5, false) } -#[lang="i128_shlo"] -fn i128_shlo(_x: i128, _y: u128) -> (i128, bool) { (6, false) } -#[lang="u128_shlo"] -fn u128_shlo(_x: u128, _y: u128) -> (u128, bool) { (6, false) } -#[lang="i128_shro"] -fn i128_shro(_x: i128, _y: u128) -> (i128, bool) { (7, false) } -#[lang="u128_shro"] -fn u128_shro(_x: u128, _y: u128) -> (u128, bool) { (8, false) } - fn test_signed(mut x: i128) -> i128 { x += 1; x -= 2; @@ -66,31 +36,31 @@ fn test_unsigned(mut x: u128) -> u128 { } fn main() { - test_signed(-200); - test_unsigned(200); + assert_eq!(test_signed(-222), -1); + assert_eq!(test_unsigned(200), 2); } // END RUST SOURCE // START rustc.test_signed.Lower128Bit.after.mir -// _2 = const i128_addo(_1, const 1i128) -> bb10; +// _2 = const compiler_builtins::int::addsub::rust_i128_addo(_1, const 1i128) -> bb10; // ... // _1 = move (_2.0: i128); -// _3 = const i128_subo(_1, const 2i128) -> bb11; +// _3 = const compiler_builtins::int::addsub::rust_i128_subo(_1, const 2i128) -> bb11; // ... // _1 = move (_3.0: i128); -// _4 = const i128_mulo(_1, const 3i128) -> bb12; +// _4 = const compiler_builtins::int::mul::rust_i128_mulo(_1, const 3i128) -> bb12; // ... // _1 = move (_4.0: i128); // ... -// _1 = const i128_div(_1, const 4i128) -> bb13; +// _1 = const compiler_builtins::int::sdiv::rust_i128_div(_1, const 4i128) -> bb13; // ... -// _1 = const i128_rem(_1, const 5i128) -> bb15; +// _1 = const compiler_builtins::int::sdiv::rust_i128_rem(_1, const 5i128) -> bb15; // ... // _1 = move (_13.0: i128); // ... // _17 = const 7i32 as u128 (Misc); -// _14 = const i128_shro(_1, move _17) -> bb16; +// _14 = const compiler_builtins::int::shift::rust_i128_shro(_1, move _17) -> bb16; // ... // _1 = move (_14.0: i128); // ... @@ -103,30 +73,30 @@ fn main() { // assert(!move (_13.1: bool), "attempt to shift left with overflow") -> bb8; // ... // _16 = const 6i32 as u128 (Misc); -// _13 = const i128_shlo(_1, move _16) -> bb14; +// _13 = const compiler_builtins::int::shift::rust_i128_shlo(_1, move _16) -> bb14; // ... // assert(!move (_14.1: bool), "attempt to shift right with overflow") -> bb9; // END rustc.test_signed.Lower128Bit.after.mir // START rustc.test_unsigned.Lower128Bit.after.mir -// _2 = const u128_addo(_1, const 1u128) -> bb8; +// _2 = const compiler_builtins::int::addsub::rust_u128_addo(_1, const 1u128) -> bb8; // ... // _1 = move (_2.0: u128); -// _3 = const u128_subo(_1, const 2u128) -> bb9; +// _3 = const compiler_builtins::int::addsub::rust_u128_subo(_1, const 2u128) -> bb9; // ... // _1 = move (_3.0: u128); -// _4 = const u128_mulo(_1, const 3u128) -> bb10; +// _4 = const compiler_builtins::int::mul::rust_u128_mulo(_1, const 3u128) -> bb10; // ... // _1 = move (_4.0: u128); // ... -// _1 = const u128_div(_1, const 4u128) -> bb11; +// _1 = const compiler_builtins::int::udiv::rust_u128_div(_1, const 4u128) -> bb11; // ... -// _1 = const u128_rem(_1, const 5u128) -> bb13; +// _1 = const compiler_builtins::int::udiv::rust_u128_rem(_1, const 5u128) -> bb13; // ... // _1 = move (_7.0: u128); // ... // _11 = const 7i32 as u128 (Misc); -// _8 = const u128_shro(_1, move _11) -> bb14; +// _8 = const compiler_builtins::int::shift::rust_u128_shro(_1, move _11) -> bb14; // ... // _1 = move (_8.0: u128); // ... @@ -139,7 +109,7 @@ fn main() { // assert(!move (_7.1: bool), "attempt to shift left with overflow") -> bb6; // ... // _10 = const 6i32 as u128 (Misc); -// _7 = const u128_shlo(_1, move _10) -> bb12; +// _7 = const compiler_builtins::int::shift::rust_u128_shlo(_1, move _10) -> bb12; // ... // assert(!move (_8.1: bool), "attempt to shift right with overflow") -> bb7; // END rustc.test_unsigned.Lower128Bit.after.mir diff --git a/src/test/mir-opt/lower_128bit_test.rs b/src/test/mir-opt/lower_128bit_test.rs index 5de75014f0e..f63926500b6 100644 --- a/src/test/mir-opt/lower_128bit_test.rs +++ b/src/test/mir-opt/lower_128bit_test.rs @@ -13,35 +13,6 @@ #![feature(i128_type)] #![feature(lang_items)] -#[lang="i128_add"] -fn i128_add(_x: i128, _y: i128) -> i128 { 0 } -#[lang="u128_add"] -fn u128_add(_x: u128, _y: u128) -> u128 { 0 } -#[lang="i128_sub"] -fn i128_sub(_x: i128, _y: i128) -> i128 { 1 } -#[lang="u128_sub"] -fn u128_sub(_x: u128, _y: u128) -> u128 { 1 } -#[lang="i128_mul"] -fn i128_mul(_x: i128, _y: i128) -> i128 { 2 } -#[lang="u128_mul"] -fn u128_mul(_x: u128, _y: u128) -> u128 { 2 } -#[lang="i128_div"] -fn i128_div(_x: i128, _y: i128) -> i128 { 3 } -#[lang="u128_div"] -fn u128_div(_x: u128, _y: u128) -> u128 { 4 } -#[lang="i128_rem"] -fn i128_rem(_x: i128, _y: i128) -> i128 { 5 } -#[lang="u128_rem"] -fn u128_rem(_x: u128, _y: u128) -> u128 { 6 } -#[lang="i128_shl"] -fn i128_shl(_x: i128, _y: u32) -> i128 { 7 } -#[lang="u128_shl"] -fn u128_shl(_x: u128, _y: u32) -> u128 { 7 } -#[lang="i128_shr"] -fn i128_shr(_x: i128, _y: u32) -> i128 { 8 } -#[lang="u128_shr"] -fn u128_shr(_x: u128, _y: u32) -> u128 { 9 } - fn test_signed(mut x: i128) -> i128 { x += 1; x -= 2; @@ -65,44 +36,44 @@ fn test_unsigned(mut x: u128) -> u128 { } fn main() { - test_signed(-200); - test_unsigned(200); + assert_eq!(test_signed(-222), -1); + assert_eq!(test_unsigned(200), 2); } // END RUST SOURCE // START rustc.test_signed.Lower128Bit.after.mir -// _1 = const i128_add(_1, const 1i128) -> bb7; +// _1 = const compiler_builtins::int::addsub::rust_i128_add(_1, const 1i128) -> bb7; // ... -// _1 = const i128_div(_1, const 4i128) -> bb8; +// _1 = const compiler_builtins::int::sdiv::rust_i128_div(_1, const 4i128) -> bb8; // ... -// _1 = const i128_rem(_1, const 5i128) -> bb11; +// _1 = const compiler_builtins::int::sdiv::rust_i128_rem(_1, const 5i128) -> bb11; // ... -// _1 = const i128_mul(_1, const 3i128) -> bb5; +// _1 = const compiler_builtins::int::mul::rust_i128_mul(_1, const 3i128) -> bb5; // ... -// _1 = const i128_sub(_1, const 2i128) -> bb6; +// _1 = const compiler_builtins::int::addsub::rust_i128_sub(_1, const 2i128) -> bb6; // ... // _11 = const 7i32 as u32 (Misc); -// _1 = const i128_shr(_1, move _11) -> bb9; +// _1 = const compiler_builtins::int::shift::rust_i128_shr(_1, move _11) -> bb9; // ... // _12 = const 6i32 as u32 (Misc); -// _1 = const i128_shl(_1, move _12) -> bb10; +// _1 = const compiler_builtins::int::shift::rust_i128_shl(_1, move _12) -> bb10; // END rustc.test_signed.Lower128Bit.after.mir // START rustc.test_unsigned.Lower128Bit.after.mir -// _1 = const u128_add(_1, const 1u128) -> bb5; +// _1 = const compiler_builtins::int::addsub::rust_u128_add(_1, const 1u128) -> bb5; // ... -// _1 = const u128_div(_1, const 4u128) -> bb6; +// _1 = const compiler_builtins::int::udiv::rust_u128_div(_1, const 4u128) -> bb6; // ... -// _1 = const u128_rem(_1, const 5u128) -> bb9; +// _1 = const compiler_builtins::int::udiv::rust_u128_rem(_1, const 5u128) -> bb9; // ... -// _1 = const u128_mul(_1, const 3u128) -> bb3; +// _1 = const compiler_builtins::int::mul::rust_u128_mul(_1, const 3u128) -> bb3; // ... -// _1 = const u128_sub(_1, const 2u128) -> bb4; +// _1 = const compiler_builtins::int::addsub::rust_u128_sub(_1, const 2u128) -> bb4; // ... // _5 = const 7i32 as u32 (Misc); -// _1 = const u128_shr(_1, move _5) -> bb7; +// _1 = const compiler_builtins::int::shift::rust_u128_shr(_1, move _5) -> bb7; // ... // _6 = const 6i32 as u32 (Misc); -// _1 = const u128_shl(_1, move _6) -> bb8; +// _1 = const compiler_builtins::int::shift::rust_u128_shl(_1, move _6) -> bb8; // END rustc.test_unsigned.Lower128Bit.after.mir From 49ee16131ee995e0641d30b15504da6f11b6c702 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 26 Nov 2017 19:30:20 -0800 Subject: [PATCH 2/4] Remove the unneeded #![feature(lang_items)]s --- src/test/mir-opt/lower_128bit_debug_test.rs | 1 - src/test/mir-opt/lower_128bit_test.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/mir-opt/lower_128bit_debug_test.rs b/src/test/mir-opt/lower_128bit_debug_test.rs index 5a0805ce1b7..ccc6e75a1b4 100644 --- a/src/test/mir-opt/lower_128bit_debug_test.rs +++ b/src/test/mir-opt/lower_128bit_debug_test.rs @@ -11,7 +11,6 @@ // compile-flags: -Z lower_128bit_ops -C debug_assertions=yes #![feature(i128_type)] -#![feature(lang_items)] fn test_signed(mut x: i128) -> i128 { x += 1; diff --git a/src/test/mir-opt/lower_128bit_test.rs b/src/test/mir-opt/lower_128bit_test.rs index f63926500b6..dc6beb436db 100644 --- a/src/test/mir-opt/lower_128bit_test.rs +++ b/src/test/mir-opt/lower_128bit_test.rs @@ -11,7 +11,6 @@ // compile-flags: -Z lower_128bit_ops -C debug_assertions=no #![feature(i128_type)] -#![feature(lang_items)] fn test_signed(mut x: i128) -> i128 { x += 1; From ad2a8e835610dc135f0df2285e912179d1bab488 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 2 Dec 2017 20:21:50 -0800 Subject: [PATCH 3/4] Ignore the lower_128bit tests on asmjs --- src/test/mir-opt/lower_128bit_debug_test.rs | 4 ++++ src/test/mir-opt/lower_128bit_test.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/test/mir-opt/lower_128bit_debug_test.rs b/src/test/mir-opt/lower_128bit_debug_test.rs index ccc6e75a1b4..40acf048aba 100644 --- a/src/test/mir-opt/lower_128bit_debug_test.rs +++ b/src/test/mir-opt/lower_128bit_debug_test.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// asmjs can't even pass i128 as arguments or return values, so ignore it. +// this will hopefully be fixed by the LLVM 5 upgrade (#43370) +// ignore-asmjs + // compile-flags: -Z lower_128bit_ops -C debug_assertions=yes #![feature(i128_type)] diff --git a/src/test/mir-opt/lower_128bit_test.rs b/src/test/mir-opt/lower_128bit_test.rs index dc6beb436db..196cdf2c3c5 100644 --- a/src/test/mir-opt/lower_128bit_test.rs +++ b/src/test/mir-opt/lower_128bit_test.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// asmjs can't even pass i128 as arguments or return values, so ignore it. +// this will hopefully be fixed by the LLVM 5 upgrade (#43370) +// ignore-asmjs + // compile-flags: -Z lower_128bit_ops -C debug_assertions=no #![feature(i128_type)] From c0654ce8156c0b3811595a29c137d318d90d0686 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 2 Dec 2017 23:24:11 -0800 Subject: [PATCH 4/4] Add ignore-emscripten too --- src/test/mir-opt/lower_128bit_debug_test.rs | 1 + src/test/mir-opt/lower_128bit_test.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/test/mir-opt/lower_128bit_debug_test.rs b/src/test/mir-opt/lower_128bit_debug_test.rs index 40acf048aba..4f9bb809e99 100644 --- a/src/test/mir-opt/lower_128bit_debug_test.rs +++ b/src/test/mir-opt/lower_128bit_debug_test.rs @@ -11,6 +11,7 @@ // asmjs can't even pass i128 as arguments or return values, so ignore it. // this will hopefully be fixed by the LLVM 5 upgrade (#43370) // ignore-asmjs +// ignore-emscripten // compile-flags: -Z lower_128bit_ops -C debug_assertions=yes diff --git a/src/test/mir-opt/lower_128bit_test.rs b/src/test/mir-opt/lower_128bit_test.rs index 196cdf2c3c5..e8c8412db80 100644 --- a/src/test/mir-opt/lower_128bit_test.rs +++ b/src/test/mir-opt/lower_128bit_test.rs @@ -11,6 +11,7 @@ // asmjs can't even pass i128 as arguments or return values, so ignore it. // this will hopefully be fixed by the LLVM 5 upgrade (#43370) // ignore-asmjs +// ignore-emscripten // compile-flags: -Z lower_128bit_ops -C debug_assertions=no