r234983 - Revert "[CodeGen] Fix crash with duplicated mangled name."

Renato Golin renato.golin at linaro.org
Wed Apr 15 01:44:40 PDT 2015


Author: rengolin
Date: Wed Apr 15 03:44:40 2015
New Revision: 234983

URL: http://llvm.org/viewvc/llvm-project?rev=234983&view=rev
Log:
Revert "[CodeGen] Fix crash with duplicated mangled name."

This reverts commit r234767, as it was breaking all ARM buildbots for two days and the
assert is not in the code, making it difficult to spot the error, which would keep the
bots red for a few more days. New errors were silently introduced because of this bug,
and we don't want this to escalate.

Removed:
    cfe/trunk/test/CodeGenCXX/duplicate-mangled-name2.cpp
    cfe/trunk/test/CodeGenCXX/duplicate-mangled-name3.cpp
Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=234983&r1=234982&r2=234983&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Apr 15 03:44:40 2015
@@ -1372,15 +1372,6 @@ void CodeGenModule::EmitGlobal(GlobalDec
                               /*DontDefer=*/false);
       return;
     }
-
-    if (llvm::GlobalValue *GV = GetGlobalValue(getMangledName(GD)))
-      if (!GV->isDeclaration()) {
-        getDiags().Report(FD->getLocation(), diag::err_duplicate_mangled_name);
-        GlobalDecl OldGD = Manglings.lookup(GV->getName());
-        if (auto *Prev = OldGD.getDecl())
-          getDiags().Report(Prev->getLocation(), diag::note_previous_definition);
-        return;
-      }
   } else {
     const auto *VD = cast<VarDecl>(Global);
     assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
@@ -2414,6 +2405,14 @@ void CodeGenModule::EmitGlobalFunctionDe
     }
   }
 
+  if (!GV->isDeclaration()) {
+    getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name);
+    GlobalDecl OldGD = Manglings.lookup(GV->getName());
+    if (auto *Prev = OldGD.getDecl())
+      getDiags().Report(Prev->getLocation(), diag::note_previous_definition);
+    return;
+  }
+
   if (GV->getType()->getElementType() != Ty) {
     // If the types mismatch then we have to rewrite the definition.
     assert(GV->isDeclaration() && "Shouldn't replace non-declaration");

Removed: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/duplicate-mangled-name2.cpp?rev=234982&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name2.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name2.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm-only %s -verify
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -femit-all-decls -emit-llvm-only %s -verify
-
-void foo(void *p) __asm("_ZN1SC2Ev");
-void foo(void *p) { } // expected-note {{previous}}
-
-struct S {
-  S() {} // expected-error {{definition with same mangled name as another definition}}
-} s;

Removed: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/duplicate-mangled-name3.cpp?rev=234982&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name3.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name3.cpp (removed)
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify
-// RUN: %clang_cc1 -triple %itanium_abi_triple -femit-all-decls -emit-llvm-only %s -verify
-
-extern "C" {
-  void _ZN1SC2Ev(void *p) { } // expected-note {{previous}}
-}
-
-struct S {
-  S() {} // expected-error {{definition with same mangled name as another definition}}
-} s;





More information about the cfe-commits mailing list