Skip to content

Subtree sync for rustc_codegen_cranelift #123785

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

Merged
merged 17 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_cranelift/.cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ task:
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh --default-toolchain none -y --profile=minimal
target_cache:
folder: target
folder: build/cg_clif
prepare_script:
- . $HOME/.cargo/env
- ./y.sh prepare
Expand All @@ -16,4 +16,5 @@ task:
# Disabling incr comp reduces cache size and incr comp doesn't save as much
# on CI anyway.
- export CARGO_BUILD_INCREMENTAL=false
- ./y.sh test
# Skip rand as it fails on FreeBSD due to rust-random/rand#1355
- ./y.sh test --skip-test test.rust-random/rand
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function runOnce() {
force: true,
});
} catch (e) {
console.log("ERROR: ", JSON.stringify(e.data, null, 2));
console.log("ERROR: ", JSON.stringify(e.response, null, 2));
core.info(`creating dev tag`);
try {
await octokit.rest.git.createRef({
Expand All @@ -68,7 +68,7 @@ async function runOnce() {
} catch (e) {
// we might race with others, so assume someone else has created the
// tag by this point.
console.log("failed to create tag: ", JSON.stringify(e.data, null, 2));
console.log("failed to create tag: ", JSON.stringify(e.response, null, 2));
}
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ jobs:
if: ${{ github.ref == 'refs/heads/master' }}
needs: [rustfmt, test, bench, dist]

permissions:
contents: write # for creating the dev tag and release

concurrency:
group: release-dev
cancel-in-progress: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ index d9de37e..8293fce 100644
#[cfg(target_has_atomic_load_store = "ptr")]
macro_rules! atomic_int_ptr_sized {
( $($target_pointer_width:literal $align:literal)* ) => { $(
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index 58b9ba4..91bbd0a 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -2246,8 +2246,6 @@ unsafe_cell_primitive_into_inner! {
u32 "32"
i64 "64"
u64 "64"
- i128 "128"
- u128 "128"
isize "ptr"
usize "ptr"
}
--
2.26.2.7.g19db9cfb68

2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-04-05"
channel = "nightly-2024-04-11"
components = ["rust-src", "rustc-dev", "llvm-tools"]
12 changes: 4 additions & 8 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ pushd rust

command -v rg >/dev/null 2>&1 || cargo install ripgrep

# FIXME remove this workaround once ICE tests no longer emit an outdated nightly message
for test in $(rg -i --files-with-matches "//@(\[.*\])? failure-status: 101" tests/ui); do
echo "rm $test"
rm -r tests/ui/{unsized-locals/,lto/,linkage*} || true
for test in $(rg --files-with-matches "lto" tests/{codegen-units,ui,incremental}); do
rm $test
done

rm -r tests/ui/{unsized-locals/,lto/,linkage*} || true
for test in $(rg --files-with-matches "lto" tests/{codegen-units,ui,incremental}); do
# should-fail tests don't work when compiletest is compiled with panic=abort
for test in $(rg --files-with-matches "//@ should-fail" tests/{codegen-units,ui,incremental}); do
rm $test
done

Expand Down Expand Up @@ -79,7 +78,6 @@ rm -r tests/run-make/fmt-write-bloat/ # tests an optimization
# ======================
rm tests/incremental/thinlto/cgu_invalidated_when_import_{added,removed}.rs # requires LLVM
rm -r tests/run-make/cross-lang-lto # same
rm -r tests/run-make/issue-7349 # same
rm -r tests/run-make/sepcomp-inlining # same
rm -r tests/run-make/sepcomp-separate # same
rm -r tests/run-make/sepcomp-cci-copies # same
Expand Down Expand Up @@ -116,8 +114,6 @@ rm -r tests/run-make/compiler-builtins # Expects lib/rustlib/src/rust to contain

# genuine bugs
# ============
rm tests/incremental/spike-neg1.rs # errors out for some reason
rm tests/incremental/spike-neg2.rs # same
rm -r tests/run-make/extern-fn-explicit-align # argument alignment not yet supported
rm -r tests/run-make/panic-abort-eh_frame # .eh_frame emitted with panic=abort

Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,19 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
.generic_activity("codegen prelude")
.run(|| crate::abi::codegen_fn_prelude(fx, start_block));

for (bb, bb_data) in traversal::mono_reachable(fx.mir, fx.tcx, fx.instance) {
let reachable_blocks = traversal::mono_reachable_as_bitset(fx.mir, fx.tcx, fx.instance);

for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() {
let block = fx.get_block(bb);
fx.bcx.switch_to_block(block);

if !reachable_blocks.contains(bb) {
// We want to skip this block, because it's not reachable. But we still create
// the block so terminators in other blocks can reference it.
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
continue;
}

if bb_data.is_cleanup {
// Unwinding after panicking is not supported
continue;
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ impl UnwindContext {
}

pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) {
if let target_lexicon::OperatingSystem::MacOSX { .. } = isa.triple().operating_system {
// The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
// requires for unwinding tables. In addition on arm64 it currently doesn't
// support 32bit relocations as we currently use for the unwinding table.
// See gimli-rs/object#415 and rust-lang/rustc_codegen_cranelift#1371
return;
}

let unwind_info = if let Some(unwind_info) =
context.compiled_code().unwrap().create_unwind_info(isa).unwrap()
{
Expand Down