diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-07-07 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-07-10 15:43:05 +0200 |
| commit | f612ba1f846c0e9ee16b0f19dd7a3719d1dddd4b (patch) | |
| tree | 5302dbc7ecad1df1ec35f10875564d93fda032f9 /compiler/rustc_codegen_llvm/src | |
| parent | ae33a9714e73dda15030894821b6819f781ed7ba (diff) | |
| download | rust-f612ba1f846c0e9ee16b0f19dd7a3719d1dddd4b.tar.gz rust-f612ba1f846c0e9ee16b0f19dd7a3719d1dddd4b.zip | |
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).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index d1aecd32e2f..cccf2f8498c 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -385,11 +385,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 } |
