r194288 - If a linkonce_odr dtor/ctor is identical to another one, just rauw.

David Blaikie dblaikie at gmail.com
Mon Nov 11 08:18:01 PST 2013


This seems to have broken the GDB bot:
http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/10344 (
http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/10344/steps/gdb-75-check/logs/gdb.cp__destrprint.exp)

I haven't looked too closely at the failure yet, but let me know if you
need a hand understanding it or deciding if it's a true/false positive.

I suspect, while the optimization you've implemented is legitimate, it will
reduce -O0 debuggability somewhat (as COMDAT/function deduplication tends
to) - if it does so too severely we might want to enable it only in -O1 and
above. (times like these it might be nice to have -Og)


On Fri, Nov 8, 2013 at 2:59 PM, Rafael Espindola <rafael.espindola at gmail.com
> wrote:

> Author: rafael
> Date: Fri Nov  8 16:59:46 2013
> New Revision: 194288
>
> URL: http://llvm.org/viewvc/llvm-project?rev=194288&view=rev
> Log:
> If a linkonce_odr dtor/ctor is identical to another one, just rauw.
>
> Unlike an alias a rauw is always safe, so we don't need to avoid this
> optimization when the replacement is not know to be available in every TU.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGCXX.cpp
>     cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
>     cfe/trunk/test/CodeGenCXX/destructors.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=194288&r1=194287&r2=194288&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Nov  8 16:59:46 2013
> @@ -139,6 +139,13 @@ bool CodeGenModule::TryEmitDefinitionAsA
>    if (Ref->getType() != AliasType)
>      Aliasee = llvm::ConstantExpr::getBitCast(Ref, AliasType);
>
> +  // Instead of creating as alias to a linkonce_odr, replace all of the
> uses
> +  // of the aliassee.
> +  if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage) {
> +    Replacements[MangledName] = Aliasee;
> +    return false;
> +  }
> +
>    // Don't create an alias to a linker weak symbol unless we know we can
> do
>    // that in every TU. This avoids producing different COMDATs in
> different
>    // TUs.
> @@ -146,12 +153,6 @@ bool CodeGenModule::TryEmitDefinitionAsA
>      if (!InEveryTU)
>        return true;
>
> -    // Instead of creating as alias to a linkonce_odr, replace all of the
> uses
> -    // of the aliassee.
> -    if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage) {
> -      Replacements[MangledName] = Aliasee;
> -      return false;
> -    }
>      assert(Linkage == TargetLinkage);
>    }
>
>
> Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=194288&r1=194287&r2=194288&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Fri Nov  8 16:59:46 2013
> @@ -45,10 +45,11 @@ B x;
>
>  namespace test4 {
>    // Test that we don't produce aliases from B to A. We cannot because we
> cannot
> -  // guarantee that they will be present in every TU.
> +  // guarantee that they will be present in every TU. Instead, we just
> call
> +  // A's destructor directly.
>
> -  // CHECK-DAG: define linkonce_odr void @_ZN5test41BD2Ev(
>    // CHECK-DAG: define linkonce_odr void @_ZN5test41AD2Ev(
> +  // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
>    struct A {
>      virtual ~A() {}
>    };
>
> Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=194288&r1=194287&r2=194288&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/destructors.cpp Fri Nov  8 16:59:46 2013
> @@ -45,7 +45,7 @@ namespace PR7526 {
>    allocator::~allocator() throw() { foo(); }
>
>    // CHECK-LABEL: define void @_ZN6PR75263fooEv()
> -  // CHECK: call void @_ZN6PR752617allocator_derivedD2Ev
> +  // CHECK: call void {{.*}} @_ZN6PR75269allocatorD2Ev
>
>    void foo() {
>      allocator_derived ad;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131111/a3809982/attachment.html>


More information about the cfe-commits mailing list