Skip to content

Adjust getMCSubtargetInfo signature for LLVM 23+#156156

Open
DKLoehr wants to merge 1 commit intorust-lang:mainfrom
DKLoehr:subtarget_info
Open

Adjust getMCSubtargetInfo signature for LLVM 23+#156156
DKLoehr wants to merge 1 commit intorust-lang:mainfrom
DKLoehr:subtarget_info

Conversation

@DKLoehr
Copy link
Copy Markdown
Contributor

@DKLoehr DKLoehr commented May 4, 2026

A recent LLVM PR changed the signature of getMCSubtargetInfo to return a reference instead of a pointer. This adjusts uses of the function in compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp to account for the different signature.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 May 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @cuviper

@rust-log-analyzer

This comment has been minimized.

Comment on lines +94 to +100
#if LLVM_VERSION_GE(23, 0)
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
return MCInfo.checkFeatures(std::string("+") + Feature);
#else
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
return MCInfo->checkFeatures(std::string("+") + Feature);
#endif
Copy link
Copy Markdown
Member

@cuviper cuviper May 4, 2026

Choose a reason for hiding this comment

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

Maybe it would be better to have the old code form a reference too? e.g.

Suggested change
#if LLVM_VERSION_GE(23, 0)
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
return MCInfo.checkFeatures(std::string("+") + Feature);
#else
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
return MCInfo->checkFeatures(std::string("+") + Feature);
#endif
#if LLVM_VERSION_GE(23, 0)
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
#else
const MCSubtargetInfo &MCInfo = *Target->getMCSubtargetInfo();
#endif
return MCInfo.checkFeatures(std::string("+") + Feature);

This way we don't duplicate the "interesting" code in each case.

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants