forked from OSchip/llvm-project
Don't use alias from derived dtor to base dtor at -O0.
This patch disables aliasing (and rauw) of derived dtors to base dtors at -O0. This optimization can have a negative impact on the debug quality. This was a latent bug for some time with local classes, but got noticed when it was generalized and broke gdb's destrprint.exp. llvm-svn: 194618
This commit is contained in:
parent
59e4a6f5e2
commit
d967badc64
|
@ -34,6 +34,11 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
|
|||
if (!getCodeGenOpts().CXXCtorDtorAliases)
|
||||
return true;
|
||||
|
||||
// Producing an alias to a base class ctor/dtor can degrade debug quality
|
||||
// as the debugger cannot tell them appart.
|
||||
if (getCodeGenOpts().OptimizationLevel == 0)
|
||||
return true;
|
||||
|
||||
// If the destructor doesn't have a trivial body, we have to emit it
|
||||
// separately.
|
||||
if (!D->hasTrivialBody())
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck %s
|
||||
// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
|
||||
// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
|
||||
|
||||
namespace test1 {
|
||||
// test that we don't produce an alias when the destructor is weak_odr. The
|
||||
|
@ -53,6 +54,11 @@ namespace test4 {
|
|||
|
||||
// CHECK-DAG: define linkonce_odr void @_ZN5test41AD2Ev(
|
||||
// CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
|
||||
|
||||
// test that we don't do this optimization at -O0 so that the debugger can
|
||||
// see both destructors.
|
||||
// NOOPT-DAG: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
|
||||
// NOOOPT-DAG: define linkonce_odr void @_ZN5test41BD2Ev
|
||||
struct A {
|
||||
virtual ~A() {}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions | FileCheck %s
|
||||
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns | FileCheck %s
|
||||
|
||||
// CHECK-DAG: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
|
||||
// CHECK-DAG: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases | FileCheck %s
|
||||
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
|
||||
|
||||
struct Member {
|
||||
~Member();
|
||||
|
|
Loading…
Reference in New Issue