- May 31, 2023
-
-
Richard Sandiford authored
Platform-specific language extensions often want to provide a way of indicating that certain functions should be called in a different way, compiled in a different way, or otherwise treated differently from a “normal” function. Honoring these indications is often required for correctness, rather being than an optimization/QoI thing. If a function declaration has a property P that matters for correctness, it will be ODR-incompatible with a function that does not have property P. If a function type has a property P that affects the calling convention, it will not be two-way compatible with a function type that does not have property P. These properties therefore affect language semantics. That in turn means that they cannot be treated as standard [[]] attributes. Until now, many of these properties have been specified using GNU-style attributes instead. GNU attributes have traditionally been more lax than standard attributes, with many of them having semantic meaning. Examples include calling conventions and the vector_size attribute. However, there is a big drawback to using GNU attributes for semantic information: compilers that don't understand the attributes will (by default) emit a warning rather than an error. They will go on to compile the code as though the attributes weren't present, which will inevitably lead to wrong code in most cases. For users who live dangerously and disable the warning, this wrong code could even be generated silently. A more robust approach would be to specify the properties using keywords, which older compilers would then reject. Some vendor-specific extensions have already taken this approach. But traditionally, each such keyword has been treated as a language extension in its own right. This has three major drawbacks: (1) The parsing rules need to be kept up-to-date as the language evolves. (2) There are often corner cases that similar extensions handle differently. (3) Each extension requires more custom code than a standard attribute. The underlying problem for all three is that, unlike for true attributes, there is no established template that extensions can reuse. The purpose of this patch series is to try to provide such a template. One option would have been to pick an existing keyword and do whatever that keyword does. The problem with that is that most keywords only apply to specific kinds of types, kinds of decls, etc., and so the parsing rules are (for good reason) not generally applicable to all types and decls. Really, the “only” thing wrong with using standard attributes is that standard attributes cannot affect semantics. In all other respects they provide exactly what we need: a well-defined grammar that evolves with the language, clear rules about what an attribute appertains to, and so on. This series therefore adds keyword “attributes” that can appear exactly where a standard attribute can appear and that appertain to exactly what a standard attribute would appertain to. The link is mechanical and no opt-outs or variations are allowed. This should make the keywords predictable for programmers who are already familiar with standard attributes. This does mean that these keywords will be accepted for parsing purposes in many more places than necessary. Inappropriate uses will then be diagnosed during semantic analysis. However, the compiler would need to reject the keywords in those positions whatever happens, and treating them as ostensible attributes shouldn't be any worse than the alternative. In some cases it might even be better. For example, SME's __arm_streaming attribute would make conceptual sense as a statement attribute, so someone who takes a “try-it-and-see” approach might write: __arm_streaming { …block-of-code…; } In fact, we did consider supporting this originally. The reason for rejecting it was that it was too difficult to implement, rather than because it didn't make conceptual sense. One slight disadvantage of the keyword-based approach is that it isn't possible to use #pragma clang attribute with the keywords. Perhaps we could add support for that in future, if it turns out to be useful. For want of a better term, I've called the new attributes "regular" keyword attributes (in the sense that their parsing is regular wrt standard attributes), as opposed to "custom" keyword attributes that have their own parsing rules. This patch adds the Attr.td support for regular keyword attributes. Adding an attribute with a RegularKeyword spelling causes tablegen to define the associated tokens and to record that attributes created with that syntax are regular keyword attributes rather than custom keyword attributes. A follow-on patch contains the main Parse and Sema support, which is enabled automatically by the Attr.td definition. Other notes: * The series does not allow regular keyword attributes to take arguments, but this could be added in future. * I wondered about trying to use tablegen for TypePrinter::printAttributedAfter too, but decided against it. RegularKeyword is really a spelling-level classification rather than an attribute-level classification, and in general, an attribute could have both GNU and RegularKeyword spellings. In contrast, printAttributedAfter is only given the attribute kind and the type that results from applying the attribute. AFAIK, it doesn't have access to the original attribute spelling. This means that some attribute-specific or type-specific knowledge might be needed to print the attribute in the best way. * Generating the tokens automatically from Attr.td means that pseudo's libgrammar does now depend on tablegen. * The patch uses the SME __arm_streaming attribute as an example for testing purposes. The attribute does not do anything at this stage. Later SME-specific patches will add proper semantics for it, and add other SME-related keyword attributes. Differential Revision: https://reviews.llvm.org/D148700 -
Richard Sandiford authored
This patch retroactively classifies all existing keyword attributes as “custom” keyword attributes, in the sense that the keywords have their own custom parsing rules. A follow-on patch will add an alternative type of keyword. No functional change intended. Differential Revision: https://reviews.llvm.org/D148699
-
Timm Bäder authored
Differential Revision: https://reviews.llvm.org/D143334
-
Oleksandr "Alex" Zinenko authored
-
khei4 authored
Differential Revision: https://reviews.llvm.org/D151772
-
Nikita Popov authored
Make sure the invariant expressions are safe to expand. In particular, we should not speculative a trapping division into the preheader. Fixes https://github.com/llvm/llvm-project/issues/62992.
-
Alex Zinenko authored
The pass attaches attributes to operations for repro generation purposes, but never removes them. This is not desirable when the pass actually succeeds. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D151791
-
Alex Zinenko authored
-
Timm Bäder authored
-
Nikita Popov authored
Conservatively return unknown in this degenerate case. This is hard to hit in practice, because such phis are usually optimized away before they reach a getObjectSize() call. Fixes https://github.com/llvm/llvm-project/issues/63013.
-
Timm Bäder authored
They don't change inside the loop.
-
Timm Bäder authored
Seems unnecessary to create a StringRef here just so we can drop the trailing null bytes. We can do that with the std::string we create anyway. Differential Revision: https://reviews.llvm.org/D151300
-
Timm Bäder authored
We should preserve empty lines in output snippets. Differential Revision: https://reviews.llvm.org/D151301
-
Timm Bäder authored
Instead of creating a CaretLine the size of the SourceLine, just leave it empty at first, let HighlightRange resize it to fit all the ~, then resize it to fit the ^. Then we can save ourselves the work to remove the trailing whitespace again. Differential Revision: https://reviews.llvm.org/D151286
-
Benjamin Chetioui authored
-
Alex Zinenko authored
-
Timm Bäder authored
printWordWrapped() is only called in one place, which passes all parameters except `Indentation`. So, remove that parameter and use its default value instead. Also remove the other default parameter values, since those are unneeded.
-
Adrian Kuegel authored
-
LLVM GN Syncbot authored
-
Timm Bäder authored
They were both only called from one place and did very similar things. Merge them into one, so we only have to iterate the source line once to generate the SourceMap. Differential Revision: https://reviews.llvm.org/D151100
-
Timm Bäder authored
Instead of calling getDecomposedLoc() and then only using the FileID.
-
Balázs Kéri authored
Reviewed By: PiotrZSL Differential Revision: https://reviews.llvm.org/D151431
-
Timm Bäder authored
We don't use the offset returned from SourceManager::getDecomposedLoc here, so we might as well just use getFileID(). Differential Revision: https://reviews.llvm.org/D151093
-
Timm Bäder authored
Differential Revision: https://reviews.llvm.org/D151078
-
Timm Bäder authored
Don't try to minimize the times we invoke operator<< on the output stream by keeping a ToPrint string around. Instead, just print the characters as we iterate over them. Differential Revision: https://reviews.llvm.org/D151075
-
Matthias Springer authored
Instead of always taking the last op from the worklist, take a random one. For testing/debugging purposes only. This feature can be used to ensure that lowering pipelines work correctly regardless of the order in which ops are processed by the GreedyPatternRewriteDriver. The randomizer can be enabled by setting a numeric `MLIR_GREEDY_REWRITE_RANDOMIZER_SEED` option. Note: When enabled, 27 tests are currently failing. Partly because FileCheck tests are looking for exact IR. Discussion: https://discourse.llvm.org/t/discussion-fuzzing-pattern-application/67911 Differential Revision: https://reviews.llvm.org/D142447
-
Hristo Hristov authored
- Added additional tests - Improved existing tests - Moved misplaced test files to the correct location Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D151205
-
Timm Bäder authored
Rename parameters and local variables and reorder things a bit to be closer to their first point of use. Differential Revision: https://reviews.llvm.org/D150840
-
LiaoChunyu authored
Use sint_to_fp instead of select. Reduce the number of branch instructions and avoid generating TargetConstantPool for double. (select cc, 1.0, 0.0) -> (sint_to_fp (zext cc)) https://alive2.llvm.org/ce/z/aoEcd9 https://godbolt.org/z/n543Y9v3e (select cc, 0.0, 1.0) -> (sint_to_fp (zext (xor cc, 1))) https://alive2.llvm.org/ce/z/zngvSB Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D151719
-
Vlad Serebrennikov authored
Also add missing marking to the test of related issue 621. https://cplusplus.github.io/CWG/issues/621.html https://cplusplus.github.io/CWG/issues/873.html Reviewed By: #clang-language-wg, shafik Differential Revision: https://reviews.llvm.org/D151704
-
Timm Bäder authored
-
Timm Bäder authored
-
Timm Bäder authored
Use llvm::raw_ostream::indent().
-
Tobias Gysi authored
The revision adds the alias analysis and access group interfaces to the call operation. Reviewed By: Dinistro Differential Revision: https://reviews.llvm.org/D151693
-
Jianjian GUAN authored
This patch adds the Zvfhmin extension for clang. Reviewed By: craig.topper, michaelmaitland Differential Revision: https://reviews.llvm.org/D150253
-
Bing1 Yu authored
class VLIWSchedBoundary manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one. Reviewed By: JamesNagurne Differential Revision: https://reviews.llvm.org/D151699
-
Enna1 authored
This patch makes the variables names for callback functions more consistent. Changes no functionality. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D151605
-
Mark de Wever authored
This should fix the Clang CI.
-
Craig Topper authored
[RISCV] Merge emitDirectiveOptionArchPlus and emitDirectiveOptionArchMinus into a single interface. NFC Probably going to do some other refactors after this, but this one was easy and clearly reduces duplicate code. Reviewed By: StephenFan Differential Revision: https://reviews.llvm.org/D151771
-
Vitaly Buka authored
-