On Thu, Oct 25, 2012 at 6:46 PM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Alexey, it seems it is failing on i686-*-*. Suppressed in r166683.<br>
Please investigate.<br></blockquote><div><br></div><div>Fixed a test in r166758. Thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
...Takumi<br>
<br>
2012/10/25 Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>>:<br>
> Author: samsonov<br>
> Date: Thu Oct 25 05:18:50 2012<br>
> New Revision: 166676<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=166676&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=166676&view=rev</a><br>
> Log:<br>
> Initialize debug info for special cases of functions that lack declarations and are generated by Clang (global initializers/destructors, thunks) . Fixes PR13942.<br>
><br>
> Added:<br>
> cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp<br>
> cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp<br>
> cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp<br>
> Modified:<br>
> cfe/trunk/lib/CodeGen/CGBlocks.cpp<br>
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>
> cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=166676&r1=166675&r2=166676&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=166676&r1=166675&r2=166676&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -1650,6 +1650,8 @@<br>
> SC_None,<br>
> false, false);<br>
><br>
> + // Initialize debug info if necessary.<br>
> + CGF.maybeInitializeDebugInfo();<br>
> CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());<br>
><br>
> if (byrefInfo.needsCopy()) {<br>
> @@ -1720,6 +1722,8 @@<br>
> SC_Static,<br>
> SC_None,<br>
> false, false);<br>
> + // Initialize debug info if necessary.<br>
> + CGF.maybeInitializeDebugInfo();<br>
> CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());<br>
><br>
> if (byrefInfo.needsDispose()) {<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=166676&r1=166675&r2=166676&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=166676&r1=166675&r2=166676&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -2050,14 +2050,22 @@<br>
> FnBeginRegionCount.push_back(LexicalBlockStack.size());<br>
><br>
> const Decl *D = GD.getDecl();<br>
> + // Function may lack declaration in source code if it is created by Clang<br>
> + // CodeGen (examples: _GLOBAL__I_a, __cxx_global_array_dtor, thunk).<br>
> + bool HasDecl = (D != 0);<br>
> // Use the location of the declaration.<br>
> - SourceLocation Loc = D->getLocation();<br>
> -<br>
> + SourceLocation Loc;<br>
> + if (HasDecl)<br>
> + Loc = D->getLocation();<br>
> +<br>
> unsigned Flags = 0;<br>
> llvm::DIFile Unit = getOrCreateFile(Loc);<br>
> llvm::DIDescriptor FDContext(Unit);<br>
> llvm::DIArray TParamsArray;<br>
> - if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {<br>
> + if (!HasDecl) {<br>
> + // Use llvm function name.<br>
> + Name = Fn->getName();<br>
> + } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {<br>
> // If there is a DISubprogram for this function available then use it.<br>
> llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator<br>
> FI = SPCache.find(FD->getCanonicalDecl());<br>
> @@ -2104,12 +2112,13 @@<br>
> Name = Name.substr(1);<br>
><br>
> unsigned LineNo = getLineNumber(Loc);<br>
> - if (D->isImplicit())<br>
> + if (!HasDecl || D->isImplicit())<br>
> Flags |= llvm::DIDescriptor::FlagArtificial;<br>
><br>
> llvm::DIType DIFnType;<br>
> llvm::DISubprogram SPDecl;<br>
> - if (CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) {<br>
> + if (HasDecl &&<br>
> + CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) {<br>
> DIFnType = getOrCreateFunctionType(D, FnType, Unit);<br>
> SPDecl = getFunctionDeclaration(D);<br>
> } else {<br>
> @@ -2132,7 +2141,8 @@<br>
> // Push function on region stack.<br>
> llvm::MDNode *SPN = SP;<br>
> LexicalBlockStack.push_back(SPN);<br>
> - RegionMap[D] = llvm::WeakVH(SP);<br>
> + if (HasDecl)<br>
> + RegionMap[D] = llvm::WeakVH(SP);<br>
> }<br>
><br>
> /// EmitLocation - Emit metadata to indicate a change in line/column<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=166676&r1=166675&r2=166676&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=166676&r1=166675&r2=166676&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -163,6 +163,9 @@<br>
><br>
> CodeGenFunction CGF(CGM);<br>
><br>
> + // Initialize debug info if needed.<br>
> + CGF.maybeInitializeDebugInfo();<br>
> +<br>
> CGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, fn,<br>
> CGM.getTypes().arrangeNullaryFunction(),<br>
> FunctionArgList(), SourceLocation());<br>
> @@ -345,6 +348,9 @@<br>
> void CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn,<br>
> llvm::Constant **Decls,<br>
> unsigned NumDecls) {<br>
> + // Initialize debug info if needed.<br>
> + maybeInitializeDebugInfo();<br>
> +<br>
> StartFunction(GlobalDecl(), getContext().VoidTy, Fn,<br>
> getTypes().arrangeNullaryFunction(),<br>
> FunctionArgList(), SourceLocation());<br>
> @@ -370,6 +376,9 @@<br>
> void CodeGenFunction::GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,<br>
> const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> ><br>
> &DtorsAndObjects) {<br>
> + // Initialize debug info if needed.<br>
> + maybeInitializeDebugInfo();<br>
> +<br>
> StartFunction(GlobalDecl(), getContext().VoidTy, Fn,<br>
> getTypes().arrangeNullaryFunction(),<br>
> FunctionArgList(), SourceLocation());<br>
> @@ -406,6 +415,9 @@<br>
> llvm::Function *fn =<br>
> CreateGlobalInitOrDestructFunction(CGM, FTy, "__cxx_global_array_dtor");<br>
><br>
> + // Initialize debug info if needed.<br>
> + maybeInitializeDebugInfo();<br>
> +<br>
> StartFunction(GlobalDecl(), getContext().VoidTy, fn, FI, args,<br>
> SourceLocation());<br>
><br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=166676&r1=166675&r2=166676&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=166676&r1=166675&r2=166676&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -333,7 +333,10 @@<br>
><br>
> FunctionArgs.push_back(Param);<br>
> }<br>
> -<br>
> +<br>
> + // Initialize debug info if needed.<br>
> + maybeInitializeDebugInfo();<br>
> +<br>
> StartFunction(GlobalDecl(), ResultType, Fn, FnInfo, FunctionArgs,<br>
> SourceLocation());<br>
><br>
><br>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp?rev=166676&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp?rev=166676&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp (added)<br>
> +++ cfe/trunk/test/CodeGenCXX/debug-info-blocks.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -0,0 +1,14 @@<br>
> +// RUN: %clang_cc1 %s -gline-tables-only -fblocks -S -emit-llvm -o - | FileCheck %s<br>
> +<br>
> +struct A {<br>
> + A();<br>
> + A(const A &);<br>
> + ~A();<br>
> +};<br>
> +<br>
> +void test() {<br>
> + __block A a;<br>
> +}<br>
> +<br>
> +// CHECK: [ DW_TAG_subprogram ] [line 10] [local] [def] [__Block_byref_object_copy_]<br>
> +// CHECK: [ DW_TAG_subprogram ] [line 10] [local] [def] [__Block_byref_object_dispose_]<br>
><br>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp?rev=166676&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp?rev=166676&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp (added)<br>
> +++ cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -0,0 +1,27 @@<br>
> +// RUN: %clang_cc1 %s -g -fno-use-cxa-atexit -S -emit-llvm -o - \<br>
> +// RUN: | FileCheck %s --check-prefix=CHECK-NOKEXT<br>
> +// RUN: %clang_cc1 %s -g -fno-use-cxa-atexit -fapple-kext -S -emit-llvm -o - \<br>
> +// RUN: | FileCheck %s --check-prefix=CHECK-KEXT<br>
> +<br>
> +class A {<br>
> + public:<br>
> + A() {}<br>
> + virtual ~A() {}<br>
> +};<br>
> +<br>
> +A glob;<br>
> +A array[2];<br>
> +<br>
> +void foo() {<br>
> + static A stat;<br>
> +}<br>
> +<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 12] [local] [def] [__cxx_global_var_init]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 12] [local] [def] [__dtor_glob]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__cxx_global_var_init1]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__cxx_global_array_dtor]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 13] [local] [def] [__dtor_]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line 16] [local] [def] [__dtor__ZZ3foovE4stat]<br>
> +// CHECK-NOKEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def] [_GLOBAL__I_a]<br>
> +<br>
> +// CHECK-KEXT: [ DW_TAG_subprogram ] [line {{.*}}] [local] [def] [_GLOBAL__D_a]<br>
><br>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=166676&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=166676&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (added)<br>
> +++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Thu Oct 25 05:18:50 2012<br>
> @@ -0,0 +1,17 @@<br>
> +// RUN: %clang_cc1 %s -g -S -emit-llvm -o - | FileCheck %s<br>
> +<br>
> +struct A {<br>
> + virtual void f();<br>
> +};<br>
> +<br>
> +struct B {<br>
> + virtual void f();<br>
> +};<br>
> +<br>
> +struct C : A, B {<br>
> + virtual void f();<br>
> +};<br>
> +<br>
> +void C::f() { }<br>
> +<br>
> +// CHECK: [ DW_TAG_subprogram ] [line 15] [def] [_ZThn8_N1C1fEv]<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>