aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Remarks
AgeCommit message (Collapse)AuthorFilesLines
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling2-10/+10
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling2-10/+10
2020-02-04[Remarks] Extend the RemarkStreamer to support other emittersFrancis Visoiu Mistrih2-0/+73
This extends the RemarkStreamer to allow for other emitters (e.g. frontends, SIL, etc.) to emit remarks through a common interface. See changes in llvm/docs/Remarks.rst for motivation and design choices. Differential Revision: https://reviews.llvm.org/D73676
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer3-3/+3
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-22[Remarks] Allow empty temporary remark filesFrancis Visoiu Mistrih1-0/+5
When parsing bitstream remarks, allow external remark files to be empty, which means there are no remarks to be parsed. In the same way, dsymutil should not produce a remark file.
2019-11-21[cmake] Explicitly mark libraries defined in lib/ as "Component Libraries"Tom Stellard1-1/+1
Summary: Most libraries are defined in the lib/ directory but there are also a few libraries defined in tools/ e.g. libLLVM, libLTO. I'm defining "Component Libraries" as libraries defined in lib/ that may be included in libLLVM.so. Explicitly marking the libraries in lib/ as component libraries allows us to remove some fragile checks that attempt to differentiate between lib/ libraries and tools/ libraires: 1. In tools/llvm-shlib, because llvm_map_components_to_libnames(LIB_NAMES "all") returned a list of all libraries defined in the whole project, there was custom code needed to filter out libraries defined in tools/, none of which should be included in libLLVM.so. This code assumed that any library defined as static was from lib/ and everything else should be excluded. With this change, llvm_map_components_to_libnames(LIB_NAMES, "all") only returns libraries that have been added to the LLVM_COMPONENT_LIBS global cmake property, so this custom filtering logic can be removed. Doing this also fixes the build with BUILD_SHARED_LIBS=ON and LLVM_BUILD_LLVM_DYLIB=ON. 2. There was some code in llvm_add_library that assumed that libraries defined in lib/ would not have LLVM_LINK_COMPONENTS or ARG_LINK_COMPONENTS set. This is only true because libraries defined lib lib/ use LLVMBuild.txt and don't set these values. This code has been fixed now to check if the library has been explicitly marked as a component library, which should now make it easier to remove LLVMBuild at some point in the future. I have tested this patch on Windows, MacOS and Linux with release builds and the following combinations of CMake options: - "" (No options) - -DLLVM_BUILD_LLVM_DYLIB=ON - -DLLVM_LINK_LLVM_DYLIB=ON - -DBUILD_SHARED_LIBS=ON - -DBUILD_SHARED_LIBS=ON -DLLVM_BUILD_LLVM_DYLIB=ON - -DBUILD_SHARED_LIBS=ON -DLLVM_LINK_LLVM_DYLIB=ON Reviewers: beanz, smeenai, compnerd, phosek Reviewed By: beanz Subscribers: wuzish, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, mgorny, mehdi_amini, sbc100, jgravelle-google, hiraditya, aheejin, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, jocewei, jsji, dang, Jim, lenary, s.egerton, pzheng, sameer.abuasal, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70179
2019-11-09Remarks - fix static analyzer warnings. NFCI.Simon Pilgrim2-8/+9
- Fix uninitialized variable warnings. - Reuse BitstreamEntry iterator to avoid Wshadow warning. - Match declaration + definition arg names in BitstreamRemarkParser::processCommonMeta - Make BitstreamRemarkParser(StringRef) constructor explicit
2019-11-09Remarks - fix shadow variable warnings. NFCI.Simon Pilgrim2-14/+16
Avoid conflict with llvm::remarks::Magic global variable.
2019-10-31[Remarks] Add support for linking remarksFrancis Visoiu Mistrih3-0/+142
Remarks are usually emitted per-TU, and for generating a standalone remark file that can be shipped with the linked binary we need some kind of tool to merge everything together. The remarks::RemarkLinker class takes care of this and: * Deduplicates remarks * Filters remarks with no debug location * Merges string tables from all the entries As an output, it provides an iterator range that can be used to serialize the remarks to a file. Differential Revision: https://reviews.llvm.org/D69141
2019-10-16[Remarks] Add support for prepending a path to external filesFrancis Visoiu Mistrih5-17/+39
This helps with testing and debugging for paths that are assumed absolute. It also uses a FileError to provide the file path it's trying to open. llvm-svn: 375008
2019-10-07[Remarks] Pass StringBlockValue as StringRef.Florian Hahn1-1/+1
After changing the remark serialization, we now pass StringRefs to the serializer. We should use StringRef for StringBlockVal, to avoid creating temporary objects, which then cause StringBlockVal.Value to point to invalid memory. Reviewers: thegameg, anemet Reviewed By: thegameg Differential Revision: https://reviews.llvm.org/D68571 llvm-svn: 373923
2019-09-16[Remarks] Allow remarks::Format::YAML to take a string tableFrancis Visoiu Mistrih4-26/+41
It should be allowed to take a string table in case all the strings in the remarks point there, but it shouldn't use it during serialization. llvm-svn: 372042
2019-09-09Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim1-0/+1
llvm-svn: 371454
2019-09-09[Remarks] Fix warning for uint8_t < 0 comparisonFrancis Visoiu Mistrih1-4/+4
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/19109/steps/build-stage1-compiler/logs/stdio llvm-svn: 371443
2019-09-09[Remarks] Add parser for bitstream remarksFrancis Visoiu Mistrih5-7/+681
The bitstream remark serializer landed in r367372. This adds a bitstream remark parser that parser bitstream remark files to llvm::remarks::Remark objects through the RemarkParser interface. A few interesting things to point out: * There are parsing helpers to parse the different types of blocks * The main parsing helper allows us to parse remark metadata and open an external file containing the encoded remarks * This adds a dependency from the Remarks library to the BitstreamReader library * The testing strategy is to create a remark entry through YAML, parse it, serialize it to bitstream, parse that back and compare the objects. * There are close to no tests for malformed bitstream remarks, due to the lack of textual format for the bitstream format. * This adds a new C API for parsing bitstream remarks: LLVMRemarkParserCreateBitstream. * This bumps the REMARKS_API_VERSION to 1. Differential Revision: https://reviews.llvm.org/D67134 llvm-svn: 371429
2019-09-06[Remarks] Add support for internalizing a remark in a string tableFrancis Visoiu Mistrih1-0/+17
In order to keep remarks around, we need to make them tied to a string table. Users then can delete the parser and rely on the string table to keep the memory of the strings alive and deduplicated. llvm-svn: 371233
2019-09-05[Remarks] Don't serialize metadata if a string table is not usedFrancis Visoiu Mistrih1-9/+14
For YAML remarks with no string table, the mode should not affect the output. llvm-svn: 371106
2019-08-23Do a sweep of symbol internalization. NFC.Benjamin Kramer1-0/+2
llvm-svn: 369803
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere5-13/+13
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. llvm-svn: 369013
2019-07-31Reland: [Remarks] Add an LLVM-bitstream-based remark serializerFrancis Visoiu Mistrih7-4/+407
Add a new serializer, using a binary format based on the LLVM bitstream format. This format provides a way to serialize the remarks in two modes: 1) Separate mode: the metadata is separate from the remark entries. 2) Standalone mode: the metadata and the remark entries are in the same file. The format contains: * a meta block: container version, container type, string table, external file path, remark version * a remark block: type, remark name, pass name, function name, debug file, debug line, debug column, hotness, arguments (key, value, debug file, debug line, debug column) A string table is required for this format, which will be dumped in the meta block to be consumed before parsing the remark blocks. On clang itself, we noticed a size reduction of 13.4x compared to YAML, and a compile-time reduction of between 1.7% and 3.5% on CTMark. Differential Revision: https://reviews.llvm.org/D63466 Original llvm-svn: 367364 Revert llvm-svn: 367370 llvm-svn: 367372
2019-07-31Revert "[Remarks] Add an LLVM-bitstream-based remark serializer"Francis Visoiu Mistrih7-403/+4
This reverts commit r367364. Breaks some bots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-gn/builds/3161/steps/annotate/logs/stdio llvm-svn: 367370
2019-07-30[Remarks] Add an LLVM-bitstream-based remark serializerFrancis Visoiu Mistrih7-4/+403
Add a new serializer, using a binary format based on the LLVM bitstream format. This format provides a way to serialize the remarks in two modes: 1) Separate mode: the metadata is separate from the remark entries. 2) Standalone mode: the metadata and the remark entries are in the same file. The format contains: * a meta block: container version, container type, string table, external file path, remark version * a remark block: type, remark name, pass name, function name, debug file, debug line, debug column, hotness, arguments (key, value, debug file, debug line, debug column) A string table is required for this format, which will be dumped in the meta block to be consumed before parsing the remark blocks. On clang itself, we noticed a size reduction of 13.4x compared to YAML, and a compile-time reduction of between 1.7% and 3.5% on CTMark. Differential Revision: https://reviews.llvm.org/D63466 llvm-svn: 367364
2019-07-30[Remarks] Add two serialization modes for remarks: separate and standaloneFrancis Visoiu Mistrih2-8/+19
The default mode is separate, where the metadata is serialized separately from the remarks. Another mode is the standalone mode, where the metadata is serialized before the remarks, on the same stream. llvm-svn: 367328
2019-07-29[Remarks] Update error message format stringFrancis Visoiu Mistrih1-4/+4
All the clang-cmake-armv{7,8} bots are failing this test. This is an attempt to fix this. llvm-svn: 367243
2019-07-26[Remarks] Silence Wreturn-type warningFrancis Visoiu Mistrih1-0/+1
Shows up here: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fuzzer/builds/27771/steps/annotate/logs/stdio. llvm-svn: 367162
2019-07-26Reland: [Remarks] Support parsing remark metadata in the YAML remark parserFrancis Visoiu Mistrih3-0/+129
This adds support to the yaml remark parser to be able to parse remarks directly from the metadata. This supports parsing separate metadata and following the external file with the associated metadata, and also a standalone file containing metadata + remarks all together. Original llvm-svn: 367148 Revert llvm-svn: 367151 This has a fix for gcc builds. llvm-svn: 367155
2019-07-26Revert "[Remarks] Support parsing remark metadata in the YAML remark parser"Francis Visoiu Mistrih3-129/+0
This reverts r367148. Seems to fail on http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fuzzer/builds/27768. llvm-svn: 367151
2019-07-26[Remarks] Support parsing remark metadata in the YAML remark parserFrancis Visoiu Mistrih3-0/+129
This adds support to the yaml remark parser to be able to parse remarks directly from the metadata. This supports parsing separate metadata and following the external file with the associated metadata, and also a standalone file containing metadata + remarks all together. llvm-svn: 367148
2019-07-26Reland: [Remarks] Add support for serializing metadata for every remark streamerFrancis Visoiu Mistrih1-0/+65
This allows every serializer format to implement metaSerializer() and return the corresponding meta serializer. Original llvm-svn: 366946 Reverted llvm-svn: 367004 This fixes the unit tests on Windows bots. llvm-svn: 367078
2019-07-25Revert rL366946 : [Remarks] Add support for serializing metadata for every ↵Simon Pilgrim1-65/+0
remark streamer This allows every serializer format to implement metaSerializer() and return the corresponding meta serializer. ........ Fix windows build bots http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win llvm-svn: 367004
2019-07-25[Remarks][NFC] Rename remarks::Parser to remarks::RemarkParserFrancis Visoiu Mistrih3-8/+8
llvm-svn: 366965
2019-07-24[Remarks] Add support for serializing metadata for every remark streamerFrancis Visoiu Mistrih1-0/+65
This allows every serializer format to implement metaSerializer() and return the corresponding meta serializer. llvm-svn: 366946
2019-07-24[Remarks][NFC] Rename remarks::Serializer to remarks::RemarkSerializerFrancis Visoiu Mistrih2-11/+11
llvm-svn: 366939
2019-07-24[Remarks] Simplify the creation of remark serializersFrancis Visoiu Mistrih3-1/+50
Introduce two new functions to create a serializer, and add support for more combinations to the YAMLStrTabSerializer. llvm-svn: 366919
2019-07-24[Remark] Suppress the "-Wreturn-type" compiler warning, NFCHaojian Wu1-0/+2
llvm-svn: 366874
2019-07-23[Remarks] String tables should be move-onlyFrancis Visoiu Mistrih4-13/+22
Copying them is expensive. This allows the tables to be moved around at lower cost, and allows a remarks::StringTable to be constructed from a remarks::ParsedStringTable. llvm-svn: 366864
2019-07-23[Remarks] Introduce a new format: yaml-strtabFrancis Visoiu Mistrih5-33/+75
This exposes better support to use a string table with a format through an actual new remark::Format, called yaml-strtab. This can now be used with -fsave-optimization-record=yaml-strtab. llvm-svn: 366849
2019-07-23[Remarks][NFC] Move the YAML serializer to its own headerFrancis Visoiu Mistrih1-1/+1
llvm-svn: 366842
2019-07-23[Remarks] Add unit tests for YAML serializationFrancis Visoiu Mistrih1-3/+0
Add tests for both the string table and non string table case. llvm-svn: 366832
2019-07-16Fix -Wreturn-type warning. NFC.Michael Liao1-0/+1
llvm-svn: 366251
2019-07-16[Remarks] Simplify and refactor the RemarkParser interfaceFrancis Visoiu Mistrih5-405/+334
Before, everything was based on some kind of type erased parser implementation which container a lot of boilerplate code when multiple formats were to be supported. This simplifies it by: * the remark now owns its arguments * *always* returning an error from the implementation side * working around the way the YAML parser reports errors: catch them through callbacks and re-insert them in a proper llvm::Error * add a CParser wrapper that is used when implementing the C API to avoid cluttering the C++ API with useless state * LLVMRemarkParserGetNext now returns an object that needs to be released to avoid leaking resources * add a new API to dispose of a remark entry: LLVMRemarkEntryDispose llvm-svn: 366217
2019-07-16[Remarks][NFC] Combine ParserFormat and SerializerFormatFrancis Visoiu Mistrih5-19/+53
It's useless to have both. llvm-svn: 366216
2019-07-10[Remarks] Add cl::Hidden to -remarks-yaml-string-tableFrancis Visoiu Mistrih1-2/+3
It was showing up in a lot of unrelated tools. llvm-svn: 365647
2019-07-04Fix MSVC "not all control paths return a value" warnings. NFCI.Simon Pilgrim1-4/+2
llvm-svn: 365119
2019-07-04[Remarks] Silence gcc warning by catching unhandled values in switchesMikael Holmen1-0/+4
Without this fix gcc (7.4) complains with ../lib/Remarks/RemarkParser.cpp: In function 'std::unique_ptr<llvm::remarks::ParserImpl> formatToParserImpl(llvm::remarks::ParserFormat, llvm::StringRef)': ../lib/Remarks/RemarkParser.cpp:29:1: error: control reaches end of non-void function [-Werror=return-type] } ^ ../lib/Remarks/RemarkParser.cpp: In function 'std::unique_ptr<llvm::remarks::ParserImpl> formatToParserImpl(llvm::remarks::ParserFormat, llvm::StringRef, const llvm::remarks::ParsedStringTable&)': ../lib/Remarks/RemarkParser.cpp:38:1: error: control reaches end of non-void function [-Werror=return-type] } ^ The Format enum currently only contains the value YAML which is indeed already handled in the switches, but gcc complains anyway. Adding a default case with an llvm_unreachable silences gcc. llvm-svn: 365118
2019-07-04[Remarks] Require an explicit format to the parserFrancis Visoiu Mistrih3-11/+31
Make the parser require an explicit format. This allows new formats to be easily added by following YAML as an example. llvm-svn: 365102
2019-07-04[Remarks][NFC] Move the string table parsing out of the parser constructorFrancis Visoiu Mistrih3-12/+11
Make the parser take an already-parsed string table. llvm-svn: 365101
2019-05-30[Remarks] Fix usage of enum classFrancis Visoiu Mistrih1-1/+1
Breaks the build on some compilers: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/9720/steps/build%20stage%201/logs/stdio llvm-svn: 362165
2019-05-30[Remarks][NFC] Move the serialization to lib/RemarksFrancis Visoiu Mistrih2-0/+167
Separate the remark serialization to YAML from the LLVM Diagnostics. This adds a new serialization abstraction: remarks::Serializer. It's completely independent from lib/IR and it provides an easy way to replace YAML by providing a new remarks::Serializer. Differential Revision: https://reviews.llvm.org/D62632 llvm-svn: 362160
2019-04-24[Remarks] Add string deduplication using a string tableFrancis Visoiu Mistrih5-6/+100
* Add support for uniquing strings in the remark streamer and emitting the string table in the remarks section. * Add parsing support for the string table in the RemarkParser. From this remark: ``` --- !Missed Pass: inline Name: NoDefinition DebugLoc: { File: 'test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c', Line: 7, Column: 3 } Function: printArgsNoRet Args: - Callee: printf - String: ' will not be inlined into ' - Caller: printArgsNoRet DebugLoc: { File: 'test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c', Line: 6, Column: 0 } - String: ' because its definition is unavailable' ... ``` to: ``` --- !Missed Pass: 0 Name: 1 DebugLoc: { File: 3, Line: 7, Column: 3 } Function: 2 Args: - Callee: 4 - String: 5 - Caller: 2 DebugLoc: { File: 3, Line: 6, Column: 0 } - String: 6 ... ``` And the string table in the .remarks/__remarks section containing: ``` inline\0NoDefinition\0printArgsNoRet\0 test-suite/SingleSource/UnitTests/2002-04-17-PrintfChar.c\0printf\0 will not be inlined into \0 because its definition is unavailable\0 ``` This is mostly supposed to be used for testing purposes, but it gives us a 2x reduction in the remark size, and is an incremental change for the updates to the remarks file format. Differential Revision: https://reviews.llvm.org/D60227 llvm-svn: 359050