Skip to content

Commit

Permalink
Add VFE test for 32 bit
Browse files Browse the repository at this point in the history
The offset in the llvm.type.checked.load intrinsic differs on 32 bit platforms
  • Loading branch information
flip1995 committed Jun 14, 2022
1 parent a93ea7e commit 195f208
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/codegen/virtual-function-elimination-32bit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0
// ignore-64bit

// CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]]

#![crate_type = "lib"]

trait T {
// CHECK-LABEL: ; <virtual_function_elimination_32bit::S as virtual_function_elimination_32bit::T>::used
fn used(&self) -> i32 {
1
}
// CHECK-LABEL-NOT: {{.*}}::unused
fn unused(&self) -> i32 {
2
}
}

#[derive(Copy, Clone)]
struct S;

impl T for S {}

fn taking_t(t: &dyn T) -> i32 {
// CHECK: @llvm.type.checked.load({{.*}}, i32 12, metadata !"[[MANGLED_TYPE0:[0-9a-zA-Z_]+]]")
t.used()
}

pub fn main() {
let s = S;
taking_t(&s);
}

// CHECK: ![[TYPE0]] = !{i32 0, !"[[MANGLED_TYPE0]]"}
// CHECK: ![[VCALL_VIS0]] = !{i64 2}
1 change: 1 addition & 0 deletions src/test/codegen/virtual-function-elimination.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0
// ignore-32bit

// CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]]
// CHECK: @vtable.1 = {{.*}}, !type ![[TYPE1:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]]
Expand Down

0 comments on commit 195f208

Please sign in to comment.