@@ -10,13 +10,10 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
10
10
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
11
11
use rustc_middle:: ty:: layout:: HasTyCtxt ;
12
12
use rustc_middle:: ty:: query:: Providers ;
13
- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
13
+ use rustc_middle:: ty:: { self , TyCtxt } ;
14
14
use rustc_session:: config:: { OptLevel , Sanitizer } ;
15
15
use rustc_session:: Session ;
16
- use rustc_target:: abi:: call:: Conv ;
17
- use rustc_target:: spec:: PanicStrategy ;
18
16
19
- use crate :: abi:: FnAbi ;
20
17
use crate :: attributes;
21
18
use crate :: llvm:: AttributePlace :: Function ;
22
19
use crate :: llvm:: { self , Attribute } ;
@@ -77,12 +74,6 @@ pub fn emit_uwtable(val: &'ll Value, emit: bool) {
77
74
Attribute :: UWTable . toggle_llfn ( Function , val, emit) ;
78
75
}
79
76
80
- /// Tell LLVM whether the function can or cannot unwind.
81
- #[ inline]
82
- fn unwind ( val : & ' ll Value , can_unwind : bool ) {
83
- Attribute :: NoUnwind . toggle_llfn ( Function , val, !can_unwind) ;
84
- }
85
-
86
77
/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
87
78
#[ inline]
88
79
fn naked ( val : & ' ll Value , is_naked : bool ) {
@@ -246,12 +237,7 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {
246
237
247
238
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
248
239
/// attributes.
249
- pub fn from_fn_attrs (
250
- cx : & CodegenCx < ' ll , ' tcx > ,
251
- llfn : & ' ll Value ,
252
- instance : ty:: Instance < ' tcx > ,
253
- fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
254
- ) {
240
+ pub fn from_fn_attrs ( cx : & CodegenCx < ' ll , ' tcx > , llfn : & ' ll Value , instance : ty:: Instance < ' tcx > ) {
255
241
let codegen_fn_attrs = cx. tcx . codegen_fn_attrs ( instance. def_id ( ) ) ;
256
242
257
243
match codegen_fn_attrs. optimize {
@@ -315,46 +301,6 @@ pub fn from_fn_attrs(
315
301
}
316
302
sanitize ( cx, codegen_fn_attrs. flags , llfn) ;
317
303
318
- unwind (
319
- llfn,
320
- if cx. tcx . sess . panic_strategy ( ) != PanicStrategy :: Unwind {
321
- // In panic=abort mode we assume nothing can unwind anywhere, so
322
- // optimize based on this!
323
- false
324
- } else if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: UNWIND ) {
325
- // If a specific #[unwind] attribute is present, use that.
326
- true
327
- } else if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: RUSTC_ALLOCATOR_NOUNWIND ) {
328
- // Special attribute for allocator functions, which can't unwind.
329
- false
330
- } else {
331
- if fn_abi. conv == Conv :: Rust {
332
- // Any Rust method (or `extern "Rust" fn` or `extern
333
- // "rust-call" fn`) is explicitly allowed to unwind
334
- // (unless it has no-unwind attribute, handled above).
335
- true
336
- } else {
337
- // Anything else is either:
338
- //
339
- // 1. A foreign item using a non-Rust ABI (like `extern "C" { fn foo(); }`), or
340
- //
341
- // 2. A Rust item using a non-Rust ABI (like `extern "C" fn foo() { ... }`).
342
- //
343
- // Foreign items (case 1) are assumed to not unwind; it is
344
- // UB otherwise. (At least for now; see also
345
- // rust-lang/rust#63909 and Rust RFC 2753.)
346
- //
347
- // Items defined in Rust with non-Rust ABIs (case 2) are also
348
- // not supposed to unwind. Whether this should be enforced
349
- // (versus stating it is UB) and *how* it would be enforced
350
- // is currently under discussion; see rust-lang/rust#58794.
351
- //
352
- // In either case, we mark item as explicitly nounwind.
353
- false
354
- }
355
- } ,
356
- ) ;
357
-
358
304
// Always annotate functions with the target-cpu they are compiled for.
359
305
// Without this, ThinLTO won't inline Rust functions into Clang generated
360
306
// functions (because Clang annotates functions this way too).
0 commit comments