aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-07-23[clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter ↵Chuanqi Xu1-396/+0
(#99599) Close https://github.com/llvm/llvm-project/issues/99479 See https://github.com/llvm/llvm-project/issues/99479 for details
2023-09-29[clang] set DebugCompilationDir in PCHContainer (#67744)Richard Howell1-0/+2
This change sets the debug compilation directory when generating debug information for PCH object containers. This allows for overriding the compilation directory in debug information in precompiled pcm files.
2023-09-12Propagate the DWARF version from the main compiler invocation to PCHC… ↵Adrian Prantl1-0/+1
(#66032) …ontainerGenerator Currently it remains uninitialized and thus always uses the LLVM default of 4.
2023-05-03[clang][deps] Make clang-scan-deps write modules in raw formatBen Langmuir1-0/+5
We have no use for debug info for the scanner modules, and writing raw ast files speeds up scanning ~15% in some cases. Note that the compile commands produced by the scanner will still build the obj format (if requested), and the scanner can *read* obj format pcms, e.g. from a PCH. rdar://108807592 Differential Revision: https://reviews.llvm.org/D149693
2023-03-29[NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in FlangKiran Chandramohan1-1/+1
This patch moves the Debug Options to llvm/Frontend so that it can be shared by Flang as well. Reviewed By: kiranchandramohan, awarzynski Differential Revision: https://reviews.llvm.org/D142347
2023-02-01[NFC][Profile] Access profile through VirtualFileSystemSteven Wu1-2/+2
Make the access to profile data going through virtual file system so the inputs can be remapped. In the context of the caching, it can make sure we capture the inputs and provided an immutable input as profile data. Reviewed By: akyrtzi, benlangmuir Differential Revision: https://reviews.llvm.org/D139052
2022-09-03[clang] Qualify auto in range-based for loops (NFC)Kazu Hirata1-2/+2
2022-07-26[CGDebugInfo] Access the current working directory from the `VFS`Argyrios Kyrtzidis1-1/+3
...instead of calling `llvm::sys::fs::current_path()` directly. Differential Revision: https://reviews.llvm.org/D130443
2022-06-06[gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls inAkira Hatanaka1-0/+4
DebugTypeVisitor This recommits d1346e2. I've added a line to the test case to enable it only on assert builds. Differential Revision: https://reviews.llvm.org/D125839
2022-06-06Revert "[gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in"Akira Hatanaka1-4/+0
This reverts commit d1346e2ee2741919a8cc1b1ffe400001e76a6d06. The commit broke a few bots.
2022-06-06[gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls inAkira Hatanaka1-0/+4
DebugTypeVisitor Differential Revision: https://reviews.llvm.org/D125839
2022-01-10Emit the C++ dialect in -gmodules .pcm files.Adrian Prantl1-0/+1
Because of commit: https://reviews.llvm.org/D104291 the -gmodules .pcm files do not have the same DW_AT_language dialect as the .o file. This was a simple matter of passing the DebugStrictDwarf flag to the PCHContainerGenerator object's CodeGenOpts from the CompilerInstance passed in to it. Before this change if you ran dwarfdump on the gmodule cache folder you would get DW_AT_language (DW_LANG_C_plus_plus) even when using -std=c++14 with clang Patch by Shubham Rastogi! Differential Revision: https://reviews.llvm.org/D116790
2021-10-19[WebAssembly] Emit clangast in custom section aligned by 4 bytesYuta Saito1-19/+36
Emit __clangast in custom section instead of named data segment to find it while iterating sections. This could be avoided if all data segements (the wasm sense) were represented as their own sections (in the llvm sense). This can be resolved by https://github.com/WebAssembly/tool-conventions/issues/138 And the on-disk hashtable in clangast needs to be aligned by 4 bytes, so add paddings in name length field in custom section header. The length of clangast section name can be represented in 1 byte by leb128, and possible maximum pads are 3 bytes, so the section name length won't be invalid in theory. Fixes https://bugs.llvm.org/show_bug.cgi?id=35928 Differential Revision: https://reviews.llvm.org/D74531
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner1-1/+1
This moves the registry higher in the LLVM library dependency stack. Every client of the target registry needs to link against MC anyway to actually use the target, so we might as well move this out of Support. This allows us to ensure that Support doesn't have includes from MC/*. Differential Revision: https://reviews.llvm.org/D111454
2021-10-06[clang] Replace report_fatal_error(std::string) uses with ↵Simon Pilgrim1-1/+1
report_fatal_error(Twine) As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
2021-04-27[clang/Basic] Make TargetInfo.h not use DataLayout againNico Weber1-6/+6
Reverts parts of https://reviews.llvm.org/D17183, but keeps the resetDataLayout() API and adds an assert that checks that datalayout string and user label prefix are in sync. Approach 1 in https://reviews.llvm.org/D17183#2653279 Reduces number of TUs build for 'clang-format' from 689 to 575. I also implemented approach 2 in D100764. If someone feels motivated to make us use DataLayout more, it's easy to revert this change here and go with D100764 instead. I don't plan on doing more work in this area though, so I prefer going with the smaller, more self-consistent change. Differential Revision: https://reviews.llvm.org/D100776
2020-11-22[Clang] Add __STDCPP_THREADS__ to standard predefine macrosZequan Wu1-2/+2
According to https://eel.is/c++draft/cpp.predefined#2.6, `__STDCPP_THREADS__` is a predefined macro. Differential Revision: https://reviews.llvm.org/D91747
2020-08-24Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"Raphael Isemann1-3/+3
The orignal patch with the missing 'REQUIRES: asserts' as there is a debug-only flag used in the test. Original summary: D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array<uint8_t, 20>` instead of `std::array<uint32_t, 5>`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013
2020-08-24Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring ↵Raphael Isemann1-3/+3
(D81347)"" This reverts commit ada2e8ea67393aa8c44fe8e9d46be62df6d1c702. Still breaking on Fuchsia (and also Fedora) with exit code 1, so back to investigating.
2020-08-24Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"Raphael Isemann1-3/+3
This relands D84013 but with a test that relies on less shell features to hopefully make the test pass on Fuchsia (where the test from the previous patch version strangely failed with a plain "Exit code 1"). Original summary: D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array<uint8_t, 20>` instead of `std::array<uint32_t, 5>`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013
2020-08-21Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"Raphael Isemann1-3/+3
This reverts commit a4c3ed42ba5625af54254584d762ebf96cc06942. The test is curiously failing with a plain exit code 1 on Fuchsia.
2020-08-21Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)Raphael Isemann1-3/+3
D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations that creates the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the array subclass that is now `std::array<uint8_t, 20>` instead of `std::array<uint32_t, 5>`). ``` uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0] ``` This code works with the old ASTFileSignature (where two uint32_t are enough to fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature and only partly filled the Signature uint64_t. This caused that the dwoID in the module ref and the dwoID in the actual module no longer match (which in turns causes that LLDB keeps warning about the dwoID's not matching when debugging -gmodules-compiled binaries). This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which makes the dwoID match again (and should prevent issues like that in the future). Reviewed By: aprantl, dang Differential Revision: https://reviews.llvm.org/D84013
2020-06-11Make ASTFileSignature an array of 20 uint8_t instead of 5 uint32_tDaniel Grumberg1-2/+2
Reviewers: aprantl, dexonsmith, Bigcheese Subscribers: arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81347
2019-10-03[Alignment][Clang][NFC] Add CharUnits::getAsAlignGuillaume Chatelet1-1/+1
Summary: This is a prerequisite to removing `llvm::GlobalObject::setAlignment(unsigned)`. This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: jholewinski, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68274 llvm-svn: 373592
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-2/+2
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
2019-08-14[clang] - An update after LLVM change.George Rimar1-1/+5
SectionRef::getName() was changed to return Expected<> (D66089) llvm-svn: 368825
2019-07-03[Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih1-1/+1
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
2019-05-16Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song1-2/+8
Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2018-12-11Move CodeGenOptions from Frontend to BasicRichard Trieu1-1/+1
Basic uses CodeGenOptions and should not depend on Frontend. llvm-svn: 348827
2018-12-06Remove unnecessary include.Richard Trieu1-1/+0
llvm-svn: 348459
2018-11-29[-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs.Adrian Prantl1-0/+2
This patch passes -fdebug-prefix-map (a feature for renaming source paths in the debug info) through to the per-module codegen options and adds the debug prefix map to the module hash. <rdar://problem/46045865> Differential Revision: https://reviews.llvm.org/D55037 llvm-svn: 347926
2018-05-15[clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen1-1/+1
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 llvm-svn: 332350
2018-01-03-gmodules: Emit debug info for implicit module imports via #include.Adrian Prantl1-0/+5
When a type is only used as a template parameter and that type is the only type imported from another #include'd module, no skeleton CU for that module is generated, so a consumer doesn't know where to find the type definition. By emitting an import declaration, we can force a skeleton CU to be generated for each imported module. rdar://problem/36266156 llvm-svn: 321754
2018-01-03Simplify code (NFC)Adrian Prantl1-3/+2
llvm-svn: 321750
2017-07-18Debug Info: Set the MainFileName when generating -gmodules debug info for PCM.Adrian Prantl1-0/+3
Previously it was uninitialized and thus always defaulted to "<stdin>". This is mostly a cosmetic change that helps making the debug info more readable. llvm-svn: 308397
2017-03-13Modules: Use hash of PCM content for SIGNATUREDuncan P. N. Exon Smith1-2/+7
Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
2017-01-05CodeGen: plumb header search down to the IASSaleem Abdulrasool1-4/+5
inline assembly may use the `.include` directive to include other content into the file. Without the integrated assembler, the `-I` group gets passed to the assembler. Emulate this by collecting the header search paths and passing them to the IAS. Resolves PR24811! llvm-svn: 291123
2016-11-08Bitcode: Decouple block info block state from reader.Peter Collingbourne1-7/+7
As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106630.html Move block info block state to a new class, BitstreamBlockInfo. Clients may set the block info for a particular cursor with the BitstreamCursor::setBlockInfo() method. At this point BitstreamReader is not much more than a container for an ArrayRef<uint8_t>, so remove it and replace all uses with direct uses of memory buffers. Differential Revision: https://reviews.llvm.org/D26259 llvm-svn: 286207
2016-11-02Bitcode: Change reader interface to take memory buffers.Peter Collingbourne1-4/+3
As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106595.html This change also fixes an API oddity where BitstreamCursor::Read() would return zero for the first read past the end of the bitstream, but would report_fatal_error for subsequent reads. Now we always report_fatal_error for all reads past the end. Updated clients to check for the end of the bitstream before reading from it. I also needed to add padding to the invalid bitcode tests in test/Bitcode/. This is because the streaming interface was not checking that the file size is a multiple of 4. Differential Revision: https://reviews.llvm.org/D26219 llvm-svn: 285773
2016-08-17Support object-file-wrapped modules in clang -module-file-info.Adrian Prantl1-13/+17
rdar://problem/24504815 llvm-svn: 279004
2016-07-15Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne1-15/+14
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
2016-06-24Use more ArrayRefsDavid Majnemer1-2/+2
No functional change is intended, just a small refactoring. llvm-svn: 273647
2016-05-27Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer1-1/+2
No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
2016-05-03[modules][debuginfo] Only include imported modules when targeting LLDBDavid Blaikie1-0/+1
These constructs are only applicable to a debugger capable of loading a Clang AST, so omit them for brevity when not doing so. We could potentially propagate more of CodeGenOptions through the ObjectFilePCGContainerOperations for consistency (so the next person who adds some CodeGenOpts feature that tweaks debug info output doesn't get caught by this), so I'm open to objections/alternatives there, but went with this for now. Tested just a couple of basic cases (one direct, one indirect (through the ObjectFilePCHContainerOperations) & fixed up other cases to pass the -debugger-tuning flag as appropriate. llvm-svn: 268460
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-2/+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
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-1/+2
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
2016-03-07Module Debugging: Fix a crash when emitting debug info for nested tag typesAdrian Prantl1-0/+9
whose DeclContext is not yet complete by deferring their emission. rdar://problem/24918680 llvm-svn: 262851
2016-03-04Make TargetInfo store an actual DataLayout instead of a string.James Y Knight1-6/+6
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
2016-02-02Move DebugInfoKind into its own header to cut the cyclic dependency edge ↵Benjamin Kramer1-1/+1
from Driver to Frontend. llvm-svn: 259489