summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* reland "[DebugInfo] Support to emit debugInfo for extern variables"Yonghong Song2019-12-221-0/+4
| | | | | | | | | | | | | Commit d77ae1552fc21a9f3877f3ed7e13d631f517c825 ("[DebugInfo] Support to emit debugInfo for extern variables") added deebugInfo for extern variables for BPF target. The commit is reverted by 891e25b02d760d0de18c7d46947913b3166047e7 as the committed tests using %clang instead of %clang_cc1 causing test failed in certain scenarios as reported by Reid Kleckner. This patch fixed the tests by using %clang_cc1. Differential Revision: https://reviews.llvm.org/D71818
* Revert "[DebugInfo] Support to emit debugInfo for extern variables"Reid Kleckner2019-12-221-4/+0
| | | | | | | This reverts commit d77ae1552fc21a9f3877f3ed7e13d631f517c825. The tests committed along with this change do not pass, and should be changed to use %clang_cc1.
* [DebugInfo] Support to emit debugInfo for extern variablesYonghong Song2019-12-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extern variable usage in BPF is different from traditional pure user space application. Recent discussion in linux bpf mailing list has two use cases where debug info types are required to use extern variables: - extern types are required to have a suitable interface in libbpf (bpf loader) to provide kernel config parameters to bpf programs. https://lore.kernel.org/bpf/CAEf4BzYCNo5GeVGMhp3fhysQ=_axAf=23PtwaZs-yAyafmXC9g@mail.gmail.com/T/#t - extern types are required so kernel bpf verifier can verify program which uses external functions more precisely. This will make later link with actual external function no need to reverify. https://lore.kernel.org/bpf/87eez4odqp.fsf@toke.dk/T/#m8d5c3e87ffe7f2764e02d722cb0d8cbc136880ed This patch added clang support to emit debuginfo for extern variables with a TargetInfo hook to enable it. The debuginfo for the extern variable is emitted only if that extern variable is referenced in the current compilation unit. Currently, only BPF target enables to generate debug info for extern variables. The emission of such debuginfo is disabled for C++ at this moment since BPF only supports a subset of C language. Emission with C++ can be enabled later if an appropriate use case is identified. -fstandalone-debug permits us to see more debuginfo with the cost of bloated binary size. This patch did not add emission of extern variable debug info with -fstandalone-debug. This can be re-evaluated if there is a real need. Differential Revision: https://reviews.llvm.org/D70696
* [Clang] Use -main-file-name for source filename if not setTeresa Johnson2019-09-301-2/+10
| | | | | | | | | | | | | | | | | | | -main-file-name is currently used to set the source name used in debug information. If the source filename is "-" and -main-file-name is set, then use the filename also for source_filename and ModuleID of the output. The argument is generally used outside the internal clang calls when running clang in a wrapper like icecc which gives the source via stdin but still wants to get a object file with the original source filename both in debug info and IR code. Patch by: the_jk (Joel Klinghed) Differential Revision: https://reviews.llvm.org/D67592 llvm-svn: 373217
* [OpenMP 5.0] Codegen support for user-defined mappers.Michael Kruse2019-08-051-0/+3
| | | | | | | | | | | | | | | | | | | This patch implements the code generation for OpenMP 5.0 declare mapper (user-defined mapper) constructs. For each declare mapper, a mapper function is generated. These mapper functions will be called by the runtime and/or other mapper functions to achieve user defined mapping. The design slides can be found at https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx Re-commit after revert in r367773 because r367755 changed the LLVM-IR output such that a CHECK line failed. Patch by Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D59474 llvm-svn: 367905
* Revert "[OpenMP 5.0] Codegen support for user-defined mappers."Michael Kruse2019-08-041-3/+0
| | | | | | | This reverts commit r367773. The test case OpenMP/declare_mapper_codegen.cpp is failing. llvm-svn: 367774
* [OpenMP 5.0] Codegen support for user-defined mappers.Michael Kruse2019-08-041-0/+3
| | | | | | | | | | | | | | | | This patch implements the code generation for OpenMP 5.0 declare mapper (user-defined mapper) constructs. For each declare mapper, a mapper function is generated. These mapper functions will be called by the runtime and/or other mapper functions to achieve user defined mapping. The design slides can be found at https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx Patch by Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D59474 llvm-svn: 367773
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [darwin] parse the SDK settings from SDKSettings.json if it exists andAlex Lorenz2018-12-171-0/+3
| | | | | | | | | | | | | | | | | | | | pass in the -target-sdk-version to the compiler and backend This commit adds support for reading the SDKSettings.json file in the Darwin driver. This file is used by the driver to determine the SDK's version, and it uses that information to pass it down to the compiler using the new -target-sdk-version= option. This option is then used to set the appropriate SDK Version module metadata introduced in r349119. Note: I had to adjust the two ast tests as the SDKROOT environment variable on macOS caused SDK version to be picked up for the compilation of source file but not the AST. rdar://45774000 Differential Revision: https://reviews.llvm.org/D55673 llvm-svn: 349380
* Move CodeGenOptions from Frontend to BasicRichard Trieu2018-12-111-1/+1
| | | | | | Basic uses CodeGenOptions and should not depend on Frontend. llvm-svn: 348827
* [MS] Defer dllexport inline friend functions like other inline methodsReid Kleckner2018-09-181-20/+9
| | | | | | | | | | | | | | | This special case was added in r264841, but the code breaks our invariants by calling EmitTopLevelDecl without first creating a HandlingTopLevelDeclRAII scope. This fixes the PCH crash in https://crbug.com/884427. I was never able to make a satisfactory reduction, unfortunately. I'm not very worried about this regressing since this change makes the code simpler while passing the existing test that shows we do emit dllexported friend function definitions. Now we just defer their emission until the tag is fully complete, which is generally good. llvm-svn: 342516
* 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
OpenPOWER on IntegriCloud