platform/upstream/llvm.git
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

2 years agoDriver: Refactor and support per target dirs in baremetal
Manoj Gupta [Wed, 10 Aug 2022 04:17:05 +0000 (21:17 -0700)]
Driver: Refactor and support per target dirs in baremetal

Refactor baremetal driver code to reduce the bespoke
additions and base class overrides.
This lets us use the per target runtimes like other clang
targets. E.g. clang -target armv7m-cros-none-eabi will now
be able to use the runtimes installed at
<resource_dir>/lib/armv7m-cros-none-eabi instead of the hardcoded
path <resource_dir>/lib/baremetal.
The older code paths should still continue to work as before if
<resource_dir>/lib/<tuple> does not exist.

Reviewed By: MaskRay, barannikov88

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

2 years agoDesist from passing function location to __msan_set_alloca_origin4.
Kevin Athey [Fri, 5 Aug 2022 23:50:45 +0000 (16:50 -0700)]
Desist from passing function location to __msan_set_alloca_origin4.

This is done by calling __msan_set_alloca_origin and providing the location of the variable by using the call stack.
This is prepatory work for dropping variable names when track-origins is enabled.

Reviewed By: vitalybuka

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

2 years ago[ms] [llvm-ml] Add support for the (many) optional SEGMENT parameters
Eric Astor [Wed, 10 Aug 2022 15:55:14 +0000 (15:55 +0000)]
[ms] [llvm-ml] Add support for the (many) optional SEGMENT parameters

Add support for many parameters to the SEGMENT directive

Reviewed By: thakis

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

2 years ago[mlir] Fix win build by using has_value() instead of hasValue() for Optional.
Alexander Belyaev [Wed, 10 Aug 2022 15:48:35 +0000 (17:48 +0200)]
[mlir] Fix win build by using has_value() instead of hasValue() for Optional.

2 years ago[clang] SourceManager: fix at SourceManager::getFileIDLoaded for the case of invalid...
Ivan Murashko [Wed, 10 Aug 2022 15:36:19 +0000 (16:36 +0100)]
[clang] SourceManager: fix at SourceManager::getFileIDLoaded for the case of invalid SLockEntry

There is a fix for the search procedure at `SourceManager::getFileIDLoaded`. It might return an invalid (not loaded) entry. That might cause clang/clangd crashes. At my case the scenario was the following:
- `SourceManager::getFileIDLoaded` returned an invalid file id for a non loaded entry and incorrectly set `SourceManager::LastFileIDLookup` to the value
- `getSLocEntry` returned `SourceManager::FakeSLocEntryForRecovery` introduced at [D89748](https://reviews.llvm.org/D89748).
- The result entry is not tested at `SourceManager::isOffsetInFileID`and as result the call `return SLocOffset < getSLocEntryByID(FID.ID+1).getOffset();` returned `true` value because `FID.ID+1` pointed to a non-fake entry
- The tested offset was marked as one that belonged to the fake `SLockEntry`

Such behaviour might cause a weird clangd crash when preamble contains some header files that were removed just after the preamble created. Unfortunately it's not so easy to reproduce the crash in the form of a LIT test thus I provided the fix only.

Test Plan:
```
ninja check-clang
```

Reviewed By: aaron.ballman

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

2 years ago[libc++] Add missing includes of <cstddef>
Louis Dionne [Wed, 10 Aug 2022 15:34:31 +0000 (11:34 -0400)]
[libc++] Add missing includes of <cstddef>

2 years ago[PowerPC] Don't use the S30 and S31 regs for the pic code
Umesh Kalappa [Wed, 10 Aug 2022 15:29:25 +0000 (10:29 -0500)]
[PowerPC] Don't use the S30 and S31 regs for the pic code

These changes to address issue
https://github.com/llvm/llvm-project/issues/55857.

Since R30/S30 is used as pointer (32 bits) for GOT Table in the ppc32 ABI,
remove it from the SPE callee save register when PIC is enabled.

This prevents emitting the SPE load and store for S30 and S31 regs.

Differential revision: https://reviews.llvm.org/D127495

2 years ago[Libomptarget][CUDA] Check CUDA compatibilty correctly
Joseph Huber [Wed, 10 Aug 2022 13:57:17 +0000 (09:57 -0400)]
[Libomptarget][CUDA] Check CUDA compatibilty correctly

We recently added support for multi-architecture binaries in
libomptarget. This is done by extracting the architecture from the
embedded image and comparing it with the major and minor version
supported by the current CUDA installation. Previously we just compared
these directly, which was not correct for binary compatibility. The CUDA
documentation states that we can consider any image with an equivalent
major or a greater or equal to minor compatible with the current image.
Change the check to use this new logic in the CUDA plugin.

Fixes #57049

Reviewed By: jdoerfert, ye-luo

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

2 years ago[X86] (0 - SetCC) | C -> (zext (not SetCC)) * (C + 1) - 1 if we can get a LEA out...
Amaury Séchet [Sun, 7 Aug 2022 03:03:50 +0000 (03:03 +0000)]
[X86] (0 - SetCC) | C -> (zext (not SetCC)) * (C + 1) - 1 if we can get a LEA out of it.

This adresses various regression in D131260 , as well as is a useful optimization in itself.

Reviewed By: RKSimon

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

2 years agoPowerPC: Don't hoist float multiply + add to fused operation on SPE
Justin Hibbits [Mon, 6 Apr 2020 15:08:02 +0000 (10:08 -0500)]
PowerPC: Don't hoist float multiply + add to fused operation on SPE

SPE doesn't have a fmadd instruction, so don't bother hoisting a
multiply and add sequence to this, as it'd become just a library call.
Hoisting happens too late for the CTR usability test to veto using the
CTR in a loop, and results in an assert "Invalid PPC CTR loop!".

2 years ago[ConstantFolding] Eliminate atan and atan2 calls
Mohammed Nurul Hoque [Wed, 10 Aug 2022 14:59:23 +0000 (10:59 -0400)]
[ConstantFolding] Eliminate atan and atan2 calls

From the opengroup specifications, atan2 may fail if the result
underflows and atan may fail if the argument is subnormal, but
we assume that does not happen and eliminate the calls if we
can constant fold the result at compile-time.

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

2 years ago[libc++] Make __libcpp_verbose_abort [[noreturn]]
Louis Dionne [Mon, 8 Aug 2022 15:53:34 +0000 (11:53 -0400)]
[libc++] Make __libcpp_verbose_abort [[noreturn]]

This will allow using it in functions that are [[noreturn]] themselves.

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

2 years agoRevert rGa772f775a2ba401e95a0bbe73deb6300f1dc12c0 "[clang-tidy] Support C++14 in...
Simon Pilgrim [Wed, 10 Aug 2022 14:25:04 +0000 (15:25 +0100)]
Revert rGa772f775a2ba401e95a0bbe73deb6300f1dc12c0 "[clang-tidy] Support C++14 in bugprone-signal-handler."

This was breaking a number of buildbots: https://lab.llvm.org/buildbot/#/builders/139/builds/26335

2 years ago[clang] Correct documentation for NEON and SVE operator support
David Truby [Wed, 10 Aug 2022 14:02:55 +0000 (15:02 +0100)]
[clang] Correct documentation for NEON and SVE operator support

Previously the language extension documentation didn't mention SVE and
was incomplete in listing the C/C++ operators supported on NEON. This
corrects the documentation to be in line with the implementation.

2 years ago[X86] Use DAG.getFreeze() to create freeze node. NFC.
Simon Pilgrim [Wed, 10 Aug 2022 13:35:50 +0000 (14:35 +0100)]
[X86] Use DAG.getFreeze() to create freeze node. NFC.

2 years ago[clang][dataflow] Analyze constructor bodies
Sam Estep [Wed, 10 Aug 2022 14:01:18 +0000 (14:01 +0000)]
[clang][dataflow] Analyze constructor bodies

This patch adds the ability to context-sensitively analyze constructor bodies, by changing `pushCall` to allow both `CallExpr` and `CXXConstructExpr`, and extracting the main context-sensitive logic out of `VisitCallExpr` into a new `transferInlineCall` method which is now also called at the end of `VisitCXXConstructExpr`.

Reviewed By: ymandel, sgatev, xazax.hun

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

2 years ago[mlir] Extract offsets-sizes-strides computation from `makeTiledShape(s)`.
Alexander Belyaev [Wed, 10 Aug 2022 13:26:49 +0000 (15:26 +0200)]
[mlir] Extract offsets-sizes-strides computation from `makeTiledShape(s)`.

This change separates computation of the actual parameters of the subset and
the materialization of subview/extract_slice. That way the users can still use
Linalg tiling logic even if they use different operations to materialize the
subsets.

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

2 years ago[LLDB] Add basic floating point ops to IR interpreter
Pavel Kosov [Wed, 10 Aug 2022 13:34:52 +0000 (16:34 +0300)]
[LLDB] Add basic floating point ops to IR interpreter

Patch adds support for fadd, fsub, fdiv, fmul and fcmp to IR interpreter.

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Reviewed By: clayborg

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

2 years ago[AIX][tests] XFAIL for system-aix instead
Jake Egan [Wed, 10 Aug 2022 13:31:04 +0000 (09:31 -0400)]
[AIX][tests] XFAIL for system-aix instead

The Clang folding for floating-point sometimes calls out to the host.

2 years ago[mlir] Generate C++ doc comments for interfaces
Alex Zinenko [Wed, 10 Aug 2022 13:11:26 +0000 (15:11 +0200)]
[mlir] Generate C++ doc comments for interfaces

When emitting the declarations for interface methods defined in ODS,
also emit their descriptions as C++ comments. This makes the
documentation accessible to C++ tooling such as IDEs that offers better
usability than reading it form the .td or the website.

Reviewed By: jpienaar

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

2 years agoMigrate llvm.experimental.patchpoint() to ptr.
Edd Barrett [Wed, 10 Aug 2022 12:13:28 +0000 (13:13 +0100)]
Migrate llvm.experimental.patchpoint() to ptr.

This intrinsic used a typed pointer for a call target operand. This
change updates the operand to be an opaque pointer and updates all
pointers in all test files that use the intrinsic.

Differential revision: https://reviews.llvm.org/D131261

2 years ago[DAG] visitFREEZE - generalize freeze(op()) -> op(freeze()) to any number of operands
Simon Pilgrim [Wed, 10 Aug 2022 12:12:04 +0000 (13:12 +0100)]
[DAG] visitFREEZE - generalize freeze(op()) -> op(freeze()) to any number of operands

canCreateUndefOrPoison currently only handles unary ops, but we intend to change that soon - this more closely matches the pushFreezeToPreventPoisonFromPropagating behaviour where the freeze is pushed up to a single operand value, as long as all others are guaranteed not to be poison/undef.

However, pushFreezeToPreventPoisonFromPropagating would freeze all uses of the value - whilst this variant requires the frozen value to be only used in the op - we can look at generalize multiple uses later if the need arises.

2 years ago[mlir][shape] Update meet to handle all size & shape types
Jacques Pienaar [Wed, 10 Aug 2022 12:08:24 +0000 (05:08 -0700)]
[mlir][shape] Update meet to handle all size & shape types

Also tighten up return type inference & compatibility functions.

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

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][AArch64][SVE] Add unary +/- operators for SVE types
David Truby [Tue, 2 Aug 2022 11:54:05 +0000 (11:54 +0000)]
[clang][AArch64][SVE] Add unary +/- operators for SVE types

This patch enables the unary promotion and negation operators on
SVE types.

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

2 years ago[DAG] canCreateUndefOrPoison - add freeze(truncate(x)) -> truncate(freeze(x)) support
Simon Pilgrim [Wed, 10 Aug 2022 10:27:08 +0000 (11:27 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(truncate(x)) -> truncate(freeze(x)) support

2 years ago[LLDB][AArch64][NFC] Fix some clang-format annotations
David Spickett [Wed, 10 Aug 2022 10:20:15 +0000 (10:20 +0000)]
[LLDB][AArch64][NFC] Fix some clang-format annotations

We don't want the DEFINE_ macros or the array registers
being clang formatted.

RegisterInfos_arm64.h was missing the off annotation and
RegisterInfos_arm64_sve.h needed the off moving to before
the macro definitions.

2 years ago[AArch64][SVE] Use SVE for VLS fcopysign for wide vectors
David Truby [Thu, 4 Aug 2022 12:40:12 +0000 (12:40 +0000)]
[AArch64][SVE] Use SVE for VLS fcopysign for wide vectors

Currently fcopysign for VLS vectors lowers through NEON even when the
vector width is wider than a NEON vector, causing bad codegen as the
vectors are split. This patch causes SVE to be used for these vectors
instead, giving much better codegen on wide VLS vectors.

Reviewed By: paulwalker-arm

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

2 years ago[clang-tidy] Support C++14 in bugprone-signal-handler.
Balázs Kéri [Wed, 10 Aug 2022 09:07:38 +0000 (11:07 +0200)]
[clang-tidy] Support C++14 in bugprone-signal-handler.

Check `bugprone-signal-handler` is improved to check for
C++-specific constructs in signal handlers. This check is
valid until C++17.

Reviewed By: whisperity

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

2 years ago[RISCV] Implement isUsedByReturnOnly TargetLowering hook in order to tailcall more...
Alex Bradbury [Wed, 10 Aug 2022 09:50:29 +0000 (10:50 +0100)]
[RISCV] Implement isUsedByReturnOnly TargetLowering hook in order to tailcall more libcalls

Prior to this patch, libcalls inserted by the SelectionDAG legalizer
could never be tailcalled. The eligibility of libcalls for tail calling
is is partly determined by checking TargetLowering::isInTailCallPosition
and comparing the return type of the libcall and the calleer.
isInTailCallPosition in turn calls TargetLowering::isUsedByReturnOnly
(which always returns false if not implemented by the target).

This patch provides a minimal implementation of
TargetLowering::isUsedByReturnOnly - enough to support tail calling
libcalls on hard float ABIs. Soft-float ABIs are left for a follow on
patch. libcall-tail-calls.ll also shows missed opportunities to tail
call integer libcalls, but this is due to issues outside of
the isUsedByReturnOnly hook.

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

2 years agoRevert "[Flang] Use find_program() to find clang-tblgen"
Nikita Popov [Wed, 10 Aug 2022 09:38:41 +0000 (11:38 +0200)]
Revert "[Flang] Use find_program() to find clang-tblgen"

This reverts commit 3bba12a81e242359580fa322cf1a9a0a43b461e6.

While this fixes doc generation in standalone flang builds, it
breaks them for combined builds of clang and flang.

2 years ago[X86][NFCI] Remove target-specific branch optimisation that's handled in BranchFolding
Alex Bradbury [Wed, 10 Aug 2022 09:35:31 +0000 (10:35 +0100)]
[X86][NFCI] Remove target-specific branch optimisation that's handled in BranchFolding

This specific optimisation is handled in OptimizeBlock in BranchFolding
so is redundant. As discussed on the review thread, I've verified that
we have test coverage for that optimisation within test/CodeGen/X86 by
disabling the BranchFolding version of this transform after applying
this patch and rerunning the test suite.

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

2 years ago[WebAssembly] Produce error when encountering unlowerable Wasm global accesses
Alex Bradbury [Wed, 10 Aug 2022 09:34:10 +0000 (10:34 +0100)]
[WebAssembly] Produce error when encountering unlowerable Wasm global accesses

WebAssembly globals are represented as IR globals with the wasm_var
address space (AS1). Prior to this patch, a wasm global load that isn't
lowerable will produce a failure to select, while a wasm global store
will produced incorrect code. This patch ensures we consistently produce
a clear error.

As noted in the test cases, it's conceivable that a frontend or an
optimisation pass could produce similar IR even in the presence of the
semantic restrictions on pointers to Wasm globals in the frontend, which
is a separate problem to address.

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

2 years agoRevert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
Phoebe Wang [Wed, 10 Aug 2022 09:26:11 +0000 (17:26 +0800)]
Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""

This reverts commit 0729d00135ccbe1514a49168bbf26986823235c2.

Buildbot https://lab.llvm.org/buildbot/#/builders/19/builds/11989 failed
with "error: ISO C requires a translation unit to contain at least one declaration [-Werror,-Wempty-translation-unit]"

2 years ago[DAG] Use DAG.getFreeze() to create freeze node. NFC.
Simon Pilgrim [Wed, 10 Aug 2022 09:26:11 +0000 (10:26 +0100)]
[DAG] Use DAG.getFreeze() to create freeze node. NFC.

2 years ago[RISCV] Add cost model for fp-mask cast op.
jacquesguan [Thu, 4 Aug 2022 09:24:45 +0000 (17:24 +0800)]
[RISCV] Add cost model for fp-mask cast op.

The cost of convert from or to mask vector is different from other cases. We could not use PowDiff to calculate it. This patch set it to 3 as we use 3 instruction to make it.

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

2 years ago[Flang][OpenMP] Fix conversion of nested loops for SIMD directive
Dominik Adamski [Mon, 8 Aug 2022 09:51:54 +0000 (04:51 -0500)]
[Flang][OpenMP] Fix conversion of nested loops for SIMD directive

Flang was not able to convert simd directive which contains nested
Fortran loops. The nested Fortran loops inside SIMD directive
are modelled as FIR loops and they need to be translated into LLVM
MLIR dialect.

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

Reviewed by: peixin

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2 years ago[LLDB] Add multi value test for const static enum
David Spickett [Tue, 9 Aug 2022 08:38:17 +0000 (08:38 +0000)]
[LLDB] Add multi value test for const static enum

1438639a2f7eb9e9cba01454d3a9b1b16d179c9a removed a test
that was using undefined behaviour setting a non-typed enum
to a value outside its known range.

That test also checked if we formatted the value properly
when it could contain >1 valid enum value.

I don't think there's anything special about how we format
typed vs non-typed enums so I'm adding a test for ScopedEnum
that will expect to see 2 enum values plus extra.

Reviewed By: labath, Michael137, shafik

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

2 years ago[Attributor] Check for noalias call in AAInstanceInfo
Nikita Popov [Thu, 21 Jul 2022 07:53:26 +0000 (09:53 +0200)]
[Attributor] Check for noalias call in AAInstanceInfo

The relevant property of allocation functions of interest here is
their uniqueness (in the sense of disjoint provenance), which is
encoded by the noalias return attribute.

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

2 years ago[Flang] Use find_program() to find clang-tblgen
Nikita Popov [Mon, 8 Aug 2022 10:40:49 +0000 (12:40 +0200)]
[Flang] Use find_program() to find clang-tblgen

Use find_program() to find the clang-tblgen executable. The current
code ends up using docs/clang-tblgen for me...

This is the same way that mlir-tblgen is obtained in:
https://github.com/llvm/llvm-project/blob/27241435515554bc21105713c9d34cf886c5bced/flang/CMakeLists.txt#L95-L96.

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

2 years ago[workflow] Run release tasks for me (tru) as well.
Tobias Hieta [Wed, 10 Aug 2022 08:02:12 +0000 (10:02 +0200)]
[workflow] Run release tasks for me (tru) as well.

Reviewed By: tstellar

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

2 years ago[release] Use threaded compression with xz
Tobias Hieta [Wed, 10 Aug 2022 08:01:13 +0000 (10:01 +0200)]
[release] Use threaded compression with xz

Use xz -T0 to use your threads

Reviewed By: tstellar

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

2 years agotsan: update Go rules to use -std=c++17
Fangrui Song [Wed, 10 Aug 2022 07:32:40 +0000 (00:32 -0700)]
tsan: update Go rules to use -std=c++17

llvm-project has switched to require C++17.

Reviewed By: dvyukov

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

2 years ago[clang][transformer] Fix crash on replacement-less ASTEdit.
Clement Courbet [Thu, 30 Jun 2022 07:34:20 +0000 (09:34 +0200)]
[clang][transformer] Fix crash on replacement-less ASTEdit.

Given that we provide an EditGenerator edit(ASTEdit), we can't ever be
sure that the user won't give us an empty replacement.

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

2 years ago[libc] Add implementation of pthread_exit and thrd_exit.
Siva Chandra Reddy [Fri, 5 Aug 2022 20:53:46 +0000 (20:53 +0000)]
[libc] Add implementation of pthread_exit and thrd_exit.

Reviewed By: michaelrj

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

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

Disable the build on macOS due to the bot fail.

Reviewed By: bkramer

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

2 years ago[ELF] Simplify llvm::enumerate with structured binding. NFC
Fangrui Song [Wed, 10 Aug 2022 04:52:08 +0000 (21:52 -0700)]
[ELF] Simplify llvm::enumerate with structured binding. NFC

2 years ago[ELF] De-template BitcodeFile::parse. NFC
Fangrui Song [Wed, 10 Aug 2022 04:46:28 +0000 (21:46 -0700)]
[ELF] De-template BitcodeFile::parse. NFC

2 years agoRevert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
Med Ismail Bennani [Wed, 10 Aug 2022 04:44:20 +0000 (21:44 -0700)]
Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""

This reverts commit ab4e5ed441d475ead43bc4ce1cdef842688292f4 since it
causes a build failure on macOS:

https://green.lab.llvm.org/green/job/lldb-cmake/45984/

2 years ago[ELF] De-template createBitcodeSymbol. NFC
Fangrui Song [Wed, 10 Aug 2022 04:43:35 +0000 (21:43 -0700)]
[ELF] De-template createBitcodeSymbol. NFC

2 years ago[lldb/crashlog] Refactor the CrashLogParser logic
Med Ismail Bennani [Tue, 9 Aug 2022 23:36:47 +0000 (16:36 -0700)]
[lldb/crashlog] Refactor the CrashLogParser logic

This patch changes the CrashLogParser class to be both the base class
and a Factory for the JSONCrashLogParser & TextCrashLogParser.

That should help remove some code duplication and ensure both class
have a parse method.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Skip null image dsym fetching on interactive mode
Med Ismail Bennani [Wed, 10 Aug 2022 00:31:31 +0000 (17:31 -0700)]
[lldb/crashlog] Skip null image dsym fetching on interactive mode

Sometimes, it can happen that a crash report has null images in its list
of used binaries. This manifests like such:

```
    0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
```

When fetching debug symbols to symbolicate the crashlog stackframe,
having null images causes `dsymForUUID` to hang for few seconds.

This patch addresses that by skipping null images from being load by the
scripted process.

rdar://97419487

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Add `-s|--skip-status` option to interactive mode
Med Ismail Bennani [Wed, 3 Aug 2022 00:29:01 +0000 (17:29 -0700)]
[lldb/crashlog] Add `-s|--skip-status` option to interactive mode

This patch introduces a new option for the interactive crashlog mode,
that will prevent it from dumping the `process status` & `thread backtrace`
output to the debugger console.

This is necessary when lldb in running from an IDE, to prevent flooding
the console with information that should be already present in the UI.

rdar://96813296

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Remove 'process_path' parsing logic
Med Ismail Bennani [Wed, 3 Aug 2022 23:36:56 +0000 (16:36 -0700)]
[lldb/crashlog] Remove 'process_path' parsing logic

In can happen when creating stackshot crash report that that key is missing.

Moreover, we try to parse that key but don't use it, or need it, since we
fetch images and symbolicate the stackframes using the binaries UUIDs.

This is why this patch removes everything that is related to the
`process_path`/`procPath` parsing.

rdar://95054188

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Update frame regex matcher
Med Ismail Bennani [Thu, 4 Aug 2022 17:34:41 +0000 (10:34 -0700)]
[lldb/crashlog] Update frame regex matcher

This patch updates the regular expression matching stackframes in
crashlog to allow addresses that are 7 characters long and more (vs. 8
characters previously).

It changes the `0x[0-9a-fA-F]{7}[0-9a-fA-F]+` by `0x[0-9a-fA-F]{7,}`.

rdar://97684839

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Surface error using SBCommandReturnObject argument
Med Ismail Bennani [Wed, 3 Aug 2022 23:45:48 +0000 (16:45 -0700)]
[lldb/crashlog] Surface error using SBCommandReturnObject argument

This patch allows the crashlog script to surface its errors to lldb by
using the provided SBCommandReturnObject argument.

rdar://95048193

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Add '-t|--target' option to interactive mode
Med Ismail Bennani [Wed, 3 Aug 2022 21:11:43 +0000 (14:11 -0700)]
[lldb/crashlog] Add '-t|--target' option to interactive mode

This patch introduces a new flag for the interactive crashlog mode, that
allow the user to specify, which target to use to create the scripted
process.

This can be very useful when lldb already have few targets created:
Instead of taking the first one (zeroth index), we will use that flag to
create a new target. If the user didn't provide a target path, we will rely
on the symbolicator to create a targer.If that fails and there are already
some targets loaded in lldb, we use the first one.

rdar://94682869

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[MLIR] [Python] Fix the Windows build broken by d747a17
John Demme [Wed, 10 Aug 2022 03:07:33 +0000 (20:07 -0700)]
[MLIR] [Python] Fix the Windows build broken by d747a17

Windows builds require all control paths return. Since we don't have
`llvm_unreachable` in the Python bindings, just return `None`.

2 years ago[MLIR] [Python] Fix `Value.owner` to handle BlockArgs
John Demme [Wed, 10 Aug 2022 02:37:04 +0000 (19:37 -0700)]
[MLIR] [Python] Fix `Value.owner` to handle BlockArgs

Previously, calling `Value.owner()` would C++ assert in debug builds if
`Value` was a block argument. Additionally, the behavior was just wrong
in release builds. This patch adds support for BlockArg Values.

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

Fix the mising change for truncdfbf2.c

Reviewed By: bkramer

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

2 years agoRevert "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Phoebe Wang [Wed, 10 Aug 2022 02:05:12 +0000 (10:05 +0800)]
Revert "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"

This reverts commit 0ae2a41d803d715975d710ec289a4bd90ca534e2.

Revert due to buildbot fail.

2 years ago[sanitizer] Let internal symbolizer to use posix_memalign
Vitaly Buka [Wed, 10 Aug 2022 01:44:00 +0000 (18:44 -0700)]
[sanitizer] Let internal symbolizer to use posix_memalign

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

#56854 shows a backwards compatibility problem when builtins of compiler-rt don't follow ABI. We need to prevent to fall into the trap again for BF16.

Reviewed By: bkramer

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

2 years ago[X86][BF16] Enable __bf16 for x86 targets.
Freddy Ye [Wed, 10 Aug 2022 00:59:21 +0000 (08:59 +0800)]
[X86][BF16] Enable __bf16 for x86 targets.

X86 psABI has updated to support __bf16 type, the ABI of which is the
same as FP16. See https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149

Reviewed By: pengfei

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

2 years ago[X86][BF16] Make backend type bf16 to follow the psABI
Phoebe Wang [Wed, 10 Aug 2022 00:58:41 +0000 (08:58 +0800)]
[X86][BF16] Make backend type bf16 to follow the psABI

X86 psABI has updated to support __bf16 type, the ABI of which is the
same as FP16. See https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149

This is an alternative of D129858, which has less code modification and
supports the vector type as well.

Reviewed By: LuoYuanke

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

2 years ago[COFF] Change a llvm::StringSet<> to llvm::DenseSet<StringRef>. NFC
Fangrui Song [Wed, 10 Aug 2022 00:50:42 +0000 (17:50 -0700)]
[COFF] Change a llvm::StringSet<> to llvm::DenseSet<StringRef>. NFC

The former stores strings and is therefore more expensive.

2 years ago[clang] add APValue type check in `TryPrintAsStringLiteral`
YingChi Long [Tue, 9 Aug 2022 17:11:41 +0000 (01:11 +0800)]
[clang] add APValue type check in `TryPrintAsStringLiteral`

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

https://reviews.llvm.org/D115031 improved printing of non-type template
parameter args. But checking if the end of Inits is 0 without checking
if APValue is an integer, causes clang to segfault. This patch adds
the code to check the type. (May not be a proper bugfix.)

Reviewed By: aaron.ballman, lichray

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

2 years ago[analyzer] Fix false positive in use-after-move checker
malavikasamak [Wed, 10 Aug 2022 00:25:19 +0000 (17:25 -0700)]
[analyzer] Fix false positive in use-after-move checker

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

2 years ago[mlir][sparse] fix doc
Aart Bik [Tue, 9 Aug 2022 22:48:00 +0000 (15:48 -0700)]
[mlir][sparse] fix doc

Reviewed By: Peiming

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