]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_codegen_gcc/src/common.rs
Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum
[rust.git] / compiler / rustc_codegen_gcc / src / common.rs
index 3868f2f7a49510150c644b8e4d42f1f6960d7e8b..ccb6cbbc2c8a74bb98ab5a977c8698dea5b7c769 100644 (file)
@@ -183,13 +183,6 @@ fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) ->
             }
             Scalar::Ptr(ptr, _size) => {
                 let (alloc_id, offset) = ptr.into_parts();
-                // For vtables, get the underlying data allocation.
-                let alloc_id = match self.tcx.global_alloc(alloc_id) {
-                    GlobalAlloc::Vtable(ty, trait_ref) => {
-                        self.tcx.vtable_allocation((ty, trait_ref))
-                    }
-                    _ => alloc_id,
-                };
                 let base_addr =
                     match self.tcx.global_alloc(alloc_id) {
                         GlobalAlloc::Memory(alloc) => {
@@ -208,7 +201,11 @@ fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) ->
                         GlobalAlloc::Function(fn_instance) => {
                             self.get_fn_addr(fn_instance)
                         },
-                        GlobalAlloc::Vtable(..) => panic!("vtables are already handled"),
+                        GlobalAlloc::VTable(ty, trait_ref) => {
+                            let alloc = self.tcx.global_alloc(self.tcx.vtable_allocation((ty, trait_ref))).unwrap_memory();
+                            let init = const_alloc_to_gcc(self, alloc);
+                            self.static_addr_of(init, alloc.inner().align, None)
+                        }
                         GlobalAlloc::Static(def_id) => {
                             assert!(self.tcx.is_static(def_id));
                             self.get_static(def_id).get_address(None)