Skip to content

Commit 0938cb7

Browse files
authored
Rollup merge of #143564 - Enselic:must_emit_unwind_tables-comment, r=oli-obk
compiler: Deduplicate `must_emit_unwind_tables()` comments There is one comment at a call site and one comment in the function definition that are mostly saying the same thing. Fold the call site comment into the function definition comment to reduce duplication. There are actually some inaccuracies in the comments but let's deduplicate before we address the inaccuracies.
2 parents e366f16 + aa364ca commit 0938cb7

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
370370
};
371371
to_add.extend(inline_attr(cx, inline));
372372

373-
// The `uwtable` attribute according to LLVM is:
374-
//
375-
// This attribute indicates that the ABI being targeted requires that an
376-
// unwind table entry be produced for this function even if we can show
377-
// that no exceptions passes by it. This is normally the case for the
378-
// ELF x86-64 abi, but it can be disabled for some compilation units.
379-
//
380-
// Typically when we're compiling with `-C panic=abort` (which implies this
381-
// `no_landing_pads` check) we don't need `uwtable` because we can't
382-
// generate any exceptions! On Windows, however, exceptions include other
383-
// events such as illegal instructions, segfaults, etc. This means that on
384-
// Windows we end up still needing the `uwtable` attribute even if the `-C
385-
// panic=abort` flag is passed.
386-
//
387-
// You can also find more info on why Windows always requires uwtables here:
388-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
389373
if cx.sess().must_emit_unwind_tables() {
390374
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
391375
}

compiler/rustc_session/src/session.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,15 @@ impl Session {
776776

777777
pub fn must_emit_unwind_tables(&self) -> bool {
778778
// This is used to control the emission of the `uwtable` attribute on
779-
// LLVM functions.
779+
// LLVM functions. The `uwtable` attribute according to LLVM is:
780780
//
781+
// This attribute indicates that the ABI being targeted requires that an
782+
// unwind table entry be produced for this function even if we can show
783+
// that no exceptions passes by it. This is normally the case for the
784+
// ELF x86-64 abi, but it can be disabled for some compilation units.
785+
//
786+
// Typically when we're compiling with `-C panic=abort` we don't need
787+
// `uwtable` because we can't generate any exceptions!
781788
// Unwind tables are needed when compiling with `-C panic=unwind`, but
782789
// LLVM won't omit unwind tables unless the function is also marked as
783790
// `nounwind`, so users are allowed to disable `uwtable` emission.

0 commit comments

Comments
 (0)