-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
compiler: Use LLVM's Comdat support #131876
Conversation
Some changes occurred in coverage instrumentation. cc @Zalathar |
These commits modify compiler targets. |
They really don't they just touch the public API... |
Thanks. r=me after squishing the fixups. |
268a153
to
49bb96c
Compare
@bors r+ |
extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V, | ||
const char *Name, size_t NameLen) { | ||
Triple TargetTriple = Triple(unwrap(M)->getTargetTriple()); | ||
GlobalObject *GV = unwrap<GlobalObject>(V); | ||
if (TargetTriple.supportsCOMDAT()) { | ||
StringRef NameRef(Name, NameLen); | ||
GV->setComdat(unwrap(M)->getOrInsertComdat(NameRef)); | ||
} | ||
} |
There was a problem hiding this comment.
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.
…r=Zalathar compiler: Use LLVM's Comdat support Acting on these long-ago issues: - rust-lang#46437 - rust-lang#68955
…kingjubilee Rollup of 8 pull requests Successful merges: - rust-lang#127462 (std: uefi: Add basic Env variables) - rust-lang#131537 (Fix range misleading field access) - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml) - rust-lang#131871 (x86-32 float return for 'Rust' ABI: treat all float types consistently) - rust-lang#131876 (compiler: Use LLVM's Comdat support) - rust-lang#131890 (Update `use` keyword docs to describe precise capturing) - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders) - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.) r? `@ghost` `@rustbot` modify labels: rollup
…r=Zalathar compiler: Use LLVM's Comdat support Acting on these long-ago issues: - rust-lang#46437 - rust-lang#68955
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#127462 (std: uefi: Add basic Env variables) - rust-lang#131537 (Fix range misleading field access) - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml) - rust-lang#131871 (x86-32 float return for 'Rust' ABI: treat all float types consistently) - rust-lang#131876 (compiler: Use LLVM's Comdat support) - rust-lang#131890 (Update `use` keyword docs to describe precise capturing) - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders) - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.) - rust-lang#131916 (small interpreter error cleanup) - rust-lang#131919 (zero-sized accesses are fine on null pointers) r? `@ghost` `@rustbot` modify labels: rollup
let name_buf = get_value_name(val).to_vec(); | ||
let name = | ||
CString::from_vec_with_nul(name_buf).or_else(|buf| CString::new(buf.into_bytes())).unwrap(); | ||
set_comdat(llmod, val, &name); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 <[email protected]>
49bb96c
to
4927600
Compare
This succeeded in @bors r+ |
Rollup of 4 pull requests Successful merges: - rust-lang#131876 (compiler: Use LLVM's Comdat support) - rust-lang#131941 (compiletest: disambiguate html-tidy from rust tidy tool) - rust-lang#131942 (compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`) - rust-lang#131945 (rustdoc: Clean up footnote handling) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131876 - workingjubilee:llvm-c-c-c-comdat, r=Zalathar compiler: Use LLVM's Comdat support Acting on these long-ago issues: - rust-lang#46437 - rust-lang#68955
…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.
…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.
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.
Acting on these long-ago issues:
r? @Zalathar