platform/upstream/llvm.git
16 months ago[Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang...
Andrew Gozillon [Fri, 17 Mar 2023 16:06:55 +0000 (11:06 -0500)]
[Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang ToolChain

This allows-fembed-offload-object's and -fopenmp-is-device
compiler invocation arguments to be passed to the Flang frontend
during split compilation when offloading in OpenMP.

An example use case is when passing an offload-arch alongside
-fopenmp to embed device objects compiled for the offload-arch
within the host architecture.

This borrows from existing clangDriver+Clang.h/.cpp work and the intent
is currently to reuse as much of the existing infrastructure and design as
we can to achieve offloading for Flang+OpenMP. An overview of
Clang's offloading design can be found
here: https://clang.llvm.org/docs/OffloadingDesign.html

Reviewers:
awarzynski
jhuber6

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

16 months ago[StandardInstrumentations] Check that module analyses are properly invalidated
Arthur Eubanks [Thu, 16 Mar 2023 16:57:35 +0000 (09:57 -0700)]
[StandardInstrumentations] Check that module analyses are properly invalidated

Followup to D146003/D146160

Reviewed By: nikic

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

16 months ago[CodeView] Add source languages ObjC and ObjC++
Stefan Gränitz [Fri, 17 Mar 2023 16:08:20 +0000 (17:08 +0100)]
[CodeView] Add source languages ObjC and ObjC++

This patch adds llvm::codeview::SourceLanguage entries, DWARF translations, and PDB source file extensions in LLVM and allow LLDB's PDB parsers to recognize them correctly.

The CV_CFL_LANG enum in the Visual Studio 2022 documentation https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang defines:
```
    CV_CFL_OBJC     = 0x11,
    CV_CFL_OBJCXX   = 0x12,
```

Since the initial commit in D24317, ObjC was emitted as C language and ObjC++ as Masm.

Reviewed By: DavidSpickett

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

16 months ago[fuzzer] Use puts() rather than printf() in CopyFileToErr()
Roy Sundahl [Thu, 16 Mar 2023 01:56:11 +0000 (18:56 -0700)]
[fuzzer] Use puts() rather than printf() in CopyFileToErr()

CopyFileToErr() uses Printf("%s", ...) which fails with a negative size on
files >2Gb (Its path is through var-args wrappers to an unnecessary "%s"
expansion and subject to int overflows) Using puts() in place of printf()
bypasses this path and writes the string directly to stderr. This avoids the
present loss of data when a crashed worker has generated >2Gb of output.

rdar://99384640

Reviewed By: yln

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

16 months ago[AST] Use ModRefInfo to represent access kind (NFC)
Nikita Popov [Fri, 17 Mar 2023 16:05:11 +0000 (17:05 +0100)]
[AST] Use ModRefInfo to represent access kind (NFC)

AST was using a custom enum with exactly the same semantics. Use
the standard one instead.

16 months ago[Docs] Add release notes for D146089.
Craig Topper [Fri, 17 Mar 2023 15:59:03 +0000 (08:59 -0700)]
[Docs] Add release notes for D146089.

16 months agoRevert "[Coroutines] Fix premature conversion of return object"
Ilya Biryukov [Fri, 17 Mar 2023 15:52:17 +0000 (16:52 +0100)]
Revert "[Coroutines] Fix premature conversion of return object"

This reverts commit 54225c457a336b1609c6d064b2b606a9238a28b9.
The lack of RVO causes compile errors in our code.
Reverting to unblock our integrate.

See D145639 for full discussion.

16 months ago[libc++][NFC] Fix typo in comment
Louis Dionne [Fri, 17 Mar 2023 15:57:34 +0000 (11:57 -0400)]
[libc++][NFC] Fix typo in comment

16 months agoInstCombine: Fold is.fpclass for single infinity to fcmp
Matt Arsenault [Sun, 11 Dec 2022 00:59:39 +0000 (19:59 -0500)]
InstCombine: Fold is.fpclass for single infinity to fcmp

llvm.is.fpclass(x, fcPosInf) -> fcmp oeq x, +inf
llvm.is.fpclass(x, fcNegInf) -> fcmp oeq x, -inf
llvm.is.fpclass(x, ~fcPosInf) -> fcmp one x, +inf
llvm.is.fpclass(x, ~fcNegInf) -> fcmp one x, -inf

llvm.is.fpclass(x, fcPosInf|fcNan) -> fcmp ueq x, +inf
llvm.is.fpclass(x, fcNegInf|fcNan) -> fcmp ueq, -inf
llvm.is.fpclass(x, ~fcPosInf & ~fcNan) -> fcmp one, x, +inf
llvm.is.fpclass(x, ~fcNegInf & ~fcNan) -> fcmp one, x, -inf

This regresses some of the logic of fcmp tests. These should be restored
in a future patch to better handle combining logic of fcmp and class.

16 months ago[flang] Use llvm-readobj instead of llvm-readelf in rv64 test
David Spickett [Fri, 17 Mar 2023 15:45:42 +0000 (15:45 +0000)]
[flang] Use llvm-readobj instead of llvm-readelf in rv64 test

In some circumstances llvm-readelf symlink to llvm-readobj appears
to not be available. For want of a proper fix in CMake, use llvm-readobj
in the test instead.

16 months agoInstCombine: Fold is.fpclass nan|zero to fcmp ueq 0
Matt Arsenault [Fri, 3 Feb 2023 21:29:31 +0000 (17:29 -0400)]
InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0

16 months agoRevert "InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0"
Matt Arsenault [Fri, 17 Mar 2023 15:36:53 +0000 (11:36 -0400)]
Revert "InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0"

This reverts commit b5ff7640cd1391ebe67e47a043fed6faf8bdcbb7.

Merge resolution gone wrong merged two unrelated patches

16 months ago[LSR] Cleanup term-fold tests
Philip Reames [Fri, 17 Mar 2023 15:32:00 +0000 (08:32 -0700)]
[LSR] Cleanup term-fold tests

Autogen for naming change, and remove comments about C code inspiration.  Multiple of these are out of sync with the actual IR, and these are IR tests anyways.

16 months agoInstCombine: Fold is.fpclass nan|zero to fcmp ueq 0
Matt Arsenault [Fri, 3 Feb 2023 21:29:31 +0000 (17:29 -0400)]
InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0

16 months agoCodeGen: Reorder case handling for is.fpclass legalization
Matt Arsenault [Thu, 2 Feb 2023 14:14:36 +0000 (10:14 -0400)]
CodeGen: Reorder case handling for is.fpclass legalization

Subnormal and zero checks can be combined into one, so move
the code closer to reduce the diff in a future change.

16 months ago[Hexagon] Ensure proper ordering of instructions in HVC::AlignVectors
Krzysztof Parzyszek [Fri, 17 Mar 2023 14:01:16 +0000 (07:01 -0700)]
[Hexagon] Ensure proper ordering of instructions in HVC::AlignVectors

The shuffle reduction creates a dependency chain. Make sure that the
inputs to the next instruction are placed ahead of the instruction itself.

16 months ago[Hexagon] Add names to all instructions created in HVC
Krzysztof Parzyszek [Fri, 17 Mar 2023 13:47:46 +0000 (06:47 -0700)]
[Hexagon] Add names to all instructions created in HVC

16 months ago[Hexagon] Add debug code to HVC::AlignVectors
Krzysztof Parzyszek [Fri, 17 Mar 2023 13:44:42 +0000 (06:44 -0700)]
[Hexagon] Add debug code to HVC::AlignVectors

That and clarify/expand some comments.

16 months ago[LSR] Another minor code style improvement [nfc]
Philip Reames [Fri, 17 Mar 2023 15:08:46 +0000 (08:08 -0700)]
[LSR] Another minor code style improvement [nfc]

16 months ago[Polly] Remove some bitcasts (NFC)
Nikita Popov [Fri, 17 Mar 2023 14:58:52 +0000 (15:58 +0100)]
[Polly] Remove some bitcasts (NFC)

No longer relevant with opaque pointers.

16 months ago[LSR] Minor code style improvement [nfc]
Philip Reames [Fri, 17 Mar 2023 14:50:26 +0000 (07:50 -0700)]
[LSR] Minor code style improvement [nfc]

16 months ago[clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from clangTesting
Alex Bradbury [Fri, 17 Mar 2023 14:42:41 +0000 (14:42 +0000)]
[clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from clangTesting

Commit 34de7da6246cdfa6ff6f3d3c514583cddc0a10ec (D143436) introduced a
dependency on the TargetRegistry in `getAnyTargetForTesting`. This is
part of MC, which wasn't listed in clang/lib/Testing/CMakeLists.txt.
This broke the -DBUILD_SHARED_LIBS=True builds.

16 months ago[Polly] Convert remaining tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 14:28:24 +0000 (15:28 +0100)]
[Polly] Convert remaining tests to opaque pointers (NFC)

16 months agoInstCombine: Add a few more tests for is.fpclass folding
Matt Arsenault [Wed, 15 Mar 2023 11:24:38 +0000 (07:24 -0400)]
InstCombine: Add a few more tests for is.fpclass folding

16 months ago[LLDB] Remove some typed pointer code (NFCI)
Nikita Popov [Fri, 17 Mar 2023 14:21:41 +0000 (15:21 +0100)]
[LLDB] Remove some typed pointer code (NFCI)

Various bitcast handling should no longer be necessary with
opaque pointers.

16 months ago[LV] Add test where pointer is incorrectly marked as uniform.
Florian Hahn [Fri, 17 Mar 2023 14:23:56 +0000 (14:23 +0000)]
[LV] Add test where pointer is incorrectly marked as uniform.

Test for #61396.

16 months agoGlobalISel: Use FPClassTest in is.fpclass lowering
Matt Arsenault [Fri, 17 Mar 2023 13:21:57 +0000 (09:21 -0400)]
GlobalISel: Use FPClassTest in is.fpclass lowering

16 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 13:45:41 +0000 (14:45 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

16 months ago[LV] Convert consecutive-ptr-uniforms.ll to use opaque pointers (NFC).
Florian Hahn [Fri, 17 Mar 2023 14:07:10 +0000 (14:07 +0000)]
[LV] Convert consecutive-ptr-uniforms.ll to use opaque pointers (NFC).

16 months agoAdd __builtin_FILE_NAME()
Ilya Karapsin [Fri, 17 Mar 2023 13:50:34 +0000 (09:50 -0400)]
Add __builtin_FILE_NAME()

Add '__builtin_FILE_NAME()', which expands to the filename because the
full path is not always needed. It corresponds to the '__FILE_NAME__'
predefined macro and is consistent with the other '__builin' functions
added for predefined macros.

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

16 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 13:30:41 +0000 (14:30 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

16 months ago[Docs] Fix typo in LoopTerminology.
Carlos Alberto Enciso [Fri, 17 Mar 2023 13:38:44 +0000 (13:38 +0000)]
[Docs] Fix typo in LoopTerminology.

16 months ago[lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()
Stefan Gränitz [Fri, 17 Mar 2023 13:37:26 +0000 (14:37 +0100)]
[lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

The old name of this function was confusing for me, when I started working on the PDB parser. The new name clearifies that the function adds file, line and column (typically referred as source info) and indicates that the information is stored in the provided decl parameter.

Reviewed By: DavidSpickett

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

16 months ago[SCEVExpander] Always use scevgep as name
Nikita Popov [Fri, 17 Mar 2023 12:18:33 +0000 (13:18 +0100)]
[SCEVExpander] Always use scevgep as name

With opaque pointers the scevgep / uglygep distinction no longer
makes sense -- GEPs are always emitted in offset-based representation.

16 months ago[BOLT] Add .relr.dyn section support
Vladislav Khmelevsky [Tue, 14 Mar 2023 20:08:11 +0000 (00:08 +0400)]
[BOLT] Add .relr.dyn section support

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

16 months ago[Clang] Stop demoting ElementCount/TypeSize conversion errors to warnings.
Paul Walker [Tue, 14 Mar 2023 17:52:13 +0000 (17:52 +0000)]
[Clang] Stop demoting ElementCount/TypeSize conversion errors to warnings.

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

16 months ago[clang] Include the error message in file reading error diagnostic
Hans Wennborg [Fri, 17 Mar 2023 09:59:03 +0000 (10:59 +0100)]
[clang] Include the error message in file reading error diagnostic

in order to provide as much information as possible to the user. The
diagnostic will now look like for example:

  error: error reading '/tmp/foo.c': Permission denied

(This addresses a FIXME from 2019, 9ef6c49baf45)

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

16 months ago[libclang] Fix documentation; NFC
Igor Kushnir [Fri, 17 Mar 2023 12:39:33 +0000 (08:39 -0400)]
[libclang] Fix documentation; NFC

Fixes cc929590ad305f0d068709c7c7999f5fc6118dc9. The
CXIndexOptions::GlobalOptions data member has been replaced with the two
CXChoice data members during code review.

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

16 months ago[bazel] update build for d60d3455eb2
Mikhail Goncharov [Fri, 17 Mar 2023 12:31:21 +0000 (13:31 +0100)]
[bazel] update build for d60d3455eb2

16 months agoRevert "Attributor: Add isAtFixpoint part of nofpclass handling"
Matt Arsenault [Fri, 17 Mar 2023 12:14:34 +0000 (08:14 -0400)]
Revert "Attributor: Add isAtFixpoint part of nofpclass handling"

This reverts commit 78313e8531c412f4b57b23e0ee04ea4a131e8d71.

Accidentally pushed

16 months agoRoll back claims that we implement P0960R3 and P1975R0
Aaron Ballman [Fri, 17 Mar 2023 12:01:51 +0000 (08:01 -0400)]
Roll back claims that we implement P0960R3 and P1975R0

We thought we had implemented these papers appropriately but have since
discovered significant issues. See discussion of the issues at:
https://github.com/llvm/llvm-project/issues/61145

The work already done on these papers is remaining in tree for the
moment while people investigate whether the issues can be fixed
forward in main. The status page is being updated so the status is
clear to users of the upcoming Clang 16 release.

16 months agoAttributor: Assume handling for nofpclass
Matt Arsenault [Fri, 3 Mar 2023 19:54:56 +0000 (15:54 -0400)]
Attributor: Assume handling for nofpclass

16 months agoAttributor: Update test
Matt Arsenault [Fri, 17 Mar 2023 11:34:07 +0000 (07:34 -0400)]
Attributor: Update test

16 months agoAttributor: Add isAtFixpoint part of nofpclass handling
Matt Arsenault [Fri, 17 Mar 2023 10:48:51 +0000 (06:48 -0400)]
Attributor: Add isAtFixpoint part of nofpclass handling

16 months agoAttributor: Start looking at uses when inferring nofpclass
Matt Arsenault [Fri, 3 Mar 2023 01:04:22 +0000 (21:04 -0400)]
Attributor: Start looking at uses when inferring nofpclass

Pretty much just copy pasted from noundef handling

16 months agoAttributor: Add baseline tests for nofpclass
Matt Arsenault [Fri, 17 Mar 2023 10:46:37 +0000 (06:46 -0400)]
Attributor: Add baseline tests for nofpclass

Guess at suggestions from D145278

16 months ago[clangd] Move standard options adaptor to CommandMangler
Dmitry Polukhin [Thu, 16 Feb 2023 13:06:53 +0000 (05:06 -0800)]
[clangd] Move standard options adaptor to CommandMangler

There is a discrepancy between how clangd processes CDB loaded from
JSON file on disk and pushed via LSP. Thus the same CDB pushed via
LSP protocol may not work as expected. Some difference between these two
paths is expected but we still need to insert driver mode and target from
binary name and expand response files.

Test Plan: check-clang-tools

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

16 months ago[clangd] Refine logic on $0 in completion snippets
Younan Zhang [Tue, 14 Mar 2023 05:15:34 +0000 (13:15 +0800)]
[clangd] Refine logic on $0 in completion snippets

We have a workaround from D128621 that makes $0 no longer being
a placeholder to conform a vscode feature. However, we have to
refine the logic as it may suppress the last parameter placeholder
for constructor of base class because not all patterns of completion
are compound statements.

This fixes clangd/clangd#1479

Reviewed By: nridge

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

16 months ago[flang][hlfir] lower hlfir.matmul_transpose to runtime call
Tom Eccles [Fri, 17 Mar 2023 09:26:45 +0000 (09:26 +0000)]
[flang][hlfir] lower hlfir.matmul_transpose to runtime call

Depends on D145960

Reviewed By: jeanPerier

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

16 months ago[flang] add fused matmul-transpose to the runtime
Tom Eccles [Fri, 17 Mar 2023 09:26:39 +0000 (09:26 +0000)]
[flang] add fused matmul-transpose to the runtime

This fused operation should run a lot faster than first transposing the
lhs array and then multiplying the matrices separately.

Based on flang/runtime/matmul.cpp

Depends on D145959

Reviewed By: klausler

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

16 months ago[flang][hlfir] add matmul canonicalizer
Tom Eccles [Fri, 17 Mar 2023 09:26:33 +0000 (09:26 +0000)]
[flang][hlfir] add matmul canonicalizer

hlfir.matmul_transpose will be lowered to a new runtime call.

A canonicalizer was chosen because
  - Alternative: a new pass for rewriting chained intrinsics - this
    would add a lot of unnecessary boilerplate.
  - Alternative: including this in the HLFIR Intrinsic Lowering pass -
    I wanted to separate these two concerns: not adding a second purpose
    complicating the intrinsic lowering pass.

With this change, the MLIR built-in canonicalization pass should be run
before the HLFIR Intrinsic Lowering pass.

Depends on D145504, D145957

Reviewed By: clementval, vzakhari

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

16 months ago[flang][hlfir] add hlfir.matmul_transpose operation
Tom Eccles [Fri, 17 Mar 2023 09:26:27 +0000 (09:26 +0000)]
[flang][hlfir] add hlfir.matmul_transpose operation

This operation will be used to transform MATMUL(TRANSPOSE(a), b). The
transformation will go in the following stages:
        1. Lowering to hlfir.transpose and hlfir.matmul
        2. Canonicalise to hlfir.matmul_transpose
        3. hlfir.matmul_transpose will be lowered to FIR as a new runtime
          library call

Step 2 (and this operation) are included for consistency with the other
hlfir intrinsic operations and to avoid mixing concerns in the intrinsic
lowering pass.

In step 3, a new runtime library call is used because this operation is
most easily implemented in one go (the transposed indexing actually
makes the indexing simpler than for a normal matrix multiplication). In
the long run, it is intended that HLFIR will allow the same buffer
to be shared between different runtime calls without temporary
allocations, but in this specific case we can do even better than that
with a dedicated implementation.

This should speed up galgel from SPEC2000 (but this hadn't been tested
yet). The optimization was implemented in Classic Flang.

Reviewed By: vzakhari

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

16 months ago[flang][hlfir] add a test chaining intrinsics
Tom Eccles [Fri, 17 Mar 2023 09:26:09 +0000 (09:26 +0000)]
[flang][hlfir] add a test chaining intrinsics

This test checks all of the parts of intrinsic lowering work together,
and makes sure that we can pass the hlfir.expr result of one intrinsic
as an argument to another.

Depends on D145503

Reviewed By: jeanPerier

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

16 months ago[flang][hlfir] clean up intrinsic arg extended values
Tom Eccles [Fri, 17 Mar 2023 09:26:02 +0000 (09:26 +0000)]
[flang][hlfir] clean up intrinsic arg extended values

Depends on D145502

Reviewed By: jeanPerier

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

16 months ago[flang][hlfir] move intrinsic lowering out of BufferizeHLFIR
Tom Eccles [Fri, 17 Mar 2023 09:25:52 +0000 (09:25 +0000)]
[flang][hlfir] move intrinsic lowering out of BufferizeHLFIR

This move is useful for a few reasons:
  - It is easier to see what the intrinsic lowering is doing when the
    operations it creates are not immediately lowered
  - When lowering a HLFIR intrinsic generates an operation which needs
    to be lowered by another pattern matcher in the same pass, MLIR will
    run that other substitution before validating and finalizing the
    original changes. This means that the erasure of operations is not
    yet visible to subsequent matchers, which hugely complicates
    transformations (in this case, hlfir.exprs cannot be rewritten
    because they are still used by the now-erased HLFIR intrinsic op.

Reviewed By: jeanPerier

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

16 months ago[OpenMP] [OMPT] [8/8] Added lit tests for OMPT target callbacks
Dhruva Chakrabarti [Fri, 17 Mar 2023 08:55:27 +0000 (09:55 +0100)]
[OpenMP] [OMPT] [8/8] Added lit tests for OMPT target callbacks

Added a new target ompt mode that depends on libomptarget OMPT support.
Added tests that verify callbacks for target regions, kernel launch,
and data transfer operations. All of them should pass on amdgpu using
make check-libomptarget.

Reviewed By: jplehr

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

16 months ago[SCEV] Recognize vscale intrinsics
Nikita Popov [Thu, 16 Mar 2023 10:27:25 +0000 (11:27 +0100)]
[SCEV] Recognize vscale intrinsics

Now that SCEV has a dedicated vscale node type, we should also map
vscale intrinsics to it. To make sure this does not regress ranges
(which were KnownBits based previously), add support for vscale to
getRangeRef() as well.

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

16 months ago[ValueTracking] Support vscale in computeConstantRange()
Nikita Popov [Thu, 16 Mar 2023 11:42:59 +0000 (12:42 +0100)]
[ValueTracking] Support vscale in computeConstantRange()

Add support for vscale in computeConstantRange(), based on
vscale_range attributes. This allows simplifying based on the
precise range, rather than a KnownBits approximation (which will
be off by a factor of two for the usual case of a power of two
upper bound).

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

16 months ago[PassBuilder] Support O0 in default pipelines
Nikita Popov [Thu, 16 Mar 2023 08:57:44 +0000 (09:57 +0100)]
[PassBuilder] Support O0 in default pipelines

The default and pre-link pipeline builders currently require you to
call a separate method for optimization level O0, even though they
have perfectly well-defined O0 optimization pipelines.

Accept O0 optimization level and call buildO0DefaultPipeline()
internally, so all consumers don't need to repeat this.

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

16 months ago[Analysis] Make order of analysis executions more stable
Bjorn Pettersson [Thu, 16 Mar 2023 18:48:06 +0000 (19:48 +0100)]
[Analysis] Make order of analysis executions more stable

When debugging and using debug-pass-manager (e.g. in regression tests)
we prefer a consistent order in which analysis passes are executed.
But when for example doing

  return MyClass(AM.getResult<LoopAnalysis>(F),
                 AM.getResult<DominatorTreeAnalysis>(F));

then the order in which LoopAnalysis and DominatorTreeAnalysis isn't
guaranteed, and might for example depend on which compiler that is
used when building LLVM.

I've not scanned the full source tree, but this fixes some occurances
of the above pattern found in lib/Analysis.

This problem was discussed briefly in review for D146206.

16 months ago[LAA] Fix transitive analysis invalidation bug by implementing LoopAccessInfoManager...
Bjorn Pettersson [Thu, 16 Mar 2023 01:00:47 +0000 (02:00 +0100)]
[LAA] Fix transitive analysis invalidation bug by implementing LoopAccessInfoManager::invalidate

The default invalidate method for analysis results is just looking
at the preserved state of the pass itself. It does not consider if
the analysis has an internal state that depend on other analyses.
Thus, we need to implement LoopAccessInfoManager::invalidate in order
to catch if LoopAccessAnalysis needs to be invalidated due to
transitive analyses such as AAManager is being invalidated. Otherwise
we might end up having references to an AAManager that is stale.

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

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

16 months ago[test][MemDep] Correct the 'NOT' checks in the invalidation.ll test case. NFC
Bjorn Pettersson [Thu, 16 Mar 2023 00:57:33 +0000 (01:57 +0100)]
[test][MemDep] Correct the 'NOT' checks in the invalidation.ll test case. NFC

The MemoryDependenceAnalysis/invalidation.ll test case was using
  ; CHECK-NOT-AA-INVALIDATE:
but I think the intention was to use
  ; CHECK-AA-INVALIDATE-NOT:

Simply changing the checks like that would make the test fail.

The old statement that AA being stateless would result in nothing
to invalidate when doing invalidate<aa> is not true afaict.
It would be different if for example doing invalidate<basic-aa>, then
the AAManager isn't invalidated (and then neither memdep would be
invalidated). But when the AAManager itself is invalidated then we
should expect to find both "Invalidating analysis: AAManager" and
"Invalidating analysis: MemoryDependenceAnalysis" in the output.

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

16 months ago[libunwind][AArch64] Unbreak building with GNU assembler
Xi Ruoyao [Fri, 17 Mar 2023 08:27:41 +0000 (09:27 +0100)]
[libunwind][AArch64] Unbreak building with GNU assembler

GNU assembler mandates armv8.5-a for memtag instructions. Maybe
we should remove this restriction in GNU assembler, but let's work
around it for current GNU Binutils releases.

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

16 months agoMake globals used for array initialization codegen constant
Hans Wennborg [Thu, 16 Mar 2023 10:23:31 +0000 (11:23 +0100)]
Make globals used for array initialization codegen constant

As pointed out in D133835 these globals will never be written to
(they're only used for trivially copyable types), so they can always be
constant.

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

16 months ago[NFC] [C++20] [Modules] Tests that the duplicated declarations in GMF
Chuanqi Xu [Fri, 17 Mar 2023 07:53:24 +0000 (15:53 +0800)]
[NFC] [C++20] [Modules] Tests that the duplicated declarations in GMF
won't get generated again

As the test shows, we don't want to see the specialized function bodies
if it is already contained in the imported modules. So we can save a lot
of compiling time then.

16 months ago[Target][RISCV] Update SubtargetFeature definition for RV32/RV64 (NFCI).
Francesco Petrogalli [Wed, 15 Mar 2023 12:09:03 +0000 (13:09 +0100)]
[Target][RISCV] Update SubtargetFeature definition for RV32/RV64  (NFCI).

This is done for consistency with other Predicate/Subtargetfeature
pairs, where the second parameter of the SubtargetFeature correspond
to the NAME of the def of the Predicate associated to the
SubtargetFeature.

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

16 months ago[Tools] Changed the number printing format for sorting
dbakunevich [Tue, 7 Mar 2023 10:34:00 +0000 (17:34 +0700)]
[Tools] Changed the number printing format for sorting

As part of this patch, I added the ability to add leading zeros.
This is necessary so that the generated files are sorted in ascending order.

Reviewed By: yrouban

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

16 months ago[X86][MC]Fix wrong action for encode movdir64b
Wang, Xin10 [Fri, 17 Mar 2023 07:19:51 +0000 (03:19 -0400)]
[X86][MC]Fix wrong action for encode movdir64b

Movdir64b is special for its mem operand, 67 prefex can not only modify its add size,
so it's mem base and index reg should be the same type as source reg, such as
movdir64b (%rdx), rcx, and could not be movdir64b (%edx), rcx.
Now llvm-mc can encode the asm 'movdir64b (%edx), rcx' but the result is the same as
'movdir64b (%edx), ecx', which offend users' intention, while gcc will object this
action and give a warning.
I add 3 new mem descriptions to let llvm-mc to report the same error.

Reviewed By: skan, craig.topper

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

16 months ago[flang] Feature list plugin
Ethan Luis McDonough [Fri, 17 Mar 2023 07:26:51 +0000 (02:26 -0500)]
[flang] Feature list plugin

Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

> One thing we need...is a way to determine what features a code uses. Preferably we would also be able to determine if they are implemented or not. Just the former could be done with a visitor for the parse tree. For the latter we would continue compilation and somehow ignore todo errors but collect them - @jdoerfert

Reviewed By: jdoerfert

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

16 months ago[compiler-rt] Avoid signed overflow in floatdidf.c and floatdisf.c
Karl-Johan Karlsson [Fri, 17 Mar 2023 06:28:38 +0000 (07:28 +0100)]
[compiler-rt] Avoid signed overflow in floatdidf.c and floatdisf.c

When compiling compiler-rt with -fsanitize=undefined and running testcases you
end up with the following warning:

UBSan: floatdisf.c:27:15: signed integer overflow: 9223372036854775807 - -1 cannot be represented in type 'di_int' (aka 'long long')

This can be avoided by doing the subtraction in a matching unsigned variant of
the type, given that the overflow is the expected result of the subtraction.

The same kind of pattern exists in floatdidf.c

This was found in an out of tree target.

Reviewed By: phosek

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

16 months ago[Modules] [doc] Document the problem that we can't include headers before import...
Chuanqi Xu [Fri, 17 Mar 2023 07:10:26 +0000 (15:10 +0800)]
[Modules] [doc] Document the problem that we can't include headers before import declarations

16 months ago[X86]add assert to confirm not-null ptr in getArithmeticReductionCost
Wang, Xin10 [Fri, 17 Mar 2023 06:16:58 +0000 (02:16 -0400)]
[X86]add assert to confirm not-null ptr in getArithmeticReductionCost

For the function getArithmeticReductionCost, it receive a ptr and dereferce it without check,
It is called many times in getTypeBasedIntrinsicInstrCost, the ptr passed to it is inited
from line 1709.

From the code, we can not ensure the ptr VecOpTy is inited when Tys is empty or Tys[VecTyIndex]
is not a VectorType, so that the getArithmeticReductionCost will do an undefined behavior.

I add assert to it, found the ptr passed to it in llvm tests are all not nullptr, but I think the check is
still meaningful for us.

Reviewed By: RKSimon

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

16 months agoRevert "[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding...
Vitaly Buka [Fri, 17 Mar 2023 06:13:32 +0000 (23:13 -0700)]
Revert "[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table"

X86FoldTablesEmitter.cpp:386:26: runtime error: shift exponent -1 is negative

This reverts commit ca4c5331823755d5f7ae28a8bcaaa0fed21cf762.

16 months agoRemove the outdated feature macro '__cpp_coroutines'
Chuanqi Xu [Fri, 17 Mar 2023 05:37:51 +0000 (13:37 +0800)]
Remove the outdated feature macro '__cpp_coroutines'

The feature macro '__cpp_coroutines' is for coroutines TS. And the
coroutines TS is deprecated. So we should remove the feature macro too.

BTW, the corresponding feature macro for standard c++ coroutines is
'__cpp_impl_coroutine'.

16 months agoRecommit "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."
Craig Topper [Fri, 17 Mar 2023 04:37:35 +0000 (21:37 -0700)]
Recommit "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."

Remove use of constexpr if that failed on the build bots.

Original commit message:

It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.

16 months ago[X86] Remove unreachable code in X86TargetTransformInfo.cpp
Wang, Xin10 [Fri, 17 Mar 2023 02:55:08 +0000 (22:55 -0400)]
[X86] Remove unreachable code in X86TargetTransformInfo.cpp

In Function getVectorInstrCost, situation Opcode == Instruction::ExtractElement
and Opcode == Instruction::InsertElement are all handled in the first 2 if-statements,
So we have no chance for the code in line 4401.

Reviewed By: RKSimon

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

16 months ago[libcxx] Add status paper for Parallelism-TS
Zhangyin [Thu, 9 Mar 2023 06:14:43 +0000 (14:14 +0800)]
[libcxx] Add status paper for Parallelism-TS

Reviewed By: #libc, philnik, Mordante

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

16 months agoAttributor: Start inferring nofpclass
Matt Arsenault [Fri, 24 Feb 2023 14:57:39 +0000 (10:57 -0400)]
Attributor: Start inferring nofpclass

Some of this is boilerplate which doesn't do anything yet.

16 months agoValueTracking: Extract fcmpToClassTest out of InstCombine
Matt Arsenault [Fri, 3 Mar 2023 14:12:23 +0000 (10:12 -0400)]
ValueTracking: Extract fcmpToClassTest out of InstCombine

Also update unsigned to FPClassTest

16 months agoValueTracking: Handle nofpclass in computeKnownFPClass
Matt Arsenault [Fri, 24 Feb 2023 14:08:46 +0000 (10:08 -0400)]
ValueTracking: Handle nofpclass in computeKnownFPClass

16 months agoValueTracking: Add start of computeKnownFPClass API
Matt Arsenault [Wed, 1 Feb 2023 14:44:06 +0000 (10:44 -0400)]
ValueTracking: Add start of computeKnownFPClass API

Add a new compute-known-bits like function to compute all
the interesting floating point properties at once.

Eventually this should absorb all the various floating point
queries we already have.

16 months agoRevert "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."
Craig Topper [Fri, 17 Mar 2023 03:05:33 +0000 (20:05 -0700)]
Revert "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."

This reverts commit 10297470e953f4f3968c54c851c8af82b07af00b.

This is failing on a build bot.

16 months ago[RISCV] Add MULW to RISCVStripWSuffix.
Craig Topper [Fri, 17 Mar 2023 02:34:16 +0000 (19:34 -0700)]
[RISCV] Add MULW to RISCVStripWSuffix.

This converts MULW to MUL if the upper bits aren't used.
This will give more opportunities to use c.mul with Zcb.

16 months agoRevert "[LSAN][HWASAN] Turn on leak sanitizer in HWASAN for Linux"
Vitaly Buka [Fri, 17 Mar 2023 02:16:16 +0000 (19:16 -0700)]
Revert "[LSAN][HWASAN] Turn on leak sanitizer in HWASAN for Linux"

Breaks x86_64 qemu tests.

This reverts commit 6c756486d44914bac6fb20513b8c41f1a5726c4c.

16 months agoRevert "[AMDGPUUnifyDivergentExitNodes] Add NewPM support"
Vitaly Buka [Fri, 17 Mar 2023 02:03:46 +0000 (19:03 -0700)]
Revert "[AMDGPUUnifyDivergentExitNodes] Add NewPM support"

Introduces nullptr dereference.

This reverts commit a5455e32b364dabe499ec11722626d4bbaf047ba.

16 months ago[libc][Obvious] Reduce the size of the tests for hypot(f).
Tue Ly [Fri, 17 Mar 2023 01:17:20 +0000 (21:17 -0400)]
[libc][Obvious] Reduce the size of the tests for hypot(f).

16 months ago[Sema] Fix null pointer dereference handleAlwaysInlineAttr.
Craig Topper [Thu, 16 Mar 2023 22:52:39 +0000 (15:52 -0700)]
[Sema] Fix null pointer dereference handleAlwaysInlineAttr.

It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.

Reviewed By: erichkeane

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

16 months ago[runtimes] Synchronize warnings flags between libc++/libc++abi/libunwind
Nikolas Klauser [Fri, 17 Feb 2023 10:31:41 +0000 (11:31 +0100)]
[runtimes] Synchronize warnings flags between libc++/libc++abi/libunwind

This mostly keeps the same warning flags. The most important exceptions are `-Wpedantic` and `-Wconversion`, which are now removed from libc++abi and libunwind.

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

Spies: mikhail.ramalho, phosek, libcxx-commits

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

16 months agoRemove #if guards from AppendBounds to fix compile on old POSIX.
Daniel Thornburgh [Thu, 16 Mar 2023 23:15:38 +0000 (16:15 -0700)]
Remove #if guards from AppendBounds to fix compile on old POSIX.

16 months ago[AMDGPU] Simplify AGPR reservation. NFC.
Stanislav Mekhanoshin [Thu, 16 Mar 2023 23:14:02 +0000 (16:14 -0700)]
[AMDGPU] Simplify AGPR reservation. NFC.

The intent of the code was to reserve all AGPRs on a target without
AGPRs, so just do exactly that. Existing code was unsound.

16 months ago[mlir][transform] change RaggedArray internals
Alex Zinenko [Thu, 16 Mar 2023 16:58:53 +0000 (16:58 +0000)]
[mlir][transform] change RaggedArray internals

Change the internal storage scheme from storing a MutableArrayRef to
storing an explicit offset+length pair. Storing an ArrayRef is dangerous
because it contains the pointer to the first element in the range, but
the entire storage vector may be reallocated, making the pointer
dangling. We don't know when the reallocation happends, so we can't
update the ArrayRefs. Store the explicit offset instead and construct
ArrayRefs on-the-fly.

Reviewed By: Peiming

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

16 months ago[TableGen] Fix test on macOS
Shoaib Meenai [Thu, 16 Mar 2023 22:43:36 +0000 (15:43 -0700)]
[TableGen] Fix test on macOS

macOS cmp requires the option to appear before the file names.

16 months ago[clang] Unconditionally add autolink hints for frameworks.
Juergen Ributzka [Thu, 16 Mar 2023 22:28:48 +0000 (15:28 -0700)]
[clang] Unconditionally add autolink hints for frameworks.

Clang infers framework autolink hints when parsing a modulemap. In order to do
so, it checks if the module is a framework and if there is a framework binary
or TBD file in the SDK. Only when Clang finds the filei, then the autolink hint
is added to the module metadata.

During a project build many clang processes perform this check, which causes
many stat calls - even for modules/frameworks that are not even used.

The linker is already resilient to non-existing framework links that come from
the autolink metadata, so there is no need for Clang to do this check.

Instead the autolink hints are now added unconditionally and the linker only
needs to do the check once. This reduces the overall number of stat calls.

This fixes rdar://106578342.

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

16 months ago[lldb] Make MemoryCache::Read more resilient
Alex Langford [Tue, 7 Mar 2023 18:12:14 +0000 (10:12 -0800)]
[lldb] Make MemoryCache::Read more resilient

MemoryCache::Read is not resilient to partial reads when reading memory
chunks less than or equal in size to L2 cache lines. There have been
attempts in the past to fix this but nothing really solved the root of
the issue.

I first created a test exercising MemoryCache's implementation and
documenting how I believe MemoryCache::Read should behave. I then
rewrote the implementation of MemoryCache::Read as needed to make sure
that the different scenarios behaved correctly.

rdar://105407095

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

16 months ago[RISCV] Remove ExtName from RISCVExtensionInfo.
Craig Topper [Thu, 16 Mar 2023 22:20:25 +0000 (15:20 -0700)]
[RISCV] Remove ExtName from RISCVExtensionInfo.

This field is never used in the compiler and was only used in
unit tests added recently.

It's only used as the value in a map where the extension name
is the key. If we need the string we can get it from the key.

Reviewed By: asb

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

16 months agoMark test added in D145155 as requiring asserts since it uses the "-debug-only" option.
Douglas Yung [Thu, 16 Mar 2023 22:01:58 +0000 (15:01 -0700)]
Mark test added in D145155 as requiring asserts since it uses the "-debug-only" option.

This should fix the test failure in Release builds.

16 months ago[mlir][StorageUniquer] Use allocators per thread instead of per shard
River Riddle [Tue, 14 Mar 2023 00:32:10 +0000 (17:32 -0700)]
[mlir][StorageUniquer] Use allocators per thread instead of per shard

This greatly reduces the number of allocators we create, while still
retaining thread safety. Reducing the number of allocators is much
better for locality and memory usage; this revision drops memory
usage for some MLIR heavy workloads (with lots of attributes/types)
by >=5%. This is due to the observation that the number of threads
is effectively always smaller than the number of parametric attributes/types.

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

16 months ago[Inliner] clang-format InlineCost.cpp and Inliner.cpp (NFC)
Kazu Hirata [Thu, 16 Mar 2023 21:55:28 +0000 (14:55 -0700)]
[Inliner] clang-format InlineCost.cpp and Inliner.cpp (NFC)

16 months ago[HWASAN] Remove RUN statements, which have to effect on the test
Kirill Stoimenov [Thu, 16 Mar 2023 21:50:59 +0000 (21:50 +0000)]
[HWASAN] Remove RUN statements, which have to effect on the test

16 months ago[LSR] Add tests which demonstrate miscompiles in the current term-fold code
Philip Reames [Thu, 16 Mar 2023 21:03:27 +0000 (14:03 -0700)]
[LSR] Add tests which demonstrate miscompiles in the current term-fold code