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

Add loongarch64 asm! support #101069

Merged
merged 1 commit into from
Apr 25, 2023
Merged

Conversation

zhaixiaojuan
Copy link
Contributor

No description provided.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cjgillot (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 27, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 27, 2022
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 2022

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor

As it's related to asm, @Amanieu could you take a look?

@Amanieu
Copy link
Member

Amanieu commented Aug 27, 2022

LGTM but this needs tests in src/test/assembly/asm.

@rust-log-analyzer

This comment has been minimized.

@zhaixiaojuan
Copy link
Contributor Author

src/test/assembly/asm/loongarch-type.rs generates the corresponding assembly file: loongarch-type.s

@Amanieu
Copy link
Member

Amanieu commented Sep 5, 2022

It seems that CI is failing due to a check introduced by #77280.

cc @petrochenkov: The loongarch target was added in LLVM 15, and is not available on the PR CI which uses the system LLVM.

@Amanieu
Copy link
Member

Amanieu commented Sep 5, 2022

I think you might be able to fix this by adding // min-llvm-version: 15.0 to that file.

@zhaixiaojuan
Copy link
Contributor Author

I think you might be able to fix this by adding // min-llvm-version: 15.0 to that file.

Thanks a lot.

@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Sep 5, 2022

When COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS is set, compiletest expects that all llvm components used by any test are available. This env var is set in CI. In other words you can't use make a test conditional on any llvm component that isn't enabled by default for rust it seems. If loongarch64 is already supported by the llvm version used by rust, you could add it to

None => "AVR;M68k",
to enable it. (also make sure to add it to the experimental_targets field in config.toml.example).

@Amanieu
Copy link
Member

Amanieu commented Sep 5, 2022

I think you need to adjust this check:

if let Some(needed_components) =

Move the component detection after the LLVM version checking.

@rust-log-analyzer

This comment has been minimized.

@zhaixiaojuan
Copy link
Contributor Author

I adjusted the check order of llvm version and component in the file
src/tools/compiletest/src/header.rs.

@@ -0,0 +1,195 @@
// min-llvm-version: 15.0
// revisions: loongarch64
Copy link
Member

Choose a reason for hiding this comment

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

This line is not needed.

if let Some(actual_version) = config.llvm_version {
if let Some(rest) = line.strip_prefix("min-llvm-version:").map(str::trim) {
let min_version = extract_llvm_version(rest).unwrap();
// Ignore if actual version is smaller the minimum required
// version
actual_version < min_version
return actual_version < min_version;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return actual_version < min_version;
if actual_version < min_version {
return true;
}

} else if let Some(rest) = line.strip_prefix("min-system-llvm-version:").map(str::trim) {
let min_version = extract_llvm_version(rest).unwrap();
// Ignore if using system LLVM and actual version
// is smaller the minimum required version
config.system_llvm && actual_version < min_version
return config.system_llvm && actual_version < min_version;
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@@ -1069,11 +1055,27 @@ fn ignore_llvm(config: &Config, line: &str) -> bool {
panic!("Malformed LLVM version range: max < min")
}
// Ignore if version lies inside of range.
actual_version >= v_min && actual_version <= v_max
return actual_version >= v_min && actual_version <= v_max;
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

} else {
false
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Remove the else branch: if there's no min-llvm-version then we should continue on to the next check below.

Comment on lines 1074 to 1076
return true;
} else {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return true;
} else {
return false;
true
} else {
false

Use trailing return syntax.

}
} else {
false
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return false;
false

@zhaixiaojuan
Copy link
Contributor Author

I seem to find a problem, when the iter_header function is called in make_test_description, the iter_header function loops to read the configuration information of each line in the xxx-types.rs file, and ignore_llvm is called every time during the loop.
When reading min-llvm-revision, the min-llvm-version branch will be entered in the llvm-ignore function. But when reading the component, the version check will be skipped and go directly to the component branch, which results in a "missing LLVM component: loongarch" error.

make_test_description:
image
iter_header:
image

I'm not sure if my thinking is correct, my current understanding is:
Between lines 924 and 948 of the code, I think the logic here should be that as long as there is a configuration that makes the value of ignore true, then the value of ignore will be true at the end.
Therefore, when ignore is set to true in one loop of iter_header, the value of ignore does not need to be set in subsequent loops.So when setting the ignore value, I added the judgment condition.

src/tools/compiletest/src/header.rs
make_test_description:

923        if !ignore {
924            ignore |= ignore_llvm(config, ln);
 ......
948            ignore |= !has_rust_lld && config.parse_name_directive(ln, "needs-rust-lld");
949        }

@Amanieu
Copy link
Member

Amanieu commented Sep 18, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Sep 18, 2022

📌 Commit ce51141ae3f5fa8f0ed8d0bdac8956e91e90ddb3 has been approved by Amanieu

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 Sep 18, 2022
@heiher
Copy link
Contributor

heiher commented Apr 12, 2023

@Amanieu I recently updated the patch set and noticed that one of the CI tests failed. It appears that the failling test is bound to an older version that does not support LoongArch. I would greatly appreciate it if you could provide me with some guidance on how to resolve this issue.

@heiher
Copy link
Contributor

heiher commented Apr 12, 2023

@Amanieu I recently updated the patch set and noticed that one of the CI tests failed. It appears that the failling test is bound to an older version that does not support LoongArch. I would greatly appreciate it if you could provide me with some guidance on how to resolve this issue.

It seems we should check the version before checking the components to ignore tests that do not match the min-llvm-version.

Amanieu added a commit to Amanieu/rust that referenced this pull request Apr 12, 2023
This check was introduced by rust-lang#77280 to ensure that all tests that are
filtered by LLVM component are actually tested in CI. However this
causes issues for new targets (e.g. rust-lang#101069) where support is only
available on the latest LLVM version.

This PR restricts the tests to only CI jobs that use the latest LLVM
version.
@Amanieu
Copy link
Member

Amanieu commented Apr 12, 2023

Should be fixed by #110232.

Copy link
Member

@Amanieu Amanieu left a comment

Choose a reason for hiding this comment

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

Can you also update the documentation in the unstable book for src/doc/unstable-book/src/language-features/asm-experimental-arch.md.

@@ -44,6 +44,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
| asm::InlineAsmArch::AArch64
| asm::InlineAsmArch::RiscV32
| asm::InlineAsmArch::RiscV64
| asm::InlineAsmArch::LoongArch64
Copy link
Member

Choose a reason for hiding this comment

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

Loongarch asm is not stable, it should not be included in this list.

@zhaixiaojuan zhaixiaojuan force-pushed the loongarch64-inline-asm branch 2 times, most recently from f57183f to 8b61821 Compare April 13, 2023 01:07
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Apr 13, 2023
@bors
Copy link
Contributor

bors commented Apr 13, 2023

☔ The latest upstream changes (presumably #109989) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit that referenced this pull request Apr 25, 2023
Allow older LLVM versions to have missing components

This check was introduced by #77280 to ensure that all tests that are filtered by LLVM component are actually tested in CI. However this causes issues for new targets (e.g. #101069) where support is only available on the latest LLVM version.

This PR restricts the tests to only CI jobs that use the latest LLVM version.
@Amanieu
Copy link
Member

Amanieu commented Apr 25, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 25, 2023

📌 Commit 5f2fa4c has been approved by Amanieu

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-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Apr 25, 2023
@bors
Copy link
Contributor

bors commented Apr 25, 2023

⌛ Testing commit 5f2fa4c with merge 999e6e5...

@bors
Copy link
Contributor

bors commented Apr 25, 2023

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing 999e6e5 to master...

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

Finished benchmarking commit (999e6e5): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.2% [1.1%, 2.9%] 3
Regressions ❌
(secondary)
4.9% [0.3%, 8.2%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.2% [1.1%, 2.9%] 3

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) - - 0

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)
- - 0
Improvements ✅
(primary)
-1.3% [-1.3%, -1.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.3% [-1.3%, -1.3%] 1

@rustbot rustbot added the perf-regression Performance regression. label Apr 25, 2023
@lqd
Copy link
Member

lqd commented Apr 25, 2023

cranelift-codegen / keccak are currently noisy, and this PR looks completely unrelated, @rustbot label: +perf-regression-triaged.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Apr 25, 2023
antoyo pushed a commit to antoyo/rust that referenced this pull request Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.