r206087 - [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
Author: whunt Date: Fri Apr 11 18:33:35 2014 New Revision: 206087 URL: http://llvm.org/viewvc/llvm-project?rev=206087view=rev Log: [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps If a vtordisp exists between two bases, then there is no need for additional alias avoidance padding. Test case included. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206087r1=206086r2=206087view=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 18:33:35 2014 @@ -2620,10 +2620,7 @@ void MicrosoftRecordLayoutBuilder::layou // bytes (in both 32 and 64 bits modes) and always involves rounding up to // the required alignment, we don't know why. if (PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() -BaseLayout.leadsWithZeroSizedBase()) - Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; -// Insert the vtordisp. -if (HasVtordisp) +BaseLayout.leadsWithZeroSizedBase() || HasVtordisp) Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; // Insert the virtual base. ElementInfo Info = getAdjustedElementInfo(BaseLayout); Modified: cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp?rev=206087r1=206086r2=206087view=diff == --- cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp (original) +++ cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp Fri Apr 11 18:33:35 2014 @@ -547,7 +547,37 @@ struct RZ8 : RX8, RY {}; // CHECK-X64-NEXT: | [sizeof=16, align=8 // CHECK-X64-NEXT: | nvsize=8, nvalign=8] +struct JA {}; +struct JB {}; +struct JC : JA { virtual void f() {} }; +struct JD : virtual JB, virtual JC { virtual void f() {} JD() {} }; +// CHECK: *** Dumping AST Record Layout +// CHECK: *** Dumping AST Record Layout +// CHECK: *** Dumping AST Record Layout +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT:0 | struct JD +// CHECK-NEXT:0 | (JD vbtable pointer) +// CHECK-NEXT:4 | struct JB (virtual base) (empty) +// CHECK-NEXT:4 | (vtordisp for vbase JC) +// CHECK-NEXT:8 | struct JC (virtual base) +// CHECK-NEXT:8 | (JC vftable pointer) +// CHECK-NEXT: 12 | struct JA (base) (empty) +// CHECK-NEXT: | [sizeof=12, align=4 +// CHECK-NEXT: | nvsize=4, nvalign=4] +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64-NEXT:0 | struct JD +// CHECK-X64-NEXT:0 | (JD vbtable pointer) +// CHECK-X64-NEXT:8 | struct JB (virtual base) (empty) +// CHECK-X64-NEXT: 12 | (vtordisp for vbase JC) +// CHECK-X64-NEXT: 16 | struct JC (virtual base) +// CHECK-X64-NEXT: 16 | (JC vftable pointer) +// CHECK-X64-NEXT: 24 | struct JA (base) (empty) +// CHECK-X64-NEXT: | [sizeof=24, align=8 +// CHECK-X64-NEXT: | nvsize=8, nvalign=8] int a[ sizeof(AT3) + @@ -565,4 +595,5 @@ sizeof(RZ5) + sizeof(RZ6) + sizeof(RZ7) + sizeof(RZ8) + +sizeof(JD) + 0]; ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206088 - Follow-up to r205999: Emit an artificial location (valid scope, line 0)
Author: adrian Date: Fri Apr 11 18:45:01 2014 New Revision: 206088 URL: http://llvm.org/viewvc/llvm-project?rev=206088view=rev Log: Follow-up to r205999: Emit an artificial location (valid scope, line 0) for CXXGlobalInit/Dtor helper functions. This makes _GLOBAL__I_a regain its DW_AT_high/low_pc in the debug info. Thanks to echristo for catching this! Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=206088r1=206087r2=206088view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Fri Apr 11 18:45:01 2014 @@ -431,43 +431,49 @@ void CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRefllvm::Constant * Decls, llvm::GlobalVariable *Guard) { - StartFunction(GlobalDecl(), getContext().VoidTy, Fn, -getTypes().arrangeNullaryFunction(), FunctionArgList()); - - llvm::BasicBlock *ExitBlock = 0; - if (Guard) { -// If we have a guard variable, check whether we've already performed these -// initializations. This happens for TLS initialization functions. -llvm::Value *GuardVal = Builder.CreateLoad(Guard); -llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, guard.uninitialized); -// Mark as initialized before initializing anything else. If the -// initializers use previously-initialized thread_local vars, that's -// probably supposed to be OK, but the standard doesn't say. -Builder.CreateStore(llvm::ConstantInt::get(GuardVal-getType(), 1), Guard); -llvm::BasicBlock *InitBlock = createBasicBlock(init); -ExitBlock = createBasicBlock(exit); -Builder.CreateCondBr(Uninit, InitBlock, ExitBlock); -EmitBlock(InitBlock); - } - - RunCleanupsScope Scope(*this); - - // When building in Objective-C++ ARC mode, create an autorelease pool - // around the global initializers. - if (getLangOpts().ObjCAutoRefCount getLangOpts().CPlusPlus) { -llvm::Value *token = EmitObjCAutoreleasePoolPush(); -EmitObjCAutoreleasePoolCleanup(token); - } - - for (unsigned i = 0, e = Decls.size(); i != e; ++i) -if (Decls[i]) - EmitRuntimeCall(Decls[i]); - - Scope.ForceCleanup(); - - if (ExitBlock) { -Builder.CreateBr(ExitBlock); -EmitBlock(ExitBlock); + { +ArtificialLocation AL(*this, Builder); +StartFunction(GlobalDecl(), getContext().VoidTy, Fn, + getTypes().arrangeNullaryFunction(), FunctionArgList()); +// Emit an artificial location for this function. +AL.Emit(); + +llvm::BasicBlock *ExitBlock = 0; +if (Guard) { + // If we have a guard variable, check whether we've already performed + // these initializations. This happens for TLS initialization functions. + llvm::Value *GuardVal = Builder.CreateLoad(Guard); + llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, + guard.uninitialized); + // Mark as initialized before initializing anything else. If the + // initializers use previously-initialized thread_local vars, that's + // probably supposed to be OK, but the standard doesn't say. + Builder.CreateStore(llvm::ConstantInt::get(GuardVal-getType(),1), Guard); + llvm::BasicBlock *InitBlock = createBasicBlock(init); + ExitBlock = createBasicBlock(exit); + Builder.CreateCondBr(Uninit, InitBlock, ExitBlock); + EmitBlock(InitBlock); +} + +RunCleanupsScope Scope(*this); + +// When building in Objective-C++ ARC mode, create an autorelease pool +// around the global initializers. +if (getLangOpts().ObjCAutoRefCount getLangOpts().CPlusPlus) { + llvm::Value *token = EmitObjCAutoreleasePoolPush(); + EmitObjCAutoreleasePoolCleanup(token); +} + +for (unsigned i = 0, e = Decls.size(); i != e; ++i) + if (Decls[i]) +EmitRuntimeCall(Decls[i]); + +Scope.ForceCleanup(); + +if (ExitBlock) { + Builder.CreateBr(ExitBlock); + EmitBlock(ExitBlock); +} } FinishFunction(); @@ -476,17 +482,22 @@ CodeGenFunction::GenerateCXXGlobalInitFu void CodeGenFunction::GenerateCXXGlobalDtorsFunc(llvm::Function *Fn, const std::vectorstd::pairllvm::WeakVH, llvm::Constant* DtorsAndObjects) { - StartFunction(GlobalDecl(), getContext().VoidTy, Fn, -getTypes().arrangeNullaryFunction(), FunctionArgList()); - - // Emit the dtors, in reverse order from construction. - for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) { -llvm::Value *Callee = DtorsAndObjects[e - i - 1].first; -llvm::CallInst *CI = Builder.CreateCall(Callee, -
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Apr 11, 2014, at 3:27 PM, Eric Christopher echri...@gmail.com wrote: On Fri, Apr 11, 2014 at 3:26 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:24 PM, Eric Christopher echri...@gmail.com wrote: So from looking at this it doesn't appear that we have any address range or location information for _GLOBAL__I_a anymore which is exactly what I was worried about: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) versus before: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_decl_file [DW_FORM_data1] (0x03) DW_AT_decl_line [DW_FORM_data1] (0x66) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) DW_AT_low_pc [DW_FORM_addr] (0x0020) DW_AT_high_pc [DW_FORM_data4] (0x000b) DW_AT_frame_base [DW_FORM_exprloc] (0x1 56 ) Now we don't have any note that this code belongs to this compile unit, etc. I think this part is incorrect. We should have scope and line information for this - even if it's line 0 etc. (Though I think the location of the variable would be a better one). Interesting! That was unintentional. I'll fix that. Thanks! Fixed in CFE r206088. 0x00e5: TAG_subprogram [13] AT_MIPS_linkage_name( _GLOBAL__I_a ) AT_artificial( 0x01 ) AT_accessibility( DW_ACCESS_public ) AT_low_pc( 0x03e0 ) AT_high_pc( 0x03eb ) AT_frame_base( rbp ) -- adrian ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206090 - [MS-ABI] Fix warning introduced in r206087
Author: whunt Date: Fri Apr 11 19:20:50 2014 New Revision: 206090 URL: http://llvm.org/viewvc/llvm-project?rev=206090view=rev Log: [MS-ABI] Fix warning introduced in r206087 No functional change. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206090r1=206089r2=206090view=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 19:20:50 2014 @@ -2619,8 +2619,8 @@ void MicrosoftRecordLayoutBuilder::layou // with a zero sized base. The padding between virtual bases is 4 // bytes (in both 32 and 64 bits modes) and always involves rounding up to // the required alignment, we don't know why. -if (PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() -BaseLayout.leadsWithZeroSizedBase() || HasVtordisp) +if ((PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() +BaseLayout.leadsWithZeroSizedBase()) || HasVtordisp) Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; // Insert the virtual base. ElementInfo Info = getAdjustedElementInfo(BaseLayout); ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r206087 - [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
On Apr 11, 2014, at 16:33, Warren Hunt wh...@google.com wrote: Author: whunt Date: Fri Apr 11 18:33:35 2014 New Revision: 206087 URL: http://llvm.org/viewvc/llvm-project?rev=206087view=rev Log: [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps If a vtordisp exists between two bases, then there is no need for additional alias avoidance padding. Test case included. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp cfe/trunk/test/Layout/ms-x86-alias-avoidance-padding.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206087r1=206086r2=206087view=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 18:33:35 2014 @@ -2620,10 +2620,7 @@ void MicrosoftRecordLayoutBuilder::layou // bytes (in both 32 and 64 bits modes) and always involves rounding up to // the required alignment, we don't know why. if (PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() -BaseLayout.leadsWithZeroSizedBase()) - Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; -// Insert the vtordisp. -if (HasVtordisp) +BaseLayout.leadsWithZeroSizedBase() || HasVtordisp) Can you add parentheses to silence warnings? I.e.: if ((PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() BaseLayout.leadsWithZeroSizedBase()) || HasVtordisp) Actually, putting the HasVtordisp first might even be easier to read: if (HasVtordisp || (PreviousBaseLayout PreviousBaseLayout-hasZeroSizedSubObject() BaseLayout.leadsWithZeroSizedBase())) Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Use -ivfsoverlay in ASTUnit
IntrusiveRefCntPtrLangOptions LangOpts; IntrusiveRefCntPtrDiagnosticsEngine Diagnostics; + IntrusiveRefCntPtrvfs::FileSystem VFS; IntrusiveRefCntPtrFileManager FileMgr; IntrusiveRefCntPtrSourceManager SourceMgr; … DiagnosticsEngine Diag, LangOptions LangOpts, SourceManager SourceMgr, FileManager FileMgr, +vfs::FileSystem VFS, Why do we need to keep the VFS separately, isn’t it owned by the FileManager ? Would it be better if a IntrusiveRefCntPtrvfs::FileSystem FS; is part of FileSystemOptions ? And created at the time with get the FileSystemOptions for the compiler invocation ? It seems it would simplify a bunch of code. On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote: Hi Dmitri and Argyrios, Could one (or both) of you take a look at my changes to the ASTUnit to support the VFS? The VFS needs to be created for most/all of the FileManagers that get created, and I’m a bit worried by the sheer number of FileManager and SourceManager creations that I needed to plug up. Ben astunit.patch ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206091 - CodeGen: Test instrumentation based profiling of templates
Author: bogner Date: Fri Apr 11 19:54:06 2014 New Revision: 206091 URL: http://llvm.org/viewvc/llvm-project?rev=206091view=rev Log: CodeGen: Test instrumentation based profiling of templates Make sure that templates are handled correctly by profile instrumentation. Added: cfe/trunk/test/Profile/Inputs/cxx-templates.profdata cfe/trunk/test/Profile/cxx-templates.cpp Added: cfe/trunk/test/Profile/Inputs/cxx-templates.profdata URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/cxx-templates.profdata?rev=206091view=auto == --- cfe/trunk/test/Profile/Inputs/cxx-templates.profdata (added) +++ cfe/trunk/test/Profile/Inputs/cxx-templates.profdata Fri Apr 11 19:54:06 2014 @@ -0,0 +1,17 @@ +main +1 +1 +1 + +_Z4loopILj0EEvv +2 +2 +1 +0 + +_Z4loopILj100EEvv +2 +2 +1 +100 + Added: cfe/trunk/test/Profile/cxx-templates.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-templates.cpp?rev=206091view=auto == --- cfe/trunk/test/Profile/cxx-templates.cpp (added) +++ cfe/trunk/test/Profile/cxx-templates.cpp Fri Apr 11 19:54:06 2014 @@ -0,0 +1,41 @@ +// Tests for instrumentation of templated code. Each instantiation of a template +// should be instrumented separately. + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate %tgen +// RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s +// RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%S/Inputs/cxx-templates.profdata %tuse +// RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s +// RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s + +// T0GEN: @[[T0C:__llvm_profile_counters__Z4loopILj0EEvv]] = linkonce_odr global [2 x i64] zeroinitializer +// T100GEN: @[[T100C:__llvm_profile_counters__Z4loopILj100EEvv]] = linkonce_odr global [2 x i64] zeroinitializer + +// T0GEN-LABEL: define linkonce_odr void @_Z4loopILj0EEvv() +// T0USE-LABEL: define linkonce_odr void @_Z4loopILj0EEvv() +// T100GEN-LABEL: define linkonce_odr void @_Z4loopILj100EEvv() +// T100USE-LABEL: define linkonce_odr void @_Z4loopILj100EEvv() +template unsigned N void loop() { + // ALL-NOT: ret + // T0GEN: store {{.*}} @[[T0C]], i64 0, i64 0 + // T100GEN: store {{.*}} @[[T100C]], i64 0, i64 0 + + // ALL-NOT: ret + // T0GEN: store {{.*}} @[[T0C]], i64 0, i64 1 + // T0USE: br {{.*}} !prof ![[T01:[0-9]+]] + // T100GEN: store {{.*}} @[[T100C]], i64 0, i64 1 + // T100USE: br {{.*}} !prof ![[T1001:[0-9]+]] + for (unsigned I = 0; I N; ++I) {} + + // ALL: ret +} + +// T0USE-DAG: ![[T01]] = metadata !{metadata !branch_weights, i32 1, i32 2} +// T100USE-DAG: ![[T1001]] = metadata !{metadata !branch_weights, i32 101, i32 2} + +int main(int argc, const char *argv[]) { + loop0(); + loop100(); + return 0; +} ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206099 - Add description about the __is_identifier() macro
Author: ygao Date: Fri Apr 11 21:25:32 2014 New Revision: 206099 URL: http://llvm.org/viewvc/llvm-project?rev=206099view=rev Log: Add description about the __is_identifier() macro Modified: cfe/trunk/docs/LanguageExtensions.rst Modified: cfe/trunk/docs/LanguageExtensions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=206099r1=206098r2=206099view=diff == --- cfe/trunk/docs/LanguageExtensions.rst (original) +++ cfe/trunk/docs/LanguageExtensions.rst Fri Apr 11 21:25:32 2014 @@ -134,6 +134,26 @@ The attribute name can also be specified (double underscore) to avoid interference from a macro with the same name. For instance, ``__always_inline__`` can be used instead of ``always_inline``. +``__is_identifier`` +--- + +This function-like macro takes a single identifier argument that might be either +a reserved word or a regular identifier. It evaluates to 1 if the argument is just +a regular identifier and not a reserved word, in the sense that it can then be +used as the name of a user-defined function or variable. Otherwise it evaluates +to 0. It can be used like this: + +.. code-block:: c++ + + ... + #ifdef __is_identifier // Compatibility with non-clang compilers. +#if __is_identifier(__wchar_t) + typedef wchar_t __wchar_t; +#endif + #endif + + __wchar_t WideCharacter; + ... Include File Checking Macros ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
Cool, thanks. -eric On Fri, Apr 11, 2014 at 4:53 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:27 PM, Eric Christopher echri...@gmail.com wrote: On Fri, Apr 11, 2014 at 3:26 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:24 PM, Eric Christopher echri...@gmail.com wrote: So from looking at this it doesn't appear that we have any address range or location information for _GLOBAL__I_a anymore which is exactly what I was worried about: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) versus before: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_decl_file [DW_FORM_data1] (0x03) DW_AT_decl_line [DW_FORM_data1] (0x66) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) DW_AT_low_pc [DW_FORM_addr] (0x0020) DW_AT_high_pc [DW_FORM_data4] (0x000b) DW_AT_frame_base [DW_FORM_exprloc] (0x1 56 ) Now we don't have any note that this code belongs to this compile unit, etc. I think this part is incorrect. We should have scope and line information for this - even if it's line 0 etc. (Though I think the location of the variable would be a better one). Interesting! That was unintentional. I'll fix that. Thanks! Fixed in CFE r206088. 0x00e5: TAG_subprogram [13] AT_MIPS_linkage_name( _GLOBAL__I_a ) AT_artificial( 0x01 ) AT_accessibility( DW_ACCESS_public ) AT_low_pc( 0x03e0 ) AT_high_pc( 0x03eb ) AT_frame_base( rbp ) -- adrian ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206021 - CodeGen: Handle binary conditional operators in PGO instrumentation
Author: bogner Date: Fri Apr 11 01:10:10 2014 New Revision: 206021 URL: http://llvm.org/viewvc/llvm-project?rev=206021view=rev Log: CodeGen: Handle binary conditional operators in PGO instrumentation This treats binary conditional operators in the same way as ternary conditional operators for instrumentation based profiling. Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/test/Profile/Inputs/c-general.profdata cfe/trunk/test/Profile/c-general.c Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206021r1=206020r2=206021view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 01:10:10 2014 @@ -442,7 +442,8 @@ namespace { } /// Assign a counter for the true part of a conditional operator. The /// count in the false part will be calculated from this counter. -void VisitConditionalOperator(const ConditionalOperator *E) { +void VisitAbstractConditionalOperator( +const AbstractConditionalOperator *E) { CounterMap[E] = NextCounter++; Visit(E-getCond()); Visit(E-getTrueExpr()); @@ -768,7 +769,8 @@ namespace { Visit(S-getHandlerBlock()); } -void VisitConditionalOperator(const ConditionalOperator *E) { +void VisitAbstractConditionalOperator( +const AbstractConditionalOperator *E) { RecordStmtCount(E); RegionCounter Cnt(PGO, E); Visit(E-getCond()); Modified: cfe/trunk/test/Profile/Inputs/c-general.profdata URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/c-general.profdata?rev=206021r1=206020r2=206021view=diff == --- cfe/trunk/test/Profile/Inputs/c-general.profdata (original) +++ cfe/trunk/test/Profile/Inputs/c-general.profdata Fri Apr 11 01:10:10 2014 @@ -129,6 +129,13 @@ boolop_loops 50 26 +conditional_operator +3 +3 +1 +0 +1 + do_fallthrough 4 4 Modified: cfe/trunk/test/Profile/c-general.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-general.c?rev=206021r1=206020r2=206021view=diff == --- cfe/trunk/test/Profile/c-general.c (original) +++ cfe/trunk/test/Profile/c-general.c Fri Apr 11 01:10:10 2014 @@ -11,6 +11,7 @@ // PGOGEN: @[[BSC:__llvm_profile_counters_big_switch]] = global [17 x i64] zeroinitializer // PGOGEN: @[[BOC:__llvm_profile_counters_boolean_operators]] = global [8 x i64] zeroinitializer // PGOGEN: @[[BLC:__llvm_profile_counters_boolop_loops]] = global [9 x i64] zeroinitializer +// PGOGEN: @[[COC:__llvm_profile_counters_conditional_operator]] = global [3 x i64] zeroinitializer // PGOGEN: @[[MAC:__llvm_profile_counters_main]] = global [1 x i64] zeroinitializer // PGOGEN: @[[STC:__llvm_profile_counters_static_func]] = internal global [2 x i64] zeroinitializer @@ -412,6 +413,24 @@ void boolop_loops() { // PGOUSE-NOT: br {{.*}} !prof ![0-9]+ } +// PGOGEN-LABEL: @conditional_operator() +// PGOUSE-LABEL: @conditional_operator() +// PGOGEN: store {{.*}} @[[COC]], i64 0, i64 0 +void conditional_operator() { + int i = 100; + + // PGOGEN: store {{.*}} @[[COC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[CO1:[0-9]+]] + int j = i 50 ? i : 1; + + // PGOGEN: store {{.*}} @[[COC]], i64 0, i64 2 + // PGOUSE: br {{.*}} !prof ![[CO2:[0-9]+]] + int k = i ?: 0; + + // PGOGEN-NOT: store {{.*}} @[[COC]], + // PGOUSE-NOT: br {{.*}} !prof ![0-9]+ +} + void do_fallthrough() { for (int i = 0; i 10; ++i) { int j = 0; @@ -503,6 +522,8 @@ static void static_func() { // PGOUSE-DAG: ![[BL6]] = metadata !{metadata !branch_weights, i32 51, i32 2} // PGOUSE-DAG: ![[BL7]] = metadata !{metadata !branch_weights, i32 26, i32 27} // PGOUSE-DAG: ![[BL8]] = metadata !{metadata !branch_weights, i32 51, i32 2} +// PGOUSE-DAG: ![[CO1]] = metadata !{metadata !branch_weights, i32 1, i32 2} +// PGOUSE-DAG: ![[CO2]] = metadata !{metadata !branch_weights, i32 2, i32 1} // PGOUSE-DAG: ![[ST1]] = metadata !{metadata !branch_weights, i32 11, i32 2} int main(int argc, const char *argv[]) { @@ -514,6 +535,7 @@ int main(int argc, const char *argv[]) { big_switch(); boolean_operators(); boolop_loops(); + conditional_operator(); do_fallthrough(); static_func(); return 0; ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[libcxx] r206024 - Remove node from a container before destroying it. Thanks to Alexander Potapenko for pointing this out.
Author: marshall Date: Fri Apr 11 03:22:42 2014 New Revision: 206024 URL: http://llvm.org/viewvc/llvm-project?rev=206024view=rev Log: Remove node from a container before destroying it. Thanks to Alexander Potapenko for pointing this out. Modified: libcxx/trunk/include/__tree Modified: libcxx/trunk/include/__tree URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=206024r1=206023r2=206024view=diff == --- libcxx/trunk/include/__tree (original) +++ libcxx/trunk/include/__tree Fri Apr 11 03:22:42 2014 @@ -1980,9 +1980,9 @@ __tree_Tp, _Compare, _Allocator::erase __begin_node() = __r.__ptr_; --size(); __node_allocator __na = __node_alloc(); -__node_traits::destroy(__na, const_castvalue_type*(_VSTD::addressof(*__p))); __tree_remove(__end_node()-__left_, static_cast__node_base_pointer(__np)); +__node_traits::destroy(__na, const_castvalue_type*(_VSTD::addressof(*__p))); __node_traits::deallocate(__na, __np, 1); return __r; } ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH] Correctly handle escaped newlines when the next token starts without a space.
Hi djasper, We will need this to correctly handle conflict markers inside macro definitions. Currently the tests as written fail directly when inserting a space after the \\\n. http://reviews.llvm.org/D3351 Files: lib/Format/Format.cpp unittests/Format/FormatTest.cpp Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1329,7 +1329,7 @@ // FIXME: Add a more explicit test. while (FormatTok-TokenText.size() 1 FormatTok-TokenText[0] == '\\' FormatTok-TokenText[1] == '\n') { - // FIXME: ++FormatTok-NewlinesBefore is missing... + ++FormatTok-NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok-TokenText = FormatTok-TokenText.substr(2); Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -746,7 +746,7 @@ int a;// This is unrelated\n };)); - EXPECT_EQ(int i; // single line trailing comment, + EXPECT_EQ(int i;\n// single line trailing comment, format(int i;\\\n// single line trailing comment)); verifyGoogleFormat(int a; // Trailing comment.); @@ -931,7 +931,7 @@ TEST_F(FormatTest, UnderstandsBlockComments) { verifyFormat(f(/*noSpaceAfterParameterNamingComment=*/true);); verifyFormat(void f() { g(/*aaa=*/x, /*bbb=*/!y); }); - EXPECT_EQ(f(a, /* Trailing comment for aa... */\n + EXPECT_EQ(f(a,\n /* Trailing comment for aa... */\n b);, format(f(a , \\\n /* Trailing comment for aa... */\n @@ -1057,7 +1057,7 @@ // h i j k, format(// a b c d e f g h i j k, getLLVMStyleWithColumns(10))); - EXPECT_EQ(// a b c d\n + EXPECT_EQ(\n// a b c d\n // e f g\n // h i j k, format(\\\n// a b c d e f g h i j k, @@ -1246,7 +1246,7 @@ */, format(/* a b c d e f g h i j k */, getLLVMStyleWithColumns(10))); - EXPECT_EQ(/* a b c d\n + EXPECT_EQ(\n/* a b c d\n * e f g\n * h i j k\n */, @@ -2462,11 +2462,11 @@ EXPECT_EQ( #define A \\\n int i; \\\n int j;, format(#define A \\\nint i;\\\n int j;, getLLVMStyleWithColumns(11))); - EXPECT_EQ(template class T f();, format(\\\ntemplate class T f();)); + EXPECT_EQ(\ntemplate class T f();, format(\\\ntemplate class T f();)); } TEST_F(FormatTest, NoEscapedNewlineHandlingInBlockComments) { - EXPECT_EQ(/* \\ \\ \\\n*/, format(\\\n/* \\ \\ \\\n*/)); + EXPECT_EQ(\n/* \\ \\ \\\n*/, format(\\\n/* \\ \\ \\\n*/)); } TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) { @@ -6349,7 +6349,7 @@ EXPECT_EQ(\some text \\n \other\;, format(\some text other\;, getLLVMStyleWithColumns(12))); - EXPECT_EQ(\some text \\n + EXPECT_EQ(\n\some text \\n \other\;, format(\\\n\some text other\;, getLLVMStyleWithColumns(12))); EXPECT_EQ( Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1329,7 +1329,7 @@ // FIXME: Add a more explicit test. while (FormatTok-TokenText.size() 1 FormatTok-TokenText[0] == '\\' FormatTok-TokenText[1] == '\n') { - // FIXME: ++FormatTok-NewlinesBefore is missing... + ++FormatTok-NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok-TokenText = FormatTok-TokenText.substr(2); Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -746,7 +746,7 @@ int a;// This is unrelated\n };)); - EXPECT_EQ(int i; // single line trailing comment, + EXPECT_EQ(int i;\n// single line trailing comment, format(int i;\\\n// single line trailing comment)); verifyGoogleFormat(int a; // Trailing comment.); @@ -931,7 +931,7 @@ TEST_F(FormatTest, UnderstandsBlockComments) { verifyFormat(f(/*noSpaceAfterParameterNamingComment=*/true);); verifyFormat(void f() { g(/*aaa=*/x, /*bbb=*/!y); }); - EXPECT_EQ(f(a, /* Trailing comment for aa... */\n + EXPECT_EQ(f(a,\n /* Trailing comment for aa... */\n b);, format(f(a , \\\n /* Trailing comment for aa... */\n @@ -1057,7 +1057,7 @@ // h i j k, format(// a b c d e f g h i j k, getLLVMStyleWithColumns(10))); - EXPECT_EQ(// a b c d\n +
Re: [PATCH] Correctly handle escaped newlines when the next token starts without a space.
I am generally fine with this, as it seems irrelevant in practice. It seems weird, however, to replace an escaped newline with a newline. Comment at: unittests/Format/FormatTest.cpp:749-750 @@ -748,4 +748,4 @@ - EXPECT_EQ(int i; // single line trailing comment, + EXPECT_EQ(int i;\n// single line trailing comment, format(int i;\\\n// single line trailing comment)); I find these tests easier to read if the strings are split after each \n. Also, while I don't see a practical use here, I don't think simply removing the escaped newline is the right thing to do here. What other purpose can it have, other than being a notion of the following comment is bound to this? But if implementing that is extra effort, I don't care. Comment at: unittests/Format/FormatTest.cpp:934 @@ -933,3 +933,3 @@ verifyFormat(void f() { g(/*aaa=*/x, /*bbb=*/!y); }); - EXPECT_EQ(f(a, /* Trailing comment for aa... */\n + EXPECT_EQ(f(a,\n /* Trailing comment for aa... */\n b);, Same here. I think here it is even worse as the test makes no sense whatsoever unless we also change the content of the comment. If we decided to keep this, maybe we should just remove/replace these tests? http://reviews.llvm.org/D3351 BRANCH fix-newlines ARCANIST PROJECT clang ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206027 - Add -fmodules-strict-decluse to check that all headers are in modules
Author: djasper Date: Fri Apr 11 06:47:45 2014 New Revision: 206027 URL: http://llvm.org/viewvc/llvm-project?rev=206027view=rev Log: Add -fmodules-strict-decluse to check that all headers are in modules Review: http://reviews.llvm.org/D3335 Added: cfe/trunk/test/Modules/strict-decluse.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Lex/ModuleMap.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=206027r1=206026r2=206027view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Apr 11 06:47:45 2014 @@ -96,6 +96,7 @@ LANGOPT(MathErrno , 1, 1, errno BENIGN_LANGOPT(HeinousExtensions , 1, 0, Extensions that we really don't like and may be ripped out at any time) LANGOPT(Modules , 1, 0, modules extension to C) LANGOPT(ModulesDeclUse, 1, 0, require declaration of module uses) +LANGOPT(ModulesStrictDeclUse, 1, 0, require declaration of module uses and all headers to be in modules) LANGOPT(Optimize , 1, 0, __OPTIMIZE__ predefined macro) LANGOPT(OptimizeSize , 1, 0, __OPTIMIZE_SIZE__ predefined macro) LANGOPT(Static, 1, 0, __STATIC__ predefined macro (as opposed to __DYNAMIC__)) Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=206027r1=206026r2=206027view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 11 06:47:45 2014 @@ -607,6 +607,9 @@ def fmodules_ignore_macro : Joined[-] def fmodules_decluse : Flag [-], fmodules-decluse, Groupf_Group, Flags[DriverOption,CC1Option], HelpTextRequire declaration of modules used within a module; +def fmodules_strict_decluse : Flag [-], fmodules-strict-decluse, Groupf_Group, + Flags[DriverOption,CC1Option], + HelpTextLike -fmodules-decluse but requires all headers to be in modules; def fretain_comments_from_system_headers : Flag[-], fretain-comments-from-system-headers, Groupf_Group, Flags[CC1Option]; def fmudflapth : Flag[-], fmudflapth, Groupf_Group; @@ -666,6 +669,8 @@ def fno_module_maps : Flag [-], fno- Flags[DriverOption]; def fno_modules_decluse : Flag [-], fno-modules-decluse, Groupf_Group, Flags[DriverOption]; +def fno_modules_strict_decluse : Flag [-], fno-strict-modules-decluse, Groupf_Group, + Flags[DriverOption]; def fno_ms_extensions : Flag[-], fno-ms-extensions, Groupf_Group; def fno_ms_compatibility : Flag[-], fno-ms-compatibility, Groupf_Group; def fno_delayed_template_parsing : Flag[-], fno-delayed-template-parsing, Groupf_Group; Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=206027r1=206026r2=206027view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr 11 06:47:45 2014 @@ -3469,6 +3469,14 @@ void Clang::ConstructJob(Compilation C, CmdArgs.push_back(-fmodules-decluse); } + // -fmodules-strict-decluse is like -fmodule-decluse, but also checks that + // all #included headers are part of modules. + if (Args.hasFlag(options::OPT_fmodules_strict_decluse, + options::OPT_fno_modules_strict_decluse, + false)) { +CmdArgs.push_back(-fmodules-strict-decluse); + } + // -fmodule-name specifies the module that is currently being built (or // used for header checking by -fmodule-maps). if (Arg *A = Args.getLastArg(options::OPT_fmodule_name)) { Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=206027r1=206026r2=206027view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Apr 11 06:47:45 2014 @@ -1343,7 +1343,9 @@ static void ParseLangArgs(LangOptions O Opts.Blocks = Args.hasArg(OPT_fblocks); Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional); Opts.Modules = Args.hasArg(OPT_fmodules); - Opts.ModulesDeclUse = Args.hasArg(OPT_fmodules_decluse); + Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse); + Opts.ModulesDeclUse = + Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse; Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); Opts.WChar = Opts.CPlusPlus
[PATCH] [Headers] Improve codegen for _mm_slli_epi32.
Hi dblaikie, This generates vector llvm ir for _mm_slli_epi32 to allow further optimization. http://reviews.llvm.org/D3353 Files: lib/Headers/emmintrin.h Index: lib/Headers/emmintrin.h === --- lib/Headers/emmintrin.h +++ lib/Headers/emmintrin.h @@ -846,7 +846,7 @@ static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) _mm_slli_epi32(__m128i __a, int __count) { - return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count); + return (__m128i)((__v4si)__a (__v4si){__count, __count, __count, __count}); } static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) Index: lib/Headers/emmintrin.h === --- lib/Headers/emmintrin.h +++ lib/Headers/emmintrin.h @@ -846,7 +846,7 @@ static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) _mm_slli_epi32(__m128i __a, int __count) { - return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count); + return (__m128i)((__v4si)__a (__v4si){__count, __count, __count, __count}); } static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH][cxxabi] function declaration not under __APPLE__ define
Hi, I've been working on porting libc++ and libc++abi to Bitrig. While there I've found a few things. This diff fixes a bug where there's a function declarataion, although the prototype is under __APPLE__, so !__APPLE__ compile will fail. \Patrick From 8924d2c5b8bd6d6c264fe7f5348bb8818e8ce3c9 Mon Sep 17 00:00:00 2001 From: Patrick Wildt patr...@blueri.se Date: Thu, 10 Apr 2014 17:14:22 +0200 Subject: [PATCH] This should be in __APPLE__, else compile fails. --- src/Unwind/UnwindCursor.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Unwind/UnwindCursor.hpp b/src/Unwind/UnwindCursor.hpp index 235922f..aa14dd1 100644 --- a/src/Unwind/UnwindCursor.hpp +++ b/src/Unwind/UnwindCursor.hpp @@ -151,10 +151,12 @@ void DwarfFDECacheA::removeAllIn(pint_t mh) { _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(_lock)); } +#if __APPLE__ template typename A void DwarfFDECacheA::dyldUnloadHook(const struct mach_header *mh, intptr_t ) { removeAllIn((pint_t) mh); } +#endif template typename A void DwarfFDECacheA::iterateCacheEntries(void (*func)( -- 1.8.5.2 (Apple Git-48) ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Add -fmodules-strict-decluse to check that all headers are in modules
Submitted as r206027. http://reviews.llvm.org/D3335 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH][cxxabi] correctly handle omit encoding
Hi, getEncodedP() should properly handle the omit encoding and return zero. \Patrick From 37c72b3bcb69c9d127011d6b0756f577d0c4166d Mon Sep 17 00:00:00 2001 From: Patrick Wildt patr...@blueri.se Date: Fri, 11 Apr 2014 14:10:55 +0200 Subject: [PATCH] If the encoding is set to omit, it should be handled properly. --- src/Unwind/AddressSpace.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Unwind/AddressSpace.hpp b/src/Unwind/AddressSpace.hpp index aac8b7f..51bd3e9 100644 --- a/src/Unwind/AddressSpace.hpp +++ b/src/Unwind/AddressSpace.hpp @@ -167,6 +167,9 @@ inline LocalAddressSpace::pint_t LocalAddressSpace::getEncodedP(pint_t addr, const uint8_t *p = (uint8_t *)addr; pint_t result; + if (encoding == DW_EH_PE_omit) +return 0; + // first get value switch (encoding 0x0F) { case DW_EH_PE_ptr: -- 1.8.5.2 (Apple Git-48) ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH][cxxabi] Properly sign-extend encoded sdata.
Hi, In the case of sdata, the returned number has to be properly sign extended, otherwise subtractions don't work. In sdata8, the result might have to be casted to sint_t instead of pint_t to be visually correct. It probably doesn't do any harm as it is now. \Patrick From d802fee6f399cf1f5f767b1fd78f07a555b77eef Mon Sep 17 00:00:00 2001 From: Patrick Wildt patr...@blueri.se Date: Fri, 11 Apr 2014 14:17:40 +0200 Subject: [PATCH] Properly sign extend sdata. --- src/Unwind/AddressSpace.hpp | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Unwind/AddressSpace.hpp b/src/Unwind/AddressSpace.hpp index aac8b7f..ce95459 100644 --- a/src/Unwind/AddressSpace.hpp +++ b/src/Unwind/AddressSpace.hpp @@ -196,12 +196,14 @@ inline LocalAddressSpace::pint_t LocalAddressSpace::getEncodedP(pint_t addr, result = (pint_t)getSLEB128(addr, end); break; case DW_EH_PE_sdata2: -result = (uint16_t)get16(addr); +/* signed so that it extends negative numbers */ +result = (int16_t)get16(addr); p += 2; addr = (pint_t) p; break; case DW_EH_PE_sdata4: -result = (uint32_t)get32(addr); +/* signed so that it extends negative numbers */ +result = (int32_t)get32(addr); p += 4; addr = (pint_t) p; break; -- 1.8.5.2 (Apple Git-48) ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Correctly handle escaped newlines when the next token starts without a space.
Now without changes to the tests... Hi djasper, http://reviews.llvm.org/D3351 CHANGE SINCE LAST DIFF http://reviews.llvm.org/D3351?vs=8472id=8476#toc BRANCH fix-newlines ARCANIST PROJECT clang Files: lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/UnwrappedLineParser.h Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -913,6 +913,8 @@ Newlines = std::min(Newlines, 1u); if (Newlines == 0 !RootToken.IsFirst) Newlines = 1; +if (RootToken.IsFirst !RootToken.HasUnescapedNewline) + Newlines = 0; // Remove empty lines after {. if (!Style.KeepEmptyLinesAtTheStartOfBlocks PreviousLine @@ -1329,7 +1331,7 @@ // FIXME: Add a more explicit test. while (FormatTok-TokenText.size() 1 FormatTok-TokenText[0] == '\\' FormatTok-TokenText[1] == '\n') { - // FIXME: ++FormatTok-NewlinesBefore is missing... + ++FormatTok-NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok-TokenText = FormatTok-TokenText.substr(2); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1511,7 +1511,7 @@ if (Right.is(tok::comment)) { return Right.Previous-BlockKind != BK_BracedInit Right.Previous-Type != TT_CtorInitializerColon - Right.NewlinesBefore 0; + (Right.NewlinesBefore 0 Right.HasUnescapedNewline); } else if (Right.Previous-isTrailingComment() || (Right.isStringLiteral() Right.Previous-isStringLiteral())) { return true; Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1358,13 +1358,18 @@ bool UnwrappedLineParser::eof() const { return FormatTok-Tok.is(tok::eof); } +bool UnwrappedLineParser::isOnNewLine(const FormatToken FormatTok) { + return (Line-InPPDirective || FormatTok.HasUnescapedNewline) + FormatTok.NewlinesBefore 0; +} + void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) { bool JustComments = Line-Tokens.empty(); for (SmallVectorImplFormatToken *::const_iterator I = CommentsBeforeNextToken.begin(), E = CommentsBeforeNextToken.end(); I != E; ++I) { -if ((*I)-NewlinesBefore JustComments) { +if (isOnNewLine(**I) JustComments) { addUnwrappedLine(); } pushToken(*I); @@ -1378,7 +1383,7 @@ void UnwrappedLineParser::nextToken() { if (eof()) return; - flushComments(FormatTok-NewlinesBefore 0); + flushComments(isOnNewLine(*FormatTok)); pushToken(FormatTok); readToken(); } @@ -1398,7 +1403,7 @@ // Comments stored before the preprocessor directive need to be output // before the preprocessor directive, at the same level as the // preprocessor directive, as we consider them to apply to the directive. - flushComments(FormatTok-NewlinesBefore 0); + flushComments(isOnNewLine(*FormatTok)); parsePPDirective(); } @@ -1409,7 +1414,7 @@ if (!FormatTok-Tok.is(tok::comment)) return; -if (FormatTok-NewlinesBefore 0 || FormatTok-IsFirst) { +if (isOnNewLine(*FormatTok) || FormatTok-IsFirst) { CommentsInCurrentLine = false; } if (CommentsInCurrentLine) { Index: lib/Format/UnwrappedLineParser.h === --- lib/Format/UnwrappedLineParser.h +++ lib/Format/UnwrappedLineParser.h @@ -108,6 +108,7 @@ void pushToken(FormatToken *Tok); void calculateBraceTypes(); void pushPPConditional(); + bool isOnNewLine(const FormatToken FormatTok); // FIXME: We are constantly running into bugs where Line.Level is incorrectly // subtracted from beyond 0. Introduce a method to subtract from Line.Level Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -913,6 +913,8 @@ Newlines = std::min(Newlines, 1u); if (Newlines == 0 !RootToken.IsFirst) Newlines = 1; +if (RootToken.IsFirst !RootToken.HasUnescapedNewline) + Newlines = 0; // Remove empty lines after {. if (!Style.KeepEmptyLinesAtTheStartOfBlocks PreviousLine @@ -1329,7 +1331,7 @@ // FIXME: Add a more explicit test. while (FormatTok-TokenText.size() 1 FormatTok-TokenText[0] == '\\' FormatTok-TokenText[1] == '\n') { - // FIXME: ++FormatTok-NewlinesBefore is missing... + ++FormatTok-NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok-TokenText = FormatTok-TokenText.substr(2); Index: lib/Format/TokenAnnotator.cpp
r206029 - Correctly handle escaped newlines when the next token starts without a space.
Author: klimek Date: Fri Apr 11 07:27:47 2014 New Revision: 206029 URL: http://llvm.org/viewvc/llvm-project?rev=206029view=rev Log: Correctly handle escaped newlines when the next token starts without a space. We will need this to correctly handle conflict markers inside macro definitions. Modified: cfe/trunk/lib/Format/Format.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/lib/Format/UnwrappedLineParser.h Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=206029r1=206028r2=206029view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Fri Apr 11 07:27:47 2014 @@ -913,6 +913,8 @@ private: Newlines = std::min(Newlines, 1u); if (Newlines == 0 !RootToken.IsFirst) Newlines = 1; +if (RootToken.IsFirst !RootToken.HasUnescapedNewline) + Newlines = 0; // Remove empty lines after {. if (!Style.KeepEmptyLinesAtTheStartOfBlocks PreviousLine @@ -1329,7 +1331,7 @@ private: // FIXME: Add a more explicit test. while (FormatTok-TokenText.size() 1 FormatTok-TokenText[0] == '\\' FormatTok-TokenText[1] == '\n') { - // FIXME: ++FormatTok-NewlinesBefore is missing... + ++FormatTok-NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok-TokenText = FormatTok-TokenText.substr(2); Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=206029r1=206028r2=206029view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Apr 11 07:27:47 2014 @@ -1511,7 +1511,7 @@ bool TokenAnnotator::mustBreakBefore(con if (Right.is(tok::comment)) { return Right.Previous-BlockKind != BK_BracedInit Right.Previous-Type != TT_CtorInitializerColon - Right.NewlinesBefore 0; + (Right.NewlinesBefore 0 Right.HasUnescapedNewline); } else if (Right.Previous-isTrailingComment() || (Right.isStringLiteral() Right.Previous-isStringLiteral())) { return true; Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=206029r1=206028r2=206029view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Apr 11 07:27:47 2014 @@ -1358,13 +1358,18 @@ void UnwrappedLineParser::addUnwrappedLi bool UnwrappedLineParser::eof() const { return FormatTok-Tok.is(tok::eof); } +bool UnwrappedLineParser::isOnNewLine(const FormatToken FormatTok) { + return (Line-InPPDirective || FormatTok.HasUnescapedNewline) + FormatTok.NewlinesBefore 0; +} + void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) { bool JustComments = Line-Tokens.empty(); for (SmallVectorImplFormatToken *::const_iterator I = CommentsBeforeNextToken.begin(), E = CommentsBeforeNextToken.end(); I != E; ++I) { -if ((*I)-NewlinesBefore JustComments) { +if (isOnNewLine(**I) JustComments) { addUnwrappedLine(); } pushToken(*I); @@ -1378,7 +1383,7 @@ void UnwrappedLineParser::flushComments( void UnwrappedLineParser::nextToken() { if (eof()) return; - flushComments(FormatTok-NewlinesBefore 0); + flushComments(isOnNewLine(*FormatTok)); pushToken(FormatTok); readToken(); } @@ -1398,7 +1403,7 @@ void UnwrappedLineParser::readToken() { // Comments stored before the preprocessor directive need to be output // before the preprocessor directive, at the same level as the // preprocessor directive, as we consider them to apply to the directive. - flushComments(FormatTok-NewlinesBefore 0); + flushComments(isOnNewLine(*FormatTok)); parsePPDirective(); } @@ -1409,7 +1414,7 @@ void UnwrappedLineParser::readToken() { if (!FormatTok-Tok.is(tok::comment)) return; -if (FormatTok-NewlinesBefore 0 || FormatTok-IsFirst) { +if (isOnNewLine(*FormatTok) || FormatTok-IsFirst) { CommentsInCurrentLine = false; } if (CommentsInCurrentLine) { Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=206029r1=206028r2=206029view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.h (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.h Fri Apr 11 07:27:47 2014 @@ -108,6 +108,7 @@ private: void pushToken(FormatToken *Tok); void
Re: [PATCH] [Headers] Improve codegen for _mm_slli_epi32.
Actually, this is wrong. _mm_slli_epi32 requires that if count is than 31, the result is 0. The operator gives it undefined behavior. http://reviews.llvm.org/D3353 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH] Format code around VCS conflict markers.
Hi djasper, http://reviews.llvm.org/D3355 Files: lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/UnwrappedLineParser.cpp lib/Format/UnwrappedLineParser.h unittests/Format/FormatTest.cpp Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1157,7 +1157,8 @@ encoding::Encoding Encoding) : FormatTok(NULL), IsFirstToken(true), GreaterStashed(false), Column(0), TrailingWhitespace(0), Lex(Lex), SourceMgr(SourceMgr), Style(Style), -IdentTable(getFormattingLangOpts()), Encoding(Encoding) { +IdentTable(getFormattingLangOpts()), Encoding(Encoding), +FirstInLineIndex(0) { Lex.SetKeepWhitespaceMode(true); for (const std::string ForEachMacro : Style.ForEachMacros) @@ -1167,9 +1168,12 @@ ArrayRefFormatToken * lex() { assert(Tokens.empty()); +assert(FirstInLineIndex == 0); do { Tokens.push_back(getNextToken()); tryMergePreviousTokens(); + if (Tokens.back()-NewlinesBefore 0) +FirstInLineIndex = Tokens.size() - 1; } while (Tokens.back()-Tok.isNot(tok::eof)); return Tokens; } @@ -1180,6 +1184,8 @@ void tryMergePreviousTokens() { if (tryMerge_TMacro()) return; +if (tryMergeConflictMarkers()) + return; if (Style.Language == FormatStyle::LK_JavaScript) { static tok::TokenKind JSIdentity[] = { tok::equalequal, tok::equal }; @@ -1254,6 +1260,63 @@ return true; } + bool tryMergeConflictMarkers() { +if (Tokens.back()-NewlinesBefore == 0 Tokens.back()-isNot(tok::eof)) + return false; + +FileID ID; +unsigned offset; +std::tie(ID, offset) = SourceMgr.getDecomposedLoc( +Tokens[FirstInLineIndex]-getStartOfNonWhitespace()); +StringRef Buffer = SourceMgr.getBuffer(ID)-getBuffer(); +auto LineOffset = Buffer.rfind('\n', offset); +if (LineOffset == StringRef::npos) { + LineOffset = 0; +} else { + ++LineOffset; +} + +// We only look at the first 8 characters of the line, as the longest +// markers are 7 characters long. +StringRef Line = Buffer.substr(LineOffset, 8); + +// Git markers are 7 characters long - either the line ends afterwards, or +// we expect a space. +bool GitMarkerSize = Line.size() = 7 || Line[7] == ' ' || Line[7] == '\n'; +// Perforce markers are 4 characters long. +bool PerforceMarkerSize = +Line.size() = 4 || Line[4] == ' ' || Line[4] == '\n'; + +TokenType Type = TT_Unknown; +if ((GitMarkerSize Line.startswith()) || +(PerforceMarkerSize Line.startswith())) { + Type = TT_ConflictStart; +} else if ((GitMarkerSize +(Line.startswith(|||) || Line.startswith(===))) || + (PerforceMarkerSize Line.startswith())) { + Type = TT_ConflictAlternative; +} else if ((GitMarkerSize Line.startswith()) || + (PerforceMarkerSize Line.startswith())) { + Type = TT_ConflictEnd; +} + +if (Type != TT_Unknown) { + FormatToken *Next = Tokens.back(); + + Tokens.resize(FirstInLineIndex + 1); + // We do not need to build a complete token here, as we will skip it + // during parsing anyway (as we must not touch whitespace around conflict + // markers). + Tokens.back()-Type = Type; + Tokens.back()-Tok.setKind(tok::kw___unknown_anytype); + + Tokens.push_back(Next); + return true; +} + +return false; + } + FormatToken *getNextToken() { if (GreaterStashed) { // Create a synthesized second '' token. @@ -1389,7 +1452,6 @@ return FormatTok; } - FormatToken *FormatTok; bool IsFirstToken; bool GreaterStashed; @@ -1401,6 +1463,8 @@ IdentifierTable IdentTable; encoding::Encoding Encoding; llvm::SpecificBumpPtrAllocatorFormatToken Allocator; + // Index of the last token that starts a new line in 'Tokens'. + unsigned FirstInLineIndex; SmallVectorFormatToken *, 16 Tokens; SmallVectorIdentifierInfo*, 8 ForEachMacros; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -64,6 +64,9 @@ TT_TrailingReturnArrow, TT_TrailingUnaryOperator, TT_UnaryOperator, + TT_ConflictStart, + TT_ConflictAlternative, + TT_ConflictEnd, TT_Unknown }; Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -465,52 +465,37 @@ } } -void UnwrappedLineParser::pushPPConditional() { - if (!PPStack.empty() PPStack.back() == PP_Unreachable) -PPStack.push_back(PP_Unreachable); - else -PPStack.push_back(PP_Conditional); -} - -void UnwrappedLineParser::parsePPIf(bool IfDef) { +void
Re: [PATCH] Format code around VCS conflict markers.
Looks good. Comment at: lib/Format/Format.cpp:1285 @@ +1284,3 @@ +// we expect a space. +bool GitMarkerSize = Line.size() = 7 || Line[7] == ' ' || Line[7] == '\n'; +// Perforce markers are 4 characters long. ..Size is not a good name for a bool. Here and below. Just remove Size? Comment at: lib/Format/Format.cpp:1272 @@ +1271,3 @@ +StringRef Buffer = SourceMgr.getBuffer(ID)-getBuffer(); +auto LineOffset = Buffer.rfind('\n', offset); +if (LineOffset == StringRef::npos) { LineOffset carries very little meaning, or at least I can't understand what it means without carefully looking at the code. Maybe add a comment. Comment at: lib/Format/Format.cpp:1268 @@ +1267,3 @@ +FileID ID; +unsigned offset; +std::tie(ID, offset) = SourceMgr.getDecomposedLoc( s/offset/Offset/ Also, offset of what? Consider adding a comment or using a more specific name. Comment at: lib/Format/Format.cpp:1392 @@ -1391,3 +1454,2 @@ } - FormatToken *FormatTok; I liked this empty line. Comment at: lib/Format/Format.cpp:1467 @@ -1404,1 +1466,3 @@ + // Index of the last token that starts a new line in 'Tokens'. + unsigned FirstInLineIndex; SmallVectorFormatToken *, 16 Tokens; Just to make this even clearer: // Index (in 'Tokens') of the last token that starts a new line. Comment at: lib/Format/FormatToken.h:67 @@ -66,1 +66,3 @@ TT_UnaryOperator, + TT_ConflictStart, + TT_ConflictAlternative, While this order makes sense, I think we should keep this alphabetical. Comment at: lib/Format/UnwrappedLineParser.cpp:468 @@ -467,10 +467,3 @@ -void UnwrappedLineParser::pushPPConditional() { - if (!PPStack.empty() PPStack.back() == PP_Unreachable) -PPStack.push_back(PP_Unreachable); - else -PPStack.push_back(PP_Conditional); -} - -void UnwrappedLineParser::parsePPIf(bool IfDef) { +void UnwrappedLineParser::conditionalCompilationStart(bool Unreachable) { ++PPBranchLevel; I think Unreachable needs some explanation... Comment at: unittests/Format/FormatTest.cpp:15 @@ -14,2 +14,3 @@ #include llvm/Support/Debug.h +#include llvm/ADT/Twine.h #include gtest/gtest.h Remove? Comment at: lib/Format/UnwrappedLineParser.cpp:1418-1431 @@ +1417,16 @@ + FormatTok-Type == TT_ConflictAlternative) { + switch (FormatTok-Type) { + case TT_ConflictStart: +conditionalCompilationStart(/*Unreachable=*/false); +break; + case TT_ConflictAlternative: +conditionalCompilationAlternative(); +break; + case TT_ConflictEnd: +conditionalCompilationEnd(); +break; + default: +llvm_unreachable(Unexpected token type.); +break; + } + FormatTok = Tokens-getNextToken(); This would be just 6 lines with if () .. Comment at: lib/Format/Format.cpp:1307-1309 @@ +1306,5 @@ + Tokens.resize(FirstInLineIndex + 1); + // We do not need to build a complete token here, as we will skip it + // during parsing anyway (as we must not touch whitespace around conflict + // markers). + Tokens.back()-Type = Type; I think a comment here would help what an expected conflict line together with the generated tokens would look like. Possibly here or at the start of the function. http://reviews.llvm.org/D3355 BRANCH implement-conflict-markers ARCANIST PROJECT clang ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Format code around VCS conflict markers.
Applied review comments. Hi djasper, http://reviews.llvm.org/D3355 CHANGE SINCE LAST DIFF http://reviews.llvm.org/D3355?vs=8477id=8478#toc BRANCH implement-conflict-markers ARCANIST PROJECT clang Files: lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/UnwrappedLineParser.cpp lib/Format/UnwrappedLineParser.h unittests/Format/FormatTest.cpp Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1157,7 +1157,8 @@ encoding::Encoding Encoding) : FormatTok(NULL), IsFirstToken(true), GreaterStashed(false), Column(0), TrailingWhitespace(0), Lex(Lex), SourceMgr(SourceMgr), Style(Style), -IdentTable(getFormattingLangOpts()), Encoding(Encoding) { +IdentTable(getFormattingLangOpts()), Encoding(Encoding), +FirstInLineIndex(0) { Lex.SetKeepWhitespaceMode(true); for (const std::string ForEachMacro : Style.ForEachMacros) @@ -1167,9 +1168,12 @@ ArrayRefFormatToken * lex() { assert(Tokens.empty()); +assert(FirstInLineIndex == 0); do { Tokens.push_back(getNextToken()); tryMergePreviousTokens(); + if (Tokens.back()-NewlinesBefore 0) +FirstInLineIndex = Tokens.size() - 1; } while (Tokens.back()-Tok.isNot(tok::eof)); return Tokens; } @@ -1180,6 +1184,8 @@ void tryMergePreviousTokens() { if (tryMerge_TMacro()) return; +if (tryMergeConflictMarkers()) + return; if (Style.Language == FormatStyle::LK_JavaScript) { static tok::TokenKind JSIdentity[] = { tok::equalequal, tok::equal }; @@ -1254,6 +1260,68 @@ return true; } + bool tryMergeConflictMarkers() { +if (Tokens.back()-NewlinesBefore == 0 Tokens.back()-isNot(tok::eof)) + return false; + +// Conflict lines look like: +// marker text from the vcs +// For example: +// /file/in/file/system at revision 1234 +// +// We merge all tokens in a line that starts with a conflict marker +// into a single token with a special token type that the unwrapped line +// parser will use to correctly rebuild the underlying code. + +FileID ID; +// Get the position of the first token in the line. +unsigned FirstInLineOffset; +std::tie(ID, FirstInLineOffset) = SourceMgr.getDecomposedLoc( +Tokens[FirstInLineIndex]-getStartOfNonWhitespace()); +StringRef Buffer = SourceMgr.getBuffer(ID)-getBuffer(); +// Calculate the offset of the start of the current line. +auto LineOffset = Buffer.rfind('\n', FirstInLineOffset); +if (LineOffset == StringRef::npos) { + LineOffset = 0; +} else { + ++LineOffset; +} + +auto FirstSpace = Buffer.find_first_of( \n, LineOffset); +StringRef LineStart; +if (FirstSpace == StringRef::npos) { + LineStart = Buffer.substr(LineOffset); +} else { + LineStart = Buffer.substr(LineOffset, FirstSpace - LineOffset); +} + +TokenType Type = TT_Unknown; +if (LineStart == || LineStart == ) { + Type = TT_ConflictStart; +} else if (LineStart == ||| || LineStart == === || + LineStart == ) { + Type = TT_ConflictAlternative; +} else if (LineStart == || LineStart == ) { + Type = TT_ConflictEnd; +} + +if (Type != TT_Unknown) { + FormatToken *Next = Tokens.back(); + + Tokens.resize(FirstInLineIndex + 1); + // We do not need to build a complete token here, as we will skip it + // during parsing anyway (as we must not touch whitespace around conflict + // markers). + Tokens.back()-Type = Type; + Tokens.back()-Tok.setKind(tok::kw___unknown_anytype); + + Tokens.push_back(Next); + return true; +} + +return false; + } + FormatToken *getNextToken() { if (GreaterStashed) { // Create a synthesized second '' token. @@ -1401,6 +1469,8 @@ IdentifierTable IdentTable; encoding::Encoding Encoding; llvm::SpecificBumpPtrAllocatorFormatToken Allocator; + // Index (in 'Tokens') of the last token that starts a new line. + unsigned FirstInLineIndex; SmallVectorFormatToken *, 16 Tokens; SmallVectorIdentifierInfo*, 8 ForEachMacros; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -33,19 +33,22 @@ TT_BlockComment, TT_CastRParen, TT_ConditionalExpr, + TT_ConflictAlternative, + TT_ConflictEnd, + TT_ConflictStart, TT_CtorInitializerColon, TT_CtorInitializerComma, TT_DesignatedInitializerPeriod, TT_DictLiteral, - TT_ImplicitStringLiteral, - TT_InlineASMColon, - TT_InheritanceColon, TT_FunctionLBrace, TT_FunctionTypeLParen, + TT_ImplicitStringLiteral, + TT_InheritanceColon, + TT_InlineASMColon, TT_LambdaLSquare, TT_LineComment, - TT_ObjCBlockLParen, TT_ObjCBlockLBrace, +
Re: [PATCH] [Headers] Improve codegen for _mm_slli_epi32.
This isn't really in my area of expertise/ownership, so I'll leave it to someone else to review. http://reviews.llvm.org/D3353 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206038 - Simplify RecordLayoutBuilder with getAsCXXRecordDecl()
Author: rnk Date: Fri Apr 11 11:57:42 2014 New Revision: 206038 URL: http://llvm.org/viewvc/llvm-project?rev=206038view=rev Log: Simplify RecordLayoutBuilder with getAsCXXRecordDecl() No functionality change. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206038r1=206037r2=206038view=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 11:57:42 2014 @@ -141,8 +141,7 @@ public: void EmptySubobjectMap::ComputeEmptySubobjectSizes() { // Check the bases. for (const auto I : Class-bases()) { -const CXXRecordDecl *BaseDecl = - castCXXRecordDecl(I.getType()-getAsRecordType()-getDecl()); +const CXXRecordDecl *BaseDecl = I.getType()-getAsCXXRecordDecl(); CharUnits EmptySize; const ASTRecordLayout Layout = Context.getASTRecordLayout(BaseDecl); @@ -168,7 +167,7 @@ void EmptySubobjectMap::ComputeEmptySubo continue; CharUnits EmptySize; -const CXXRecordDecl *MemberDecl = castCXXRecordDecl(RT-getDecl()); +const CXXRecordDecl *MemberDecl = RT-getAsCXXRecordDecl(); const ASTRecordLayout Layout = Context.getASTRecordLayout(MemberDecl); if (MemberDecl-isEmpty()) { // If the class decl is empty, get its size. @@ -349,8 +348,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjec if (I.isVirtual()) continue; -const CXXRecordDecl *BaseDecl = - castCXXRecordDecl(I.getType()-getAsRecordType()-getDecl()); +const CXXRecordDecl *BaseDecl = I.getType()-getAsCXXRecordDecl(); CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(BaseDecl); if (!CanPlaceFieldSubobjectAtOffset(BaseDecl, Class, BaseOffset)) @@ -360,9 +358,8 @@ EmptySubobjectMap::CanPlaceFieldSubobjec if (RD == Class) { // This is the most derived class, traverse virtual bases as well. for (const auto I : RD-vbases()) { - const CXXRecordDecl *VBaseDecl = -castCXXRecordDecl(I.getType()-getAsRecordType()-getDecl()); - + const CXXRecordDecl *VBaseDecl = I.getType()-getAsCXXRecordDecl(); + CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBaseDecl); if (!CanPlaceFieldSubobjectAtOffset(VBaseDecl, Class, VBaseOffset)) return false; @@ -394,10 +391,8 @@ EmptySubobjectMap::CanPlaceFieldSubobjec return true; QualType T = FD-getType(); - if (const RecordType *RT = T-getAsRecordType()) { -const CXXRecordDecl *RD = castCXXRecordDecl(RT-getDecl()); + if (const CXXRecordDecl *RD = T-getAsCXXRecordDecl()) return CanPlaceFieldSubobjectAtOffset(RD, RD, Offset); - } // If we have an array type we need to look at every element. if (const ConstantArrayType *AT = Context.getAsConstantArrayType(T)) { @@ -405,8 +400,8 @@ EmptySubobjectMap::CanPlaceFieldSubobjec const RecordType *RT = ElemTy-getAsRecordType(); if (!RT) return true; - -const CXXRecordDecl *RD = castCXXRecordDecl(RT-getDecl()); + +const CXXRecordDecl *RD = RT-getAsCXXRecordDecl(); const ASTRecordLayout Layout = Context.getASTRecordLayout(RD); uint64_t NumElements = Context.getConstantArrayElementCount(AT); @@ -459,8 +454,7 @@ void EmptySubobjectMap::UpdateEmptyField if (I.isVirtual()) continue; -const CXXRecordDecl *BaseDecl = - castCXXRecordDecl(I.getType()-getAsRecordType()-getDecl()); +const CXXRecordDecl *BaseDecl = I.getType()-getAsCXXRecordDecl(); CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(BaseDecl); UpdateEmptyFieldSubobjects(BaseDecl, Class, BaseOffset); @@ -469,9 +463,8 @@ void EmptySubobjectMap::UpdateEmptyField if (RD == Class) { // This is the most derived class, traverse virtual bases as well. for (const auto I : RD-vbases()) { - const CXXRecordDecl *VBaseDecl = - castCXXRecordDecl(I.getType()-getAsRecordType()-getDecl()); - + const CXXRecordDecl *VBaseDecl = I.getType()-getAsCXXRecordDecl(); + CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBaseDecl); UpdateEmptyFieldSubobjects(VBaseDecl, Class, VBaseOffset); } @@ -493,8 +486,7 @@ void EmptySubobjectMap::UpdateEmptyField void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const FieldDecl *FD, CharUnits Offset) { QualType T = FD-getType(); - if (const RecordType *RT = T-getAsRecordType()) { -const CXXRecordDecl *RD = castCXXRecordDecl(RT-getDecl()); + if (const CXXRecordDecl *RD = T-getAsCXXRecordDecl()) { UpdateEmptyFieldSubobjects(RD, RD, Offset); return; } @@ -505,8 +497,8 @@ void EmptySubobjectMap::UpdateEmptyField const RecordType *RT = ElemTy-getAsRecordType(); if (!RT) return; - -const CXXRecordDecl *RD =
r206039 - [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.
Author: bwilson Date: Fri Apr 11 12:16:13 2014 New Revision: 206039 URL: http://llvm.org/viewvc/llvm-project?rev=206039view=rev Log: [PGO] Change MapRegionCounters to be a RecursiveASTVisitor. This avoids the overhead of specifying all the traversal code when using ConstStmtVisitor and makes it a lot easier to maintain this. Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206039r1=206038r2=206039view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 12:16:13 2014 @@ -321,8 +321,8 @@ llvm::Function *CodeGenPGO::emitInitiali } namespace { - /// A StmtVisitor that fills a map of statements to PGO counters. - struct MapRegionCounters : public ConstStmtVisitorMapRegionCounters { + /// A RecursiveASTVisitor that fills a map of statements to PGO counters. + struct MapRegionCounters : public RecursiveASTVisitorMapRegionCounters { /// The next counter value to assign. unsigned NextCounter; /// The map of statements to counters. @@ -331,135 +331,55 @@ namespace { MapRegionCounters(llvm::DenseMapconst Stmt *, unsigned CounterMap) : NextCounter(0), CounterMap(CounterMap) {} -void VisitChildren(const Stmt *S) { - for (Stmt::const_child_range I = S-children(); I; ++I) -if (*I) - this-Visit(*I); +// Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl +// is handled as a separate function. +bool TraverseBlockExpr(BlockExpr *block) { return true; } + +bool VisitDecl(const Decl *D) { + switch (D-getKind()) { + default: +break; + case Decl::Function: + case Decl::CXXMethod: + case Decl::CXXConstructor: + case Decl::CXXDestructor: + case Decl::CXXConversion: + case Decl::ObjCMethod: + case Decl::Block: +CounterMap[D-getBody()] = NextCounter++; +break; + } + return true; } -void VisitStmt(const Stmt *S) { VisitChildren(S); } -/// Assign a counter to track entry to the function body. -void VisitFunctionDecl(const FunctionDecl *D) { - CounterMap[D-getBody()] = NextCounter++; - Visit(D-getBody()); -} -void VisitObjCMethodDecl(const ObjCMethodDecl *D) { - CounterMap[D-getBody()] = NextCounter++; - Visit(D-getBody()); -} -void VisitBlockDecl(const BlockDecl *D) { - CounterMap[D-getBody()] = NextCounter++; - Visit(D-getBody()); -} -/// Assign a counter to track the block following a label. -void VisitLabelStmt(const LabelStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getSubStmt()); -} -/// Assign a counter for the body of a while loop. -void VisitWhileStmt(const WhileStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getCond()); - Visit(S-getBody()); -} -/// Assign a counter for the body of a do-while loop. -void VisitDoStmt(const DoStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getBody()); - Visit(S-getCond()); -} -/// Assign a counter for the body of a for loop. -void VisitForStmt(const ForStmt *S) { - CounterMap[S] = NextCounter++; - if (S-getInit()) -Visit(S-getInit()); - const Expr *E; - if ((E = S-getCond())) -Visit(E); - if ((E = S-getInc())) -Visit(E); - Visit(S-getBody()); -} -/// Assign a counter for the body of a for-range loop. -void VisitCXXForRangeStmt(const CXXForRangeStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getRangeStmt()); - Visit(S-getBeginEndStmt()); - Visit(S-getCond()); - Visit(S-getLoopVarStmt()); - Visit(S-getBody()); - Visit(S-getInc()); -} -/// Assign a counter for the body of a for-collection loop. -void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getElement()); - Visit(S-getBody()); -} -/// Assign a counter for the exit block of the switch statement. -void VisitSwitchStmt(const SwitchStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getCond()); - Visit(S-getBody()); -} -/// Assign a counter for a particular case in a switch. This counts jumps -/// from the switch header as well as fallthrough from the case before this -/// one. -void VisitCaseStmt(const CaseStmt *S) { - CounterMap[S] = NextCounter++; - Visit(S-getSubStmt()); -} -/// Assign a counter for the default case of a switch statement. The count -/// is the number of branches from the loop header to the default, and does -/// not include fallthrough from previous cases. If we have multiple -/// conditional branch blocks from the switch instruction to the default
Re: r206039 - [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.
On Apr 11, 2014, at 10:16, Bob Wilson bob.wil...@apple.com wrote: Author: bwilson Date: Fri Apr 11 12:16:13 2014 New Revision: 206039 URL: http://llvm.org/viewvc/llvm-project?rev=206039view=rev Log: [PGO] Change MapRegionCounters to be a RecursiveASTVisitor. This avoids the overhead of specifying all the traversal code when using ConstStmtVisitor and makes it a lot easier to maintain this. Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206039r1=206038r2=206039view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 12:16:13 2014 @@ -321,8 +321,8 @@ llvm::Function *CodeGenPGO::emitInitiali } namespace { - /// A StmtVisitor that fills a map of statements to PGO counters. - struct MapRegionCounters : public ConstStmtVisitorMapRegionCounters { + /// A RecursiveASTVisitor that fills a map of statements to PGO counters. + struct MapRegionCounters : public RecursiveASTVisitorMapRegionCounters { /// The next counter value to assign. unsigned NextCounter; /// The map of statements to counters. @@ -331,135 +331,55 @@ namespace { MapRegionCounters(llvm::DenseMapconst Stmt *, unsigned CounterMap) : NextCounter(0), CounterMap(CounterMap) {} -void VisitChildren(const Stmt *S) { - for (Stmt::const_child_range I = S-children(); I; ++I) -if (*I) - this-Visit(*I); +// Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl +// is handled as a separate function. +bool TraverseBlockExpr(BlockExpr *block) { return true; } Do we need something similar for C++11 lambdas? ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r206039 - [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.
On Apr 11, 2014, at 10:16, Bob Wilson bob.wil...@apple.com wrote: +// Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl +// is handled as a separate function. +bool TraverseBlockExpr(BlockExpr *block) { return true; } + +bool VisitDecl(const Decl *D) { + switch (D-getKind()) { + default: +break; + case Decl::Function: + case Decl::CXXMethod: + case Decl::CXXConstructor: + case Decl::CXXDestructor: + case Decl::CXXConversion: + case Decl::ObjCMethod: + case Decl::Block: +CounterMap[D-getBody()] = NextCounter++; +break; + } + return true; } [Sorry this is broken up.] This doesn't look like a new problem, but why aren't we looking at FunctionTemplateDecls? ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH] don't diagnose -Wchar-subscript for safe char literal
Hello! I have made a fix for this bug: http://llvm.org/bugs/show_bug.cgi?id=18389 Please review. Best regards, Daniel Marjamäki .. Daniel Marjamäki Senior Engineer Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden Mobile: +46 (0)709 12 42 62 E-mail: daniel.marjam...@evidente.se www.evidente.se Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp (revision 206032) +++ lib/Sema/SemaExpr.cpp (arbetskopia) @@ -3832,7 +3832,8 @@ if ((IndexExpr-getType()-isSpecificBuiltinType(BuiltinType::Char_S) || IndexExpr-getType()-isSpecificBuiltinType(BuiltinType::Char_U)) - !IndexExpr-isTypeDependent()) + !IndexExpr-isTypeDependent() + !isaCharacterLiteral(IndexExpr)) Diag(LLoc, diag::warn_subscript_is_char) IndexExpr-getSourceRange(); // C99 6.5.2.1p1: shall have type pointer to *object* type. Similarly, Index: test/SemaCXX/warn-char-subscripts.cpp === --- test/SemaCXX/warn-char-subscripts.cpp (revision 206032) +++ test/SemaCXX/warn-char-subscripts.cpp (arbetskopia) @@ -19,3 +19,7 @@ t2char(); // expected-note {{in instantiation of function template specialization 't2char' requested here}} } +void charliteral() { + int array[256]; + array['0'] = 0; // no danger here +} ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r206039 - [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.
On Apr 11, 2014, at 11:00 AM, Duncan P. N. Exon Smith dexonsm...@apple.com wrote: On Apr 11, 2014, at 10:16, Bob Wilson bob.wil...@apple.com wrote: +// Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl +// is handled as a separate function. +bool TraverseBlockExpr(BlockExpr *block) { return true; } + +bool VisitDecl(const Decl *D) { + switch (D-getKind()) { + default: +break; + case Decl::Function: + case Decl::CXXMethod: + case Decl::CXXConstructor: + case Decl::CXXDestructor: + case Decl::CXXConversion: + case Decl::ObjCMethod: + case Decl::Block: +CounterMap[D-getBody()] = NextCounter++; +break; + } + return true; } [Sorry this is broken up.] This doesn't look like a new problem, but why aren't we looking at FunctionTemplateDecls? Justin is currently looking to see if we’re missing anything like that. I’m not very familiar with how templates work inside clang. I was assuming that we only care about templates that get instantiated and that we would then see them as ordinary Functions or CXXMethods. ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Add support for named values in the parser.
LGTM. http://reviews.llvm.org/D3276 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Add support for named values in the parser.
LGTM. On Mon, Apr 07, 2014 at 08:41:53AM -0700, Samuel Benzaquen wrote: Comment at: lib/ASTMatchers/Dynamic/Parser.cpp:304 @@ +303,3 @@ + + // Parse as a matcher expressoin. + return parseMatcherExpressionImpl(NameToken, Value); Peter Collingbourne wrote: Typo: expression. Fixed. Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:334 @@ -333,2 +333,3 @@ if (it == RegistryData-constructors().end()) { -Error-addError(NameRange, Error-ET_RegistryNotFound) MatcherName; +if (Error) { + Error-addError(NameRange, Error-ET_RegistryMatcherNotFound) Peter Collingbourne wrote: I wonder if it would be better to drop the Error parameter from this function (and Sema::lookupMatcherCtor) and move diagnostic emission to the parser. That would be more consistent with how Sema::getNamedValue works, and would also allow you to do both lookups once, in parseIdentifierPrefixImpl. Yes. It made sense when it was inside constructMatcher, but now it makes more sense outside. http://reviews.llvm.org/D3276 -- Peter ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Fix diagnostics for C-style cast to function type
Sorry for the delay! +// but the type cast should be considered as failure. + +OverloadExpr* oe = OverloadExpr::find(SrcExpr.get()).Expression; +Self.Diag(OpRange.getBegin(), diag::err_bad_cstyle_cast_overload) + oe-getName() DestType OpRange + oe-getQualifierLoc().getSourceRange(); +Self.NoteAllOverloadCandidates(SrcExpr.get()); Some tiny typographical things here: no blank line between the comment and the code, put the * on the right not on the left, and 'oe' should be 'OE'. Otherwise, this looks good to me. Do you need someone to commit it for you? On Thu, Mar 27, 2014 at 9:51 AM, Logan Chien tzuhsiang.ch...@gmail.comwrote: Ping? On Mon, Mar 17, 2014 at 11:59 PM, Logan Chien tzuhsiang.ch...@gmail.comwrote: Hi, It seems that if the C-style type cast is applied to the overloaded function and the destination type is function type, then Clang will crash with assertion failure. For example, void foo(int); void foo(int, int); void bar() { typedef void (ft)(int); ft p = (ft)foo; } In this case, the overloaded function foo will be cast to a function type, which should be considered as an error. But, unfortunately, since the function resolution is using canonical type, the matched function will be returned, and raise SEGV at lib/Sema/SemaCast.cpp:2101. This patch fixes this issue by removing the assertion and add some error diagnostics as the one in static_cast. Please have a look. Thanks. Logan ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205144 - [PowerPC] Make -pg generate calls to _mcount not mcount
On Tue, Apr 08, 2014 at 06:48:21AM -0500, Hal Finkel wrote: Doug, Tom, I'd like to pull this into 3.4.1. This patch has been merged. -Hal - Original Message - From: Hal Finkel hfin...@anl.gov To: cfe-commits@cs.uiuc.edu Sent: Sunday, March 30, 2014 8:00:07 AM Subject: r205144 - [PowerPC] Make -pg generate calls to _mcount not mcount Author: hfinkel Date: Sun Mar 30 08:00:06 2014 New Revision: 205144 URL: http://llvm.org/viewvc/llvm-project?rev=205144view=rev Log: [PowerPC] Make -pg generate calls to _mcount not mcount At least on REL6 (Linux/glibc 2.12), the proper symbol for generating gprof data is _mcount, not mcount. Prior to this change, compiling with -pg would generate linking errors (because of unresolved references to mcount), after this change -pg seems at least minimally functional. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGen/mcount.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=205144r1=205143r2=205144view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Sun Mar 30 08:00:06 2014 @@ -355,6 +355,16 @@ public: LinuxTargetInfo(const llvm::Triple Triple) : OSTargetInfoTarget(Triple) { this-UserLabelPrefix = ; this-WIntType = TargetInfo::UnsignedInt; + +switch (Triple.getArch()) { +default: + break; +case llvm::Triple::ppc: +case llvm::Triple::ppc64: +case llvm::Triple::ppc64le: + this-MCountName = _mcount; + break; +} } const char *getStaticInitSectionSpecifier() const override { Modified: cfe/trunk/test/CodeGen/mcount.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mcount.c?rev=205144r1=205143r2=205144view=diff == --- cfe/trunk/test/CodeGen/mcount.c (original) +++ cfe/trunk/test/CodeGen/mcount.c Sun Mar 30 08:00:06 2014 @@ -1,4 +1,8 @@ // RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -pg -triple powerpc-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s +// RUN: %clang_cc1 -pg -triple powerpc64-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s +// RUN: %clang_cc1 -pg -triple powerpc64le-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-PPC %s void foo(void) { // CHECK: call void @mcount() +// CHECK-PPC: call void @_mcount() } ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits -- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: 3.4.1 patches
On Tue, Apr 08, 2014 at 06:51:21PM -0400, Brad Smith wrote: Please back port r203007 to the 3.4.1 release. This patch has been merged. -Tom -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r204942 - Comment parsing: attach comments to enums declared using the NS_ENUM macro
On Thu, Mar 27, 2014 at 9:40 AM, Dmitri Gribenko griboz...@gmail.comwrote: Author: gribozavr Date: Thu Mar 27 11:40:51 2014 New Revision: 204942 URL: http://llvm.org/viewvc/llvm-project?rev=204942view=rev Log: Comment parsing: attach comments to enums declared using the NS_ENUM macro Previously we would only attach comments to the typedef. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/Index/annotate-comments-objc.m cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=204942r1=204941r2=204942view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Mar 27 11:40:51 2014 @@ -145,11 +145,23 @@ RawComment *ASTContext::getRawCommentFor DeclLoc = D-getLocStart(); else { DeclLoc = D-getLocation(); -// If location of the typedef name is in a macro, it is because being -// declared via a macro. Try using declaration's starting location -// as the declaration location. -if (DeclLoc.isMacroID() isaTypedefDecl(D)) - DeclLoc = D-getLocStart(); +if (DeclLoc.isMacroID()) { + if (isaTypedefDecl(D)) { Should this be TypedefNameDecl? (That also covers C++11 alias declarations, which are another syntax for typedefs.) +// If location of the typedef name is in a macro, it is because being +// declared via a macro. Try using declaration's starting location as +// the declaration location. +DeclLoc = D-getLocStart(); + } else if (const TagDecl *TD = dyn_castTagDecl(D)) { +// If location of the tag decl is inside a macro, but the spelling of +// the tag name comes from a macro argument, it looks like a special +// macro like NS_ENUM is being used to define the tag decl. In that +// case, adjust the source location to the expansion loc so that we can +// attach the comment to the tag decl. +if (SourceMgr.isMacroArgExpansion(DeclLoc) +TD-isCompleteDefinition()) + DeclLoc = SourceMgr.getExpansionLoc(DeclLoc); + } +} } // If the declaration doesn't map directly to a location in a file, we Modified: cfe/trunk/test/Index/annotate-comments-objc.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments-objc.m?rev=204942r1=204941r2=204942view=diff == --- cfe/trunk/test/Index/annotate-comments-objc.m (original) +++ cfe/trunk/test/Index/annotate-comments-objc.m Thu Mar 27 11:40:51 2014 @@ -32,6 +32,32 @@ void functionBeforeImports(void); - (void)method1_isdoxy4; /*! method1_isdoxy4 IS_DOXYGEN_SINGLE */ @end +//===--- +// rdar://14348912 +// Check that we attach comments to enums declared using the NS_ENUM macro. +//===--- + +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type + +/// An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE +typedef NS_ENUM(int, An_NS_ENUM_isdoxy1) { Red, Green, Blue }; + +// In the implementation of attaching comments to enums declared using the +// NS_ENUM macro, it is tempting to use the fact that enum decl is embedded in +// the typedef. Make sure that the heuristic is strong enough that it does not +// attach unrelated comments in the following cases where tag decls are +// embedded in declarators. + +#define DECLARE_FUNCTION() \ +void functionFromMacro() { \ + typedef struct Struct_notdoxy Struct_notdoxy; \ +} + +/// IS_DOXYGEN_NOT_ATTACHED +DECLARE_FUNCTION() + +/// typedef_isdoxy1 IS_DOXYGEN_SINGLE +typedef struct Struct_notdoxy *typedef_isdoxy1; #endif @@ -91,4 +117,8 @@ void functionBeforeImports(void); // CHECK: annotate-comments-objc.m:30:9: ObjCInstanceMethodDecl=method1_isdoxy2:{{.*}} method1_isdoxy2 IS_DOXYGEN_SINGLE // CHECK: annotate-comments-objc.m:31:9: ObjCInstanceMethodDecl=method1_isdoxy3:{{.*}} method1_isdoxy3 IS_DOXYGEN_SINGLE // CHECK: annotate-comments-objc.m:32:9: ObjCInstanceMethodDecl=method1_isdoxy4:{{.*}} method1_isdoxy4 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments-objc.m:43:22: TypedefDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments-objc.m:60:32: TypedefDecl=typedef_isdoxy1:{{.*}} typedef_isdoxy1 IS_DOXYGEN_SINGLE Modified: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp?rev=204942r1=204941r2=204942view=diff
Re: [PATCH][REVIEW REQUEST] Fix for libclang completion of already declared template friends.
On Fri, Mar 14, 2014 at 6:59 AM, Francisco Lopes francisco.mailing.li...@oblita.com wrote: hi, thanks for the comment but, for example, as I want to add the call to getCanonicalDecl for this situation of friends solely, don't I need to check whether it's in friend name space too? I'm not sure whether you meant to replace the two first checks, or just the second. I meant to replace all the checks. I don't see why you would want to call getCanonicalDecl here, or why you'd care whether the name has ever been declared as a friend. All you should check is, is the name visible now? Regards. 2014-03-13 20:59 GMT-03:00 Richard Smith rich...@metafoo.co.uk: Your visibility check seems more complex than necessary. I think this should do what you want: if (ND-getMostRecentDecl()-isInIdentifierNamespace(Decl::IDNS_Ordinary | Decl::IDNS_Tag)) // visible On Wed, Mar 12, 2014 at 2:12 PM, Francisco Lopes francisco.mailing.li...@oblita.com wrote: Ping 2014-03-07 14:47 GMT-03:00 Francisco Lopes francisco.mailing.li...@oblita.com: Hi, attached is a patch that tries to fix libclang bug 13699http://llvm.org/bugs/show_bug.cgi?id=13699 . Please review. -- Francisco Lopes PS: I have requested commit access in late 2012 but never made a test commit or anything. At the time I have received from Chris Lattner: I'm sorry for the delay, I've been fighting mailing list issues. Commit after approval access is granted. Please try a test commit! I'm not sure whether it's still valid. ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] PR19095 Undefined reference to friend template function defined inside template class
Hi! I'm afraid this patch is incorrect; it even does the wrong thing in your test case. Skipping the setInstantiatedFromMemberTemplate call causes us to mix up the template parameter list numbering -- we substitute the argument given for T as the value U, and we don't substitute anything for T. For instance, in the definition of f instantiated for the f(3.0) call, we should have T=double, U=int, but we actually have T=no value, U=double, as can be seen in the AST dump. This also does the wrong thing if C is instantiated twice -- such a case should be an error, because f would have multiple definitions. On Mon, Mar 24, 2014 at 5:29 AM, suyog sarda sardas...@gmail.com wrote: Gentle Ping!! On Thu, Mar 20, 2014 at 9:46 AM, suyog sarda sardas...@gmail.com wrote: Gentle Ping!! On Fri, Mar 14, 2014 at 10:29 PM, suyog sarda sardas...@gmail.comwrote: Hi, Attaching patch for bug 19095. Please help in reviewing the same. Also, I haven't attached a test case yet in the patch as i am not sure how it should be and in which file it should be. In my opinion, the test case would go into *tools/clang/test/SemaCXX/friend.cpp *would be something like below (similar to that mentioned in the bug) * template class Tvoid f(T);template class Uclass C{ template class T friend void f(T) { CU c; c.i = 3; } public : void g() { f(3.0); // OK }int i;};void h (){ f(7); // OK Cdouble c; c.g();}* Please help in reviewing the patch as well as the test case. -- With regards, Suyog Sarda -- With regards, Suyog Sarda -- With regards, Suyog Sarda ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: OK to merge r205144, r204742, and r196981 for the 3.4.1 release?
On Apr 10, 2014, at 7:39 PM, Tom Stellard t...@stellard.net wrote: Hi Doug, Hal Finkel, Brad Smith, and David Fang, have all nominated patches for the 3.4.1 release: http://llvm.org/viewvc/llvm-project?rev=205144view=rev http://llvm.org/viewvc/llvm-project?view=revisionrevision=204742 http://llvm.org/viewvc/llvm-project?view=revisionrevision=196981 Do you approve? Yes, all three are approved. Thanks, Tom! - Doug ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Recovery of switch statement
Comment at: lib/Parse/ParseStmt.cpp:701-705 @@ -688,5 +700,7 @@ // not valid. SourceLocation AfterColonLoc = PP.getLocForEndOfToken(ColonLoc); +if (ColonLoc.isInvalid()) + AfterColonLoc = PrevTokLocation; Diag(AfterColonLoc, diag::err_label_end_of_compound_statement) FixItHint::CreateInsertion(AfterColonLoc, ;); SubStmt = true; This doesn't look right in the case where `ColonLoc` is invalid. `AfterColonLoc` will point to the *start* of the previous token in this case, and we'll provide a fix-it inserting a semicolon in a fairly random place. In the case where `ColonLoc` is invalid, we've already hit at least one error, so it seems better to suppress the follow-on diagnostic here. I think this will also do the wrong thing if we have a sequence of `case` statements, and the last one is missing a colon or is otherwise malformed; we'll use the last `ColonLoc` for any of the `case` statements we succeeded in handling. Maybe reset `ColonLoc` to `SourceLocation()` each time around the `do` loop to fix this? Comment at: lib/Sema/SemaStmt.cpp:707-708 @@ +706,4 @@ + if (!Body) { +// Put the synthesized null statement on the same line as the end of switch +// condition. +SourceLocation SynthesizedNullStmtLocation; This comment doesn't explain what's happening here. Something like: // This happens if the body was ill-formed. Synthesize a null statement at the end of the switch condition. ... would be better. But our normal approach here would be to simply return `StmtError()` in this case. Any reason not to do that? http://reviews.llvm.org/D3137 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Modules - fix exclude header with umbrella directory
I'm hesitant to say this LGTM, since this code was clearly added deliberately, but I'm having a hard time understanding why we'd want strange (and subtly-broken) rules for umbrella directories. Why is the model not simply that they implicitly generate a bunch of submodules? Also, this patch should have an accompanying testcase showing that it fixes the behavior of `exclude header` when combined with umbrella headers. http://reviews.llvm.org/D3090 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206069 - Add a test to distinguish between reserved tokens and normal identifiers.
Author: ygao Date: Fri Apr 11 15:55:19 2014 New Revision: 206069 URL: http://llvm.org/viewvc/llvm-project?rev=206069view=rev Log: Add a test to distinguish between reserved tokens and normal identifiers. The -fms-extensions option affects a number of subtle front-end C/C++ behaviors, and it would be useful to be able to distinguish MS keywords from regular identifiers in the ms-extensions mode even if the triple does not define a Windows target. It should make life easier if anyone needs to port their Windows codes to elsewhere. Differential Revision: http://reviews.llvm.org/D3034 Added: cfe/trunk/test/Lexer/keywords_test.c Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPMacroExpansion.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=206069r1=206068r2=206069view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Apr 11 15:55:19 2014 @@ -125,6 +125,7 @@ class Preprocessor : public RefCountedBa IdentifierInfo *Ident__has_include; // __has_include IdentifierInfo *Ident__has_include_next; // __has_include_next IdentifierInfo *Ident__has_warning; // __has_warning + IdentifierInfo *Ident__is_identifier;// __is_identifier IdentifierInfo *Ident__building_module; // __building_module IdentifierInfo *Ident__MODULE__; // __MODULE__ Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=206069r1=206068r2=206069view=diff == --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Apr 11 15:55:19 2014 @@ -115,6 +115,7 @@ void Preprocessor::RegisterBuiltinMacros Ident__has_include = RegisterBuiltinMacro(*this, __has_include); Ident__has_include_next = RegisterBuiltinMacro(*this, __has_include_next); Ident__has_warning = RegisterBuiltinMacro(*this, __has_warning); + Ident__is_identifier= RegisterBuiltinMacro(*this, __is_identifier); // Modules. if (LangOpts.Modules) { @@ -1359,6 +1360,7 @@ void Preprocessor::ExpandBuiltinMacro(To } else if (II == Ident__has_feature || II == Ident__has_extension || II == Ident__has_builtin || + II == Ident__is_identifier || II == Ident__has_attribute) { // The argument to these builtins should be a parenthesized identifier. SourceLocation StartLoc = Tok.getLocation(); @@ -1382,6 +1384,8 @@ void Preprocessor::ExpandBuiltinMacro(To bool Value = false; if (!IsValid) Diag(StartLoc, diag::err_feature_check_malformed); +else if (II == Ident__is_identifier) + Value = FeatureII-getTokenID() == tok::identifier; else if (II == Ident__has_builtin) { // Check for a builtin is trivial. Value = FeatureII-getBuiltinID() != 0; Added: cfe/trunk/test/Lexer/keywords_test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/keywords_test.c?rev=206069view=auto == --- cfe/trunk/test/Lexer/keywords_test.c (added) +++ cfe/trunk/test/Lexer/keywords_test.c Fri Apr 11 15:55:19 2014 @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -std=c99 -E %s -o - | FileCheck --check-prefix=CHECK-NONE %s + +// RUN: %clang_cc1 -std=gnu89 -E %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s +// RUN: %clang_cc1 -std=c99 -fgnu-keywords -E %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s +// RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-NONE %s + +// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s + +void f() { +// CHECK-NONE: int asm +// CHECK-GNU-KEYWORDS: asm (ret : :) +#if __is_identifier(asm) + int asm; +#else + asm (ret : :); +#endif +} + +// CHECK-NONE: no_ms_wchar +// CHECK-MS-KEYWORDS: has_ms_wchar +#if __is_identifier(__wchar_t) +void no_ms_wchar(); +#else +void has_ms_wchar(); +#endif ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205952 - Add global static variables for anonymous union fields. This makes
On Thu, Apr 10, 2014 at 11:14 AM, Robinson, Paul paul_robin...@playstation.sony.com wrote: I get that/assume this also has interesting interactions with pubnames ( thus representing these as global variables makes it easier for pubnames to get the names given our implementation, etc). rathole pubnames... not dead yet? /rathole Although I guess the same consideration would apply to the pending pubnames replacement. Basically. Pubnames/Pubtypes are also used in the current input to gold generating gdb index as well. :) -eric ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205952 - Add global static variables for anonymous union fields. This makes
On Thu, Apr 10, 2014 at 9:52 AM, David Blaikie dblai...@gmail.com wrote: All that being said, I have been a proponent of whatever works for the debugger(s) in the past - though this might meet my infrequent used feature that I'd rather not carry the legacy of compatibility for instead let the debugger bear the burden of bugs/fixing. But perhaps that's just personal bias due to the particular area of impact. I get that/assume this also has interesting interactions with pubnames ( thus representing these as global variables makes it easier for pubnames to get the names given our implementation, etc). Right, while it seems possible for the debugger to have guessed print a as there's no a, but hey, is a an anonymous union at global scope that could have injected its contents into the current scope let's go through every member of the type and see if it's there, but that seems a bit much to assume on their part. :) As far as the source fidelity thing, I don't have a particular color for the shed here and don't mind either way. Ditto with whether or not we put a variable with no name for the union itself. -eric On Thu, Apr 10, 2014 at 9:15 AM, David Blaikie dblai...@gmail.com wrote: On Wed, Apr 9, 2014 at 10:20 PM, Eric Christopher echri...@gmail.com wrote: Author: echristo Date: Thu Apr 10 00:20:00 2014 New Revision: 205952 URL: http://llvm.org/viewvc/llvm-project?rev=205952view=rev Log: Add global static variables for anonymous union fields. This loses source fidelity though, doesn't it? We no longer describe which of these fields are mutually exclusive, etc. We manage to get this correct for member variables that are anonymous unions - why wouldn't the same behavior be correct for globals? This makes sure that a debugger can find them when stepping through code, for example from the included testcase: Sounds like this is a debugger bug if it couldn't manage it with the previous representation, no? Well, actually - this looks like it might just be a compiler bug that we accept this entity at all... gcc doesn't seem to accept this code. I don't know why we would either. GCC 4.6, 4.7, 4.8.1, and ToT all warn that the static anonymous struct defines an unnamed struct/union with no instances (rather than introducing a global unnamed struct/union). Hmm, nope - just a piece of C++11 that GCC doesn't implement. Though GCC and Clang do both implement anonymous unions at function scope and both implement the debug info as this patch does for globals. (with the same loss in source fidelity) Wait, no, GCC does something weird - it includes variables directly in the function's lexical block /and/ it includes the union: void f() { union { int x, y; }; ... } looks like: subprogram x variable int x at location foo variable int y at location foo variable anon at location foo union anon member int x member int y So we've got some inconsistency here... :/ Sounds like GCC was working around the same debugger limitation but with a little better source fidelity. If possible, I'd rather we just fix the debugger and only produce the dwarf that describes the source... (haven't looked in detail at the code for this patch yet - just the change in behavior) 12 int test_it() { 13 c = 1; 14 d = 2; - 15 a = 4; 16 return (c == 1); 17 } 18 (lldb) p a (int) $0 = 2 (lldb) p c (int) $1 = 2 (lldb) p d (int) $2 = 2 and a, c, d are all part of the file static anonymous union: static union { int c; int d; union { int a; }; struct { int b; }; }; Fixes PR19221. Added: cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=205952r1=205951r2=205952view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Apr 10 00:20:00 2014 @@ -3180,6 +3180,37 @@ CGDebugInfo::getOrCreateStaticDataMember return T; } +/// Recursively collect all of the member fields of a global anonymous decl and +/// create static variables for them. The first time this is called it needs +/// to be on a union and then from there we can have additional unnamed fields. +llvm::DIGlobalVariable +CGDebugInfo::CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit, +unsigned LineNo, StringRef LinkageName, +llvm::GlobalVariable *Var, +llvm::DIDescriptor DContext) { + llvm::DIGlobalVariable GV; + + for (const auto *Field : RD-fields()) { +llvm::DIType FieldTy =
Re: [PATCH] OpenCL - allow address space qualifiers on arrays passed as arguments
On 04/10/2014 07:21 PM, Fraser Cormack wrote: The OpenCL 1.1 and 1.2 specifications state that arrays as arguments can be given address space qualifiers (section 6.5). The OpenCL 1.0 spec isn't so clear in this regard, but since it's based on C99, I assume that it is possible. Does anyone have input on this? LGTM. BR, -- Pekka ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Fix for crash due to g++.old-deja/g++.other/using3.C
On Tue, Mar 18, 2014 at 2:48 AM, Dinesh Dwivedi dines...@samsung.comwrote: Submitted bug report [http://llvm.org/bugs/show_bug.cgi?id=19171] Should we update typo-correction code, to suggest only base class member if using declaration is inside derivied class. Yes, that seems like the right approach. We shouldn't have got to this point with an invalid 'Orig' declaration. Also, please put the test in the existing 'using-decl-1.cpp' file. ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Allow overriding -split-dwarf-file
On Fri, Apr 4, 2014 at 9:07 AM, Lubos Lunak l.lu...@centrum.cz wrote: On Friday 04 of April 2014, David Blaikie wrote: Oops, re-add cfe-commits. On Fri, Apr 4, 2014 at 8:34 AM, David Blaikie dblai...@gmail.com wrote: On Fri, Apr 4, 2014 at 8:24 AM, Lubos Lunak l.lu...@centrum.cz wrote: On Friday 04 of April 2014, Eric Christopher wrote: ... Why would you want to do this? The compile itself happens in a chroot and the expected and actual output locations differ (and don't even exist in the other tree). In your scenario the .dwo is not side-by-side with the .o? Or are you overriding the .o name as well in some way? The scenario is distributed compiling with Icecream (https://github.com/icecc/icecream). If you don't know it, think distcc, except more sophisticated in some ways, one of them being that it ships the compiler to the remote host and uses it in chroot (which avoids a number of problems and allows cross-compiling). Which means the actual compile run lacks a number of things, like the source file itself (piped using stdin), the source file location, or the expected output location. The result goes to a temporary .o file, which is generally not a problem (I don't think the name of the .o file matters), but with split dwarf the .dwo name gets hardcoded to this random location in the .o file. For performance reasons there's a chroot location per compiler, not per compile, so while I could temporarily create the right location, I'm not exactly eager to write the code to do that properly with all the locks etc. when I could use a compiler option that just sets one dwarf info field, if only I actually could use it. If you want a precedent, there's already -fdebug-compilation-dir, which AFAICT is exactly the same, just with a different dwarf info field. I could do with changing DW_AT_GNU_dwo_name explicitly after the build, but that seems needlessly complex given that this seems to be exactly what the option does. I don't see why I would be allowed to override any option except for this one. -Xclang and the underlying driver arguments aren't really a stable/guaranteed interface. I'd be more inclined to accept this change if it were just for some debugging, but since it sounds like you want to rely on it, it's good for us to understand the goal and perhaps suggest or provide the best way of achieving it long-term. It's stable/guaranteed enough for me, and I'd rather have a clean solution that maybe breaks one day than something hackish the whole time. I'm guessing you mean that the actual output file name differs? I.e. some sort of temporary cached file ala ccache that doesn't have the same name as the file that you've just compiled? The directory ends up being the same here (or can be set with, as you surmised -fdebug-compilation-dir). If so, I don't mind an option to set here necessarily, but would like to see it plumbed through and not rely on Xclang options. -eric ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[PATCH] Use -ivfsoverlay in ASTUnit
Hi Dmitri and Argyrios, Could one (or both) of you take a look at my changes to the ASTUnit to support the VFS? The VFS needs to be created for most/all of the FileManagers that get created, and I’m a bit worried by the sheer number of FileManager and SourceManager creations that I needed to plug up. Ben astunit.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: OK to merge r205144, r204742, and r196981 for the 3.4.1 release?
On Fri, Apr 11, 2014 at 01:27:49PM -0700, Douglas Gregor wrote: On Apr 10, 2014, at 7:39 PM, Tom Stellard t...@stellard.net wrote: Hi Doug, Hal Finkel, Brad Smith, and David Fang, have all nominated patches for the 3.4.1 release: http://llvm.org/viewvc/llvm-project?rev=205144view=rev http://llvm.org/viewvc/llvm-project?view=revisionrevision=204742 http://llvm.org/viewvc/llvm-project?view=revisionrevision=196981 Do you approve? Yes, all three are approved. Thanks, Tom! These patches have been merged. -Tom - Doug ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: CodeGen: OK to merge r203007 for 3.4.1 release?
On Thu, Apr 10, 2014 at 10:18:30PM -0700, John McCall wrote: On Apr 10, 2014, at 7:41 PM, Tom Stellard t...@stellard.net wrote: Brad Smith has nominated the following commit for inclusion in the 3.4.1 release: http://llvm.org/viewvc/llvm-project?view=revisionrevision=203007 Do you approve? Yes, although please change it to use castAsFunctionProtoType() at least in trunk. Brad, are you able to make this change in trunk? This patch has been merged. -Tom ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: Re: Fix for ICE in clang due to infinite loop.
See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3914.html ... for the latest description of the rule that we should use to handle this case. (Look for issue 1673.) On Mon, Mar 17, 2014 at 10:48 PM, Mayur Pandey mayu...@samsung.com wrote: Gentle Ping. *From:* Eli Friedman eli.fried...@gmail.com *Sent:* Thursday, September 26, 2013 6:23 AM *To:* mayu...@samsung.com ; Richard Smith rich...@metafoo.co.uk *Cc:* cfe-commits@cs.uiuc.edu Commits cfe-commits@cs.uiuc.edu+Commits *Subject:* Re: Re: Fix for ICE in clang due to infinite loop. On Tue, Sep 24, 2013 at 11:48 PM, MAYUR PANDEY mayu...@samsung.comwrote: This is the similar way it has been fixed in gcc. They have kept a note of parent and they break the loop when it is again noticed. With the usage of global map there are no performance issues as such. Also please suggest the alternate way of fixing this issue. I'm not an expert on overload resolution rules, so if you're certain we actually need a map to catch this case, that's fine, I guess. (Richard, can you chime in?) The rest of my feedback still applies. -Eli --- *Original Message* --- *Sender* : Eli Friedmaneli.fried...@gmail.com *Date* : Sep 10, 2013 06:53 (GMT+09:00) *Title* : Re: Fix for ICE in clang due to infinite loop. On Mon, Sep 9, 2013 at 5:08 AM, MAYUR PANDEY mayu...@samsung.comwrote: Hi, Attached is the fix for Compiler crash caused by infinite loop when we try to compile the following code. struct A; struct B { B (A const ); B (B ); }; struct A { A (B); }; B f (B const b) { return b; } ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [LLVMdev] 3.4.1 Release Plans
On Fri, Apr 04, 2014 at 04:29:04PM +0800, Jiangning Liu wrote: Hi, I think the latter option is the right choice. The pain of preserving the ABI belongs with our hard-working branch maintainers (and they always have the option of rejecting a change because it would break the ABI). Absolutely! --renato Sorry, I 'm not sure I'm following you guys correctly. Do you mean we should not allow any LLVMWhatever.so ABI broken, so we need to guarantee the ordering of those intrinsic enums generated by Intrinsicsxxx.td? If yes, I don't think it's worthwhile tuning them with whatever tricky method to make abi-compliance-checker give 100% backward compatibility, so I'd want to give up adding the complete NEON support in 3.4.1 release. Therefore, plan B is to port the followings to 3.4.1 release only, CLANG: 198940 Enable -fuse-init-array for all AArch64 ELF targets by default, not just linux. LLVM: 198937 Make sure -use-init-array has intended effect on all AArch64 ELF targets, not just linux. 198941 Silence unused variable warning for non-asserting builds that was introduced in r198937. 199369 For ARM, fix assertuib failures for some ld/st 3/4 instruction with wirteback. 201541 Fix a typo about lowering AArch64 va_copy. 201841 [AArch64] Add register constraints to avoid generating STLXR and STXR with unpredictable behavior. 204304 [ARM]Fix an assertion failure in A15SDOptimizer about DPair reg class by treating DPair as QPR. I tried them and the regression tests can all pass. All of these patches have been merged. -Tom -- Thanks, -Jiangning ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] InstrProf: Calculate a better function hash
On Apr 10, 2014, at 17:21, Duncan P. N. Exon Smith dexonsm...@apple.com wrote: On Apr 10, 2014, at 4:13, Chandler Carruth chandl...@google.com wrote: And comments on the proper change... Thanks for the review! Updated patch attached. +void MapRegionCounters::assignCounter(const Decl *D) { + CounterMap[D-getBody()] = NextCounter++; + Hash.combine(hashDecl(*D)); +} Why hash the declaration at all? There shouldn't be any cases where a declaration impacts control flow, and you have complexity enum and in the hasher to handle this. Good point. +static PGOHash::HashType hashStmt(const Stmt S) { While I see the appeal of this abstraction, I don't think it is ultimately buying you much of anything. We already do a full switch over the StmtClass in the visitor, we shouldn't re-do it here (for simplicity, I'm moderately confident the optimizer will fix this). I would probably leave the counter management as it was, and just add a hash combine step for the statements. Or you could pass the enum through and share the counter growth and hash combination much like you have in the current patch. The complexity I would avoid is yet another switch over all of the CFG-impacting statement kinds. Does that make sense to you? I'm mainly concerned about minimizing boilerplate. Bob's working on a patch to switch to RecursiveASTVisitor so we can gut the traversal logic, and I don't want to move in the opposite direction. Your idea to pass the enum through accomplishes the same goal (and is obviously cleaner), so I went with that. I've rebased after Bob's commit in r206039. New patch attached. I re-added a getHashStmt() function since it made for the cleanest diff. I think this is the best way here after all. pgo-hash-5.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Add getter methods for arguments, ranges and fix-it hints to PartialDiagnostic
As we've discussed on the other patch, I don't like violating the abstraction of `PartialDiagnostic` in this way. I think there are other approaches we can use to get the desired behavior without resorting to this. http://reviews.llvm.org/D3060 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] Handle properly somewhat special cases of -main-file-name
On Fri, Apr 4, 2014 at 9:08 AM, Lubos Lunak l.lu...@centrum.cz wrote: On Friday 04 of April 2014, David Blaikie wrote: The comment in CGDebugInfo.cpp says that -main-file-name will contain only the file name, with no path information. Are there cases where that is not true when -main-file-name is passed from the Clang driver, rather than by the user in your example below? If the driver provides this guarantee and the user violates it when passing an undocumented flag manually, I don't see a need to support it - but if there is such a need, it'd be good to understand/documemnt/discuss it. I think the driver always only passes the filename, but I do pass it explicitly, since I feed the source from stdin and the source or even its directory don't exist (distributed compiling, the same way with the patch for -dwarf-split-file). And actually case 2) without using the option explicitly results in DW_AT_name becoming /- (I don't know why the driver doesn't simply pass the name as it is, which wouldn't need the code that attempts to rebuild it later). As for undocumented, the documentation status of the option is about the same like with many others - it's just in the .td file including its description. The description says quite clearly what the option does, it doesn't say it's internal, it works fine (except for these small problems), I even checked the sources to be sure, and I don't see why Clang should forbid usage of the option if I know what I'm doing (and would have to resort to ugly hacks otherwise). There's no guarantee that the option will continue to exist at all so I'd really prefer that you not use it. Any time you have to use -Xclang to set something then it's not an exposed option that you should be using. That said, if we can come up with a structured set of uses for this sort of compilation strategy rather than piecemeal then we should discuss it and how it'll fit into the driver. -eric On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak l.lu...@centrum.cz wrote: The handling of -main-file-name in CGDebugInfo::CreateCompileUnit() can result in incorrect DW_AT_name in somewhat special cases: 1) $ touch /tmp/a.cpp $ clang++ -Wall -c /tmp/a.cpp -g -o /tmp/a.o -Xclang -main-file-name -Xclang /new/path/a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name 12 DW_AT_name: (indirect string, offset: 0x15): /tmp/new/path/a.cpp 2) $ touch /tmp/a.cpp $ cd / $ cat /tmp/a.cpp | clang++ -Wall -x c++ -c - -g -o /tmp/a.o -Xclang -main-file-name -Xclang a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name 12 DW_AT_name: (indirect string, offset: 0x15): /a.cpp The attached patch fixes those. Ok to commit? -- Lubos Lunak ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205226 - Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lis
Thanks for doing this! Looks like this won't reject the ill-formed construct [[deprecated()]]. (Both [[gnu::deprecated()]] and __attribute__((deprecated())) are OK, IIRC.) On Mon, Mar 31, 2014 at 10:32 AM, Aaron Ballman aa...@aaronballman.comwrote: Author: aaronballman Date: Mon Mar 31 12:32:39 2014 New Revision: 205226 URL: http://llvm.org/viewvc/llvm-project?rev=205226view=rev Log: Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lists to be handled properly, fixing the deprecated, type_visibility, and capability-related attributes with arguments. Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/test/Parser/cxx0x-attributes.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=205226r1=205225r2=205226view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Mon Mar 31 12:32:39 2014 @@ -1996,6 +1996,16 @@ private: /// locations where attributes are not allowed. void DiagnoseAndSkipCXX11Attributes(); + /// \brief Parses syntax-generic attribute arguments for attributes which are + /// known to the implementation, and adds them to the given ParsedAttributes + /// list with the given attribute syntax. + void ParseAttributeArgsCommon(IdentifierInfo *AttrName, +SourceLocation AttrNameLoc, +ParsedAttributes Attrs, SourceLocation *EndLoc, +IdentifierInfo *ScopeName, +SourceLocation ScopeLoc, +AttributeList::Syntax Syntax); + void MaybeParseGNUAttributes(Declarator D, LateParsedAttrList *LateAttrs = 0) { if (Tok.is(tok::kw___attribute)) { @@ -2053,6 +2063,13 @@ private: SourceLocation *EndLoc = 0); void ParseCXX11Attributes(ParsedAttributesWithRange attrs, SourceLocation *EndLoc = 0); + /// \brief Parses a C++-style attribute argument list. Returns true if this + /// results in adding an attribute to the ParsedAttributes list. + bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName, + SourceLocation AttrNameLoc, + ParsedAttributes Attrs, SourceLocation *EndLoc, + IdentifierInfo *ScopeName, + SourceLocation ScopeLoc); IdentifierInfo *TryParseCXX11AttributeIdentifier(SourceLocation Loc); Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=205226r1=205225r2=205226view=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Mar 31 12:32:39 2014 @@ -259,6 +259,65 @@ void Parser::ParseAttributeWithTypeArg(I 0, AttrNameLoc, 0, 0, AttributeList::AS_GNU); } +void Parser::ParseAttributeArgsCommon( +IdentifierInfo *AttrName, SourceLocation AttrNameLoc, +ParsedAttributes Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, +SourceLocation ScopeLoc, AttributeList::Syntax Syntax) { + // Ignore the left paren location for now. + ConsumeParen(); + + ArgsVector ArgExprs; + if (Tok.is(tok::identifier)) { +// If this attribute wants an 'identifier' argument, make it so. +bool IsIdentifierArg = attributeHasIdentifierArg(*AttrName); +AttributeList::Kind AttrKind = +AttributeList::getKind(AttrName, ScopeName, Syntax); + +// If we don't know how to parse this attribute, but this is the only +// token in this argument, assume it's meant to be an identifier. +if (AttrKind == AttributeList::UnknownAttribute || +AttrKind == AttributeList::IgnoredAttribute) { + const Token Next = NextToken(); + IsIdentifierArg = Next.is(tok::r_paren) || Next.is(tok::comma); +} + +if (IsIdentifierArg) + ArgExprs.push_back(ParseIdentifierLoc()); + } + + if (!ArgExprs.empty() ? Tok.is(tok::comma) : Tok.isNot(tok::r_paren)) { +// Eat the comma. +if (!ArgExprs.empty()) + ConsumeToken(); + +// Parse the non-empty comma-separated list of expressions. +do { + std::unique_ptrEnterExpressionEvaluationContext Unevaluated; + if (attributeParsedArgsUnevaluated(*AttrName)) +Unevaluated.reset( +new EnterExpressionEvaluationContext(Actions, Sema::Unevaluated)); + + ExprResult
Re: r205226 - Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lis
On Fri, Apr 11, 2014 at 5:38 PM, Richard Smith rich...@metafoo.co.uk wrote: Thanks for doing this! Looks like this won't reject the ill-formed construct [[deprecated()]]. (Both [[gnu::deprecated()]] and __attribute__((deprecated())) are OK, IIRC.) Good point! I'll add that on my TODO list. :-) Thanks! ~Aaron ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: [PATCH] CodeGen: Emit globals with a constant initializer but no definition as available_externally.
I don't think the `available_externally` check is right, but that looks like the right direction. http://reviews.llvm.org/D1982 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Thu, Apr 10, 2014 at 4:36 PM, Adrian Prantl apra...@apple.com wrote: On Apr 10, 2014, at 4:33 PM, Eric Christopher echri...@gmail.com wrote: Uh did you look at the code that added this stuff explicitly? Which stuff specifically are you referring to? The original patch that added the line information for global constructors made sure that they existed so we'd get a backtrace through them. I was away and on my phone when I sent the mail, my apologies, and still haven't looked at this patch yet, but figured I'd respond to this part. -eric -- adrian On Apr 10, 2014 4:31 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsDispose()) { llvm::Value *V = CGF.GetAddrOfLocalVar(src); Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Apr 10 18:21:53 2014 @@ -2504,7 +2504,10 @@ llvm::DICompositeType CGDebugInfo::getOr } /// EmitFunctionStart - Constructs the debug code for entering a function. -void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, +void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, +
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Apr 11, 2014, at 3:02 PM, Eric Christopher echri...@gmail.com wrote: On Thu, Apr 10, 2014 at 4:36 PM, Adrian Prantl apra...@apple.com wrote: On Apr 10, 2014, at 4:33 PM, Eric Christopher echri...@gmail.com wrote: Uh did you look at the code that added this stuff explicitly? Which stuff specifically are you referring to? The original patch that added the line information for global constructors made sure that they existed so we'd get a backtrace through them. I was away and on my phone when I sent the mail, my apologies, and still haven't looked at this patch yet, but figured I'd respond to this part. That makes more sense now. The problem is that the line number information itself was bogus. After this patch the global constructor still has a debug info entry, it just that the line table entry points to line 0 (which is the appropriate location for most artificial functions). I don’t think there is any other correct line to point _GLOBAL__I_a to. -- adrian -- adrian On Apr 10, 2014 4:31 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsDispose()) { llvm::Value *V = CGF.GetAddrOfLocalVar(src); Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=205999r1=205998r2=205999view=diff
Re: [PATCH] Modules - fix exclude header with umbrella directory
I chatted with Doug and we agreed this looks good to remove. You'll need to fix this test, probably by just removing the exclude header y/b.h, which looks wrong: FAIL: Clang :: Modules/exclude-header.c (3575 of 7161) http://reviews.llvm.org/D3090 ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206077 - [MS-ABI] Update to vtordisp computation
Author: whunt Date: Fri Apr 11 17:05:28 2014 New Revision: 206077 URL: http://llvm.org/viewvc/llvm-project?rev=206077view=rev Log: [MS-ABI] Update to vtordisp computation A portion of the vtordisp computation that was previously unguarded by a test for the declaration of user defined constructors/destructors was erroniously adding vtordisps to things that shouldn't have them. This patch correctly guards that codepath. In addition, it updates the comments to make them more clear. Test case is included. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp cfe/trunk/test/Layout/ms-x86-vtordisp.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206077r1=206076r2=206077view=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Apr 11 17:05:28 2014 @@ -2655,16 +2655,20 @@ void MicrosoftRecordLayoutBuilder::final } } -static bool -RequiresVtordisp(const llvm::SmallPtrSetconst CXXRecordDecl *, 2 HasVtordisp, - const CXXRecordDecl *RD) { - if (HasVtordisp.count(RD)) +// Recursively walks the non-virtual bases of a class and determines if any of +// them are in the bases with overridden methods set. +static bool RequiresVtordisp( +const llvm::SmallPtrSetconst CXXRecordDecl *, 2 +BasesWithOverriddenMethods, +const CXXRecordDecl *RD) { + if (BasesWithOverriddenMethods.count(RD)) return true; // If any of a virtual bases non-virtual bases (recursively) requires a // vtordisp than so does this virtual base. for (const auto I : RD-bases()) if (!I.isVirtual() -RequiresVtordisp(HasVtordisp, I.getType()-getAsCXXRecordDecl())) +RequiresVtordisp(BasesWithOverriddenMethods, + I.getType()-getAsCXXRecordDecl())) return true; return false; } @@ -2703,38 +2707,38 @@ MicrosoftRecordLayoutBuilder::computeVto if (bi.second.hasVtorDisp()) HasVtordispSet.insert(bi.first); } - // If we define a constructor or destructor and override a function that is - // defined in a virtual base's vtable, that virtual bases need a vtordisp. - // Here we collect a list of classes with vtables for which our virtual bases - // actually live. The virtual bases with this property will require - // vtordisps. In addition, virtual bases that contain non-virtual bases that - // define functions we override also require vtordisps, this case is checked - // explicitly below. - if (RD-hasUserDeclaredConstructor() || RD-hasUserDeclaredDestructor()) { -llvm::SmallPtrSetconst CXXMethodDecl *, 8 Work; -// Seed the working set with our non-destructor virtual methods. -for (const auto *I : RD-methods()) - if (I-isVirtual() !isaCXXDestructorDecl(I)) -Work.insert(I); -while (!Work.empty()) { - const CXXMethodDecl *MD = *Work.begin(); - CXXMethodDecl::method_iterator i = MD-begin_overridden_methods(), - e = MD-end_overridden_methods(); - if (i == e) -// If a virtual method has no-overrides it lives in its parent's vtable. -HasVtordispSet.insert(MD-getParent()); - else -Work.insert(i, e); - // We've finished processing this element, remove it from the working set. - Work.erase(MD); -} + // If we do not have a user declared constructor or destructor then we don't + // introduce any additional vtordisps. + if (!RD-hasUserDeclaredConstructor() !RD-hasUserDeclaredDestructor()) +return HasVtordispSet; + // Compute a set of base classes which define methods we override. A virtual + // base in this set will require a vtordisp. A virtual base that transitively + // contains one of these bases as a non-virtual base will also require a + // vtordisp. + llvm::SmallPtrSetconst CXXMethodDecl *, 8 Work; + llvm::SmallPtrSetconst CXXRecordDecl *, 2 BasesWithOverriddenMethods; + // Seed the working set with our non-destructor virtual methods. + for (const auto *I : RD-methods()) +if (I-isVirtual() !isaCXXDestructorDecl(I)) + Work.insert(I); + while (!Work.empty()) { +const CXXMethodDecl *MD = *Work.begin(); +CXXMethodDecl::method_iterator i = MD-begin_overridden_methods(), + e = MD-end_overridden_methods(); +// If a virtual method has no-overrides it lives in its parent's vtable. +if (i == e) + BasesWithOverriddenMethods.insert(MD-getParent()); +else + Work.insert(i, e); +// We've finished processing this element, remove it from the working set. +Work.erase(MD); } - // Re-check all of our vbases for vtordisp requirements (in case their - // non-virtual bases have vtordisp requirements). + // For each of our virtual bases, check if it is in the set of overridden + // bases or
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Fri, Apr 11, 2014 at 3:09 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:02 PM, Eric Christopher echri...@gmail.com wrote: On Thu, Apr 10, 2014 at 4:36 PM, Adrian Prantl apra...@apple.com wrote: On Apr 10, 2014, at 4:33 PM, Eric Christopher echri...@gmail.com wrote: Uh did you look at the code that added this stuff explicitly? Which stuff specifically are you referring to? The original patch that added the line information for global constructors made sure that they existed so we'd get a backtrace through them. I was away and on my phone when I sent the mail, my apologies, and still haven't looked at this patch yet, but figured I'd respond to this part. That makes more sense now. The problem is that the line number information itself was bogus. After this patch the global constructor still has a debug info entry, it just that the line table entry points to line 0 (which is the appropriate location for most artificial functions). I don't think there is any other correct line to point _GLOBAL__I_a to. Perhaps to the source information of the original variable, but I'll punt to Nick and Alexey on this one since they both have used this feature a bit more. Thanks! -eric -- adrian -- adrian On Apr 10, 2014 4:31 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsDispose()) { llvm::Value *V = CGF.GetAddrOfLocalVar(src);
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Apr 11, 2014, at 3:19 PM, Eric Christopher echri...@gmail.com wrote: On Fri, Apr 11, 2014 at 3:09 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:02 PM, Eric Christopher echri...@gmail.com wrote: On Thu, Apr 10, 2014 at 4:36 PM, Adrian Prantl apra...@apple.com wrote: On Apr 10, 2014, at 4:33 PM, Eric Christopher echri...@gmail.com wrote: Uh did you look at the code that added this stuff explicitly? Which stuff specifically are you referring to? The original patch that added the line information for global constructors made sure that they existed so we'd get a backtrace through them. I was away and on my phone when I sent the mail, my apologies, and still haven't looked at this patch yet, but figured I'd respond to this part. That makes more sense now. The problem is that the line number information itself was bogus. After this patch the global constructor still has a debug info entry, it just that the line table entry points to line 0 (which is the appropriate location for most artificial functions). I don't think there is any other correct line to point _GLOBAL__I_a to. Perhaps to the source information of the original variable, but I'll punt to Nick and Alexey on this one since they both have used this feature a bit more. To clarify, _GLOBAL__I_a is the compile-unit-wide function that invokes all the individual global constructors. For the individual constructors, we have a valid line, of course, but not for the _GLOBAL__I_a. -- adrian Thanks! -eric -- adrian -- adrian On Apr 10, 2014 4:31 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0,
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
So from looking at this it doesn't appear that we have any address range or location information for _GLOBAL__I_a anymore which is exactly what I was worried about: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) versus before: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_decl_file [DW_FORM_data1] (0x03) DW_AT_decl_line [DW_FORM_data1] (0x66) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) DW_AT_low_pc [DW_FORM_addr] (0x0020) DW_AT_high_pc [DW_FORM_data4] (0x000b) DW_AT_frame_base [DW_FORM_exprloc] (0x1 56 ) Now we don't have any note that this code belongs to this compile unit, etc. I think this part is incorrect. We should have scope and line information for this - even if it's line 0 etc. (Though I think the location of the variable would be a better one). -eric On Thu, Apr 10, 2014 at 4:21 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsDispose()) {
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Apr 11, 2014, at 3:24 PM, Eric Christopher echri...@gmail.com wrote: So from looking at this it doesn't appear that we have any address range or location information for _GLOBAL__I_a anymore which is exactly what I was worried about: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) versus before: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_decl_file [DW_FORM_data1] (0x03) DW_AT_decl_line [DW_FORM_data1] (0x66) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) DW_AT_low_pc [DW_FORM_addr] (0x0020) DW_AT_high_pc [DW_FORM_data4] (0x000b) DW_AT_frame_base [DW_FORM_exprloc] (0x1 56 ) Now we don't have any note that this code belongs to this compile unit, etc. I think this part is incorrect. We should have scope and line information for this - even if it's line 0 etc. (Though I think the location of the variable would be a better one). Interesting! That was unintentional. I’ll fix that. thanks, adrian -eric On Thu, Apr 10, 2014 at 4:21 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI,
Re: r205999 - Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
On Fri, Apr 11, 2014 at 3:26 PM, Adrian Prantl apra...@apple.com wrote: On Apr 11, 2014, at 3:24 PM, Eric Christopher echri...@gmail.com wrote: So from looking at this it doesn't appear that we have any address range or location information for _GLOBAL__I_a anymore which is exactly what I was worried about: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) versus before: 0x00d0: DW_TAG_subprogram [13] DW_AT_MIPS_linkage_name [DW_FORM_strp] ( .debug_str[0x0099] = _GLOBAL__I_a) DW_AT_decl_file [DW_FORM_data1] (0x03) DW_AT_decl_line [DW_FORM_data1] (0x66) DW_AT_artificial [DW_FORM_flag_present] (true) DW_AT_accessibility [DW_FORM_data1] (0x01) DW_AT_low_pc [DW_FORM_addr] (0x0020) DW_AT_high_pc [DW_FORM_data4] (0x000b) DW_AT_frame_base [DW_FORM_exprloc] (0x1 56 ) Now we don't have any note that this code belongs to this compile unit, etc. I think this part is incorrect. We should have scope and line information for this - even if it's line 0 etc. (Though I think the location of the variable would be a better one). Interesting! That was unintentional. I'll fix that. Thanks! -eric thanks, adrian -eric On Thu, Apr 10, 2014 at 4:21 PM, Adrian Prantl apra...@apple.com wrote: Author: adrian Date: Thu Apr 10 18:21:53 2014 New Revision: 205999 URL: http://llvm.org/viewvc/llvm-project?rev=205999view=rev Log: Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 Added: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=205999r1=205998r2=205999view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 10 18:21:53 2014 @@ -1135,6 +1135,7 @@ CodeGenFunction::GenerateBlockFunction(G // Begin generating the function. StartFunction(blockDecl, fnType-getReturnType(), fn, fnInfo, args, +blockDecl-getLocation(), blockInfo.getBlockExpr()-getBody()-getLocStart()); // Okay. Undo some of what StartFunction did. @@ -1306,7 +1307,7 @@ CodeGenFunction::GenerateCopyHelperFunct false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1476,7 +1477,7 @@ CodeGenFunction::GenerateDestroyHelperFu false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); - StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation()); + StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation()); AL.Emit(); llvm::Type *structPtrTy = blockInfo.StructureType-getPointerTo(); @@ -1765,7 +1766,7 @@ generateByrefCopyHelper(CodeGenFunction SC_Static, false, false); - CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation()); + CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation()); if (byrefInfo.needsCopy()) { llvm::Type *byrefPtrType = byrefType.getPointerTo(0); @@ -1834,7 +1835,7 @@ generateByrefDisposeHelper(CodeGenFuncti SourceLocation(), II, R, 0, SC_Static,
Re: [PATCH] Add support for optimization reports.
In this update: - Do not force line/column info generation. Rather, warn when -Rpass is used without debug info. - Fix BackendConsumer::OptimizationRemarkHandler to operate the same way as the other diagnostic handlers. If no debug information is available, use an empty SourceLocation object. - Fix the -Rpass test to make it independent of the optimization level used. Hi qcolombet, rsmith, http://reviews.llvm.org/D3226 CHANGE SINCE LAST DIFF http://reviews.llvm.org/D3226?vs=8323id=8491#toc Files: include/clang/Basic/Diagnostic.td include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticFrontendKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticIDs.h include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/Basic/DiagnosticIDs.cpp lib/CodeGen/CodeGenAction.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/TextDiagnosticPrinter.cpp test/Frontend/optimization-remark.c Index: include/clang/Basic/Diagnostic.td === --- include/clang/Basic/Diagnostic.td +++ include/clang/Basic/Diagnostic.td @@ -102,6 +102,7 @@ class DefaultWarnShowInSystemHeader { bit WarningShowInSystemHeader = 1; } +class DefaultRemark { DiagMapping DefaultMapping = MAP_REMARK; } // Definitions for Diagnostics. include DiagnosticASTKinds.td Index: include/clang/Basic/DiagnosticDriverKinds.td === --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -114,6 +114,11 @@ unknown or ill-formed Objective-C runtime '%0'; def err_drv_emit_llvm_link : Error -emit-llvm cannot be used when linking; +def err_drv_optimization_remark_pattern : Error + %0 in '%1'; +def warn_drv_optimization_remark_missing_loc : Warningoptimization remarks + will not show source location information (use -gline-tables-only + -gcolumn-info to enable it), InGroupBackendOptimizationRemark; def warn_O4_is_O3 : Warning-O4 is equivalent to -O3, InGroupDeprecated; def warn_drv_optimization_value : Warningoptimization level '%0' is unsupported; using '%1%2' instead, Index: include/clang/Basic/DiagnosticFrontendKinds.td === --- include/clang/Basic/DiagnosticFrontendKinds.td +++ include/clang/Basic/DiagnosticFrontendKinds.td @@ -32,6 +32,15 @@ def remark_fe_backend_plugin: Remark%0, CatBackend, InGroupRemarkBackendPlugin; def note_fe_backend_plugin: Note%0, CatBackend; +def err_fe_backend_optimization_remark: Remark%0, CatBackend, +InGroupBackendOptimizationRemark; +def warn_fe_backend_optimization_remark: Remark%0, CatBackend, +InGroupBackendOptimizationRemark; +def remark_fe_backend_optimization_remark: Remark%0, CatBackend, +InGroupBackendOptimizationRemark, DefaultRemark; +def note_fe_backend_optimization_remark: Remark%0, CatBackend, +InGroupBackendOptimizationRemark; + def err_fe_invalid_code_complete_file : Error cannot locate code-completion file %0, DefaultFatal; def err_fe_stdout_binary : Errorunable to change standard output to binary, Index: include/clang/Basic/DiagnosticGroups.td === --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -665,3 +665,4 @@ def BackendFrameLargerThan : DiagGroupframe-larger-than; def BackendPlugin : DiagGroupbackend-plugin; def RemarkBackendPlugin : DiagGroupremark-backend-plugin; +def BackendOptimizationRemark : DiagGrouppass; Index: include/clang/Basic/DiagnosticIDs.h === --- include/clang/Basic/DiagnosticIDs.h +++ include/clang/Basic/DiagnosticIDs.h @@ -154,6 +154,9 @@ /// default. static bool isDefaultMappingAsError(unsigned DiagID); + /// \brief Return true if the specified diagnostic is a Remark. + static bool isRemark(unsigned DiagID); + /// \brief Determine whether the given built-in diagnostic ID is a Note. static bool isBuiltinNote(unsigned DiagID); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -60,6 +60,7 @@ def M_Group : OptionGroupM group, GroupCompileOnly_Group; def T_Group : OptionGroupT group; def O_Group : OptionGroupO group, GroupCompileOnly_Group; +def R_Group : OptionGroupR group, GroupCompileOnly_Group; def W_Group : OptionGroupW group, GroupCompileOnly_Group; def d_Group : OptionGroupd group; def f_Group : OptionGroupf group, GroupCompileOnly_Group; @@ -253,7 +254,9 @@ def Qunused_arguments : Flag[-], Qunused-arguments, Flags[DriverOption, CoreOption], HelpTextDon't emit
Re: [PATCH] preview patch for fixit for finding modules needing import/inclusion
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6961-6963 @@ -6960,6 +6960,5 @@ __module_private__; -def err_module_private_declaration : Error - declaration of %0 must be imported from module '%1' before it is required; -def err_module_private_definition : Error - definition of %0 must be imported from module '%1' before it is required; +def warn_need_module_import : Warning + use of identifier '%0' requires import/inclusion of the module '%1', + InGroupNeedImport; def err_module_import_in_extern_c : Error This shouldn't be a `Warning`. If we really want to allow this as an extension (and I don't see why we should), it should be an `ExtWarn`, and should be `DefaultError`. Comment at: include/clang/Driver/Options.td:671-673 @@ -667,2 +670,5 @@ Flags[DriverOption]; +def fno_modules_search_all : Flag [-], fno-modules-search-all, Groupf_Group, + Flags[DriverOption, CC1Option], + HelpTextInhibit search of non-imported modules to resolve references; def fno_ms_extensions : Flag[-], fno-ms-extensions, Groupf_Group; Only the non-default value of the flag should have `HelpText`. Comment at: include/clang/Frontend/CompilerInstance.h:154 @@ -150,3 +153,3 @@ public: - CompilerInstance(); + CompilerInstance(bool BuildingModuleFlag = false); ~CompilerInstance(); This constructor should be `explicit`. Also, just `BuildingModule`, not `BuildingModuleFlag`. Comment at: lib/Frontend/CompilerInstance.cpp:857 @@ -853,3 +856,3 @@ // module. - CompilerInstance Instance; + CompilerInstance Instance(true); Instance.setInvocation(*Invocation); `Instance(/*BuildingModule=*/true);` would be more obvious. Comment at: lib/Frontend/CompilerInstance.cpp:1427 @@ +1426,3 @@ + if (!HaveFullGlobalModuleIndex GlobalIndex !buildingModule()) { +ModuleMap MMap = getPreprocessor().getHeaderSearchInfo().getModuleMap(); +bool recreateIndex = false; Do we need to take any other steps to ensure we've actually loaded all the modulemap files that are within our include paths? Comment at: lib/Frontend/CompilerInvocation.cpp:1347-1349 @@ -1346,2 +1346,5 @@ Opts.ModulesDeclUse = Args.hasArg(OPT_fmodules_decluse); + Opts.ModulesSearchAll = Opts.Modules + (!Args.hasArg(OPT_fno_modules_search_all) || + Args.hasArg(OPT_fmodules_search_all)); Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); I think this should default to off. It still makes diagnostics non-reproducible (because it depends on what other modules happen to be in the global index at the point when we perform typo correction), and may have a *very* significant runtime penalty if we hit a diagnostic. Comment at: lib/Sema/SemaDecl.cpp:10072 @@ -10072,1 +10071,3 @@ + LookupOrdinaryName, S, 0, Validator, + 0, false, 0, true, false))) diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion), I really don't like this collection of unexplained mystery arguments (repeating the default arguments for all but the last). Maybe move the error recovery flag earlier, and change it to an `enum class` so its values can have more obvious names (and won't accidentally convert to `bool`)? Comment at: lib/Sema/SemaLookup.cpp:4067 @@ +4066,3 @@ + if (ErrorRecovery !Loader.buildingModule() + getLangOpts().Modules getLangOpts().ModulesSearchAll) { +// Load global module index, or retrieve a previously loaded one. `` should go on the previous line. Comment at: lib/Sema/SemaLookup.cpp:4075-4109 @@ +4074,37 @@ + + // Find the modules that reference the identifier. + // Note that this only finds top-level modules. + // We'll let diagnoseTypo find the actual declaration module. + if (GlobalIndex-lookupIdentifier(Typo-getName(), FoundModules)) { +TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0, 0); +TC.setCorrectionRange(SS, TypoName); +// Walk the found modules that reference the identifier. +for (GlobalModuleIndex::HitSet::iterator I = FoundModules.begin(), +E = FoundModules.end(); I != E; ++I) { + ModuleFile *TheModuleFile = *I; + // Find the module from the file name. + Module *TheModule = PP.getHeaderSearchInfo().lookupModuleFromFile( +TheModuleFile-FileName); + assert(TheModule Should be able to find the module.); + // Make the module visible so we can do a name lookup. + Loader.makeModuleVisible(TheModule, Module::AllVisible, +TypoName.getLoc(), false); + // Do a name lookup. + LookupResult ModRes(*this, TypoName, LookupKind); +
Re: [PATCH] Fix In file included from for files generated with -frewrite-includes
Makes perfect sense, and patch LGTM. Thanks! On Fri, Apr 4, 2014 at 3:16 AM, Lubos Lunak l.lu...@centrum.cz wrote: Option -frewrite-includes comments out #include directives it replaces by enclosing it in #if 0, which moves the included contents, changing their perceived line numbers e.g. in the In file included from messages in a follow-up compilation: $ cat b.cpp #include b.h $ cat b.h void f() { int unused_variable; } $ clang++ -E -frewrite-includes b.cpp | clang++ -Wall -x c++ -c - In file included from b.cpp:4: ./b.h:3:9: warning: unused variable 'unused_variable' [-Wunused-variable] int unused_variable; ^ 1 warning generated. $ clang++ -Wall -c b.cpp In file included from b.cpp:1: ./b.h:3:9: warning: unused variable 'unused_variable' [-Wunused-variable] int unused_variable; ^ 1 warning generated. The attached patch fixes this. -- Lubos Lunak ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
libc++ PATCH: Fixes /lib/CMakeLists.txt for Apple ARM targets
Dear all, I have noticed that due to some minor syntax typos in /lib/CMakeLists.txt, the file /lib/libc++abi.exp is incorrectly referenced as the reexported symbol list for Apple ARM targets (it should instead be /lib/libc++sjlj-abi.exp for these targets). Please find in the following a patch to fix this issue on revision r206024. Best regards, Quentin --- lib/CMakeLists.txt.old 2014-04-11 23:40:24.0 +0200 +++ lib/CMakeLists.txt 2014-04-11 23:41:50.0 +0200 @@ -60,9 +60,9 @@ if ( APPLE ) -Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp /usr/lib/libSystem.B.dylib) else() -if ( ${CMAKE_OSX_SYSROOT} ) - list(FIND ${CMAKE_OSX_ARCHITECTURES} armv7 OSX_HAS_ARMV7) - if (OSX_HAS_ARMV7) +if ( NOT ${CMAKE_OSX_SYSROOT} STREQUAL ) + list(FIND CMAKE_OSX_ARCHITECTURES armv7 OSX_HAS_ARMV7) + if ( NOT ${OSX_HAS_ARMV7} STREQUAL -1 ) set(OSX_RE_EXPORT_LINE ${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp) ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
r206081 - CodeGen: Fix handling of C++11 lambdas in profiling
Author: bogner Date: Fri Apr 11 18:06:35 2014 New Revision: 206081 URL: http://llvm.org/viewvc/llvm-project?rev=206081view=rev Log: CodeGen: Fix handling of C++11 lambdas in profiling Until now we were generating duplicate counters for lambdas: one set in the function where the lambda was declared and another for the lambda itself. Instead, we should skip over the bodies of lambdas in their containing contexts. Added: cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata cfe/trunk/test/Profile/cxx-lambda.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206081r1=206080r2=206081view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 18:06:35 2014 @@ -331,9 +331,10 @@ namespace { MapRegionCounters(llvm::DenseMapconst Stmt *, unsigned CounterMap) : NextCounter(0), CounterMap(CounterMap) {} -// Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl -// is handled as a separate function. -bool TraverseBlockExpr(BlockExpr *block) { return true; } +// Blocks and lambdas are handled as separate functions, so we need not +// traverse them in the parent context. +bool TraverseBlockExpr(BlockExpr *BE) { return true; } +bool TraverseLambdaBody(LambdaExpr *LE) { return true; } bool VisitDecl(const Decl *D) { switch (D-getKind()) { @@ -431,6 +432,11 @@ namespace { Visit(D-getBody()); } +// Skip lambda expressions. We visit these as FunctionDecls when we're +// generating them and aren't interested in the body when generating a +// parent context. +void VisitLambdaExpr(const LambdaExpr *LE) {} + void VisitObjCMethodDecl(const ObjCMethodDecl *D) { // Counter tracks entry to the method body. RegionCounter Cnt(PGO, D-getBody()); Added: cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata?rev=206081view=auto == --- cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata (added) +++ cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata Fri Apr 11 18:06:35 2014 @@ -0,0 +1,20 @@ +cxx-lambda.cpp:_ZZ7lambdasvENK3$_0clEi +3 +3 +10 +9 +9 + +main +1 +1 +1 + +_Z7lambdasv +4 +4 +1 +1 +10 +1 + Added: cfe/trunk/test/Profile/cxx-lambda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-lambda.cpp?rev=206081view=auto == --- cfe/trunk/test/Profile/cxx-lambda.cpp (added) +++ cfe/trunk/test/Profile/cxx-lambda.cpp Fri Apr 11 18:06:35 2014 @@ -0,0 +1,57 @@ +// Tests for instrumentation of C++11 lambdas + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate %tgen +// RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%S/Inputs/cxx-lambda.profdata %tuse +// RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s +// RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s + +// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = global [4 x i64] zeroinitializer +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = global [1 x i64] zeroinitializer +// LMBGEN: @[[LFC:__llvm_profile_counters__ZZ7lambdasvENK3\$_0clEi]] = internal global [3 x i64] zeroinitializer + +// PGOGEN-LABEL: define void @_Z7lambdasv() +// PGOUSE-LABEL: define void @_Z7lambdasv() +// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 0 +void lambdas() { + int i = 1; + + // LMBGEN-LABEL: define internal zeroext i1 @_ZZ7lambdasvENK3$_0clEi( + // LMBUSE-LABEL: define internal zeroext i1 @_ZZ7lambdasvENK3$_0clEi( + // LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 0 + auto f = [i](int k) { +// LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 1 +// LMBUSE: br {{.*}} !prof ![[LF1:[0-9]+]] +if (i 0) {} +// LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 2 +// LMBUSE: br {{.*}} !prof ![[LF2:[0-9]+]] +return k i; + }; + + // PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[LW1:[0-9]+]] + if (i) {} + + // PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 2 + // PGOUSE: br {{.*}} !prof ![[LW2:[0-9]+]] + for (i = 0; i 10; ++i) +f(9 - i); + + // PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 3 + // PGOUSE: br {{.*}} !prof ![[LW3:[0-9]+]] + if (i) {} +} + +// PGOUSE-DAG: ![[LW1]] = metadata !{metadata !branch_weights, i32 2, i32 1} +// PGOUSE-DAG: ![[LW2]] = metadata !{metadata !branch_weights, i32 11, i32 2}