summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* D34444: Teach codegen to work in incremental processing mode.Vassil Vassilev2017-08-271-0/+13
| | | | | | | | | | | | | | When isIncrementalProcessingEnabled is on we might want to produce multiple llvm::Modules. This patch allows the clients to start a new llvm::Module, allowing CodeGen to continue working after a HandleEndOfTranslationUnit call. This should give the necessary facilities to write a unittest for D34059. As discussed in the review this is meant to give us a way to proceed forward in our efforts to upstream our interpreter-related patches. The design of this will likely change soon. llvm-svn: 311843
* [Coverage] Don't emit mappings for functions in dependent contexts (fixes ↵Vedant Kumar2017-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR32679) The coverage implementation marks functions which won't be emitted as 'deferred', so that it can emit empty coverage regions for them later (once their linkages are known). Functions in dependent contexts are an exception: if there isn't a full instantiation of a function, it shouldn't be marked 'deferred'. We've been breaking that rule without much consequence because we just ended up with useless, extra, empty coverage mappings. With PR32679, this behavior finally caused a crash, because clang marked a partial template specialization as 'deferred', causing the MS mangler to choke in its delayed-template-parsing mode: error: cannot mangle this template type parameter type yet (http://bugs.llvm.org/show_bug.cgi?id=32679) Fix this by checking if a decl's context is a dependent context before marking it 'deferred'. Based on a patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32144 llvm-svn: 300723
* [DebugInfo] Added support to Clang FE for generating debug info for ↵Amjad Aboud2017-02-091-0/+8
| | | | | | | | | | | preprocessor macros. Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info. Added CC1 "-debug-info-macro" flag that enables emitting macro debug info. Differential Revision: https://reviews.llvm.org/D16135 llvm-svn: 294637
* Introduce a type-safe enum for ForDefinition.John McCall2016-11-301-1/+1
| | | | llvm-svn: 288289
* Various improvements to the public IRGen interface.John McCall2016-05-181-5/+39
| | | | llvm-svn: 269880
* Fix a bug involving deferred decl emission and PCHReid Kleckner2016-04-221-2/+18
| | | | | | | | | | | | | | | | For various reasons, involving dllexport and class linkage compuations, we have to wait until after the semicolon after a class declaration to emit inline methods. These are "deferred" decls. Before this change, finishing the tag decl would trigger us to deserialize some PCH so that we could make a "pretty" IR-level type. Deserializing the PCH triggered calls to HandleTopLevelDecl, which, when done, checked the deferred decl list, and emitted some dllexported decls that weren't ready. Avoid this re-entrancy. Deferred decls should not get emitted when a tag is finished, they should only be emitted after a real top level decl in the main file. llvm-svn: 267186
* revert SVN r265702, r265640Saleem Abdulrasool2016-04-081-3/+1
| | | | | | | | | | | Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
* Basic: move CodeGenOptions from FrontendSaleem Abdulrasool2016-04-071-1/+3
| | | | | | | | This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
* For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann2016-03-301-4/+15
| | | | | | | | | | | | | | ...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-14/+4
| | | | | | | | | 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-4/+14
| | | | | | | | | | | | Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
* Remove compile time PreserveName in favor of a runtime cc1 ↵Mehdi Amini2016-03-131-2/+3
| | | | | | | | | | | | | | | | | | | | -discard-value-names option Summary: This flag is enabled by default in the driver when NDEBUG is set. It is forwarded on the LLVMContext to discard all value names (but GlobalValue) for performance purpose. This an improved version of D18024 Reviewers: echristo, chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18127 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263394
* Make TargetInfo store an actual DataLayout instead of a string.James Y Knight2016-03-041-1/+1
| | | | | | | | | | | | | | 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
* [OPENMP 4.0] Codegen for 'declare reduction' construct.Alexey Bataev2016-03-041-0/+9
| | | | | | | Emit function for 'combiner' part of 'declare reduction' construct and 'initialilzer' part, if any. llvm-svn: 262699
* 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-10/+2
| | | | | | | | | | | | | | `#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
* Check for frontend errors after releasing the Builder.Manman Ren2016-01-281-3/+6
| | | | | | | | | | | | | Frontend can emit errors when releaseing the Builder. If there are errors before or when releasing the Builder, we reset the module to stop here before invoking the backend. Before this commit, clang will continue to invoke the backend and backend can crash. Differential Revision: http://reviews.llvm.org/D16564 llvm-svn: 259116
* [MS ABI] Allow a member pointers' converted type to changeDavid Majnemer2016-01-261-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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-3/+5
| | | | | | | | | 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
* [MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer2015-10-081-1/+1
| | | | | | | | | | -fms-compatibility No ABI for C++ currently makes it possible to implement the standard 100% perfectly. We wrongly hid some of our compatible behavior behind -fms-compatibility instead of tying it to the compiler ABI. llvm-svn: 249656
* Rename DescriptionString -> DataLayoutString as it matches the actualEric Christopher2015-08-051-1/+1
| | | | | | use of the string. llvm-svn: 244178
* LLVM API Change: the Module always owns the DataLayoutMehdi Amini2015-07-241-8/+3
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 243115
* Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.Adrian Prantl2015-06-301-12/+21
| | | | | | | In order to produce debug info for clang modules CGDebugInfo it needs access to macros passed on the command line and the isysroot. llvm-svn: 241035
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* Wrap to 80 columns. No behavior change.Nico Weber2015-01-171-1/+2
| | | | llvm-svn: 226364
* Remove unused parameter, followup to r179639. No behavior change.Nico Weber2015-01-151-1/+0
| | | | llvm-svn: 226128
* Remove ASTConsumer::HandleVTable()'s bool parameter.Nico Weber2015-01-151-2/+2
| | | | | | | | | | | Sema calls HandleVTable() with a bool parameter which is then threaded through three layers. The only effect of this bool is an early return at the last layer. Instead, remove this parameter and call HandleVTable() only if the bool is true. No intended behavior change. llvm-svn: 226096
* Initialize CodeGeneratorImpl::Ctx in constructor.Yaron Keren2014-12-251-1/+1
| | | | llvm-svn: 224835
* Tweak the assert in ModuleBuilder from r224533 (PR21989)Hans Wennborg2014-12-191-2/+3
| | | | | | | Turns out there will be left-over deferred inline methods if there have been errors, because in that case HandleTopLevelDecl bails out early. llvm-svn: 224649
* ModuleBuilder: assert that all deferred inline method defs get handledHans Wennborg2014-12-181-4/+7
| | | | | | | While we're here, also move the declaration of DeferredInlineMethodDefinitions closer to the other member vars and make it a SmallVector. NFC. llvm-svn: 224533
* InstrProf: Don't emit coverage for uninstantiated templatesJustin Bogner2014-11-181-3/+5
| | | | | | | | | | | | | We include unused functions and methods in -fcoverage-mapping so that we can differentiate between uninstrumented and unused. This can cause problems for uninstantiated templates though, since they may involve an incomplete type that can't be mangled. This shows up in things like libc++'s <unordered_map> and makes coverage unusable. Avoid the issue by skipping uninstantiated methods of a templated class. llvm-svn: 222204
* [modules] Fix a rejects-valid resulting from emitting an inline functionRichard Smith2014-08-131-1/+5
| | | | | | | | recursively within the emission of another inline function. This ultimately led to us emitting the same inline function definition twice, which we then rejected because we believed we had a mangled name conflict. llvm-svn: 215579
* Add coverage mapping generation.Alex Lorenz2014-08-041-4/+13
| | | | | | | | | | This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
* Notional simplification: defer emitting deferred inline methods until we finishRichard Smith2014-08-011-4/+21
| | | | | | emitting everything, rather than potentially doing this reentrantly. llvm-svn: 214582
* Re-commit r214547 with tests fixed. Hopefully all the bots will be happy now.Richard Smith2014-08-011-3/+5
| | | | | | | | | Original message: Fix iterator invalidation issues that are breaking my modules buildbot's bootstrap. llvm-svn: 214555
* Revert r214547 due to test breakage.Richard Smith2014-08-011-6/+3
| | | | llvm-svn: 214549
* Fix iterator invalidation issues that are breaking my modules buildbot's ↵Richard Smith2014-08-011-3/+6
| | | | | | bootstrap. llvm-svn: 214547
* MS compatibility: always emit dllexported in-class initialized static data ↵Hans Wennborg2014-07-171-0/+13
| | | | | | | | | | | | | | members (PR20140) This makes us emit dllexported in-class initialized static data members (which are treated as definitions in MSVC), even when they're not referenced. It also makes their special linkage reflected in the GVA linkage instead of getting massaged in CodeGen. Differential Revision: http://reviews.llvm.org/D4563 llvm-svn: 213304
* Defer codegen of inline method definitions to the end of current top level ↵Hans Wennborg2014-06-061-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | declaration We would previously fail to emit a definition of bar() for the following code: struct __declspec(dllexport) S { void foo() { t->bar(); } struct T { void bar() {} }; T *t; }; Note that foo() is an exported method, but bar() is not. However, foo() refers to bar() so we need to emit its definition. We would previously fail to realise that bar() is used. By deferring the method definitions until the end of the top level declaration, we can simply call EmitTopLevelDecl on them and rely on the usual mechanisms to decide whether the method should be emitted or not. Differential Revision: http://reviews.llvm.org/D4038 llvm-svn: 210356
* Implement -Wframe-larger-than backend diagnosticAlp Toker2014-06-051-0/+15
| | | | | | | | | | | | | | | | | | Add driver and frontend support for the GCC -Wframe-larger-than=bytes warning. This is the first GCC-compatible backend diagnostic built around LLVM's reporting feature. This commit adds infrastructure to perform reverse lookup from mangled names emitted after LLVM IR generation. We use that to resolve precise locations and originating AST functions, lambdas or block declarations to produce seamless codegen-guided diagnostics. An associated change, StringMap now maintains unique mangled name strings instead of allocating copies. This is a net memory saving in C++ and a small hit for C where we no longer reuse IdentifierInfo storage, pending further optimisation. llvm-svn: 210293
* Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg2014-05-231-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR11170) The previous code that was supposed to handle this didn't work since parsing of inline method definitions is delayed to the end of the outer class definition. Thus, when HandleTagDeclDefinition() got called for the inner class, the inline functions in that class had not been parsed yet. Richard suggested that the way to do this is by handling inline method definitions through a new ASTConsumer callback. I really wanted to call ASTContext::DeclMustBeEmitted() instead of checking for attributes, but doing that causes us to compute linkage, and then we fail with "error: unsupported: typedef changes linkage of anonymous type, but linkage was already computed" on tests like this: (from SemaCXX/undefined-internal.cpp) :-/ namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } Differential Revision: http://reviews.llvm.org/D3809 llvm-svn: 209549
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-14/+14
| | | | | | class. llvm-svn: 203643
* [C++11] Replace OwningPtr include with <memory>.Ahmed Charles2014-03-091-1/+1
| | | | llvm-svn: 203389
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-3/+4
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [C++11] Replacing DeclBase iterators decls_begin() and decls_end() with ↵Aaron Ballman2014-03-071-4/+2
| | | | | | iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203278
* Change OwningPtr::take() to OwningPtr::release().Ahmed Charles2014-03-071-3/+1
| | | | | | This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202625
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
OpenPOWER on IntegriCloud