compiler: Use LLVM's Comdat support by workingjubilee · Pull Request #131876 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation21 Commits3 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

workingjubilee

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Oct 18, 2024

@rustbot

Some changes occurred in coverage instrumentation.

cc @Zalathar

Zalathar

Zalathar

@Zalathar Zalathar added A-code-coverage

Area: Source-based code coverage (-Cinstrument-coverage)

A-LLVM

Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

labels

Oct 18, 2024

@rustbot

@workingjubilee

These commits modify compiler targets.

They really don't they just touch the public API...

Zalathar

@Zalathar

Thanks. r=me after squishing the fixups.

@workingjubilee

@Zalathar

@bors

📌 Commit 49bb96c has been approved by Zalathar

It is now in the queue for this repository.

@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

Oct 19, 2024

workingjubilee

Comment on lines -1661 to -1669

extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V,
const char *Name, size_t NameLen) {
Triple TargetTriple = Triple(unwrap(M)->getTargetTriple());
GlobalObject *GV = unwrap(V);
if (TargetTriple.supportsCOMDAT()) {
StringRef NameRef(Name, NameLen);
GV->setComdat(unwrap(M)->getOrInsertComdat(NameRef));
}
}

Choose a reason for hiding this comment

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

afaict the LLVM-C API doesn't have an exact match of the support check we do here, which is why I implemented it via Rust. I'll go fix that.

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Oct 19, 2024

@workingjubilee

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 19, 2024

@bors

…kingjubilee

Rollup of 8 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Oct 19, 2024

@matthiaskrgr

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 19, 2024

@bors

@matthiaskrgr

@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

Oct 19, 2024

Zalathar

Comment on lines +181 to +184

let name_buf = get_value_name(val).to_vec();
let name =
CString::from_vec_with_nul(name_buf).or_else(|buf
set_comdat(llmod, val, &name);

Choose a reason for hiding this comment

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

Oh, looks like we need the supports-comdat check here too.

Or maybe this is a sign that the check should be inside set_comdat instead?

Choose a reason for hiding this comment

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

Isn't this because !self.is_like_aix && !self.is_like_osx should be !self.is_like_aix || !self.is_like_osx?

No.

Choose a reason for hiding this comment

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

I mean it's really a sign that "setting a comdat" needs to be a function on the CodegenCx, imo, where we already have acquired all the info, so that it isn't called when we don't have access to that.

Choose a reason for hiding this comment

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

Yeah, that makes sense. Happy to leave that for future work.

@workingjubilee @Zalathar

Migrate llvm::set_comdat and llvm::SetUniqueComdat to LLVM-C FFI.

Note, now we can call llvm::set_comdat only when the target actually supports adding comdat. As this has no convenient LLVM-C API, we implement this as TargetOptions::supports_comdat.

Co-authored-by: Stuart Cook Zalathar@users.noreply.github.com

@workingjubilee

Zalathar added a commit to Zalathar/rust that referenced this pull request

Oct 19, 2024

@Zalathar

@Zalathar

This succeeded in aarch64-apple, so let's try it again.

@bors r+

@bors

📌 Commit 4927600 has been approved by Zalathar

It is now in the queue for this repository.

@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

Oct 20, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 20, 2024

@bors

Rollup of 4 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Oct 20, 2024

@rust-timer

@bors

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Oct 20, 2024

@matthiaskrgr

…nem,workingjubilee

Make llvm::set_section take a &CStr

There's no reason to convert the section name to an intermediate String, when the LLVM-C API wants a C string anyway.

Follow-up to rust-lang#131876.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Oct 20, 2024

@matthiaskrgr

…nem,workingjubilee

Make llvm::set_section take a &CStr

There's no reason to convert the section name to an intermediate String, when the LLVM-C API wants a C string anyway.

Follow-up to rust-lang#131876.

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Oct 20, 2024

@rust-timer

Rollup merge of rust-lang#131962 - Zalathar:llvm-set-section, r=Swatinem,workingjubilee

Make llvm::set_section take a &CStr

There's no reason to convert the section name to an intermediate String, when the LLVM-C API wants a C string anyway.

Follow-up to rust-lang#131876.

Labels

A-code-coverage

Area: Source-based code coverage (-Cinstrument-coverage)

A-LLVM

Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.