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 LLVM IR generated for C-variadic arguments #59577

Merged
merged 1 commit into from
Mar 31, 2019

Conversation

dlrobertson
Copy link
Contributor

It is possible to create malformed LLVM IR given variadic arguments that
are aggregate types. This occurs due to improper tracking of the current
argument in the functions list of arguments.

Fixes: #58881

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2019
)),
layout: layout,
};
self.codegen_argument(&mut bx, op, &mut llargs, &fn_ty.args[i]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

codegen_argument when called given a function where is_ignore is true doesn't do anything other than add padding (which we shouldn't do here for C-variadics), so this section isn't needed.

layout: layout,
};
self.codegen_argument(&mut bx, op, &mut llargs, &fn_ty.args[i]);
let i = if sig.c_variadic && last_arg_idx.map(|x| i >= x).unwrap_or(false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we hit the "spoofed" C-variadic argument we need to use i + 1 for each of the subsequent iterations of this loop. If we don't we'll end up using the wrong argument info.

@dlrobertson dlrobertson changed the title Fix LLVM generated for C-variadic arguments Fix LLVM IR generated for C-variadic arguments Mar 31, 2019
@nagisa
Copy link
Member

nagisa commented Mar 31, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Mar 31, 2019

📌 Commit 9095feb has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2019
Centril added a commit to Centril/rust that referenced this pull request Mar 31, 2019
Fix LLVM IR generated for C-variadic arguments

It is possible to create malformed LLVM IR given variadic arguments that
are aggregate types. This occurs due to improper tracking of the current
argument in the functions list of arguments.

Fixes: rust-lang#58881
@Centril
Copy link
Contributor

Centril commented Mar 31, 2019

Failed in #59582 (comment), @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 31, 2019
@dlrobertson
Copy link
Contributor Author

dlrobertson commented Mar 31, 2019

Fixed the test. It now passes on the following architectures:

  • x86_64-unknown-linux-gnu
  • i686-unknown-linux-gnu
  • i586-unkown-linux-gnu

@dlrobertson
Copy link
Contributor Author

It still fails on aarch64-unknown-linux-gnu. I'm debating adding ignore statements for certain architectures

@nagisa
Copy link
Member

nagisa commented Mar 31, 2019 via email

@bors
Copy link
Contributor

bors commented Mar 31, 2019

📌 Commit ebed9e5fb16238dfb09bc4ed23859e391160109f has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 31, 2019
@nagisa
Copy link
Member

nagisa commented Mar 31, 2019 via email

@bors
Copy link
Contributor

bors commented Mar 31, 2019

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Mar 31, 2019

📌 Commit ebed9e5fb16238dfb09bc4ed23859e391160109f has been approved by nagisa

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 31, 2019
@dlrobertson
Copy link
Contributor Author

@nagisa Made the CHECK string a bit more general and it passes with all of the previously listed architectures. Would it be better to see if it passes homu or just add ignores now for the host triples I didn't test?

@Centril
Copy link
Contributor

Centril commented Mar 31, 2019

r? @nagisa

@nagisa
Copy link
Member

nagisa commented Mar 31, 2019

@dlrobertson It would be fine to ignore as well, but I think, as far as codegen tests are concerned, that also means compilation errors, and thus ICEs, are ignored as well.

It is possible to create malformed LLVM IR given variadic arguments that
are aggregate types. This occurs due to improper tracking of the current
argument in the functions list of arguments.
@dlrobertson dlrobertson force-pushed the fix_58881 branch 2 times, most recently from 2e97578 to a9d62be Compare March 31, 2019 17:47
@dlrobertson
Copy link
Contributor Author

After doing some further testing my updated version does not fail on prior versions. As a result, we'll need to use ignore for a proper regression test. I used only-x86_64. Technically the test can also be run on aarch64, but I figured it would be more maintainable if we used an only- statement instead of multiple ignore- statements. I think ignore-windows is needed because Windows on x86_64 is similar to i686.

@nagisa
Copy link
Member

nagisa commented Mar 31, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Mar 31, 2019

📌 Commit a9d62be has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 31, 2019
@bors
Copy link
Contributor

bors commented Mar 31, 2019

⌛ Testing commit a9d62be with merge e3428db...

bors added a commit that referenced this pull request Mar 31, 2019
Fix LLVM IR generated for C-variadic arguments

It is possible to create malformed LLVM IR given variadic arguments that
are aggregate types. This occurs due to improper tracking of the current
argument in the functions list of arguments.

Fixes: #58881
@bors
Copy link
Contributor

bors commented Mar 31, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nagisa
Pushing e3428db to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 31, 2019
@bors bors merged commit a9d62be into rust-lang:master Mar 31, 2019
@dlrobertson dlrobertson deleted the fix_58881 branch March 31, 2019 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants