[llvm-branch-commits] [cfe-branch] r118575 - in /cfe/branches/Apple/whitney: lib/CodeGen/CGVTables.cpp test/CodeGenCXX/thunks.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 9 09:32:42 PST 2010
Author: ddunbar
Date: Tue Nov 9 11:32:42 2010
New Revision: 118575
URL: http://llvm.org/viewvc/llvm-project?rev=118575&view=rev
Log:
Merge r118466:
--
Author: John McCall <rjmccall at apple.com>
Date: Tue Nov 9 01:18:05 2010 +0000
When re-using a vtable slot for the nearest overridden method, just because
there's no return adjustment from the overridden to the overrider doesn't
mean there isn't a return adjustment from the overrider to the final
overrider. This matters if we're emitting a virtual this-adjustment thunk
because the overrider virtually inherits from the class providing the
nearest overridden method. Do the appropriate return adjustment in this case.
Fixes PR7611.
Modified:
cfe/branches/Apple/whitney/lib/CodeGen/CGVTables.cpp
cfe/branches/Apple/whitney/test/CodeGenCXX/thunks.cpp
Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGVTables.cpp?rev=118575&r1=118574&r2=118575&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGVTables.cpp Tue Nov 9 11:32:42 2010
@@ -1664,9 +1664,18 @@
if (ThisAdjustment.VCallOffsetOffset &&
Overrider.Method->getParent() == MostDerivedClass) {
+
+ // There's no return adjustment from OverriddenMD and MD,
+ // but that doesn't mean there isn't one between MD and
+ // the final overrider.
+ BaseOffset ReturnAdjustmentOffset =
+ ComputeReturnAdjustmentBaseOffset(Context, Overrider.Method, MD);
+ ReturnAdjustment ReturnAdjustment =
+ ComputeReturnAdjustment(ReturnAdjustmentOffset);
+
// This is a virtual thunk for the most derived class, add it.
AddThunk(Overrider.Method,
- ThunkInfo(ThisAdjustment, ReturnAdjustment()));
+ ThunkInfo(ThisAdjustment, ReturnAdjustment));
}
}
Modified: cfe/branches/Apple/whitney/test/CodeGenCXX/thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenCXX/thunks.cpp?rev=118575&r1=118574&r2=118575&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenCXX/thunks.cpp (original)
+++ cfe/branches/Apple/whitney/test/CodeGenCXX/thunks.cpp Tue Nov 9 11:32:42 2010
@@ -260,6 +260,25 @@
}
}
+// PR7611
+namespace Test11 {
+ struct A { virtual A* f(); };
+ struct B : virtual A { virtual A* f(); };
+ struct C : B { virtual C* f(); };
+ C* C::f() { return 0; }
+
+ // The this-adjustment and return-adjustment thunk required when
+ // C::f appears in a vtable where A is at a nonzero offset from C.
+ // CHECK: define {{.*}} @_ZTcv0_n24_v0_n32_N6Test111C1fEv(
+
+ // C::f itself.
+ // CHECK: define {{.*}} @_ZN6Test111C1fEv(
+
+ // The return-adjustment thunk required when C::f appears in a vtable
+ // where A is at a zero offset from C.
+ // CHECK: define {{.*}} @_ZTch0_v0_n32_N6Test111C1fEv(
+}
+
/**** The following has to go at the end of the file ****/
// This is from Test5:
More information about the llvm-branch-commits
mailing list