platform/upstream/llvm.git
2 years agoFix clang-tidy readability-redundant-smartptr-get in MLIR ModuleTranslation.cpp ...
Mehdi Amini [Sat, 8 Jan 2022 20:06:50 +0000 (20:06 +0000)]
Fix clang-tidy readability-redundant-smartptr-get in MLIR ModuleTranslation.cpp (NFC)

2 years agoEnable readability-redundant-smartptr-get in MLIR local clang-tidy config
Mehdi Amini [Sat, 8 Jan 2022 19:23:16 +0000 (19:23 +0000)]
Enable readability-redundant-smartptr-get in MLIR local clang-tidy config

2 years ago[llvm] Remove redundant member initialization (NFC)
Kazu Hirata [Sat, 8 Jan 2022 19:56:44 +0000 (11:56 -0800)]
[llvm] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

2 years agoRemove duplicate forward declarations (NFC)
Kazu Hirata [Sat, 8 Jan 2022 19:56:42 +0000 (11:56 -0800)]
Remove duplicate forward declarations (NFC)

2 years ago[clang] Remove unused forward declarations (NFC)
Kazu Hirata [Sat, 8 Jan 2022 19:56:40 +0000 (11:56 -0800)]
[clang] Remove unused forward declarations (NFC)

2 years ago[llvm] Fix bugprone argument comments (NFC)
Kazu Hirata [Sat, 8 Jan 2022 19:56:38 +0000 (11:56 -0800)]
[llvm] Fix bugprone argument comments (NFC)

Identified with bugprone-argument-comment.

2 years ago[instcombine] Key deref vs deref_or_null annotation of allocation sites off nonnull...
Philip Reames [Sat, 8 Jan 2022 18:29:09 +0000 (10:29 -0800)]
[instcombine] Key deref vs deref_or_null annotation of allocation sites off nonnull attribute

Goal is to remove use of isOpNewLike.  I looked at a couple approaches to this, and this turned out to be the cheapest one.  Just letting deref_or_null be generated causes a bunch of test diffs, and I couldn't convince myself there wasn't a real regression somewhere.  A generic instcombine to convert deref_or_null + nonnull to deref is annoying complicated since you have to mix facts from callsite and declaration while manipulating only existing call site attributes.  It just wasn't worth the code complexity.

Note that the change in new-delete-itanium.ll is a real regression.  If you have a callsite which overrides the builtin status of a nobuiltin declaration, *and* you don't put the apppriate attributes on that callsite, you may lose the deref fact.  I decided this didn't matter; if anyone disagrees, you can add this case to the generic non-null inference.

2 years ago[libc++] [ranges] Add namespace __cpo to ranges::{advance,next,prev}.
Arthur O'Dwyer [Tue, 4 Jan 2022 01:49:24 +0000 (20:49 -0500)]
[libc++] [ranges] Add namespace __cpo to ranges::{advance,next,prev}.

The reason for those nested namespaces is explained in D115315:

> AIUI, this keeps the CPO's own type from ADL'ing into the `std::ranges`
> namespace; e.g. `foobar(std::ranges::uninitialized_default_construct)`
> should not consider `std::ranges::foobar` a candidate, even if
> `std::ranges::foobar` is not a CPO itself. Also, of course, consistency
> (Chesterton's Fence, the economist's hundred-dollar bill): if it were
> safe to omit the namespace, we'd certainly want to do it everywhere,
> not just here.

This makes these three niebloids more consistent with the other Ranges
niebloids we've already implemented, such as the `ranges::begin` group
and the `ranges::uninitialized_default_construct` group.

FWIW, we still have three different indentation-and-comment styles
among these three groups.

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

2 years agoRevert "[lldb] Set result error state in 'frame variable'"
Dave Lee [Sat, 8 Jan 2022 17:35:13 +0000 (09:35 -0800)]
Revert "[lldb] Set result error state in 'frame variable'"

This reverts commit 2c7d10c41278181e3e45c68f28b501cd95193a8a.

2 years ago[lldb] Set result error state in 'frame variable'
Dave Lee [Fri, 7 Jan 2022 03:38:31 +0000 (19:38 -0800)]
[lldb] Set result error state in 'frame variable'

Ensure that errors in `frame variable` are reflected in result object.

The statistics for `frame variable` show invocations as being successful, even
when executing one of the error paths.

This change replaces `result.GetErrorStream()` with `result.AppendError()`,
which also sets the status to `eReturnStatusFailed`.

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

2 years ago[CGObjCMac] Use castAs<> instead of getAs<> to avoid dereference of nullptr inside...
Simon Pilgrim [Sat, 8 Jan 2022 16:18:46 +0000 (16:18 +0000)]
[CGObjCMac] Use castAs<> instead of getAs<> to avoid dereference of nullptr inside BuildRCBlockVarRecordLayout

This will assert the cast is correct instead of returning nullptr (UnionType is a subtype of RecordType so this should be clean).

2 years ago[LSR] Auto-generate check lines for test.
Florian Hahn [Sat, 8 Jan 2022 15:44:52 +0000 (15:44 +0000)]
[LSR] Auto-generate check lines for test.

Checking the full output provides more context and makes it easier to
review changes to the test in a follow-up patch.

2 years ago[LoopUnroll] Make test more robust by removing undef.
Florian Hahn [Sat, 8 Jan 2022 15:43:30 +0000 (15:43 +0000)]
[LoopUnroll] Make test more robust by removing undef.

Replace a uses of undef in the tests. The undef causes runtime checks
to be trivially fold/removeable, which does defeat the purpose of the test.

2 years ago[LV] Make tests more robust by removing undef.
Florian Hahn [Fri, 7 Jan 2022 22:06:22 +0000 (22:06 +0000)]
[LV] Make tests more robust by removing undef.

Replace some uses of undef in the tests. The undef causes runtime checks
to be trivially fold/removeable, which does defeat the purpose of the tests.

2 years ago[X86] LowerRotate - enable ROTL vXi16 rotate-by-splat-amount on pre-AVX targets
Simon Pilgrim [Sat, 8 Jan 2022 14:57:00 +0000 (14:57 +0000)]
[X86] LowerRotate - enable ROTL vXi16 rotate-by-splat-amount on pre-AVX targets

To enable this on all targets there's still a number of regressions due to getSplatValue/getTargetVShiftNode but these don't really affect pre-AVX targets.

2 years ago[DivergenceAnalysis] Simplify inRegion test based on whether the RegionLoop pointer...
Simon Pilgrim [Sat, 8 Jan 2022 14:30:10 +0000 (14:30 +0000)]
[DivergenceAnalysis] Simplify inRegion test based on whether the RegionLoop pointer is null or not

More closely matches the documentation

Requested by @nikic

2 years ago[CGExpr] Use castAs<> instead of getAs<> to avoid dereference of nullptr
Simon Pilgrim [Sat, 8 Jan 2022 14:26:09 +0000 (14:26 +0000)]
[CGExpr] Use castAs<> instead of getAs<> to avoid dereference of nullptr

This will assert the cast is correct instead of returning nullptr

2 years ago[DivergenceAnalysis] Fix static analyzer warning about dereference of nullptr
Simon Pilgrim [Sat, 8 Jan 2022 13:57:33 +0000 (13:57 +0000)]
[DivergenceAnalysis] Fix static analyzer warning about dereference of nullptr

We're testing that the RegionLoop pointer is null in the first part of the check, so we need to check that its non-null before dereferencing it in a later part of the check.

2 years ago[OpenMPOpt] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr. NFC
Simon Pilgrim [Sat, 8 Jan 2022 13:47:35 +0000 (13:47 +0000)]
[OpenMPOpt] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr. NFC

2 years ago[X86][SSE] Add initial FSHL/FSHR vXi8 lowering support
Simon Pilgrim [Sat, 8 Jan 2022 12:19:25 +0000 (12:19 +0000)]
[X86][SSE] Add initial FSHL/FSHR vXi8 lowering support

This is very similar to the existing ROTL/ROTR support for scalar shifts in LowerRotate, I think as time goes on we should be able to share much of this code in helpers between Funnel Shift + Rotation lowering.

2 years agoMultiple fixes to affine loop tiling return status and checks
Uday Bondhugula [Mon, 27 Dec 2021 19:12:14 +0000 (00:42 +0530)]
Multiple fixes to affine loop tiling return status and checks

Fix crash in the presence of yield values. Multiple fixes to affine loop
tiling pre-condition checks and return status. Do not signal pass
failure on a failure to tile since the IR is still valid. Detect index
set computation failure in checkIfHyperrectangular and return failure.
Replace assertions with proper status return. Move checks to an
appropriate place earlier in the utility before mutation happens.

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

2 years ago[SCEVExpander] Skip creating <u 0 check, which is always false.
Florian Hahn [Sat, 8 Jan 2022 10:29:19 +0000 (10:29 +0000)]
[SCEVExpander] Skip creating <u 0 check, which is always false.

Unsigned compares of the form <u 0 are always false. Do not create such
a redundant check in generateOverflowCheck.

The patch introduces a new lambda to create the check, so we can
exit early conveniently and skip creating some instructions feeding the
check.

I am planning to sink a few additional instructions as follow-ups, but I
would prefer to do this separately, to keep the changes and diff
smaller.

Reviewed By: reames

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

2 years ago[MLIR][NFC] Move PresburgerSet to Presburger/ directory
Groverkss [Sat, 8 Jan 2022 10:08:30 +0000 (15:38 +0530)]
[MLIR][NFC] Move PresburgerSet to Presburger/ directory

This patch moves PresburgerSet to Presburger/ directory. This patch is purely
mechincal, it only moves and renames functionality and tests.

This patch is part of a series of patches to move presburger functionality to
Presburger/ directory.

Reviewed By: arjunp

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

2 years ago[GlobalISel] Use getPreferredShiftAmountTy in one more G_UBFX combine
Jay Foad [Fri, 7 Jan 2022 12:19:49 +0000 (12:19 +0000)]
[GlobalISel] Use getPreferredShiftAmountTy in one more G_UBFX combine

Change CombinerHelper::matchBitfieldExtractFromShrAnd to use
getPreferredShiftAmountTy for the shift-amount-like operands of G_UBFX
just like all the other G_[SU]BFX combines do. This better matches the
AMDGPU legality rules for these instructions.

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

2 years ago[GlobalISel] Fix legality checks for G_UBFX combines
Jay Foad [Fri, 7 Jan 2022 11:44:49 +0000 (11:44 +0000)]
[GlobalISel] Fix legality checks for G_UBFX combines

1. Fix CombinerHelper::matchBitfieldExtractFromAnd to check legality
   with the correct types for the G_UBFX that it builds.
2. Fix AMDGPUTargetLowering::isConstantUnsignedBitfieldExtractLegal to
   match the legality rules: result and first operand can be s32 or s64
   but the "shift amount" operands are always s32.
3. Add AMDGPU tests where the post-legalizer combiner would create
   illegal MIR without the above fixes.

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

2 years agoFix GDB printers test
Christian Sigg [Fri, 7 Jan 2022 21:44:41 +0000 (22:44 +0100)]
Fix GDB printers test

- Prevent symbols from being stripped so that it can run with 'RelWithDebInfo'.
- Adjust llvm-support CHECKs after code changes.
- Polish mlir-support CHECKs as suggested in https://reviews.llvm.org/D116646.

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

2 years ago[ORC-RT] Add missing headers from 1d82e19f37d.
Lang Hames [Sat, 8 Jan 2022 06:46:14 +0000 (17:46 +1100)]
[ORC-RT] Add missing headers from 1d82e19f37d.

This should fix the build failure at
https://lab.llvm.org/buildbot/#/builders/165/builds/12997

2 years ago[ORC-RT] Add debug logging macros.
Lang Hames [Wed, 22 Dec 2021 02:58:43 +0000 (13:58 +1100)]
[ORC-RT] Add debug logging macros.

Inspired by LLVM_DEBUG, but using environment variables rather than command line
options.

Code can use ORC_RT_DEBUG(...) (if ORC_RT_DEBUG_TYPE is set), or
ORC_RT_DEBUG_WITH_TYPE(<type>, ...) (if ORC_RT_DEBUG_TYPE is not set. E.g. in
headers).

Debug logging is enabled in the executor by setting the ORC_RT_DEBUG environment
variable. Debug logging can be restricted by type by setting the
ORC_RT_DEBUG_TYPES environment variable to a comma separated list of types,
e.g. ORC_RT_DEBUG_TYPES=macho_platform,sps.

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

2 years ago[ORC] Add missing header from 089acf25223.
Lang Hames [Sat, 8 Jan 2022 06:26:48 +0000 (17:26 +1100)]
[ORC] Add missing header from 089acf25223.

2 years ago[ORC][JITLink] Merge JITLink AllocActionCall and ORC WrapperFunctionCall.
Lang Hames [Sat, 8 Jan 2022 01:08:06 +0000 (12:08 +1100)]
[ORC][JITLink] Merge JITLink AllocActionCall and ORC WrapperFunctionCall.

These types performed identical roles. Merging them simplifies interoperability
between JITLink and ORC APIs (allowing us to address a few FIXMEs).

2 years ago[Target] use range-based for loops (NFC)
Kazu Hirata [Sat, 8 Jan 2022 05:20:36 +0000 (21:20 -0800)]
[Target] use range-based for loops (NFC)

2 years ago[clang-format][NFC] Fix a bug in getPreviousToken() in the parser
owenca [Sat, 8 Jan 2022 05:09:54 +0000 (21:09 -0800)]
[clang-format][NFC] Fix a bug in getPreviousToken() in the parser

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

2 years agoAdd first draft of the discourse migration guide.
Tanya Lattner [Sat, 8 Jan 2022 04:24:35 +0000 (20:24 -0800)]
Add first draft of the discourse migration guide.

2 years ago[RISCV] Add a command line option to control the LMUL used by TTI's getRegisterBitWidth.
Craig Topper [Sat, 8 Jan 2022 03:50:44 +0000 (19:50 -0800)]
[RISCV] Add a command line option to control the LMUL used by TTI's getRegisterBitWidth.

By default we return the width of an LMUL=1 register. We can enable
testing with larger LMUL values by returning a larger bit width.

This patch adds a RISCV specific option to provide a LMUL which will be
multiplied by the LMUL=1 bit width.

Reviewed By: kito-cheng

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

2 years ago[llvm] Remove unused forward declarations (NFC)
Kazu Hirata [Sat, 8 Jan 2022 04:00:34 +0000 (20:00 -0800)]
[llvm] Remove unused forward declarations (NFC)

2 years ago[RISCV] Set getMinVectorRegisterBitWidth to 16 if enable fixed length vector code...
Kito Cheng [Mon, 3 Jan 2022 07:32:49 +0000 (15:32 +0800)]
[RISCV] Set getMinVectorRegisterBitWidth to 16 if enable fixed length vector code gen for RVV

getMinVectorRegisterBitWidth means what vector types is supported in
this target, and actually RISC-V support all fixed length vector types with
vector length less than `getMinRVVVectorSizeInBits`, so set it to 16,
means 2 x i8, that is minimal fixed length vector size in theory.

That also fixed one issue, some testcase migth become non-vectorizable
when `-riscv-v-vector-bits-min` set to larger value, because the vector size is
smaller than `-riscv-v-vector-bits-min`.

For example, following code can vectorize by SLP with
`-riscv-v-vector-bits-min=128` or `-riscv-v-vector-bits-min=256`, but
can't vectorize `-riscv-v-vector-bits-min=512` or larger:

```
void foo(double *da) {
  da[0] = 0;
  da[1] = 1;
  da[2] = 2;
  da[3] = 3;
}
```

Reviewed By: craig.topper

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

2 years ago[NFC] Test commit.
Jun Zhang [Sat, 8 Jan 2022 02:36:09 +0000 (10:36 +0800)]
[NFC] Test commit.

This is just a test commit to check whether the permission I got is
correct or not.

2 years agoAvoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option...
Mehdi Amini [Sat, 8 Jan 2022 01:40:24 +0000 (01:40 +0000)]
Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option is set

a32300a changed it to create a ThreadPool eagerly so that it gets reused
across buffers, however it also made it so that we create a ThreadPool
early even if we're not gonna use it later because of the command line
option `--mlir-disable-threading` is provided.

Fix #53056

Reland 45adf608024 after build fixes

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

2 years agoRevert "Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading...
Mehdi Amini [Sat, 8 Jan 2022 02:23:30 +0000 (02:23 +0000)]
Revert "Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option is set"

This reverts commit 45adf608024655d3594993d041af9602da41780f.
Build is broken

2 years ago[gn build] (manually) port feeff8a37c35
Nico Weber [Sat, 8 Jan 2022 02:19:01 +0000 (21:19 -0500)]
[gn build] (manually) port feeff8a37c35

This reverts commit 3ca69283442183d71f13700d860f5912b631bcb0.
492de35df44 relanded in feeff8a37c35.
The reland only uses CMAKE_INSTALL_INCLUDEDIR and not CMAKE_INSTALL_BINDIR
in llvm-config, so this reland reflects that.

2 years ago[MLIR] Fix compilation with LLVM_ENABLE_THREADS=OFF
John Demme [Sat, 8 Jan 2022 01:56:57 +0000 (01:56 +0000)]
[MLIR] Fix compilation with LLVM_ENABLE_THREADS=OFF

Currently, compiles with LLVM_ENABLE_THREADS=OFF fail due to this symbol missing. Add it but assert as calling code is (and should be) checking that threading is enabled.

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

2 years agoAvoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option...
Mehdi Amini [Sat, 8 Jan 2022 01:40:24 +0000 (01:40 +0000)]
Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option is set

a32300a changed it to create a ThreadPool eagerly so that it gets reused
across buffers, however it also made it so that we create a ThreadPool
early even if we're not gonna use it later because of the command line
option `--mlir-disable-threading` is provided.

Fix #53056

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

2 years ago[libc++] Disable coverage with sanitize-coverage=0
Ben Wagner [Sat, 8 Jan 2022 01:34:05 +0000 (17:34 -0800)]
[libc++] Disable coverage with sanitize-coverage=0

When building libcxx, libcxxabi, and libunwind the build environment may
specify any number of sanitizers. For some build feature tests these
sanitizers must be disabled to prevent spurious linking errors. With
-fsanitize= this is straight forward with -fno-sanitize=all. With
-fsanitize-coverage= there is no -fno-sanitize-coverage=all, but there
is the equivalent undocumented but tested -fsanitize-coverage=0.

The current build rules fail to disable 'trace-pc-guard'. By disabling
all sanitize-coverage flags, including 'trace-pc-guard', possible
spurious linker errors are prevented. In particular, this allows libcxx,
libcxxabi, and libunwind to be built with HonggFuzz.

CMAKE_REQUIRED_FLAGS is extra compile flags when running CMake build
configuration steps (like check_cxx_compiler_flag). It does not affect
the compile flags for the actual build of the project (unless of course
these flags change whether or not a given source compiles and links or
not). So libcxx, libcxxabi, and libunwind will still be built with any
specified sanitize-coverage as before. The build configuration steps
(which are mostly checking to see if certain compiler flags are
available) will not try to compile and link "int main() { return 0;}"
(or other specified source) with sanitize-coverage (which can fail to
link at this stage in building, since the final compile flags required
are yet to be determined).

The change to LIBFUZZER_CFLAGS was done to keep it consistent with the
obvious intention of disabling all sanitize-coverage. This appears to
be intentional, preventing the fuzzer driver itself from showing up in
any coverage calculations.

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

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

2 years ago[llvm] Remove redundant member initialization (NFC)
Kazu Hirata [Sat, 8 Jan 2022 01:45:09 +0000 (17:45 -0800)]
[llvm] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

2 years ago[Darwin][Sanitizer] Lower Python requirement for iOS simulator testing
Julian Lettner [Sat, 8 Jan 2022 01:35:52 +0000 (17:35 -0800)]
[Darwin][Sanitizer] Lower Python requirement for iOS simulator testing

Lower Python requirements: 3.7 -> 3.6

Workaround introduced in: ebd8eee62a431a6744c3f187fcda58e5dea08499

2 years agoDon't pass uninitialized QueryKind
Vitaly Buka [Fri, 7 Jan 2022 18:30:50 +0000 (10:30 -0800)]
Don't pass uninitialized QueryKind

Even if findImplementors does not use
uninitialized parameter it's still UB and
it's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years ago[Darwin] Apply workaround to make symbolication in iOS simulators work
Julian Lettner [Sat, 8 Jan 2022 00:47:37 +0000 (16:47 -0800)]
[Darwin] Apply workaround to make symbolication in iOS simulators work

Specify `ASAN_SYMBOLIZER_PATH` when running simulator tests.  This will
unblock simulator testing in GreenDragon (Apple's open source testing).

2 years ago[llvm] Use `GNUInstallDirs` to support custom installation dirs
John Ericson [Sat, 11 Dec 2021 01:36:24 +0000 (01:36 +0000)]
[llvm] Use `GNUInstallDirs` to support custom installation dirs

This is the patch for LLVM proper in my series for adding GNUInstallDirs support in all project.

Additionally:

Create a new `CACHE STRING` variable, `LLVM_EXAMPLES_INSTALL_DIR`, to control where the examples are installed on analogy with the other variables.

---

This patch supersedes D28234, which tried to do the same thing but hand-rolled without GNUInstallDirs.

This patch nearly reverts commit 3 0fc88bf1dc15a72e2d9809d28019d386b7a7cc0, which was a revert of a prior attempt."

(I had to add a space here or else Phabricator detects a reference cycle and won't let me do the form submit.)

Reviewed By: compnerd

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

2 years ago[CMake][WinMsvc] Fix user passed compiler/linker flags
Yuanfang Chen [Sat, 8 Jan 2022 00:34:38 +0000 (16:34 -0800)]
[CMake][WinMsvc] Fix user passed compiler/linker flags

Users could pass flags by environment variables like CFLAGS/CXXFLAGS/LDFLAGS
or by using CMAKE_<LANG>_FLAGS_INIT/CMAKE_<t>_LINKER_FLAGS_INIT. So this
toolchain file should append to INIT flags instead. Otherwise, user
flags would be discarded here by assigning to CMAKE_<LANG>_FLAGS
directly.

Reviewed By: smeenai, mstorsjo

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

2 years ago[formatters] Improve documentation
Walter Erquinigo [Fri, 17 Dec 2021 22:33:54 +0000 (14:33 -0800)]
[formatters] Improve documentation

This adds some important remarks to the data formatter documentation.

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

2 years ago[lldb] Remove lldbconfig module
Jonas Devlieghere [Fri, 7 Jan 2022 23:25:20 +0000 (15:25 -0800)]
[lldb] Remove lldbconfig module

The lldbconfig module was necessary to run the LLDB test suite against a
reproducer. Since this functionality has been removed, the module is no
longer necessary.

2 years agoMake separate config variable for `LLVM_LIBRARY_DIRS`
John Ericson [Sat, 1 Jan 2022 01:20:32 +0000 (01:20 +0000)]
Make separate config variable for `LLVM_LIBRARY_DIRS`

@beanz tells me it should in fact exists, and it would be bad to put a
list of dirs in `LLVM_LIBRARY_DIR`. I am therefore making some changes
to help avoid this an other mistakes:

- Use a separate `LLVM_CONFIG_LIBRARY_DIR` (no "S") variable so we don't
  start putting a list in `LLVM_LIBRARY_DIR` by mistake.

- Define the individual dir variables first, and the define the list of
  dirs variables programmatically.

Also, I rearranged the definitions of the "regular" single dirs below so
`LLVM_BINARY_DIR`, which is the unsuffixed one, comes first before the
suffixed ones.

Reviewed By: beanz

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

2 years ago[RISCV] Materializing constants with 'rori'
Baoshan Pang [Fri, 7 Jan 2022 23:29:22 +0000 (15:29 -0800)]
[RISCV] Materializing constants with 'rori'

Reviewed By: craig.topper

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

2 years agoInitialize output parameter
Vitaly Buka [Fri, 7 Jan 2022 18:36:47 +0000 (10:36 -0800)]
Initialize output parameter

Or code like this have UB passing uninitialized CmpValue:

```
  int64_t CmpMask, CmpValue;
  if (!TII->analyzeCompare(MI, SrcReg, SrcReg2, CmpMask, CmpValue))
    return false;
  if (TII->optimizeCompareInstr(MI, SrcReg, SrcReg2, CmpMask, CmpValue, MRI)) {
```

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years agoInitialize ExtAddrMode::Scale
Vitaly Buka [Fri, 7 Jan 2022 18:36:01 +0000 (10:36 -0800)]
Initialize ExtAddrMode::Scale

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years agoInitialize fields of TypeRecord subclasses
Vitaly Buka [Fri, 7 Jan 2022 18:35:22 +0000 (10:35 -0800)]
Initialize fields of TypeRecord subclasses

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years agoInitialize HighlightingsBuilder::Resolver
Vitaly Buka [Fri, 7 Jan 2022 18:32:24 +0000 (10:32 -0800)]
Initialize HighlightingsBuilder::Resolver

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years agoInitialize output parameters
Vitaly Buka [Fri, 7 Jan 2022 18:22:35 +0000 (10:22 -0800)]
Initialize output parameters

If the function returns true, it should
set all output paremeters, similar to Output::preflightElement, or we
have UB on code like:

```
void *SaveInfo;
if (io.preflightFlowElement(i, SaveInfo))
  io.postflightFlowElement(SaveInfo);
```

It's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

2 years ago[Hexagon] Reconize M2_mnaci in HexagonBitTracker
Sumanth Gundapaneni [Fri, 7 Jan 2022 22:42:54 +0000 (14:42 -0800)]
[Hexagon] Reconize M2_mnaci in HexagonBitTracker

2 years ago[-fms-extensions] Make some exception specification warnings/errors compatible with...
Amy Huang [Thu, 23 Dec 2021 23:09:30 +0000 (15:09 -0800)]
[-fms-extensions] Make some exception specification warnings/errors compatible with what cl.exe does

Make clang-cl error when a function definition is missing 'noexcept',
and succeed without warnings when missing '__declspec(nothrow)' or 'throw'.

Fixes pr52860

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

2 years ago[Clang][CFG] check children statements of asm goto
Nick Desaulniers [Fri, 7 Jan 2022 22:10:57 +0000 (14:10 -0800)]
[Clang][CFG] check children statements of asm goto

When performing CFG based analyses, don't forget to check the child
statements of an asm goto, such as the expressions used for
inputs+outputs.

Fixes: https://github.com/llvm/llvm-project/issues/51024
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1439

Reviewed By: void, jyknight, jyu2, efriedma

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

2 years ago[MemoryBuiltin] Cleanup stale todo comments [NFC]
Philip Reames [Fri, 7 Jan 2022 21:55:32 +0000 (13:55 -0800)]
[MemoryBuiltin] Cleanup stale todo comments [NFC]

strdup/strndup are already partially implemented, move remaining comment to relevant place.  Remaining named routines are copy routines and mostly handled via intrinsics already - they do not allocate new memory.

2 years ago[lldb] Use lit_config.note to print module cache message
Jonas Devlieghere [Fri, 7 Jan 2022 21:34:06 +0000 (13:34 -0800)]
[lldb] Use lit_config.note to print module cache message

2 years ago[MLIR] Add IntegerPolyhedron::getUniverse
Groverkss [Fri, 7 Jan 2022 21:23:22 +0000 (02:53 +0530)]
[MLIR] Add IntegerPolyhedron::getUniverse

This operation already exists in FlatAffineConstraints but is added to
IntegerPolyhedron to keep consistancy in available methods.

2 years ago[NFCI] `ScalarEvolution::getRangeRef()`: collapse `SCEVMinMaxExpr` handling
Roman Lebedev [Fri, 7 Jan 2022 21:18:14 +0000 (00:18 +0300)]
[NFCI] `ScalarEvolution::getRangeRef()`: collapse `SCEVMinMaxExpr` handling

2 years agoRevert "[Inline] Attempt to delete any discardable if unused functions"
Arthur Eubanks [Fri, 7 Jan 2022 21:11:18 +0000 (13:11 -0800)]
Revert "[Inline] Attempt to delete any discardable if unused functions"

This reverts commit 335a3163aab4ab3a52c7c15d03bcf1ce9ba79fbb.

Causes crashes when building llvm-test-suite's kc under ReleaseLTO-g.

2 years ago[Hexagon] Use map from HexagonDepArch instead of local one, NFC
Krzysztof Parzyszek [Fri, 7 Jan 2022 20:45:22 +0000 (12:45 -0800)]
[Hexagon] Use map from HexagonDepArch instead of local one, NFC

Co-authored-by: Brian Cain <bcain@quicinc.com>
2 years ago[lld] Deprecate using llvm-config to detect llvm installation
John Ericson [Sun, 2 Jan 2022 06:29:26 +0000 (06:29 +0000)]
[lld] Deprecate using llvm-config to detect llvm installation

This is continuing in the path of D51714, which did this for Clang.

I have rearranged the source code Clang so one can diff the top-level
CMakeLists.txt of Clang and LLD, ensuring we use the same strategy for
both.

Besides diffing the two files, `git diff --color-moved` on LLD also helps review.

Reviewed By: beanz

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

2 years ago[LLDB] Fix setting of success in Socket::Close()
Shafik Yaghmour [Fri, 7 Jan 2022 19:56:57 +0000 (11:56 -0800)]
[LLDB] Fix setting of success in Socket::Close()

Both close and closesocket should return 0 on success so using !! looks incorrect. I replaced this will a more readable == 0 check.

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

2 years agoUpdate DWARF fission extension attributes
Adrian Prantl [Fri, 7 Jan 2022 20:40:08 +0000 (12:40 -0800)]
Update DWARF fission extension attributes

This patch brings the transitional DWARF 4 + fission attributes up to date.

Patch by David Anderson!

Differential Review: https://reviews.llvm.org/D116065

2 years ago[Hexagon] Extract condition into function, NFC
Krzysztof Parzyszek [Fri, 7 Jan 2022 20:10:54 +0000 (12:10 -0800)]
[Hexagon] Extract condition into function, NFC

Co-authored-by: Brian Cain <bcain@quicinc.com>
2 years ago[ASan][Darwin] Avoid crash during ASan initialization
Julian Lettner [Thu, 23 Dec 2021 06:30:46 +0000 (22:30 -0800)]
[ASan][Darwin] Avoid crash during ASan initialization

Always pass `depth=1` to `vm_region_recurse_64()`.  `depth` is a in-out
parameter and gets reset to 0 after the first call, so we incorrectly
pass `depth=0` on subsequent calls.

We want to avoid the following crash:
```
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000180000000
Exception Codes: 0x0000000000000001, 0x0000000180000000
VM Region Info: 0x180000000 is not in any region. Bytes after previous region: 277577729 Bytes before following region: 384270336
   REGION TYPE         START - END   [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
   Stack          16f64c000-16f748000 [ 1008K] rw-/rwx SM=PRV thread 0
---> GAP OF 0x27730000 BYTES
   unused shlib __TEXT   196e78000-196eac000 [ 208K] r-x/r-x SM=COW ... this process
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [767]
```

Crashing code:
```
static mach_header *get_dyld_image_header() {
 unsigned depth = 1;
 vm_size_t size = 0;
 vm_address_t address = 0;
 kern_return_t err = KERN_SUCCESS;
 mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;

 while (true) {
  struct vm_region_submap_info_64 info;
  err = vm_region_recurse_64(mach_task_self(), &address, &size, &depth,
                (vm_region_info_t)&info, &count);
  if (err != KERN_SUCCESS) return nullptr;

  if (size >= sizeof(mach_header) && info.protection & kProtectionRead) {
   mach_header *hdr = (mach_header *)address;
   if ((hdr->magic == MH_MAGIC || hdr->magic == MH_MAGIC_64) &&   // << CRASH: sanitizer_procmaps_mac.cpp:176
     hdr->filetype == MH_DYLINKER) {
    return hdr;
   }
  }
  address += size;
 }
}
```

Radar-Id: rdar://problem/86773501

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

2 years ago[Hexagon] Fix release build break after 547658567353d
Krzysztof Parzyszek [Fri, 7 Jan 2022 20:21:02 +0000 (12:21 -0800)]
[Hexagon] Fix release build break after 547658567353d

2 years ago[CMake] Factor out config prefix finding logic
John Ericson [Mon, 3 Jan 2022 02:25:06 +0000 (02:25 +0000)]
[CMake] Factor out config prefix finding logic

See the docs in the new function for details.

 I think I found every instance of this copy pasted code. Polly could
 also use it, but currently does something different, so I will save the
 behavior change for a future revision.

We get the shared, non-installed CMake modules following the pattern
established in D116472.

It might be good to have LLD and Flang also use this, but that would be
a functional change and so I leave it as future work.

Reviewed By: beanz, lebedev.ri

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

2 years ago[cmake] Add read-me for the common CMake utils
John Ericson [Mon, 3 Jan 2022 07:51:54 +0000 (07:51 +0000)]
[cmake] Add read-me for the common CMake utils

Now that I am adding more things there, I thought it prudent to document
what should and should not go there, and how it is used.

Reviewed By: lebedev.ri

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

2 years ago[Hexagon] Duplex error: wrong branch hint
Michael Lambert [Fri, 7 Jan 2022 19:55:45 +0000 (11:55 -0800)]
[Hexagon] Duplex error: wrong branch hint

2 years ago[Hexagon] Consider direction hint forming dealloc_return duplex
colinl [Fri, 7 Jan 2022 19:51:56 +0000 (11:51 -0800)]
[Hexagon] Consider direction hint forming dealloc_return duplex

2 years ago[MLIR][NFC] Move presburger functionality from FlatAffineConstraints to IntegerPolyhedron
Groverkss [Fri, 7 Jan 2022 19:52:29 +0000 (01:22 +0530)]
[MLIR][NFC] Move presburger functionality from FlatAffineConstraints to IntegerPolyhedron

This patch moves all presburger functionality from FlatAffineConstraints to
IntegerPolyhedron. This patch is purely mechanical, it only moves and renames
functionality and tests.

This patch is part of a series of patches to move presburger functionality to
Presburger/ directory.

Reviewed By: bondhugula

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

2 years ago[LLDB] libcxx summary formatters for std::string_view
Ben Jackson [Fri, 7 Jan 2022 19:38:47 +0000 (11:38 -0800)]
[LLDB] libcxx summary formatters for std::string_view

When printing a std::string_view, print the referenced string as the
summary. Support string_view, u32string_view, u16string_view and
wstring_view, as we do for std::string and friends.

This is based on the existing fomratter for std::string, and just
extracts the data and length members, pushing them through the existing
string formatter.

In testing this, a "FIXME" was corrected for printing of non-ASCII empty
values. Previously, the "u", 'U" etc. prefixes were not printed for
basic_string<> types that were not char. This is trivial to resolve by
printing the prefix before the "".

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

2 years ago[Hexagon] Improve check for subinstruction registers
colinl [Fri, 7 Jan 2022 19:33:14 +0000 (11:33 -0800)]
[Hexagon] Improve check for subinstruction registers

2 years ago[Hexagon] Reject accumulating on vd.tmp
Yuanxiang Ye [Fri, 7 Jan 2022 19:07:32 +0000 (11:07 -0800)]
[Hexagon] Reject accumulating on vd.tmp

Added hvx accum checker function and test cases.

2 years ago[Inline] Attempt to delete any discardable if unused functions
Arthur Eubanks [Fri, 7 Jan 2022 17:47:55 +0000 (09:47 -0800)]
[Inline] Attempt to delete any discardable if unused functions

Previously we limited ourselves to only internal/private functions. We
can also delete linkonce_odr functions.

Minor compile time wins:
https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=instructions

Major memory wins on tramp3d:
https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=max-rss

Reviewed By: nikic

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

2 years ago[Hexagon] Apply tiny core packet size slots limit
Brian Cain [Thu, 3 May 2018 16:04:26 +0000 (11:04 -0500)]
[Hexagon] Apply tiny core packet size slots limit

2 years ago[Hexagon] Simplify AX instruction detection
colinl [Fri, 7 Jan 2022 17:41:39 +0000 (09:41 -0800)]
[Hexagon] Simplify AX instruction detection

2 years ago[instcombine] Delete duplicate object size logic
Philip Reames [Fri, 7 Jan 2022 18:30:53 +0000 (10:30 -0800)]
[instcombine] Delete duplicate object size logic

nstCombine appears to duplicate the allocation size logic used inside getObjectSize when figuring out which attributes are safe to place on the callsite. We can use the existing utility function instead.

The test change is correct. With aligned_alloc, a zero alignment is required to return nullptr. As such, deref_or_null is a correct attribute to use.

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

2 years ago[x86] make select lowering using SBB hack more flexible
Sanjay Patel [Fri, 7 Jan 2022 13:06:51 +0000 (08:06 -0500)]
[x86] make select lowering using SBB hack more flexible

select (X != 0), -1, Y --> 0 - X; or (sbb), Y
select (X != 0), Y, -1 --> X - 1; or (sbb), Y

We already had these x86 carry-flag transforms, but one was over-specified to
handle a "0" select arm only. That's just a special-case of the more general
pattern (the 'or' will be deleted if Y is zero).

This is part of solving #53006, but it misses that example because some other
combine has already converted that exact pattern into math ops.

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

2 years agoUse nullptr instead of 0 or NULL (NFC)
Kazu Hirata [Fri, 7 Jan 2022 18:17:29 +0000 (10:17 -0800)]
Use nullptr instead of 0 or NULL (NFC)

Identified with modernize-use-nullptr.

2 years ago[LazyCallGraph] Ignore empty RefSCCs rather than shift RefSCCs when removing dead...
Arthur Eubanks [Tue, 14 Dec 2021 00:21:17 +0000 (16:21 -0800)]
[LazyCallGraph] Ignore empty RefSCCs rather than shift RefSCCs when removing dead functions

This is in preparation for D115545 which attempts to delete discardable functions if they are unused. With that change, shifting RefSCCs becomes noticeable in compile time. This change makes the LCG update negligible again.

Reviewed By: nikic

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

2 years agoscudo: fix thread-safety macro name
Dmitry Vyukov [Fri, 7 Jan 2022 17:25:58 +0000 (18:25 +0100)]
scudo: fix thread-safety macro name

Missed in 765921de5b ("sanitizer_common: prefix thread-safety macros with SANITIZER_") update.

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

2 years ago[ComprehensiveBufferize] Fix a warning
Kazu Hirata [Fri, 7 Jan 2022 17:25:59 +0000 (09:25 -0800)]
[ComprehensiveBufferize] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp:292:12:
  error: comparison of integers of different signs: 'int' and
  'unsigned int' [-Werror,-Wsign-compare]

2 years ago[Support] No longer require flushing raw_string_ostream
Logan Smith [Thu, 9 Dec 2021 04:02:37 +0000 (20:02 -0800)]
[Support] No longer require flushing raw_string_ostream

Since 65b13610a5226b84889b923bae884ba395ad084d, raw_string_ostream
has been unbuffered by default, making .flush() a no-op. This diff
formalizes this by no longer .flush()ing in the .str() method or
the destructor. .str() has been marked as "consider removing", since
its primary use case used to be making .flush()+access a one-liner,
and it also has issues such as preventing NRVO/implicit move when used
in return statements.

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

2 years agoExtract utility function for checking initial value of allocation [NFC, try 2]
Philip Reames [Fri, 7 Jan 2022 16:25:26 +0000 (08:25 -0800)]
Extract utility function for checking initial value of allocation [NFC, try 2]

This is a reoccuring pattern, we can consolidate three copies into one.  The main motivation is to reduce usages of isMallocLike.

The original commit (which was quickly reverted) didn't account for the allocation function could be an invoke, test coverage for that case added in this commit.

2 years ago[mlir][linalg][bufferize][NFC] Add `analyzeOp` helper function
Matthias Springer [Fri, 7 Jan 2022 16:26:14 +0000 (01:26 +0900)]
[mlir][linalg][bufferize][NFC] Add `analyzeOp` helper function

This function runs just the analysis of Comprehensive Bufferize, but does not bufferize the IR yet.

This is in preparation of fixing CallOp bufferization. Also needed for unifying Comprehensive Bufferize and core bufferization; the new partial bufferization can simply run bufferization without an analysis.

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

2 years ago[Hexagon] s/Fatal/ReportErrors/
Brian Cain [Thu, 26 Apr 2018 04:10:26 +0000 (23:10 -0500)]
[Hexagon] s/Fatal/ReportErrors/

Rename argument from 'Fatal' => 'ReportErrors'.  HexagonShuffler refers to
this arg as 'ReportErrors' and calling it 'Fatal' in HexagonMCShuffler is
misleading and inconsistent.

2 years ago[Hexagon] MC testcases for verifying packetization rules
colinl [Fri, 7 Jan 2022 15:45:11 +0000 (07:45 -0800)]
[Hexagon] MC testcases for verifying packetization rules

2 years ago[Hexagon] Show slot resources for errors
Brian Cain [Thu, 14 Nov 2019 16:17:45 +0000 (10:17 -0600)]
[Hexagon] Show slot resources for errors

For a scalar packet resource error, emit details about the slots
available for each instruction in the packet.

2 years ago[Hexagon] Misc shuffling fixes
Krzysztof Parzyszek [Fri, 10 Jan 2020 17:30:48 +0000 (11:30 -0600)]
[Hexagon] Misc shuffling fixes

Co-authored-by: Brian Cain <bcain@quicinc.com>
2 years agoFix a bug in 67a3331e (cast instead of dyn_cast)
Philip Reames [Fri, 7 Jan 2022 16:22:53 +0000 (08:22 -0800)]
Fix a bug in 67a3331e (cast instead of dyn_cast)

The original commit was expected to be NFC, but I didn't account for the fact that invokes could be considered allocation functions.  Interestingly, only one builder caught the problem.

2 years ago[AArch64] Update addo and subo costs
David Green [Fri, 7 Jan 2022 16:20:23 +0000 (16:20 +0000)]
[AArch64] Update addo and subo costs

Similar to D116732, this adds basic scalar sadd_with_overflow,
uadd_with_overflow, ssub_with_overflow and usub_with_overflow costs for
aarch64, which are usually quite efficiently lowered.

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

2 years ago[mlir][linalg][bufferize][NFC] Simplify buffer API of BufferizationState
Matthias Springer [Fri, 7 Jan 2022 16:10:15 +0000 (01:10 +0900)]
[mlir][linalg][bufferize][NFC] Simplify buffer API of BufferizationState

Instead of `lookupBuffer` and `getResultBuffer`, there is now a single `getBuffer` function. This simplifies the `BufferizableOpInterface` API and is less confusing to users. They could previously have called the wrong function.

Furthermore, since `getBuffer` now takes an `OpOperand &` instead of a `Value`, users can no longer accidentally use one of the previous two functions incorrectly, which would have resulted in missing buffer copies.

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