platform/upstream/llvm.git
18 months ago[clang][Interp] Add missing static_assert message
Timm Bäder [Sat, 8 Apr 2023 13:44:11 +0000 (15:44 +0200)]
[clang][Interp] Add missing static_assert message

18 months ago[clang][Interp][NFC] Add test for e7f55bb
Timm Bäder [Sat, 8 Apr 2023 13:26:46 +0000 (15:26 +0200)]
[clang][Interp][NFC] Add test for e7f55bb

18 months ago[clang][Interp] Fix a crash when calling invalid constexpr functions
Timm Bäder [Sat, 8 Apr 2023 09:59:59 +0000 (11:59 +0200)]
[clang][Interp] Fix a crash when calling invalid constexpr functions

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

18 months ago[libc++][chrono] Add sys_time formatter.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Add sys_time formatter.

Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters

Reviewed By: ldionne, #libc

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

18 months ago[libc++][format] Implements LWG3892.
Mark de Wever [Fri, 3 Mar 2023 19:23:51 +0000 (20:23 +0100)]
[libc++][format] Implements LWG3892.

This LWG issue is based on the discussion regarding

  P2733R3 Fix handling of empty specifiers in std::format

This paper was disussed and changed a few times in LEWG during the
Issaquah meeting. The paper was not voted in, instead LEWG asked for
a DR against C++26.

This LWG issue contains the direction voted by LEWG. This issue has not
been voted in yet. However it fixes some of the defencies on the
container based formatting. Without this fix the range-default-formatter
for strings looks bad when used in containers.

The changes of this issue match the intended changes of P27333.

type                      fmt     before     after (if changed)
---------------------------------------------------------------
char                      {}      a
char                      {:?}    'a'
array<char, 1>            {}      ['a']
array<char, 1>            {::}    [a]
array<char, 1>            {::c}   [a]
array<char, 1>            {::?}   ['a']
map<char, char>           {}      {a: a}     -> {'a': 'a'}
map<char, char>           {::}    {'a': 'a'}
set<char>                 {}      {'a'}
set<char>                 {::}    {a}
set<char>                 {::c}   {a}
set<char>                 {::?}   {'a'}
tuple<char>               {}      ('a')
stack<char>               {}      ['a']
stack<char>               {::}    [a]
stack<char>               {::c}   [a]
stack<char>               {::?}   ['a']
array<array<char, 1>, 1>  {}      [[a]]      -> {'a': 'a'}
array<array<char, 1>, 1>  {::}    [['a']]
array<array<char, 1>, 1>  {:::}   [[a]]
array<array<char, 1>, 1>  {:::c}  [[a]]
array<array<char, 1>, 1>  {:::?}  [['a']]
array<tuple<char>, 1>     {}      [(a)]      -> [('a')]
tuple<tuple<char>>        {}      ((a))      -> (('a'))
tuple<array<char, 1>>     {}      ([a])      -> (['a'])

Note the optimization text as mentioned in the tuple formatter can't be
done. The call to parse may affect the formatter so its state needs to
be preserved.

Reviewed By: ldionne, #libc, EricWF

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

18 months ago[VPlan] Require VFRange.End to be a power-of-2. (NFCI)
Florian Hahn [Sat, 8 Apr 2023 12:04:08 +0000 (13:04 +0100)]
[VPlan] Require VFRange.End to be a power-of-2. (NFCI)

This removes the need to convert the end of the range to the next
power-of-2 for the end iterator after 4bd3fda5124962 and was suggested
as follow-up TODO in D147468.

18 months agoAMDGPU: Add baseline test for issue 61083
Matt Arsenault [Sun, 5 Mar 2023 19:53:06 +0000 (15:53 -0400)]
AMDGPU: Add baseline test for issue 61083

18 months agollvm-reduce: Actually change to the temporary directory in test
Matt Arsenault [Sat, 8 Apr 2023 11:07:29 +0000 (07:07 -0400)]
llvm-reduce: Actually change to the temporary directory in test

Hopefully fixes issue #61132

18 months agoAMDGPU: Fix LiveVariables verifier error for values defined before SI_END_CF
Matt Arsenault [Sun, 5 Mar 2023 11:07:23 +0000 (07:07 -0400)]
AMDGPU: Fix LiveVariables verifier error for values defined before SI_END_CF

GlobalISel happens to insert some constant materializes before SI_END_CF
in one test. These need to be excluded from AliveBlocks since they
are defined in the original block and used in the split block,
so they aren't fully alive through either block.

The case where the value defined in the first block which was originally used
in a later block is still broken.

Avoids a verifier error in a future patch.

18 months agoAMDGPU: Fix missing MIR serialization for PSInputAddr/PSInputEnable
Matt Arsenault [Sun, 5 Mar 2023 01:14:08 +0000 (21:14 -0400)]
AMDGPU: Fix missing MIR serialization for PSInputAddr/PSInputEnable

Resuming any mir test for a pixel shader would assert in the AsmPrinter.

18 months ago[VPlan] Add VFRange::begin() and end() iterators. (NFCI)
Florian Hahn [Sat, 8 Apr 2023 09:19:56 +0000 (10:19 +0100)]
[VPlan] Add VFRange::begin() and end() iterators. (NFCI)

Add an iterator to iterate over all VFs in VFRange. This simplifies some
existing code and allows using all_of,any_of and none_of on a VFRange.

Reviewed By: Ayal

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

18 months ago[Docs][llvm-remarkutil] Fix dangling reference in documentation
Aiden Grossman [Sat, 8 Apr 2023 07:45:55 +0000 (07:45 +0000)]
[Docs][llvm-remarkutil] Fix dangling reference in documentation

D147710 introduced a new annotation-count subcommand to llvm-remarkutil
and added in documentation. However, the reference added under the
subcommands list never actually pointed to anything. This patch adds a
marker for the reference to point to so that the link works and the
sphinx build finishes without any errors.

18 months ago[AMDGPU] Fix a case of updating LiveIntervals in SIOptimizeExecMaskingPreRA
Jay Foad [Thu, 6 Apr 2023 16:26:05 +0000 (17:26 +0100)]
[AMDGPU] Fix a case of updating LiveIntervals in SIOptimizeExecMaskingPreRA

This was causing two test failures when I applied D129208 to enable
extra verification of LiveIntervals:

  LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
  LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir

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

18 months ago[TableGen] Simplify TypeInfer::expandOverloads. NFC
Craig Topper [Sat, 8 Apr 2023 06:38:04 +0000 (23:38 -0700)]
[TableGen] Simplify TypeInfer::expandOverloads. NFC

Directly test the 5 overloaded types instead of doing extra
set creation and iteration.

18 months ago[clang][Sema][NFC] Save token name instead of the full token
Timm Bäder [Wed, 5 Apr 2023 11:46:11 +0000 (13:46 +0200)]
[clang][Sema][NFC] Save token name instead of the full token

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

18 months ago[clang][Interp][NFCI] Call* ops don't modify the PC
Timm Bäder [Fri, 3 Feb 2023 11:20:15 +0000 (12:20 +0100)]
[clang][Interp][NFCI] Call* ops don't modify the PC

This caused the reported errors from the Call*() handlers to report the
wrong source location.

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

18 months ago[Outliner] Add an option to only enable outlining of patterns above a certain threshold
Nathan Lanza [Sat, 8 Apr 2023 06:10:27 +0000 (02:10 -0400)]
[Outliner] Add an option to only enable outlining of patterns above a certain threshold

Outlining isn't always a win when the saved instruction count is >= 1.
The overhead of representing a new function in the binary depends on
exception metadata and alignment. So parameterize this for local tuning.

Reviewed By: paquette

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

18 months ago[clang-tidy] fix concat-nest-namespace fix hint remove the macro
Congcong Cai [Sat, 8 Apr 2023 04:24:25 +0000 (06:24 +0200)]
[clang-tidy] fix concat-nest-namespace fix hint remove the macro

Partially fixed [#60035](https://github.com/llvm/llvm-project/issues/60035)
This patch refactor the FixHint for concat-nest-namespace.
1. remove each namespace except the last non-nest namespace.
2. replace the last non-nest namespace with the new name.

It can remain the comment / pragma / macro between namespace and update the close comment.

Reviewed By: PiotrZSL

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

18 months ago[ORC] Drop tests for OrcV2CBindingsReflectProcessSymbols after 231107a8b5b.
Lang Hames [Sat, 8 Apr 2023 03:00:49 +0000 (03:00 +0000)]
[ORC] Drop tests for OrcV2CBindingsReflectProcessSymbols after 231107a8b5b.

This test was removed as LLJIT now reflects process symbols by default.

18 months ago[MergeICmps] Attach metadata to new created loads
Zhongyunde [Sat, 8 Apr 2023 02:45:39 +0000 (10:45 +0800)]
[MergeICmps] Attach metadata to new created loads

Use clone to keep the metadata, the issue is reported
by aeubanks on D141188.

Reviewed By: nikic, paulwalker-arm

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

18 months agoRe-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." with fixes.
Lang Hames [Fri, 7 Apr 2023 17:06:20 +0000 (17:06 +0000)]
Re-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." with fixes.

This reapplies 371cb1af61d, which was reverted in 0b2240eda01 due to bot
failures.

The clang-repl test failure is fixed by dropping the process symbols definition
generator that was manually attached to the main JITDylib, since LLJIT now
exposes process symbols by default. (The bug was triggered when JIT'd code used
the process atexit provided by the generator, rather than the JIT atexit which
has been moved into the platform JITDylib).

Any LLJIT clients that see crashes in static destructors should likewise remove
any process symbol generators attached to their main JITDylib.

18 months ago[bazel build] pull in cubin only when needed
Aart Bik [Fri, 7 Apr 2023 23:24:27 +0000 (16:24 -0700)]
[bazel build] pull in cubin only when needed

Reviewed By: Peiming

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

18 months agoFix build failure introduced in https://reviews.llvm.org/D145208
Augusto Noronha [Fri, 7 Apr 2023 23:36:11 +0000 (16:36 -0700)]
Fix build failure introduced in https://reviews.llvm.org/D145208

18 months agoAMDGPU: Make myself code owner
Matt Arsenault [Tue, 21 Feb 2023 18:50:11 +0000 (14:50 -0400)]
AMDGPU: Make myself code owner

18 months agollvm-reduce: Try running test in temporary directory
Matt Arsenault [Mon, 3 Apr 2023 13:29:44 +0000 (09:29 -0400)]
llvm-reduce: Try running test in temporary directory

Attempt to fix issue #61761

18 months ago[llvm-remarkutil] Add missing new line for `llvm/docs/CommandGuide/llvm-remarkutil...
Zain Jaffal [Fri, 7 Apr 2023 22:45:45 +0000 (23:45 +0100)]
[llvm-remarkutil] Add missing new line for `llvm/docs/CommandGuide/llvm-remarkutil.rst`

18 months agoRecommit "Add an option to print out annotation remark count."
Zain Jaffal [Fri, 7 Apr 2023 22:42:39 +0000 (23:42 +0100)]
Recommit  "Add an option to print out annotation remark count."

Add missing new line for `llvm/docs/CommandGuide/llvm-remarkutil.rst`

This reverts commit 0f7fcb4c670fbef2c25b835fdfdd29598c6c13ae.

18 months agoRevert "Add an option to print out annotation remark count."
Zain Jaffal [Fri, 7 Apr 2023 22:41:53 +0000 (23:41 +0100)]
Revert "Add an option to print out annotation remark count."

This reverts commit 7cc80ef5fa359b68ee85033f98b1bef1f37fb21c.

18 months ago[NFC] Add a new test case in add-and-not.ll
Amaury Séchet [Fri, 7 Apr 2023 22:34:53 +0000 (22:34 +0000)]
[NFC] Add a new test case in add-and-not.ll

18 months ago[clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined...
Xiang Li [Fri, 7 Apr 2023 15:34:56 +0000 (11:34 -0400)]
[clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

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

Only check self assignment on BO_Assign when BuildOverloadedBinOp.

18 months agoAdd an option to print out annotation remark count.
Zain Jaffal [Thu, 6 Apr 2023 14:09:24 +0000 (15:09 +0100)]
Add an option to print out annotation remark count.

This adds a `annotation-count` option to llvm-remarkutil.

```
llvm-remarkutil annotation-count -remark=REMARK
```
This will print out the remark count for a pass that uses annotation remarks.

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

18 months ago[-Wunsafe-buffer-usage] FixableGadget for handling stand alone pointers under UPC
MalavikaSamak [Fri, 7 Apr 2023 22:11:05 +0000 (15:11 -0700)]
[-Wunsafe-buffer-usage] FixableGadget for handling stand alone pointers under UPC

This patch introduces UPCStandalonePointerGadget, a FixableGadget that emits fixits to
handle cases where a pointer identified as unsafe is simply referenced. An example of
such a case is when the pointer is input as an argument to a method call, where we can
not change the type of the argument. For cases where the strategy for the unsafe pointer is
to use std::span, the idea is to extract the underlying pointer by invoking the "data()"
method on the span instance.

For example, the gadget emits a fixit for S3, where S1, S2 are handled by other gadgets:
  S1: int *ptr = new int[10];
  S2: int val1 = ptr[k]; // Unsafe operation on ptr
  S3: foo(ptr); // Some method that accepts raw pointer => FIXIT: foo(ptr.data());

Reviewed by: NoQ, ziqingluo-90, jkorous

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

18 months ago[mlir][math]Expand Fused math.fmaf to a multiply-add
Balaji V. Iyer [Fri, 7 Apr 2023 21:47:20 +0000 (21:47 +0000)]
[mlir][math]Expand Fused math.fmaf to a multiply-add

Fused multiply and add are being pushed directly to the libm. This is problematic
for situations where libm is not available. This patch will break down a fused multiply and
add into a multiply followed by an add.

Reviewed By: rsuderman

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

18 months agoRemove redundant `get()` call and use auto on LHS of make_unique
David Blaikie [Fri, 7 Apr 2023 22:12:31 +0000 (22:12 +0000)]
Remove redundant `get()` call and use auto on LHS of make_unique

18 months ago[Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser
Ben Hamilton [Tue, 4 Apr 2023 21:27:42 +0000 (15:27 -0600)]
[Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

Apple added a new NS_ERROR_ENUM macro to help define enums for
NSError codes.

This updates libformat's Objective-C language-guessing heuristic
to detect the new macro as well as related NSError types.

Tested: New tests added.

Reviewed By: MyDeveloperDay

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

18 months ago[Sanitizers][Atos] Remove null-ing of atos process pointer
Blue Gaston [Thu, 6 Apr 2023 17:33:40 +0000 (10:33 -0700)]
[Sanitizers][Atos] Remove null-ing of atos process pointer

Currently, when we send an address to atos to be symbolized, it is
expected that atos returns with more than it was sent, i.e. symbol
information for that address. In the case where only the address is
returned, we currently null the pointer to the atos process. Typically,
for modules where no symbolication is expected, we do not send the
address to atos.

However, in new simulators there is an early call that atos does not
return any symbol information for. And in this case, because we have
gotten rid of the pointer to the process, no subsequent frames are
symbolicated, even tho atos is still working/running.

This patch removes the nulling of the pointer to the process. This
allows subsequent calls to atos even after an unexpected result.
It also now Reports what has happened and the address this occurred.

This will improve symbolication in cases where we get an unepxected
result, and will make it easier to diagnose atos if it is not
symbolicating as expected.

Filed a radar about the change of behavior 107621524

rdar://107169715

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

18 months ago[flang][NFC] Add select type test to check correct ordering
Valentin Clement [Fri, 7 Apr 2023 21:18:48 +0000 (14:18 -0700)]
[flang][NFC] Add select type test to check correct ordering

Somehow this test has been left behind in my sandbox. This
patch adds a lowering test for fir.select_type operation and
makes sure the dynamic type comaparison is done in the right
order when we have multiple CLASS IS type guard statement
for types that are linked.

This should have been posted with D138280.

Reviewed By: PeteSteinfeld

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

18 months ago[COFF] Add MC support for emitting IMAGE_WEAK_EXTERN_ANTI_DEPENDENCY symbols
Eli Friedman [Fri, 3 Mar 2023 02:09:14 +0000 (18:09 -0800)]
[COFF] Add MC support for emitting IMAGE_WEAK_EXTERN_ANTI_DEPENDENCY symbols

This is mostly useful for ARM64EC, which uses such symbols extensively.

One interesting quirk of ARM64EC is that we need to be able to emit weak
symbols that point at each other (so if either symbol is defined
elsewhere, both symbols point at the definition).  This required a few
changes to the way we handle weak symbols on Windows.

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

18 months ago[JSON] Fix uninitialized variable warning
Jonas Devlieghere [Fri, 7 Apr 2023 20:54:45 +0000 (13:54 -0700)]
[JSON] Fix uninitialized variable warning

Fix uninitialized variable warning when deserializing a std::optional<E>
where is an enum type.

JSON.h:771:20: warning: variable 'Result' is uninitialized when used here [-Wuninitialized]
  if (!fromJSON(E, Result, P))
                   ^~~~~~

18 months ago[lldb] Add unittests for a few FileSpec methods
Alex Langford [Fri, 7 Apr 2023 18:41:54 +0000 (11:41 -0700)]
[lldb] Add unittests for a few FileSpec methods

This adds tests for:
- FileSpec::TestFileNameExtensions
- FileSpec::TestFileNameStrippingExtension
- FileSpec::IsSourceImplementationFile

This additionally updates incorrect documentation.

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

18 months ago[NFC][clang] Fix static analyzer tool remarks about large copies by values
Manna, Soumi [Fri, 7 Apr 2023 20:37:56 +0000 (16:37 -0400)]
[NFC][clang] Fix static analyzer tool remarks about large copies by values

        Reported by Coverity:

        Big parameter passed by value
        Copying large values is inefficient, consider passing by reference; Low, medium, and high size thresholds for detection can be adjusted.

       1. Inside "SemaConcept.cpp" file, in subsumes<clang::Sema::MaybeEmitAmbiguousAtomicConstraintsDiagnostic(clang::NamedDecl *, llvm::ArrayRef<clang::Expr const *>, clang::NamedDecl *, llvm::ArrayRef<clang::Expr const *>)::[lambda(clang::AtomicConstraint const &, clang::AtomicConstraint const &) (instance 2)]>(llvm::SmallVector<llvm::SmallVector<clang::AtomicConstraint *, 2u>, 4u>, llvm::SmallVector<llvm::SmallVector<clang::AtomicConstraint *, 2u>, 4u>, T1): A large function call parameter exceeding the low threshold is passed by value.

        i. pass_by_value: Passing parameter PDNF of type NormalForm (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.

        ii. pass_by_value: Passing parameter QCNF of type NormalForm (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.

        2. Inside "CodeGenAction.cpp" file, in clang::reportOptRecordError(llvm::Error, clang::DiagnosticsEngine &, clang::CodeGenOptions): A very large function call parameter exceeding the high threshold is passed by value.

        i. pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions const (size 1560 bytes) by value, which exceeds the high threshold of 512 bytes.

        3. Inside "SemaCodeComplete.cpp" file, in HandleCodeCompleteResults(clang::Sema *, clang::CodeCompleteConsumer *, clang::CodeCompletionContext, clang::CodeCompletionResult *, unsigned int): A large function call parameter exceeding the low threshold is passed by value.

        i. pass_by_value: Passing parameter Context of type clang::CodeCompletionContext (size 200 bytes) by value, which exceeds the low threshold of 128 bytes.

        4. Inside "SemaConcept.cpp" file, in <unnamed>::SatisfactionStackRAII::SatisfactionStackRAII(clang::Sema &, clang::NamedDecl const *, llvm::FoldingSetNodeID): A large function call parameter exceeding the low threshold is passed by value.

        i. pass_by_value: Passing parameter FSNID of type llvm::FoldingSetNodeID (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.

        Reviewed By: erichkeane, aaron.ballman

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

18 months ago[SLP][NFC]Make clusterSortPtrAccesses static.
Alexey Bataev [Fri, 7 Apr 2023 20:22:48 +0000 (13:22 -0700)]
[SLP][NFC]Make clusterSortPtrAccesses static.

18 months ago[InstCombine] Improve transforms for `(mul X, Y)` -> `(shl X, log2(Y)`
Noah Goldstein [Fri, 7 Apr 2023 19:35:37 +0000 (14:35 -0500)]
[InstCombine] Improve transforms for `(mul X, Y)` -> `(shl X, log2(Y)`

Using the more robust log2 search allows us to fold more cases (same
logic as exists for idiv/irem).

Reviewed By: nikic

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

18 months ago[InstCombine] Add tests for indirect mul by power of 2; NFC
Noah Goldstein [Fri, 17 Mar 2023 06:32:32 +0000 (01:32 -0500)]
[InstCombine] Add tests for indirect mul by power of 2; NFC

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

18 months ago[Clang][Sema] Add MultiLevelTemplateArgumentList::dump
Alexander Shaposhnikov [Fri, 7 Apr 2023 19:34:52 +0000 (19:34 +0000)]
[Clang][Sema] Add MultiLevelTemplateArgumentList::dump

Add MultiLevelTemplateArgumentList::dump
(similarly to TemplateArgument::dump).

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

18 months ago[mlir][sparse] Simplifying Merger::expContainsTensor
wren romano [Wed, 29 Mar 2023 23:36:14 +0000 (16:36 -0700)]
[mlir][sparse] Simplifying Merger::expContainsTensor

`expContainsTensor` used to call `expIsTensor` to short-circuit the recursive calls; however, the very first thing `expContainsTensor` does is to check `expIsTensor`, so the short-circuiting code just causes the function to check that condition redundantly.

Depends On D146684

Reviewed By: aartbik

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

18 months ago[libc] Add baremetal abort
Alex Brachet [Fri, 7 Apr 2023 19:25:27 +0000 (19:25 +0000)]
[libc] Add baremetal abort

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

18 months ago[lldb] Move "SelectMostRelevantFrame" from Thread::WillStop
Jim Ingham [Fri, 7 Apr 2023 19:17:57 +0000 (12:17 -0700)]
[lldb] Move "SelectMostRelevantFrame" from Thread::WillStop

SelectMostRelevantFrame triggers the StackFrameRecognizer construction,
which can run arbitrary Python code, call expressions etc. WillStop gets
called on every private stop while the recognizers are a user-facing
feature, so first off doing this work on every stop is inefficient. But
more importantly, you can get in to situations where the recognizer
causes an expression to get run, then when we fetch the stop event at
the end of the expression evaluation, we call WillStop again on the
expression handling thread, which will do the same StackFrameRecognizer
work again. If anyone is locking along that path, you will end up with a
deadlock between the two threads.

The example that brought this to my attention was the
objc_exception_throw recognizer which can cause the objc runtime
introspection functions to get run, and those take a lock in
AppleObjCRuntimeV2::DynamicClassInfoExtractor::UpdateISAToDescriptorMap
along this path, so the second thread servicing the expression deadlocks
against the first thread waiting for the expression to complete.

It makes more sense to have the frame recognizers run on demand, either
when someone asks for the variables for the frame, or when someone does
GetSelectedFrame. The former already worked that way, the only reason
this was being done in WillStop was because the StackFrameRecognizers
can change the SelectedFrame, so you needed to run them before the
anyone requested the SelectedFrame.

This patch moves SelectMostRelevantFrame to StackFrameList, and runs it
when GetSelectedFrame is called for the first time on a given stop. If
you call SetSelectedFrame before GetSelectedFrame, then you should NOT
run the recognizer & change the frame out from under you. This patch
also makes that work. There were already tests for this behavior, and
for the feature that caused the hang, but the hang is racy, and it
doesn't trigger all the time, so I don't have a way to test that
explicitly.

One more detail: it's actually pretty easy to end up calling
GetSelectedFrame, for instance if you ask for the best ExecutionContext
from an ExecutionContextRef it will fill the StackFrame with the result
of GetSelectedFrame and that would still have the same problems if this
happens on the Private State Thread. So this patch also short-circuits
SelectMostRelevantFrame if run on the that thread. I can't think of any
reason the computations that go on on the Private State Thread would
actually want the SelectedFrame - that's a user-facing concept, so
avoiding that complication is the best way to go.

rdar://107643231

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

18 months ago[SLP][NFC]Improve SLP time by precomputing value<->gather nodes
Alexey Bataev [Fri, 7 Apr 2023 18:22:27 +0000 (11:22 -0700)]
[SLP][NFC]Improve SLP time by precomputing value<->gather nodes
dependencies.

Improved compiled time by the precomputing the mapping between gathered
scalars and their gather/buildvector nodes for later use in
isGatherShuffledEntry to avoid recomputing this map each time this
function is called.

18 months ago[libc++] Reject standard attributes which are extensions in libcpp-uglify-attributes
Nikolas Klauser [Tue, 7 Mar 2023 16:00:01 +0000 (17:00 +0100)]
[libc++] Reject standard attributes which are extensions in libcpp-uglify-attributes

This adds a list of attributes which can be pretty to be able to reject attributes which were introduced in a later C++ standard.
Fixes #61196

Reviewed By: Mordante, #libc

Spies: mikhail.ramalho, jdoerfert, libcxx-commits

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

18 months ago[libc][obvious] fix phrasing in assert comment
Michael Jones [Fri, 7 Apr 2023 18:50:43 +0000 (11:50 -0700)]
[libc][obvious] fix phrasing in assert comment

18 months ago[flang] Handle correctly user defined assignment for allocatable component
Valentin Clement [Fri, 7 Apr 2023 18:47:35 +0000 (11:47 -0700)]
[flang] Handle correctly user defined assignment for allocatable component

In the Fortran standard 2018 section 10.2.1.3 (13), it is mentioned
that all noncoarray allocatable component must follow this sequence of
operations:

1) If the component of the variable is allocated, it is deallocated.
2) If the component of the value of expr is allocated, the corresponding
   component of the variable is allocated with the same dynamic type and
   type parameters as the component of the value of expr. If it is an
   array, it is allocated with the same bounds. The value of the
   component of the value of expr is then assigned to the corresponding
   component of the variable using defined assignment if the declared type
   of the component has a type-bound defined assignment consistent with the
   component, and intrinsic assignment for the dynamic type of that component
   otherwise.

This patch updates the code to make use of the user defined assignment for
allocatable component and make sure the component is allocated correctly.

Reviewed By: klausler

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

18 months agoRevert "[Clang][Sema] Fix comparison of constraint expressions"
Alexander Shaposhnikov [Fri, 7 Apr 2023 18:32:49 +0000 (18:32 +0000)]
Revert "[Clang][Sema] Fix comparison of constraint expressions"

This temporarily reverts commit
60bee9ff544541e83ffbd4be31923d0e8b644690.
The diff will be recommitted once the newly discovered
regressions are fixed.

18 months ago[Clang] Improve designated inits diagnostic location
Bill Wendling [Fri, 7 Apr 2023 18:35:29 +0000 (11:35 -0700)]
[Clang] Improve designated inits diagnostic location

A "null" designator won't have a valid location. Try to approximate this
location as best we can in that situation.

Closes 61118
Closes 46132

Reviewed By: shafik

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

18 months ago[mlir] Add tests accidentally removed from arith expand-ops
Robert Suderman [Fri, 7 Apr 2023 18:12:12 +0000 (18:12 +0000)]
[mlir] Add tests accidentally removed from arith expand-ops

Some tests were accidentally removed due to debug code being included.
Readding the tests to guarantee coverage.

Reviewed By: NatashaKnk

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

18 months ago[gn build] Port 376168babb51
LLVM GN Syncbot [Fri, 7 Apr 2023 17:38:29 +0000 (17:38 +0000)]
[gn build] Port 376168babb51

18 months ago[clang-tidy] Add modernize-type-traits check
Nathan James [Fri, 7 Apr 2023 17:38:13 +0000 (18:38 +0100)]
[clang-tidy] Add modernize-type-traits check

This check will look for usages of standard library type traits of the form `traits<...>::type` and `traits<...>::value` and convert them into `traits_t<...>` and `traits_v<...>` respectively.
This expands on the work in D135404 by supporting dependent traits with no instantiations as well as types.

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

18 months ago[support] Revise ScopedPrinter formatting tests for floats
Paul Kirth [Fri, 24 Mar 2023 22:10:11 +0000 (22:10 +0000)]
[support] Revise ScopedPrinter formatting tests for floats

Previously there were several attempts to make the format checks for NaN
and Inf work across platforms, like AIX and Solaris, that print these
values slightly differently. This resulted in a number of forward fixes,
until we finally disabled the tests for NaN and Inf. This change should
make the test robust across different platforms, and reduce the overall
amount of code by delegating to helper functions that use the same
format strings as the implementations used by PrintNumber().

This additionally reverts commit 5a9bad171be5dfdf9430a0f6cbff14d29ca54181
and fa56e362af475e0758cfb41c42f78db50da7235c.

Reviewed By: jhenderson

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

18 months ago[libc++] Module fixes for __synth_three_way.
Mark de Wever [Tue, 21 Mar 2023 17:05:35 +0000 (18:05 +0100)]
[libc++] Module fixes for __synth_three_way.

These changes make it possible to use __synth_three_way in modules. The
change from a lambda to a function is a Clang issue.

The change is list was needed since the compiler couldn't deduce the
comparison template argument.

Adds a few missing includes too.

Reviewed By: #libc, ldionne

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

18 months ago[Clang] Fix buildbots after Fix filtering of inline namespaces for friend functions...
Shafik Yaghmour [Fri, 7 Apr 2023 16:18:15 +0000 (09:18 -0700)]
[Clang] Fix buildbots after Fix filtering of inline namespaces for friend functions commit

In commit cffadbd951e9 the test I added was using a C++17 feature and this
breaking some build bots. I don't need the feature and so I will modify
the test to not use it.

18 months ago[Clang] Fix filtering of inline namespaces for friend functions
Shafik Yaghmour [Fri, 7 Apr 2023 15:57:24 +0000 (08:57 -0700)]
[Clang] Fix filtering of inline namespaces for friend functions

PR D135370 implemented a performance improvement but it restricted the filtering
of declaration from inline namespace too much. In particular it did not filter
for the function template case.

This led to a regression and this PR removes that check.

This fixes: https://github.com/llvm/llvm-project/issues/61851

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

18 months ago[libc++][format][chrono] Addresses LWG3842.
Mark de Wever [Sat, 18 Feb 2023 13:54:29 +0000 (14:54 +0100)]
[libc++][format][chrono] Addresses LWG3842.

  LWG3842 Unclear wording for precision in chrono-format-spec

Note there is nothing to do, the issue clarifies the wording in the Standard.
The new wording matches my interpretation of the previous wording and this has
already been implemented in libc++.

Reviewed By: #libc, ldionne

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

18 months ago[libc++][format] Use granularized charconv.
Mark de Wever [Thu, 16 Mar 2023 16:59:42 +0000 (17:59 +0100)]
[libc++][format] Use granularized charconv.

This reduces the number of transitive includes when using format.

Reviewed By: #libc, ldionne

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

18 months ago[libc++] Qualifies intmax_t and uintmax_t.
Mark de Wever [Fri, 24 Mar 2023 16:18:11 +0000 (17:18 +0100)]
[libc++] Qualifies intmax_t and uintmax_t.

This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)(?<!::u)u?intmax_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.
This is a preparation for that module.

Reviewed By: #libc, ldionne

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

18 months ago[Doc][NFC] Fix a typo
Phoebe Wang [Fri, 7 Apr 2023 15:34:26 +0000 (23:34 +0800)]
[Doc][NFC] Fix a typo

18 months ago[mlir-cpu-runner] Add `export_executable_symbols` in CMake
Andrzej Warzynski [Thu, 30 Mar 2023 08:54:54 +0000 (08:54 +0000)]
[mlir-cpu-runner] Add `export_executable_symbols` in CMake

This patch is primarily about the change in
"mlir/tools/mlir-cpu-runner/CMakeLists.txt". LLJIT needs access to
symbols (e.g. llvm_orc_registerEHFrameSectionWrapper) that will be
defined in the executable when LLVM is linked statically. This change is
consistent with how other tools within LLVM use LLJIT. It is required to
make sure that:
```
 $ mlir-cpu-runner --host-supports-jit
```
correctly returns `true` on platforms that do support JITting (in my
case that's AArch64 Linux).

The change in "mlir/lib/ExecutionEngine/CMakeLists.txt" is required to
avoid ODR violations when symbols from `mlir-cpu-runner` are exported
and when loading `libmlir_async_runtime.so` in `mlir-cpu-runner`.
Specifically, to avoid `EnableABIBreakingChecks` being defined twice.
For more context:
  * https://github.com/llvm/llvm-project/issues/61712
  * https://github.com/llvm/llvm-project/issues/61856
  * https://reviews.llvm.org/D146935 (this PR)

This change relands ccdcfad0815296d8952438632d9abe6bc0a5258a

Fixes #61856

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

18 months ago[clang] Add test for CWG607
Vlad Serebrennikov [Fri, 7 Apr 2023 13:58:11 +0000 (17:58 +0400)]
[clang] Add test for CWG607

[[https://wg21.link/p1787 | P1787]]: CWG607 is resolved by looking up unqualified names in a mem-initializer-id from outside the parameter scope.
Wording: Lookup for an unqualified name in a mem-initializer-id ignores the constructor’s function parameter scope. ([class.base.init]/2)

Reviewed By: #clang-language-wg, shafik

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

18 months ago[clang] Mark CWG562 as N/A
Vlad Serebrennikov [Fri, 7 Apr 2023 13:57:09 +0000 (17:57 +0400)]
[clang] Mark CWG562 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG562 is resolved by defining lookup as occurring from a program point.
Wording: A single search in a scope S for a name N from a program point P finds all declarations that precede P to which any name that is the same as N ([basic.pre]) is bound in S. ([basic.lookup]/2)

Reviewed By: #clang-language-wg, cor3ntin, shafik

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

18 months ago[clang] Add test for CWG255
Vlad Serebrennikov [Fri, 7 Apr 2023 13:56:12 +0000 (17:56 +0400)]
[clang] Add test for CWG255

[[https://wg21.link/p1787 | P1787]]: CWG255 (partially resolved by N3778 is resolved by generally specifying the restriction to usual deallocation functions.
Wording: In any case, any declarations other than of usual deallocation functions ([basic.stc.dynamic.deallocation]) are discarded. ([expr.delete]/9)

Reviewed By: #clang-language-wg, cor3ntin

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

18 months ago[libc][math] Update range reduction step for log10f and reduce its latency.
Tue Ly [Thu, 6 Apr 2023 13:26:16 +0000 (09:26 -0400)]
[libc][math] Update range reduction step for log10f and reduce its latency.

Simplify the range reduction steps by choosing the reduction constants
carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double
precision, even without FMA instructions, and -2^-8 <= v < 2^-7.  This allows the
polynomial evaluations to be parallelized more efficiently.

Reviewed By: zimmermann6

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

18 months ago[mlir][llvm] Fix bswap naming (NFC)
Christian Ulmann [Fri, 7 Apr 2023 14:19:10 +0000 (16:19 +0200)]
[mlir][llvm] Fix bswap naming (NFC)

As pointed out in https://reviews.llvm.org/D147711#inline-1427665, the
bswap intrinsic is called byteswap, not bitswap.

18 months ago[doc][clang-tidy] Sort release notes by check name.
Clement Courbet [Fri, 7 Apr 2023 14:10:47 +0000 (16:10 +0200)]
[doc][clang-tidy] Sort release notes by check name.

18 months ago[X86] Fix problem in D147541
Phoebe Wang [Fri, 7 Apr 2023 09:37:53 +0000 (17:37 +0800)]
[X86] Fix problem in D147541

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

18 months ago[clang] Add test for CWG191
Vlad Serebrennikov [Fri, 7 Apr 2023 13:50:23 +0000 (17:50 +0400)]
[clang] Add test for CWG191

Also mark CWG1200 as "na."

[[https://wg21.link/p1787 | P1787]]: CWG191 and CWG1200 are resolved by defining unqualified lookup in terms of every enclosing scope.
Wording: If no declarations are found, the results of the unqualified search are the results of an unqualified search in the parent scope of S, if any, from P. ([basic.lookup.unqual]/2)

Reviewed By: #clang-language-wg, shafik

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

18 months ago[clang-format] NFC Document the other space before colon option
sstwcw [Fri, 7 Apr 2023 13:49:55 +0000 (13:49 +0000)]
[clang-format] NFC Document the other space before colon option

There are two options that do much the same thing, but for different
languages.  With the addition to the doc, the user is less likely to
configure the wrong option and get frustrated that it doesn't work.

Reviewed By: MyDeveloperDay

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

18 months ago[mlir][llvm] Add missing bit manipulation intrs
Christian Ulmann [Fri, 7 Apr 2023 12:18:28 +0000 (14:18 +0200)]
[mlir][llvm] Add missing bit manipulation intrs

This commit adds three missing bit manipulation intrinsics.
LangRef: https://llvm.org/docs/LangRef.html#bit-manipulation-intrinsics

Reviewed By: gysit

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

18 months agoUpdate static_assert message for redundant cases
Krishna Narayanan [Fri, 7 Apr 2023 12:08:47 +0000 (08:08 -0400)]
Update static_assert message for redundant cases

There are some simple messages where an expansion isn't particularly
helpful or needed. We aim to eliminate expansions that don't add much
value for user (this will give us slightly more room or prioritise to
have longer diagnostics elsewhere).

The test case for which it has been tested:
```
constexpr auto is_gitlab = false;
constexpr auto is_weekend = false;
static_assert(is_gitlab or is_weekend);
```

Previous warning/error message:
```
<source>:4:1: error: static assertion failed due to requirement 'is_gitlab || is_weekend'
static_assert(is_gitlab or is_weekend);
^             ~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:25: note: expression evaluates to 'false || false'
static_assert(is_gitlab or is_weekend);
              ~~~~~~~~~~^~~~~~~~~~~~~
```
Currrent warning/error message:
```
<source>:4:1: error: static assertion failed due to requirement 'is_gitlab'
static_assert(is_gitlab or is_weekend);
^             ~~~~~~~~~
```
This patch aims to remove some redundant cases of static assert messages
where the expansions are particularly unhelpful. In this particular
patch, we have ignored the printing of diagnostic warnings for binary
operators with logical OR operations.

This is done to prioritise and prefer to emit longer diagnostic
warnings for more important concerns elsewhere.

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

18 months ago[clang-tidy]bugprone-fold-init-type
Clement Courbet [Thu, 10 Nov 2022 09:03:14 +0000 (10:03 +0100)]
[clang-tidy]bugprone-fold-init-type

Handle iterators that do not define a `value_type` type alias.

Get the value type from the return type of `Iter::operator*` instead.

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

18 months ago[VPlan] Add VPInterleaveRecipe::NeedsMaskForGaps field (NFCI).
Florian Hahn [Fri, 7 Apr 2023 12:11:03 +0000 (13:11 +0100)]
[VPlan] Add VPInterleaveRecipe::NeedsMaskForGaps field (NFCI).

This patch adds a NeedsMaskForGaps field to VPInterleaveRecipe to record
whether a mask for gaps is needed. This removes a dependence on the cost
model in VPlan code-generation.

Reviewed By: Ayal

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

18 months ago[libc][NFC] Simplify op_generic
Guillaume Chatelet [Fri, 7 Apr 2023 11:58:20 +0000 (11:58 +0000)]
[libc][NFC] Simplify op_generic

18 months ago[libc] Use SFINAE to implement is_signed/is_unsigned
Guillaume Chatelet [Fri, 7 Apr 2023 11:57:39 +0000 (11:57 +0000)]
[libc] Use SFINAE to implement is_signed/is_unsigned

This allows to use the type traits with types that are non constructible from integers.

18 months ago[libc] Add value_type to cpp::array
Guillaume Chatelet [Fri, 7 Apr 2023 11:24:12 +0000 (11:24 +0000)]
[libc] Add value_type to cpp::array

18 months ago[mlir][ODS] Verify type constraint in `TypeAttrOf`
Markus Böck [Fri, 7 Apr 2023 10:29:55 +0000 (12:29 +0200)]
[mlir][ODS] Verify type constraint in `TypeAttrOf`

The current implementation does not verify the type constraint, meaning that any type that happens to be of the same C++ type would pass the verifier.
E.g. a `TypeAttrOf<I64>` would happily accept a `i32` since both satisfy `isa<IntegerType>()`.

This patch fixes that by adding an optional type predicate parameter to `TypeAttrBase` that the type within `TypeAttr` has to satisfy. `TypeAttrOf` then simply passes the predicate of its type parameter as argument.

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

18 months ago[AMDGPU] Fix comment in SIOptimizeExecMaskingPreRA
Jay Foad [Fri, 7 Apr 2023 10:07:50 +0000 (11:07 +0100)]
[AMDGPU] Fix comment in SIOptimizeExecMaskingPreRA

18 months agoFix Bazel build after "Implement Pass and Dialect plugins for mlir-opt"
Tomás Longeri [Fri, 7 Apr 2023 08:09:12 +0000 (10:09 +0200)]
Fix Bazel build after "Implement Pass and Dialect plugins for mlir-opt"

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

18 months ago[libc][NFC] Simplify type_traits
Guillaume Chatelet [Fri, 7 Apr 2023 08:07:51 +0000 (08:07 +0000)]
[libc][NFC] Simplify type_traits

18 months ago[Test] Add one more test on IRCE & regenerate checks
Max Kazantsev [Fri, 7 Apr 2023 07:58:26 +0000 (14:58 +0700)]
[Test] Add one more test on IRCE & regenerate checks

18 months ago[JITLink][RISCV] ADD/SUB relocs: read value from working memory
Job Noorman [Fri, 7 Apr 2023 07:47:41 +0000 (09:47 +0200)]
[JITLink][RISCV] ADD/SUB relocs: read value from working memory

The various ADD/SUB relocations work by reading the current value the
relocation points to, transforming it, and then writing it back to
memory. While the current implementation writes the value back to
working memory, it reads the current value from the execution address of
the relocation. This causes at least wrong results, but often crashes,
when the addresses of working memory are not equal to execution
addresses. This patch fixes this by reading the current value from
working memory.

Reviewed By: lhames

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

18 months ago[Clang] Fix markup in cxx_status
Corentin Jabot [Fri, 7 Apr 2023 07:42:54 +0000 (09:42 +0200)]
[Clang] Fix markup in cxx_status

This reverts the changes to cxx_status introduced
by https://reviews.llvm.org/D146178, as it did
break the html markup

While This PR resolves a bug related to concepts,
it doesn't seem useful to change the advertised implementation
of that paper many years after the fact, especially as the
paper encompasses many issue resolution.

18 months agoFix the two gmoules-prefered-name-* tests
YongKang Zhu [Fri, 7 Apr 2023 05:17:35 +0000 (22:17 -0700)]
Fix the two gmoules-prefered-name-* tests

Add missing "REQUIRES: asserts" for the two tests added in commit
711a64412749ae73709562b591ab1609a3ee7751 (Diff: D145803).

Reviewed By: chapuni

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

18 months ago[mlir][affine] Vectorizer test notifies the case with the unparallel loop with reduction
Kai Sasaki [Fri, 7 Apr 2023 06:55:55 +0000 (15:55 +0900)]
[mlir][affine] Vectorizer test notifies the case with the unparallel loop with reduction

Vectorizer test does not support unparallel loop since no parallel reduction is available. We can emit the informational message instead of crashing the cli in such a case.
Fixes https://github.com/llvm/llvm-project/issues/61842

Reviewed By: mehdi_amini

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

18 months ago[libunwind][LoongArch] Restore $r1 before $r4 in `jumpto`
Weining Lu [Fri, 7 Apr 2023 05:38:44 +0000 (13:38 +0800)]
[libunwind][LoongArch] Restore $r1 before $r4 in `jumpto`

$ra should be restored before $a0, otherwise the baseaddress ($a0) would
be destroyed. See file `UnwindRegistersSave.S` for reference.

This also makes libcxx and libcxxabi regtest pass for the `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` build.

Reviewed By: MaskRay, xen0n, #libunwind

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

18 months ago[libunwind][test] Add test to check for unw_resume()
zhanglimin [Fri, 7 Apr 2023 05:40:58 +0000 (13:40 +0800)]
[libunwind][test] Add test to check for unw_resume()

This is here for local unwinding, which unw_resume() restores
the machine state and then directly resumes execution in the
target stack frame.

Reviewed By: wangleiat

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

18 months ago[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b
Serguei Katkov [Fri, 31 Mar 2023 05:40:42 +0000 (12:40 +0700)]
[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b

Unfortunately alive2 cannot prove the correctness due to fails by timeout even for
float type half.

However it should be correct. If a and b are not NaN, maximum and minimum will just
return different values (a and b) and take into account a + b == b + a this is the same.
If a or b is NaN, than maximum and minimum are equal to NaN and NaN + NaN is NaN.
a + b is also a NaN.

In terms of preserving fast flags, we cannot preserve ninf due to
minimum(NaN, Infinity) == maximum(NaN, Infinity) == NaN,
minimum(NaN, Infinity) +ninf maximum(NaN, Infinity) == NaN +ninf NaN = NaN
However transformation will change
minimum(NaN, Infinity) + maximum(NaN, Infinity) to NaN +ninf Infinity == poison.

But if fadd is marked as nnan, we can preserve because NaN +ninf/nnan NaN = poison as well.

The same optimization for
  maximum(a,b) * minimum(a,b) => a * b
is added.
All said above for fadd is correct for fmul.

Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D147299

18 months agoRevert "[ORC] LLJIT updates: ExecutorNativePlatform, default link order, ..."
Lang Hames [Fri, 7 Apr 2023 05:32:21 +0000 (05:32 +0000)]
Revert "[ORC] LLJIT updates: ExecutorNativePlatform, default link order, ..."

This reverts commit 371cb1af61d668234a242b34c773c146cb9077e7, which broke some
unit tests (see e.g. https://lab.llvm.org/buildbot#builders/139/builds/38754).

18 months ago[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.
Serguei Katkov [Fri, 7 Apr 2023 04:16:29 +0000 (11:16 +0700)]
[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.

The same optimization for
  max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek
sadd: https://alive2.llvm.org/ce/z/zNu_er
uadd + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
sadd + nuw/nsw: https://alive2.llvm.org/ce/z/w_2Nrs

umul: https://alive2.llvm.org/ce/z/dgXRLr
smul: https://alive2.llvm.org/ce/z/hBjGzz
umul + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
smul + nuw/nsw: https://alive2.llvm.org/ce/z/87MNeS

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D147296

18 months ago[ORC] LLJIT updates: ExecutorNativePlatform, default link order, Process JD.
Lang Hames [Thu, 6 Apr 2023 18:28:25 +0000 (18:28 +0000)]
[ORC] LLJIT updates: ExecutorNativePlatform, default link order, Process JD.

This commit includes several related ergonomic improvements to LLJIT.

(1) Adds a default JITDylibSearchOrder to be appended to the initial link order
of JITDylibs created via LLJIT::createJITDylib (dropping any duplicate entries).

This was introduced to support automatic reflection of process symbols (see
(2) below), but has been made visible to clients as it's generically useful,
e.g. if clients have some extra set of libraries that they want to be visible
to JIT'd code by default.

The default JITDylibSearchOrder is only appended to the link order of JITDylibs
created via LLJIT::createJITDylib, and will not be apply to JITDylibs created by
directly calling the underlying ExecutionSession -- in that case clients can set
up the link order manually.

(2) Makes process symbols visible to JIT'd code by default via the new "Process"
JITDylib, which is added to the default link order.

LLJIT clients usually want symbols in the executor process to be accessible to
JIT'd code. Until now clients have been left to set this up themselves by adding
a DynamicLibrarySearchGenerator to the Main JITDylib. This patch adds a new
process symbols JITDylib that will be created by default (with an
EPCDynamicLibrarySearchGenerator attached) and added to the default link order,
making process symbols available to JIT'd code.

Clients who do not want process symbols to be visible to JIT'd code by default
can call setLinkProcessSymbolsByDefault(false) on their LLJITBuilder to disable
this:

LLJITBuilder()
  ...
  .setLinkProcessSymbolsByDefault(false)
  ...
  .create();

Clients can also call setProcessSymbolsJITDylibSetup to take over responsibility
for configuring the process symbols JITDylib (the callback that the client
supplies will be called on the bare process symbols JITDylib immediately after
it is created).

If setLinkProcessSymbolsByDefault(false) is called and no JITDylib setup
callback has been set then the process symbols JITDylib will not be created and
LLJIT::getProcessSymbolsJITDylib will return null.

(3) Adds an ExecutorNativePlatform utility that makes it easier to enable
native platform features.

Some object format features (e.g. native static initializers and thread locals)
require runtime support in the executing process. Support for these features in
ORC is implemented cooperatively between the ORC runtime and the LLVM Platform
subclasses (COFFPlatform, ELFNixPlatform, and MachOPlatform).
ExecutorNativePlatfrom simplifies the process of loading the ORC runtime and
creating the appropriate platform class for the executor process.

ExecutorNativePlatform takes a path to the ORC runtime (or a MemoryBuffer
containing the runtime) and other required runtimes for the executor platform
(e.g. MSVC on Windows) and then configures LLJIT with an appropriate platform
class based on the executor's target triple:

LLJITBuilder()
  .setPlatformSetUp(ExecutorNativePlatform("/path/to/orc-runtime.a"));

(The ORC runtime is built as part of compiler-rt, and the exact name of the
archive is platform dependent).

The ORC runtime and platform symbols will be added to a new "Platform" JITDylib,
which will be added to the *front* of the default link order (so JIT'd code will
prefer symbol definitions in the platform/runtime to definitions in the executor
process).

ExecutorNativePlatform assumes that the Process JITDylib is available, as
the ORC runtime may depend on symbols provided by the executor process.

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

18 months agoRevert "[InstCombine] Add support for max(a,b) + min(a,b) => a + b."
Serguei Katkov [Fri, 7 Apr 2023 04:14:28 +0000 (11:14 +0700)]
Revert "[InstCombine] Add support for max(a,b) + min(a,b) => a + b."

Revert commit due to failure on buildbot:
error: 'match_combine_or' may not intend to support class template argument deduction

This reverts commit b86a06ef284f2637bef89bf5bb20157a8b195568.

18 months ago[InstCombine] Add support for max(a,b) + min(a,b) => a + b.
Serguei Katkov [Fri, 31 Mar 2023 02:35:06 +0000 (09:35 +0700)]
[InstCombine] Add support for max(a,b) + min(a,b) => a + b.

The same optimization for
  max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek
sadd: https://alive2.llvm.org/ce/z/zNu_er
uadd + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
sadd + nuw/nsw: https://alive2.llvm.org/ce/z/w_2Nrs

umul: https://alive2.llvm.org/ce/z/dgXRLr
smul: https://alive2.llvm.org/ce/z/hBjGzz
umul + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
smul + nuw/nsw: https://alive2.llvm.org/ce/z/87MNeS

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D147296

18 months ago[mlir][tblgen] Emit interface decls in definition order in the .td file
Matthias Springer [Fri, 7 Apr 2023 03:02:17 +0000 (12:02 +0900)]
[mlir][tblgen] Emit interface decls in definition order in the .td file

Interface decls were previously sorted by name. This lead to problems when using interface inheritance when both interfaces are defined in the same .td file. The derived interface must appear after the base interface, otherwise the generated C++ will not compile.

With this change, interfaces will compile as long as the base interface is defined before derived interfaces in the .td file.

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