Codegen tests

This commit is contained in:
Oliver Schneider 2018-01-15 10:31:28 +01:00
parent f73d4ac9e0
commit 0595ff1009
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
4 changed files with 8 additions and 7 deletions

View File

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
// compile-flags: -C no-prepopulate-passes // compile-flags: -C no-prepopulate-passes
// ignore-tidy-linelength
#![crate_type = "lib"] #![crate_type = "lib"]
@ -19,12 +20,11 @@
// CHECK: @STATIC = {{.*}}, align 4 // CHECK: @STATIC = {{.*}}, align 4
// This checks the constants from inline_enum_const // This checks the constants from inline_enum_const
// CHECK: @ref.{{[0-9]+}} = {{.*}}, align 2 // CHECK: @byte_str.{{[0-9]+}} = {{.*}}, align 2
// This checks the constants from {low,high}_align_const, they share the same // This checks the constants from {low,high}_align_const, they share the same
// constant, but the alignment differs, so the higher one should be used // constant, but the alignment differs, so the higher one should be used
// CHECK: [[LOW_HIGH:@ref.[0-9]+]] = {{.*}}, align 4 // CHECK: [[LOW_HIGH:@byte_str.[0-9]+]] = {{.*}}, align 4
// CHECK: [[LOW_HIGH_REF:@const.[0-9]+]] = {{.*}} [[LOW_HIGH]]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -54,7 +54,7 @@ pub fn inline_enum_const() -> E<i8, i16> {
#[no_mangle] #[no_mangle]
pub fn low_align_const() -> E<i16, [i16; 3]> { pub fn low_align_const() -> E<i16, [i16; 3]> {
// Check that low_align_const and high_align_const use the same constant // Check that low_align_const and high_align_const use the same constant
// CHECK: load {{.*}} bitcast ({ i16, [0 x i8], i16, [4 x i8] }** [[LOW_HIGH_REF]] // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* [[LOW_HIGH]], i32 0, i32 0, i32 0), i64 8, i32 2, i1 false)
*&E::A(0) *&E::A(0)
} }
@ -62,6 +62,6 @@ pub fn low_align_const() -> E<i16, [i16; 3]> {
#[no_mangle] #[no_mangle]
pub fn high_align_const() -> E<i16, i32> { pub fn high_align_const() -> E<i16, i32> {
// Check that low_align_const and high_align_const use the same constant // Check that low_align_const and high_align_const use the same constant
// CHECK: load {{.*}} bitcast ({ i16, [0 x i8], i16, [4 x i8] }** [[LOW_HIGH_REF]] // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* [[LOW_HIGH]], i32 0, i32 0, i32 0), i64 8, i32 4, i1 false)
*&E::A(0) *&E::A(0)
} }

View File

@ -12,7 +12,7 @@
#![crate_type = "lib"] #![crate_type = "lib"]
// CHECK: @VAR1 = constant i32 1, section ".test_one" // CHECK: @VAR1 = constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one"
#[no_mangle] #[no_mangle]
#[link_section = ".test_one"] #[link_section = ".test_one"]
pub static VAR1: u32 = 1; pub static VAR1: u32 = 1;

View File

@ -22,7 +22,7 @@ mod aux_mod;
include!("aux_mod.rs"); include!("aux_mod.rs");
// Here we check that the expansion of the file!() macro is mapped. // Here we check that the expansion of the file!() macro is mapped.
// CHECK: internal constant [34 x i8] c"/the/src/remap_path_prefix/main.rs" // CHECK: @byte_str.1 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }>, align 1
pub static FILE_PATH: &'static str = file!(); pub static FILE_PATH: &'static str = file!();
fn main() { fn main() {

View File

@ -12,6 +12,7 @@ fn xyz() -> u8 { 42 }
const NUM: u8 = xyz(); const NUM: u8 = xyz();
//~^ ERROR calls in constants are limited to constant functions, struct and enum constructors //~^ ERROR calls in constants are limited to constant functions, struct and enum constructors
//~| ERROR constant evaluation error
fn main() { fn main() {
match 1 { match 1 {