-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #83482 - hyd-dev:uwtable, r=nagisa
Allow using `-C force-unwind-tables=no` when `panic=unwind` It seems LLVM still generates proper unwind tables even there is no `uwtable` attribute, unless I looked at the wrong place 🤔: https://github.com/llvm/llvm-project/blob/c21016715f0ee4a36affdf7150ac135ca98b0eae/llvm/include/llvm/IR/Function.h#L666 Therefore, I *assume* it's safe to omit `uwtable` even when `panic=unwind`, and this PR removes the restriction that disallows using `-C force-unwind-tables=no` when `panic=unwind`.
- Loading branch information
Showing
7 changed files
with
74 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// assembly-output: emit-asm | ||
// only-x86_64-unknown-linux-gnu | ||
// compile-flags: -C panic=unwind -C force-unwind-tables=n -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-NOT: .cfi_startproc | ||
pub fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// assembly-output: emit-asm | ||
// only-x86_64-unknown-linux-gnu | ||
// compile-flags: -C panic=unwind -C force-unwind-tables=n | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: foo: | ||
// CHECK: .cfi_startproc | ||
#[no_mangle] | ||
fn foo() { | ||
panic!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// compile-flags: -C panic=unwind -C no-prepopulate-passes | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK: attributes #{{.*}} uwtable | ||
pub fn foo() {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// run-pass | ||
// ignore-windows target requires uwtable | ||
// ignore-wasm32-bare no proper panic=unwind support | ||
// compile-flags: -C panic=unwind -C force-unwind-tables=n | ||
|
||
use std::panic::{self, AssertUnwindSafe}; | ||
|
||
struct Increase<'a>(&'a mut u8); | ||
|
||
impl Drop for Increase<'_> { | ||
fn drop(&mut self) { | ||
*self.0 += 1; | ||
} | ||
} | ||
|
||
#[inline(never)] | ||
fn unwind() { | ||
panic!(); | ||
} | ||
|
||
#[inline(never)] | ||
fn increase(count: &mut u8) { | ||
let _increase = Increase(count); | ||
unwind(); | ||
} | ||
|
||
fn main() { | ||
let mut count = 0; | ||
assert!(panic::catch_unwind(AssertUnwindSafe( | ||
#[inline(never)] | ||
|| increase(&mut count) | ||
)).is_err()); | ||
assert_eq!(count, 1); | ||
} |