forked from OSchip/llvm-project
InstrProf: Increment the profile counter for all types of destructor
-fprofile-instr-generate does not emit counter increment intrinsics for Dtor_Deleting and Dtor_Complete destructors with assigned counters. This causes unnecessary [-Wprofile-instr-out-of-date] warnings during profile-use runs even if the source has never been modified since profile collection. Patch by Betul Buyukkurt. Thanks! llvm-svn: 237804
This commit is contained in:
parent
fd27a1dc1b
commit
fb29822bf4
|
@ -1366,6 +1366,10 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
|
||||||
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl());
|
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl());
|
||||||
CXXDtorType DtorType = CurGD.getDtorType();
|
CXXDtorType DtorType = CurGD.getDtorType();
|
||||||
|
|
||||||
|
Stmt *Body = Dtor->getBody();
|
||||||
|
if (Body)
|
||||||
|
incrementProfileCounter(Body);
|
||||||
|
|
||||||
// The call to operator delete in a deleting destructor happens
|
// The call to operator delete in a deleting destructor happens
|
||||||
// outside of the function-try-block, which means it's always
|
// outside of the function-try-block, which means it's always
|
||||||
// possible to delegate the destructor body to the complete
|
// possible to delegate the destructor body to the complete
|
||||||
|
@ -1378,8 +1382,6 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stmt *Body = Dtor->getBody();
|
|
||||||
|
|
||||||
// If the body is a function-try-block, enter the try before
|
// If the body is a function-try-block, enter the try before
|
||||||
// anything else.
|
// anything else.
|
||||||
bool isTryBody = (Body && isa<CXXTryStmt>(Body));
|
bool isTryBody = (Body && isa<CXXTryStmt>(Body));
|
||||||
|
@ -1418,8 +1420,6 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
|
||||||
case Dtor_Base:
|
case Dtor_Base:
|
||||||
assert(Body);
|
assert(Body);
|
||||||
|
|
||||||
incrementProfileCounter(Body);
|
|
||||||
|
|
||||||
// Enter the cleanup scopes for fields and non-virtual bases.
|
// Enter the cleanup scopes for fields and non-virtual bases.
|
||||||
EnterDtorCleanups(Dtor, Dtor_Base);
|
EnterDtorCleanups(Dtor, Dtor_Base);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instr-generate | FileCheck %s
|
||||||
|
|
||||||
|
struct Member {
|
||||||
|
~Member();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
virtual ~A();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B : A {
|
||||||
|
Member m;
|
||||||
|
virtual ~B();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Complete dtor
|
||||||
|
// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev", section "__DATA,__llvm_prf_names", align 1
|
||||||
|
|
||||||
|
// Deleting dtor
|
||||||
|
// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev", section "__DATA,__llvm_prf_names", align 1
|
||||||
|
|
||||||
|
// Complete dtor counters and profile data
|
||||||
|
// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
|
||||||
|
// CHECK: @__llvm_profile_data__ZN1BD1Ev =
|
||||||
|
|
||||||
|
// Deleting dtor counters and profile data
|
||||||
|
// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
|
||||||
|
// CHECK: @__llvm_profile_data__ZN1BD0Ev =
|
||||||
|
|
||||||
|
B::~B() { }
|
Loading…
Reference in New Issue