Commit Graph

431209 Commits

Author SHA1 Message Date
Renato Golin 94761b9dba Update ProgrammersManual STL docs
The SGI page doesn't exist anymore and isn't really relevant at this day
and age.

While at it, added the "other" main C++ website and moved all URLs to
HTTPS.
2022-07-27 10:30:47 +01:00
Matheus Izvekov 15f3cd6bfc
[clang] Implement ElaboratedType sugaring for types written bare
Without this patch, clang will not wrap in an ElaboratedType node types written
without a keyword and nested name qualifier, which goes against the intent that
we should produce an AST which retains enough details to recover how things are
written.

The lack of this sugar is incompatible with the intent of the type printer
default policy, which is to print types as written, but to fall back and print
them fully qualified when they are desugared.

An ElaboratedTypeLoc without keyword / NNS uses no storage by itself, but still
requires pointer alignment due to pre-existing bug in the TypeLoc buffer
handling.

---

Troubleshooting list to deal with any breakage seen with this patch:

1) The most likely effect one would see by this patch is a change in how
   a type is printed. The type printer will, by design and default,
   print types as written. There are customization options there, but
   not that many, and they mainly apply to how to print a type that we
   somehow failed to track how it was written. This patch fixes a
   problem where we failed to distinguish between a type
   that was written without any elaborated-type qualifiers,
   such as a 'struct'/'class' tags and name spacifiers such as 'std::',
   and one that has been stripped of any 'metadata' that identifies such,
   the so called canonical types.
   Example:
   ```
   namespace foo {
     struct A {};
     A a;
   };
   ```
   If one were to print the type of `foo::a`, prior to this patch, this
   would result in `foo::A`. This is how the type printer would have,
   by default, printed the canonical type of A as well.
   As soon as you add any name qualifiers to A, the type printer would
   suddenly start accurately printing the type as written. This patch
   will make it print it accurately even when written without
   qualifiers, so we will just print `A` for the initial example, as
   the user did not really write that `foo::` namespace qualifier.

2) This patch could expose a bug in some AST matcher. Matching types
   is harder to get right when there is sugar involved. For example,
   if you want to match a type against being a pointer to some type A,
   then you have to account for getting a type that is sugar for a
   pointer to A, or being a pointer to sugar to A, or both! Usually
   you would get the second part wrong, and this would work for a
   very simple test where you don't use any name qualifiers, but
   you would discover is broken when you do. The usual fix is to
   either use the matcher which strips sugar, which is annoying
   to use as for example if you match an N level pointer, you have
   to put N+1 such matchers in there, beginning to end and between
   all those levels. But in a lot of cases, if the property you want
   to match is present in the canonical type, it's easier and faster
   to just match on that... This goes with what is said in 1), if
   you want to match against the name of a type, and you want
   the name string to be something stable, perhaps matching on
   the name of the canonical type is the better choice.

3) This patch could expose a bug in how you get the source range of some
   TypeLoc. For some reason, a lot of code is using getLocalSourceRange(),
   which only looks at the given TypeLoc node. This patch introduces a new,
   and more common TypeLoc node which contains no source locations on itself.
   This is not an inovation here, and some other, more rare TypeLoc nodes could
   also have this property, but if you use getLocalSourceRange on them, it's not
   going to return any valid locations, because it doesn't have any. The right fix
   here is to always use getSourceRange() or getBeginLoc/getEndLoc which will dive
   into the inner TypeLoc to get the source range if it doesn't find it on the
   top level one. You can use getLocalSourceRange if you are really into
   micro-optimizations and you have some outside knowledge that the TypeLocs you are
   dealing with will always include some source location.

4) Exposed a bug somewhere in the use of the normal clang type class API, where you
   have some type, you want to see if that type is some particular kind, you try a
   `dyn_cast` such as `dyn_cast<TypedefType>` and that fails because now you have an
   ElaboratedType which has a TypeDefType inside of it, which is what you wanted to match.
   Again, like 2), this would usually have been tested poorly with some simple tests with
   no qualifications, and would have been broken had there been any other kind of type sugar,
   be it an ElaboratedType or a TemplateSpecializationType or a SubstTemplateParmType.
   The usual fix here is to use `getAs` instead of `dyn_cast`, which will look deeper
   into the type. Or use `getAsAdjusted` when dealing with TypeLocs.
   For some reason the API is inconsistent there and on TypeLocs getAs behaves like a dyn_cast.

5) It could be a bug in this patch perhaps.

Let me know if you need any help!

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D112374
2022-07-27 11:10:54 +02:00
Sam McCall 7b70c2e75c [pseudo] Fix initializer of string table
Apparently new string[/*no size*/]{"foo", "bar"} is a clang/gcc extension?
2022-07-27 11:04:12 +02:00
Daniil Dudkin fefa36a864 [flang][NFC] Unify check prefixes in `abstract-results.fir` test
Now the prefixes have the same length
and they'll be easier to distinguish when
`GlobalOp` tests will be added

Depends on D129778

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D130087
2022-07-27 11:57:51 +03:00
Daniil Dudkin cb33e4ab14 [flang] Generalize `AbstractResultOpt` pass
This change decouples common functionality for convering abstract
results, so it can be reused later.

Depends on D129485

Reviewed By: clementval, jeanPerier

Differential Revision: https://reviews.llvm.org/D129778
2022-07-27 11:55:17 +03:00
Alex Zinenko e99fae8997 [mlir] more aggressive folding in tiling/fusion transformations
Combine the recently added utilities for folded-by-construction affine
operations with the attribute-based Range to enable more folding. This
decreases the amount of emitted code but has little effect on test
precisely because the tests are not checking for the spurious constants.
The difference in the shape of affine maps comes from the internals of
affine folding.

Depends on D129633

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D130167
2022-07-27 08:52:18 +00:00
Alex Zinenko 70e99f387a [mlir] Make ViewLikeInterface Range work with attributes
While most of methods in ViewLikeInterface accept an `OpFoldResult` for
the offset/size/stride that may be static, represented as `Attribute`,
or dynamic, represented as `Value`, the `Range` abstraction only
accepted `Values`. This can often lead to known-constant
offset/size/strides being materialized into constant operations and
hinder further constant propagation without explicitly running the
constant folding pass. This often leads to a more complicated than
necessary addressing code being emitted. Switch `Range` to use
`OpFoldResult`. Code that uses `Range` currently keeps materializing the
constants to minimize the effect of this change on the IR. Further
commits will make use of this.

Reviewed By: nicolasvasilache, mravishankar

Differential Revision: https://reviews.llvm.org/D129633
2022-07-27 08:52:13 +00:00
Alex Zinenko 08a1b07e7c [mlir] Partially port splitting transform to TilingInterface
The structured op splitting transformation is conceptually similar to
tiling in the sense that it decomposes the iteration space of the
original op into several parts. Therefore, it is possible to implement
it using the TilingInterface to operate on iteration spaces and their
parts. However, the implementation also requires to pass updated input
operands, which is not supported by the interface, so the implementation
currently remains Linalg-specific.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D129564
2022-07-27 08:52:08 +00:00
Alexey Lapshin 79ff02a122 Revert "[Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections."
This reverts commit 0d191b7553.
2022-07-27 11:48:56 +03:00
Ying Yi 8d46cb343f Emit a simple StackSizesSection on PS4.
Differential Revision: https://reviews.llvm.org/D130495
2022-07-27 09:39:24 +01:00
Ying Yi bfe191dfa7 Disable stack-sizes section by default for PS4.
Differential Revision: https://reviews.llvm.org/D130493
2022-07-27 09:37:20 +01:00
David Green 39f8384964 [ARM] Correct features on pacbti instructions.
Given a patch like D129506, using instructions not valid for the current
feature set becomes an error. This updates the Arm hint-space
instructions for pac/bti to require thumbv7m as opposed to 8.1-m.main, to
make them valid when compiling for thumbv7m with -mbranch-protection.

Differential Revision: https://reviews.llvm.org/D129692
2022-07-27 09:15:14 +01:00
Adrian Kuegel a0154218c3 [mlir] Apply ClangTidyPerformance findings (NFC) 2022-07-27 10:05:22 +02:00
Nikita Popov b1b1086973 [ARM] Add target feature to force 32-bit atomics
This adds a +atomic-32 target feature, which instructs LLVM to assume
that lock-free 32-bit atomics are available for this target, even
if they usually wouldn't be.

If only atomic loads/stores are used, then this won't emit libcalls.
If atomic CAS is used, then the user is responsible for providing
any necessary __sync implementations (e.g. by masking interrupts
for single-core privileged use cases).

See https://reviews.llvm.org/D120026#3674333 for context on this
change. The tl;dr is that the thumbv6m target in Rust has
historically made atomic load/store only available, which is
incompatible with the change from D120026, which switched these to
use libatomic.

Differential Revision: https://reviews.llvm.org/D130480
2022-07-27 10:00:31 +02:00
Amara Emerson 9cc1dd209d [AArch64][GlobalISel] Lower vector G_CTTZ.
Fixes issue 56398
2022-07-27 00:14:30 -07:00
Sam McCall afc4958f5a [pseudo] Add dangling-else guard to missing if-statement variants 2022-07-27 09:08:34 +02:00
Sam McCall 89f284bc23 [pseudo] Remove dead header
This was an earlier draft of Language.h that got committed accidentally
2022-07-27 09:05:59 +02:00
Sam McCall 6bdb15fe84 [pseudo] Reorganize CXX.h enums
- Place rules under rule::lhs::rhs__rhs__rhs
- Change mangling of keywords to ALL_CAPS (needed to turn keywords that appear
  alone on RHS into valid identifiers)
- Make enums implicitly convertible to underlying type (though still scoped,
  using alias tricks)

In principle this lets us exhaustively write a switch over all rules of a NT:
  switch ((rule::declarator)N->rule()) {
    case rule::declarator::noptr_declarator:
      ...
  }
In practice we don't do this anywhere yet as we're often switching over multiple
nonterminal kinds at once.

Differential Revision: https://reviews.llvm.org/D130414
2022-07-27 09:03:29 +02:00
Amara Emerson aeeb174cec Update checks legalize-cttz.mir test before change. 2022-07-26 23:41:09 -07:00
Chuanqi Xu 8d91b1da57 [NFC] [C++20] [Modules] Use Sema::isModuleUnitOfCurrentTU to simplify the code 2022-07-27 14:33:28 +08:00
Danny Mösch e818ce0e06 [clang] Make parts of index test optional
Reason is that the test behaves differently in clang-ppc64-aix in that the optional part appears in the output.
2022-07-27 08:25:52 +02:00
Chuanqi Xu e8e46cdce3 [NFC] [C++20] [Modules] Use Sema::isCurrentModulePurview() to simplify the codes 2022-07-27 14:15:32 +08:00
Chuanqi Xu 5588985212 [NFC] Convert a dyn_cast<> to an isa<> 2022-07-27 13:56:38 +08:00
Tom Stellard 809855b56f Bump the trunk major version to 16 2022-07-26 21:34:45 -07:00
Weverything 1f8ae9d7e7 Inline function calls.
Fix unused variable in non-assert builds after
300fbf56f8
2022-07-26 21:12:28 -07:00
Keith Smiley e3857791a7
[lld-macho] Fix -bitcode_process_mode arg type
This is still undocumented and unsupported, but if someone passed it
before you would end up with a missing file error since this takes an
argument that wouldn't be handled.

Differential Revision: https://reviews.llvm.org/D130606
2022-07-26 20:58:17 -07:00
Konstantin Varlamov b105f26c8a [libc++][ranges] Fix the CI. 2022-07-26 19:45:06 -07:00
Kai Luo 1cbaf681b0 [clang][AIX] Add option to control quadword lock free atomics ABI on AIX
We are supporting quadword lock free atomics on AIX. For the situation that users on AIX are using a libatomic that is lock-based for quadword types, we can't enable quadword lock free atomics by default on AIX in case user's new code and existing code accessing the same shared atomic quadword variable, we can't guarentee atomicity. So we need an option to enable quadword lock free atomics on AIX, thus we can build a quadword lock-free libatomic(also for advanced users considering atomic performance critical) for users to make the transition smooth.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D127189
2022-07-27 01:56:25 +00:00
Kirill Stoimenov d6e1e0a019 [ASan] Use stack safety analysis to optimize allocas instrumentation.
Added alloca optimization which was missed during the implemenation of D112098.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130503
2022-07-26 18:48:16 -07:00
Vitaly Buka 704a6ea507 [asan][test] Check for __asan_stack_malloc 2022-07-26 18:28:14 -07:00
Jon Chesterfield 3ccd88f209 [amdgpu][nfc] Separate processUsedLDS into independent pieces, rename it 2022-07-27 01:55:43 +01:00
Michael Kruse fe0e5b3e43 [Polly] Insert !dbg metadata for emitted CallInsts.
The IR Verifier requires that every call instruction to an inlineable
function (among other things, its implementation must be visible in the
translation unit) must also have !dbg metadata attached to it. When
parallelizing, Polly emits calls to OpenMP runtime function out of thin
air, or at least not directly derived from a bounded list of previous
instruction. While we could search for instructions in the SCoP that has
some debug info attached to it, there is no guarantee that we find any.
Our solution is to generate a new DILocation that points to line 0 to
represent optimized code.

The OpenMP function implementation is usually not available in the
user's translation unit, but can become visible in an LTO build. For
the bug to appear, libomp must also be built with debug symbols.

IMHO, the IR verifier rule is too strict. Runtime functions can
also be inserted by other optimization passes, such as
LoopIdiomRecognize. When inserting a call to e.g. memset, it uses the
DebugLoc from a StoreInst from the unoptimized code. It is not
required to have !dbg metadata attached either.

Fixes #56692
2022-07-26 19:43:53 -05:00
Jon Chesterfield 9981afdd42 [amdgpu][nfc] Extract kernel annotation from processUsedLDS 2022-07-27 01:38:41 +01:00
Tom Stellard 858ded9cba workflows: Use sccache to speed up CI builds
Reviewed By: asl

Differential Revision: https://reviews.llvm.org/D129880
2022-07-26 17:25:26 -07:00
Vitaly Buka c99b9cf45a [asan][test] Cleanup asan-stack-safety.ll test 2022-07-26 17:18:00 -07:00
Tom Stellard 9d05de2a91 Import CI tests from the release branch
The tests still only run on pushes or pull requests for the release
branch, but having it in the main branch means we don't have to copy
the tests every time we create a new release branch.

Reviewed By: asl

Differential Revision: https://reviews.llvm.org/D129526
2022-07-26 16:53:24 -07:00
Konstantin Varlamov 8e26c315a7 [libc++][NFC] Add checks for lifetime issues in classic algorithms.
Differential Revision: https://reviews.llvm.org/D130330
2022-07-26 16:15:11 -07:00
Konstantin Varlamov d406c6493e [libc++][ranges] Implement `ranges::is_heap{,_until}`.
Differential Revision: https://reviews.llvm.org/D130547
2022-07-26 16:11:24 -07:00
Jakob Johnson d36ae4952d Add string conversion for InstructionControlFlowKind enum
Refactor the string conversion of the `lldb::InstructionControlFlowKind` enum out
of `Instruction::Dump` to enable reuse of this logic by the
JSON TraceDumper (to be implemented in separate diff).

Will coordinate the landing of this change with D130320 since there will be a minor merge conflict between
these changes.

Test Plan:
Run unittests
```
> ninja check-lldb
[4/5] Running lldb unit test suite

Testing Time: 10.13s
  Passed: 1084
```

Verify '-k' flag's output
```
(lldb) thread trace dump instructions -k
thread #1: tid = 1375377
  libstdc++.so.6`std::ostream::flush() + 43
    7048: 0x00007ffff7b54dab    return      retq
    7047: 0x00007ffff7b54daa    other       popq   %rbx
    7046: 0x00007ffff7b54da7    other       movq   %rbx, %rax
    7045: 0x00007ffff7b54da5    cond jump   je     0x11adb0                  ; <+48>
    7044: 0x00007ffff7b54da2    other       cmpl   $-0x1, %eax
  libc.so.6`_IO_fflush + 249
    7043: 0x00007ffff7161729    return      retq
    7042: 0x00007ffff7161728    other       popq   %rbp
    7041: 0x00007ffff7161727    other       popq   %rbx
    7040: 0x00007ffff7161725    other       movl   %edx, %eax
    7039: 0x00007ffff7161721    other       addq   $0x8, %rsp
    7038: 0x00007ffff7161709    cond jump   je     0x87721                   ; <+241>
    7037: 0x00007ffff7161707    other       decl   (%rsi)
    7036: 0x00007ffff71616fe    cond jump   je     0x87707                   ; <+215>
    7035: 0x00007ffff71616f7    other       cmpl   $0x0, 0x33de92(%rip)      ; __libc_multiple_threads
    7034: 0x00007ffff71616ef    other       movq   $0x0, 0x8(%rsi)
    7033: 0x00007ffff71616ed    cond jump   jne    0x87721                   ; <+241>
    7032: 0x00007ffff71616e9    other       subl   $0x1, 0x4(%rsi)
    7031: 0x00007ffff71616e2    other       movq   0x88(%rbx), %rsi
    7030: 0x00007ffff71616e0    cond jump   jne    0x87721                   ; <+241>
    7029: 0x00007ffff71616da    other       testl  $0x8000, (%rbx)           ; imm = 0x8000
```

Differential Revision: https://reviews.llvm.org/D130580
2022-07-26 16:09:57 -07:00
Konstantin Varlamov 964aeb713e [libc++][ranges] Make sure all range algorithms support differing projection types:
- for all algorithms taking more than one range, add a `robust` test to
  check the case where the ranges have different value types and the
  given projections are different, with each projection applying to
  a different value type;
- fix `ranges::include` to apply the correct projection to each range.

Differential Revision: https://reviews.llvm.org/D130515
2022-07-26 15:51:49 -07:00
Konstantin Varlamov ead7302bbb [libc++][ranges] Implement `ranges::generate{,_n}`.
Differential Revision: https://reviews.llvm.org/D130552
2022-07-26 15:50:32 -07:00
Tom Stellard fd84d97ba6 Revert "[Support] Workaround compiler bug in MSVC"
This reverts commit ec8f4fd68c.

This caused a failure in the mlir-windows bot.
2022-07-26 15:49:35 -07:00
Tom Stellard 66d755bbf8 workflows: Add GitHub action for automating some release tasks
For each release tag, this action will create a new release on GitHub,
and for each -final tag, this action will build the documentation and
upload it to GitHub.

Reviewed By: hans, kwk

Differential Revision: https://reviews.llvm.org/D99780
2022-07-26 15:36:51 -07:00
Tom Stellard f673dcc693 github: Automatically assign reviewers for backport requests
When there is a backport request, the GitHub Action that handles the
backport will now automatically assign the issue to the user(s) who
approved the commit in Phabricator and create an issue comment asking
them to review the request.

Reviewed By: thieta, kwk

Differential Revision: https://reviews.llvm.org/D126423
2022-07-26 15:30:27 -07:00
Dmitry Vassiliev e3e63f30a5 [CodeGen] Fixed ambiguous symbol ExtAddrMode in case of NDEBUG and LLVM_ENABLE_DUMP
This patch fixes the following error with MSVC 16.9.2 in case of NDEBUG and LLVM_ENABLE_DUMP:
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2872: 'ExtAddrMode': ambiguous symbol
llvm/include/llvm/CodeGen/TargetInstrInfo.h(86): note: could be 'llvm::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2447): note: or '`anonymous-namespace'::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2039: 'print': is not a member of 'llvm::ExtAddrMode'

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D130426
2022-07-27 00:21:57 +02:00
Tom Stellard 17d4796cc8 github: Fix release automation /branch command with new repo
We started using the llvm/llvm-project-release-prs repo for
backport pull requests, but since this repo is not a fork of
llvm/llvm-project it will reject pull requests from other repos. In
order to fix this, when ever someone uses the /branch command to request
a branch be merged into the release branch, we first copy the branch to
the llvm-project-release-prs repo and then create the pull request.

Reviewed By: thieta

Differential Revision: https://reviews.llvm.org/D126940
2022-07-26 15:05:05 -07:00
Fangrui Song b3270888cb [ELF] addDependentLibrary: fix a use-after-free bug in archiveName 2022-07-26 14:52:07 -07:00
River Riddle 01eedbc7c1 [mlir] Refactor SubElementInterface replace support
The current support was essentially the amount necessary
to support replacing SymbolRefAttrs, but suffers from various
deficiencies (both ergonomic and functional):

* Replace crashes if unsupported
 This makes it really hard to use safely, given that you don't know
 if you are going to crash or not when using it.

* Types aren't supported
This seems like a simple missed addition when the attribute replacement
support was originally added.

* The ergonomics are weird
It currently uses an index based replacement, which makes the implementations
quite clunky.

This commit refactors support to be a bit more ergonomic, and also
adds support for types in the process. This was also a great oppurtunity
to greatly simplify how replacement is done in the symbol table.

Fixes #56355

Differential Revision: https://reviews.llvm.org/D130589
2022-07-26 14:51:22 -07:00
Fangrui Song 6d0b42745e [ELF] addLibrary: fix a use-after-free bug in archiveName
It manifests as an incorrect name in --print-archive-stats=.
2022-07-26 14:36:57 -07:00
Fangrui Song e27a029ed0 [ELF][test] Clean up print-archive-stats.s 2022-07-26 14:36:09 -07:00