diff options
| author | Ralf Jung <post@ralfj.de> | 2022-07-17 11:36:37 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-07-20 16:57:31 -0400 |
| commit | da5e4d73f192b5c0faa357992e6b6c61707ae592 (patch) | |
| tree | 4f1672a1f13dc7ef0bd814b7b5d393d40ec32350 /compiler/rustc_codegen_gcc/src/common.rs | |
| parent | a7468c60f8dbf5feb23ad840b174d7e57113a846 (diff) | |
| download | rust-da5e4d73f192b5c0faa357992e6b6c61707ae592.tar.gz rust-da5e4d73f192b5c0faa357992e6b6c61707ae592.zip | |
add a Vtable kind of symbolic allocations
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/common.rs')
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/common.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs index fc391f53f18..3868f2f7a49 100644 --- a/compiler/rustc_codegen_gcc/src/common.rs +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -183,6 +183,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { } 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) => { @@ -201,6 +208,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { GlobalAlloc::Function(fn_instance) => { self.get_fn_addr(fn_instance) }, + GlobalAlloc::Vtable(..) => panic!("vtables are already handled"), GlobalAlloc::Static(def_id) => { assert!(self.tcx.is_static(def_id)); self.get_static(def_id).get_address(None) |
