Hello,

I am working on a verifier for Rust, based on the generated LLVM code. I am having an issue with code generated similar to the following

struct Point {
  pub x: u32,
  pub y: u32
}
fn double_point(p: Point) -> Point {
  Point { x: 2*p.x, y: 2*p.y }
}
fn main() {
  let p = Point { x: 2, y: 3 };
  let q = double_point(p);
  assert!(q.x == 4 && q.y == 6);
}

The call to the double_point function is what causes the issue, as shown in the following generated llvm-ir code

%8 = bitcast %Point* %arg to i64*
%9 = load i64, i64* %8, align 4
%10 = call i64 @_ZN5point12double_point17h4b5ca79567fdc22dE(i64 %9)
store i64 %10, i64* %abi_cast

In the verifier's default mode, reads from the i64 don't work correctly, giving an assertion violation. This code works if the Point structure uses 64-bit ints instead, since no packing occurs.

My question is: is there is a way to prevent the compiler from bit-casting the structure to an integer? I am using a December 2016 nightly compiler, and have tried disabling all optimizations.

Thanks,

Mark

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to