Closed
Description
This code contains two offset calculations and two function pointer loads:
#![crate_type="lib"]
pub struct Wrapper<T: ?Sized> {
x: usize,
y: usize,
t: T
}
pub trait Foo {
fn foo(&self);
}
pub fn test(foo: &Wrapper<Foo>) {
foo.t.foo();
foo.t.foo();
}
LLVM should be able to remove all but the first occurrences via common subexpression elimination, but for some reason it reloads from the vtable pointer each time. The only reasonable explanation I can think of is that LLVM assumes that the vtable pointer may alias some pointer that the called function manipulates.