When possible, use the vbase offset offsets from the most derived class directly.
llvm-svn: 98247
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp
index 3e07756..9f79299 100644
--- a/clang/lib/CodeGen/CGVtable.cpp
+++ b/clang/lib/CodeGen/CGVtable.cpp
@@ -1406,9 +1406,16 @@
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 &&