about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-07-19 19:50:04 -0400
committerRalf Jung <post@ralfj.de>2022-07-20 17:12:07 -0400
commit5e840c5c8c75081dda4b33f8afcb0c77ad3105bb (patch)
tree04c4b2e6e9bb5210805b27ac89f990098b5e157c /compiler/rustc_codegen_llvm
parent8affef2ccba424f37445f6df6592426600d00a31 (diff)
downloadrust-5e840c5c8c75081dda4b33f8afcb0c77ad3105bb.tar.gz
rust-5e840c5c8c75081dda4b33f8afcb0c77ad3105bb.zip
incorporate some review feedback
Diffstat (limited to 'compiler/rustc_codegen_llvm')
-rw-r--r--compiler/rustc_codegen_llvm/src/intrinsic.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs
index 01e276ac902..9cca9bcf724 100644
--- a/compiler/rustc_codegen_llvm/src/intrinsic.rs
+++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs
@@ -10,6 +10,7 @@ use crate::value::Value;
 use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh};
 use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
 use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
+use rustc_codegen_ssa::meth;
 use rustc_codegen_ssa::mir::operand::OperandRef;
 use rustc_codegen_ssa::mir::place::PlaceRef;
 use rustc_codegen_ssa::traits::*;
@@ -364,17 +365,13 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
             }
 
             sym::vtable_size | sym::vtable_align => {
-                let ptr = args[0].immediate();
-                let layout = self.layout_of(self.tcx.types.usize);
-                let type_ = self.backend_type(layout);
-                let offset = match name {
-                    sym::vtable_size => 1,
-                    sym::vtable_align => 2,
+                let vtable = args[0].immediate();
+                let idx = match name {
+                    sym::vtable_size => ty::COMMON_VTABLE_ENTRIES_SIZE,
+                    sym::vtable_align => ty::COMMON_VTABLE_ENTRIES_ALIGN,
                     _ => bug!(),
                 };
-                let offset = self.const_int(type_, offset);
-                let vtable_field_ptr = self.inbounds_gep(type_, ptr, &[offset]);
-                self.load(type_, vtable_field_ptr, layout.align.abi)
+                meth::VirtualIndex::from_index(idx).get_usize(self, vtable)
             }
 
             _ if name.as_str().starts_with("simd_") => {