r237804 - InstrProf: Increment the profile counter for all types of destructor
Justin Bogner
mail at justinbogner.com
Wed May 20 09:16:23 PDT 2015
Author: bogner
Date: Wed May 20 11:16:23 2015
New Revision: 237804
URL: http://llvm.org/viewvc/llvm-project?rev=237804&view=rev
Log:
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!
Added:
cfe/trunk/test/Profile/cxx-virtual-destructor-calls.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=237804&r1=237803&r2=237804&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed May 20 11:16:23 2015
@@ -1366,6 +1366,10 @@ void CodeGenFunction::EmitDestructorBody
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl());
CXXDtorType DtorType = CurGD.getDtorType();
+ Stmt *Body = Dtor->getBody();
+ if (Body)
+ incrementProfileCounter(Body);
+
// The call to operator delete in a deleting destructor happens
// outside of the function-try-block, which means it's always
// possible to delegate the destructor body to the complete
@@ -1378,8 +1382,6 @@ void CodeGenFunction::EmitDestructorBody
return;
}
- Stmt *Body = Dtor->getBody();
-
// If the body is a function-try-block, enter the try before
// anything else.
bool isTryBody = (Body && isa<CXXTryStmt>(Body));
@@ -1418,8 +1420,6 @@ void CodeGenFunction::EmitDestructorBody
case Dtor_Base:
assert(Body);
- incrementProfileCounter(Body);
-
// Enter the cleanup scopes for fields and non-virtual bases.
EnterDtorCleanups(Dtor, Dtor_Base);
Added: cfe/trunk/test/Profile/cxx-virtual-destructor-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-virtual-destructor-calls.cpp?rev=237804&view=auto
==============================================================================
--- cfe/trunk/test/Profile/cxx-virtual-destructor-calls.cpp (added)
+++ cfe/trunk/test/Profile/cxx-virtual-destructor-calls.cpp Wed May 20 11:16:23 2015
@@ -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() { }
More information about the cfe-commits
mailing list