platform/upstream/llvm.git
2 years ago[LLD] [COFF] Add support for a new, mingw specific embedded directive -exclude-symbols:
Martin Storsjö [Sun, 17 Jul 2022 21:11:37 +0000 (00:11 +0300)]
[LLD] [COFF] Add support for a new, mingw specific embedded directive -exclude-symbols:

This is an entirely new embedded directive - extending the GNU ld
command line option --exclude-symbols to be usable in embedded
directives too.

(GNU ld.bfd also got support for the same new directive, currently in
the latest git version, after the 2.39 branch.)

This works as an inverse to the regular embedded dllexport directives,
for cases when autoexport of all eligible symbols is performed.

Differential Revision: https://reviews.llvm.org/D130120

2 years ago[LLD] [MinGW] Implement the --exclude-symbols option
Martin Storsjö [Mon, 18 Jul 2022 20:43:02 +0000 (23:43 +0300)]
[LLD] [MinGW] Implement the --exclude-symbols option

This adds support for the existing GNU ld command line option, which
allows excluding individual symbols from autoexport (when linking a
DLL and no symbols are marked explicitly as dllexported).

Differential Revision: https://reviews.llvm.org/D130118

2 years ago[TypePromotion] Search from ZExt + PHI
Andre Vieira [Thu, 11 Aug 2022 08:47:53 +0000 (09:47 +0100)]
[TypePromotion] Search from ZExt + PHI

Expand TypePromotion pass to try to promote PHI-nodes in loops that are the
operand of a ZExt, using the ZExt's result type to determine the Promote Width.

Differential Revision: https://reviews.llvm.org/D111237

2 years ago[TypePromotion] Hoist out Promote Width calculation
Andre Vieira [Thu, 11 Aug 2022 08:41:59 +0000 (09:41 +0100)]
[TypePromotion] Hoist out Promote Width calculation

Hoist out promote width calculation to simplify runOnFunction.

Differential Revision: https://reviews.llvm.org/D131489

2 years ago[TypePromotion] Don't delete Insns when iterating
Andre Vieira [Thu, 11 Aug 2022 08:39:20 +0000 (09:39 +0100)]
[TypePromotion] Don't delete Insns when iterating

Differential Revision: https://reviews.llvm.org/D131488

2 years ago[TypePromotion] Don't insert Truncate for a no-op ZExt
Andre Vieira [Thu, 11 Aug 2022 08:37:42 +0000 (09:37 +0100)]
[TypePromotion] Don't insert Truncate for a no-op ZExt

Differential Revision: https://reviews.llvm.org/D131487

2 years ago[MemorySanitizer] Support memcpy.inline and memset.inline
Marco Elver [Thu, 11 Aug 2022 08:40:57 +0000 (10:40 +0200)]
[MemorySanitizer] Support memcpy.inline and memset.inline

Other sanitizers (ASan, TSan, see added tests) already handle
memcpy.inline and memset.inline by not relying on InstVisitor to turn
the intrinsics into calls. Only MSan instrumentation currently does not
support them due to missing InstVisitor callbacks.

Fix it by actually making InstVisitor handle Mem*InlineInst.

While the mem*.inline intrinsics promise no calls to external functions
as an optimization, for the sanitizers we need to break this guarantee
since access into the runtime is required either way, and performance
can no longer be guaranteed. All other cases, where generating a call is
incorrect, should instead use no_sanitize.

Fixes: https://github.com/llvm/llvm-project/issues/57048

Reviewed By: vitalybuka, dvyukov

Differential Revision: https://reviews.llvm.org/D131577

2 years ago[mlir][sparse] Use the correct ABI on x86 and re-enable tests
Benjamin Kramer [Thu, 11 Aug 2022 08:38:12 +0000 (10:38 +0200)]
[mlir][sparse] Use the correct ABI on x86 and re-enable tests

c7ec6e19d5446a448f888b33f66316cf2ec6ecae made LLVM adhere to the x86
psABI and pass bf16 in SSE registers instead of GPRs. This breaks the
custom versions of runtime functions we have for bf16 conversion. A
great fix for this would be to use __bf16 types instead which carry the
right ABI, but that type isn't widely available.

Instead just pretend it's a 32 bit float on the ABI boundary and
carefully cast it to the right type.

Fixes #57042

2 years ago[gn build] Port 9ae5896d9673
LLVM GN Syncbot [Thu, 11 Aug 2022 08:37:36 +0000 (08:37 +0000)]
[gn build] Port 9ae5896d9673

2 years ago[LLDB] Fix out-of-bounds memory access in EmulationStateArm
Slava Gurevich [Thu, 11 Aug 2022 08:08:25 +0000 (01:08 -0700)]
[LLDB] Fix out-of-bounds memory access in EmulationStateArm

Functionally broken code for reading and writing registers, likely due to typos,
and could cause out-of-bounds memory access.

Differential Revision: https://reviews.llvm.org/D131658

2 years ago[clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check
Carlos Galvez [Thu, 2 Jun 2022 13:10:07 +0000 (13:10 +0000)]
[clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check

Flags uses of const-qualified and reference data members in structs.
Implements rule C.12 of C++ Core Guidelines.

Differential Revision: https://reviews.llvm.org/D126880

2 years ago[clang][dataflow] Store DeclContext of block being analysed in Environment if available.
Wei Yi Tee [Wed, 3 Aug 2022 14:48:49 +0000 (14:48 +0000)]
[clang][dataflow] Store DeclContext of block being analysed in Environment if available.

Differential Revision: https://reviews.llvm.org/D131065

2 years ago[clang] [HLSL] Fix GCC warnings about virtual methods that are hidden
Martin Storsjö [Tue, 2 Aug 2022 07:28:52 +0000 (10:28 +0300)]
[clang] [HLSL] Fix GCC warnings about virtual methods that are hidden

This fixes the following warnings produced by GCC 9:

In file included from ../tools/clang/include/clang/Sema/ExternalSemaSource.h:15,
                 from ../tools/clang/include/clang/Sema/HLSLExternalSemaSource.h:17,
                 from ../tools/clang/lib/Sema/HLSLExternalSemaSource.cpp:12:
../tools/clang/include/clang/AST/ExternalASTSource.h:211:16: warning: ‘virtual void clang::ExternalASTSource::CompleteType(clang::ObjCInterfaceDecl*)’ was hidden [-Woverloaded-virtual]
  211 |   virtual void CompleteType(ObjCInterfaceDecl *Class);
      |                ^~~~~~~~~~~~
In file included from ../tools/clang/lib/Sema/HLSLExternalSemaSource.cpp:12:
../tools/clang/include/clang/Sema/HLSLExternalSemaSource.h:49:8: warning:   by  virtual void clang::HLSLExternalSemaSource::CompleteType(clang::TagDecl*)’ [-Woverloaded-virtual]
   49 |   void CompleteType(TagDecl *Tag) override;
      |        ^~~~~~~~~~~~

Differential Revision: https://reviews.llvm.org/D130969

2 years ago[libcxx] [test] Merge the experimental-lib-exports testcases into static-lib-exports
Martin Storsjö [Thu, 7 Jul 2022 20:38:38 +0000 (23:38 +0300)]
[libcxx] [test] Merge the experimental-lib-exports testcases into static-lib-exports

Since bb939931a1adb9a47a2de13c359d6a72aeb277c8, the c++experimental
library is always built, so these tested files should always be built
(even if they aren't used in tests).

Differential Revision: https://reviews.llvm.org/D129399

2 years ago[clang] Try to fix builders
Timm Bäder [Thu, 11 Aug 2022 07:06:41 +0000 (09:06 +0200)]
[clang] Try to fix builders

Try to fix these errors:

SemaDeclCXX.cpp:16666:19: error: declaration of ‘const clang::Expr* clang::Sema::DiagnoseStaticAssertDetails(const clang::Expr*)::<unnamed struct>::Expr’ changes meaning of ‘Expr’ [-fpermissive]
16666 |       const Expr *Expr;
      |                   ^~~~

2 years ago[test][asan] Disable symbolization
Vitaly Buka [Thu, 11 Aug 2022 07:01:14 +0000 (00:01 -0700)]
[test][asan] Disable symbolization

Reduces runtime of the test.
Unrelated pre-merge checks often timeouts here.

2 years ago[JITLink] Silence GCC warnings about parentheses around && and || operators
Martin Storsjö [Thu, 11 Aug 2022 06:56:49 +0000 (09:56 +0300)]
[JITLink] Silence GCC warnings about parentheses around && and || operators

This silences the following warnings:

../include/llvm/ExecutionEngine/JITLink/JITLink.h:1108:56: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 1105 |     assert(S == Scope::Local || llvm::count_if(AbsoluteSymbols,
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1106 |                                                [&](const Symbol *Sym) {
      |                                                ~~~~~~~~~~~~~~~~~~~~~~~~
 1107 |                                                  return Sym->getName() == Name;
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1108 |                                                }) == 0 &&
      |                                                ~~~~~~~~^~
 1109 |                                     "Duplicate absolute symbol");
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

2 years ago[clangd][test] Fix error message in SerializationTest.BinaryConversions
Tom Praschan [Thu, 11 Aug 2022 06:32:22 +0000 (08:32 +0200)]
[clangd][test] Fix error message in SerializationTest.BinaryConversions

I noticed this when adding a new type to the index for
https://github.com/clangd/clangd/issues/529. When the assertion failed,
this actually caused a crash, because llvm::expected would complain that
we did not take the error.

2 years ago[PowerPC] Change a double Log2 for localentry to integral Log2. NFC
Fangrui Song [Thu, 11 Aug 2022 06:45:13 +0000 (23:45 -0700)]
[PowerPC] Change a double Log2 for localentry to integral Log2. NFC

2 years ago[clang][sema] Print more information about failed static assertions
Timm Bäder [Mon, 1 Aug 2022 12:12:32 +0000 (14:12 +0200)]
[clang][sema] Print more information about failed static assertions

For failed static assertions, try to take the expression apart and print
useful information about why it failed. In particular, look at binary
operators and print the compile-time evaluated value of the LHS/RHS.

Differential Revision: https://reviews.llvm.org/D130894

2 years ago[ORC] Add missing std::move.
Sunho Kim [Thu, 11 Aug 2022 06:40:47 +0000 (15:40 +0900)]
[ORC] Add missing std::move.

2 years ago[gn build] Port 7bece0f03bf6
LLVM GN Syncbot [Thu, 11 Aug 2022 06:28:14 +0000 (06:28 +0000)]
[gn build] Port 7bece0f03bf6

2 years ago[gn build] Port 7260cdd2e13a
LLVM GN Syncbot [Thu, 11 Aug 2022 06:28:12 +0000 (06:28 +0000)]
[gn build] Port 7260cdd2e13a

2 years ago[ORC][COFF] Introduce COFFVCRuntimeBootstrapper.
Sunho Kim [Thu, 11 Aug 2022 06:27:05 +0000 (15:27 +0900)]
[ORC][COFF] Introduce COFFVCRuntimeBootstrapper.

Introduces COFFVCRuntimeBootstrapper that loads/initialize vc runtime libraries. In COFF, we *must* jit-link vc runtime libraries as COFF relocation types have no proper way to deal with out-of-reach data symbols ragardless of linking mode. (even dynamic version msvcrt.lib have tons of static data symbols that must be jit-linked) This class tries to load vc runtime library files from msvc installations with an option to override the path.

There are some complications when dealing with static version of vc runtimes. First, they need static initializers to be ran that requires COFFPlatform support but orc runtime will not be usable before vc runtimes are fully initialized. (as orc runtime will use msvc stl libraries) COFFPlatform that will be introduced in a following up patch will collect static initializers and run them manually in host before boostrapping itself. So, the user will have to do the following.
1. Create COFFPlatform that addes static initializer collecting passes.
2. LoadVCRuntime
3. InitializeVCRuntime
4. COFFPlatform.bootstrap()
Second, the internal crt initialization function had to be reimplemented in orc side. There are other ways of doing this, but this is the simplest implementation that makes platform fully responsible for static initializer. The complication comes from the fact that crt initialization functions (such as acrt_initialize or dllmain_crt_process_attach) actually run all static initializers by traversing from `__xi_a` symbol to `__xi_z`. This requires symbols to be contiguously allocated in sections alphabetically sorted in memory, which is not possible right now and not practical in jit setting. We might ignore emission of `__xi_a` and `__xi_z` symbol and allocate them ourselves, but we have to take extra care after orc runtime boostrap has been done -- as that point orc runtime should be the one running the static initializers.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D130456

2 years ago[LLDB][RISCV] Add riscv software breakpoint trap code
Emmmer [Wed, 10 Aug 2022 13:36:48 +0000 (21:36 +0800)]
[LLDB][RISCV] Add riscv software breakpoint trap code

Added:
- Take RISC-V `ebreak` instruction as breakpoint trap code, so our breakpoint works as expected now.

Further work:
- RISC-V does not support hardware single stepping yet. A software implementation may come in future PR.
- Add support for RVC extension (the trap code, etc.).

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D131566

2 years ago[Clang] Update cxx_dr_status [NFC]
Corentin Jabot [Thu, 11 Aug 2022 06:21:28 +0000 (08:21 +0200)]
[Clang] Update cxx_dr_status [NFC]

Update the DR status page with the C++ Standard Core
Issues List revision 109.

2 years ago[LLDB][RISCV] Add riscv register definition and read/write
Emmmer [Wed, 10 Aug 2022 13:36:20 +0000 (21:36 +0800)]
[LLDB][RISCV] Add riscv register definition and read/write

This patch is based on the minimal extract of D128250.

What is implemented:
- Use the same register layout as Linux kernel and mock read/write for `x0` register (the always zero register).
- Refactor some duplicate code, and delete unused register definitions.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D130342

2 years ago[JITLink][COFF][x86_64] Stub SECREL relocation to external symbol.
Sunho Kim [Thu, 11 Aug 2022 06:12:25 +0000 (15:12 +0900)]
[JITLink][COFF][x86_64] Stub SECREL relocation to external symbol.

Stubs SECREL relocation to external symbol. In order to correctly deal with this, we want to requrest memory manager to keep track of address of first block of sepecific section and keep address to be only increased from that point. We also should give jitlink to get information about global section. The relocation is only used for debug and tls info which we don't support yet anyways, so just stubbing it for now.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D130451

2 years ago[JITLink][COFF][x86_64] Implement SECTION/SECREL relocation.
Sunho Kim [Thu, 11 Aug 2022 06:12:24 +0000 (15:12 +0900)]
[JITLink][COFF][x86_64] Implement SECTION/SECREL relocation.

Implements SECTION/SECREL relocation. These are used by debug info (pdb) data.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D130275

2 years ago[clang][transformer] Finish plumbing `Note` all the way to the output.
Clement Courbet [Wed, 29 Jun 2022 08:38:14 +0000 (10:38 +0200)]
[clang][transformer] Finish plumbing `Note` all the way to the output.

Right now we can only add a single warning, notes are not possible.

Apparently some provisions were made to allow notes, but they were never
propagated all the way to the diagnostics.

Differential Revision: https://reviews.llvm.org/D128807

2 years ago[RISCV][test] Precommitted test for optimization for vmerge and unmasked intrinsics.
Yeting Kuo [Fri, 29 Jul 2022 09:21:11 +0000 (17:21 +0800)]
[RISCV][test] Precommitted test for optimization for vmerge and unmasked intrinsics.

Precommitted test cases for D130442.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D130753

2 years ago[XCOFF] ignore the cold attribute.
esmeyi [Thu, 11 Aug 2022 05:13:05 +0000 (01:13 -0400)]
[XCOFF] ignore the cold attribute.

Summary: AIX XCOFF doesn't support the cold feature.
    While it shouldn't be a function error when XCOFF catching the cold attribute.
    As with the behavior of other formats, we just ignore the attribute for now.

Reviewed By: DiggerLin

Differential Revision: https://reviews.llvm.org/D131473

2 years ago[fir] Fix build
Jeff Niu [Thu, 11 Aug 2022 05:10:27 +0000 (01:10 -0400)]
[fir] Fix build

2 years ago[RISCV] Rename PROC_ALIAS to TUNE_ALIAS to reflect it's usage. NFC
Craig Topper [Thu, 11 Aug 2022 04:43:52 +0000 (21:43 -0700)]
[RISCV] Rename PROC_ALIAS to TUNE_ALIAS to reflect it's usage. NFC

This is not used as general CPU alias. Only to support -mtune. Name it as such.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D131602

2 years ago[CodeGen] Generate efficient assembly for freeze(poison) version of `mm*_cast*` intel...
aqjune [Mon, 27 Jun 2022 08:44:51 +0000 (17:44 +0900)]
[CodeGen] Generate efficient assembly for freeze(poison) version of `mm*_cast*` intel intrinsics

This patch makes the variants of `mm*_cast*` intel intrinsics that use `shufflevector(freeze(poison), ..)` emit efficient assembly.
(These intrinsics are planned to use `shufflevector(freeze(poison), ..)` after shufflevector's semantics update; relevant thread: D103874)

To do so, this patch

1. Updates `LowerAVXCONCAT_VECTORS` in X86ISelLowering.cpp to recognize `FREEZE(UNDEF)` operand of `CONCAT_VECTOR` in addition to `UNDEF`
2. Updates X86InstrVecCompiler.td to recognize `insert_subvector` of `FREEZE(UNDEF)` vector as its first operand.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D130339

2 years ago[mlir][LLVMIR] Clean up the definitions of ReturnOp/CallOp
Jeff Niu [Thu, 11 Aug 2022 04:34:02 +0000 (00:34 -0400)]
[mlir][LLVMIR] Clean up the definitions of ReturnOp/CallOp

2 years ago[msan] Extract SetAllocaOrigin
Vitaly Buka [Thu, 11 Aug 2022 03:53:02 +0000 (20:53 -0700)]
[msan] Extract SetAllocaOrigin

2 years ago[msan] Another try for powerpc fix after D131205
Vitaly Buka [Thu, 11 Aug 2022 03:38:55 +0000 (20:38 -0700)]
[msan] Another try for powerpc fix after D131205

2 years ago[LoongArch] Override TargetLowering::isOffsetFoldingLegal()
wanglei [Thu, 11 Aug 2022 02:50:11 +0000 (10:50 +0800)]
[LoongArch] Override TargetLowering::isOffsetFoldingLegal()

This patch disable GlobalAddress+Offset folding.

Differential Revision: https://reviews.llvm.org/D131491

2 years ago[RISCV] Add cost model for mask vector extend and truncate instruction.
jacquesguan [Wed, 10 Aug 2022 09:24:55 +0000 (17:24 +0800)]
[RISCV] Add cost model for mask vector extend and truncate instruction.

As extending from or truncating to mask vector do not use the same instructions as the normal cast, this path changed it to 2 which is the number of instructions we used.

Differential Revision: https://reviews.llvm.org/D131552

2 years ago[LoongArch] Define the new-style reloc types
WANG Xuerui [Thu, 11 Aug 2022 02:21:29 +0000 (10:21 +0800)]
[LoongArch] Define the new-style reloc types

Differential Revision: https://reviews.llvm.org/D131467

2 years ago[clang-format] git-clang-format --staged should format the index
Gergely Meszaros [Thu, 11 Aug 2022 02:29:58 +0000 (19:29 -0700)]
[clang-format] git-clang-format --staged should format the index

When --staged (or --cached) use the index for formatting as well, not just
for the line numbers to format. Without this change git-clang-format gets
the changed line numbers based on the index, but then formats these lines on
the working tree version of the file.

This is a problem when the working tree and index differ. One common case
would be (and is the motivation behind this patch) when applying the
suggested changes git-clang-format --staged, then forgetting to add the
applied changes. When git-clang-format --staged --diff is used in a
pre-commit hook in this scenario, then the hook would allow committing the
improperly formatted changes, as the file is correctly formatted in the work
tree.

Fixes #56797.

Differential Revision: https://reviews.llvm.org/D130108

2 years ago[msan] Try to fix powerpc after D131205
Vitaly Buka [Thu, 11 Aug 2022 02:28:20 +0000 (19:28 -0700)]
[msan] Try to fix powerpc after D131205

2 years ago[LoongArch] Add insn aliases `jr` and `ret`
WANG Xuerui [Thu, 11 Aug 2022 01:42:07 +0000 (09:42 +0800)]
[LoongArch] Add insn aliases `jr` and `ret`

Differential Revision: https://reviews.llvm.org/D131512

2 years ago[compiler-rt][BF16] Provide __truncdfbf2 and __truncsfbf2 only when __bf16 is available
Phoebe Wang [Wed, 10 Aug 2022 01:13:27 +0000 (09:13 +0800)]
[compiler-rt][BF16] Provide __truncdfbf2 and __truncsfbf2 only when __bf16 is available

Differential Revision: https://reviews.llvm.org/D131147

2 years ago[MLIR][NFC] Refactor affine analysis helpers
Uday Bondhugula [Tue, 9 Aug 2022 12:05:09 +0000 (17:35 +0530)]
[MLIR][NFC] Refactor affine analysis helpers

Refactor affine analysis helpers: the existing ones were using
unnecessary or improperly named arguments. NFC.

Differential Revision: https://reviews.llvm.org/D131557

2 years ago[LoongArch] Add codegen support for bitreverse
WANG Xuerui [Thu, 11 Aug 2022 00:50:50 +0000 (08:50 +0800)]
[LoongArch] Add codegen support for bitreverse

Differential Revision: https://reviews.llvm.org/D131378

2 years ago[MLIR] Add missing check for unsupported affine dependence analysis
Uday Bondhugula [Thu, 11 Aug 2022 00:03:23 +0000 (05:33 +0530)]
[MLIR] Add missing check for unsupported affine dependence analysis

Add missing check in affine dependence analysis when dependence analysis
isn't possible due to the ops being in different affine scopes.  The
lack of such a check could lead to a crash or incorrect behavior in
several dependent utilities.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131556

2 years ago[MLIR] Fix build breakage due to 5c5af910fefbea943a11452b63e2424e5f823470
Uday Bondhugula [Thu, 11 Aug 2022 00:26:17 +0000 (05:56 +0530)]
[MLIR] Fix build breakage due to 5c5af910fefbea943a11452b63e2424e5f823470

Fix build breakage due to 5c5af910fefbea943a11452b63e2424e5f823470.

```commit 5c5af910fefbea943a11452b63e2424e5f823470
Author: Jeff Niu <jeff@modular.com>
Date:   Tue Aug 9 22:07:35 2022 -0400

    [mlir][LLVMIR] "Modernize" Insert/ExtractValueOp ```

results in

```lib/Conversion/LLVMCommon/MemRefBuilder.cpp:170:70: error: call of overloaded ‘makeArrayRef<int64_t>(<brace-enclosed initializer list>)’ is ambiguous
       llvm::makeArrayRef<int64_t>({kStridePosInMemRefDescriptor,
       pos}));

llvm/include/llvm/ADT/ArrayRef.h:505:15: note: candidate: ‘llvm::ArrayRef<T> llvm::makeArrayRef(const std::vector<T>&) [with T = long int]’
   ArrayRef<T> makeArrayRef(const std::vector<T> &Vec) {
               ^~~~~~~~~~~~
llvm/include/llvm/ADT/ArrayRef.h:516:37: note: candidate: ‘llvm::ArrayRef<T> llvm::makeArrayRef(const llvm::ArrayRef<T>&) [with T = long int]’
   template <typename T> ArrayRef<T> makeArrayRef(const ArrayRef<T> &Vec) {
                                                                      ^

Differential Revision: https://reviews.llvm.org/D131637

2 years ago[lld-macho] Add support for objc_msgSend stubs
Keith Smiley [Fri, 17 Jun 2022 04:35:18 +0000 (21:35 -0700)]
[lld-macho] Add support for objc_msgSend stubs

Apple Clang in Xcode 14 introduced a new feature for reducing the
overhead of objc_msgSend calls by deduplicating the setup calls for each
individual selector. This works by clang adding undefined symbols for
each selector called in a translation unit, such as `_objc_msgSend$foo`
for calling the `foo` method on any `NSObject`. There are 2
different modes for this behavior, the default directly does the setup
for `_objc_msgSend` and calls it, and the smaller option does the
selector setup, and then calls the standard `_objc_msgSend` stub
function.

The general overview of how this works is:

- Undefined symbols with the given prefix are collected
- The suffix of each matching undefined symbol is added as a string to
  `__objc_methname`
- A pointer is added for every method name in the `__objc_selrefs`
  section
- A `got` entry is emitted for `_objc_msgSend`
- Stubs are emitting pointing to the synthesized locations

Notes:

- Both `__objc_methname` and `__objc_selrefs` can also exist from object
  files, so their contents are merged with our synthesized contents
- The compiler emits method names for defined methods, but not for
  undefined symbols you call, but stubs are used for both
- This only implements the default "fast" mode currently just to reduce
  the diff, I also doubt many folks will care to swap modes
- This only implements this for arm64 and x86_64, we don't need to
  implement this for 32 bit iOS archs, but we should implement it for
  watchOS archs in a later diff

Differential Revision: https://reviews.llvm.org/D128108

2 years ago[test][sanitizer] Fix REQUIRES of the test
Vitaly Buka [Wed, 10 Aug 2022 23:58:47 +0000 (16:58 -0700)]
[test][sanitizer] Fix REQUIRES of the test

getnetent is availible from API 28

2 years ago[test][sanitizer] Switch test to a different group
Vitaly Buka [Wed, 10 Aug 2022 23:51:57 +0000 (16:51 -0700)]
[test][sanitizer] Switch test to a different group

2 years agolldb: Disable unittests if llvm_gtest target does not exist
Tom Stellard [Wed, 10 Aug 2022 23:56:05 +0000 (16:56 -0700)]
lldb: Disable unittests if llvm_gtest target does not exist

This fixes the stand-alone build configuration where LLVM_MAIN_SRC_DIR
does not exist.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D124314

2 years ago[flang] Support DOT_PRODUCT in late inlining.
Slava Zakharin [Wed, 10 Aug 2022 03:11:48 +0000 (20:11 -0700)]
[flang] Support DOT_PRODUCT in late inlining.

This change inlines DOT_PRODUCT calls for real and integer types.

Differential Revision: https://reviews.llvm.org/D131538

2 years ago[test][sanitizer] Change exit code to debug llvm-avr-linux
Vitaly Buka [Wed, 10 Aug 2022 23:28:59 +0000 (16:28 -0700)]
[test][sanitizer] Change exit code to debug llvm-avr-linux

2 years ago[lldb/crashlog] Add `-V|--version` option
Med Ismail Bennani [Wed, 10 Aug 2022 23:17:19 +0000 (16:17 -0700)]
[lldb/crashlog] Add `-V|--version` option

This patch introduces a new option to the crashlog command to get the
the script version.

Since `crashlog.py` is not actually versioned, this returns lldb's
version instead.

rdar://98392669

Differential Revision: https://reviews.llvm.org/D131542

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[test][sanitizer] Fix REQUIRES in few tests
Vitaly Buka [Wed, 10 Aug 2022 23:11:51 +0000 (16:11 -0700)]
[test][sanitizer] Fix REQUIRES in few tests

2 years ago[mlir][sparse][bf16] disable two bf16 tests
Aart Bik [Wed, 10 Aug 2022 21:38:01 +0000 (14:38 -0700)]
[mlir][sparse][bf16] disable two bf16 tests

Supposedly our ABI issues were fixed, per issue:
https://github.com/llvm/llvm-project/issues/55992

However, with a recent changes to bf16, these tests
fail again; not sure why yet:
https://reviews.llvm.org/D130832
https://lab.llvm.org/buildbot/#/builders/61/builds/30600

So we disable the tests for now. Issue is tracked in:
https://github.com/llvm/llvm-project/issues/57042

Differential Revision: https://reviews.llvm.org/D131621

2 years ago[test][sanitizer] Fix getgrouplist test
Vitaly Buka [Wed, 10 Aug 2022 22:48:21 +0000 (15:48 -0700)]
[test][sanitizer] Fix getgrouplist test

2 years agoRemove function name from sanitize-memory-track-origins binary.
Kevin Athey [Wed, 10 Aug 2022 18:18:32 +0000 (11:18 -0700)]
Remove function name from sanitize-memory-track-origins binary.

This work is being done to reduce the size of MSAN with track origins binary.

Builds upon: https://reviews.llvm.org/D131205

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131415

2 years ago[clang][deps] NFC: Move dependency consumer into header file
Jan Svoboda [Wed, 10 Aug 2022 22:24:32 +0000 (15:24 -0700)]
[clang][deps] NFC: Move dependency consumer into header file

2 years ago[LLDB][NFC] Clean up dead code
Slava Gurevich [Wed, 10 Aug 2022 19:52:09 +0000 (12:52 -0700)]
[LLDB][NFC] Clean up dead code

Remove unreachable code that will never execute.

Differential Revision: https://reviews.llvm.org/D131613

2 years ago[LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp
Slava Gurevich [Wed, 10 Aug 2022 09:48:51 +0000 (02:48 -0700)]
[LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp

Static code inspection guided fixes for the following issues:
- dead code
- buffer not null-terminated
- null-dereference
- out-of-bounds access

Differential Revision: https://reviews.llvm.org/D131554

2 years ago[libc] move to combined integer converter
Michael Jones [Fri, 5 Aug 2022 21:51:10 +0000 (14:51 -0700)]
[libc] move to combined integer converter

The functions converting integers into decimal, hexadecimal, and octal,
are all very similar. This patch moves to a combined converter to save
code size.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D131302

2 years ago[libc][NFC] add arrow operator to optional
Michael Jones [Wed, 10 Aug 2022 18:58:04 +0000 (11:58 -0700)]
[libc][NFC] add arrow operator to optional

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D131610

2 years ago[libc++] Reorganize the documentation of extensions for integral types
Louis Dionne [Wed, 10 Aug 2022 21:34:45 +0000 (17:34 -0400)]
[libc++] Reorganize the documentation of extensions for integral types

2 years agoRevert "[clang][dataflow] Store DeclContext of block being analysed in Environment...
Evgenii Stepanov [Wed, 10 Aug 2022 21:20:57 +0000 (14:20 -0700)]
Revert "[clang][dataflow] Store DeclContext of block being analysed in Environment if available."

Use of uninitialized memory.
https://lab.llvm.org/buildbot/#/builders/74/builds/12713

This reverts commit 8a4c40bfe8e6605ffc9d866f8620618dfdde2875.

2 years agoRevert "[clang][dataflow] Analyze constructor bodies"
Evgenii Stepanov [Wed, 10 Aug 2022 21:20:49 +0000 (14:20 -0700)]
Revert "[clang][dataflow] Analyze constructor bodies"

https://lab.llvm.org/buildbot/#/builders/74/builds/12713

This reverts commit 000c8fef86abb7f056cbea2de99f21dca4b81bf8.

2 years agoRevert "[clang][dataflow] Don't crash when caller args are missing storage locations"
Evgenii Stepanov [Wed, 10 Aug 2022 21:20:41 +0000 (14:20 -0700)]
Revert "[clang][dataflow] Don't crash when caller args are missing storage locations"

https://lab.llvm.org/buildbot/#/builders/74/builds/12713

This reverts commit 43b298ea1282f29d448fc0f6ca971bc5fa698355.

2 years ago[Attributor][FIX] Visit same instructions with different scopes
Johannes Doerfert [Wed, 10 Aug 2022 17:33:17 +0000 (12:33 -0500)]
[Attributor][FIX] Visit same instructions with different scopes

If we collect potential values we need to visit a value even if we have
seen it before if the scope is different. The scope is part of the
result after all. Test included.

Fixes https://github.com/llvm/llvm-project/issues/56753

Differential Revision: https://reviews.llvm.org/D131597

2 years ago[lld/elf] Use C++17 nested namespace syntax in most places
Nico Weber [Wed, 10 Aug 2022 19:31:58 +0000 (15:31 -0400)]
[lld/elf] Use C++17 nested namespace syntax in most places

Like D131405, but for ELF.

No behavior change.

Differential Revision: https://reviews.llvm.org/D131612

2 years ago[flang] Add semantics test for event_query subroutine
Naje George [Thu, 4 Aug 2022 22:12:48 +0000 (15:12 -0700)]
[flang] Add semantics test for event_query subroutine

Reviewed By: ktras

Differential Revision: https://reviews.llvm.org/D131211

2 years ago[InstCombine] Tighten up known library function signature tests (PR #56463)
Martin Sebor [Mon, 18 Jul 2022 17:47:12 +0000 (11:47 -0600)]
[InstCombine] Tighten up known library function signature tests (PR #56463)

Replace a switch statement used to validate arguments to known library
functions with a more consistent table-driven approach and tighten it
up.

2 years ago[libc][NFC] clean int to string static templates
Michael Jones [Wed, 10 Aug 2022 18:58:36 +0000 (11:58 -0700)]
[libc][NFC] clean int to string static templates

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D131611

2 years ago[clang] Require strict matches for defines for PCH in GCC style directories
Martin Storsjö [Wed, 25 May 2022 12:07:18 +0000 (15:07 +0300)]
[clang] Require strict matches for defines for PCH in GCC style directories

When clang includes a PCH, it tolerates some amount of differences
between the defines used when creating and when including the PCH
- this seems to be intentionally allowed in
c379c072405f39bca1d3552408fc0427328e8b6d (and later extended in
b63687519610a73dd565be1fec28332211b4df5b).

When using a PCH (or when picking a PCH out of a directory containing
multiple candidates) Clang used to accept the header if there were
defines on the command line when creating the PCH that are missing
when using the PCH, or vice versa, defines only set when using the
PCH.

The only cases where Clang explicitly rejected the use of a PCH
is if there was an explicit conflict between the options, e.g.
-DFOO=1 vs -DFOO=2, or -DFOO vs -UFOO.

The latter commit added a FIXME that we really should check whether
mismatched defines actually were used somewhere in the PCH, so that
the define would affect the outcome. This FIXME has stood unaddressed
since 2012.

This differs from GCC, which rejects PCH files if the defines differ
at all.

When explicitly including a single PCH file, the relaxed policy
of allowing minor differences is harmless for correct use cases
(but may fail to diagnose mismtaches), and potentially allow using
PCHs in wider cases (where the user intentionally know that the
differences in defines are harmless for the PCH).

However, for GCC style PCH directories, with a directory containing
multiple PCH variants and the compiler should pick the correct match
out of them, Clang's relaxed logic was problematic. The directory
could contain two otherwise identical PCHs, but one built with -DFOO
and one without. When attempting to include a PCH and iterating over
the candidates in the directory, Clang would essentially pick the
first one out of the two, even if there existed a better, exact
match in the directory.

Keep the relaxed checking when specificlly including one named
PCH file, but require strict matches when trying to pick the right
candidate out of a GCC style directory with alternatives.

This fixes https://github.com/lhmouse/mcfgthread/issues/63.

Differential Revision: https://reviews.llvm.org/D126676

2 years ago[mlir][ods] (NFC) split out erroring format tests
Jeff Niu [Wed, 10 Aug 2022 17:36:52 +0000 (13:36 -0400)]
[mlir][ods] (NFC) split out erroring format tests

2 years ago[EarlyCSE] allow flexibility in atan(-0.0) test
Sanjay Patel [Wed, 10 Aug 2022 19:01:09 +0000 (15:01 -0400)]
[EarlyCSE] allow flexibility in atan(-0.0) test

As discussed in the post-commit feedback for b53d44fe47413c87f619b,
this test was failing on AIX because atan(-0.0) results in 0.0 (positive).

Differential Revision: https://reviews.llvm.org/D131601

2 years ago[clang][deps] Always generate module paths
Jan Svoboda [Mon, 8 Aug 2022 18:08:09 +0000 (11:08 -0700)]
[clang][deps] Always generate module paths

Since D129389 (and downstream PR https://github.com/apple/llvm-project/pull/4965), the dependency scanner is responsible for generating full command-lines, including the modules paths. This patch removes the flag that was making this an opt-in behavior in clang-scan-deps.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D131420

2 years ago[libc++] Implement `thread::id` comparators as free functions
Adrian Vogelsgesang [Sun, 31 Jul 2022 23:12:42 +0000 (16:12 -0700)]
[libc++] Implement `thread::id` comparators as free functions

So far, the `thread::id` comparators were implemented as hidden friends.
This was non-conforming and lead to incorrectly rejected C++ code, as
can be seen in the linked Github issue.

Fixes https://github.com/llvm/llvm-project/issues/56187

Differential Revision: https://reviews.llvm.org/D131430

2 years agoRevert "[AMDGPU] SIFixSGPRCopies refactoring"
Evgenii Stepanov [Wed, 10 Aug 2022 18:31:23 +0000 (11:31 -0700)]
Revert "[AMDGPU] SIFixSGPRCopies refactoring"

Breaks ASan tests.

This reverts commit 3f8ae7efa866e581a16e9ccc8e29744722f13fff.

2 years ago[libc] add int to string for extended bases
Michael Jones [Thu, 4 Aug 2022 20:38:32 +0000 (13:38 -0700)]
[libc] add int to string for extended bases

The default IntegerToString class only supports base 10, this patch adds
a version which supports any base between 2 and 36 inclusive. This will
be used in an upcoming patch.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D131301

2 years ago[libc] Support StringView equality tests
Michael Jones [Fri, 5 Aug 2022 20:40:45 +0000 (13:40 -0700)]
[libc] Support StringView equality tests

Previously, the integer_to_string tests used EXPECT_TRUE(.equals)
which doesn't have useful error messages. Now they properly check
equality with the EXPECT_EQ macro, which allows for comparing the
strings more naturally.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D131300

2 years ago[Clang] Restrict non fixed enum to a value outside the range of the enumeration value...
Shafik Yaghmour [Wed, 10 Aug 2022 17:26:47 +0000 (10:26 -0700)]
[Clang] Restrict non fixed enum to a value outside the range of the enumeration values warning to context requiring a constant expression

In D131307 we allowed the diagnostic to be turned into a warning for a
transition period.

This had the side effect of triggering the warning in contexts not required to
be constant expression. This change will restrict the diagnostic to constant
expression contexts. This should reduce the fallout of this diagnostic.

Differential Revision: https://reviews.llvm.org/D131528

2 years agoDefault implicit function pointer conversions diagnostic to be an error
Aaron Ballman [Wed, 10 Aug 2022 17:52:33 +0000 (13:52 -0400)]
Default implicit function pointer conversions diagnostic to be an error

Implicitly converting between incompatible function pointers in C is
currently a default-on warning (it is an error in C++). However, this
is very poor security posture. A mismatch in parameters or return
types, or a mismatch in calling conventions, etc can lead to
exploitable security vulnerabilities. Rather than allow this unsafe
practice with a warning, this patch strengthens the warning to be an
error (while still allowing users the ability to disable the error or
the warning entirely to ease migration). Users should either ensure the
signatures are correctly compatible or they should use an explicit cast
if they believe that's more reasonable.

Differential Revision: https://reviews.llvm.org/D131351

2 years ago[ms] [llvm-ml] Handle OPTION PROLOGUE/EPILOGUE:NONE
Eric Astor [Wed, 10 Aug 2022 17:51:51 +0000 (17:51 +0000)]
[ms] [llvm-ml] Handle OPTION PROLOGUE/EPILOGUE:NONE

Since we don't yet implement PROC's PROLOGUE and EPILOGUE support, we can safely ignore the option that disables them.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D131524

2 years ago[NFC][Clang] make AtomicConstraint::ParameterMapping const
Yuanfang Chen [Wed, 10 Aug 2022 17:47:17 +0000 (10:47 -0700)]
[NFC][Clang] make AtomicConstraint::ParameterMapping const

It was not const due to the way it is initialized. This is needed for
a following patch.

2 years ago[clang][dataflow] Don't crash when caller args are missing storage locations
Sam Estep [Wed, 10 Aug 2022 17:50:14 +0000 (17:50 +0000)]
[clang][dataflow] Don't crash when caller args are missing storage locations

This patch modifies `Environment`'s `pushCall` method to pass over arguments that are missing storage locations, instead of crashing.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D131600

2 years ago[mlir][spirv] Turn various passes to plain OperationPass
jackalcooper [Wed, 10 Aug 2022 17:45:40 +0000 (13:45 -0400)]
[mlir][spirv] Turn various passes to plain OperationPass

Made passes converting ops from other dialects to spirv OperationPass,
so that downstream compiler could put them in a proper nested pass
manager to lower device code only.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131591

2 years agoAdd docs for function attributes hot/cold
Ofek Shilon [Wed, 10 Aug 2022 17:48:43 +0000 (13:48 -0400)]
Add docs for function attributes hot/cold

Following https://reviews.llvm.org/D92493, this add docs for the hot
and cold function attributes.

Differential Revision: https://reviews.llvm.org/D130933

2 years ago[libc++] Fixes string_view comparison operators.
Mark de Wever [Sat, 6 Aug 2022 12:27:46 +0000 (14:27 +0200)]
[libc++] Fixes string_view comparison operators.

While implementing `operator<=>` for `string_view` (D130295) @philnik
pointed out `common_type` should be `type_identity`. Since it was an
existing issue that wasn't addressed.

This addresses the issue for both the new and existing equality and
comparison operators. The test is based on the example posted in
D130295.

Reviewed By: philnik, #libc, huixie90

Differential Revision: https://reviews.llvm.org/D131322

2 years ago[AMDGPU] Fix prologue/epilogue markers in .debug_line table for trivial functions
Venkata Ramanaiah Nalamothu [Tue, 9 Aug 2022 11:19:09 +0000 (16:49 +0530)]
[AMDGPU] Fix prologue/epilogue markers in .debug_line table for trivial functions

All the prologue instructions should have unknown source location
co-ordinates while the epilogue instructions should have source
location of last non-debug instruction after which epilogue
instructions are insrted.

This ensures the prologue/epilogue markers are generated correctly
in the line table.

Changes are brought in from the downstream CFI patches.

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D131485

2 years ago[MC] Avoid calling vector<FieldInfo> members before FieldInfo is defined
Ilya Biryukov [Wed, 10 Aug 2022 17:19:20 +0000 (19:19 +0200)]
[MC] Avoid calling vector<FieldInfo> members before FieldInfo is defined

The C++ Standard requires a complete type T when using any members of
`vector<T>`, see
https://eel.is/c++draft/vector#overview-4.

This only breaks with latest libc++ in C++20 mode and does not show up
in common configurations.
We have an internal experimental configuration that discovered this.

Reviewed By: alexfh

Differential Revision: https://reviews.llvm.org/D131595

2 years ago[mlir][math] Added basic support for IPowI operation.
Slava Zakharin [Fri, 22 Jul 2022 18:44:44 +0000 (11:44 -0700)]
[mlir][math] Added basic support for IPowI operation.

The operation computes pow(b, p), where 'b' and 'p' are signed integers
of the same width. The result's type matches the operands' type.

Differential Revision: https://reviews.llvm.org/D129809

2 years ago[NFC][libc++][test] Removes unneeded code.
Mark de Wever [Mon, 8 Aug 2022 17:53:31 +0000 (19:53 +0200)]
[NFC][libc++][test] Removes unneeded code.

In D130295 @mumbleskates wondered why `std::strong_ordering::equal` had
special code since it's the same as `std::strong_ordering::equivalent`.

This is indeed the case so the special case can be removed.

Reviewed By: mumbleskates, #libc, avogelsgesang, ldionne

Differential Revision: https://reviews.llvm.org/D131419

2 years ago[MCParser] Fix a warning
Kazu Hirata [Wed, 10 Aug 2022 16:56:44 +0000 (09:56 -0700)]
[MCParser] Fix a warning

This patch fixes:

  llvm/lib/MC/MCParser/COFFMasmParser.cpp:333:28: error: comparison of
  integers of different signs: 'unsigned int' and 'int'
  [-Werror,-Wsign-compare]

2 years ago[CostModel] Update RUN -passes=* to double quotes to appease update scripts on windows
Simon Pilgrim [Wed, 10 Aug 2022 16:53:51 +0000 (17:53 +0100)]
[CostModel] Update RUN -passes=* to double quotes to appease update scripts on windows

DOS really doesn't like `` quotes to be used in command lines

Some prep work as I'm intending to resurrect D79483 soon

2 years ago[analyzer] [NFC] Add more test cases for equality tracking
Denys Petrov [Tue, 9 Aug 2022 18:18:34 +0000 (21:18 +0300)]
[analyzer] [NFC] Add more test cases for equality tracking

Summary: Cover `ConstraintAssignor::assign(EquivalenceClass, RangeSet)` function with more regression tests.

Differential Revision: https://reviews.llvm.org/D131514

2 years ago[mlir][LLVMIR] "Modernize" Insert/ExtractValueOp
Jeff Niu [Wed, 10 Aug 2022 02:07:35 +0000 (22:07 -0400)]
[mlir][LLVMIR] "Modernize" Insert/ExtractValueOp

This patch "modernizes" the LLVM `insertvalue` and `extractvalue`
operations to use DenseI64ArrayAttr, since they only require an array of
indices and previously there was confusion about whether to use i32 or
i64 arrays, and to use assembly format.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131537

2 years ago[NFC] Restructured SimplifyIntrinsicsPass::getOrCreateFunction.
Slava Zakharin [Tue, 9 Aug 2022 23:37:44 +0000 (16:37 -0700)]
[NFC] Restructured SimplifyIntrinsicsPass::getOrCreateFunction.

I would like to add DOT_PRODUCT support in this pass, so this restructuring
is the first step to allow some code reuse inside getOrCreateFunction().

Differential Revision: https://reviews.llvm.org/D131530

2 years ago[Analysis] Remove unused CostModelAnalysis::getInstructionCost helper. NFCI.
Simon Pilgrim [Wed, 10 Aug 2022 16:20:58 +0000 (17:20 +0100)]
[Analysis] Remove unused CostModelAnalysis::getInstructionCost helper. NFCI.

Everything now uses TTI costs calls directly