From 195f2082002c9db456e0fde8c1d5db79929ae293 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 12 May 2022 11:04:42 +0100 Subject: [PATCH] Add VFE test for 32 bit The offset in the llvm.type.checked.load intrinsic differs on 32 bit platforms --- .../virtual-function-elimination-32bit.rs | 35 +++++++++++++++++++ .../codegen/virtual-function-elimination.rs | 1 + 2 files changed, 36 insertions(+) create mode 100644 src/test/codegen/virtual-function-elimination-32bit.rs diff --git a/src/test/codegen/virtual-function-elimination-32bit.rs b/src/test/codegen/virtual-function-elimination-32bit.rs new file mode 100644 index 0000000000000..6f963363a998c --- /dev/null +++ b/src/test/codegen/virtual-function-elimination-32bit.rs @@ -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: ; ::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} diff --git a/src/test/codegen/virtual-function-elimination.rs b/src/test/codegen/virtual-function-elimination.rs index 46f96d505b882..4cf7e12fee215 100644 --- a/src/test/codegen/virtual-function-elimination.rs +++ b/src/test/codegen/virtual-function-elimination.rs @@ -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]+]]