summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenAction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Change setDiagnosticsOutputFile to take a unique_ptr from a raw pointer (NFC)Mehdi Amini2016-11-191-1/+2
| | | | | | | | | | | | | | Summary: This makes it explicit that ownership is taken. Also replace all `new` with make_unique<> at call sites. Reviewers: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26884 llvm-svn: 287449
* Adapt to llvm NamedRegionTimer changesMatthias Braun2016-11-181-1/+1
| | | | | | We have to specify a name and description for the timers and groups now. llvm-svn: 287371
* Bitcode: Change module reader functions to return an llvm::Expected.Peter Collingbourne2016-11-131-4/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D26562 llvm-svn: 286752
* Mirror the llvm changes that split Bitcode/ReaderWriter.hTeresa Johnson2016-11-111-1/+1
| | | | | | | | | | The change in D26502 splits ReaderWriter.h, which contains the APIs into both the BitReader and BitWriter libraries, into BitcodeReader.h and BitcodeWriter.h. Change clang uses to the appropriate split header(s). llvm-svn: 286567
* IR, Bitcode: Change bitcode reader to no longer own its memory buffer.Peter Collingbourne2016-11-081-1/+1
| | | | | | | | | | | | | | | | | | Unique ownership is just one possible ownership pattern for the memory buffer underlying the bitcode reader. In practice, as this patch shows, ownership can often reside at a higher level. With the upcoming change to allow multiple modules in a single bitcode file, it will no longer be appropriate for modules to generally have unique ownership of their memory buffer. The C API exposes the ownership relation via the LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModuleInContext2 functions, so we still need some way for the module to own the memory buffer. This patch does so by adding an owned memory buffer field to Module, and using it in a few other places where it is convenient. Differential Revision: https://reviews.llvm.org/D26384 llvm-svn: 286214
* Add an option to save the backend-produced YAML optimization record to a fileHal Finkel2016-10-111-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The backend now has the capability to save information from optimizations, the same information that can be used to generate optimization diagnostics but in machine-consumable form, into an output file. This can be enabled when using opt (see r282539), and this change enables it when using clang. The idea is that other tools will be able to consume these files, and perhaps in combination with the original source code, produce various kinds of optimization reports for users (and for compiler developers). We now have at-least two tools that can consume these files: * tools/llvm-opt-report * utils/opt-viewer Using the flag -fsave-optimization-record will cause the YAML file to be generated; the file name will be based on the output file name (if we're using -c or -S and have an output name), or the input file name. When we're using CUDA, or some other offloading mechanism, separate files are generated for each backend target. The output file name can be specified by the user using -foptimization-record-file=filename. Differential Revision: https://reviews.llvm.org/D25225 llvm-svn: 283834
* Use StringRef in Pass/PassManager APIs (NFC)Mehdi Amini2016-10-011-1/+1
| | | | llvm-svn: 283004
* Shorten DiagnosticInfoOptimizationRemark* to OptimizationRemark*. NFCAdam Nemet2016-09-271-21/+15
| | | | | | | With the new streaming interface in LLVM, these class names need to be typed a lot and it's way too looong. llvm-svn: 282545
* Adapt to LLVM optimization remark interface change. NFCAdam Nemet2016-09-271-1/+1
| | | | llvm-svn: 282540
* Revert "Adapt to LLVM optimization remark interface change. NFC"Adam Nemet2016-09-271-1/+1
| | | | | | This reverts commit r282500. llvm-svn: 282504
* Adapt to LLVM optimization remark interface change. NFCAdam Nemet2016-09-271-1/+1
| | | | llvm-svn: 282500
* Reapply r281276 with passing -emit-llvm in one of the testsAdam Nemet2016-09-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original commit message: Add -fdiagnostics-show-hotness Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281293
* Revert "Add -fdiagnostics-show-hotness"Adam Nemet2016-09-131-9/+1
| | | | | | | | This reverts commit r281276. Many bots are failing. llvm-svn: 281279
* Add -fdiagnostics-show-hotnessAdam Nemet2016-09-121-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281276
* [CodeGen] Handle recursion in LLVMIRGeneration Timer.Davide Italiano2016-07-211-8/+23
| | | | | | | | | | | | This can happen when emitting a local decl, which triggers loading a decl imported from an AST file, which we then hand to the AST consumer. Timer is not allowed to recurse so an assertion fire. Keep a reference counter to avoid this problem. LGTM'd by Richard Smith on IRC. Differential Revision: https://reviews.llvm.org/D20748 llvm-svn: 276242
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne2016-07-151-10/+12
| | | | | | | | | | | | | | This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream implicitly owned by the CompilerInstance. This in most cases required that I move ownership of the output stream to the relevant ASTConsumer. The motivation for this change is to allow BackendConsumer to be a client of interfaces such as D20268 which take ownership of the output stream. Differential Revision: http://reviews.llvm.org/D21537 llvm-svn: 275507
* [Diag] Add getter shouldAlwaysPrint. NFCAdam Nemet2016-06-291-3/+3
| | | | | | | | | | For the new hotness attribute, the API will take the pass rather than the pass name so we can no longer play the trick of AlwaysPrint being a special pass name. This adds a getter to help the transition. There is also a corresponding llvm patch. llvm-svn: 274101
* Update for DiagnosticInfoStackSize changesMatt Arsenault2016-06-201-1/+2
| | | | llvm-svn: 273178
* Embed bitcode in object file (clang cc1 part)Steven Wu2016-05-111-0/+6
| | | | | | | | | | | | | | | | | | | Summary: Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1 option is used, clang will embed both the input bitcode and cc1 commandline into the bitcode in special sections before compiling to the object file. Using -fembed-bitcode-marker will only introduce a marker in both sections. Depends on D17390 Reviewers: rsmith Subscribers: yaron.keren, vsk, cfe-commits Differential Revision: http://reviews.llvm.org/D17392 llvm-svn: 269202
* Adding omitted column to invalid loc diagnostic.Ben Craig2016-05-061-1/+1
| | | | | | | | | | | note_fe_backend_invalid_loc expects three arguments (file, line, column), and will assert when only given two. The other two places in this file that use note_fe_backend_invalid_loc already supply the Column for the third parameter. http://reviews.llvm.org/D19936 llvm-svn: 268732
* Enable ODR uniquing of DITypes for ThinLTO backendsTeresa Johnson2016-04-201-0/+5
| | | | | | | | | | | | | | | | | Summary: This is a follow-on to apply Duncan's new DIType ODR uniquing from r266549 and r266713 in more places. When invoking ThinLTO backend compiles via clang (for a distributed build), invoke enableDebugTypeODRUniquing() before parsing the module. Reviewers: dexonsmith, joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D19264 llvm-svn: 266852
* Restore slightly less dodgy diagnostic handler for inline asmTim Northover2016-04-061-0/+25
| | | | | | | | Turns out it was there mostly to prevent Clang asking people to report a bug. This time we report something to Clang's real diagnostics handler so that it exits with something approximating a real error and tidies up after itself. llvm-svn: 265592
* Diagnostics: remove dodgy handler for bitcode inlineasm diagnostics.Tim Northover2016-03-311-8/+0
| | | | | | | | Whatever crash it was there to present appears to have been fixed in the backend now, and it had the nasty side-effect of causing clang to exit(0) and leave a .o containing goodness knows what even when an error hit. llvm-svn: 265038
* For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann2016-03-301-3/+3
| | | | | | | | | | | | | | ...as that is apparently what MSVC does. This is an updated version of r263738, which had to be reverted in r263740 due to test failures. The original version had erroneously emitted functions that are defined in class templates, too (see the updated "Handle friend functions" code in EmitDeferredDecls, lib/CodeGen/ModuleBuilder.cpp). (The updated tests needed to be split out into their own dllexport-ms-friend.cpp because of the CHECK-NOTs which would have interfered with subsequent CHECK-DAGs in dllexport.cpp.) Differential Revision: http://reviews.llvm.org/D18430 llvm-svn: 264841
* Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner2016-03-171-3/+3
| | | | | | | | | This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
* For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner2016-03-171-3/+3
| | | | | | | | | | | | Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
* Temporarily revert these patches:Eric Christopher2016-03-121-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 60d9845f6a037122d9be9a6d92d4de617ef45b04 Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 18:48:02 2016 +0000 Fix clang crash: when CodeGenAction is initialized without a context, use the member and not the parameter From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263273 91177308-0d34-0410-b5e6-96231b3b80d8 commit af7ce3bf04a75ad5124b457b805df26006bd215b Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:32:58 2016 +0000 Fix build: use -> with pointers and not . Silly typo. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263267 91177308-0d34-0410-b5e6-96231b3b80d8 commit d0eea119192814954e7368c77d0dc5a9eeec1fbb Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:15:44 2016 +0000 Remove compile time PreserveName switch based on NDEBUG Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263257 91177308-0d34-0410-b5e6-96231b3b80d8 until we can fix the Release builds. This reverts commits 263257, 263267, 263273 llvm-svn: 263320
* Fix clang crash: when CodeGenAction is initialized without a context, use ↵Mehdi Amini2016-03-111-1/+1
| | | | | | | the member and not the parameter From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263273
* Fix build: use -> with pointers and not .Mehdi Amini2016-03-111-1/+1
| | | | | | | Silly typo. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263267
* Remove compile time PreserveName switch based on NDEBUGMehdi Amini2016-03-111-1/+7
| | | | | | | | | | | | | | | Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263257
* Make TargetInfo store an actual DataLayout instead of a string.James Y Knight2016-03-041-2/+2
| | | | | | | | | | | | | | Use it to calculate UserLabelPrefix, instead of specifying it (often incorrectly). Note that the *actual* user label prefix has always come from the DataLayout, and is handled within LLVM. The main thing clang's TargetInfo::UserLabelPrefix did was to set the #define value. Having these be different from each-other is just silly. Differential Revision: http://reviews.llvm.org/D17183 llvm-svn: 262737
* Serialize `#pragma detect_mismatch`.Nico Weber2016-03-021-5/+0
| | | | | | | This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
* Serialize `#pragma comment`.Nico Weber2016-03-021-8/+0
| | | | | | | | | | | | | | `#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
* Avoid double deletion in Clang driver.Serge Pavlov2016-02-181-21/+8
| | | | | | | | | | | | | | | | Llvm module object is shared between CodeGenerator and BackendConsumer, in both classes it is stored as std::unique_ptr, which is not a good design solution and can cause double deletion error. Usually it does not occur because in BackendConsumer::HandleTranslationUnit the ownership of CodeGenerator over the module is taken away. If however this method is not called, the module is deleted twice and compiler crashes. As the module owned by BackendConsumer is always the same as CodeGenerator has, pointer to llvm module can be removed from BackendGenerator. Differential Revision: http://reviews.llvm.org/D15450 llvm-svn: 261222
* Add backend dignostic printer for unsupported featuresOliver Stannard2016-02-021-11/+64
| | | | | | | | | | | | | | Re-commit of r258950 after fixing layering violation. The related LLVM patch adds a backend diagnostic type for reporting unsupported features, this adds a printer for them to clang. In the case where debug location information is not available, I've changed the printer to report the location as the first line of the function, rather than the closing brace, as the latter does not give the user any information. This also affects optimisation remarks. llvm-svn: 259499
* Revert r259036, it introduces a cyclic library dependencyOliver Stannard2016-01-281-65/+11
| | | | llvm-svn: 259043
* Add backend dignostic printer for unsupported featuresOliver Stannard2016-01-281-11/+65
| | | | | | | | | | | | | | | | | | Re-commit of r258950 after fixing layering violation. Add backend dignostic printer for unsupported features The related LLVM patch adds a backend diagnostic type for reporting unsupported features, this adds a printer for them to clang. In the case where debug location information is not available, I've changed the printer to report the location as the first line of the function, rather than the closing brace, as the latter does not give the user any information. This also affects optimisation remarks. Differential Revision: http://reviews.llvm.org/D16591 llvm-svn: 259036
* Revert r258951 (and r258950), "Refactor backend diagnostics for unsupported ↵NAKAMURA Takumi2016-01-281-64/+11
| | | | | | | | | | | features" It broke layering violation in LLVMIR. clang r258950 "Add backend dignostic printer for unsupported features" llvm r258951 "Refactor backend diagnostics for unsupported features" llvm-svn: 259016
* Add backend dignostic printer for unsupported featuresOliver Stannard2016-01-271-11/+64
| | | | | | | | | | | | | | The related LLVM patch adds a backend diagnostic type for reporting unsupported features, this adds a printer for them to clang. In the case where debug location information is not available, I've changed the printer to report the location as the first line of the function, rather than the closing brace, as the latter does not give the user any information. This also affects optimisation remarks. Differential Revision: http://reviews.llvm.org/D16591 llvm-svn: 258950
* [MS ABI] Allow a member pointers' converted type to changeDavid Majnemer2016-01-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Member pointers in the MS ABI are tricky for a variety of reasons. The size of a member pointer is indeterminate until the program reaches a point where the representation is required to be known. However, *pointers* to member pointers may exist without knowing the pointee type's representation. In these cases, we synthesize an opaque LLVM type for the pointee type. However, we can be in a situation where the underlying member pointer's representation became known mid-way through the program. To account for this, we attempted to manicure CodeGen's type-cache so that we can replace the opaque member pointer type with the real deal while leaving the pointer types unperturbed. This, unfortunately, is a problematic approach to take as we will violate CodeGen's invariants. These violations are mostly harmless but let's do the right thing instead: invalidate the type-cache if a member pointer's LLVM representation changes. This fixes PR26313. llvm-svn: 258839
* Introduce -fsanitize-stats flag.Peter Collingbourne2016-01-161-2/+2
| | | | | | | | | This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16175 llvm-svn: 257971
* [ThinLTO] Leverage new in-place renaming supportTeresa Johnson2016-01-081-35/+1
| | | | | | | | | | | | Due to the new in-place renaming support added in r257174, we no longer need to invoke ThinLTO global renaming from clang. It will be invoked on the module in the FunctionImport pass (by an immediately following llvm commit). As a result, we don't need to load the FunctionInfoIndex as early, so that is moved down into EmitAssemblyHelper::EmitAssembly. llvm-svn: 257179
* Update for llvm api change.Rafael Espindola2015-12-161-2/+2
| | | | llvm-svn: 255843
* Update for llvm api change.Rafael Espindola2015-12-141-33/+27
| | | | llvm-svn: 255572
* [ThinLTO] Option to invoke ThinLTO backend passes and importingTeresa Johnson2015-12-071-21/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds new option -fthinlto-index=<file> to invoke the LTO pipeline along with function importing via clang using the supplied function summary index file. This supports invoking the parallel ThinLTO backend processes in a distributed build environment via clang. Additionally, this causes the module linker to be invoked on the bitcode file being compiled to perform any necessary promotion and renaming of locals that are exported via the function summary index file. Add a couple tests that confirm we get expected errors when we try to use the new option on a file that isn't bitcode, or specify an invalid index file. The tests also confirm that we trigger the expected function import pass. Depends on D15024 Reviewers: joker.eph, dexonsmith Subscribers: joker.eph, davidxl, cfe-commits Differential Revision: http://reviews.llvm.org/D15025 llvm-svn: 254927
* Update for llvm api change.Rafael Espindola2015-12-011-1/+1
| | | | llvm-svn: 254450
* Allow linking multiple bitcode files.Artem Belevich2015-10-271-53/+61
| | | | | | | | | | | | | | | | | | Linking options for particular file depend on the option that specifies the file. Currently there are two: * -mlink-bitcode-file links in complete content of the specified file. * -mlink-cuda-bitcode links in only the symbols needed by current TU. Linked symbols are internalized. This bitcode linking mode is used to link device-specific bitcode provided by CUDA. Files are linked in order they are specified on command line. -mlink-cuda-bitcode replaces -fcuda-uses-libdevice flag. Differential Revision: http://reviews.llvm.org/D13913 llvm-svn: 251427
* [CUDA] Postprocess bitcode linked in during device-side CUDA compilation.Artem Belevich2015-09-101-1/+6
| | | | | | | | Link in and internalize the symbols we need from supplied bitcode library. Differential Revision: http://reviews.llvm.org/D11664 llvm-svn: 247317
* Initialize the AST consumer as soon as we have both an ASTConsumer and anRichard Smith2015-08-181-5/+2
| | | | | | | ASTContext. Fixes some cases where we could previously initialize the AST consumer more than once. llvm-svn: 245346
OpenPOWER on IntegriCloud