Skip to content

Add TargetOptions::min_global_align, with s390x at 16-bit #44440

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

Merged
merged 2 commits into from
Sep 11, 2017

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Sep 8, 2017

The SystemZ LALR instruction provides PC-relative addressing for globals,
but only to even addresses, so other compilers make sure that such
globals are always 2-byte aligned. In Clang, this is modeled with
TargetInfo::MinGlobalAlign, and TargetOptions::min_global_align now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and
the latter two don't have targets in rust master.

Fixes #44411.
r? @eddyb

The SystemZ `LALR` instruction provides PC-relative addressing for
globals, but only to *even* addresses, so other compilers make sure that
such globals are always 2-byte aligned.  In Clang, this is modeled with
`TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX,
and the latter two don't have targets in rust master.
@eddyb
Copy link
Member

eddyb commented Sep 9, 2017

r? @alexcrichton or @japaric

@rust-highfive rust-highfive assigned alexcrichton and unassigned eddyb Sep 9, 2017
// which can force it to be smaller. Rust doesn't support this yet.
if let Some(min) = ccx.sess().target.target.options.min_global_align {
match ty::layout::Align::from_bits(min, min) {
Ok(min) => align = cmp::max(align, min.abi() as machine::llalign),
Copy link
Member

Choose a reason for hiding this comment

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

There's a .min method on Align, you should use that.

Copy link
Member Author

Choose a reason for hiding this comment

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

We want the greater of the two, so it would be Align::max. But this would require converting the incoming machine::llalign to Align, comparing, then back to llalign for the LLVM call. I don't see the point of that.

Copy link
Member

Choose a reason for hiding this comment

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

Well, llalign should have never existed etc. etc. I'll just have to remember fixing it on my branch where it's gone, but the rebase should catch it because of type mismatches and whatnot.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it's also pointless to convert min_global_align to Align. I just figured a little sanity checking of that value would be good.

Copy link
Member

@eddyb eddyb Sep 9, 2017

Choose a reason for hiding this comment

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

That conversion is fine, since it will be in there sooner or later! In the future I plan to have librustc_back and a lot of librustc/ty/layout.rs be in the same crate so even the target specification would use it.

@japaric
Copy link
Member

japaric commented Sep 9, 2017

@bors r+

Thanks @cuviper

@bors
Copy link
Collaborator

bors commented Sep 9, 2017

📌 Commit c606e97 has been approved by japaric

@bors
Copy link
Collaborator

bors commented Sep 11, 2017

⌛ Testing commit c606e97 with merge 19d30fc...

bors added a commit that referenced this pull request Sep 11, 2017
Add `TargetOptions::min_global_align`, with s390x at 16-bit

The SystemZ `LALR` instruction provides PC-relative addressing for globals,
but only to *even* addresses, so other compilers make sure that such
globals are always 2-byte aligned.  In Clang, this is modeled with
`TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and
the latter two don't have targets in rust master.

Fixes #44411.
r? @eddyb
@carols10cents carols10cents added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 11, 2017
@bors
Copy link
Collaborator

bors commented Sep 11, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: japaric
Pushing 19d30fc to master...

@bors bors merged commit c606e97 into rust-lang:master Sep 11, 2017
@cuviper cuviper deleted the min_global_align branch September 26, 2017 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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