aboutsummaryrefslogtreecommitdiff
path: root/clang/utils
AgeCommit message (Collapse)AuthorFilesLines
2022-08-17[clang][SVE] Undefine preprocessor macro defined inMaciej Gabka1-0/+2
arm_sve.h defines and uses __ai macro which needs to be undefined (as it is already in arm_neon.h). Reviewed By: paulwalker-arm Differential Revision: https://reviews.llvm.org/D131580 (cherry picked from commit 48e1250a91d244741c8677fed248ace1fcd7c41c)
2022-07-26[RISCV][Clang] Refactor RISCVVEmitter. (NFC)Zakk Chen1-14/+11
Remove MaskedPrototype and add several fields in RVVIntrinsicRecord, compute Prototype in runtime. Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D126741
2022-07-26[RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)Zakk Chen1-46/+15
This changed is based on https://reviews.llvm.org/D111617 Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D126740
2022-07-26[RISCV] Lazily add RVV C intrinsics.Kito Cheng3-110/+256
Leverage the method OpenCL uses that adds C intrinsics when the lookup failed. There is no need to define C intrinsics in the header file any more. It could help to avoid the large header file to speed up the compilation of RVV source code. Besides that, only the C intrinsics used by the users will be added into the declaration table. This patch is based on https://reviews.llvm.org/D103228 and inspired by OpenCL implementation. ### Experimental Results #### TL;DR: - Binary size of clang increase ~200k, which is +0.07% for debug build and +0.13% for release build. - Single file compilation speed up ~33x for debug build and ~8.5x for release build - Regression time reduce ~10% (`ninja check-all`, enable all targets) #### Header size change ``` | size | LoC | ------------------------------ Before | 4,434,725 | 69,749 | After | 6,140 | 162 | ``` #### Single File Compilation Time Testcase: ``` #include <riscv_vector.h> vint32m1_t test_vadd_vv_vfloat32m1_t(vint32m1_t op1, vint32m1_t op2, size_t vl) { return vadd(op1, op2, vl); } ``` ##### Debug build: Before: ``` real 0m19.352s user 0m19.252s sys 0m0.092s ``` After: ``` real 0m0.576s user 0m0.552s sys 0m0.024s ``` ~33x speed up for debug build ##### Release build: Before: ``` real 0m0.773s user 0m0.741s sys 0m0.032s ``` After: ``` real 0m0.092s user 0m0.080s sys 0m0.012s ``` ~8.5x speed up for release build #### Regression time Note: the failed case is `tools/llvm-debuginfod-find/debuginfod.test` which is unrelated to this patch. ##### Debug build Before: ``` Testing Time: 1358.38s Skipped : 11 Unsupported : 446 Passed : 75767 Expectedly Failed: 190 Failed : 1 ``` After ``` Testing Time: 1220.29s Skipped : 11 Unsupported : 446 Passed : 75767 Expectedly Failed: 190 Failed : 1 ``` ##### Release build Before: ``` Testing Time: 381.98s Skipped : 12 Unsupported : 1407 Passed : 74765 Expectedly Failed: 176 Failed : 1 ``` After: ``` Testing Time: 346.25s Skipped : 12 Unsupported : 1407 Passed : 74765 Expectedly Failed: 176 Failed : 1 ``` #### Binary size of clang ##### Debug build Before ``` text data bss dec hex filename 335261851 12726004 552812 348540667 14c64efb bin/clang ``` After ``` text data bss dec hex filename 335442803 12798708 552940 348794451 14ca2e53 bin/clang ``` +253K, +0.07% code size ##### Release build Before ``` text data bss dec hex filename 144123975 8374648 483140 152981763 91e5103 bin/clang ``` After ``` text data bss dec hex filename 144255762 8447296 483268 153186326 9217016 bin/clang ``` +204K, +0.13% Authored-by: Kito Cheng <kito.cheng@sifive.com> Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com> Reviewed By: khchen, aaron.ballman Differential Revision: https://reviews.llvm.org/D111617
2022-07-23Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`John Ericson1-1/+1
Follow up to D117977, where I missed this new usage after one rebase. Thanks @tsteller in https://reviews.llvm.org/D117977#3670919 for noticing. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D130362
2022-07-22[Flang] Generate documentation for compiler flagsDylan Fleming1-0/+28
This patch aims to create a webpage to document Flang's command line options on https://flang.llvm.org/docs/ in a similar way to Clang's https://clang.llvm.org/docs/ClangCommandLineReference.html This is done by using clang_tablegen to generate an .rst file from Options.td (which is current shared with Clang) For this to work, ClangOptionDocEmitter.cpp was updated to allow specific Flang flags to be included, rather than bulk excluding clang flags. Note: Some headings in the generated documentation will incorrectly contain references to Clang, e.g. "Flags controlling the behaviour of Clang during compilation" This is because Options.td (Which is shared between both Clang and Flang) contains hard-coded DocBrief sections. I couldn't find a non-intrusive way to make this target-dependant, as such I've left this as is, and it will need revisiting later. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D129864
2022-07-21Revert "[Flang] Generate documentation for compiler flags"Andrzej Warzynski1-28/+0
This reverts commit 396e944d82f3e212746cd241e4caba445523aff6. Failing bot: https://lab.llvm.org/buildbot/#/builders/89/builds/30096
2022-07-21[Flang] Generate documentation for compiler flagsDylan Fleming1-0/+28
This patch aims to create a webpage to document Flang's command line options on https://flang.llvm.org/docs/ in a similar way to Clang's https://clang.llvm.org/docs/ClangCommandLineReference.html This is done by using clang_tablegen to generate an .rst file from Options.td (which is current shared with Clang) For this to work, ClangOptionDocEmitter.cpp was updated to allow specific Flang flags to be included, rather than bulk excluding clang flags. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D129864
2022-07-14[analyzer] Evaluate construction of non-POD type arraysisuckatcs1-1/+10
Introducing the support for evaluating the constructor of every element in an array. The idea is to record the index of the current array member being constructed and create a loop during the analysis. We looping over the same CXXConstructExpr as many times as many elements the array has. Differential Revision: https://reviews.llvm.org/D127973
2022-07-13[clang] Use value instead of getValue (NFC)Kazu Hirata1-6/+6
2022-07-05[RISCV][Clang] Teach RISCVEmitter to generate BitCast for pointer operands.Yeting Kuo1-0/+10
RVV C intrinsics use pointers to scalar for base address and their corresponding IR intrinsics but use pointers to vector. It makes some vector load intrinsics need specific ManualCodegen and MaskedManualCodegen to just add bitcast for transforming to IR. For simplifying riscv_vector.td, the patch make RISCVEmitter detect pointer operands and bitcast them. Reviewed By: kito-cheng Differential Revision: https://reviews.llvm.org/D129043
2022-06-25[clang] Don't use Optional::hasValue (NFC)Kazu Hirata1-5/+5
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-11/+11
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-11/+11
2022-06-22Clang AttributeReference: emit entries for "Undocumented" attributes.James Y Knight1-10/+16
Almost all attributes currently marked `Undocumented` are user-facing attributes which _ought_ to be documented, but nobody has written it yet. This change ensures that we at least acknowledge that these attributes exist in the documentation, even if we have no description of their semantics. A new category, `InternalOnly` has been added for those few attributes which are not user-facing, and should remain omitted from the docs.
2022-06-20[clang] Don't use Optional::getValue (NFC)Kazu Hirata2-4/+3
2022-06-20[clang] Don't use Optional::hasValue (NFC)Kazu Hirata2-2/+2
2022-06-20[OpenCL][TableGen] Fix type extension guard emissionSven van Haastregt1-1/+1
For certain cases (such as for the double subtype of AGenType), the OpenCLBuiltinFileEmitterBase would not emit the extension #if-guard. Fix that by looking at the extension of the actual type instead of the argument type (which could be a GenType that does not carry any extension information).
2022-06-20[analyzer] SATest: Weaken assumption about HTML filesMarco Antognini1-5/+8
Instead of assuming there is an HTML file for each diagnostics, consider the HTML files only when they exist, individually of each other. After generating the reference data, running python /scripts/SATest.py build --projects simbody was resulting in this error: File "/scripts/CmpRuns.py", line 250, in read_single_file assert len(d['HTMLDiagnostics_files']) == 1 KeyError: 'HTMLDiagnostics_files' Reviewed By: steakhal Differential Revision: https://reviews.llvm.org/D126197
2022-06-20[analyzer] SATest: Ensure Docker image can be builtMarco Antognini1-0/+4
Solve build issues occurring when running `docker build`. Fix the version of cmake-data to solve the following issue: The following packages have unmet dependencies: cmake : Depends: cmake-data (= 3.20.5-0kitware1) but 3.23.1-0kitware1ubuntu18.04.1 is to be installed Install libjpeg to solve this issue when installing Python requirements: The headers or library files could not be found for jpeg, a required dependency when compiling Pillow from source. Reviewed By: steakhal Differential Revision: https://reviews.llvm.org/D126196
2022-06-18[clang] Use value_or instead of getValueOr (NFC)Kazu Hirata1-1/+1
2022-06-18[clang] Call *set::insert without checking membership first (NFC)Kazu Hirata1-2/+1
2022-06-16cmake: configure clang lit to use hmaptool from source directlyMatheus Izvekov1-10/+1
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: dyung Differential Revision: https://reviews.llvm.org/D127943
2022-06-15[clang] Reject non-declaration C++11 attributes on declarationsMartin Boehme1-1/+1
For backwards compatiblity, we emit only a warning instead of an error if the attribute is one of the existing type attributes that we have historically allowed to "slide" to the `DeclSpec` just as if it had been specified in GNU syntax. (We will call these "legacy type attributes" below.) The high-level changes that achieve this are: - We introduce a new field `Declarator::DeclarationAttrs` (with appropriate accessors) to store C++11 attributes occurring in the attribute-specifier-seq at the beginning of a simple-declaration (and other similar declarations). Previously, these attributes were placed on the `DeclSpec`, which made it impossible to reconstruct later on whether the attributes had in fact been placed on the decl-specifier-seq or ahead of the declaration. - In the parser, we propgate declaration attributes and decl-specifier-seq attributes separately until we can place them in `Declarator::DeclarationAttrs` or `DeclSpec::Attrs`, respectively. - In `ProcessDeclAttributes()`, in addition to processing declarator attributes, we now also process the attributes from `Declarator::DeclarationAttrs` (except if they are legacy type attributes). - In `ConvertDeclSpecToType()`, in addition to processing `DeclSpec` attributes, we also process any legacy type attributes that occur in `Declarator::DeclarationAttrs` (and emit a warning). - We make `ProcessDeclAttribute` emit an error if it sees any non-declaration attributes in C++11 syntax, except in the following cases: - If it is being called for attributes on a `DeclSpec` or `DeclaratorChunk` - If the attribute is a legacy type attribute (in which case we only emit a warning) The standard justifies treating attributes at the beginning of a simple-declaration and attributes after a declarator-id the same. Here are some relevant parts of the standard: - The attribute-specifier-seq at the beginning of a simple-declaration "appertains to each of the entities declared by the declarators of the init-declarator-list" (https://eel.is/c++draft/dcl.dcl#dcl.pre-3) - "In the declaration for an entity, attributes appertaining to that entity can appear at the start of the declaration and after the declarator-id for that declaration." (https://eel.is/c++draft/dcl.dcl#dcl.pre-note-2) - "The optional attribute-specifier-seq following a declarator-id appertains to the entity that is declared." (https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-1) The standard contains similar wording to that for a simple-declaration in other similar types of declarations, for example: - "The optional attribute-specifier-seq in a parameter-declaration appertains to the parameter." (https://eel.is/c++draft/dcl.fct#3) - "The optional attribute-specifier-seq in an exception-declaration appertains to the parameter of the catch clause" (https://eel.is/c++draft/except.pre#1) The new behavior is tested both on the newly added type attribute `annotate_type`, for which we emit errors, and for the legacy type attribute `address_space` (chosen somewhat randomly from the various legacy type attributes), for which we emit warnings. Depends On D111548 Reviewed By: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D126061
2022-06-10[clang][tablegen] adds human documentation to `WarningOption`Christopher Di Bella1-2/+10
Building on D126796, this commit adds the infrastructure for being able to print out descriptions of what each warning does. Differential Revision: https://reviews.llvm.org/D126832
2022-06-09cmake: use llvm dir variables for clang/utils/hmaptoolMatheus Izvekov1-14/+9
Copy hmaptool using the paths for CURRENT_TOOLS_DIR, so everything goes in the right place in case llvm is included from a top level CMakeLists.txt. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: stephenneuendorffer Differential Revision: https://reviews.llvm.org/D126308
2022-06-03[Attributes] Remove AttrSyntax and migrate uses to ↵Leonard Grey1-9/+14
AttributeCommonInfo::Syntax (NFC) This is setup for allowing hasAttribute to work for plugin-provided attributes Differential Revision: https://reviews.llvm.org/D126902
2022-06-02Revert "cmake: use llvm dir variables for clang/utils/hmaptool"Nikita Popov1-5/+15
As discussed on the review, this change breaks the standalone clang build. When building against an installed LLVM, the LLVM_TOOLS_BINARY_DIR cmake variable points to the location of the installed LLVM tools, not to the cmake build directory. This means that we would end up trying to move hmaptool into something like /usr/bin as part of the normal build, while this should only be happening when running an install target. This reverts commit bf1ab1f0eb9578914343f48096229ecccd0ecf52.
2022-05-31[RISCV][NFC] Rename variables in rvv intrinsics related files.Zakk Chen1-5/+5
This patch does the same thing as D125886 did. - Use `Overloaded` rather than `Mangled`. - Use `Prototype` or `Desc` rather than `Seq`, it's not just a string sequence. Reviewed By: fakepaper56 Differential Revision: https://reviews.llvm.org/D126634
2022-05-30cmake: fix clang standalone buildMatheus Izvekov1-1/+1
D126308 broke building clang standalone, as LLVM_UTILS_INSTALL_DIR is not exported. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D126671
2022-05-28[clang][cmake] Fixed typo in hmaptool CMakeLists.txtDaniel Hannon1-1/+1
There was a typo in the CMakeLists.txt for hmap tool that installed it to the wrong directory https://github.com/llvm/llvm-project/issues/55753 Reviewed By: keith Differential Revision: https://reviews.llvm.org/D126598
2022-05-27cmake: use llvm dir variables for clang/utils/hmaptoolMatheus Izvekov1-15/+5
Install hmaptool using the LLVM specific variables, so everything goes in the right place in case llvm is included from a top level CMakeLists.txt. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: stephenneuendorffer Differential Revision: https://reviews.llvm.org/D126308
2022-05-18[RISCV][NFC] Rename variable in RISCVVEmitter.cppKito Cheng1-26/+26
- Use `Overloaded` rather than `Mangled`. - Use `Prototype` or `Desc` rather than `Seq`, it's not just a string sequence. - `Prototype` for those PrototypeDescriptor will used to evaluate as argument type. - `Desc` for those PrototypeDescriptor will used to evaluate as part of function name. Reviewed By: khchen Differential Revision: https://reviews.llvm.org/D125886
2022-05-16[RISCV][NFC] Refactor RISC-V vector intrinsic utils.Kito Cheng1-105/+70
This patch is preparation for D111617, use class/struct/enum rather than char/StringRef to present internal information as possible, that provide more compact way to store those info and also easier to serialize/deserialize. And also that improve readability of the code, e.g. "v" vs TypeProfile::Vector. Reviewed By: khchen Differential Revision: https://reviews.llvm.org/D124730
2022-04-20[clang-tblgen] Automatically document options valuesserge-sans-paille1-2/+26
This is a port of f5c666742f7bb4ae79ec79c8acf61dced4d37cc9 to clang's tablegen, with a better wording. Differential Revision: https://reviews.llvm.org/D123682
2022-04-20[RISCV] Moving RVV intrinsic type related util to clang/SupportKito Cheng2-793/+32
We add a new clang library called `clangSupport` for putting those utils which can be used in clang table-gen and other clang component. We tried to put that into `llvm/Support`, but actually those stuffs only used in clang* and clang-tblgen, so I think that might be better to create `clang/Support` * clang will used that in https://reviews.llvm.org/D111617. Reviewed By: khchen, MaskRay, aaron.ballman Differential Revision: https://reviews.llvm.org/D121984
2022-04-19[analyzer] ClangSA should tablegen doc urls refering to the main doc pageBalazs Benics1-10/+5
AFAIK we should prefer https://clang.llvm.org/docs/analyzer/checkers.html to https://clang-analyzer.llvm.org/{available_checks,alpha_checks}.html This patch will ensure that the doc urls produced by tablegen for the ClangSA, will use the new url. Nothing else will be changed. Reviewed By: martong, Szelethus, ASDenysPetrov Differential Revision: https://reviews.llvm.org/D121387
2022-04-19[analyzer] Turn missing tablegen doc entry of a checker into fatal errorBalazs Benics1-8/+11
It turns out all checkers explicitly mention the `Documentation<>`. It makes sense to demand this, so emit a fatal tablegen error if such happens. Reviewed By: martong, Szelethus Differential Revision: https://reviews.llvm.org/D122244
2022-04-19[analyzer][NFC] Introduce the checker package separator characterBalazs Benics1-9/+10
Reviewed By: martong, ASDenysPetrov Differential Revision: https://reviews.llvm.org/D122243
2022-04-14[HLSL] Add Semantic syntax, and SV_GroupIndexChris Bieneman1-7/+22
HLSL has a language feature called Semantics which get attached to declarations like attributes and are used in a variety of ways. One example of semantic use is here with the `SV_GroupIndex` semantic which, when applied to an input for a compute shader is pre-populated by the driver with a flattened thread index. Differential Revision: https://reviews.llvm.org/D122699 # Conflicts: # clang/include/clang/Basic/Attr.td # clang/include/clang/Basic/AttrDocs.td
2022-04-08Revert "Reland "[RISCV][NFC] Moving RVV intrinsic type related util to ↵Kito Cheng1-2/+198
llvm/Support"" This reverts commit fc2d8326ae4d6e05c1aa2db7e7dbd8e759bf4d51.
2022-04-08Reland "[RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support"Kito Cheng1-198/+2
Reland Note: We've resolve the circular dependency issue on llvm/lib/Support and llvm/TableGen. Differential Revision: https://reviews.llvm.org/D121984
2022-03-28Revert D121984 "[RISCV][NFC] Moving RVV intrinsic type related util to ↵Fangrui Song1-2/+198
llvm/Support" This reverts commit ad57e10dbca2fdeff1448afc0aa1cf23d6df8736 and 1967fd8d5e7e40a987d8f65d163c7eb8f4b9e76f llvm/lib/Support/RISCVVIntrinsicUtils.cpp introduced llvm/TableGen includes, a circular dependency https://llvm.org/docs/CodingStandards.html#library-layering I think this particular instance is serious and should be reverted.
2022-03-28[RISCV][NFC] Moving RVV intrinsic type related util to llvm/SupportKito Cheng1-198/+2
This patch is split from https://reviews.llvm.org/D111617, we need those stuffs on clang, so must moving those stuff to llvm/Support. Reviewed By: khchen Differential Revision: https://reviews.llvm.org/D121984
2022-03-25[cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIRSam McCall3-10/+2
CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode) placeholder. It is used to add the just-built binaries to $PATH for lit tests. In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose. But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree and LLVM_TOOLS_DIR points at the provided LLVM binaries. Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and other things always built with clang. This is a few cryptic lines of CMake in each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg(). This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it: - there's nothing clang-specific about the value - it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch) It also defines CURRENT_LIBS_DIR. While I removed the last usage of CLANG_LIBS_DIR in e4cab4e24d1, there are LLD_LIBS_DIR usages etc that may be live, and I'd like to mechanically update them in a followup patch. Differential Revision: https://reviews.llvm.org/D121763
2022-03-24[NFCI] Fix set-but-unused warning in ClangAttrEmitter.cppDávid Bolvanský1-2/+0
2022-03-23[Clang][NeonEmitter] emit ret decl first for -Wdeclaration-after-statementNick Desaulniers1-7/+16
The generated arm_neon.h header isn't -Wdeclaration-after-statement compliant when targeting -mbig-endian. Update the generator to declare the return value, if any, first before any other arguments that might need to be "reversed" from little endian to big. Another approach would have been to try to ignore this warning in system headers, though that might not be precise for tokens involved in macro expansion. See also: https://reviews.llvm.org/D116833#3236209. Link: https://github.com/ClangBuiltLinux/linux/issues/1603 Fixes: https://github.com/llvm/llvm-project/issues/54062 Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D122189
2022-03-22[RISCV][NFC] Refine and refactor RISCVVEmitter and riscv_vector.td.Zakk Chen1-85/+74
1. Rename nomask as unmasked to keep with the terminology in the spec. 2. Merge UnMaskpolicy and Maskedpolicy arguments into one in RVVBuiltin class. 3. Rename HasAutoDef as HasBuiltinAlias. 4. Move header definition code into one class. Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D120870
2022-03-21[clang] Remove Address::deprecated from MveEmitterArthur Eubanks1-3/+14
We have to keep track of pointer pointee types with opaque pointers. Reviewed By: simon_tatham Differential Revision: https://reviews.llvm.org/D122046
2022-03-21[OpenCL] Guard write_only image3d_t with TypeExtensionSven van Haastregt1-4/+13
Ensure that the TypeExtension of an `ImageType` is also taken into account when generating `OpenCLBuiltins.inc`. This aligns the handling of the `write_only image3d_t` type for `-fdeclare-opencl-builtins` with opencl-c.h with respect to the `cl_khr_3d_image_writes` extension. Since the `write_only image3d_t` type is not available when the extension is disabled, this commit does not add a test to `SemaOpenCL/fdeclare-opencl-builtins.cl`.