]> granicus.if.org Git - clang/commitdiff
When possible, use the vbase offset offsets from the most derived class directly.
authorAnders Carlsson <andersca@mac.com>
Thu, 11 Mar 2010 07:00:45 +0000 (07:00 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 11 Mar 2010 07:00:45 +0000 (07:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98247 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp

index 3e07756ad5cec585f95c45e8c457cac80c1115e3..9f792993ac48d281feeb931d606142c6af4f1873 100644 (file)
@@ -1406,9 +1406,16 @@ VtableBuilder::ComputeReturnAdjustment(BaseOffset Offset) {
   if (!Offset.isEmpty()) {
     if (Offset.VirtualBase) {
       // Get the virtual base offset offset.
-      Adjustment.VBaseOffsetOffset = 
-        VtableInfo.getVirtualBaseOffsetIndex(Offset.DerivedClass,
-                                             Offset.VirtualBase);
+      if (Offset.DerivedClass == MostDerivedClass) {
+        // We can get the offset offset directly from our map.
+        Adjustment.VBaseOffsetOffset = 
+          VBaseOffsetOffsets.lookup(Offset.VirtualBase);
+      } else {
+        Adjustment.VBaseOffsetOffset = 
+          VtableInfo.getVirtualBaseOffsetIndex(Offset.DerivedClass,
+                                               Offset.VirtualBase);
+      }
+
       // FIXME: Once the assert in getVirtualBaseOffsetIndex is back again,
       // we can get rid of this assert.
       assert(Adjustment.VBaseOffsetOffset != 0 &&