[cfe-commits] r94499 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/virt.cpp
Mike Stump
mrs at apple.com
Mon Jan 25 19:42:22 PST 2010
Author: mrs
Date: Mon Jan 25 21:42:22 2010
New Revision: 94499
URL: http://llvm.org/viewvc/llvm-project?rev=94499&view=rev
Log:
Be sure to track the non-virtual part of the vcall offset in complex
multiple inheritance cases. WIP.
This fixes 20% of the outstanding problems found by the randomized
tester.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/virt.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=94499&r1=94498&r2=94499&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Mon Jan 25 21:42:22 2010
@@ -59,6 +59,7 @@
llvm::DenseMap<const CXXMethodDecl *, Index_t> VCall;
llvm::DenseMap<GlobalDecl, Index_t> VCallOffset;
+ llvm::DenseMap<GlobalDecl, Index_t> VCallOffsetForVCall;
// This is the offset to the nearest virtual base
llvm::DenseMap<const CXXMethodDecl *, Index_t> NonVirtualOffset;
llvm::DenseMap<const CXXRecordDecl *, Index_t> VBIndex;
@@ -632,6 +633,7 @@
Index_t &idx = VCall[UMD];
// Allocate the first one, after that, we reuse the previous one.
if (idx == 0) {
+ VCallOffsetForVCall[UMD] = Offset/8;
NonVirtualOffset[UMD] = -CurrentVBaseOffset/8 + Offset/8;
idx = VCalls.size()+1;
VCalls.push_back(Offset/8 - CurrentVBaseOffset/8);
@@ -1077,14 +1079,15 @@
if (idx == 0) {
NonVirtualOffset[UMD] = CurrentVBaseOffset/8 - OverrideOffset/8;
VCallOffset[GD] = OverrideOffset/8;
+ VCallOffsetForVCall[UMD] = OverrideOffset/8;
idx = VCalls.size()+1;
- VCalls.push_back(0);
+ VCalls.push_back(OverrideOffset/8 - CurrentVBaseOffset/8);
D1(printf(" vcall for %s at %d with delta %d most derived %s\n",
MD->getNameAsString().c_str(), (int)-idx-3,
(int)VCalls[idx-1], MostDerivedClass->getNameAsCString()));
} else {
VCallOffset[GD] = VCallOffset[OGD];
- VCalls[idx-1] = -VCallOffset[OGD] + OverrideOffset/8;
+ VCalls[idx-1] = -VCallOffsetForVCall[UMD] + OverrideOffset/8;
D1(printf(" vcall patch for %s at %d with delta %d most derived %s\n",
MD->getNameAsString().c_str(), (int)-idx-3,
(int)VCalls[idx-1], MostDerivedClass->getNameAsCString()));
Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=94499&r1=94498&r2=94499&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Mon Jan 25 21:42:22 2010
@@ -389,8 +389,8 @@
// CHECK-LP64-NEXT: .quad 0
// CHECK-LP64-NEXT: .quad 0
// CHECK-LP64-NEXT: .quad -16
-// CHECK-LP64-NEXT .quad -32
-// CHECK-LP64: .quad 0
+// CHECK-LP64-NEXT: .quad -32
+// CHECK-LP64-NEXT: .quad 0
// CHECK-LP64-NEXT: .quad 0
// CHECK-LP64-NEXT: .quad -32
// CHECK-LP64-NEXT: .quad __ZTI8test16_D
More information about the cfe-commits
mailing list