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

llvm: replace some deprecated functions, add fixmes #109862

Merged
merged 8 commits into from
Apr 8, 2023

Conversation

klensy
Copy link
Contributor

@klensy klensy commented Apr 2, 2023

Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.

@rustbot
Copy link
Collaborator

rustbot commented Apr 2, 2023

r? @WaffleLapkin

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

@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 Apr 2, 2023
@klensy klensy changed the title llvm: llvm: replace some deprecated functions, add fixmes Apr 2, 2023
Comment on lines 1075 to 1078
// FIXME: deprecated, replace with LLVMMDStringInContext2
pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;

// LLVMMDStringInContext but don't own string
pub fn LLVMMDStringInContext2(C: &Context, Str: *const c_char, SLen: size_t) -> &Metadata;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can probably replace LLVMMDStringInContext with LLVMMDStringInContext2 all around, using value<->metadata wrappers around, but don't know is it worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like some of them are sensible to replace at least. E.g. in consts.rs LLVMMDStringInContext and LLVMMDNodeInContext can be replaced with the 2 variants (just need to replace both of them together and it works out fine).

Copy link
Contributor Author

@klensy klensy Apr 5, 2023

Choose a reason for hiding this comment

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

Yes, but void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, LLVMValueRef Val)

let meta = llvm::LLVMMDNodeInContext(self.llcx, data.as_ptr(), 2);
llvm::LLVMAddNamedMetadataOperand(
self.llmod,
"wasm.custom_sections\0".as_ptr().cast(),
meta,
);

https://github.com/llvm/llvm-project/blame/02aa966c135172885182ddd6f5d76883c2402bed/llvm/lib/IR/Core.cpp#L1292-L1300
feeds in LLVMValueRef , but LLVMMDNodeInContext2 will return LLVMMetadataRef, so wrap\unwrap (or rewrite LLVMAddNamedMetadataOperand).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) prevents refactor too, sadly.

Comment on lines +1301 to 1306
pub fn LLVMBuildCleanupPad<'a>(
B: &Builder<'a>,
ParentPad: Option<&'a Value>,
ArgCnt: c_uint,
Args: *const &'a Value,
NumArgs: c_uint,
Name: *const c_char,
) -> Option<&'a Value>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sometimes llvm type LLVMValueRef modeled in rust as Option<&'a Value>, sometimes as &'a Value, where LLVMValueRef can be nullptr:
https://github.com/llvm/llvm-project/blame/42d1b276f7793999be3f9b6a99efbb143254c729/llvm/lib/IR/Core.cpp#L3170-L3178

It feels wrong and can lead to funny results, or i'm wrong? Don't have strong c++ here, so advice requested.

@klensy
Copy link
Contributor Author

klensy commented Apr 3, 2023

@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2023
@klensy
Copy link
Contributor Author

klensy commented Apr 3, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 3, 2023
@WaffleLapkin
Copy link
Member

r? nikic

@rustbot rustbot assigned nikic and unassigned WaffleLapkin Apr 3, 2023
klensy added 6 commits April 4, 2023 15:12
… LLVMValueRef, some that accept LLVMMetadataRef, and replacing one with another not always possible without explicit convertion
… LLVMRustMetadataTypeInContext with LLVMMetadataTypeInContext
LLVMRustBuildCleanupPad -> LLVMBuildCleanupPad
LLVMRustBuildCleanupRet -> LLVMBuildCleanupRet
LLVMRustBuildCatchPad -> LLVMBuildCatchPad
LLVMRustBuildCatchRet -> LLVMBuildCatchRet
LLVMRustBuildCatchSwitch -> LLVMBuildCatchSwitch
LLVMRustBuildIntCast -> LLVMBuildIntCast2
LLVMRustAddHandler -> LLVMAddHandler
compiler/rustc_codegen_llvm/src/llvm/ffi.rs Outdated Show resolved Hide resolved
Comment on lines 1075 to 1078
// FIXME: deprecated, replace with LLVMMDStringInContext2
pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;

// LLVMMDStringInContext but don't own string
pub fn LLVMMDStringInContext2(C: &Context, Str: *const c_char, SLen: size_t) -> &Metadata;
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like some of them are sensible to replace at least. E.g. in consts.rs LLVMMDStringInContext and LLVMMDNodeInContext can be replaced with the 2 variants (just need to replace both of them together and it works out fine).

compiler/rustc_codegen_llvm/src/llvm/ffi.rs Outdated Show resolved Hide resolved
@klensy
Copy link
Contributor Author

klensy commented Apr 7, 2023

@rustbot ready

@nikic
Copy link
Contributor

nikic commented Apr 7, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 7, 2023

📌 Commit c0bc001 has been approved by nikic

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 7, 2023
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 7, 2023
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Apr 7, 2023
llvm: replace some deprecated functions, add fixmes

Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Apr 7, 2023
llvm: replace some deprecated functions, add fixmes

Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.
@Noratrieb
Copy link
Member

maybe this was the cause of https://github.com/notifications#issuecomment-1500588281?
@bors rollup=iffy
feel free to r- if you think it's likely, but I'll leave it open for now to test it again

@bors
Copy link
Contributor

bors commented Apr 7, 2023

⌛ Testing commit c0bc001 with merge 7d6375c5f6ff8809fe43ad38f6fb068b850dd2d9...

@bors
Copy link
Contributor

bors commented Apr 7, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 7, 2023
@klensy
Copy link
Contributor Author

klensy commented Apr 7, 2023

Yes, can reproduce when building stage2 compiler, but don't have idea why, for now.

fails on f41e711

@rust-log-analyzer

This comment has been minimized.

@klensy
Copy link
Contributor Author

klensy commented Apr 8, 2023

@rustbot ready fixed issue with B/bool type

@nikic
Copy link
Contributor

nikic commented Apr 8, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2023

📌 Commit fdfca76 has been approved by nikic

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 Apr 8, 2023
@bors
Copy link
Contributor

bors commented Apr 8, 2023

⌛ Testing commit fdfca76 with merge dd2b195...

@bors
Copy link
Contributor

bors commented Apr 8, 2023

☀️ Test successful - checks-actions
Approved by: nikic
Pushing dd2b195 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 8, 2023
@bors bors merged commit dd2b195 into rust-lang:master Apr 8, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 8, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dd2b195): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.1% [2.9%, 3.3%] 2
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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. T-compiler Relevant 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.

8 participants