Auto merge of #86950 - tmiasko:personality, r=nagisa

Use existing declaration of rust_eh_personality

If crate declares `rust_eh_personality`, re-use existing declaration
as otherwise attempts to set function attributes that follow the
declaration will fail (unless it happens to have exactly the same
type signature as the one predefined in the compiler).

Fixes #70117.
Fixes https://github.com/rust-lang/rust/pull/81469#issuecomment-809428126; probably.
This commit is contained in:
bors 2021-07-18 20:33:23 +00:00
commit 59216858a3
4 changed files with 38 additions and 5 deletions

View file

@ -386,11 +386,16 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
} else {
"rust_eh_personality"
};
let fty = self.type_variadic_func(&[], self.type_i32());
self.declare_cfn(name, llvm::UnnamedAddr::Global, fty)
if let Some(llfn) = self.get_declared_value(name) {
llfn
} else {
let fty = self.type_variadic_func(&[], self.type_i32());
let llfn = self.declare_cfn(name, llvm::UnnamedAddr::Global, fty);
attributes::apply_target_cpu_attr(self, llfn);
llfn
}
}
};
attributes::apply_target_cpu_attr(self, llfn);
self.eh_personality.set(Some(llfn));
llfn
}