platform/upstream/llvm.git
2 years ago[flang] Complement one-to-one association check of bind name and entity name
Peixin-Qiao [Tue, 14 Jun 2022 02:34:38 +0000 (10:34 +0800)]
[flang] Complement one-to-one association check of bind name and entity name

As Fortran 2018 C802 and C873, if bind name is specified, there can only
be only one entity. The check for common block is missed before. As
Fortran 2018 8.5.5 point 2, the bind name is one identifier, which is
unique. That is, one entity can not have multiple bind names. Also add
this check.

Reviewed By: klausler, Jean Perier

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

2 years ago[flang] Add semantic check for multiple part-ref with nonzero rank for TBP
Peixin-Qiao [Tue, 14 Jun 2022 02:17:44 +0000 (10:17 +0800)]
[flang] Add semantic check for multiple part-ref with nonzero rank for TBP

As Fortran 2018 C919, there shall not be more than one part-ref with
nonzero rank. Support this semantic check for type-bound procedure to
address the issue https://github.com/llvm/llvm-project/issues/55811.

Reviewed By: klausler

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

2 years ago[sanitizer] Add -lresolv only for non-Android non-musl Linux
Fangrui Song [Tue, 14 Jun 2022 02:12:13 +0000 (19:12 -0700)]
[sanitizer] Add -lresolv only for non-Android non-musl Linux

Refine the D127145 logic with my original suggestion.
It turns out that many OSes don't have libresolv.

2 years ago[libcxx][AIX] Switch build compiler to clang
Jake Egan [Tue, 14 Jun 2022 01:44:58 +0000 (21:44 -0400)]
[libcxx][AIX] Switch build compiler to clang

This patch switches the build compiler for AIX from ibm-clang to clang. ibm-clang++_r has `-pthread` by default, but clang for AIX doesn't, so `-pthread` had to be added to the test config. A bunch of tests now pass, so the `XFAIL` was removed. This patch also switch the build to use the visibility support available in clang-15 to control symbols exported by the shared library (AIX traditionally uses explicit export lists for this purpose).

Reviewed By: #libc, #libc_abi, daltenty, #libunwind, ldionne

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

2 years ago[InstCombine] Don't slice up PHIs when pred BB has catchswitch
Heejin Ahn [Sat, 11 Jun 2022 04:51:16 +0000 (21:51 -0700)]
[InstCombine] Don't slice up PHIs when pred BB has catchswitch

If an integer PHI has an illegal type (according to the data layout) and
it is only used by `trunc` or `trunc(lshr)` operations, we split the PHI
into various instructions in its predecessors:
https://github.com/llvm/llvm-project/blob/6d1543a16797fa07eecea7e542df5b42422fc721/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp#L1536-L1543

So this can produce code like the following:
Before:
```
pred:
  ...

bb:
  %p = phi i8 [ %somevalue, %pred ], ...
  ...
  %tobool = trunc i8 %p to i1
  use %tobool
  ...
```
In this code, `%p` has an illegal integer type, `i8`, and its only used
in a `trunc` instruction later. In this case this pass puts extraction
code in its predecessors:

After:
```
pred:
  ...
  %t = and i8 %somevalue, 1
  %extract = icmp ne i8 %t, 0

bb:
  %p.new = phi i1 [ %extract, %pred ], ...
  use %p.new instead of %tobool
```

But this doesn't work if `pred` is a `catchswitch` BB because it cannot
have any non-PHI instructions. This CL ensures we bail out in that case.

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

Reviewed By: dschuff

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

2 years ago[Driver] Improve linking options for target AVR
Ben Shi [Tue, 14 Jun 2022 01:23:05 +0000 (01:23 +0000)]
[Driver] Improve linking options for target AVR

1. Support user specified linker (-fuse-ld)
2. Support user specified linker script (-T)

Reviewed By: MaskRay

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

2 years ago[BasicTTI] Remove unused support for multiple opcodes in getTypeBasedIntrinsicInstrCo...
Philip Reames [Tue, 14 Jun 2022 01:19:50 +0000 (18:19 -0700)]
[BasicTTI] Remove unused support for multiple opcodes in getTypeBasedIntrinsicInstrCost [nfc]

ISDs only ever contains a single ISD opcode.  We can simplify the code under this assumption. The code being removed was added back in 2016 in 0f26b0aeb4a91 to support FMAXNAN/FMINNAN, but at some point since then the motivating case was rewritten not to use the ISDs mechanism.  No reason to keep the false generality around now.

2 years agoRevert "[Driver] Improve linking options for target AVR"
Ben Shi [Tue, 14 Jun 2022 01:12:21 +0000 (09:12 +0800)]
Revert "[Driver] Improve linking options for target AVR"

This reverts commit d7599be9e84fb205b7f50de406dc87858aebc0f4.

2 years ago[C-API][ORC] Add C API to suspend lookups during definition generation.
Lang Hames [Tue, 14 Jun 2022 00:14:23 +0000 (17:14 -0700)]
[C-API][ORC] Add C API to suspend lookups during definition generation.

Slow definition generators may suspend lookups to temporarily release the
session lock, allowing unrelated lookups to proceed.

Using this functionality is discouraged: it is best to make definition
generation fast, rather than suspending the lookup. As a last resort where
this is not possible, suspension may be used.

2 years ago[CodeGen] Remove futureWeight (NFC)
Kazu Hirata [Tue, 14 Jun 2022 00:10:23 +0000 (17:10 -0700)]
[CodeGen] Remove futureWeight (NFC)

The last use was removed on Jun 5, 2022 in
commit 5c06f7168fd1bd589b831cacd5f1cb8a928446fb, which itself was
a patch to remove unused code.

2 years ago[Driver] Improve linking options for target AVR
Ben Shi [Mon, 23 May 2022 10:22:51 +0000 (10:22 +0000)]
[Driver] Improve linking options for target AVR

1. Support linking with lld
2. Support user specifed linker script

Reviewed By: MaskRay

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

2 years ago[C-API][ORC] Add LLVMOrcExecutionSessionLookup -- generic async symbol lookup.
Lang Hames [Mon, 13 Jun 2022 23:30:24 +0000 (16:30 -0700)]
[C-API][ORC] Add LLVMOrcExecutionSessionLookup -- generic async symbol lookup.

An API to wrap ExecutionSession::lookup, this allows C API clients to use async
lookup.

The immediate motivation for adding this is to simplify upcoming
definition-generator unit tests.

As we're adding more tests that need to convert between C and C++ flag values
this commit adds helper functions to support this. This patch also updates the
CAPIDefinitionGenerator to use these new utilities.

2 years ago[flang][runtime] Skip remainder of bad input record even with ADVANCE='NO'
Peter Klausler [Wed, 8 Jun 2022 22:23:56 +0000 (15:23 -0700)]
[flang][runtime] Skip remainder of bad input record even with ADVANCE='NO'

After a recoverable error condition in a READ statement with ADVANCE='NO',
skip the remainder of the current record.

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

2 years ago[flang] Intrinsic module procedure pure prefixes
V Donaldson [Mon, 13 Jun 2022 22:16:07 +0000 (15:16 -0700)]
[flang] Intrinsic module procedure pure prefixes

Per 7.11.1p1 - All [ieee_arithmetic and ieee_exceptions] functions are
pure and all the subroutines are impure unless otherwise stated.  Most of
these functions are elemental (and not impure), which implies pure.
Several of the remaining non-elemental functions are missing pure prefixes;
add them.

2 years ago[flang][runtime] Don't loop in runtime if blank appears in BOZ input
Peter Klausler [Wed, 8 Jun 2022 21:52:01 +0000 (14:52 -0700)]
[flang][runtime] Don't loop in runtime if blank appears in BOZ input

The code for scanning BOZ input allows for blanks and tabs to appear,
but can hang if they do and the BOZ input value is not followed by
extra valid digits; the repositioning for the second sweep simply
needed to be done in units of character, not valid digits.

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

2 years ago[flang] Handle USE association in parse tree rewriting
Peter Klausler [Wed, 8 Jun 2022 21:11:07 +0000 (14:11 -0700)]
[flang] Handle USE association in parse tree rewriting

f18 was treating "f() = 1" as a statement function definition
if it could be viewed as being in the specification part and
"f" was a USE-associated function returning a data pointer.
(The non-USE-associated case is fine.)  Fix to allow for "f"
to be USE associated.

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

2 years ago[flang] Fix crash on USE error
Peter Klausler [Wed, 8 Jun 2022 20:50:43 +0000 (13:50 -0700)]
[flang] Fix crash on USE error

Handle the case of a non-generic procedure that is USE associated
into a scope that has a generic interface of the same name with an
appropriate error rather than crashing.

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

2 years ago[flang][runtime] Detect overflow of fixed-sized exponent output field
Peter Klausler [Wed, 8 Jun 2022 19:44:12 +0000 (12:44 -0700)]
[flang][runtime] Detect overflow of fixed-sized exponent output field

When Ew.dEe or Gw.dEe output has an exponent requiring more than 'e'
digits, the whole output field must overflow to asterisks.  The runtime
was detecting short fields and padding them with zeroes, but not
overflow.

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

2 years ago[flang][runtime] Fix overflow detection for REAL input
Peter Klausler [Thu, 9 Jun 2022 18:39:18 +0000 (11:39 -0700)]
[flang][runtime] Fix overflow detection for REAL input

The test for an overflow during decimal->binary conversion was taking
place too late, causing the data not to be rescanned from the beginning.

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

2 years ago[flang][runtime] Don't emit any leading blanks for G0/E0 output editing
Peter Klausler [Wed, 8 Jun 2022 17:42:40 +0000 (10:42 -0700)]
[flang][runtime] Don't emit any leading blanks for G0/E0 output editing

There were cases where E0.d output editing (or G0.d editing that is converted
to E0.d) would emit one or more leading blank characters; fix them.

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

2 years ago[RISCV] Fix use of texternalsym in output pattern where input was tglobaladdr. NFC
Craig Topper [Mon, 13 Jun 2022 22:28:29 +0000 (15:28 -0700)]
[RISCV] Fix use of texternalsym in output pattern where input was tglobaladdr. NFC

I don't think the name used in the output pattern is used to control
anything about the isel table emission, but it should match the input.

2 years ago[mlir] Fix CMake file
Mogball [Mon, 13 Jun 2022 22:35:51 +0000 (22:35 +0000)]
[mlir] Fix CMake file

2 years ago[bazel] Unbreak the build after cf6a7c194793
Benjamin Kramer [Mon, 13 Jun 2022 22:23:17 +0000 (00:23 +0200)]
[bazel] Unbreak the build after cf6a7c194793

2 years ago[mlir] Support getSuccessorInputs from parent op
Mogball [Mon, 13 Jun 2022 22:02:02 +0000 (22:02 +0000)]
[mlir] Support getSuccessorInputs from parent op

Ops that implement `RegionBranchOpInterface` are allowed to indicate that they can branch back to themselves in `getSuccessorRegions`, but there is no API that allows them to specify the forwarded operands. This patch enables that by changing `getSuccessorEntryOperands` to accept `None`.

Fixes #54928

Reviewed By: rriddle

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

2 years ago[ConstraintElimination] Add tests with cmps with constant ops only.
Florian Hahn [Mon, 13 Jun 2022 21:57:53 +0000 (22:57 +0100)]
[ConstraintElimination] Add tests with cmps with constant ops only.

Add extra test coverage for conditions with constant ops.

2 years ago[AMDGPU] Use null for dead sdst operand
Stanislav Mekhanoshin [Fri, 10 Jun 2022 19:13:40 +0000 (12:13 -0700)]
[AMDGPU] Use null for dead sdst operand

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

2 years ago[BOLT][NFC] Pass Function to BC.printInstructions in BinaryBasicBlock::dump
Amir Ayupov [Mon, 13 Jun 2022 21:26:14 +0000 (14:26 -0700)]
[BOLT][NFC] Pass Function to BC.printInstructions in BinaryBasicBlock::dump

BC::printInstruction(s) has many uses of Function ptr if it's available:
# printing CFI instructions (unconditional)
# printing debug line information (-print-debug-info)
# printing instruction relocations (-print-relocations)

Enable these uses by passing Function ptr from the primary printing entry point:
BinaryBasicBlock::dump.

Reviewed By: maksfb

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

2 years ago[Analysis] Remove getUniqueInstruction (NFC)
Kazu Hirata [Mon, 13 Jun 2022 21:26:20 +0000 (14:26 -0700)]
[Analysis] Remove getUniqueInstruction (NFC)

The last use was removed on Apr 7, 2022 in commit
5cefe7d9f531fe6eac4cd22978861752498b2265.

2 years agoFix-forward broken ASan test on Windows.
Mitch Phillips [Mon, 13 Jun 2022 21:22:43 +0000 (14:22 -0700)]
Fix-forward broken ASan test on Windows.

Hopefully the final whack-a-mole.

Relevant differential revision: https://reviews.llvm.org/D126929

2 years ago[LV] Replace OrigPHIsToFix in native with VPlan traversal. (NFC)
Florian Hahn [Mon, 13 Jun 2022 21:20:58 +0000 (22:20 +0100)]
[LV] Replace OrigPHIsToFix in native with VPlan traversal. (NFC)

OrigPHIsToFix is only used in the native path. Collecting phis can be
replaced by iterating over the plan. This also removes another
unnecessary use of a late getVPValue.

This also reduces the coupling between ILV and the VPlan utilities.

2 years ago[libc] Add explicit casts for string functions
Alex Brachet [Mon, 13 Jun 2022 21:06:27 +0000 (21:06 +0000)]
[libc] Add explicit casts for string functions

This fixes warnings from `-Wimplicit-int-conversion`

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

2 years agoRevert "gn build: Add support for building the standalone ubsan runtime."
Peter Collingbourne [Mon, 13 Jun 2022 21:02:58 +0000 (14:02 -0700)]
Revert "gn build: Add support for building the standalone ubsan runtime."

As well as followup commits.
Build is still failing on mac. I'll debug it locally.
http://45.33.8.238/macm1/37269/step_4.txt

This reverts commit ee21411107aa18e191a25380b9e4679f3909a0c7.
This reverts commit 6ef9af6386fe7cd9d5d93342c430528baa8d1026.
This reverts commit b49bd8e07faf0f4d04e6cdfe33d901a2cd8b2346.

2 years ago[libc] Add Fuchsia implementation of ::testing::Test
Alex Brachet [Mon, 13 Jun 2022 21:03:51 +0000 (21:03 +0000)]
[libc] Add Fuchsia implementation of ::testing::Test

2 years ago[NFC] Undo AIX build compiler workaround
Hubert Tong [Mon, 13 Jun 2022 02:36:32 +0000 (22:36 -0400)]
[NFC] Undo AIX build compiler workaround

Removes the workaround from https://reviews.llvm.org/D98509#2732628 for
an AIX build compiler issue.

The AIX build compiler product that caused the issue has since been
fixed. Also, the AIX build compiler has been changed to one based on
LLVM.

2 years agogn build: Don't define an action for gen_version_script on mac/win.
Peter Collingbourne [Mon, 13 Jun 2022 20:52:27 +0000 (13:52 -0700)]
gn build: Don't define an action for gen_version_script on mac/win.

Nothing should depend on the action on those platforms,
as they don't use version scripts.

Should fix mac build:
http://45.33.8.238/macm1/37264/step_4.txt

2 years ago[C-API][ORC] Add missing error check to unit test.
Lang Hames [Mon, 13 Jun 2022 20:48:00 +0000 (13:48 -0700)]
[C-API][ORC] Add missing error check to unit test.

2 years ago[C-API][ORC] Fix struct name.
Lang Hames [Mon, 13 Jun 2022 19:15:53 +0000 (12:15 -0700)]
[C-API][ORC] Fix struct name.

This struct was using the wrong prefix (LLVMJIT... vs LLVMOrc...).

2 years agoRestore missing runtimes-test-depends target that causes build failures when LLVM_INC...
James Nagurne [Thu, 2 Jun 2022 22:30:55 +0000 (17:30 -0500)]
Restore missing runtimes-test-depends target that causes build failures when LLVM_INCLUDE_TESTS is ON

7cc8377f removed the 'runtimes-test-depends' target in runtimes builds that
is assumed to exist when using a bootstrapped runtime build.

For a full analysis, see:
https://discourse.llvm.org/t/looking-for-guidance-on-broken-downstream-bootstrapped-runtimes-builds/62934

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

2 years agogn build: Disable ubsan build on mac/win.
Peter Collingbourne [Mon, 13 Jun 2022 20:43:56 +0000 (13:43 -0700)]
gn build: Disable ubsan build on mac/win.

Build failures:
http://45.33.8.238/macm1/37263/step_4.txt
http://45.33.8.238/win/60034/step_4.txt

2 years ago[RISCV] Disable matchSplatAsGather for i1 vectors to prevent creating illegal nodes.
Craig Topper [Mon, 13 Jun 2022 20:30:36 +0000 (13:30 -0700)]
[RISCV] Disable matchSplatAsGather for i1 vectors to prevent creating illegal nodes.

We were incorrectly creating a VRGATHER node with i1 vector type. We
could support this by promoting the mask to i8 and truncating it, but
for now I want to prevent the crash.

Fixes PR56007.

Reviewed By: reames

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

2 years ago[mlir][TilingInterface] Add pattern to tile using TilingInterface and implement Tilin...
Mahesh Ravishankar [Mon, 13 Jun 2022 19:56:32 +0000 (19:56 +0000)]
[mlir][TilingInterface] Add pattern to tile using TilingInterface and implement TilingInterface for Linalg ops.

This patch adds support for tiling operations that implement the
TilingInterface.
- It separates the loop constructs that are used to iterate over tile
  from the implementation of the tiling itself. For example, the use
  of destructive updates is more related to use of scf.for for
  iterating over tiles that are tensors.
- To test the transformation, TilingInterface is implemented for
  LinalgOps. The separation of the looping constructs used from the
  implementation of tile code generation greatly simplifies the
  latter.
- The implementation of TilingInterface for LinalgOp is kept as an
  external model for now till this approach can be fully flushed out
  to replace the existing tiling + fusion approaches in Linalg.

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

2 years agoPartially revert 3222f95ea8c4de153f908c138cdec178e22acaf4
Zequan Wu [Mon, 13 Jun 2022 20:20:44 +0000 (13:20 -0700)]
Partially revert 3222f95ea8c4de153f908c138cdec178e22acaf4

2 years ago[AMDGPU] Define SGPR_NULL64 register. NFCI.
Stanislav Mekhanoshin [Fri, 10 Jun 2022 17:58:39 +0000 (10:58 -0700)]
[AMDGPU] Define SGPR_NULL64 register. NFCI.

On gfx10+ null register can be used as both 32 and 64 bit operand.
Define a 64 bit version of the register to use during codegen.

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

2 years agogn build: Add support for building the AArch64 LSE builtins.
Peter Collingbourne [Sat, 11 Jun 2022 05:07:39 +0000 (22:07 -0700)]
gn build: Add support for building the AArch64 LSE builtins.

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

2 years agogn build: Add support for building the standalone ubsan runtime.
Peter Collingbourne [Fri, 29 Apr 2022 00:23:47 +0000 (17:23 -0700)]
gn build: Add support for building the standalone ubsan runtime.

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

2 years ago[AMDGPU] Add GFX11 llvm.amdgcn.permlane64 intrinsic
Jay Foad [Mon, 13 Jun 2022 15:35:44 +0000 (16:35 +0100)]
[AMDGPU] Add GFX11 llvm.amdgcn.permlane64 intrinsic

Compared to permlane16, permlane64 has no BC input because it has no
boundary conditions, no fi input because the instruction acts as if FI
were always enabled, and no OLD input because it always writes to every
active lane.

Also use the new intrinsic in the atomic optimizer pass.

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

2 years ago[gn build] Port ea9ff9fac3a6
LLVM GN Syncbot [Mon, 13 Jun 2022 20:04:00 +0000 (20:04 +0000)]
[gn build] Port ea9ff9fac3a6

2 years ago[AMDGPU] Work around GFX11 flat scratch SVS swizzling bug
Jay Foad [Wed, 6 Apr 2022 16:16:50 +0000 (17:16 +0100)]
[AMDGPU] Work around GFX11 flat scratch SVS swizzling bug

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

2 years ago[LLDB][formatters] Add formatter for libc++'s std::span
Adrian Prantl [Mon, 13 Jun 2022 17:51:01 +0000 (10:51 -0700)]
[LLDB][formatters] Add formatter for libc++'s std::span

This patch adds a libcxx formatter for std::span. The
implementation is based on the libcxx formatter for
std::vector. The main difference is the fact that
std::span conditionally has a __size member based
on whether it has a static or dynamic extent.

Example output of formatted span:

(std::span<const int, 18446744073709551615>) $0 = size=6 {
  [0] = 0
  [1] = 1
  [2] = 2
  [3] = 3
  [4] = 4
  [5] = 5
}
The second template parameter here is actually std::dynamic_extent,
but the type declaration we get back from the TypeSystemClang is the
actual value (which in this case is (size_t)-1). This is consistent
with diagnostics from clang, which doesn't desugar this value either.
E.g.,:

span.cpp:30:31: error: implicit instantiation of undefined template
    'Undefined<std::span<int, 18446744073709551615>>'
Testing:

Added API-tests

Confirmed manually using LLDB cli that printing spans works in various scenarios

Patch by Michael Buch!

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

2 years ago[AMDGPU] Add some GFX11 atomic optimizer testing
Jay Foad [Mon, 13 Jun 2022 15:12:12 +0000 (16:12 +0100)]
[AMDGPU] Add some GFX11 atomic optimizer testing

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

2 years ago[AMDGPU] Fix GFX11 codegen for V_MAD_U64_U32 and V_MAD_I64_I32
Jay Foad [Mon, 13 Jun 2022 15:28:05 +0000 (16:28 +0100)]
[AMDGPU] Fix GFX11 codegen for V_MAD_U64_U32 and V_MAD_I64_I32

GFX11 uses different pseudos for these because of a new constraint
on which operands' registers can overlap.

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

2 years ago[lld-macho] Fix symbol name returned from InputSection::getLocation
Daniel Bertalan [Mon, 13 Jun 2022 19:49:27 +0000 (15:49 -0400)]
[lld-macho] Fix symbol name returned from InputSection::getLocation

This commit fixes the issue that getLocation always printed the name of
the first symbol in the section.

For clarity, upper_bound is used instead of a linear search for finding
the closest symbol name. Note that this change does not affect
performance: this function is only called when printing errors and
`symbols` typically contains a single symbol because of
.subsections_via_symbols.

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

2 years ago[gn build] Port 3abaefe64c22
LLVM GN Syncbot [Mon, 13 Jun 2022 19:41:30 +0000 (19:41 +0000)]
[gn build] Port 3abaefe64c22

2 years ago[libc++] Simplify the char_traits specializations
Nikolas Klauser [Mon, 13 Jun 2022 15:54:20 +0000 (17:54 +0200)]
[libc++] Simplify the char_traits specializations

Reviewed By: ldionne, #libc

Spies: mgorny, EricWF, mclow.lists, libcxx-commits

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

2 years ago[flang] Fix type mismatch in verification error
Eric Schweitz [Mon, 13 Jun 2022 19:35:23 +0000 (21:35 +0200)]
[flang] Fix type mismatch in verification error

FIR models Fortran intrinsic types with deliberate KIND values. Like
Fortran, COMPLEX and REAL have related KINDs in FIR. Lowering now
converts REAL types to floating point (MLIR) up front. This patch moves
the code to convert from FIR RealType to MLIR FloatType out of codegen
and into the builder, allowing FIR ComplexTypes to have their element
type returned as an MLIR FloatType.

We should consider whether to replace fir::ComplexType with
mlir::ComplexType at some point. I believe these types are presently
used to convey distinctins in the target ABIs in the Tilikum bridge
however.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[libc++] Granularize some more of <type_traits>
Nikolas Klauser [Mon, 13 Jun 2022 15:36:53 +0000 (17:36 +0200)]
[libc++] Granularize some more of <type_traits>

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[flang][NFC] Add source location information to report unsupported complex types
Eric Schweitz [Mon, 13 Jun 2022 19:30:41 +0000 (21:30 +0200)]
[flang][NFC] Add source location information to report unsupported complex types

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier, PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoReland "Add sanitizer metadata attributes to clang IR gen."
Mitch Phillips [Mon, 13 Jun 2022 19:12:31 +0000 (12:12 -0700)]
Reland "Add sanitizer metadata attributes to clang IR gen."

RE-LAND (reverts a revert):
This reverts commit 8e1f47b596b28fbc88cf32e8f46eb2fecb145fb2.

This patch adds generation of sanitizer metadata attributes (which were
added in D126100) to the clang frontend.

We still currently generate the llvm.asan.globals that's consumed by
the IR pass, but the plan is to eventually migrate off of that onto
purely debuginfo and these IR attributes.

Reviewed By: vitalybuka, kstoimenov

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

2 years ago[analyzer][NFC] Remove unused Analyses enum
Balazs Benics [Mon, 13 Jun 2022 19:19:55 +0000 (21:19 +0200)]
[analyzer][NFC] Remove unused Analyses enum

Reviewed By: martong

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

2 years agoRevert "Add sanitizer metadata attributes to clang IR gen."
Mitch Phillips [Mon, 13 Jun 2022 19:10:40 +0000 (12:10 -0700)]
Revert "Add sanitizer metadata attributes to clang IR gen."

This reverts commit e7766972a6790e25dbb4ce3481f57e9792b49269.

Broke the Windows buildbots.

2 years ago[clang-format] Handle more cases for RemoveBracesLLVM
owenca [Mon, 13 Jun 2022 07:10:26 +0000 (00:10 -0700)]
[clang-format] Handle more cases for RemoveBracesLLVM

Call mightFitOneOneline() on the line before the closing brace only
if it is at the level of the block.

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

2 years agoMinor fix to ae60869908db6e8f45b51bc35d983706e8a296ae
Zequan Wu [Mon, 13 Jun 2022 19:08:26 +0000 (12:08 -0700)]
Minor fix to ae60869908db6e8f45b51bc35d983706e8a296ae

2 years agoMinor fix to 3222f95ea8c4de153f908c138cdec178e22acaf4
Zequan Wu [Mon, 13 Jun 2022 19:06:07 +0000 (12:06 -0700)]
Minor fix to 3222f95ea8c4de153f908c138cdec178e22acaf4

2 years ago[LLDB][NativePDB] Convert backslash to slash when creating CU and filter out CU with...
Zequan Wu [Mon, 13 Jun 2022 18:53:38 +0000 (11:53 -0700)]
[LLDB][NativePDB] Convert backslash to slash when creating CU and filter out CU with no function in ResolveSymbolContext.

On Windows, when compile with -fdebug-compilation-dir which contains slash, the source file path in PDB will look like "../tmp\file.cc" because the path separator used is determined by target machine. Converting backslash to slash helps lldb to find the CU in ResolveSymbolContext.

We want to filter out CU with no function in ResolveSymbolContext as a cpp file will have two debug info modules in PDB if built with thinlto and one of them is a skeleton with no function debug info.

2 years ago[clang-cl] Accept /FA[c][s][u], but ignore the arguments
Stephen Long [Mon, 13 Jun 2022 18:53:39 +0000 (11:53 -0700)]
[clang-cl] Accept /FA[c][s][u], but ignore the arguments

Previously, /FAsc would emit a warning. Now, it will just do what /FA does.

https://docs.microsoft.com/en-us/cpp/build/reference/fa-fa-listing-file?view=msvc-170

Reviewed By: hans

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

2 years ago[flang] Document extension: Ew.0 output editing
Peter Klausler [Wed, 8 Jun 2022 22:52:46 +0000 (15:52 -0700)]
[flang] Document extension: Ew.0 output editing

The restrictions on the relationship between a "kP" scale factor
and a Ew.d/Dw.d/Gw.d significant digit count are not enforced for
output editing when there is no nonzero scale factor in effect.
(An error message about a bad scale factor is confusing if no kP
control edit descriptor has been used.)  Document this usage in
Extensions.md.

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

2 years ago[RISCV] Add basic fshr/fshl cost and codegen coverage
Philip Reames [Mon, 13 Jun 2022 18:49:44 +0000 (11:49 -0700)]
[RISCV] Add basic fshr/fshl cost and codegen coverage

2 years ago[mlir][linalg] Add conv_2d_nhwc_fhwc to core_named_ops.py
Benjamin Kramer [Mon, 13 Jun 2022 18:37:44 +0000 (20:37 +0200)]
[mlir][linalg] Add conv_2d_nhwc_fhwc to core_named_ops.py

So it doesn't disappear when running the generator.

2 years ago[flang] Fix bogus branch target error on END SELECT
Peter Klausler [Tue, 7 Jun 2022 22:56:46 +0000 (15:56 -0700)]
[flang] Fix bogus branch target error on END SELECT

The scope model used for branch target checking treats a label
on an END SELECT statement as if it were in the previous CASE block.
This makes it illegal to GO TO that label from within any earlier
CASE block in that statement.  Fix by treating the CASE blocks as
nested scopes within the scope of the SELECT construct.

Also, add a "warning:" tag to related warning messages.

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

2 years agoRecommit "[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add...
Craig Topper [Mon, 13 Jun 2022 18:21:23 +0000 (11:21 -0700)]
Recommit "[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add some immediates."

With fix for sanitizer build bot failure.

2 years ago[flang][runtime] Fix runtime CSHIFT of rank>1 array case of negative shift count
Peter Klausler [Tue, 7 Jun 2022 17:11:17 +0000 (10:11 -0700)]
[flang][runtime] Fix runtime CSHIFT of rank>1 array case of negative shift count

The calculation of the source index was incorrect when a CSHIFT shift
count value is negative, for the implementation of CSHIFT for arrays
with rank >= 2.  (The vector CSHIFT is fine.)

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

2 years ago[Dexter] Remove debugger-dependent test from windows
Stephen Tozer [Mon, 13 Jun 2022 18:25:56 +0000 (19:25 +0100)]
[Dexter] Remove debugger-dependent test from windows

One of the tests added in the recent floating point patch involves
string comparison against the debugger output; as DbgEng and LLDB have
different output, the test cannot pass against both of them, so disable
it on windows.

2 years ago[clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers
Stephen Long [Mon, 13 Jun 2022 18:20:26 +0000 (11:20 -0700)]
[clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers

https://docs.microsoft.com/en-us/cpp/build/reference/external-external-headers-diagnostics?view=msvc-170

Reviewed By: hans

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

2 years ago[flang][runtime] Don't crash after reporting I/O statement errors
Peter Klausler [Mon, 6 Jun 2022 22:59:01 +0000 (15:59 -0700)]
[flang][runtime] Don't crash after reporting I/O statement errors

When an I/O statement is known to be in a recoverable error state,
it shouldn't cause a crash later in execution because it's not in
an expected non-erroneous processing state.  Add checking for the
ErroneousIoStatementState variant on paths that might otherwise
lead to runtime crashes.

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

2 years agoAdd sanitizer metadata attributes to clang IR gen.
Mitch Phillips [Mon, 13 Jun 2022 18:18:55 +0000 (11:18 -0700)]
Add sanitizer metadata attributes to clang IR gen.

This patch adds generation of sanitizer metadata attributes (which were
added in D126100) to the clang frontend.

We still currently generate the `llvm.asan.globals` that's consumed by
the IR pass, but the plan is to eventually migrate off of that onto
purely debuginfo and these IR attributes.

Reviewed By: vitalybuka, kstoimenov

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

2 years ago[Dexter] Fix incorrect test expectations for floating point tests
Stephen Tozer [Mon, 13 Jun 2022 18:03:55 +0000 (19:03 +0100)]
[Dexter] Fix incorrect test expectations for floating point tests

A pair of tests had incorrect expectations set, one being an off-by-one
error and the other using decimal points in the expect that lldb omits.

2 years ago[lld-macho] Require aarch64 for eh-frame.s test
Jez Ng [Mon, 13 Jun 2022 18:04:10 +0000 (14:04 -0400)]
[lld-macho] Require aarch64 for eh-frame.s test

Should fix the test failure introduced by D124561.

2 years agoRevert "[mlir][vector] Add patterns to ppropagate vector distribution"
Thomas Raoux [Mon, 13 Jun 2022 17:55:31 +0000 (17:55 +0000)]
Revert "[mlir][vector] Add patterns to ppropagate vector distribution"

This reverts commit 1c84800c42d2183a29392c175c8d5f20a4be65d2.

This was causing asan crash.

2 years ago[flang][runtime] Fix list-directed/NAMELIST complex input with "r*" repetition count
Peter Klausler [Mon, 6 Jun 2022 21:14:42 +0000 (14:14 -0700)]
[flang][runtime] Fix list-directed/NAMELIST complex input with "r*" repetition count

The little state machine in GetNextDataEdit() wasn't transitioning
properly from reading the imaginary part of the number back to the
real part for the next iteration of a repeated value.

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

2 years agoReland: unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after 8c8a267...
Nico Weber [Thu, 2 Jun 2022 02:33:36 +0000 (22:33 -0400)]
Reland: unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after 8c8a2679a20f

See revision b8b7a9dcdcbc for prior art.

Reland of: 4463bd0f89181234e0cef982e21de2e96038f873 since the dependent
patch D126340 is also relanding.

2 years agoReland [clang][AIX] add option mdefault-visibility-export-mapping
David Tenty [Tue, 10 May 2022 15:39:58 +0000 (11:39 -0400)]
Reland [clang][AIX] add option mdefault-visibility-export-mapping

The option mdefault-visibility-export-mapping is created to allow
mapping default visibility to an explicit shared library export
(e.g. dllexport). Exactly how and if this is manifested is target
dependent (since it depends on how they map dllexport in the IR).

Three values are provided for the option:

* none: the default and behavior without the option, no additional export linkage information is created.
* explicit: add the export for entities with explict default visibility from the source, including RTTI
* all: add the export for all entities with default visibility

This option is useful for targets which do not export symbols as part of
their usual default linkage behaviour (e.g. AIX), such targets
traditionally specified such information in external files (e.g. export
lists), but this mapping allows them to use the visibility information
typically used for this purpose on other (e.g. ELF) platforms.

This relands commit: 8c8a2679a20f621994fa904bcfc68775e7345edc

with fixes for the compile time and assert problems that were reported
by:

* making shouldMapVisibilityToDLLExport inline and provide an early return
in the case where no mapping is in effect (aka non-AIX platforms)
* don't try to export RTTI types which we will give internal linkage to

Reviewed By: MaskRay

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

2 years ago[flang][runtime] Better (but still synchronous) support for asynchronous I/O
Peter Klausler [Mon, 6 Jun 2022 18:44:19 +0000 (11:44 -0700)]
[flang][runtime] Better (but still synchronous) support for asynchronous I/O

Track pending "asynchronous" I/O operation IDs so that WAIT statements can
report errors about bad ID numbers.

Lowering will need to extended to call GetAsynchronousId() for a READ or
WRITE statement with ID=n.

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

2 years ago[lldb] Add missing UTF-8 char basic type entries
Luís Ferreira [Mon, 13 Jun 2022 17:32:57 +0000 (17:32 +0000)]
[lldb] Add missing UTF-8 char basic type entries

D120690 introduced `eBasicTypeChar8` but missed proper documentation order. This also introduces the missing bindings data on Swig, which should correspond with the documented information.

Reviewed By: labath

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

2 years ago[flang][runtime] Fix nonadvancing output edge case
Peter Klausler [Mon, 6 Jun 2022 16:09:19 +0000 (09:09 -0700)]
[flang][runtime] Fix nonadvancing output edge case

When nonadvancing output uses T/TL control edit descriptors to reposition
the record, don't reset the position to the furthest point written at
the end of the write.

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

2 years ago[BOLT][NFC] Forward declare ReorderBlocks for MSVC19
Amir Ayupov [Mon, 13 Jun 2022 06:06:29 +0000 (23:06 -0700)]
[BOLT][NFC] Forward declare ReorderBlocks for MSVC19

Fix bolt-x86_64-wine-msvc builder:
https://lab.llvm.org/buildbot/#/builders/222/builds/1154

Reviewed By: maksfb

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

2 years agoRevert "[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add...
Mitch Phillips [Mon, 13 Jun 2022 17:15:14 +0000 (10:15 -0700)]
Revert "[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add some immediates."

This reverts commit 8bbcb988481c4b072e5f545ef222078ff2a8df3b.

Broke the UBSan bot. More details in https://reviews.llvm.org/D127376.

2 years ago[mlir][spirv] Fix result type for arith.cmpi/cmpf conversion
Lei Zhang [Mon, 13 Jun 2022 17:15:05 +0000 (13:15 -0400)]
[mlir][spirv] Fix result type for arith.cmpi/cmpf conversion

We cannot directly use the original result type; instead we need
to deduce it from the converted operand type. This addresses
invalid ops generated from converting single element vectors.

Reviewed By: ThomasRaoux

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

2 years ago[mlir][spirv] Use UnrealizedConversionCast in ArithmeticToSPIRV
Lei Zhang [Mon, 13 Jun 2022 17:13:07 +0000 (13:13 -0400)]
[mlir][spirv] Use UnrealizedConversionCast in ArithmeticToSPIRV

This avoids pulling in function converion patterns, which is not
part of what we want to test in ArithmeticToSPIRV. It also allows
using ConvertArithmeticToSPIRVPass as a standalone step.

Reviewed By: ThomasRaoux

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

2 years agoRevert "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"
Mitch Phillips [Mon, 13 Jun 2022 16:49:33 +0000 (09:49 -0700)]
Revert "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

This reverts commit b8f9459715815fa055b3e1c5f970c616797dfcfb.

Broke the ASan buildbot. See https://reviews.llvm.org/D126781 for more
information.

2 years agoRevert "Also move WeakRefReferences in CodeGenModule::moveLazyEmssionStates"
Mitch Phillips [Mon, 13 Jun 2022 16:49:07 +0000 (09:49 -0700)]
Revert "Also move WeakRefReferences in CodeGenModule::moveLazyEmssionStates"

This reverts commit 0ecbedc0986bd4b7b90a60a5f31d32337160d4c4.

Parent change broke the ASan buildbot. See
https://reviews.llvm.org/D126781 for more information.

2 years ago[mlir][spirv] Convert math.ctlz to spv.GLSL.FindUMsb
Lei Zhang [Mon, 13 Jun 2022 17:01:53 +0000 (13:01 -0400)]
[mlir][spirv] Convert math.ctlz to spv.GLSL.FindUMsb

Reviewed By: ThomasRaoux

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

2 years ago[flang][NFC] Add TODOs for KIND = 2
Valentin Clement [Mon, 13 Jun 2022 16:45:02 +0000 (18:45 +0200)]
[flang][NFC] Add TODOs for KIND = 2

Add TODO for KIND=2 so the user is notified correctly.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier, PeteSteinfeld

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

Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
2 years ago[X86] combineEXTEND_VECTOR_INREG - don't attempt to shuffle combine ANY_EXTEND_VECTOR...
Simon Pilgrim [Mon, 13 Jun 2022 16:41:56 +0000 (17:41 +0100)]
[X86] combineEXTEND_VECTOR_INREG - don't attempt to shuffle combine ANY_EXTEND_VECTOR_INREG without SSE41

Without SSE41, ANY_EXTEND_VECTOR_INREG nodes are likely to be prematurely combined to a target shuffle preventing generic sign extension folds.

Fixes a number of sign-extend regressions in D127115.

2 years ago[AMDGPU] Make temp vgpr selection stable in indirectCopyToAGPR
Stanislav Mekhanoshin [Fri, 10 Jun 2022 18:55:10 +0000 (11:55 -0700)]
[AMDGPU] Make temp vgpr selection stable in indirectCopyToAGPR

This uses rotating reminder of division by 3 to select another
temp vgpr each next time in a sequence of several agpr copies.
Therefore, temp vgpr selection depends on the generated agpr
number. This number could change with any unrelated change to
the register definitions.

Stabilize the selection by using a real agpr number.

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

2 years ago[mlir][vector] Add patterns to ppropagate vector distribution
Thomas Raoux [Mon, 6 Jun 2022 23:37:00 +0000 (23:37 +0000)]
[mlir][vector] Add patterns to ppropagate vector distribution

Add patterns to propagate vector distribution and remove dead
arguments. This handles propagation for several vector operations.

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

2 years ago[Flang][OpenMP] Avoid double privatisation of loop variables
Kiran Chandramohan [Mon, 13 Jun 2022 16:26:36 +0000 (16:26 +0000)]
[Flang][OpenMP] Avoid double privatisation of loop variables

Loop variables of a worksharing loop and sequential loops in parallel
region are privatised by default. These variables are marked with
OmpPreDetermined. Skip explicit privatisation of these variables.

Note: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: Leporacanthicus

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Mats Petersson <mats.petersson@arm.com>
2 years ago[mlir] (NFC) Clean up bazel and CMake target names
Mogball [Mon, 13 Jun 2022 06:50:55 +0000 (06:50 +0000)]
[mlir] (NFC) Clean up bazel and CMake target names

All dialect targets in bazel have been named *Dialect and all dialect
targets in CMake have been named MLIR*Dialect.

2 years ago[mlir][spirv] Remove unused `traits` from `SPV_Attr`
Lei Zhang [Mon, 13 Jun 2022 16:20:57 +0000 (12:20 -0400)]
[mlir][spirv] Remove unused `traits` from `SPV_Attr`

This addresses the warning of unused template argument.

2 years ago[mlir][spirv] Convert single element vector.splat/fma
Lei Zhang [Mon, 13 Jun 2022 16:14:13 +0000 (12:14 -0400)]
[mlir][spirv] Convert single element vector.splat/fma

Reviewed By: ThomasRaoux, hanchung

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

2 years ago[libc++][NFC] Use concepts in <bit>.
Mark de Wever [Sun, 12 Jun 2022 10:24:21 +0000 (12:24 +0200)]
[libc++][NFC] Use concepts in <bit>.

All supported compilers have concepts support so use that in the C++20
functions in <bit>.

s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/ as drive-by fix.

Reviewed By: #libc, ldionne

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