When we're devirtualizing a method call, make sure the method has the correct IR type.

Reported in the thread "devirtualisation appears to crash clang on covariant functions on ARM" on cfe-dev.

llvm-svn: 166651
This commit is contained in:
Eli Friedman 2012-10-25 00:12:49 +00:00
parent d02437c902
commit ade609770e
2 changed files with 8 additions and 9 deletions

View File

@ -259,16 +259,16 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE,
}
// Compute the function type we're calling.
const CXXMethodDecl *CalleeDecl = DevirtualizedMethod ? DevirtualizedMethod : MD;
const CGFunctionInfo *FInfo = 0;
if (isa<CXXDestructorDecl>(MD))
FInfo = &CGM.getTypes().arrangeCXXDestructor(cast<CXXDestructorDecl>(MD),
if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(CalleeDecl))
FInfo = &CGM.getTypes().arrangeCXXDestructor(Dtor,
Dtor_Complete);
else if (isa<CXXConstructorDecl>(MD))
FInfo = &CGM.getTypes().arrangeCXXConstructorDeclaration(
cast<CXXConstructorDecl>(MD),
Ctor_Complete);
else if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(CalleeDecl))
FInfo = &CGM.getTypes().arrangeCXXConstructorDeclaration(Ctor,
Ctor_Complete);
else
FInfo = &CGM.getTypes().arrangeCXXMethodDeclaration(MD);
FInfo = &CGM.getTypes().arrangeCXXMethodDeclaration(CalleeDecl);
llvm::Type *Ty = CGM.getTypes().GetFunctionType(*FInfo);

View File

@ -131,8 +131,7 @@ namespace Test7 {
// CHECK: alloca
// CHECK-NEXT: store
// CHECK-NEXT: load
// CHECK-NEXT: bitcast
// CHECK-NEXT: call {{.*}} @_ZN5Test73zed1fEv
// CHECK-NEXT: call i32 @_ZN5Test73zed1fEv
// CHECK-NEXT: ret
return static_cast<bar*>(z)->f();
}