Skip to content

Commit

Permalink
Add UWTable attr to functions with a personality function
Browse files Browse the repository at this point in the history
Adding a personality function forces LLVM to generate unwinding info that might be incorrect.
To solve it, always apply the UWTable attribute when setting a personality function.

Fixes rust-lang#123733
  • Loading branch information
Reflexe committed Jun 1, 2024
1 parent cfb7304 commit f435256
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}

fn set_personality_fn(&mut self, personality: &'ll Value) {
// Work around for https://github.com/rust-lang/rust/issues/123733
// add the UWTable attribute to every function with a personality function.
let uwtable = llvm::AttributeKind::UWTable.create_attr(self.llcx);
attributes::apply_to_llfn(self.llfn(), llvm::AttributePlace::Function, &[uwtable]);

unsafe {
llvm::LLVMSetPersonalityFn(self.llfn(), personality);
}
Expand Down

0 comments on commit f435256

Please sign in to comment.