Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of FFI arguments #33872

Merged
merged 6 commits into from May 26, 2016

Conversation

Projects
None yet
5 participants
@nagisa
Copy link
Contributor

nagisa commented May 25, 2016

r? @eddyb @nikomatsakis or whoever else.

cc @alexcrichton @rust-lang/core

The strategy employed here was to essentially change code we generate from

  %s = alloca %S ; potentially smaller than argument, but never larger
  %1 = bitcast %S* %s to { i64, i64 }*
  store { i64, i64 } %0, { i64, i64 }* %1, align 4

to

  %1 = alloca { i64, i64 } ; the copy of argument itself
  store { i64, i64 } %0, { i64, i64 }* %1, align 4
  %s = bitcast { i64, i64 }* %1 to %S* ; potentially truncate by casting to a pointer of smaller type.
@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented May 25, 2016

Hmm, it clashes with debuginfo.


// FIXME: hacky lol?
datum::Datum::new(lltmp, arg_ty,
datum::Lvalue::new("datum::lvalue_scratch_datum"))

This comment has been minimized.

@eddyb

eddyb May 25, 2016

Member

This won't work with debuginfo, which wants an alloca with no casts on top.
I would suggest giving it the alloca before the cast and hope that it doesn't care about the type (debuginfo metadata should describe the actual value in the alloca all by itself).
cc @michaelwoerister

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 26, 2016

Thanks for the quick fix @nagisa!

@nagisa nagisa force-pushed the nagisa:undef-is-llvm-for-sigsegv branch from ae8fc5c to 0d2a84c May 26, 2016

@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented May 26, 2016

Added a check for debuginfo thing. All should work now.

If there’s any hard-pressing nits, feel to fork and make another PR as I’m likely to be in bed for a while now.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented May 26, 2016

@bors r+ p=100

@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 26, 2016

📌 Commit e0e50a4 has been approved by eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 26, 2016

⌛️ Testing commit e0e50a4 with merge 73fdf78...

bors added a commit that referenced this pull request May 26, 2016

Auto merge of #33872 - nagisa:undef-is-llvm-for-sigsegv, r=eddyb
Fix handling of FFI arguments

r? @eddyb @nikomatsakis or whoever else.

cc @alexcrichton @rust-lang/core

The strategy employed here was to essentially change code we generate from

```llvm
  %s = alloca %S ; potentially smaller than argument, but never larger
  %1 = bitcast %S* %s to { i64, i64 }*
  store { i64, i64 } %0, { i64, i64 }* %1, align 4
```

to

```llvm
  %1 = alloca { i64, i64 } ; the copy of argument itself
  store { i64, i64 } %0, { i64, i64 }* %1, align 4
  %s = bitcast { i64, i64 }* %1 to %S* ; potentially truncate by casting to a pointer of smaller type.
```
@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 26, 2016

💔 Test failed - auto-linux-64-debug-opt

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented May 26, 2016

Miscompiling the compiler, resulting in this for stage2 libcore:

thread 'rustc' panicked at 'RefCell<T> already borrowed', ../src/libcore/cell.rs:492

@alexcrichton Serious question: why is RUST_BACKTRACE=1 not set on the bots? I assume it has to do with some tests not taking that very well?

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 26, 2016

No particular reason, it just hasn't been done yet. We'd probably benefit from just setting it in the build system directly.

@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented May 26, 2016

@bors r=eddyb 2f0da79

@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented May 26, 2016

@bors r=eddyb 5b40452

@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 26, 2016

⌛️ Testing commit 5b40452 with merge 3c795e0...

bors added a commit that referenced this pull request May 26, 2016

Auto merge of #33872 - nagisa:undef-is-llvm-for-sigsegv, r=eddyb
Fix handling of FFI arguments

r? @eddyb @nikomatsakis or whoever else.

cc @alexcrichton @rust-lang/core

The strategy employed here was to essentially change code we generate from

```llvm
  %s = alloca %S ; potentially smaller than argument, but never larger
  %1 = bitcast %S* %s to { i64, i64 }*
  store { i64, i64 } %0, { i64, i64 }* %1, align 4
```

to

```llvm
  %1 = alloca { i64, i64 } ; the copy of argument itself
  store { i64, i64 } %0, { i64, i64 }* %1, align 4
  %s = bitcast { i64, i64 }* %1 to %S* ; potentially truncate by casting to a pointer of smaller type.
```
@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 26, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented May 26, 2016

@bors retry force

@sanxiyn

This comment has been minimized.

Copy link
Member

sanxiyn commented May 26, 2016

Another case of #33844.

@bors bors merged commit 5b40452 into rust-lang:master May 26, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 26, 2016

Discussed on IRC and accepted for a beta backport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.