Hi Argyrios and Renato,
Very sorry for the breakage.

I looked at the build log 4713 and saw two test failures:
FAIL: Clang::duplicate-mangled-name3.cpp
FAIL: LLVM::tail-call-mem-intrinsics.ll

It looks like the LLVM test (tail-call-mem-intrinsics.ll) also appeared in 
previous logs:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/4712
and the test was later removed.

The new clang test failed on ARM because a "void func(void *)" function is 
named like a constructor and the clang codegen
is trying to emit a call to it. The ARMABIInfo expects the constructor to 
return a pointer to the class/struct, whereas the other
targets seem to ignore the return type. I can twist the test case to make it 
pass on ARM, but I do not have a good idea yet
of how to properly fix the issue. I was thinking maybe I need a way to call 
setInvalidDecl() when emitting the
duplicate-mangled-name error message, so that other parts of the clang codegen 
can check that field. The clang::GlobalDecl
wrapper does not allow me to modify the underlying Decl struct though.

Renato, you mentioned that new bugs were introduced silently by this patch. Are 
there other bugs that I should be aware of?

- Gao


________________________________________
From: Argyrios Kyrtzidis [[email protected]]
Sent: Wednesday, April 15, 2015 7:34 AM
To: Gao, Yunzhong
Cc: Renato Golin; Clang Commits
Subject: Re: r234767 - [CodeGen] Fix crash with duplicated mangled name.

+ Yunzhong

> On Apr 15, 2015, at 1:50 AM, Renato Golin <[email protected]> wrote:
>
> I have reverted it for now, since new bugs have been introduced
> silently and this is the second time this week, we don't want to
> escalate.
>
> Let me know if you need help testing it next time.
>
> cheers,
> --renato
>
> On 15 April 2015 at 09:38, Renato Golin <[email protected]> wrote:
>> Hi,
>>
>> This patch broke all ARM bots:
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/4713
>>
>> static llvm::CastInst*
>> llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*,
>> llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion
>> `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
>>
>> Can you please have a look?
>>
>> cheers,
>> --renato

Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp	(revision 235075)
+++ lib/CodeGen/CodeGenModule.cpp	(working copy)
@@ -1372,6 +1372,15 @@
                               /*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.");
@@ -2410,14 +2419,6 @@
     }
   }
 
-  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");
Index: test/CodeGenCXX/duplicate-mangled-name2.cpp
===================================================================
--- test/CodeGenCXX/duplicate-mangled-name2.cpp	(revision 0)
+++ test/CodeGenCXX/duplicate-mangled-name2.cpp	(working copy)
@@ -0,0 +1,9 @@
+// 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;
Index: test/CodeGenCXX/duplicate-mangled-name3.cpp
===================================================================
--- test/CodeGenCXX/duplicate-mangled-name3.cpp	(revision 234767)
+++ test/CodeGenCXX/duplicate-mangled-name3.cpp	(working copy)
@@ -1,8 +1,9 @@
 // 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
 
+struct S;
 extern "C" {
-  void _ZN1SC2Ev(void *p) { } // expected-note {{previous}}
+  S *_ZN1SC2Ev(void *p) { return ((S *)0); } // expected-note {{previous}}
 }
 
 struct S {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to