forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#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
29 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 | ||
|
||
#![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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// compile-flags: -C no-prepopulate-passes -C panic=abort -C force-unwind-tables=n | ||
// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=n | ||
// ignore-windows | ||
|
||
#![crate_type="lib"] | ||
|
||
// CHECK-LABEL: define void @foo | ||
// CHECK-NOT: attributes #{{.*}} uwtable | ||
pub fn foo() {} | ||
#[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// compile-flags: -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,33 @@ | ||
// run-pass | ||
// ignore-windows target requires uwtable | ||
// 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); | ||
} |