Skip to content

Fix handling of FFI arguments - #33872

Merged
bors merged 6 commits into
rust-lang:masterfrom
nagisa:undef-is-llvm-for-sigsegv
May 26, 2016
Merged

Fix handling of FFI arguments#33872
bors merged 6 commits into
rust-lang:masterfrom
nagisa:undef-is-llvm-for-sigsegv

Conversation

@nagisa

Copy link
Copy Markdown
Member

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*%sto { i64, i64 }*
store { i64, i64 } %0, { i64, i64 }* %1, align4

to

%1 = alloca { i64, i64 } ; the copy of argument itselfstore { i64, i64 } %0, { i64, i64 }* %1, align4%s = bitcast { i64, i64 }* %1to%S*; potentially truncate by casting to a pointer of smaller type.

@nagisanagisa added the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 25, 2016
@nagisa

Copy link
Copy Markdown
MemberAuthor

Hmm, it clashes with debuginfo.

Comment threadsrc/librustc_trans/base.rs Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Thanks for the quick fix @nagisa!

@alexcrichtonalexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 26, 2016
@nagisa
nagisaforce-pushed the undef-is-llvm-for-sigsegv branch from ae8fc5c to 0d2a84cCompareMay 26, 2016 00:26
@nagisa

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
Contributor

@bors r+ p=100

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit e0e50a4 has been approved by eddyb

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e0e50a4 with merge 73fdf78...

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

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

@eddyb

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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

@nagisa

Copy link
Copy Markdown
MemberAuthor

@bors r=eddyb 2f0da79

@nagisa

Copy link
Copy Markdown
MemberAuthor

@bors r=eddyb 5b40452

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

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

bors added a commit that referenced this pull request May 26, 2016
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

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

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

@nagisa

Copy link
Copy Markdown
MemberAuthor

@bors retry force

@sanxiyn

Copy link
Copy Markdown
Contributor

Another case of #33844.

@bors
bors merged commit 5b40452 into rust-lang:masterMay 26, 2016
@alexcrichtonalexcrichton added the beta-accepted Accepted for backporting to the compiler in the beta channel. label May 26, 2016
@alexcrichton

Copy link
Copy Markdown
Member

Discussed on IRC and accepted for a beta backport

@alexcrichtonalexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 20, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@nagisa@alexcrichton@eddyb@bors@sanxiyn