Skip to content

Commit 62cffee

Browse files
committed
Auto merge of rust-lang#123785 - bjorn3:sync_cg_clif-2024-04-11, r=bjorn3
Subtree sync for rustc_codegen_cranelift This fixes an ICE for unreachable blocks. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 241fc13 + 2ab4334 commit 62cffee

File tree

8 files changed

+44
-14
lines changed

8 files changed

+44
-14
lines changed

Diff for: compiler/rustc_codegen_cranelift/.cirrus.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ task:
77
- curl https://sh.rustup.rs -sSf --output rustup.sh
88
- sh rustup.sh --default-toolchain none -y --profile=minimal
99
target_cache:
10-
folder: target
10+
folder: build/cg_clif
1111
prepare_script:
1212
- . $HOME/.cargo/env
1313
- ./y.sh prepare
@@ -16,4 +16,5 @@ task:
1616
# Disabling incr comp reduces cache size and incr comp doesn't save as much
1717
# on CI anyway.
1818
- export CARGO_BUILD_INCREMENTAL=false
19-
- ./y.sh test
19+
# Skip rand as it fails on FreeBSD due to rust-random/rand#1355
20+
- ./y.sh test --skip-test test.rust-random/rand

Diff for: compiler/rustc_codegen_cranelift/.github/actions/github-release/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async function runOnce() {
5656
force: true,
5757
});
5858
} catch (e) {
59-
console.log("ERROR: ", JSON.stringify(e.data, null, 2));
59+
console.log("ERROR: ", JSON.stringify(e.response, null, 2));
6060
core.info(`creating dev tag`);
6161
try {
6262
await octokit.rest.git.createRef({
@@ -68,7 +68,7 @@ async function runOnce() {
6868
} catch (e) {
6969
// we might race with others, so assume someone else has created the
7070
// tag by this point.
71-
console.log("failed to create tag: ", JSON.stringify(e.data, null, 2));
71+
console.log("failed to create tag: ", JSON.stringify(e.response, null, 2));
7272
}
7373
}
7474

Diff for: compiler/rustc_codegen_cranelift/.github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ jobs:
268268
if: ${{ github.ref == 'refs/heads/master' }}
269269
needs: [rustfmt, test, bench, dist]
270270

271+
permissions:
272+
contents: write # for creating the dev tag and release
273+
271274
concurrency:
272275
group: release-dev
273276
cancel-in-progress: true

Diff for: compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch

+13
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ index d9de37e..8293fce 100644
8282
#[cfg(target_has_atomic_load_store = "ptr")]
8383
macro_rules! atomic_int_ptr_sized {
8484
( $($target_pointer_width:literal $align:literal)* ) => { $(
85+
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
86+
index 58b9ba4..91bbd0a 100644
87+
--- a/library/core/src/cell.rs
88+
+++ b/library/core/src/cell.rs
89+
@@ -2246,8 +2246,6 @@ unsafe_cell_primitive_into_inner! {
90+
u32 "32"
91+
i64 "64"
92+
u64 "64"
93+
- i128 "128"
94+
- u128 "128"
95+
isize "ptr"
96+
usize "ptr"
97+
}
8598
--
8699
2.26.2.7.g19db9cfb68
87100

Diff for: compiler/rustc_codegen_cranelift/rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-04-05"
2+
channel = "nightly-2024-04-11"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]

Diff for: compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ pushd rust
1010

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

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

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

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

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

Diff for: compiler/rustc_codegen_cranelift/src/base.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,19 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
267267
.generic_activity("codegen prelude")
268268
.run(|| crate::abi::codegen_fn_prelude(fx, start_block));
269269

270-
for (bb, bb_data) in traversal::mono_reachable(fx.mir, fx.tcx, fx.instance) {
270+
let reachable_blocks = traversal::mono_reachable_as_bitset(fx.mir, fx.tcx, fx.instance);
271+
272+
for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() {
271273
let block = fx.get_block(bb);
272274
fx.bcx.switch_to_block(block);
273275

276+
if !reachable_blocks.contains(bb) {
277+
// We want to skip this block, because it's not reachable. But we still create
278+
// the block so terminators in other blocks can reference it.
279+
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
280+
continue;
281+
}
282+
274283
if bb_data.is_cleanup {
275284
// Unwinding after panicking is not supported
276285
continue;

Diff for: compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ impl UnwindContext {
3838
}
3939

4040
pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) {
41+
if let target_lexicon::OperatingSystem::MacOSX { .. } = isa.triple().operating_system {
42+
// The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
43+
// requires for unwinding tables. In addition on arm64 it currently doesn't
44+
// support 32bit relocations as we currently use for the unwinding table.
45+
// See gimli-rs/object#415 and rust-lang/rustc_codegen_cranelift#1371
46+
return;
47+
}
48+
4149
let unwind_info = if let Some(unwind_info) =
4250
context.compiled_code().unwrap().create_unwind_info(isa).unwrap()
4351
{

0 commit comments

Comments
 (0)