[cfe-commits] r89412 - in /cfe/trunk: lib/CodeGen/CGRecordLayoutBuilder.cpp lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/dyncast.cpp test/CodeGenCXX/virt.cpp
Mike Stump
mrs at apple.com
Thu Nov 19 16:02:19 PST 2009
Author: mrs
Date: Thu Nov 19 18:02:19 2009
New Revision: 89412
URL: http://llvm.org/viewvc/llvm-project?rev=89412&view=rev
Log:
Fixup key function calculations.
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dyncast.cpp
cfe/trunk/test/CodeGenCXX/virt.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=89412&r1=89411&r2=89412&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Thu Nov 19 18:02:19 2009
@@ -345,12 +345,8 @@
if (MD->isPure())
continue;
- // FIXME: This doesn't work. If we have an out of line body, that body will
- // set the MD to have a body, what we want to know is, was the body present
- // inside the declaration of the class. For now, we just avoid the problem
- // by pretending there is no key function.
- return 0;
- if (MD->getBody())
+ const FunctionDecl *fn;
+ if (MD->getBody(fn) && !fn->isOutOfLine())
continue;
// We found it.
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=89412&r1=89411&r2=89412&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Nov 19 18:02:19 2009
@@ -623,7 +623,9 @@
const CGRecordLayout &CGLayout = Types.getCGRecordLayout(RD);
// A definition of a KeyFunction, generates all the class data, such
// as vtable, rtti and the VTT.
- if (CGLayout.getKeyFunction() == MD)
+ if (CGLayout.getKeyFunction()
+ && (CGLayout.getKeyFunction()->getCanonicalDecl()
+ == MD->getCanonicalDecl()))
getVtableInfo().GenerateClassData(RD);
}
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
Modified: cfe/trunk/test/CodeGenCXX/dyncast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dyncast.cpp?rev=89412&r1=89411&r2=89412&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dyncast.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dyncast.cpp Thu Nov 19 18:02:19 2009
@@ -97,7 +97,7 @@
// CHECK-LL-NEXT: br i1 %4, label %5, label %9
// CHECK-LL: ; <label>:5
// CHECK-LL-NEXT: %6 = bitcast %class.test1_A* %tmp to i8*
-// CHECK-LL-NEXT: %7 = call i8* @__dynamic_cast(i8* %6, i8* bitcast (i8** @_ZTI7test1_B to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1)
+// CHECK-LL-NEXT: %7 = call i8* @__dynamic_cast(i8* %6, i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1)
// CHECK-LL-NEXT: %8 = bitcast i8* %7 to %class.test1_D*
// CHECK-LL-NEXT: br label %10
// CHECK-LL: ; <label>:9
@@ -120,7 +120,7 @@
// CHECK-LL-NEXT: br i1 %12, label %13, label %17
// CHECK-LL: ; <label>:13
// CHECK-LL-NEXT: %14 = bitcast %class.test1_A* %tmp6 to i8*
-// CHECK-LL-NEXT: %15 = call i8* @__dynamic_cast(i8* %14, i8* bitcast (i8** @_ZTI7test1_B to i8*), i8* bitcast (i8** @_ZTI7test1_A to i8*), i64 -1)
+// CHECK-LL-NEXT: %15 = call i8* @__dynamic_cast(i8* %14, i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i64 -1)
// CHECK-LL-NEXT: %16 = bitcast i8* %15 to %class.test1_A*
// CHECK-LL-NEXT: br label %18
// CHECK-LL: ; <label>:17
@@ -143,7 +143,7 @@
// CHECK-LL-NEXT: br i1 %20, label %21, label %25
// CHECK-LL: ; <label>:21
// CHECK-LL-NEXT: %22 = bitcast %class.test1_A* %tmp14 to i8*
-// CHECK-LL-NEXT: %23 = call i8* @__dynamic_cast(i8* %22, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_B to i8*), i64 -1)
+// CHECK-LL-NEXT: %23 = call i8* @__dynamic_cast({{.*}} %22, i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i64 -1)
// CHECK-LL-NEXT: %24 = bitcast i8* %23 to %class.test1_A*
// CHECK-LL-NEXT: br label %26
// CHECK-LL: ; <label>:25
@@ -214,7 +214,7 @@
// CHECK-LL-NEXT: br i1 %34, label %35, label %39
// CHECK-LL: ; <label>:35
// CHECK-LL-NEXT: %36 = bitcast %class.test1_A* %tmp54 to i8*
-// CHECK-LL-NEXT: %37 = call i8* @__dynamic_cast(i8* %36, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1)
+// CHECK-LL-NEXT: %37 = call i8* @__dynamic_cast(i8* %36, i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1)
// CHECK-LL-NEXT: %38 = bitcast i8* %37 to %class.test1_D*
// CHECK-LL-NEXT: br label %40
// CHECK-LL: ; <label>:39
@@ -237,7 +237,7 @@
// CHECK-LL-NEXT: br i1 %42, label %43, label %47
// CHECK-LL: ; <label>:43
// CHECK-LL-NEXT: %44 = bitcast %class.test1_A* %tmp63 to i8*
-// CHECK-LL-NEXT: %45 = call i8* @__dynamic_cast(i8* %44, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_E to i8*), i64 -1)
+// CHECK-LL-NEXT: %45 = call i8* @__dynamic_cast(i8* %44, i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_E to i8*), i64 -1)
// CHECK-LL-NEXT: %46 = bitcast i8* %45 to %class.test1_E*
// CHECK-LL-NEXT: br label %48
// CHECK-LL: ; <label>:47
@@ -279,7 +279,7 @@
// CHECK-LL: if.end85:
// CHECK-LL-NEXT: br i1 false, label %50, label %53
// CHECK-LL: ; <label>:50
-// CHECK-LL-NEXT: %51 = call i8* @__dynamic_cast(i8* null, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1)
+// CHECK-LL-NEXT: %51 = call i8* @__dynamic_cast(i8* null, i8* bitcast ({{.*}}* @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1)
// CHECK-LL-NEXT: %52 = bitcast i8* %51 to %class.test1_D*
// CHECK-LL-NEXT: br label %54
// CHECK-LL: ; <label>:53
Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=89412&r1=89411&r2=89412&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Thu Nov 19 18:02:19 2009
@@ -4,6 +4,11 @@
// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll
// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s
+
+// CHECK-LP64: main:
+// CHECK-LP64: movl $1, 12(%rax)
+// CHECK-LP64: movl $2, 8(%rax)
+
struct B {
virtual void bar1();
virtual void bar2();
@@ -12,6 +17,12 @@
void B::bar1() { }
void B::bar2() { }
+// CHECK-LP64: __ZTV1B:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI1B
+// CHECK-LP64-NEXT: .quad __ZN1B4bar1Ev
+// CHECK-LP64-NEXT: .quad __ZN1B4bar2Ev
+
struct C {
virtual void bee1();
virtual void bee2();
@@ -41,6 +52,28 @@
};
void F::foo() { }
+// CHECK-LP64: __ZTV1F:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 16
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI1F
+// CHECK-LP64-NEXT: .quad __ZN1D3booEv
+// CHECK-LP64-NEXT: .quad __ZN1F3fooEv
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 18446744073709551600
+// CHECK-LP64-NEXT: .quad __ZTI1F
+// CHECK-LP64-NEXT: .quad __ZN2D13barEv
+// CHECK-LP64-NEXT: .quad __ZN2D14bar2Ev
+// CHECK-LP64-NEXT: .quad __ZN2D14bar3Ev
+// CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev
+// CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev
+
+
int j;
void *vp;
void test2() {
@@ -79,9 +112,18 @@
ap->b = 2;
}
-// CHECK-LP64: main:
-// CHECK-LP64: movl $1, 12(%rax)
-// CHECK-LP64: movl $2, 8(%rax)
+// CHECK-LP64: __ZTV1A:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI1A
+// CHECK-LP64-NEXT: .quad __ZN1B4bar1Ev
+// CHECK-LP64-NEXT: .quad __ZN1B4bar2Ev
+// CHECK-LP64-NEXT: .quad __ZN1A4foo1Ev
+// CHECK-LP64-NEXT: .quad __ZN1A4foo2Ev
+// CHECK-LP64-NEXT: .quad 18446744073709551600
+// CHECK-LP64-NEXT: .quad __ZTI1A
+// CHECK-LP64-NEXT: .quad __ZN1C4bee1Ev
+// CHECK-LP64-NEXT: .quad __ZN1C4bee2Ev
+
struct test12_A {
virtual void foo0() { }
@@ -675,12 +717,10 @@
};
struct test16_D : test16_NV1, virtual test16_B2 {
- virtual void bar();
- virtual test16_D *foo1();
+ virtual void bar() { }
+ virtual test16_D *foo1() { return 0; }
};
-void test16_D::bar() { }
-
// CHECK-LP64: __ZTV8test16_D:
// CHECK-LP64-NEXT: .quad 32
// CHECK-LP64-NEXT: .quad 16
@@ -1040,45 +1080,6 @@
-// CHECK-LP64: __ZTV1B:
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .quad __ZTI1B
-// CHECK-LP64-NEXT: .quad __ZN1B4bar1Ev
-// CHECK-LP64-NEXT: .quad __ZN1B4bar2Ev
-
-// CHECK-LP64: __ZTV1A:
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .quad __ZTI1A
-// CHECK-LP64-NEXT: .quad __ZN1B4bar1Ev
-// CHECK-LP64-NEXT: .quad __ZN1B4bar2Ev
-// CHECK-LP64-NEXT: .quad __ZN1A4foo1Ev
-// CHECK-LP64-NEXT: .quad __ZN1A4foo2Ev
-// CHECK-LP64-NEXT: .quad 18446744073709551600
-// CHECK-LP64-NEXT: .quad __ZTI1A
-// CHECK-LP64-NEXT: .quad __ZN1C4bee1Ev
-// CHECK-LP64-NEXT: .quad __ZN1C4bee2Ev
-
-// CHECK-LP64: __ZTV1F:
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .quad 16
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .quad __ZTI1F
-// CHECK-LP64-NEXT: .quad __ZN1D3booEv
-// CHECK-LP64-NEXT: .quad __ZN1F3fooEv
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64-NEXT: .quad 18446744073709551600
-// CHECK-LP64-NEXT: .quad __ZTI1F
-// CHECK-LP64-NEXT: .quad __ZN2D13barEv
-// CHECK-LP64-NEXT: .quad __ZN2D14bar2Ev
-// CHECK-LP64-NEXT: .quad __ZN2D14bar3Ev
-// CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev
-// CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev
-
test21_D d21;
test20_D d20;
test19_D d19;
More information about the cfe-commits
mailing list