platform/upstream/llvm.git
2 years ago[LangRef] Limit readnone,read/writeonly to memory visible outside the fn
Florian Hahn [Mon, 25 Apr 2022 10:32:50 +0000 (11:32 +0100)]
[LangRef] Limit readnone,read/writeonly to memory visible outside the fn

This patch unifies the wording used for readnone, readonly and writeonly
attributes. The definitions now more specifically refer to memory visible
outside the function

The motivation for the clarification is D123473.

Reviewed By: nlopes

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

2 years ago[gn build] Port 042dc3c46d73
LLVM GN Syncbot [Mon, 25 Apr 2022 10:26:57 +0000 (10:26 +0000)]
[gn build] Port 042dc3c46d73

2 years ago[mlir][LLVM] Support opaque pointers in `llvm.mlir.addressof`
Markus Böck [Mon, 25 Apr 2022 10:23:09 +0000 (12:23 +0200)]
[mlir][LLVM] Support opaque pointers in `llvm.mlir.addressof`

The verifier of llvm.mlir.addressof did not properly account for opaque pointers, that is, the pointer type not having an element type equal to the type of the referenced global or function. This patch fixes that by skipping the test for the element type if the pointer is opaque.

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

2 years ago[libc++] add zip_view and views::zip for C++23
Hui Xie [Mon, 25 Apr 2022 10:18:54 +0000 (12:18 +0200)]
[libc++] add zip_view and views::zip for C++23

- add zip_view and views::zip for C++23
- added unit tests
- implemented section 5.6 (zip) in P2321R2

I used clang-format to format the files but they look nothing like the rest of the code base. Manually indenting each line to match the styles sounds like an impossible task. Is there any clang-format file which can format it reasonable similar to the rest of the code base so that I can manually format the rest lines that look weird?

Reviewed By: ldionne, #libc, philnik, var-const

Spies: Mordante, philnik, libcxx-commits, mgorny

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

2 years ago[InstCombine] Add tests for X + Y - 1 u< X (NFC)
Nikita Popov [Mon, 25 Apr 2022 10:20:56 +0000 (12:20 +0200)]
[InstCombine] Add tests for X + Y - 1 u< X (NFC)

2 years ago[Test] Simplify test for PR55072
Max Kazantsev [Mon, 25 Apr 2022 10:20:08 +0000 (17:20 +0700)]
[Test] Simplify test for PR55072

2 years ago[Serialization] write expr dependence bits as a single integer
Sam McCall [Fri, 22 Apr 2022 12:00:36 +0000 (14:00 +0200)]
[Serialization] write expr dependence bits as a single integer

When exprs are written unabbreviated:
  - these were encoded as 5 x vbr6 = 30 bits
  - now they fit exactly into a one-chunk vbr = 6 bits

clangd --check=clangd/AST.cpp reports ~1% reduction in PCH size
(42826720->42474460)

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

2 years ago[mlir][vector] insert `alloca`s outside of loops
Alex Zinenko [Mon, 25 Apr 2022 08:25:59 +0000 (10:25 +0200)]
[mlir][vector] insert `alloca`s outside of loops

After https://reviews.llvm.org/D119743 added the `AutomaticAllocationScope`
trait to loop-like constructs, the vector transfer full/partial splitting pass
started inserting allocations for temporaries within the closest loop rather
than the closest function (or other allocation scope such as `async.execute`).
While this is correct as long as the lowered code takes care of automatic
deallocation at the end of each iteration of the loop, this interferes with
downstream optimizations that expect `alloca`s to be at the function level.
Step over loops when looking for the closest allocation scope in vector
transfer full/partial splitting pass thus restoring the original behavior.

Reviewed By: hanchung

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

2 years ago[MemorySSA] Use -simple-loop-unswitch instead of -loop-unswitch in test.
Florian Hahn [Mon, 25 Apr 2022 08:22:45 +0000 (09:22 +0100)]
[MemorySSA] Use -simple-loop-unswitch instead of -loop-unswitch in test.

2 years ago[runtimes] [CMake] Rename a cmake variable missed in b3df14b6c98702ce50401fd039852787...
Martin Storsjö [Mon, 25 Apr 2022 06:03:00 +0000 (09:03 +0300)]
[runtimes] [CMake] Rename a cmake variable missed in b3df14b6c98702ce50401fd039852787373e4676

This was missed as this check only is executed if linking doesn't
work without it.

2 years ago[Test] Add test for PR55072
Max Kazantsev [Mon, 25 Apr 2022 08:18:51 +0000 (15:18 +0700)]
[Test] Add test for PR55072

2 years ago[MemorySSA] Generate check lines for test.
Florian Hahn [Mon, 25 Apr 2022 08:02:42 +0000 (09:02 +0100)]
[MemorySSA] Generate check lines for test.

This is to ensure we produce the same code when switching to
SimpleLoopUnswitch.

2 years ago[mlir][Bazel] Add missing dependencies.
Adrian Kuegel [Mon, 25 Apr 2022 07:16:16 +0000 (09:16 +0200)]
[mlir][Bazel] Add missing dependencies.

When building with layering_check enabled, there needs to be a
dependency for each header include.

2 years ago[flang] fix LBOUND lowering with KIND and no DIM arguments
Jean Perier [Mon, 25 Apr 2022 07:20:07 +0000 (09:20 +0200)]
[flang] fix LBOUND lowering with KIND and no DIM arguments

The lowering code was mistakenly assuming that the second argument
in the signature provided by semantics is the DIM argument. This
caused calls with a KIND argument but no DIM to be lowered as if the
KIND argument was DIM.

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

2 years ago[mlir][LLVM] Support opaque pointers in data layout entries
Markus Böck [Mon, 25 Apr 2022 07:14:18 +0000 (09:14 +0200)]
[mlir][LLVM] Support opaque pointers in data layout entries

This is likely preferable to having it crash if one were to specify an opaque pointer type, and the actual element type is unused either way.

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

2 years agoFix an issue in comment. NFC
Jun Zhang [Mon, 25 Apr 2022 04:43:49 +0000 (12:43 +0800)]
Fix an issue in comment. NFC

I think the author renamed the function but forgot to update the
comment.
Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[OpenMP][IRBuilder] Handle unexcuted EXPECT_FALSE
Shraiysh Vaishay [Mon, 25 Apr 2022 02:53:58 +0000 (08:23 +0530)]
[OpenMP][IRBuilder] Handle unexcuted EXPECT_FALSE

This patch addresses the comment about unexecuted test in D122371.

Reviewed By: probinson

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

2 years ago[InstCombine] Complete folding of fneg-of-fabs
Chenbing Zheng [Mon, 25 Apr 2022 01:48:43 +0000 (09:48 +0800)]
[InstCombine] Complete folding of fneg-of-fabs

This patch add a function foldSelectWithFCmpToFabs, and do more combine for
fneg-of-fabs.
With 'nsz':
fold (X <  +/-0.0) ? X : -X or (X <= +/-0.0) ? X : -X to -fabs(x)
fold (X >  +/-0.0) ? X : -X or (X >= +/-0.0) ? X : -X to -fabs(x)

Reviewed By: spatel

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

2 years ago[libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD
Brad Smith [Mon, 25 Apr 2022 01:45:49 +0000 (21:45 -0400)]
[libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD

Reviewed By: ldionne, emaste, dim

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

2 years ago[clang-format] Refactor determineStarAmpUsage NFC
sstwcw [Sun, 24 Apr 2022 22:30:22 +0000 (22:30 +0000)]
[clang-format] Refactor determineStarAmpUsage NFC

There was some duplicate code in determineStarAmpUsage and
determinePlusMinusCaretUsage

Now a `-` or `+` following `;`, `sizeof`, `co_await`, or `delete` is
regarded as a unary operator.

Now a `*` or `&` following `case` is also a unary operator.

Reviewed By: curdeius, MyDeveloperDay, HazardyKnusperkeks

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

2 years agoMove test/.gitattributes to clang-tools-extra/test
Aaron Puchert [Sun, 24 Apr 2022 20:30:25 +0000 (22:30 +0200)]
Move test/.gitattributes to clang-tools-extra/test

It was probably accidentally added there, see the discussion on change
D97625. It is certainly without effect, to quote gitattributes(5):

    When deciding what attributes are assigned to a path, Git consults
    [...], `.gitattributes` file in the same directory as the path in
    question, and its parent directories up to the toplevel of the work
    tree [...]

Running `git check-attr -a` on the files in question shows that now the
settings are indeed effective whereas before they were not.

Lastly, lit ignores the file like any dotfile, see getTestsInDirectory
of FileBasedTest in llvm/utils/lit/lit/formats/base.py. This can be
verified with `llvm-lit --show-tests clang-tools-extra/test`.

2 years ago[flang] Do not create arith.extui with same from/to type
Valentin Clement (バレンタイン クレメン) [Sun, 24 Apr 2022 18:37:27 +0000 (20:37 +0200)]
[flang] Do not create arith.extui with same from/to type

In some case the lowering of `ichar` is generating an `arith.extui` operation
with the same from/to type. This operation do not accept from/to types to be
the same. If the from/to types are identical, we do not generate the extra
operation.

Reviewed By: jeanPerier

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

2 years agorun-clang-tidy: Fix infinite loop on windows
Jonas Toth [Sun, 24 Apr 2022 15:16:36 +0000 (17:16 +0200)]
run-clang-tidy: Fix infinite loop on windows

`find_compilation_database` checked only for "/" as exit point, but on Windows, this root is impossible.
Fixes #53642

Authored By: Febbe
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D119481

2 years agollvm-reduce: Don't delete triple/datalayout
Matt Arsenault [Sun, 17 Apr 2022 14:15:16 +0000 (10:15 -0400)]
llvm-reduce: Don't delete triple/datalayout

Removing these is extremely unhelpful and just adds extra hassle. This
is really finding out whether your test script uses -mtriple or
not. You can't meaningfully delete these fields, and the resulting
module defaults to the host.

2 years ago[runtimes] [CMake] Unify variable names
Petr Hosek [Thu, 10 Mar 2022 09:47:09 +0000 (11:47 +0200)]
[runtimes] [CMake] Unify variable names

Avoid repeating CMake checks across runtimes by unifying names of
variables used for results to leverage CMake caching.

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

2 years ago[InstCombine] Add test for fold fcmp-of-copysign. nfc
Chenbing Zheng [Sun, 24 Apr 2022 09:26:15 +0000 (17:26 +0800)]
[InstCombine] Add test for fold fcmp-of-copysign. nfc

Add more tests with differert predicates.

2 years ago[analyzer] Add option for AddrSpace in core.NullDereference check
Vince Bridgers [Fri, 8 Apr 2022 11:17:14 +0000 (06:17 -0500)]
[analyzer] Add option for AddrSpace in core.NullDereference check

    This change adds an option to detect all null dereferences for
    non-default address spaces, except for address spaces 256, 257 and 258.
    Those address spaces are special since null dereferences are not errors.

    All address spaces can be considered (except for 256, 257, and 258) by
    using -analyzer-config
    core.NullDereference:DetectAllNullDereferences=true. This option is
    false by default, retaining the original behavior.

    A LIT test was enhanced to cover this case, and the rst documentation
    was updated to describe this behavior.

Reviewed By: steakhal

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

2 years ago[RISCV] Add sched to pseudo function call instructions
wangpc [Sun, 24 Apr 2022 06:55:54 +0000 (14:55 +0800)]
[RISCV] Add sched to pseudo function call instructions

To fix llvm-mca's error of 'found an unsupported instruction
in the input assembly sequence.' caused by the lack of
scheduling info.

Pseudo function call instructions will be expanded to `auipc`
and `jalr`, so their scheduling info are the combination of
two.

Reviewed By: craig.topper

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

2 years ago[NFC][Clang][Pragma] Remove unused variables
Senran Zhang [Sun, 24 Apr 2022 02:49:58 +0000 (10:49 +0800)]
[NFC][Clang][Pragma] Remove unused variables

Reviewed By: beanz

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

2 years ago[OCaml][DebugInfo] Add bindings for parameter and auto variable creation
Vaivaswatha Nagaraj [Sun, 24 Apr 2022 04:07:04 +0000 (09:37 +0530)]
[OCaml][DebugInfo] Add bindings for parameter and auto variable creation

This patch extends https://reviews.llvm.org/D90831 with a few more
functions added to the OCaml debuginfo bindings.

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

2 years ago[lld/mac] For catalyst outputs, tolerate implicitly linking against mac-only tbd...
Nico Weber [Fri, 22 Apr 2022 15:55:50 +0000 (11:55 -0400)]
[lld/mac] For catalyst outputs, tolerate implicitly linking against mac-only tbd files

Before this,

  clang empty.cc -target x86_64-apple-ios13.1-macabi \
      -framework CoreServices -fuse-ld=lld

would error out with

    ld64.lld: error: path/to/MacOSX.sdk/System/Library/Frameworks/
         CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
         Versions/A/CarbonCore.tbd(
             /System/Library/Frameworks/
             CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
             Versions/A/CarbonCore) is incompatible with x86_64 (macCatalyst)

Now it works, like with ld64.

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

2 years ago[InlineCost] Set LastCallToStaticBonus in ML inlining models.
Jun Ma [Fri, 22 Apr 2022 07:08:01 +0000 (15:08 +0800)]
[InlineCost] Set LastCallToStaticBonus in ML inlining models.

This patch set LastCallToStaticBonus based on check, it has
no noticeable size reduction on an internal workload and linux kernel
with Os/Oz.

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

2 years agoRevert "[mlir][sparse] Expose SpareTensor passes as enums instead of opaque numbers...
Nick Kreeger [Sun, 24 Apr 2022 01:14:48 +0000 (20:14 -0500)]
Revert "[mlir][sparse] Expose SpareTensor passes as enums instead of opaque numbers for vectorization and parallelization options."

This reverts commit d59cf901cbae7991f7847eb038d825efff1221ad.

Build fails on NVIDIA Sparse tests:
https://lab.llvm.org/buildbot/#/builders/61/builds/25447

2 years agoReverting accidental git-revert commits.
Nick Kreeger [Sun, 24 Apr 2022 01:12:15 +0000 (20:12 -0500)]
Reverting accidental git-revert commits.

Revert "Revert "Revert "Revert "[Concepts] Fix overload resolution bug with constrained candidates""""

This reverts commit cfc2c5905ec11a501cdfc9502f503ab494c200b6.

2 years agoReverting accidental git-revert commits.
Nick Kreeger [Sun, 24 Apr 2022 01:11:58 +0000 (20:11 -0500)]
Reverting accidental git-revert commits.

Revert "Revert "Revert "[Concepts] Fix overload resolution bug with constrained candidates"""

This reverts commit a0636b5855f5ba1f7033670dc32c956d63baaa51.

2 years agoReverting accidental git-revert commits.
Nick Kreeger [Sun, 24 Apr 2022 01:11:27 +0000 (20:11 -0500)]
Reverting accidental git-revert commits.

Revert "Revert "[Concepts] Fix overload resolution bug with constrained candidates""

This reverts commit f6af446b6625657b1b9046273f5b33bc1173a97c.

2 years agoRevert "Revert "Revert "[Concepts] Fix overload resolution bug with constrained candi...
Nick Kreeger [Sun, 24 Apr 2022 00:36:51 +0000 (19:36 -0500)]
Revert "Revert "Revert "[Concepts] Fix overload resolution bug with constrained candidates"""

This reverts commit a0636b5855f5ba1f7033670dc32c956d63baaa51.

2 years agoRevert "Revert "[Concepts] Fix overload resolution bug with constrained candidates""
Nick Kreeger [Sun, 24 Apr 2022 00:35:50 +0000 (19:35 -0500)]
Revert "Revert "[Concepts] Fix overload resolution bug with constrained candidates""

This reverts commit f6af446b6625657b1b9046273f5b33bc1173a97c.

2 years agoRevert "[Concepts] Fix overload resolution bug with constrained candidates"
Nick Kreeger [Sun, 24 Apr 2022 00:35:41 +0000 (19:35 -0500)]
Revert "[Concepts] Fix overload resolution bug with constrained candidates"

This reverts commit 807e418413a0958ad1ea862093fb262673b2afa1.

2 years ago[mlir][sparse] Expose SpareTensor passes as enums instead of opaque numbers for vecto...
Nick Kreeger [Sun, 24 Apr 2022 00:16:57 +0000 (19:16 -0500)]
[mlir][sparse] Expose SpareTensor passes as enums instead of opaque numbers for vectorization and parallelization options.

The SparseTensor passes currently use opaque numbers for the CLI, despite using an enum internally. This patch exposes the enums instead of numbered items that are matched back to the enum.

Fixes GitHub issue #53389

Reviewed by: aartbik, mehdi_amini

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

2 years ago[Concepts] Fix overload resolution bug with constrained candidates
Roy Jacobson [Fri, 15 Apr 2022 15:58:11 +0000 (11:58 -0400)]
[Concepts] Fix overload resolution bug with constrained candidates

When doing overload resolution, we have to check that candidates' parameter types are equal before trying to find a better candidate through checking which candidate is more constrained.
This revision adds this missing check and makes us diagnose those cases as ambiguous calls when the types are not equal.

Fixes GitHub issue https://github.com/llvm/llvm-project/issues/53640

Reviewed By: erichkeane

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

2 years ago[hwasan][test] Change -hwasan to -passes=hwasan
Fangrui Song [Sat, 23 Apr 2022 21:07:31 +0000 (14:07 -0700)]
[hwasan][test] Change -hwasan to -passes=hwasan

With the -enable-new-pm defaulting to true, the two forms have the same effect,
but the previous form uses the legacy pass manager syntax which is being phased
out.

2 years ago[Bazel] Add more mlir dependencies after D124298
Fangrui Song [Sat, 23 Apr 2022 20:06:54 +0000 (13:06 -0700)]
[Bazel] Add more mlir dependencies after D124298

The Bazel layering_check feature compiles libraries with `-fmodule-name=X
-fmodules-strict-decluse` which require #include to be in deps.

2 years ago[Bazel] Make mlir:BufferizationDialect depend on mlir:ArithmeticDialect after D124298
Fangrui Song [Sat, 23 Apr 2022 19:59:37 +0000 (12:59 -0700)]
[Bazel] Make mlir:BufferizationDialect depend on mlir:ArithmeticDialect after D124298

2 years ago[analyzer] Clean checker options from bool to DefaultBool (NFC)
Vince Bridgers [Sun, 10 Apr 2022 12:44:11 +0000 (07:44 -0500)]
[analyzer] Clean checker options from bool to DefaultBool (NFC)

A recent review emphasized the preference to use DefaultBool instead of
bool for checker options. This change is a NFC and cleans up some of the
instances where bool was used, and could be changed to DefaultBool.

Reviewed By: steakhal

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

2 years ago[OpenMP] Use CUDA's non-RDC mode when LTO has whole program visibility
Joseph Huber [Fri, 22 Apr 2022 17:19:16 +0000 (13:19 -0400)]
[OpenMP] Use CUDA's non-RDC mode when LTO has whole program visibility

When we do LTO we consider ourselves to have whole program visibility if
every single input file we have contains LLVM bitcode. If we have whole
program visibliity then we can create a single image and utilize CUDA's
non-RDC mode by not passing `-c` to `ptxas` and ignoring the `nvlink`
job. This should be faster for some situations and also saves us the
time executing `nvlink`.

Reviewed By: tra

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

2 years ago[libc++] Fixes concepts overload resolution.
Mark de Wever [Wed, 20 Apr 2022 16:47:13 +0000 (18:47 +0200)]
[libc++] Fixes concepts overload resolution.

D123182 fixes a bug in Clang's overload resolution. After it landed it
was discovered `basic_format_arg`'s constructors contains this bug. This
fixes the bug in libc++, unblocking D123182.

The code has been tested in combination with D123182.

Reviewed By: royjacobson, #libc

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

2 years ago[BOLT][CMAKE] Simplify Clang/LLD identification
Amir Ayupov [Sat, 23 Apr 2022 16:16:53 +0000 (12:16 -0400)]
[BOLT][CMAKE] Simplify Clang/LLD identification

Refactor nested conditions. NFC

Reviewed By: maksfb

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

2 years agoRevert "[clang] Adding Platform/Architecture Specific Resource Header Installation...
Ye Luo [Sat, 23 Apr 2022 14:25:54 +0000 (09:25 -0500)]
Revert "[clang] Adding Platform/Architecture Specific Resource Header Installation Targets"

Caused build failure see github issue #55002

This reverts commit 2512a875ccac158bc9b654b09e3347db167e33df.

2 years ago[C++20][Modules][Driver][HU 4/N] Add fdirectives-only mode for preprocessing output.
Iain Sandoe [Fri, 31 Jul 2020 09:44:12 +0000 (10:44 +0100)]
[C++20][Modules][Driver][HU 4/N] Add fdirectives-only mode for preprocessing output.

When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

Thus it preserves macros that are still live after such processing.
This output can be consumed by a second compilation to produce a header unit.

We automatically invoke this (with -E) when we know that the job produces a
header unit so that the preprocessed output reflects the macros that will be
defined when the binary HU is emitted.

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

2 years ago[NFC] Sync code for upstreaming.
Eric Schweitz [Fri, 22 Apr 2022 20:57:21 +0000 (13:57 -0700)]
[NFC] Sync code for upstreaming.

Remove redundant code.

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

2 years ago[IndVarSimplify] Replace legacy loop-unswitch with SimpleLoopUnswitch.
Florian Hahn [Sat, 23 Apr 2022 13:08:47 +0000 (14:08 +0100)]
[IndVarSimplify] Replace legacy loop-unswitch with SimpleLoopUnswitch.

Also moves the test to use the new pass manager.

2 years ago[SimpleLoopUnswitch] Use SLU version of memoryssa-threshold option.
Florian Hahn [Sat, 23 Apr 2022 13:03:32 +0000 (14:03 +0100)]
[SimpleLoopUnswitch] Use SLU version of memoryssa-threshold option.

Update the test to use the SLU version of the option.

2 years ago[SCCP] Add initial tests for freeze.
Florian Hahn [Fri, 22 Apr 2022 21:23:21 +0000 (22:23 +0100)]
[SCCP] Add initial tests for freeze.

2 years ago[SCEV] Use getConstant to construct SCEV for ConstantInt (NFC).
Florian Hahn [Sat, 23 Apr 2022 10:12:58 +0000 (11:12 +0100)]
[SCEV] Use getConstant to construct SCEV for ConstantInt (NFC).

We already know that we will construct a SCEVConstant. Directly use
getConstant, rather than going through getSCEV.

2 years ago[mlir][bufferize][NFC] Remove old references to Comprehensive Bufferize
Matthias Springer [Sat, 23 Apr 2022 08:59:47 +0000 (17:59 +0900)]
[mlir][bufferize][NFC] Remove old references to Comprehensive Bufferize

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

2 years ago[mlir][bufferize][NFC] Clean up test cases
Matthias Springer [Sat, 23 Apr 2022 08:59:06 +0000 (17:59 +0900)]
[mlir][bufferize][NFC] Clean up test cases

Run `one-shot-bufferize` instead of `linalg-comprehensive-module-bufferize` and move some test cases to their respective dialects.

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

2 years ago[C++20][Modules][Driver][HU 3/N] Handle foo.h with -fmodule-header and/or C++ invocation.
Iain Sandoe [Thu, 18 Feb 2021 12:23:15 +0000 (12:23 +0000)]
[C++20][Modules][Driver][HU 3/N] Handle foo.h with -fmodule-header and/or C++ invocation.

Allow an invocation like clang -fmodule-header bar.h (which will be a C++
compilation, but using a header which will be recognised as a C one).

Also  we do not want to produce:
 "treating 'c-header' input as 'c++-header' when in C++ mode"
diagnostics when the user has been specific about the intent.

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

2 years ago[mlir][NFC] Shift a bunch of dialect includes from the .h to the .cpp
River Riddle [Fri, 22 Apr 2022 21:17:08 +0000 (14:17 -0700)]
[mlir][NFC] Shift a bunch of dialect includes from the .h to the .cpp

Now that dialect constructors are generated in the .cpp file, we can
drop all of the dependent dialect includes from the .h file.

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

2 years ago[mlir] Generate Dialect constructors in .cpp instead of .h
River Riddle [Fri, 22 Apr 2022 21:16:06 +0000 (14:16 -0700)]
[mlir] Generate Dialect constructors in .cpp instead of .h

By generating in the .h file, we were forcing dialects to include
a lot of additional header files because:

* Fields of the dialect, e.g. std::unique_ptr<>, were unable to use
  forward declarations.
* Dependent dialects are loaded in the constructor, requiring the
  full definition of each dependent dialect (which, depending on
  the file structure of the dialect, may include the operations).

By generating in the .cpp we get much faster builds, and also
better align with the rest of the code base.

Fixes #55044

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

2 years ago[clang][OpenMP][DebugInfo] Debug support for TLS variables present in OpenMP consruct
Alok Kumar Sharma [Thu, 14 Apr 2022 09:04:22 +0000 (14:34 +0530)]
[clang][OpenMP][DebugInfo] Debug support for TLS variables present in OpenMP consruct

In case of OpenMP programs, thread local variables can be present in
any clause pertaining to OpenMP constructs, as we know that compiler
generates artificial functions and in some cases values are passed to
those artificial functions thru parameters. For an example, if thread
local variable is present in copyin clause (testcase attached with the
patch), parameter with same name is generated as parameter to artificial
function. When user inquires the thread Local variable, its debug info
is hidden by the parameter. User never gets the actual TLS variable
when inquires it, instead gets the artificial parameter.

Current patch suppresses the debug info for such artificial parameter to
enable correct debugging of TLS variables.

Reviewed By: aprantl

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

2 years ago[test] Don't rely on default of detect_stack_use_after_return
Vitaly Buka [Sat, 23 Apr 2022 06:28:27 +0000 (23:28 -0700)]
[test] Don't rely on default of detect_stack_use_after_return

2 years agoRevert "[test] Don't rely on default of detect_stack_use_after_return"
Vitaly Buka [Sat, 23 Apr 2022 06:25:02 +0000 (23:25 -0700)]
Revert "[test] Don't rely on default of detect_stack_use_after_return"

Revent acidentally deleted lines.

This reverts commit ff25f694731f7b9fa33f2955e751f3ccb3c35afa.

2 years ago[NFC][LAA] Match-up type sizes for possible extensions, based on actual bit-size...
Chang-Sun Lin Jr [Sat, 23 Apr 2022 06:16:20 +0000 (23:16 -0700)]
[NFC][LAA] Match-up type sizes for possible extensions, based on actual bit-size rather than rounded-up byte size.

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

2 years ago[test] Don't rely on default of detect_stack_use_after_return
Vitaly Buka [Sat, 23 Apr 2022 02:08:56 +0000 (19:08 -0700)]
[test] Don't rely on default of detect_stack_use_after_return

2 years ago[ASan][test] Fix mismatched-new-delete in asan test unaligned_loads_and_stores.cpp
Enna1 [Sat, 23 Apr 2022 03:57:23 +0000 (11:57 +0800)]
[ASan][test] Fix mismatched-new-delete in asan test unaligned_loads_and_stores.cpp

Fix mismatched-new-delete in asan test unaligned_loads_and_stores.cpp

Reviewed By: vitalybuka, MaskRay

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

2 years ago[Driver] Call hasFlag instead of hasArg
Akira Hatanaka [Fri, 22 Apr 2022 23:48:38 +0000 (16:48 -0700)]
[Driver] Call hasFlag instead of hasArg

`_HAS_STATIC_RTTI` should be set to 0 only by `-fno-rtti` according to the
summary of https://reviews.llvm.org/D103771.

rdar://92039243

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

2 years ago[RISCV][test] Rename prefix and remove unused text (NFC)
Zakk Chen [Fri, 22 Apr 2022 03:01:54 +0000 (20:01 -0700)]
[RISCV][test] Rename prefix and remove unused text (NFC)

In D123418 we removed some RUN line (ex. RV32-ELEN16) but their
expected results still exist there.
Remove them and rename prefix for more descriptive.

Reviewed By: frasercrmck, asb, craig.topper

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

2 years ago[lld-macho] Remove stray debug printf
Jez Ng [Sat, 23 Apr 2022 02:17:24 +0000 (22:17 -0400)]
[lld-macho] Remove stray debug printf

Accidentally committed as part of b440c25742.

2 years agoRevert "[nfc][asan][windows] Fix test after D124057"
Vitaly Buka [Sat, 23 Apr 2022 02:10:08 +0000 (19:10 -0700)]
Revert "[nfc][asan][windows] Fix test after D124057"

The patch does not fix the bot.

This reverts commit 62b78a063ab1dc6c2df33c7a6582ecc62b31b519.

2 years ago[asan] Don't enable detect_stack_use_after_return on Windows
Vitaly Buka [Sat, 23 Apr 2022 02:09:52 +0000 (19:09 -0700)]
[asan] Don't enable detect_stack_use_after_return on Windows

It's not clear how ready it's there.

2 years ago[test] Don't rely on default of detect_stack_use_after_return
Vitaly Buka [Sat, 23 Apr 2022 02:08:56 +0000 (19:08 -0700)]
[test] Don't rely on default of detect_stack_use_after_return

2 years ago[SLP][NFC] Outline lookahead heuristics into a separate helper class.
Valery N Dmitriev [Sat, 23 Apr 2022 01:59:08 +0000 (18:59 -0700)]
[SLP][NFC] Outline lookahead heuristics into a separate helper class.

Minor refactoring to reduce size of functional change D124309:
  look-ahead scoring routines pulled out of VLOperands and formed
  new LookAheadHeuristics helper class.

Reviewed By: Alexey Bataev (ABataev), Vasileios Porpodas (vporpo)
Differential Revision: https://reviews.llvm.org/D124313

2 years agoRevert "Revert "[compiler-rt][Darwin] Add arm64 to simulator platforms""
Dan Liew [Sat, 23 Apr 2022 01:44:15 +0000 (18:44 -0700)]
Revert "Revert "[compiler-rt][Darwin] Add arm64 to simulator platforms""

This reverts commit 3469cb14e2316a1e3cf64db5be3738379d9daa8d.

Relanding the patch on behalf of Byoungchan Lee.

The original patch (8a3afc6da5bc94fcbac708156fc1cf4220e7d1f1) was
reverted because it appeared to be landed without the approval
of an Apple engineer.

After internal discussion we're happy for this to land and I've
formally approved the patch in phabricator
(https://reviews.llvm.org/D119174).

rdar://92134140

2 years ago[lld-macho] Allow dead_strip to work with exported private extern symbols
Vincent Lee [Thu, 21 Apr 2022 02:57:10 +0000 (19:57 -0700)]
[lld-macho] Allow dead_strip to work with exported private extern symbols

It seems like we are overly asserting when running `-dead_strip` with
exported symbols. ld64 treats exported private extern symbols as a liveness
root. Loosen the assert to match ld64's behavior.

Reviewed By: #lld-macho, int3

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

2 years ago[fixup] Handle enum constant `Lang_OBJC` introduced in 4604db94.
Volodymyr Sapsai [Sat, 23 Apr 2022 00:59:17 +0000 (17:59 -0700)]
[fixup] Handle enum constant `Lang_OBJC` introduced in 4604db94.

2 years ago[Index] Remove reference to `UnresolvedUsingIfExists`
Ben Barham [Fri, 22 Apr 2022 18:36:00 +0000 (11:36 -0700)]
[Index] Remove reference to `UnresolvedUsingIfExists`

Assuming `ns::foo` doesn't exist, given:
```
using ns::foo __attribute__((using_if_exists));
```

The AST will look something like:
UsingDecl
  UsingShadowDecl
    UnresolvedUsingIfExistsDecl

Thus we end up adding a reference to `UnresolvedUsingIfExistsDecl` when
processing `UsingDecl`, but never add the decl itself. In this case the
decl is really the `UsingDecl` anyway though (which we do output), so it
makes more sense to just remove the extra reference.

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

2 years ago[nfc][asan][android] Fix test after D124057
Vitaly Buka [Sat, 23 Apr 2022 00:16:11 +0000 (17:16 -0700)]
[nfc][asan][android] Fix test after D124057

2 years ago[nfc][asan][windows] Fix test after D124057
Vitaly Buka [Sat, 23 Apr 2022 00:09:47 +0000 (17:09 -0700)]
[nfc][asan][windows] Fix test after D124057

2 years agoRevert "[compiler-rt][Darwin] Add arm64 to simulator platforms"
Dan Liew [Fri, 22 Apr 2022 23:50:35 +0000 (16:50 -0700)]
Revert "[compiler-rt][Darwin] Add arm64 to simulator platforms"

This reverts commit 8a3afc6da5bc94fcbac708156fc1cf4220e7d1f1.

The commit being was landed without review from any Apple engineers
which is problematic because the patch only affects Apple platforms.

rdar://92134140

2 years ago[flang][runtime] Signal record read overrun when PAD='NO'
Peter Klausler [Tue, 19 Apr 2022 23:48:42 +0000 (16:48 -0700)]
[flang][runtime] Signal record read overrun when PAD='NO'

When PAD='NO' and ADVANCE='YES', we currently signal an input
error when a formatted read tries to go past the end of a record
only when a fixed RECL= is in effect.  Other compilers will signal
an error without RECL= too, and that seems like a precedent we
should follow.

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

2 years ago[flang][runtime] Enforce some limits on kP scale factors
Peter Klausler [Fri, 22 Apr 2022 21:21:51 +0000 (14:21 -0700)]
[flang][runtime] Enforce some limits on kP scale factors

Ew.d and Dw.d output edit descriptors should respect limitations from
the standard on the value of a kP scale factor with respect to the
digit count (d), at least for values of k other than zero.

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

2 years ago[ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.
Volodymyr Sapsai [Sat, 5 Mar 2022 01:33:48 +0000 (17:33 -0800)]
[ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

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

2 years ago[ELF] Drop unused original symbol after wrapping if not defined
Shoaib Meenai [Wed, 20 Apr 2022 04:45:54 +0000 (21:45 -0700)]
[ELF] Drop unused original symbol after wrapping if not defined

We were previously only omitting the original of a wrapped symbol if it
was not used by an object file and undefined. We can tighten the second
condition to drop any symbol that isn't defined instead, which lets us
drop a previous check (added in https://reviews.llvm.org/D118756) that
was only covering some such symbols.

Reviewed By: MaskRay

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

2 years ago[clang-tidy] Ignore macros defined within declarations
Richard [Sun, 17 Apr 2022 00:26:01 +0000 (18:26 -0600)]
[clang-tidy] Ignore macros defined within declarations

Modernize-macro-to-enum shouldn't try to convert macros to enums
when they are defined inside a declaration or definition, only
when the macros are defined at the top level.  Since preprocessing
is disconnected from AST traversal, match nodes in the AST and then
invalidate source ranges spanning AST nodes before issuing diagnostics.

ClangTidyCheck::onEndOfTranslationUnit is called before
PPCallbacks::EndOfMainFile, so defer final diagnostics to the
PPCallbacks implementation.

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

Fixes #54883

2 years ago[ELF] Fix wrapping symbols produced during LTO codegen
Shoaib Meenai [Wed, 20 Apr 2022 01:04:17 +0000 (18:04 -0700)]
[ELF] Fix wrapping symbols produced during LTO codegen

We were previously not correctly wrapping symbols that were only
produced during LTO codegen and unreferenced before then, or symbols
only referenced from such symbols. The root cause was that we weren't
marking the wrapped symbol as used if we only saw the use after LTO
codegen, leading to the failed wrapping.

Fix this by explicitly tracking whether a symbol will become referenced
after wrapping is done. We can use this property to tell LTO to preserve
such symbols, instead of overload isUsedInRegularObj for this purpose.
Since we're no longer setting isUsedInRegularObj for all symbols which
will be wrapped, its value at the time of performing the wrapping in the
symbol table will accurately reflect whether the symbol was actually
used in an object (including in an LTO-generated object), and we can
propagate that value to the wrapped symbol and thereby ensure we wrap
correctly.

This incorrect wrapping was the only scenario I was aware of where we
produced an invalid PLT relocation, which D123985 started diagnosing,
and with it fixed, we lose the test for that diagnosis. I think it's
worth keeping the diagnosis though, in case we run into other issues in
the future which would be caught by it.

Fixes PR50675.

Reviewed By: MaskRay

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

2 years ago[ELF] Move SymbolUnion assertions to source file
Shoaib Meenai [Tue, 19 Apr 2022 20:42:05 +0000 (13:42 -0700)]
[ELF] Move SymbolUnion assertions to source file

Otherwise they fires for every single file which includes the header,
which is very noisy when building.

Reviewed By: MaskRay, peter.smith

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

2 years ago[flang][runtime] Fix edge-case FP input bugs
Peter Klausler [Wed, 13 Apr 2022 16:56:42 +0000 (09:56 -0700)]
[flang][runtime] Fix edge-case FP input bugs

Blanks are allowed in more places than I allowed for, and
"NAN(foobar)" is allowed to have any parenthesis-balanced
characters in parentheses.

Update: Fix up old sanity test, then avoid usage of "limit" when null.

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

2 years ago[llvm][misexpect] Avoid division by 0 when using sample profiling
Paul Kirth [Fri, 22 Apr 2022 22:41:54 +0000 (22:41 +0000)]
[llvm][misexpect] Avoid division by 0 when using sample profiling

MisExpect diagnostics should not prevent compilation from succeeding, and the
assertion is insufficient to prevent division by zero in release builds.

This patch addresses that by replacing the assert with an early return.

Additionally, it disables MisExpect diagnostics when using sample profiling,
since this is the only known case where this error has manifested.

Reviewed By: tejohnson

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

2 years agoRecommit "[SLP][AArch64] Implement lookahead operand reordering score of splat loads...
Vasileios Porpodas [Fri, 22 Apr 2022 15:29:51 +0000 (08:29 -0700)]
Recommit "[SLP][AArch64] Implement lookahead operand reordering score of splat loads for AArch64"

This reverts commit 7052a0ad689b990265ec79bd2b0a7d6e8c131bfe.

2 years ago[libomptarget] Make omp_target_is_present checks storage instead of zero length array.
Ye Luo [Fri, 22 Apr 2022 22:36:59 +0000 (17:36 -0500)]
[libomptarget] Make omp_target_is_present checks storage instead of zero length array.

Consider checking whether a pointer has been mapped can be achieved via omp_get_mapped_ptr.
omp_target_is_present is more needed to check whether the storage being pointed is mapped.
This restore the old behavior of omp_target_is_present before D123093
Fixes https://github.com/llvm/llvm-project/issues/54899

Reviewed By: jdenny

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

2 years ago[Clang][OpenMP] libompd: get libomp hwloc includedir by target_link_libraries
Ye Luo [Fri, 22 Apr 2022 22:33:41 +0000 (17:33 -0500)]
[Clang][OpenMP] libompd: get libomp hwloc includedir by target_link_libraries

When hwloc is used and is installed outside of the default paths, the omp CMake target
needs to provide the needed include path thru the CMake target by adding it with
target_include_directories to it, so libompd gets it as well when it defines it's cmake
target using target_link_libraries.

As suggested in D122667

Reviewed By: ye-luo

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

2 years ago[asan] Enable detect_stack_use_after_return=1 by default
Vitaly Buka [Wed, 20 Apr 2022 01:31:13 +0000 (18:31 -0700)]
[asan] Enable detect_stack_use_after_return=1 by default

By default -fsanitize=address already compiles with this check,
why not use it.
For compatibly it can be disabled with env ASAN_OPTIONS=detect_stack_use_after_return=0.

Reviewed By: eugenis, kda, #sanitizers, hans

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

2 years agollvm-reduce: Fix cloning unset maxCallFrameSize
Matt Arsenault [Fri, 22 Apr 2022 20:31:08 +0000 (16:31 -0400)]
llvm-reduce: Fix cloning unset maxCallFrameSize

This was promoting an unset max call frame size to a max call frame
size of 0.

2 years agoProcessImplicitDefs: Use required properties instead of isSSA assert
Matt Arsenault [Fri, 22 Apr 2022 21:43:53 +0000 (17:43 -0400)]
ProcessImplicitDefs: Use required properties instead of isSSA assert

2 years ago[mlir][LLVM] Fix `DataLayoutTypeInterface` for opqaue pointers with non-default addre...
Markus Böck [Fri, 22 Apr 2022 22:10:02 +0000 (00:10 +0200)]
[mlir][LLVM] Fix `DataLayoutTypeInterface` for opqaue pointers with non-default address space

As a fallback mechanism, if no entry was supplied for a given address space, the size or alignment for a pointer type with the default address space is returned instead.
This code currently crashes with opaque pointers, as it tries to construct a typed pointer type from the opaque pointer type, leading to a null pointer dereference when fetching the element type.

This patch fixes the issue by handling the opaque pointer cases explicitly.

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

2 years ago[mlir][LLVM] Fix crash when using opaque pointers in function signatures
Markus Böck [Fri, 22 Apr 2022 22:09:27 +0000 (00:09 +0200)]
[mlir][LLVM] Fix crash when using opaque pointers in function signatures

Using opaque pointers in function signatures leads to an attempt to recursively convert all types, including sub types in LLVM types. In the case of LLVM pointers, it may not have a subtype aka element type if it is opaque which would then lead to a null pointer dereference.

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

2 years ago[Clang][OpenMP] Fix the issue that temp cubin files are not removed after compilation...
Shilei Tian [Fri, 22 Apr 2022 22:07:20 +0000 (18:07 -0400)]
[Clang][OpenMP] Fix the issue that temp cubin files are not removed after compilation when using new OpenMP driver

The root cause of this is, in `NVPTX::Assembler::ConstructJob`, the output file name might not match the `Output`'s file name passed into the function because `CudaToolChain::getInputFilename` is a specialized version. That means the real output file is not added to the temp files list, which will be all removed in the d'tor of `Compilation`. In order to "fix" it, in the function `NVPTX::OpenMPLinker::ConstructJob`, before calling `clang-nvlink-wrapper`, the function calls `getToolChain().getInputFilename(II)` to get the right output file name for each input, and add it to temp file, and then they can be removed w/o any issue. However, this whole logic doesn't work when using the new OpenMP driver because `NVPTX::OpenMPLinker::ConstructJob` is not called at all, which causing the issue that the cubin file generated in each single unit compilation is out of track.

In this patch, we add the real output file into temp files if its name doesn't match `Output`. We add it when the file is an output instead of doing it when it is an input, like what we did in `NVPTX::OpenMPLinker::ConstructJob`, which makes more sense.

Reviewed By: jhuber6

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

2 years agoFix CollapsedLayoutMap for dim size 1 case
Yi Zhang [Tue, 19 Apr 2022 00:50:30 +0000 (20:50 -0400)]
Fix CollapsedLayoutMap for dim size 1 case

This change fixes `CollapsedLayoutMap` for cases where the collapsed
dims are size 1. The cases where inner most dims are size 1 and
noncontiguous can be represented by the strided form and therefore can
be allowed. For such cases, the new stride should be of the next entry
in an association whose dimension is not size 1. If the next entry is
dynamic, it's not possible to decide which stride to use at compilation
time and the stride is set to dynamic.

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

2 years ago[SLP][NFC] Pre-commit test showing deficiency in current roots selection algorithm.
Valery N Dmitriev [Fri, 22 Apr 2022 21:47:02 +0000 (14:47 -0700)]
[SLP][NFC] Pre-commit test showing deficiency in current roots selection algorithm.

Test case to show not quite optimal SLP vectorization.

Reviewed By: Vasileios Porpodas (vporpo)
Differential Revision: https://reviews.llvm.org/D124293