[PATCH] D24812: Lit C++11 Compatibility Patch #11
probinson added a reviewer: rjmccall. probinson added a comment. +rjmccall as CodeGen owner. https://reviews.llvm.org/D24812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++
probinson added a comment. These are all Objective-C++ tests, and AFAIK we don't intend to change the default Objective-C++ dialect when we finally do change the default C++ dialect. So I think these tests do not need to be modified. https://reviews.llvm.org/D29739 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++
probinson added a comment. In https://reviews.llvm.org/D29739#673971, @rjmccall wrote: > In https://reviews.llvm.org/D29739#673933, @tigerleapgorge wrote: > > > Hi John, > > > > Here is the most recent discussion I can find on cfe-dev. > > “I'm guessing that Objective-C/C++ is kind of passe, so nobody is really > > interested in modernizing it” > > http://lists.llvm.org/pipermail/cfe-dev/2016-December/051844.html > > > > As far as I am aware, there appears to be no strong reason to bump or not > > to bump ObjC++. > > > It certainly simplifies the message to say that we've changed the default C++ > dialect to C++11 across the board. That should apply to ObjC++ as well. I > would not describe ObjC++ as passé; it's a very important language for Apple > developers. Nice to know, although nobody piped up on the earlier cited discussion. Sony is invested in making the lit tests C++11 clean so that we can upstream a change to make it the default C++ dialect for PS4. That will ensure that any new C++ tests are C++11 clean. This is one step in the direction of making C++11 (or even something newer) the default dialect for everybody. However we are not an Objective-C++ vendor. We are neutral about changing the default dialect there; if you want to change the default dialect for Objective-C++, that's fine with us, but I don't think we can invest in learning enough about Objective-C++ to do the right thing with the existing Objective-C++ tests. In particular I don't know whether forcing 98 on these tests is the "right" solution; all we know is that it made the tests pass, which is not particularly surprising. I really think Apple would need to step up here if the default Objective-C++ dialect is going to change. > It is likely that the Rewriter generates C++98-only code. I believe the > Rewriter is no longer being actively maintained; I'm not sure we're ready to > propose removing it yet, but if there are specific problems with those tests, > I think it makes some sense to just pass -std=gnu++98 for them. > > John. I am pretty sure we already modified the Rewriter tests to explicitly compile the rewritten C++ as -98 code. It's just the straight Objective-C++ tests where Charles has stepped back. --paulr https://reviews.llvm.org/D29739 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++
probinson added a comment. In https://reviews.llvm.org/D29739#674297, @rjmccall wrote: > In https://reviews.llvm.org/D29739#674288, @probinson wrote: > > > I really think Apple would need to step up here if the default > > Objective-C++ dialect is going to change. > > > I don't mind stepping up and doing this work. I just thought you'd already > done it. This patch updates some tests; is that enough, or are there further > changes required in order to change the default ObjC++ dialect? > > John. Charles tells me this is the last group of Objective-C++ tests that failed, so maybe there isn't anything else to do after all. I had thought there were more. He'll go ahead with this set. We have another couple dozen C++ tests to straighten out, then we'll be ready to have the dev-list discussion about upgrading the default for 5.0, and whether it's the narrow case (just C++ and just for PS4, which was our original plan) or the big bang (both languages and for everybody). https://reviews.llvm.org/D29739 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#675687, @chandlerc wrote: > In https://reviews.llvm.org/D28404#675616, @mehdi_amini wrote: > > > We're still waiting for @rsmith to comment whether it'd be better to `have > > a LangOpts flag that basically means "pragma clang optimize off is always > > in effect."` and `Have Sema pretend the pragma is in effect at all times, > > at -O0`. > > > FWIW, I have no real opinion about this side of it, I see it more as a detail > of how Clang wants to implement this kind of thing. That was my suggestion as it seemed like this patch is essentially replicating the attribute-conflict detection logic that's in place for attributes specified in the source. And we do like to say DRY. But I won't insist; the patch can proceed as far as I'm concerned. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28620: Guard __gnuc_va_list typedef
This revision was automatically updated to reflect the committed changes. Closed by commit rL292819: Guard __gnuc_va_list typedef. (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D28620?vs=84151=85430#toc Repository: rL LLVM https://reviews.llvm.org/D28620 Files: cfe/trunk/lib/Headers/stdarg.h cfe/trunk/test/Headers/stdarg-gnuc_va_list.c Index: cfe/trunk/test/Headers/stdarg-gnuc_va_list.c === --- cfe/trunk/test/Headers/stdarg-gnuc_va_list.c +++ cfe/trunk/test/Headers/stdarg-gnuc_va_list.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s +// expected-no-diagnostics + +// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has +// previously been defined in another header file. +typedef __builtin_va_list __va_list; +typedef __va_list __gnuc_va_list; +#define __GNUC_VA_LIST + +#include Index: cfe/trunk/lib/Headers/stdarg.h === --- cfe/trunk/lib/Headers/stdarg.h +++ cfe/trunk/lib/Headers/stdarg.h @@ -43,10 +43,9 @@ #define va_copy(dest, src) __builtin_va_copy(dest, src) #endif -/* Hack required to make standard headers work, at least on Ubuntu */ #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1 -#endif typedef __builtin_va_list __gnuc_va_list; +#endif #endif /* __STDARG_H */ Index: cfe/trunk/test/Headers/stdarg-gnuc_va_list.c === --- cfe/trunk/test/Headers/stdarg-gnuc_va_list.c +++ cfe/trunk/test/Headers/stdarg-gnuc_va_list.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s +// expected-no-diagnostics + +// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has +// previously been defined in another header file. +typedef __builtin_va_list __va_list; +typedef __va_list __gnuc_va_list; +#define __GNUC_VA_LIST + +#include Index: cfe/trunk/lib/Headers/stdarg.h === --- cfe/trunk/lib/Headers/stdarg.h +++ cfe/trunk/lib/Headers/stdarg.h @@ -43,10 +43,9 @@ #define va_copy(dest, src) __builtin_va_copy(dest, src) #endif -/* Hack required to make standard headers work, at least on Ubuntu */ #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1 -#endif typedef __builtin_va_list __gnuc_va_list; +#endif #endif /* __STDARG_H */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
probinson added a comment. As dblaikie said in email, probably better to make this X86-specific; if long-double varies by OS you can put in a specific triple. FTR we don't rely on Perl being available everywhere, anything that does this kind of scripty stuff uses Python. Comment at: test/CodeGen/debug-info-static-const-fp.c:1 -// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s +// RUN: %clang -emit-llvm -O0 -S -g %s -o %t +// RUN: perl <%t >%t-check-prefix -n -e \ Sorry didn't notice this before, %clang is for driver tests only; use %clang_cc1 here. https://reviews.llvm.org/D27597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)
probinson added inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:350 + std::string Checksum; + SM.getChecksumMD5(SM.getFileID(Loc), Checksum); + rnk wrote: > We should only do this if `CGM.getCodeGenOpts().EmitCodeView`, or we will > regress compile time on other platforms without any added functionality. Eventually we'll want it for DWARF 5 also, but for now conditioning on CodeView is fine. https://reviews.llvm.org/D27641 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27597: [DebugInfo] Restore test case for long double constants.
probinson accepted this revision. probinson added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D27597#621618, @dgross wrote: > So would a Python equivalent of the Perl be acceptable? I think this is an > academic question -- better to explicitly test multiple triples. There are a small number of tests that run Python scripts, but they are generally doing something really unusual (I admit I haven't gone to look, but that's my recollection). If you can get proper coverage without Python, and it doesn't require standing on your head, people generally prefer that. In this case, multiple RUNs with different triples will do the job, so that's preferable. LGTM. https://reviews.llvm.org/D27597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27794: Make some diagnostic tests C++11 clean
probinson added a reviewer: ABataev. probinson added a comment. +abataev for OpenMP. https://reviews.llvm.org/D27794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27794: Make some diagnostic tests C++11 clean
probinson created this revision. probinson added a reviewer: rsmith. probinson added subscribers: cfe-commits, tigerleapgorge. Another half-dozen test revisions in the ongoing campaign to make things ready for C++11 as Clangs's default dialect. Most of these are straightforward, but I am not entirely sure about a couple of things: - In fixit.cpp, the place that now gets 'expected unqualified-id' seems funny, but maybe that's just the nature of things - In copy-assignment.cpp, I am bemused by the whole thing but especially 'passing argument to parameter here' https://reviews.llvm.org/D27794 Files: test/FixIt/fixit.cpp test/OpenMP/teams_distribute_collapse_messages.cpp test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp test/Parser/backtrack-off-by-one.cpp test/SemaCXX/copy-assignment.cpp Index: test/SemaCXX/copy-assignment.cpp === --- test/SemaCXX/copy-assignment.cpp +++ test/SemaCXX/copy-assignment.cpp @@ -1,12 +1,22 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 + +#if __cplusplus >= 201103L +// expected-note@+3 2 {{candidate constructor}} +// expected-note@+2 {{passing argument to parameter here}} +#endif struct A { }; struct ConvertibleToA { operator A(); }; struct ConvertibleToConstA { +#if __cplusplus >= 201103L +// expected-note@+2 {{candidate function}} +#endif operator const A(); }; @@ -69,6 +79,9 @@ na = a; na = constA; na = convertibleToA; +#if __cplusplus >= 201103L +// expected-error@+2 {{no viable conversion}} +#endif na = convertibleToConstA; na += a; // expected-error{{no viable overloaded '+='}} Index: test/Parser/backtrack-off-by-one.cpp === --- test/Parser/backtrack-off-by-one.cpp +++ test/Parser/backtrack-off-by-one.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify %s -std=c++98 +// RUN: %clang_cc1 -verify %s -std=c++11 // PR25946 // We had an off-by-one error in an assertion when annotating A below. Our @@ -10,8 +12,10 @@ // expected-error@+1 {{expected '{' after base class list}} template class B : T // not ',' or '{' -// expected-error@+3 {{C++ requires a type specifier for all declarations}} -// expected-error@+2 {{expected ';' after top level declarator}} +#if __cplusplus < 201103L +// expected-error@+4 {{expected ';' after top level declarator}} +#endif +// expected-error@+2 {{C++ requires a type specifier for all declarations}} // expected-error@+1 {{expected ';' after class}} A { }; Index: test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp === --- test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp +++ test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp @@ -1,8 +1,13 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp %s -std=c++98 +// RUN: %clang_cc1 -verify -fopenmp %s -std=c++11 void foo() { } +#if __cplusplus >= 201103L +// expected-note@+2 4 {{declared here}} +#endif bool foobool(int argc) { return argc; } @@ -50,6 +55,9 @@ for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+6 2 {{non-constexpr function 'foobool' cannot be used}} +#endif // expected-error@+4 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'collapse' clause}} // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}} // expected-error@+2 2 {{expression is not an integral constant expression}} @@ -62,7 +70,11 @@ for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; -// expected-error@+2 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L +// expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}} +#else +// expected-error@+3 2 {{expression is not an integral constant expression}} +#endif #pragma omp target #pragma omp teams distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) @@ -110,11 +122,17 @@ for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+3 {{non-constexpr function 'foobool' cannot be used}} +#endif #pragma omp target
[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.
probinson added subscribers: cfe-commits, probinson. probinson added a comment. Hi David! As this is a Clang patch, you should subscribe cfe-commits rather than llvm-commits. I've done that for you. See also inline comments. Comment at: lib/CodeGen/CGDebugInfo.cpp:3765 +InitExpr = + DBuilder.createConstantValueExpression(Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( This line exceeds 80 columns. clang-format is your friend. Comment at: test/CodeGen/debug-info-static-const-fp.c:19 +// CHECK: !4 = distinct !DIGlobalVariable(name: "hVal", scope: !0, file: !1, line: 6, type: !5, isLocal: true, isDefinition: true, expr: !7) +// CHECK: !7 = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) +// CHECK: !8 = distinct !DIGlobalVariable(name: "fVal", scope: !0, file: !1, line: 8, type: !9, isLocal: true, isDefinition: true, expr: !11) Checking for the entire exact line for the variable is a bit fragile. Really what you want to do is associate the variable with the correct expression, and ignore all the irrelevant details. Something like this: ``` // CHECK: DIGlobalVariable(name: "hVal", {{.*}} expr: ![[HEXPR:{{[0-9]+}}]] // CHECK: ![[HEXPR] = ! DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) ``` And similar pairs for the other variables. I'd use a different FileCheck variable for each case. https://reviews.llvm.org/D27549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.
probinson accepted this revision. probinson added a reviewer: probinson. probinson added a comment. This revision is now accepted and ready to land. LGTM. Comment at: lib/CodeGen/CGDebugInfo.cpp:3765 +InitExpr = + DBuilder.createConstantValueExpression(Init.getFloat().bitcastToAPInt().getZExtValue()); GV.reset(DBuilder.createGlobalVariable( dgross wrote: > probinson wrote: > > This line exceeds 80 columns. clang-format is your friend. > Done. Is clang-format mentioned in any of the documentation that describes > the development process? I might have missed it (not that that's an excuse > for a needless violation of the coding guidelines). I would have thought the coding guidelines would mention clang-format, but I'm not finding it there (or in the stuff about submitting a patch). https://reviews.llvm.org/D27549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. I guess I'm getting irritated because people are trying to tell me what optnone means. I know what it means; I spent probably a whole year pushing to get it adopted. Optnone means: When you are running optimizations, try not to optimize this part, if you can. That's it. That's *all*. It has never meant anything else. Telling me different means you misunderstand, and trying to persuade me that *I* misunderstand is going to be a waste of time and effort. I fully understand that this is not the definition of optnone that you *want*. Please feel free to propose a redefinition. But don't go telling me that the thing you *want* is what the thing already *is* and that any difference is a bug. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. Basically, I don't see why having clang always emit a real .o at -O0 would be a problem. I haven't gotten through the other-CFI documentation yet though. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640182, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640178, @mehdi_amini wrote: > > > Also, that's not practicable: what if I have an LTO static library for > > which I don't have the source, now if I build my own file with -O0 -flto I > > can't link anymore. > > > Also: LTO is required for some features likes CFI. There are users who wants > CFI+O0 during development (possibly for debugging a subcomponent of the app). Sorry, you lost me. CFI is part of DWARF and we do DWARF perfectly well without LTO (and at O0). https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640314, @mehdi_amini wrote: > I don't follow: IMO if I generate a module with optnone and pipe it to `opt > -O3` I expect no function IR to be touched. If it is not the case it is a bug. Your opinion and expectation are not supported by the IR spec. Optnone skips "most" optimization passes. It is not practical (or was not, at the time) to make the -O3 pipeline behave exactly the same as the -O0 pipeline, and also not actually necessary to support the purpose for which 'optnone' was invented. If you have a goal of making 'optnone' functions use the actual -O0 pipeline, while non-optnone functions use the optimizing pipeline, more power to you and you will need to take up that particular design challenge with Chandler first. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640362, @probinson wrote: > In https://reviews.llvm.org/D28404#640314, @mehdi_amini wrote: > > > I don't follow: IMO if I generate a module with optnone and pipe it to `opt > > -O3` I expect no function IR to be touched. If it is not the case it is a > > bug. > > > Your opinion and expectation are not supported by the IR spec. Optnone skips > "most" optimization passes. It is not practical (or was not, at the time) to > make the -O3 pipeline behave exactly the same as the -O0 pipeline, and also > not actually necessary to support the purpose for which 'optnone' was > invented. > > If you have a goal of making 'optnone' functions use the actual -O0 pipeline, > while non-optnone functions use the optimizing pipeline, more power to you > and you will need to take up that particular design challenge with Chandler > first. Oh, maybe you are thinking of eliminating the -O0 pipeline? Because if -O0 implies optnone then it's kinda-sorta the same thing as the optimization pipeline operating on nothing but optnone functions? I'd think that would make -O0 compilations slow down, which would not be a feature. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640588, @mehdi_amini wrote: > Actually, as mentioned before, I could be fine with making `O0` incompatible > with LTO, however security features like CFI (or other sort of whole-program > analyses/instrumentations) requires LTO. Well, "requires LTO" is overstating the case, AFAICT from the link you gave me. Doesn't depend on //optimization// at all. It depends on some interprocedural analyses given some particular scope/visibility boundary, which it is convenient to define as a set of linked bitcode modules, that by some happy chance is the same set of linked bitcode modules that LTO will operate on. If it's important to support combining a bitcode version of my-application with your-bitcode-library for this CFI or whatever, and you also want to let me have my-application be unoptimized while your-bitcode-library gets optimized, NOW we have a use-case. (Maybe that's what you had in mind earlier, but for some reason I wasn't able to extract that out of any prior comments. No matter.) I'm now thinking along the lines of a `-foptimize-off` flag (bikesheds welcome) which would set the default for the pragma to 'off'. How is that different than what you wanted for `-O0`? It is defined in terms of an existing pragma, which is WAY easier to explain and WAY easier to implement. And, it still lets us say that `-c -O0 -flto` is a mistake, if that seems like a useful thing to say. Does that seem reasonable? Fit your understanding of the needs? https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640170, @probinson wrote: > In my experience, modifying source Note that the source modification consists of adding `#pragma clang optimize off` to the top of the file. It is not a complicated thing. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640314, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640284, @probinson wrote: > > > In https://reviews.llvm.org/D28404#640178, @mehdi_amini wrote: > > > > > In https://reviews.llvm.org/D28404#640170, @probinson wrote: > > > > > > > In my experience, modifying source is by far simpler than hacking a > > > > build system to make a special case for compiler options for one module > > > > in an application. (If you have a way to build Clang with everything > > > > done LTO except one module built with -O0, on Linux with ninja, I would > > > > be very curious to hear how you do that.) > > > > > > > > > Static library, separated projects, etc. > > > We have tons of users... > > > > > > Still waiting. > > > Waiting for what? > We have use-cases, I gave you a few (vendor static libraries are one). > Again, if you think it is wrong to support O0 and LTO, then please elaborate. Your original use-case described debugging a module in an application. You claimed it was simpler to change the build options for a module than change the source, which I am still waiting to hear how/why that is simpler. Your subsequent use cases are about entire sub-projects, which is entirely different and orthogonal to where you started. Please elaborate on the original use case. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640314, @mehdi_amini wrote: > You just wrote above that " mixing -O0 and LTO " is wrong, *if* I were to > agree with you at some point, then I'd make it a hard error. Yes, I was not clear that I meant that `-O0 -flto` on the same clang command line just seems nonsensical. "Optimize my program without optimizing it" forsooth. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#639887, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#639874, @probinson wrote: > > > Over the weekend I had a thought: Why is -O0 so special here? That is, > > after going to all this trouble to propagate -O0 to LTO, how does this > > generalize to propagating -O1 or any other specific -O option? (Maybe this > > question would be better dealt with on the dev list...) > > > O0 is "special" like Os and Oz because we have an attribute for it and passes > "know" how to handle this attribute. > I guess no-one cares enough about > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//O3 > to find a solution for these (in the context of LTO, I don't really care > about > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2/). > It is likely that Og would need a special treatment at some point, maybe > with a new attribute as well, to inhibit optimization that can't preserve > debug info properly. "I don't care" doesn't seem like much of a principle. Optnone does not equal -O0. It is a debugging aid for the programmer, because debugging optimized code sucks. If you have an LTO-built application and want to de-optimize parts of it to aid with debugging, then you can use the pragma, as originally intended. I don't think `-c -O0 -flto` should get this not-entirely-O0-like behavior. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640178, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640170, @probinson wrote: > > > In https://reviews.llvm.org/D28404#640090, @mehdi_amini wrote: > > > > > In https://reviews.llvm.org/D28404#640046, @probinson wrote: > > > > > > > "I don't care" doesn't seem like much of a principle. > > > > > > > > > Long version is: "There is no use-case, no users, so I don't have much > > > motivation to push it forward for the only sake of completeness". Does it > > > sound enough of a principle like that? > > > > > > No. You still need to have adequate justification for your use case, which > > I think you do not. > > > I don't follow your logic. > IIUC, you asked about "why not supporting `O1/O2/O3`" ; how is *not > supporting* these because their not useful / don't have use-case related to > "supporting `O0` is useful"? Upfront, it seemed peculiar to handle only one optimization level. After more thought, the whole idea of mixing -O0 and LTO seems wrong. Sorry, should have signaled that I had changed my mind about it. Optnone does not equal -O0. It is a debugging aid for the programmer, because debugging optimized code sucks. If you have an LTO-built application and want to de-optimize parts of it to aid with debugging, then you can use the pragma, as originally intended. >>> >>> Having to modifying the source isn't friendly. Not being able to honor -O0 >>> during LTO is not user-friendly. >> >> IMO, '-O0' and '-flto' are conflicting options and therefore not deserving >> of special support. > > You're advocating for *rejecting* O0 built module at link-time? We'd still > need to detect this though. Status-quo isn't acceptable. > Also, that's not practicable: what if I have an LTO static library for which > I don't have the source, now if I build my own file with -O0 -flto I can't > link anymore. No, I'm saying they are conflicting options on the same Clang command line. As long as your linker can handle foo.o and bar.bc on the same command line, not a problem. (If your linker can't handle that, fix the linker first.) >> In my experience, modifying source is by far simpler than hacking a build >> system to make a special case for compiler options for one module in an >> application. (If you have a way to build Clang with everything done LTO >> except one module built with -O0, on Linux with ninja, I would be very >> curious to hear how you do that.) > > Static library, separated projects, etc. > We have tons of users... Still waiting. Your up-front use case was about de-optimizing a module to assist debugging it within an LTO-built application, not building entire projects one way versus another. If that is not actually your use case, you need to start over with the correct description. I don't think `-c -O0` should get this not-entirely-O0-like behavior. >>> >>> What is "not-entirely"? And why do you think that? >> >> "Not entirely" means that running the -O0 pipeline, and running an >> optimization pipeline but asking some subset of passes to turn themselves >> off, does not get you the same result. And I think that because I'm the one >> who put 'optnone' upstream in the first place. The case that particularly >> sticks in my memory is the register allocator, but I believe there are >> passes at every stage that do not turn themselves off for optnone. > > That's orthogonal: you're saying we are not handling it correctly yet, I'm > just moving toward *fixing* all these. It's not orthogonal; that's exactly how 'optnone' behaves today. If you have proposed a redesign of how to mix optnone and non-optnone functions in the same compilation unit, in some way other than what's done today, I am not aware of it; can you point to your proposal? https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640314, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640284, @probinson wrote: > > > Upfront, it seemed peculiar to handle only one optimization level. After > > more thought, the whole idea of mixing -O0 and LTO seems wrong. Sorry, > > should have signaled that I had changed my mind about it. > > > You just haven't articulated 1) why it is wrong and 2) what should we do > about it. "Optimize without optimizing" really? Does not sound confused to you? Persuade me why it makes sense. If it doesn't make sense, then yes making the `-O0 -flto` combination an error would be the right path. Unless you are taking the position that `-flto` doesn't mean "use LTO" and instead means something else, like "emit bitcode" in which case you should be advocating to change the name of the option to say what it means. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640090, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640046, @probinson wrote: > > > "I don't care" doesn't seem like much of a principle. > > > Long version is: "There is no use-case, no users, so I don't have much > motivation to push it forward for the only sake of completeness". Does it > sound enough of a principle like that? No. You still need to have adequate justification for your use case, which I think you do not. >> Optnone does not equal -O0. It is a debugging aid for the programmer, >> because debugging optimized code sucks. If you have an LTO-built >> application and want to de-optimize parts of it to aid with debugging, then >> you can use the pragma, as originally intended. > > Having to modifying the source isn't friendly. Not being able to honor -O0 > during LTO is not user-friendly. IMO, '-O0' and '-flto' are conflicting options and therefore not deserving of special support. In my experience, modifying source is by far simpler than hacking a build system to make a special case for compiler options for one module in an application. (If you have a way to build Clang with everything done LTO except one module built with -O0, on Linux with ninja, I would be very curious to hear how you do that.) But if your build system makes that easy, you can just as easily remove `-flto` as add `-O0` and thus get the result you want without trying to pass conflicting options to the compiler. Or spending time implementing this patch. >> I don't think `-c -O0` should get this not-entirely-O0-like behavior. > > What is "not-entirely"? And why do you think that? "Not entirely" means that running the -O0 pipeline, and running an optimization pipeline but asking some subset of passes to turn themselves off, does not get you the same result. And I think that because I'm the one who put 'optnone' upstream in the first place. The case that particularly sticks in my memory is the register allocator, but I believe there are passes at every stage that do not turn themselves off for optnone. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640682, @mehdi_amini wrote: > > I'm now thinking along the lines of a `-foptimize-off` flag (bikesheds > > welcome) which would set the default for the pragma to 'off'. How is that > > different than what you wanted for `-O0`? It is defined in terms of an > > existing pragma, which is WAY easier to explain and WAY easier to > > implement. And, it still lets us say that `-c -O0 -flto` is a mistake, if > > that seems like a useful thing to say. > > Well -O0 being actually "disable optimization", I found "way easier" to > handle everything the same way (pragma, command line, etc.). I kind of find > it confusing for the user to differentiate `-O0` from `-foptimize=off`. What > is supposed to change between the two? There is a pedantic difference, rooted in the still-true factoid that O0 != optnone. If we redefine LTO as "Link Time Operation" (rather than Optimization; see my reply to Duncan) then `-O0 -flto` is no longer an oxymoron, but using the attribute to imply the optimization level is still not good fidelity to what the user asked for. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. @rsmith could you say whether it seems reasonable to have a LangOpts flag that basically means "`pragma clang optimize off` is always in effect." I think it would make the other optnone-related logic simpler. It would not be the only sort-of-codegen-related flag in LangOpts (e.g. the PIC/PIE stuff). In https://reviews.llvm.org/D28404#641538, @probinson wrote: > There is another way to make use of the attribute, which I think will be more > robust: > > Have Sema pretend the pragma is in effect at all times, at -O0. Then all the > existing conflict detection/resolution logic Just Works, and there's no need > to spend 4 lines of code hoping to replicate the correct conditions in > CodeGenModule. > > Because Sema does not have a handle on CodeGenOptions and therefore does not > a-priori know the optimization level, probably the right thing to do is move > the flag to LangOpts and set it under the correct conditions in > CompilerInvocation. It wouldn't be the first codegen-like option in LangOpts. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#641078, @chandlerc wrote: > For me, the arguments you're raising against -O0 and -flto don't hold up on > closer inspection: > > - O0 != optnone: correct. But this is only visible in LTO. And in LTO, Os != > optsize, and Oz != minsize. But we use optsize and minsize to communicate > between the compilation and the LTO step to the best of our ability the > intent of the programmer. It appears we can use optnone exactly the same way > here. If the design decision is that relevant optimization controls are propagated into bitcode as function attributes, I grumble but concede it will do something similar to what was requested. It does bother me that we keep finding things that LTO needs to know but which it does not know because it runs in a separate phase of the workflow. I hope it is not a serious problem to ask "is there a more sensible way to fix this?" Maybe I'm not so good at expressing that so it comes out as a question rather than an objection, but that's basically what it is. This design decision leaves -O1/-Og needing yet another attribute, when we get around to that, but I suppose Og would not have the interaction-with-other-attributes problems that optnone has. > - optnone isn't *really* no optimizations: clearly this is true, but then > neither is -O0. We run the always inliner, a couple of other passes, and we > run several parts of the code generators optimizer. I understand why optnone > deficiencies (ie, too many optimizations) might be frustrating, but having > *more users* seems likely to make this *better*. We have picked all the low-hanging fruit there, and probably some medium-hanging fruit. Mehdi did have the misunderstanding that optnone == -O0 and that I think was worth correcting. > - There is no use case for -O0 + -flto: The email thread has an exchange between Duncan and me, where I accept the use case. > But all of this seems like an attempt to argue "you are wrong to have your > use case". I personally find that an unproductive line of discussion. Not saying it was *wrong* just the description did not convey adequate justification. Listing a few project types does not constitute a use case. We did get to one, eventually, and it even involved differences in optimization levels. > For example, you might ask: could we find some other way to solve the problem > you are trying to solve here? There is another way to make use of the attribute, which I think will be more robust: Have Sema pretend the pragma is in effect at all times, at -O0. Then all the existing conflict detection/resolution logic Just Works, and there's no need to spend 4 lines of code hoping to replicate the correct conditions in CodeGenModule. Because Sema does not have a handle on CodeGenOptions and therefore does not a-priori know the optimization level, probably the right thing to do is move the flag to LangOpts and set it under the correct conditions in CompilerInvocation. It wouldn't be the first codegen-like option in LangOpts. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#641557, @mehdi_amini wrote: > As I stand right now, there hasn't been any correction. > I still consider the fact that `optnone` wouldn't produce the "same" result > (modulo corner cases around `merging global variables` for instance) as O0 a > bug that need to be fixed. Why? That's not the purpose of optnone. You've already admitted there are some differences. Why are other differences important? https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#641606, @mehdi_amini wrote: > If we want to support `-O0 -flto` and `optnone` it the way to convey this to > the optimizer, I don't see the alternative. optsize != -Os (according to Chandler) minsize != -Oz (according to Chandler) optnone != -O0 (according to both me and Chandler) optnone is not "the way to convey (-O0) to the optimizer." Please get that misunderstanding out of your head. Clang handles -O0 by creating a short, minimalist pipeline, and running everything through it. Clang handles -O2 by creating a fuller optimization pipeline, and functions with 'optnone' skip many of the passes in the pipeline. These are architecturally different processes, you are not going to be able to make 'optnone' behave exactly like -O0 without major redesign of how the pipelines work. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28503: Documentation for the newly added x86 intrinsics.
probinson added inline comments. Comment at: emmintrin.h:1607 +/// +/// This intrinsic corresponds to the VMOVSD / MOVSD instruction. +/// should this be VMOVQ/MOVQ instead? Repository: rL LLVM https://reviews.llvm.org/D28503 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28620: Guard __gnuc_va_list typedef
probinson created this revision. probinson added a reviewer: yaron.keren. probinson added a subscriber: cfe-commits. https://reviews.llvm.org/D28620 Files: lib/Headers/stdarg.h test/Headers/stdarg-gnuc_va_list.c Index: test/Headers/stdarg-gnuc_va_list.c === --- test/Headers/stdarg-gnuc_va_list.c +++ test/Headers/stdarg-gnuc_va_list.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s +// expected-no-diagnostics + +// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has +// previously been defined in another header file. +typedef __builtin_va_list __va_list; +typedef __va_list __gnuc_va_list; +#define __GNUC_VA_LIST + +#include Index: lib/Headers/stdarg.h === --- lib/Headers/stdarg.h +++ lib/Headers/stdarg.h @@ -46,7 +46,7 @@ /* Hack required to make standard headers work, at least on Ubuntu */ #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1 -#endif typedef __builtin_va_list __gnuc_va_list; +#endif #endif /* __STDARG_H */ Index: test/Headers/stdarg-gnuc_va_list.c === --- test/Headers/stdarg-gnuc_va_list.c +++ test/Headers/stdarg-gnuc_va_list.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s +// expected-no-diagnostics + +// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has +// previously been defined in another header file. +typedef __builtin_va_list __va_list; +typedef __va_list __gnuc_va_list; +#define __GNUC_VA_LIST + +#include Index: lib/Headers/stdarg.h === --- lib/Headers/stdarg.h +++ lib/Headers/stdarg.h @@ -46,7 +46,7 @@ /* Hack required to make standard headers work, at least on Ubuntu */ #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1 -#endif typedef __builtin_va_list __gnuc_va_list; +#endif #endif /* __STDARG_H */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. Maybe instead, pass a flag to enable setting optnone on everything when the driver sees `-O0 -flto`? The patch as-is obviously has a massive testing cost, and it's easy to imagine people being tripped up by this in the future. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#638221, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#638217, @probinson wrote: > > > The patch as-is obviously has a massive testing cost, and it's easy to > > imagine people being tripped up by this in the future. > > > Can you clarify what massive testing cost you're referring to? Well, you just had to modify around 50 tests, and I'd expect some future tests to have to deal with it too. Maybe "massive" is overstating it but it seemed like an unusually large number. I don't know that just slapping the option on all these tests is really the most appropriate fix, either, in some cases. I'll look at it more. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#638350, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#638299, @probinson wrote: > > > In https://reviews.llvm.org/D28404#638221, @mehdi_amini wrote: > > > > > In https://reviews.llvm.org/D28404#638217, @probinson wrote: > > > > > > > The patch as-is obviously has a massive testing cost, and it's easy to > > > > imagine people being tripped up by this in the future. > > > > > > > > > Can you clarify what massive testing cost you're referring to? > > > > > > Well, you just had to modify around 50 tests, and I'd expect some future > > tests to have to deal with it too. Maybe "massive" is overstating it but > > it seemed like an unusually large number. > > > There are two things: > > - tests are modified: when adding a new option, it does not seems unusual to > me 50 seems rather more than usual, but whatever. Granted it's not hundreds. > - what impact on future testing. I still don't see any of this future > "testing cost" you're referring to right now. Maybe I worry too much. I am getting a slightly different set of test failures than you did though. I get these failures: CodeGen/aarch64-neon-extract.c CodeGen/aarch64-poly128.c CodeGen/arm-neon-shifts.c CodeGen/arm64-crc32.c And I don't get these failures: CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp CodeGenCXX/apple-kext-no-staticinit-section.cpp CodeGenCXX/debug-info-global-ctor-dtor.cpp Comment at: clang/lib/CodeGen/CodeGenModule.cpp:900 +// OptimizeNone implies noinline; we should not be inlining such +// functions. B.addAttribute(llvm::Attribute::NoInline); I'd set ShouldAddOptNone = false here, as it's already explicit. Comment at: clang/test/CodeGen/aarch64-neon-2velem.c:1 -// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s +// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -disable-O0-optnone -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s Option specified twice. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912 // OptimizeNone wins over OptimizeForSize and MinSize. F->removeFnAttr(llvm::Attribute::OptimizeForSize); F->removeFnAttr(llvm::Attribute::MinSize); mehdi_amini wrote: > chandlerc wrote: > > Is this still at all correct? Why? it seems pretty confusing especially in > > conjunction with the code below. > > > > > > I think this may force you to either: > > a) stop early-marking of -Os and -Oz flags with these attributes (early: > > prior to calling this routine) and handling all of the -O flag synthesized > > attributes here, or > > b) set optnone for -O0 wher ewe set optsize for -Os and friends, and then > > remove it where necessary here. > > > > I don't have any strong opinion about a vs. b. > I believe it is still correct: during Os/Oz we reach this point and figure > that there is `__attribute__((optnone))` in the *source* (not `-O0`), we > remove the attributes, nothing changes. Did I miss something? > Hmmm the Os/Oz attributes are added in CGCall.cpp, and are guarded with a check on the presence of the Optnone source attribute, so if the Optnone source attribute is present we should never see these. And Os/Oz set OptimizationLevel to 2, which is not zero, so we won't come through here for ShouldAddOptNone reasons either. Therefore these 'remove' calls should be no-ops and could be removed. (For paranoia you could turn them into asserts, and do some experimenting to see whether I'm confused about how this all fits together.) https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:962 + ShouldAddOptNone &= !D->hasAttr(); + ShouldAddOptNone &= !D->hasAttr(); + ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline); chandlerc wrote: > why is optnone incompatible with *cold* Because cold implies OptimizeForSize (just above this). I take no position on whether that is reasonable. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added inline comments. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:896 + !CodeGenOpts.DisableO0ImplyOptNone && CodeGenOpts.OptimizationLevel == 0; + // We can't add optnone in the following cases, it won't pass the verifier + ShouldAddOptNone &= !D->hasAttr(); Period at the end of a comment. Comment at: clang/lib/CodeGen/CodeGenModule.cpp:900 + ShouldAddOptNone &= !D->hasAttr(); + if (ShouldAddOptNone) { +B.addAttribute(llvm::Attribute::OptimizeNone); This block is redundant now? The same things are added in the next if block. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. Over the weekend I had a thought: Why is -O0 so special here? That is, after going to all this trouble to propagate -O0 to LTO, how does this generalize to propagating -O1 or any other specific -O option? (Maybe this question would be better dealt with on the dev list...) https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27994: Make two vtable tests tolerate C++11
probinson created this revision. probinson added a reviewer: rjmccall. probinson added a subscriber: cfe-commits. In C++11, we don't emit vtables as eagerly as we do for C++03, so fiddle the tests to emit them when the test expects them. In the C++11 test cleanup project, we're commonly making the tests run in both dialects and sometimes with no dialect specified (as Clang's default will presumably advance to C++14/17 at some point). I didn't do that for vtable-layout.cpp because it runs FileCheck 46 times, and replicating that really seemed like too much. If it also seems like too much for vtable-linkage.cpp, the easy thing is to force it to C++03. https://reviews.llvm.org/D27994 Files: test/CodeGenCXX/vtable-layout.cpp test/CodeGenCXX/vtable-linkage.cpp Index: test/CodeGenCXX/vtable-linkage.cpp === --- test/CodeGenCXX/vtable-linkage.cpp +++ test/CodeGenCXX/vtable-linkage.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03 +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt // RUN: FileCheck %s < %t +// RUN: FileCheck %s < %t.03 +// RUN: FileCheck %s < %t.11 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt namespace { @@ -33,6 +37,11 @@ static struct : D { } e; +// Force 'e' to be constructed and therefore have a vtable defined. +void use_e() { + e.f(); +} + // The destructor is the key function. template struct E { Index: test/CodeGenCXX/vtable-layout.cpp === --- test/CodeGenCXX/vtable-layout.cpp +++ test/CodeGenCXX/vtable-layout.cpp @@ -1919,6 +1919,8 @@ virtual int i(int); virtual int i(); }; + // Force C's vtable to be generated. + int C::f() { return 1; } class D : C {}; Index: test/CodeGenCXX/vtable-linkage.cpp === --- test/CodeGenCXX/vtable-linkage.cpp +++ test/CodeGenCXX/vtable-linkage.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03 +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt // RUN: FileCheck %s < %t +// RUN: FileCheck %s < %t.03 +// RUN: FileCheck %s < %t.11 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt namespace { @@ -33,6 +37,11 @@ static struct : D { } e; +// Force 'e' to be constructed and therefore have a vtable defined. +void use_e() { + e.f(); +} + // The destructor is the key function. template struct E { Index: test/CodeGenCXX/vtable-layout.cpp === --- test/CodeGenCXX/vtable-layout.cpp +++ test/CodeGenCXX/vtable-layout.cpp @@ -1919,6 +1919,8 @@ virtual int i(int); virtual int i(); }; + // Force C's vtable to be generated. + int C::f() { return 1; } class D : C {}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27936: C++11 test cleanup: nonthrowing destructors
probinson added a reviewer: rjmccall. probinson added a comment. +rjmccall as IR Gen owner. https://reviews.llvm.org/D27936 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27936: C++11 test cleanup: nonthrowing destructors
This revision was automatically updated to reflect the committed changes. Closed by commit rL290207: C++11 test cleanup: nonthrowing destructors (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D27936?vs=81982=82157#toc Repository: rL LLVM https://reviews.llvm.org/D27936 Files: cfe/trunk/test/CodeGenCXX/destructors.cpp cfe/trunk/test/CodeGenCXX/nrvo.cpp cfe/trunk/test/CodeGenCXX/partial-destruction.cpp Index: cfe/trunk/test/CodeGenCXX/partial-destruction.cpp === --- cfe/trunk/test/CodeGenCXX/partial-destruction.cpp +++ cfe/trunk/test/CodeGenCXX/partial-destruction.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03 +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11 // Test IR generation for partial destruction of aggregates. @@ -45,7 +46,8 @@ // CHECK-NEXT: br label // CHECK: [[ED_AFTER:%.*]] = phi [[A]]* [ [[ED_END]], {{%.*}} ], [ [[ED_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[ED_CUR]] = getelementptr inbounds [[A]], [[A]]* [[ED_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_CUR]], [[ED_BEGIN]] // CHECK-NEXT: br i1 [[T0]], // CHECK: ret void @@ -58,7 +60,8 @@ // CHECK-NEXT: br i1 [[T0]], // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[PARTIAL_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E_BEGIN]] // CHECK-NEXT: br i1 [[T0]], @@ -73,20 +76,21 @@ // FIXME: There's some really bad block ordering here which causes // the partial destroy for the primary normal destructor to fall // within the primary EH destructor. - // CHECK: landingpad { i8*, i32 } - // CHECK-NEXT: cleanup - // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]] - // CHECK-NEXT: br i1 [[T0]] - // CHECK: [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ] - // CHECK-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]]) - // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]] - // CHECK-NEXT: br i1 [[T0]] + // CHECKv03: landingpad { i8*, i32 } + // CHECKv03-NEXT: cleanup + // CHECKv03: [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]] + // CHECKv03-NEXT: br i1 [[T0]] + // CHECKv03: [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ] + // CHECKv03-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1 + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]]) + // CHECKv03: [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]] + // CHECKv03-NEXT: br i1 [[T0]] // Back to the primary EH destructor. // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[E_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E0]] // CHECK-NEXT: br i1 [[T0]], @@ -120,8 +124,10 @@ // CHECK-NEXT: cleanup // CHECK: landingpad { i8*, i32 } // CHECK-NEXT: cleanup - // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[Y]]) - // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[X]]) + // CHECKv03: invoke void @_ZN5test11AD1Ev([[A]]* [[Y]]) + // CHECKv03: invoke void @_ZN5test11AD1Ev([[A]]* [[X]]) + // CHECKv11: call void @_ZN5test11AD1Ev([[A]]* [[Y]]) + // CHECKv11: call void @_ZN5test11AD1Ev([[A]]* [[X]]) } namespace test2 { @@ -153,7 +159,8 @@ // CHECK-NEXT: br i1 [[EMPTY]], // CHECK: [[PAST:%.*]] = phi [[A]]* [ [[CUR]], {{%.*}} ], [ [[DEL:%.*]], {{%.*}} ] // CHECK-NEXT: [[DEL]] = getelementptr inbounds [[A]], [[A]]* [[PAST]], i64 -1 -// CHECK-NEXT: invoke void @_ZN5test21AD1Ev([[A]]* [[DEL]]) +// CHECKv03-NEXT: invoke void
[PATCH] D27994: Make two vtable tests tolerate C++11
This revision was automatically updated to reflect the committed changes. Closed by commit rL290205: Make two vtable tests tolerate C++11. (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D27994?vs=82126=82156#toc Repository: rL LLVM https://reviews.llvm.org/D27994 Files: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp Index: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp === --- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp +++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp @@ -1919,6 +1919,8 @@ virtual int i(int); virtual int i(); }; + // Force C's vtable to be generated. + int C::f() { return 1; } class D : C {}; Index: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp === --- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp +++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03 +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt // RUN: FileCheck %s < %t +// RUN: FileCheck %s < %t.03 +// RUN: FileCheck %s < %t.11 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt namespace { @@ -33,6 +37,11 @@ static struct : D { } e; +// Force 'e' to be constructed and therefore have a vtable defined. +void use_e() { + e.f(); +} + // The destructor is the key function. template struct E { Index: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp === --- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp +++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp @@ -1919,6 +1919,8 @@ virtual int i(int); virtual int i(); }; + // Force C's vtable to be generated. + int C::f() { return 1; } class D : C {}; Index: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp === --- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp +++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03 +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt // RUN: FileCheck %s < %t +// RUN: FileCheck %s < %t.03 +// RUN: FileCheck %s < %t.11 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt namespace { @@ -33,6 +37,11 @@ static struct : D { } e; +// Force 'e' to be constructed and therefore have a vtable defined. +void use_e() { + e.f(); +} + // The destructor is the key function. template struct E { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27956: Make CodeGenCXX/stack-reuse-miscompile.cpp tolerate C++11
This revision was automatically updated to reflect the committed changes. Closed by commit rL290208: Make a test use a specific C++ dialect (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D27956?vs=82020=82160#toc Repository: rL LLVM https://reviews.llvm.org/D27956 Files: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp Index: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp === --- cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp +++ cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for // f function because all temporary objects in this function are used for the Index: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp === --- cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp +++ cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for // f function because all temporary objects in this function are used for the ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27794: Make some diagnostic tests C++11 clean
This revision was automatically updated to reflect the committed changes. Closed by commit rL290262: Make some diagnostic tests C++11 clean. (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D27794?vs=81977=82248#toc Repository: rL LLVM https://reviews.llvm.org/D27794 Files: cfe/trunk/test/FixIt/fixit.cpp cfe/trunk/test/Parser/backtrack-off-by-one.cpp cfe/trunk/test/SemaCXX/copy-assignment.cpp Index: cfe/trunk/test/FixIt/fixit.cpp === --- cfe/trunk/test/FixIt/fixit.cpp +++ cfe/trunk/test/FixIt/fixit.cpp @@ -1,8 +1,12 @@ -// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s +// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++98 %s +// RUN: cp %s %t-98 +// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++98 %t-98 +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++98 %t-98 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s -// RUN: cp %s %t -// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t -// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t +// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++11 %s +// RUN: cp %s %t-11 +// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++11 %t-11 +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++11 %t-11 /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the @@ -21,7 +25,11 @@ template struct CT { template struct Inner; }; // expected-note{{previous use is here}} +// FIXME: In C++11 this gets 'expected unqualified-id' which fixit can't fix. +// Probably parses as `CT<10> > 2 > ct;` rather than `CT<(10 >> 2)> ct;`. +#if __cplusplus < 201103L CT<10 >> 2> ct; // expected-warning{{require parentheses}} +#endif class C3 { public: @@ -41,7 +49,11 @@ }; class B : public A { +#if __cplusplus >= 201103L + A::foo; // expected-error{{ISO C++11 does not allow access declarations}} +#else A::foo; // expected-warning{{access declarations are deprecated}} +#endif }; void f() throw(); // expected-note{{previous}} @@ -285,8 +297,10 @@ void (*p)() = ; (void)(==p); // expected-error {{use '> ='}} (void)(>=p); // expected-error {{use '> >'}} +#if __cplusplus < 201103L (void)(>=p); // expected-error {{use '> >'}} (Shr)>>=p; // expected-error {{use '> >'}} +#endif // FIXME: We correct this to ' > >= p;' not ' >>= p;' //(Shr)>>=p; Index: cfe/trunk/test/Parser/backtrack-off-by-one.cpp === --- cfe/trunk/test/Parser/backtrack-off-by-one.cpp +++ cfe/trunk/test/Parser/backtrack-off-by-one.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify %s -std=c++98 +// RUN: %clang_cc1 -verify %s -std=c++11 // PR25946 // We had an off-by-one error in an assertion when annotating A below. Our @@ -10,8 +12,10 @@ // expected-error@+1 {{expected '{' after base class list}} template class B : T // not ',' or '{' -// expected-error@+3 {{C++ requires a type specifier for all declarations}} -// expected-error@+2 {{expected ';' after top level declarator}} +#if __cplusplus < 201103L +// expected-error@+4 {{expected ';' after top level declarator}} +#endif +// expected-error@+2 {{C++ requires a type specifier for all declarations}} // expected-error@+1 {{expected ';' after class}} A { }; Index: cfe/trunk/test/SemaCXX/copy-assignment.cpp === --- cfe/trunk/test/SemaCXX/copy-assignment.cpp +++ cfe/trunk/test/SemaCXX/copy-assignment.cpp @@ -1,12 +1,22 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 + +#if __cplusplus >= 201103L +// expected-note@+3 2 {{candidate constructor}} +// expected-note@+2 {{passing argument to parameter here}} +#endif struct A { }; struct ConvertibleToA { operator A(); }; struct ConvertibleToConstA { +#if __cplusplus >= 201103L +// expected-note@+2 {{candidate function}} +#endif operator const A(); }; @@ -69,6 +79,9 @@ na = a; na = constA; na = convertibleToA; +#if __cplusplus >= 201103L +// expected-error@+2 {{no viable conversion}} +#endif na = convertibleToConstA; na += a; // expected-error{{no viable overloaded '+='}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27794: Make some diagnostic tests C++11 clean
probinson marked an inline comment as done. probinson added a comment. FIXME added. https://reviews.llvm.org/D27794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11
probinson updated this revision to Diff 82021. probinson added a comment. Force C++03 on this test, to make it insensitive to future changes in the default dialect. https://reviews.llvm.org/D27955 Files: test/CodeGenCXX/arm-swiftcall.cpp Index: test/CodeGenCXX/arm-swiftcall.cpp === --- test/CodeGenCXX/arm-swiftcall.cpp +++ test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. Index: test/CodeGenCXX/arm-swiftcall.cpp === --- test/CodeGenCXX/arm-swiftcall.cpp +++ test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11
probinson created this revision. probinson added a reviewer: rjmccall. probinson added a subscriber: cfe-commits. Herald added subscribers: rengolin, aemerson. The test conjures up and returns a temp which has a struct type, and the struct has some empty/padding bytes in the middle. In C++03 these are handled as zero, so the code uses 'llvm.memset' to initialize the temp. In C++11, the padding is handled as undef, so the code uses 'llvm.memcpy' instead, making the test fail. I've made the test run twice, once per dialect, and check for the appropriate intrinsic. It doesn't look like this is the point of the test, though,. so maybe hard-coding the dialect would be preferable. https://reviews.llvm.org/D27955 Files: test/CodeGenCXX/arm-swiftcall.cpp Index: test/CodeGenCXX/arm-swiftcall.cpp === --- test/CodeGenCXX/arm-swiftcall.cpp +++ test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03 +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11 // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. @@ -48,7 +49,8 @@ TEST(struct_1); // CHECK-LABEL: define {{.*}} @return_struct_1() // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align 4 -// CHECK: @llvm.memset +// CHECKv03: @llvm.memset +// CHECKv11: @llvm.memcpy // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x i8\], i8, \[1 x i8\], float, float }]]* // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 // CHECK: [[FIRST:%.*]] = load i32, i32* [[T0]], align 4 Index: test/CodeGenCXX/arm-swiftcall.cpp === --- test/CodeGenCXX/arm-swiftcall.cpp +++ test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03 +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11 // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. @@ -48,7 +49,8 @@ TEST(struct_1); // CHECK-LABEL: define {{.*}} @return_struct_1() // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align 4 -// CHECK: @llvm.memset +// CHECKv03: @llvm.memset +// CHECKv11: @llvm.memcpy // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x i8\], i8, \[1 x i8\], float, float }]]* // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 // CHECK: [[FIRST:%.*]] = load i32, i32* [[T0]], align 4 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27956: Make CodeGenCXX/stack-reuse-miscompile.cpp tolerate C++11
probinson created this revision. probinson added a reviewer: lenykholodov. probinson added a subscriber: cfe-commits. In this test, the allocas for the temps come out in a different order depending on whether the dialect is C++03 or C++11. To avoid depending on the default dialect, I forced it to C++03. I am concerned, though, because the commentary says there should be no lifetime intrinsics. While that was true in Clang 3.8, it is no longer true in Clang 3.9, regardless of dialect. However, the test does not actually verify that there are no lifetime intrinsics. Is it still true that there should be no lifetime intrinsics? If so, then there is a bug that the test has failed to detect. If not, then the comment should be updated. https://reviews.llvm.org/D27956 Files: test/CodeGenCXX/stack-reuse-miscompile.cpp Index: test/CodeGenCXX/stack-reuse-miscompile.cpp === --- test/CodeGenCXX/stack-reuse-miscompile.cpp +++ test/CodeGenCXX/stack-reuse-miscompile.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for // f function because all temporary objects in this function are used for the Index: test/CodeGenCXX/stack-reuse-miscompile.cpp === --- test/CodeGenCXX/stack-reuse-miscompile.cpp +++ test/CodeGenCXX/stack-reuse-miscompile.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for // f function because all temporary objects in this function are used for the ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27936: C++11 test cleanup: nonthrowing destructors
probinson created this revision. probinson added a reviewer: rsmith. probinson added a subscriber: cfe-commits. If a dtor has no interesting members, then it ends up being nothrow, which affects the generated IR. Modify some tests to tolerate this difference between C++03 and C++11. In C++11, a destructor without an explicit exception-spec gets an implicit exception-spec. If the dtor has a body, the implicit exception-spec permits throwing exactly the set of types thrown by anything the dtor calls. If the dtor doesn't have a body, use what would be the default dtor's body to determine the implicit exception-spec. If there are no calls, the implicit exception-spec is nothrow. https://reviews.llvm.org/D27936 Files: test/CodeGenCXX/destructors.cpp test/CodeGenCXX/nrvo.cpp test/CodeGenCXX/partial-destruction.cpp Index: test/CodeGenCXX/partial-destruction.cpp === --- test/CodeGenCXX/partial-destruction.cpp +++ test/CodeGenCXX/partial-destruction.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03 +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11 // Test IR generation for partial destruction of aggregates. @@ -45,7 +46,8 @@ // CHECK-NEXT: br label // CHECK: [[ED_AFTER:%.*]] = phi [[A]]* [ [[ED_END]], {{%.*}} ], [ [[ED_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[ED_CUR]] = getelementptr inbounds [[A]], [[A]]* [[ED_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_CUR]], [[ED_BEGIN]] // CHECK-NEXT: br i1 [[T0]], // CHECK: ret void @@ -58,7 +60,8 @@ // CHECK-NEXT: br i1 [[T0]], // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[PARTIAL_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E_BEGIN]] // CHECK-NEXT: br i1 [[T0]], @@ -73,20 +76,21 @@ // FIXME: There's some really bad block ordering here which causes // the partial destroy for the primary normal destructor to fall // within the primary EH destructor. - // CHECK: landingpad { i8*, i32 } - // CHECK-NEXT: cleanup - // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]] - // CHECK-NEXT: br i1 [[T0]] - // CHECK: [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ] - // CHECK-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]]) - // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]] - // CHECK-NEXT: br i1 [[T0]] + // CHECKv03: landingpad { i8*, i32 } + // CHECKv03-NEXT: cleanup + // CHECKv03: [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]] + // CHECKv03-NEXT: br i1 [[T0]] + // CHECKv03: [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ] + // CHECKv03-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1 + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]]) + // CHECKv03: [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]] + // CHECKv03-NEXT: br i1 [[T0]] // Back to the primary EH destructor. // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[E_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ] // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1 - // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) + // CHECKv11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[E_CUR]]) // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E0]] // CHECK-NEXT: br i1 [[T0]], @@ -120,8 +124,10 @@ // CHECK-NEXT: cleanup // CHECK: landingpad { i8*, i32 } // CHECK-NEXT: cleanup - // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[Y]]) - // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[X]]) + // CHECKv03: invoke void @_ZN5test11AD1Ev([[A]]* [[Y]]) + // CHECKv03: invoke void @_ZN5test11AD1Ev([[A]]* [[X]]) + // CHECKv11: call void @_ZN5test11AD1Ev([[A]]* [[Y]]) + // CHECKv11: call void @_ZN5test11AD1Ev([[A]]* [[X]]) }
[PATCH] D27794: Make some diagnostic tests C++11 clean
probinson added a reviewer: rnk. probinson updated this revision to Diff 81977. probinson added a comment. Remove the OpenMP tests from this review (committed in r290128). +rnk who added test/Parser/backtrack-off-by-one.cpp originally. https://reviews.llvm.org/D27794 Files: test/FixIt/fixit.cpp test/Parser/backtrack-off-by-one.cpp test/SemaCXX/copy-assignment.cpp Index: test/SemaCXX/copy-assignment.cpp === --- test/SemaCXX/copy-assignment.cpp +++ test/SemaCXX/copy-assignment.cpp @@ -1,12 +1,22 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 + +#if __cplusplus >= 201103L +// expected-note@+3 2 {{candidate constructor}} +// expected-note@+2 {{passing argument to parameter here}} +#endif struct A { }; struct ConvertibleToA { operator A(); }; struct ConvertibleToConstA { +#if __cplusplus >= 201103L +// expected-note@+2 {{candidate function}} +#endif operator const A(); }; @@ -69,6 +79,9 @@ na = a; na = constA; na = convertibleToA; +#if __cplusplus >= 201103L +// expected-error@+2 {{no viable conversion}} +#endif na = convertibleToConstA; na += a; // expected-error{{no viable overloaded '+='}} Index: test/Parser/backtrack-off-by-one.cpp === --- test/Parser/backtrack-off-by-one.cpp +++ test/Parser/backtrack-off-by-one.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify %s -std=c++98 +// RUN: %clang_cc1 -verify %s -std=c++11 // PR25946 // We had an off-by-one error in an assertion when annotating A below. Our @@ -10,8 +12,10 @@ // expected-error@+1 {{expected '{' after base class list}} template class B : T // not ',' or '{' -// expected-error@+3 {{C++ requires a type specifier for all declarations}} -// expected-error@+2 {{expected ';' after top level declarator}} +#if __cplusplus < 201103L +// expected-error@+4 {{expected ';' after top level declarator}} +#endif +// expected-error@+2 {{C++ requires a type specifier for all declarations}} // expected-error@+1 {{expected ';' after class}} A { }; Index: test/FixIt/fixit.cpp === --- test/FixIt/fixit.cpp +++ test/FixIt/fixit.cpp @@ -1,8 +1,12 @@ -// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s +// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++98 %s +// RUN: cp %s %t-98 +// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++98 %t-98 +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++98 %t-98 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s -// RUN: cp %s %t -// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t -// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t +// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++11 %s +// RUN: cp %s %t-11 +// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++11 %t-11 +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++11 %t-11 /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the @@ -21,7 +25,10 @@ template struct CT { template struct Inner; }; // expected-note{{previous use is here}} +// In C++11 this gets 'expected unqualified-id' which fixit can't fix. +#if __cplusplus < 201103L CT<10 >> 2> ct; // expected-warning{{require parentheses}} +#endif class C3 { public: @@ -41,7 +48,11 @@ }; class B : public A { +#if __cplusplus >= 201103L + A::foo; // expected-error{{ISO C++11 does not allow access declarations}} +#else A::foo; // expected-warning{{access declarations are deprecated}} +#endif }; void f() throw(); // expected-note{{previous}} @@ -285,8 +296,10 @@ void (*p)() = ; (void)(==p); // expected-error {{use '> ='}} (void)(>=p); // expected-error {{use '> >'}} +#if __cplusplus < 201103L (void)(>=p); // expected-error {{use '> >'}} (Shr)>>=p; // expected-error {{use '> >'}} +#endif // FIXME: We correct this to ' > >= p;' not ' >>= p;' //(Shr)>>=p; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11
This revision was automatically updated to reflect the committed changes. Closed by commit rL290145: Make another test insensitive to the default C++ dialect. (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D27955?vs=82021=82028#toc Repository: rL LLVM https://reviews.llvm.org/D27955 Files: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp Index: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp === --- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp +++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. Index: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp === --- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp +++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s +// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK // This isn't really testing anything ARM-specific; it's just a convenient // 32-bit platform. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson updated this revision to Diff 106063. probinson added a comment. Refresh to current TOT, and ping. Funny what you can find in a year-old to-do list https://reviews.llvm.org/D14358 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-fwd-param.cpp test/Modules/ExtDebugInfo.cpp Index: test/Modules/ExtDebugInfo.cpp === --- test/Modules/ExtDebugInfo.cpp +++ test/Modules/ExtDebugInfo.cpp @@ -93,9 +93,13 @@ // CHECK-SAME: flags: DIFlagFwdDecl, // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIi") -// This type isn't, however, even with standalone non-module debug info this -// type is a forward declaration. -// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "traits", +// This type isn't, however, it is a template parameter type and so gets a +// forward declaration. +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// CHECK-SAME: name: "traits", +// CHECK-SAME: scope: ![[NS]], +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIiEE") // This one isn't. // CHECK: !DICompositeType(tag: DW_TAG_class_type, Index: test/CodeGenCXX/debug-info-template-fwd-param.cpp === --- test/CodeGenCXX/debug-info-template-fwd-param.cpp +++ test/CodeGenCXX/debug-info-template-fwd-param.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -debug-info-kind=limited -emit-llvm -o - | FileCheck %s +// A forward declaration of a template should still have template parameters. + +template class A { +public: + A(T val); +private: + T x; +}; + +struct B { + A *p; +}; + +B b; + +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A" +// CHECK-SAME: flags: DIFlagFwdDecl +// CHECK-SAME: templateParams: [[PARAM_LIST:![0-9]*]] +// CHECK: [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]} +// CHECK: [[PARAM]] = !DITemplateTypeParameter(name: "T", +// CHECK-SAME: type: [[CTYPE:![0-9]*]] +// CHECK: [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type +// CHECK-SAME: baseType: [[BTYPE:![0-9]*]] +// CHECK: [[BTYPE]] = !DIBasicType(name: "int" Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -805,6 +805,10 @@ llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName); + if (const ClassTemplateSpecializationDecl *TSpecial = + dyn_cast(RD)) +DBuilder.replaceArrays(RetTy, llvm::DINodeArray(), + CollectCXXTemplateParams(TSpecial, DefUnit)); ReplaceMap.emplace_back( std::piecewise_construct, std::make_tuple(Ty), std::make_tuple(static_cast(RetTy))); Index: test/Modules/ExtDebugInfo.cpp === --- test/Modules/ExtDebugInfo.cpp +++ test/Modules/ExtDebugInfo.cpp @@ -93,9 +93,13 @@ // CHECK-SAME: flags: DIFlagFwdDecl, // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIi") -// This type isn't, however, even with standalone non-module debug info this -// type is a forward declaration. -// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "traits", +// This type isn't, however, it is a template parameter type and so gets a +// forward declaration. +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// CHECK-SAME: name: "traits", +// CHECK-SAME: scope: ![[NS]], +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIiEE") // This one isn't. // CHECK: !DICompositeType(tag: DW_TAG_class_type, Index: test/CodeGenCXX/debug-info-template-fwd-param.cpp === --- test/CodeGenCXX/debug-info-template-fwd-param.cpp +++ test/CodeGenCXX/debug-info-template-fwd-param.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -debug-info-kind=limited -emit-llvm -o - | FileCheck %s +// A forward declaration of a template should still have template parameters. + +template class A { +public: + A(T val); +private: + T x; +}; + +struct B { + A *p; +}; + +B b; + +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A" +// CHECK-SAME: flags: DIFlagFwdDecl +// CHECK-SAME: templateParams: [[PARAM_LIST:![0-9]*]] +// CHECK: [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]} +// CHECK: [[PARAM]] = !DITemplateTypeParameter(name: "T", +// CHECK-SAME: type: [[CTYPE:![0-9]*]] +// CHECK: [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type +// CHECK-SAME: baseType: [[BTYPE:![0-9]*]] +// CHECK:
[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity
probinson added a comment. Sweet. I don't have the chops to understand the Objective-C test but otherwise LGTM. Comment at: lib/Bitcode/Reader/MetadataLoader.cpp:1684 + HasFile ? getMDOrNull(Record[6]) : nullptr, + HasFile ? Record[4] : 0, getMDString(Record[5]))), NextMetadataNo); That's a nice touch. https://reviews.llvm.org/D35583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35715: Preserve typedef names in debug info for template type parameters
probinson created this revision. If a template instantiation uses a typedef'd name as a template parameter, this is usually resolved to its underlying type when we generate the name of the instance in the debug info. PS4 prefers to see the original parameter as in the source. Define an option that makes that happen, and have the default for the option depend on debugger tuning. This also provides some motivation for https://reviews.llvm.org/D14358. https://reviews.llvm.org/D35715 Files: include/clang/AST/PrettyPrinter.h include/clang/AST/TemplateBase.h include/clang/AST/Type.h include/clang/Basic/LangOptions.def include/clang/Driver/Options.td lib/AST/TemplateBase.cpp lib/AST/Type.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp lib/Sema/SemaTemplate.cpp test/CodeGen/debug-template-types.cpp test/Driver/clang_f_opts.c test/Index/print-type.cpp Index: test/Index/print-type.cpp === --- test/Index/print-type.cpp +++ test/Index/print-type.cpp @@ -119,7 +119,9 @@ // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] -// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux] [typekind=Unexposed] [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] [typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] [canonicaltype=outer::Qux ] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] [typekind=Int]] [isPOD=1] +// The expression in the next line is for -femit-typedefs-in-template-types +// which is the default on PS4. +// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux ] [typekind=Unexposed] [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] [typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] [canonicaltype=outer::Qux ] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] [typekind=Int]] [isPOD=1] // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] [canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] [resulttype=T] [resulttypekind=Unexposed] [isPOD=0] Index: test/Driver/clang_f_opts.c === --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -496,3 +496,10 @@ // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders // CHECK-NO-ALLOW-PLACEHOLDERS-NOT: -fallow-editor-placeholders + +// RUN: %clang -### -femit-typedefs-in-template-types %s 2>&1 | FileCheck -check-prefix=CHECK-EMIT-TYPEDEF-NAMES %s +// RUN: %clang -### -fno-emit-typedefs-in-template-types %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EMIT-TYPEDEF-NAMES %s +// RUN: %clang -### -gsce %s 2>&1 | FileCheck -check-prefix=CHECK-EMIT-TYPEDEF-NAMES %s +// RUN: %clang -### -ggdb %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EMIT-TYPEDEF-NAMES %s +// CHECK-EMIT-TYPEDEF-NAMES:-femit-typedefs-in-template-types +// CHECK-NO-EMIT-TYPEDEF-NAMES-NOT: -femit-typedefs-in-template-types Index: test/CodeGen/debug-template-types.cpp === --- test/CodeGen/debug-template-types.cpp +++ test/CodeGen/debug-template-types.cpp @@ -0,0 +1,94 @@ +// RUN: %clang_cc1 -debug-info-kind=standalone -fgnu-keywords -std=c++11 -femit-typedefs-in-template-types -emit-llvm %s -o - | FileCheck %s + +// With -femit-typedefs-in-template-types, template parameter type names should +// not be stripped of typedef names. This test tries some more complicated +// cases to check that we don't drop qualifiers and attach them correctly to +// the typename. + + +class A +{ +public: + int i; + A(){} +}; + +typedef A myA; + +myA a1; + +volatile decltype(a1) a; + +template +class B +{ + T t; +}; + +// See that we collect all the qualifiers while finding the topmost typedef +B b; +// CHECK-DAG: !DICompositeType(tag: DW_TAG_class_type, name: "B" + +class C +{ +public: + C(){} + C(volatile C&){} +}; + +typedef volatile C myC; + +const myC c; + +template +class D +{ + T t; +}; + +// See that we don't add the typedef's qualifiers to the type name +D d; +// CHECK-DAG: !DICompositeType(tag:
[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets
probinson added a comment. FTR, from a PS4 perspective this is all good, but we'd like somebody from outside our team to take a look. https://reviews.llvm.org/D36411 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. I mentioned this in the PR but I should have restated it here, sorry... Wolfgang authored this patch. He is away for a month so I volunteered to post this, in case it was okay for resolving the PR as the crash is present in the 5.0 branch. I do know Wolfgang was not really happy with it, and your questions might well be part of why that is. The patch has been in our local version of 5.0 for a couple of weeks without obvious problems, but that is not proof that it is always okay. https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson created this revision. Make sure all temporary MD nodes have been replaced with uniqued or distinct nodes before we clone a function. Fixes PR33930. https://reviews.llvm.org/D37038 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGVTables.cpp test/CodeGenCXX/temp-md-nodes1.cpp test/CodeGenCXX/temp-md-nodes2.cpp Index: test/CodeGenCXX/temp-md-nodes2.cpp === --- test/CodeGenCXX/temp-md-nodes2.cpp +++ test/CodeGenCXX/temp-md-nodes2.cpp @@ -0,0 +1,33 @@ +// REQUIRES: asserts +// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm %s -o - | \ +// RUN: FileCheck %s + +// This test simply checks that the varargs thunk is created. The failing test +// case asserts. + +typedef signed char __int8_t; +typedef int BOOL; +class CMsgAgent; + +class CFs { +public: + typedef enum {} CACHE_HINT; + virtual BOOL ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ) ; +}; + +typedef struct {} _Lldiv_t; + +class CBdVfs { +public: + virtual ~CBdVfs( ) {} +}; + +class CBdVfsImpl : public CBdVfs, public CFs { + BOOL ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ); +}; + +BOOL CBdVfsImpl::ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ) { + return true; +} + +// CHECK: define {{.*}} @_ZThn8_N10CBdVfsImpl12ReqCacheHintEP9CMsgAgentN3CFs10CACHE_HINTEz( Index: test/CodeGenCXX/temp-md-nodes1.cpp === --- test/CodeGenCXX/temp-md-nodes1.cpp +++ test/CodeGenCXX/temp-md-nodes1.cpp @@ -0,0 +1,18 @@ +// REQUIRES: asserts +// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm %s -o - | \ +// RUN: FileCheck %s + +// This test simply checks that the varargs thunk is created. The failing test +// case asserts. + +struct Alpha { + virtual void bravo(...); +}; +struct Charlie { + virtual ~Charlie() {} +}; +struct CharlieImpl : Charlie, Alpha { + void bravo(...) {} +} delta; + +// CHECK: define {{.*}} void @_ZThn8_N11CharlieImpl5bravoEz( Index: lib/CodeGen/CGVTables.cpp === --- lib/CodeGen/CGVTables.cpp +++ lib/CodeGen/CGVTables.cpp @@ -152,6 +152,10 @@ llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true); llvm::Function *BaseFn = cast(Callee); + // Ensure we don't have any temporary MD nodes before we clone the function. + if (DebugInfo) +DebugInfo->replaceTemporaryNodes(); + // Clone to thunk. llvm::ValueToValueMapTy VMap; llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap); Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -440,6 +440,7 @@ void completeTemplateDefinition(const ClassTemplateSpecializationDecl ); void completeUnusedClass(const CXXRecordDecl ); + void replaceTemporaryNodes(); /// Create debug info for a macro defined by a #define directive or a macro /// undefined by a #undef directive. Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -4091,18 +4091,7 @@ TheCU->setDWOId(Signature); } - -void CGDebugInfo::finalize() { - // Creating types might create further types - invalidating the current - // element and the size(), so don't cache/reference them. - for (size_t i = 0; i != ObjCInterfaceCache.size(); ++i) { -ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i]; -llvm::DIType *Ty = E.Type->getDecl()->getDefinition() - ? CreateTypeDefinition(E.Type, E.Unit) - : E.Decl; -DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty); - } - +void CGDebugInfo::replaceTemporaryNodes() { for (auto p : ReplaceMap) { assert(p.second); auto *Ty = cast(p.second); @@ -4115,6 +4104,21 @@ DBuilder.replaceTemporary(llvm::TempDIType(Ty), cast(it->second)); } + ReplaceMap.clear(); +} + +void CGDebugInfo::finalize() { + // Creating types might create further types - invalidating the current + // element and the size(), so don't cache/reference them. + for (size_t i = 0; i != ObjCInterfaceCache.size(); ++i) { +ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i]; +llvm::DIType *Ty = E.Type->getDecl()->getDefinition() + ? CreateTypeDefinition(E.Type, E.Unit) + : E.Decl; +DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty); + } + + replaceTemporaryNodes(); for (const auto : FwdDeclReplaceMap) { assert(p.second); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37604: Disable debuginfo-tests for non-native configurations
probinson added a comment. In https://reviews.llvm.org/D37604#864187, @aprantl wrote: > This seems reasonable to me, thanks! > When you commit this, could you please double-check that the tests are still > running on the green dragon builders? I'll also keep an eye on them. I was able to google "llvm green dragon" and find what looks like the right page, but I kind of would have expected to see a link on the llvm.org front page? Am I just not looking in the right place? https://reviews.llvm.org/D37604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37604: Disable debuginfo-tests for non-native configurations
probinson closed this revision. probinson added a comment. r312803. Forgot to put the tag in the commit message https://reviews.llvm.org/D37604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. In https://reviews.llvm.org/D37038#89, @aprantl wrote: > This may have gotten lost earlier: Would it be possible to instruct > CloneFunction to not clone any temporary MDNodes via one of the flags that > are passed to the ValueMapper? I did look at that, sorry for not reporting back. ValueMapper seems to be quite adamant about having non-temporary nodes. I can try pursuing that further but it would be quite the "learning experience" I think. Alternatively we could try deferring the thunk cloning until after all other codegen, but that also seems like a pretty hacky approach. https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37604: Disable debuginfo-tests for non-native configurations
probinson created this revision. This requires the host triple to match the default target triple, in order to run debuginfo-tests. It's possible this is too restrictive, but offhand it seems like a reasonable starting point. https://reviews.llvm.org/D37604 Files: lit.local.cfg Index: lit.local.cfg === --- lit.local.cfg +++ lit.local.cfg @@ -0,0 +1,3 @@ +# debuginfo-tests are not expected to pass in a cross-compilation setup. +if 'native' not in config.available_features: +config.unsupported = True Index: lit.local.cfg === --- lit.local.cfg +++ lit.local.cfg @@ -0,0 +1,3 @@ +# debuginfo-tests are not expected to pass in a cross-compilation setup. +if 'native' not in config.available_features: +config.unsupported = True ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37604: Disable debuginfo-tests for non-native configurations
probinson added a comment. The new file goes in the debuginfo-tests directory. It's a separate project so that's probably not obvious from the diff. https://reviews.llvm.org/D37604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson updated this revision to Diff 116711. probinson added a comment. Add a command-line flag to control emitting the template parameter children. Default to on for SCE debugger tuning. I am not super excited about my choice of option name or the help text; alternate suggestions welcome. I would prefer to eliminate the `` from the instance name as well, because our debugger reconstructs a name more to its liking from the parameter children. However, IIUC the name with params is used for deduplication in LTO, so that is probably not such a good idea. :-) https://reviews.llvm.org/D14358 Files: include/clang/Basic/LangOptions.def include/clang/Driver/Options.td lib/CodeGen/CGDebugInfo.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGenCXX/debug-info-fwd-template-param.cpp test/Driver/clang_f_opts.c Index: test/Driver/clang_f_opts.c === --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -495,6 +495,11 @@ // CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling // CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling +// RUN: %clang -### -S -fdebug-forward-template-params %s 2>&1 | FileCheck -check-prefix=CHECK-FWD-TMPL %s +// RUN: %clang -### -S -fno-debug-forward-template-params %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FWD-TMPL %s +// CHECK-FWD-TMPL: -fdebug-forward-template-params +// CHECK-NO-FWD-TMPL-NOT: -fdebug-forward-template-params + // RUN: %clang -### -S -fallow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-ALLOW-PLACEHOLDERS %s // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders Index: test/CodeGenCXX/debug-info-fwd-template-param.cpp === --- test/CodeGenCXX/debug-info-fwd-template-param.cpp +++ test/CodeGenCXX/debug-info-fwd-template-param.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -fdebug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD %s +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -fno-debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=NONE %s +// A forward declaration of a template instantiation should have template +// parameter children (if we ask for them). + +template class A { +public: + A(T val); +private: + T x; +}; + +struct B { + A *p; +}; + +B b; + +// CHILD: !DICompositeType(tag: DW_TAG_class_type, name: "A" +// CHILD-SAME: flags: DIFlagFwdDecl +// CHILD-SAME: templateParams: [[PARAM_LIST:![0-9]*]] +// CHILD: [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]} +// CHILD: [[PARAM]] = !DITemplateTypeParameter(name: "T", +// CHILD-SAME: type: [[CTYPE:![0-9]*]] +// CHILD: [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type +// CHILD-SAME: baseType: [[BTYPE:![0-9]*]] +// CHILD: [[BTYPE]] = !DIBasicType(name: "int" + +// NONE: !DICompositeType(tag: DW_TAG_class_type, name: "A" +// NONE-SAME: flags: DIFlagFwdDecl +// NONE-NOT: templateParams: +// NONE-SAME: ) Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2201,6 +2201,7 @@ Opts.EncodeExtendedBlockSig = Args.hasArg(OPT_fencode_extended_block_signature); Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls); + Opts.EmitFwdTemplateChildren = Args.hasArg(OPT_fdebug_forward_template_params); Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags); Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags); Opts.AlignDouble = Args.hasArg(OPT_malign_double); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2969,6 +2969,13 @@ CmdArgs.push_back("-generate-type-units"); } + // Decide how to render forward declarations of template instantiations. + // SCE defaults to on, others default to off. + if (Args.hasFlag(options::OPT_fdebug_forward_template_params, + options::OPT_fno_debug_forward_template_params, + DebuggerTuning == llvm::DebuggerKind::SCE)) +CmdArgs.push_back("-fdebug-forward-template-params"); + RenderDebugInfoCompressionArgs(Args, CmdArgs, D); } Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -833,6 +833,10 @@ llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName); + if
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
This revision was automatically updated to reflect the committed changes. Closed by commit rL31: [DWARF] Allow forward declarations of a class template instantiation (authored by probinson). Changed prior to commit: https://reviews.llvm.org/D14358?vs=116862=117030#toc Repository: rL LLVM https://reviews.llvm.org/D14358 Files: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -833,6 +833,10 @@ llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType( getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName); + if (CGM.getCodeGenOpts().DebugFwdTemplateParams) +if (auto *TSpecial = dyn_cast(RD)) + DBuilder.replaceArrays(RetTy, llvm::DINodeArray(), + CollectCXXTemplateParams(TSpecial, DefUnit)); ReplaceMap.emplace_back( std::piecewise_construct, std::make_tuple(Ty), std::make_tuple(static_cast(RetTy))); Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -2969,6 +2969,11 @@ CmdArgs.push_back("-generate-type-units"); } + // Decide how to render forward declarations of template instantiations. + // SCE wants full descriptions, others just get them in the name. + if (DebuggerTuning == llvm::DebuggerKind::SCE) +CmdArgs.push_back("-debug-forward-template-params"); + RenderDebugInfoCompressionArgs(Args, CmdArgs, D); } Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -528,6 +528,7 @@ Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); Opts.DebugExplicitImport = Triple.isPS4CPU(); + Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params); for (const auto : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) Opts.DebugPrefixMap.insert(StringRef(Arg).split('=')); Index: cfe/trunk/include/clang/Driver/CC1Options.td === --- cfe/trunk/include/clang/Driver/CC1Options.td +++ cfe/trunk/include/clang/Driver/CC1Options.td @@ -200,6 +200,9 @@ def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; +def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">, + HelpText<"Emit complete descriptions of template parameters in forward" + " declarations">; def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">, HelpText<"Emit an error if a C++ static local initializer would need a guard variable">; def no_implicit_float : Flag<["-"], "no-implicit-float">, Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def === --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def @@ -219,6 +219,10 @@ CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the ///< skeleton CU to allow for symbolication ///< of inline stack frames without .dwo files. +CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete + ///< template parameter descriptions in + ///< forward declarations (versus just + ///< including them in the name). CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists. Index: cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp === --- cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp +++ cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD %s +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -emit-llvm -o - | FileCheck --check-prefix=NONE %s +// A DWARF forward declaration of a template instantiation
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson added a comment. I think I will go ahead and commit this; it doesn't change the status quo for CodeView and if something is warranted we can do that in a follow-up. https://reviews.llvm.org/D14358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson added a comment. In https://reviews.llvm.org/D14358#882445, @dblaikie wrote: > > I would prefer to eliminate the `` from the instance name as well, > > because our debugger reconstructs a name more to its liking from the > > parameter children. However, IIUC the name with params is used for > > deduplication in LTO, so that is probably not such a good idea. :-) > > Though you have this out of tree? How do you cope with LTO there? We discovered that we had to keep them in the name for LTO. > I've not fully refreshed myself on the previous conversations - but it looks > like my thought was that this state proposed here is weird/inconsistent: The > parameters are already in the name, so adding them in the DIEs seems > redundant. If the parameters weren't in the name then this change might make > more sense. Our debugger throws away the params in the name, and relies on the children. The names as rendered in DWARF by Clang are not textually consistent with names as rendered by the demangler. Our debugger uses the children to construct names that are consistent with how the demangler works. Then it can match up type names returned by the demangler to type names it has constructed. Assuming I am not misunderstanding our debugger guys again, but that's my recollection. I believe we have talked previously about using a different scheme for deduplication that doesn't depend (or not so much) on the names. If we had that, we could eliminate params from the name, and save probably a noticeable chunk of space in the string section. I haven't tried to measure that, though. But we have to have the children in place before we can experiment with other deduplication schemes. There is also the pedantic point that DWARF doesn't say these child entries are optional, or omitted for forward declarations. I know gcc doesn't (or didn't, anyway; what I have locally is gcc 5.4) but gcc is not the arbiter of what constitutes conforming DWARF. https://reviews.llvm.org/D14358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35715: Preserve typedef names in debug info for template type parameters
probinson abandoned this revision. probinson added a comment. Abandoning. This change is irrelevant to the SCE debugger, and while I believe it could be made more complete and better reflect the original source (which is what the DWARF spec says names should be), I do not have time to pursue it. If somebody else feels moved to take it up, go ahead. https://reviews.llvm.org/D35715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson added a comment. In https://reviews.llvm.org/D14358#881666, @aprantl wrote: > Does this have to be exposed through the driver or could this be a cc1 option > only? My thinking was to make it easier for LLDB to play with it and decide whether DWARF conformance on this point is a good thing for them also. But I admit it's not something an end user would really care about or want to change. I can make it a cc1 option. Comment at: include/clang/Basic/LangOptions.def:144 BENIGN_LANGOPT(EmitAllDecls , 1, 0, "emitting all declarations") +BENIGN_LANGOPT(EmitFwdTemplateChildren, 1, 0, "emit template parameter children in forward declarations") LANGOPT(MathErrno , 1, 1, "errno in math functions") aprantl wrote: > Why is this a LangOpt instead of a CodeGenOpt? > Should it reference `debug` somewhere in the name? Because I thought EmitAllDecls was for debug info, and this felt related. But I see EmitAllDecls is not used in CGDebugInfo and generally we do put debug-related options in CodeGenOpt so I will move that. (Someday we should collect all that stuff into a DebugOpt class.) And I will rename it to DebugFwdTemplateChildren. https://reviews.llvm.org/D14358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14358: DWARF's forward decl of a template should have template parameters.
probinson added a reviewer: rnk. probinson added a comment. +rnk for the CodeView question. Comment at: include/clang/Frontend/CodeGenOptions.def:222 ///< of inline stack frames without .dwo files. +CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete + ///< template parameter descriptions in dblaikie wrote: > Maybe 'Decl' rather than 'Fwd'. Well, in a sense they are all declarations, and 'Fwd' is a clearer statement of the distinction this flag is trying to make. Unless you feel strongly I'd prefer to leave it as is. Comment at: lib/CodeGen/CGDebugInfo.cpp:836 llvm::DINode::FlagFwdDecl, FullName); + if (CGM.getCodeGenOpts().DebugFwdTemplateParams) +if (auto *TSpecial = dyn_cast(RD)) It just occurred to me... should CodeView care about this? Comment at: test/CodeGenCXX/debug-info-fwd-template-param.cpp:7 +template class A; +A *p; + dblaikie wrote: > Any particular reason for const int, rather than int? It was the illustrative example of the difference between the demangler ("int const") and clang ("const int") that the debugger guys tripped over, and so was in the source I started with when creating this test. I think you are correct, it is not important to have it. https://reviews.llvm.org/D14358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36501: add flag to undo ABI change in r310401
probinson added a comment. Locally we have a couple different tactics for dealing with changes that we can't support. A more coherent approach would be great. For example we defined a new TargetCXXABI::Kind value that is mostly GenericItaniumABI except where it isn't. I personally did not do most of the various ABI-related tweaks so I don't claim to have a good handle on them, and we have been slow to get these things upstream; but I'd love to make that happen. Repository: rL LLVM https://reviews.llvm.org/D36501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself
probinson added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:2934 +ABICompatArg->render(Args, CmdArgs); + // Add runtime flag for PS4 when PGO or Coverage are enabled. ``` else if (getToolChain().getTriple().isPS4()) CmdArgs.push_back("-fclang-abi-compat=3.2"); ``` Which lets us avoid piles of PS4 special cases all over everywhere. Sony is historically very conservative about compatibility, and we'll be happier defaulting it this way. Setting platform-specific defaults in the driver seems to be pretty common already, this is just one more. Repository: rL LLVM https://reviews.llvm.org/D36501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself
probinson added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:2934 +ABICompatArg->render(Args, CmdArgs); + // Add runtime flag for PS4 when PGO or Coverage are enabled. rsmith wrote: > probinson wrote: > > ``` > > else if (getToolChain().getTriple().isPS4()) > > CmdArgs.push_back("-fclang-abi-compat=3.2"); > > ``` > > > > Which lets us avoid piles of PS4 special cases all over everywhere. > > Sony is historically very conservative about compatibility, and we'll be > > happier defaulting it this way. Setting platform-specific defaults in the > > driver seems to be pretty common already, this is just one more. > I initially thought that made sense too, but I'm now fairly convinced that it > doesn't. > > > Let's take Darwin as an example. There are some facets of Darwin's platform > ABI that are determined by what old versions of Clang did, and other facets > of its platform ABI that have changed to match changes to the x86_64 psABI > and Itanium C++ ABI. But it's irrelevant where the platform ABI rules come > from; the point is that there is some set of platform ABI rules that you > could write down, and Clang attempts to implement those rules correctly by > default. > > The flag being added in this patch provides the ability to request that Clang > does something else: that it produces code that is ABI-compatible with what a > prior version of itself did when targeting that platform ABI. In particular, > we fixed the C++ calling convention for certain rare class types in Clang 5 > to conform to (an update to) the Itanium C++ ABI rules, and this patch allows > that to be undone. > > It seems to me that the situation for PS4 is exactly the same. There is some > platform ABI that you could write down, and Clang attempts to be compatible > with that by default. And it's irrelevant whether that's the ABI that Clang > 3.2 used or the ABI of GCC 2.95; it's just the platform ABI. This is not a > "be compatible with clang 3.2" mode, it is (as far as I can tell) the actual > platform ABI. > > > Let me repeat an example I gave before: suppose Clang 5 has some (accidental) > ABI change in it for PS4, and we fix that in Clang 6 to once again follow the > platform ABI by doing what Clang 3.2 did. In that case, building with > `-fclang-abi-compat=5` should theoretically reinstate that accidental ABI > change. > > Hopefully that should clarify that this does *not* actually let us avoid PS4 > special cases anywhere. ABI choices depend on both the platform ABI *and* on > the version of Clang that we're providing compatibility with (if any). > > > That said, it's clearly not up to me what the PS4 platform ABI is. If you > want to say that the PS4 platform ABI is actually something other than what > Clang 3.2 does, but all object code on your system is compiled in a > compatibility mode that diverges from the platform ABI and matches Clang 3.2, > then I would concede that we can remove the PS4 platform special cases > elsewhere and set a default here. But that sounds like a very strange > decision to make, and it creates a horrible problem for the meaning of the > `-fclang-abi-compat` flag: if someone in the future specifies > `-fclang-abi-compat=5` when targeting PS4, and Clang 5 by default set > `-fclang-abi-compat=3.2`, then are we targeting what Clang 5 would have done > by default or what Clang 5 would have done when told to be compatible with > itself? As you can see, this default would create a lot of confusion. On the other hand, if all the places that check ClangABICompat also check for PS4 and Darwin, then specifying `-fclang-abi-compat` while targeting PS4 or Darwin has no effect, and also no diagnostic. Which seems to make `-fclang-abi-compat` totally pointless. Is there a non-PS4/Darwin use-case for this flag? Repository: rL LLVM https://reviews.llvm.org/D36501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added inline comments. Comment at: lib/CodeGen/CGVTables.cpp:157 + if (DebugInfo) +DebugInfo->replaceTemporaryNodes(); + aprantl wrote: > Have you looked at what it would take to only finalize the nodes reachable > via the function? > Otherwise — have you audited that this is always safe? I do not know how to find nodes reachable from a particular function, either before or after they are finalized. GenerateVarArgsThunk is called after we do EmitGlobalFunctionDefinition on the function we are about to clone. The ReplaceMap holds replaceable forward type declarations, I think? So I can imagine that codegen for a subsequent function might need to create a complete type, even one that is reachable from the function we are about to clone. Of course I find the whole metadata memory management scheme pretty opaque, but this is my best guess about the situation. https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself
probinson added a comment. Sorry it took so long to wrap my head around this, but it has been about 20 years since I've had to accommodate an intentional ABI breakage, and that's actually what you want to do. Remembering that case, I have a model for this one, and I understand what you are doing now. Be that as it may, `-fclang-abi-compat` is meaningless on PS4, because every time there's a case for checking ClangABICompat, PS4 will want to do it the 3.2 way regardless. And we'll just make those checks in all those places. At least it will be relatively easy to audit, and I'm sure our licensees will be happy to ignore the new flag. So, I am convinced, and the patch LGTM. Repository: rL LLVM https://reviews.llvm.org/D36501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. Trying to understand the broader context here, I looked back through the list of revisions mentioned in PR33930 to see if that helped. When called on a method, CodeGenModule::EmitGlobalDefinition() calls CodeGenModule::EmitGlobalFunctionDefinition(), which in turn calls CodeGenFunction::GenerateCode(), which calls CodeGenFunction::FinishFunction(), which calls CGDebugInfo::EmitFunctionEnd(), which calls DIBuilder::finalizeSubprogram(). This is supposed to finalize the metadata for the subprogram. If the method is virtual, EmitGlobalDefinition() then calls getVTables().EmitThunks() which eventually gets to GenerateVarArgsThunk(). Which crashes when it tries to CloneFunction the original virtual method, because an operand of some piece of metadata is still temporary. So, either something happens such that EmitFunctionEnd() doesn't actually call finalizeSubprogram(), or finalizeSubprogram() doesn't finalize everything that it needs to finalize. finalizeSubprogram() retrieves the variables from the subprogram and handles them; what is it missing? https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. In https://reviews.llvm.org/D37038#854722, @probinson wrote: > finalizeSubprogram() retrieves the variables from the subprogram and handles > them; what is it missing? For temp-md-nodes2.cpp, the assertion in mapTopLevelUniquedNode() trips on a DICompositeType for CBdVfsImpl. This appears to be the "scope" operand of the (distinct) DISubprogram for "ReqCacheHint" which is the function being cloned. For temp-md-nodes1.cpp, the assertion in visitOperands() trips on a DICompositeType for "Charlie" but I haven't worked out where it's used yet. Is there a straightforward way to dump all the metadata for a function? Calling `print()` or 'dump()` just does the one node. https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. Dumping the whole module, the temporary DICompositeType node for CBdVfsImpl is used both as the scope node for the DISubprogram, and also as the baseType of a DIDerivedType which is a pointer type in the type list for the subprogram. Given that the DICompositeType is a scope for the method, but is still marked as a forward declaration, I'm guessing that the composite type will be expanded into a full type, but that apparently happens after codegen for its methods. So, it would be premature to finalize the metadata node at this point? https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself
probinson added a comment. I would prefer a diagnostic if PS4 && >3.2. Whether you map "latest" to 3.2 or diagnose that also, up to you, I'm okay either way. Repository: rL LLVM https://reviews.llvm.org/D36501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. In https://reviews.llvm.org/D37038#89, @aprantl wrote: > This may have gotten lost earlier: Would it be possible to instruct > CloneFunction to not clone any temporary MDNodes via one of the flags that > are passed to the ValueMapper? I tried that. Basically, the new flag just disabled all the `isUniqued` assertions. What I found for test case 1 is that the DIE for CharlieImpl was duplicated, but there was only one copy of Charlie. This is, hmmm, less bad (I hesitate to say "better") than the original patch, which duplicated both CharlieImpl and Charlie. Obviously we'd rather not duplicate anything. https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning
probinson added a comment. I now think the tactic to pursue is making sure the containing DICompositeType(s) for the method have complete descriptions, and RAUW the temporary nodes, prior to calling CloneFunction. Actually wading around in the MDNodes, Types, and Decls to accomplish that result promises to be "interesting" and "educational" (advice/suggestions welcome). https://reviews.llvm.org/D37038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39069: CodeGen: Fix missing debug loc due to alloca
probinson added a comment. Anytime the code between saveIP() and restoreIP() could set the current debug location, it needs to be saved/restored along with the insertion point. I have to say the problem is not obvious to me here, so maybe saveIP/restoreIP should be changed (or eliminated in favor of always using InsertPointGuard). I'm not seeing a lot of places where saveIP/restoreIP are used. The test looks like all it's doing is verifying both calls have a debug location at all. It could verify that both calls have the _same_ debug location, which I would find much more robust and convincing. https://reviews.llvm.org/D39069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39622: Fix type name generation in DWARF for template instantiations with enum types and template specializations
probinson added a comment. Philosophically, mangled names and DWARF information serve different purposes, and I don't think you will find one true solution where both of them can yield the same name that everyone will be happy with. Mangled names exist to provide unique and reproducible identifiers for the "same" entity across compilation units. They are carefully specified (for example) to allow a linker to associate a reference in one object file to a definition in a different object file, and be guaranteed that the association is correct. A demangled name is a necessarily context-free translation of the mangled name into something that has a closer relationship to how a human would think of or write the name of the thing, but isn't necessarily the only way to write the name of the thing. DWARF names are (deliberately not carefully specified) strings that ought to bear some relationship to how source code would name the thing, but you probably don't want to attach semantic significance to those names. This is rather emphatically true for names containing template parameters. Typedefs (and their recent offspring, 'using' aliases) are your sworn enemy here. Enums, as you have found, are also a problem. Basically, the type of an entity does not have a unique name, and trying to coerce different representations of the type into having the same unique name is a losing battle. https://reviews.llvm.org/D39622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39239: [AST] Incorrectly qualified unscoped enumeration as template actual parameter.
probinson added a comment. Have you tried the GDB suite yet? If it has no problems, and we can make LLDB happy, I'm okay with it. https://reviews.llvm.org/D39239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40948: Switch Clang's default C++ language target to C++14
probinson added a reviewer: rjmccall. probinson added a comment. +rjmccall for the codegen bits. Comment at: clang/test/SemaCXX/new-array-size-conv.cpp:1 -// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=gnu++98 %s // RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s I think the intent here was "whatever the current default is" and not specifically gnu++98, because the next line explicitly specifies c++98. So, unless this test fails miserably for C++14 (which I wouldn't expect) I think it should be adapted to whatever gets reported for that dialect. Repository: rC Clang https://reviews.llvm.org/D40948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40712: Add cc1 flag enabling the function stack size section that was added in r319430
probinson added a comment. The title says "Add cc1 option..." which to me implies a "cc1 only" option. What you're actually doing is adding a driver option. Please update the title. Comment at: test/Driver/stack-size-section.c:2 +// RUN: %clang -target x86_64-unknown %s -S -o %t +// RUN: not grep '.stack_sizes' %t +// RUN: %clang -target x86_64-unknown -fstack-size-section %s -S -o %t Driver tests use `-###` to report the command line they'd use to invoke cc1, and verify the presence or absence of the option that you expect to see in the cc1 command line. The actual functionality test (presence or absence of something in the IR or whatever) should go in some other more appropriate place. Also, we use FileCheck not grep. https://reviews.llvm.org/D40712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41044: Implementation of -fextend-lifetimes and -fextend-this-ptr to aid with debugging of optimized code
probinson added a comment. I should note we've had at least one request to make this specifiable per-function, which would mean defining an attribute to control the emission of the fake-use intrinsics. Doing the feature that way would be consistent with 'optnone'. https://reviews.llvm.org/D41044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40948: Switch Clang's default C++ language target to C++14
probinson added inline comments. Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1733 // The PS4 uses C++11 as the default C++ standard. - if (T.isPS4()) -LangStd = LangStandard::lang_gnucxx11; - else -LangStd = LangStandard::lang_gnucxx98; + LangStd = LangStandard::lang_gnucxx14; break; filcab wrote: > t.p.northover wrote: > > filcab wrote: > > > Why are you changing the PS4 default too? > > Paul Robinson indicated that it was feasible back in March: > > http://lists.llvm.org/pipermail/cfe-dev/2017-March/052986.html. If that's > > changed I'd be happy to put it back to C++11, but he's one of the main > > people (rightly) bugging me about this so I'd be slightly surprised. > > > > I also notice the comment crept back in. Bother. > Sounds good, then. If Paul is happy with that change, I don't see a problem > there (assuming you do get rid of the comment for good :-) ). > > Thank you, > > Filipe Yes, PS4 product management is happy to move forward. Repository: rC Clang https://reviews.llvm.org/D40948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39239: [AST] Incorrectly qualified unscoped enumeration as template actual parameter.
probinson added a comment. Have you tried this change against the GDB and LLDB test suites? If they have failures then we should think about whether those tests are over-specific or whether we should put this under a tuning option. https://reviews.llvm.org/D39239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden
probinson added a comment. In https://reviews.llvm.org/D46767#1096746, @rsmith wrote: > Everything old is new again. If only that were true about my brain. :-P > This was discussed when `-fclang-abi-compat` was introduced; see > https://reviews.llvm.org/D36501 for the argument why this patch is the wrong > way of modeling an ABI. Forcing the `ClangABICompat` language option as a way > of "tricking" Clang into producing the PS4 ABI is a hack. The various ABI > changes that `-fclang-abi-compat=` controls are simply part of the PS4 ABI, > and that knowledge should idealistically be carried by the CodeGen (etc) code > that knows about PS4, rather than by imagining that there is some other PS4 > ABI that Clang would produces at version `Latest`, and that we're asking for > a compatibility version of it. Muchas gracias for the reminder of the previous discussion; it's quite true that on our side we have not done our due diligence in making sure that upstream Clang fully supports the PS4 ABI, and that `-fclang-abi-compat` is the wrong way to do this. It needs to become part of my team's consciousness and collective memory that these sorts of expedient hacks are the wrong approach. > This will go wrong if we ever release (or have ever released) a Clang version > that fails to properly implement the PS4 ABI. Yeah, we crossed that bridge years ago, but nobody has been brave enough to try to deliver that patch upstream. Actually I think there are two, but as they typically don't cause any merge conflicts they're not at top-of-mind for anybody, even me. > However, we should not issue a warning for use of the flag. Remember that the > flag means "please be ABI-compatible with Clang version X.Y". Because all > versions of Clang that target PS4 use the same ABI, the flag is a no-op on > that target (at least for now, until we accidentally introduce an ABI break). > So we should not be warning on it, just silently accepting it and doing what > it says -- which for now is nothing. Got it. I'll take an action to straighten this one out. Repository: rC Clang https://reviews.llvm.org/D46767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden
probinson accepted this revision. probinson added a comment. This revision is now accepted and ready to land. LGTM Repository: rC Clang https://reviews.llvm.org/D46767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46439: [Sema] Fix incorrect packed aligned structure layout
probinson added a comment. This wouldn't be another layout/ABI breakage, would it? Repository: rC Clang https://reviews.llvm.org/D46439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47260: Testcase for dwarf 5 crash/assert when calculating a checksum for an expansion
probinson added a comment. @trixirt do you mind if I commandeer this review? I think I have a patch. Repository: rC Clang https://reviews.llvm.org/D47260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47260: [DebugInfo] Skip MD5 checksums of preprocessed files
probinson updated this revision to Diff 148663. probinson added a comment. Upload patch to suppress checksums when we see a preprocessed file. https://reviews.llvm.org/D47260 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/test/CodeGen/md5-checksum-crash.c Index: clang/test/CodeGen/md5-checksum-crash.c === --- /dev/null +++ clang/test/CodeGen/md5-checksum-crash.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -dwarf-version=5 %s -emit-llvm -o- | FileCheck %s +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-kind=limited %s -emit-llvm -o- | FileCheck %s + +// This had been crashing, no MD5 checksum for string.h. +// Now if there are #line directives, don't bother with checksums +// as a preprocessed file won't properly reflect the original source. +#define __NTH fct +void fn1() {} +# 7 "/usr/include/string.h" +void __NTH() {} +// Verify no checksum attributes on these files. +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}") +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}") Index: clang/lib/CodeGen/CGDebugInfo.h === --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ CodeGenModule const codegenoptions::DebugInfoKind DebugKind; bool DebugTypeExtRefs; + mutable bool EmitFileChecksums; llvm::DIBuilder DBuilder; llvm::DICompileUnit *TheCU = nullptr; ModuleMap *ClangModuleMap = nullptr; Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,19 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; - llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, ); - if (Invalid) + const SrcMgr::SLocEntry = SM.getSLocEntry(FID, ); + if (Invalid || !Entry.isFile()) return None; + if (Entry.getFile().hasLineDirectives()) { +EmitFileChecksums = false; +return None; + } + llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID); llvm::MD5 Hash; llvm::MD5::MD5Result Result; Index: clang/test/CodeGen/md5-checksum-crash.c === --- /dev/null +++ clang/test/CodeGen/md5-checksum-crash.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -dwarf-version=5 %s -emit-llvm -o- | FileCheck %s +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-kind=limited %s -emit-llvm -o- | FileCheck %s + +// This had been crashing, no MD5 checksum for string.h. +// Now if there are #line directives, don't bother with checksums +// as a preprocessed file won't properly reflect the original source. +#define __NTH fct +void fn1() {} +# 7 "/usr/include/string.h" +void __NTH() {} +// Verify no checksum attributes on these files. +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}") +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}") Index: clang/lib/CodeGen/CGDebugInfo.h === --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ CodeGenModule const codegenoptions::DebugInfoKind DebugKind; bool DebugTypeExtRefs; + mutable bool EmitFileChecksums; llvm::DIBuilder DBuilder; llvm::DICompileUnit *TheCU = nullptr; ModuleMap *ClangModuleMap = nullptr; Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,19 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; -
[PATCH] D47260: [DebugInfo] Skip MD5 checksums of preprocessed files
This revision was automatically updated to reflect the committed changes. probinson marked an inline comment as done. Closed by commit rL11: [DebugInfo] Dont bother with MD5 checksums of preprocessed files. (authored by probinson, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47260?vs=148663=148668#toc Repository: rL LLVM https://reviews.llvm.org/D47260 Files: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/test/CodeGen/md5-checksum-crash.c Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,21 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; - llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, ); - if (Invalid) + const SrcMgr::SLocEntry = SM.getSLocEntry(FID, ); + if (Invalid || !Entry.isFile()) return None; + if (Entry.getFile().hasLineDirectives()) { +// This must be a preprocessed file; its content won't match the original +// source; therefore checksumming the text we have is pointless or wrong. +EmitFileChecksums = false; +return None; + } + llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID); llvm::MD5 Hash; llvm::MD5::MD5Result Result; Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h === --- cfe/trunk/lib/CodeGen/CGDebugInfo.h +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ CodeGenModule const codegenoptions::DebugInfoKind DebugKind; bool DebugTypeExtRefs; + mutable bool EmitFileChecksums; llvm::DIBuilder DBuilder; llvm::DICompileUnit *TheCU = nullptr; ModuleMap *ClangModuleMap = nullptr; Index: cfe/trunk/test/CodeGen/md5-checksum-crash.c === --- cfe/trunk/test/CodeGen/md5-checksum-crash.c +++ cfe/trunk/test/CodeGen/md5-checksum-crash.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -dwarf-version=5 %s -emit-llvm -o- | FileCheck %s +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-kind=limited %s -emit-llvm -o- | FileCheck %s + +// This had been crashing, no MD5 checksum for string.h. +// Now if there are #line directives, don't bother with checksums +// as a preprocessed file won't properly reflect the original source. +#define __NTH fct +void fn1() {} +# 7 "/usr/include/string.h" +void __NTH() {} +// Verify no checksum attributes on these files. +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}") +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}") Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,21 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; - llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, ); - if (Invalid) + const SrcMgr::SLocEntry = SM.getSLocEntry(FID, ); + if (Invalid || !Entry.isFile()) return None; + if (Entry.getFile().hasLineDirectives()) { +// This must be a preprocessed file; its content won't match the original +// source; therefore checksumming the text we have is pointless or wrong. +EmitFileChecksums = false; +return None; + } + llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID); llvm::MD5 Hash; llvm::MD5::MD5Result Result; Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h === --- cfe/trunk/lib/CodeGen/CGDebugInfo.h +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ CodeGenModule const codegenoptions::DebugInfoKind DebugKind; bool
[PATCH] D47375: [Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.
probinson added a comment. LGTM with the indicated test tweak, but best if @filcab also takes a look. Comment at: lib/Driver/ToolChains/PS4CPU.cpp:87 +CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a"); + } +} Don't bother with braces for a one-line `if` body. Comment at: test/Driver/fsanitize.c:624 +// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a // CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}} // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak Repeat this NOT line before the new check? to preserve the property described in the comment. Repository: rC Clang https://reviews.llvm.org/D47375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47291: Proposal to make rtti errors more generic.
probinson added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6729 def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires enabling RTTI">; filcab wrote: > I'd prefer to have the way to enable RTTI mentioned in the message. Could we > have something like `ToolChain::getRTTIMode()` and have a "RTTI was on/of" or > "RTTI defaulted to on/off"? That way we'd be able to have a message similar > to the current one (mentioning "you passed -fno-rtti") on platforms that > default to RTTI=on, and have your updated message (possibly with a mention of > "use -frtti") on platforms that default to RTTI=off. > > (This is a minor usability comment about this patch, I don't consider it a > blocker or anything) If the options are spelled differently for clang-cl and we had a way to retrieve the appropriate spellings, providing the option to use in the diagnostic does seem like a nice touch. Repository: rC Clang https://reviews.llvm.org/D47291 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47260: [DebugInfo] Skip MD5 checksums of preprocessed files
This revision was automatically updated to reflect the committed changes. probinson marked an inline comment as done. Closed by commit rC11: [DebugInfo] Dont bother with MD5 checksums of preprocessed files. (authored by probinson, committed by ). Changed prior to commit: https://reviews.llvm.org/D47260?vs=148663=148667#toc Repository: rL LLVM https://reviews.llvm.org/D47260 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h test/CodeGen/md5-checksum-crash.c Index: test/CodeGen/md5-checksum-crash.c === --- test/CodeGen/md5-checksum-crash.c +++ test/CodeGen/md5-checksum-crash.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -dwarf-version=5 %s -emit-llvm -o- | FileCheck %s +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-kind=limited %s -emit-llvm -o- | FileCheck %s + +// This had been crashing, no MD5 checksum for string.h. +// Now if there are #line directives, don't bother with checksums +// as a preprocessed file won't properly reflect the original source. +#define __NTH fct +void fn1() {} +# 7 "/usr/include/string.h" +void __NTH() {} +// Verify no checksum attributes on these files. +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}") +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}") Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,21 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; - llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, ); - if (Invalid) + const SrcMgr::SLocEntry = SM.getSLocEntry(FID, ); + if (Invalid || !Entry.isFile()) return None; + if (Entry.getFile().hasLineDirectives()) { +// This must be a preprocessed file; its content won't match the original +// source; therefore checksumming the text we have is pointless or wrong. +EmitFileChecksums = false; +return None; + } + llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID); llvm::MD5 Hash; llvm::MD5::MD5Result Result; Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ CodeGenModule const codegenoptions::DebugInfoKind DebugKind; bool DebugTypeExtRefs; + mutable bool EmitFileChecksums; llvm::DIBuilder DBuilder; llvm::DICompileUnit *TheCU = nullptr; ModuleMap *ClangModuleMap = nullptr; Index: test/CodeGen/md5-checksum-crash.c === --- test/CodeGen/md5-checksum-crash.c +++ test/CodeGen/md5-checksum-crash.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -dwarf-version=5 %s -emit-llvm -o- | FileCheck %s +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-kind=limited %s -emit-llvm -o- | FileCheck %s + +// This had been crashing, no MD5 checksum for string.h. +// Now if there are #line directives, don't bother with checksums +// as a preprocessed file won't properly reflect the original source. +#define __NTH fct +void fn1() {} +# 7 "/usr/include/string.h" +void __NTH() {} +// Verify no checksum attributes on these files. +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}") +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}") Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -67,6 +67,8 @@ DBuilder(CGM.getModule()) { for (const auto : CGM.getCodeGenOpts().DebugPrefixMap) DebugPrefixMap[KV.first] = KV.second; + EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView || + CGM.getCodeGenOpts().DwarfVersion >= 5; CreateCompileUnit(); } @@ -365,15 +367,21 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const { Checksum.clear(); - if (!CGM.getCodeGenOpts().EmitCodeView && - CGM.getCodeGenOpts().DwarfVersion < 5) + if (!EmitFileChecksums) return None; SourceManager = CGM.getContext().getSourceManager(); bool Invalid; - llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, ); - if (Invalid) + const SrcMgr::SLocEntry = SM.getSLocEntry(FID, );
[PATCH] D47260: [DebugInfo] Skip MD5 checksums of preprocessed files
probinson marked an inline comment as done. probinson added inline comments. Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:378 return None; + if (Entry.getFile().hasLineDirectives()) { +EmitFileChecksums = false; aprantl wrote: > Can you add a comment explaining why we are doing this here? Of course. https://reviews.llvm.org/D47260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits