Skip to content

Commit ea22451

Browse files
danielsntedinski
authored andcommittedMay 26, 2021
Correctly handle the abort intrinsic (rust-lang#151)
1 parent df98a52 commit ea22451

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed
 

‎compiler/rustc_codegen_llvm/src/gotoc/hooks.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,19 @@ impl<'tcx> GotocHook<'tcx> for Intrinsic {
221221
span: Option<Span>,
222222
) -> Stmt {
223223
let loc = tcx.codegen_span_option2(span);
224-
let p = assign_to.unwrap();
225-
let target = target.unwrap();
226-
Stmt::block(
227-
vec![
228-
tcx.codegen_intrinsic(instance, fargs, &p, span),
229-
Stmt::goto(tcx.find_label(&target), loc.clone()),
230-
],
231-
loc,
232-
)
224+
if (tcx.symbol_name(instance) == "abort") {
225+
Stmt::assert_false("abort intrinsic reached", loc)
226+
} else {
227+
let p = assign_to.unwrap();
228+
let target = target.unwrap();
229+
Stmt::block(
230+
vec![
231+
tcx.codegen_intrinsic(instance, fargs, &p, span),
232+
Stmt::goto(tcx.find_label(&target), loc.clone()),
233+
],
234+
loc,
235+
)
236+
}
233237
}
234238
}
235239

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
#![feature(core_intrinsics)]
4+
use std::intrinsics;
5+
fn main() {
6+
intrinsics::abort();
7+
}

0 commit comments

Comments
 (0)
Please sign in to comment.