platform/upstream/llvm.git
2 years agoFix: [MCParser] Correctly handle CRLF line ends when consuming line comments
Tozer [Tue, 17 Aug 2021 15:14:12 +0000 (16:14 +0100)]
Fix: [MCParser] Correctly handle CRLF line ends when consuming line comments

Fixes an issue with revision 5c6f748c.

Move the test added in the above commit into the X86 folder, ensuring
that it is only run on targets where its triple is valid.

2 years agotsan: test: Initialize all fields of Params struct
Marco Elver [Tue, 17 Aug 2021 14:54:07 +0000 (16:54 +0200)]
tsan: test: Initialize all fields of Params struct

Some compilers started complaining about the test:

tsan_trace_test.cpp:128:21: error: missing field 'type' initializer

Fix it by initializing all 5 fields, even though the type field will be
reset in the for loop.

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

2 years ago[MCParser] Correctly handle CRLF line ends when consuming line comments
Tozer [Tue, 17 Aug 2021 14:38:45 +0000 (15:38 +0100)]
[MCParser] Correctly handle CRLF line ends when consuming line comments

Fixes issue: https://bugs.llvm.org/show_bug.cgi?id=47983

The AsmLexer currently has an issue with lexing line comments in files
with CRLF line endings, in which it reads the carriage return as being
part of the line comment. This causes an error for certain valid comment
layouts; this patch fixes this by excluding the carriage return from the
line comment.

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

2 years ago[libc++][NFC] Fix indentation of documentation
Louis Dionne [Tue, 17 Aug 2021 14:52:12 +0000 (10:52 -0400)]
[libc++][NFC] Fix indentation of documentation

2 years ago[Bitcode] Remove unused declaration writeBitcodeHeader (NFC)
Kazu Hirata [Tue, 17 Aug 2021 14:10:51 +0000 (07:10 -0700)]
[Bitcode] Remove unused declaration writeBitcodeHeader (NFC)

The corresponding definition was removed on Nov 29, 2016 in commit
5a0a2e648c267d99111b21482ca709f580e9ccc2.

2 years ago[LIT]Accept cat_64 command name on AIX in shtest
Jinsong Ji [Tue, 17 Aug 2021 14:05:28 +0000 (14:05 +0000)]
[LIT]Accept cat_64 command name on AIX in shtest

AIX may use cat_64 for 64 bit cat, this is just update the lit test to accept the name as well.

Reviewed By: #powerpc, shchenz

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

2 years ago[SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute
Dylan Fleming [Tue, 17 Aug 2021 13:00:47 +0000 (14:00 +0100)]
[SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute

Removed AArch64 usage of the getMaxVScale interface, replacing it with
the vscale_range(min, max) IR Attribute.

Reviewed By: paulwalker-arm

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

2 years ago[libc++][NFC] Refactor tests for transform_view
Louis Dionne [Tue, 17 Aug 2021 13:20:24 +0000 (09:20 -0400)]
[libc++][NFC] Refactor tests for transform_view

Adjust the names of helper function objects to represent better what
they do, as suggested in the review of D107098.

2 years ago[ARM] Enable subreg liveness
David Green [Tue, 17 Aug 2021 13:10:33 +0000 (14:10 +0100)]
[ARM] Enable subreg liveness

This enables subreg liveness in the arm backend when MVE is present,
which allows the register allocator to detect when subregister are
alive/dead, compared to only acting on full registers. This can helps
produce better code on MVE with the way MQPR registers are made up of
SPR registers, but is especially helpful for MQQPR and MQQQQPR
registers, where there are very few "registers" available and being able
to split them up into subregs can help produce much better code.

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

2 years ago[ARM] Add MQQPR and MQQQQPR spill and reload pseudo instructions
David Green [Tue, 17 Aug 2021 12:51:34 +0000 (13:51 +0100)]
[ARM] Add MQQPR and MQQQQPR spill and reload pseudo instructions

As a part of D107642, this adds pseudo instructions for MQQPR and
MQQQQPR register classes, that can spill and reloads entire registers
whilst keeping them combined, not splitting them into multiple D subregs
that a VLDMIA/VSTMIA would use. This can help certain analyses, and
helps to prevent verifier issues with subreg liveness.

2 years ago[InstCombine] remove unused function argument; NFC
Sanjay Patel [Tue, 17 Aug 2021 12:10:16 +0000 (08:10 -0400)]
[InstCombine] remove unused function argument; NFC

2 years ago[InstCombine] fold signed min/max intrinsics with negated operands
Sanjay Patel [Tue, 17 Aug 2021 11:31:05 +0000 (07:31 -0400)]
[InstCombine] fold signed min/max intrinsics with negated operands

If both operands are negated, we can invert the min/max and do
the negation after:
smax (neg nsw X), (neg nsw Y) --> neg nsw (smin X, Y)
smin (neg nsw X), (neg nsw Y) --> neg nsw (smax X, Y)

This is visible as a remaining regression in D98152. I don't see
a way to generalize this for 'unsigned' or adapt Negator to
handle it. This only appears to be safe with 'nsw':
https://alive2.llvm.org/ce/z/GUy1zJ

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

2 years ago[InstCombine] add tests for smin/smax intrinsics with negated ops; NFC
Sanjay Patel [Mon, 16 Aug 2021 19:27:55 +0000 (15:27 -0400)]
[InstCombine] add tests for smin/smax intrinsics with negated ops; NFC

2 years ago[GlobalISel] Add combine for PTR_ADD with regbanks
Sebastian Neubauer [Tue, 17 Aug 2021 11:58:16 +0000 (13:58 +0200)]
[GlobalISel] Add combine for PTR_ADD with regbanks

Combine two G_PTR_ADDs, but keep the register bank of the constant.
That way, the combine can be used in post-regbank-select combines.

Introduce two helper methods in CombinerHelper, getRegBank and
setRegBank that get and set an optional register bank to a register.
That way, they can be used before and after register bank selection.

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

2 years ago[lldb] Make TestAArch64AdrpAdd depend on the AArch64 target
Raphael Isemann [Tue, 17 Aug 2021 10:46:44 +0000 (12:46 +0200)]
[lldb] Make TestAArch64AdrpAdd depend on the AArch64 target

LLDB is using LLVM's target-specific disassembler which is only available when
the respective LLVM target has been enabled in the build config.

This patch just skips the test if there is no arm64 target (and its
disassembler) available in the current build config.

Reviewed By: jasonmolenda

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

2 years ago[CodeGenPrepare] The instruction to be sunk should be inserted before its user in...
Tiehu Zhang [Tue, 17 Aug 2021 10:50:54 +0000 (18:50 +0800)]
[CodeGenPrepare] The instruction to be sunk should be inserted before its user in a block

In current implementation, the instruction to be sunk will be inserted before the target instruction without considering the def-use tree,
which may case Instruction does not dominate all uses error. We need to choose a suitable location to insert according to the use chain

Reviewed By: dmgreen

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

2 years ago[DebugInfo][InstrRef] Honour too-much-debug-info cutouts
Jeremy Morse [Tue, 17 Aug 2021 10:32:41 +0000 (11:32 +0100)]
[DebugInfo][InstrRef] Honour too-much-debug-info cutouts

This reapplies 54a61c94f93, its follow up in 547b712500e, which were
reverted 95fe61e63954. Original commit message:

VarLoc based LiveDebugValues will abandon variable location propagation if
there are too many blocks and variable assignments in the function. If it
didn't, and we had (say) 1000 blocks and 1000 variables in scope, we'd end
up with 1 million DBG_VALUEs just at the start of blocks.

Instruction-referencing LiveDebugValues should honour this limitation too
(because the same limitation applies to it). Hoist the relevant command
line options into LiveDebugValues.cpp and pass it down into the
implementation classes as an argument to ExtendRanges. I've duplicated all
the run-lines in live-debug-values-cutoffs.mir to have an
instruction-referencing flavour.

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

2 years ago[AArch64] LowerCONCAT_VECTORS - merge getNumOperands() calls. NFCI.
Simon Pilgrim [Tue, 17 Aug 2021 10:22:49 +0000 (11:22 +0100)]
[AArch64] LowerCONCAT_VECTORS - merge getNumOperands() calls. NFCI.

Improves on the unused variable fix from rG4357562067003e25ab343a2d67a60bd89cd66dbf

2 years ago[AggressiveInstCombine] Add shift left instruction to `TruncInstCombine` DAG
Anton Afanasyev [Thu, 12 Aug 2021 11:51:57 +0000 (14:51 +0300)]
[AggressiveInstCombine] Add shift left instruction to `TruncInstCombine` DAG

Add `shl` instruction to the DAG post-dominated by `trunc`, allowing
TruncInstCombine to reduce bitwidth of expressions containing left shifts.

The only thing we need to check is that the target bitwidth must be wider
than the maximal shift amount: https://alive2.llvm.org/ce/z/AwArqu

Part of https://reviews.llvm.org/D107766

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

2 years ago[Test][AggressiveInstCombine] Add test for shifts
Anton Afanasyev [Thu, 12 Aug 2021 11:51:57 +0000 (14:51 +0300)]
[Test][AggressiveInstCombine] Add test for shifts

Precommit test for D107766/D108091. Also move fixed test for PR50555
from SLPVectorizer/X86/ to PhaseOrdering/X86/ subdirectory.

2 years ago[hwasan] Prevent reordering of tag checks.
Florian Mayer [Wed, 11 Aug 2021 13:25:50 +0000 (14:25 +0100)]
[hwasan] Prevent reordering of tag checks.

They were previously unconstrained, which allowed them to be reordered
before the shadow memory write.

Reviewed By: eugenis

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

2 years ago[NFC] Fix typos
PeixinQiao [Tue, 17 Aug 2021 09:16:37 +0000 (17:16 +0800)]
[NFC] Fix typos

Initial commit test.

2 years ago[mlir][linalg] Remove duplicate methods (NFC).
Tobias Gysi [Tue, 17 Aug 2021 07:04:21 +0000 (07:04 +0000)]
[mlir][linalg] Remove duplicate methods (NFC).

Remove duplicate methods used to check iterator types.

Reviewed By: aartbik

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

2 years ago[X86] [AMX] Replace bitcast with specific AMX intrinsics with X86 specific cast.
Bing1 Yu [Thu, 5 Aug 2021 09:01:21 +0000 (17:01 +0800)]
[X86] [AMX] Replace bitcast with specific AMX intrinsics with X86 specific cast.

There is some discussion on the bitcast for vector and x86_amx at https://reviews.llvm.org/D99152. This patch is to introduce a x86 specific cast for vector and x86_amx, so that it can avoid some unnecessary optimization by middle-end. On the other way, we have to optimize the x86 specific cast by ourselves. This patch also optimize the cast operation to eliminate redundant code.

Reviewed By: LuoYuanke

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

2 years agoAMDGPU: During img instruction ret value construction cater for non int values
David Stuttard [Wed, 5 Feb 2020 14:22:18 +0000 (14:22 +0000)]
AMDGPU: During img instruction ret value construction cater for non int values

Make sure return type is int type.

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

Change-Id: Ic02f07d1234cd51b6ed78c3fecd2cb1d6acd5644

2 years ago[flang][nfc] Tweak the FrontendAction class
Andrzej Warzynski [Fri, 13 Aug 2021 16:27:46 +0000 (16:27 +0000)]
[flang][nfc] Tweak the FrontendAction class

This patch refactors the `FrontendAction` class. It merely moves code
around so that re-using it is easier. No new functionality is
introduced.

1. Three new member methods are introduced: `RunPrescan`, `RunParse`,
`RunSemanticChecks`.
2. The following free functions are re-implemented as member methods:
  * `reportFatalSemanticErrors`
  * `reportFatalScanningErrors`
  * `reportFatalParsingErrors`
  * `reportFatalErrors`
`reportFatalSemanticErrors` is updated to resemble the other error
reporting functions and to make the API more consistent.
3. The `BeginSourceFileAction` methods are simplified and the unused
input argument is deleted.

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

2 years ago[Polly][Isl] Use isl::val::sub instead of isl::val::sub_ui. NFC
Riccardo Mori [Tue, 17 Aug 2021 07:34:28 +0000 (09:34 +0200)]
[Polly][Isl] Use isl::val::sub instead of isl::val::sub_ui. NFC

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 -  Use `isl::val::sub` instead of `isl::val::sub_ui`
 - `isl-noexceptions.h` has been generated by https://github.com/patacca/isl/commit/355e84163ae78ff637c71fb532f36d15277a2b1b

Depends on D107225

Reviewed By: Meinersbur

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

2 years ago[MLIR] [Python] Allow 'operation.parent' to return 'None'
John Demme [Tue, 17 Aug 2021 05:37:14 +0000 (22:37 -0700)]
[MLIR] [Python] Allow 'operation.parent' to return 'None'

This is more Pythonic and better matches the C++ and C APIs.

Reviewed By: stellaraccident

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

2 years ago[analyzer] Add option to SATest.py for extra checkers
Deep Majumder [Tue, 17 Aug 2021 05:12:30 +0000 (10:42 +0530)]
[analyzer] Add option to SATest.py for extra checkers

This patch adds the flag `extra-checkers` to the sub-command `build` for
passing a comma separated list of additional checkers to include.

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

2 years ago[tests] precommit tests for D107692
Yunde Zhong [Tue, 17 Aug 2021 05:02:23 +0000 (13:02 +0800)]
[tests] precommit tests for D107692

2 years ago[AsmParser] Remove MDConstant (NFC)
Kazu Hirata [Tue, 17 Aug 2021 04:21:11 +0000 (21:21 -0700)]
[AsmParser] Remove MDConstant (NFC)

The last use was removed on Sep 22, 2016 in commit
fcee2d80017f8e2db6a8ac3a70bdc0653afa7d01.

2 years ago[LNICM] Fix infinite loop
Whitney Tsang [Tue, 17 Aug 2021 03:50:13 +0000 (12:50 +0900)]
[LNICM] Fix infinite loop

There is a bug introduced by https://reviews.llvm.org/D107219 which causes an infinite loop, when there are more than 2 levels PHINode chain.

Reviewed By: uint256_t

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

2 years ago[AVR][clang] Improve search for avr-libc installation path
Ben Shi [Sat, 7 Aug 2021 08:29:27 +0000 (16:29 +0800)]
[AVR][clang] Improve search for avr-libc installation path

Search avr-libc path according to avr-gcc installation at first,
then other possible installed pathes.

Reviewed By: MaskRay

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

2 years ago[AMDGPU] Skip pseudo MIs in hazard recognizer
Christudasan Devadasan [Fri, 13 Aug 2021 02:54:42 +0000 (22:54 -0400)]
[AMDGPU] Skip pseudo MIs in hazard recognizer

Instructions like WAVE_BARRIER and SI_MASKED_UNREACHABLE
are only placeholders to prevent certain unwanted
transformations and will get discarded during assembly
emission. They should not be counted during nop insertion.

Reviewed By: rampitec

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

2 years ago[lld-macho][test] Remove ld64.lld: prefix in a diagnostic
Fangrui Song [Tue, 17 Aug 2021 02:41:11 +0000 (19:41 -0700)]
[lld-macho][test] Remove ld64.lld: prefix in a diagnostic

The convention is not to check the prefix before `error: `.
This gives flexibility if we need to rename ld64.lld to something else,
(e.g. a while ago we used ld64.lld.darwinnew).

2 years ago[split-file] Default to --no-leading-lines
Fangrui Song [Tue, 17 Aug 2021 02:23:11 +0000 (19:23 -0700)]
[split-file] Default to --no-leading-lines

It turns out that the --leading-lines may be a bad default.
[[#@LINE+-num]] is rarely used.

2 years ago[MLIR] [Python] Fix out-of-tree Windows python bindings
John Demme [Tue, 17 Aug 2021 02:18:23 +0000 (19:18 -0700)]
[MLIR] [Python] Fix out-of-tree Windows python bindings

MSVC needs to know where to put the archive (.lib) as well as the runtime
(.dll). If left to the default location, multiple rules to generate the same
file will be produced, creating a Ninja error.

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

2 years ago[lld-macho] Refactor parseSections to avoid creating isec on LLVM segments
Vincent Lee [Mon, 16 Aug 2021 22:19:43 +0000 (15:19 -0700)]
[lld-macho] Refactor parseSections to avoid creating isec on LLVM segments

Address post follow up comment in D108016. Avoid creating isec for
LLVM segments since we are skipping over it.

Reviewed By: #lld-macho, int3

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

2 years ago[AMDGPU] Make BVH isel consistent with other MIMG opcodes
Carl Ritson [Tue, 17 Aug 2021 01:24:49 +0000 (10:24 +0900)]
[AMDGPU] Make BVH isel consistent with other MIMG opcodes

Suffix opcodes with _gfx10.
Remove direct references to architecture specific opcodes.
Add a BVH flag and apply this to diassembly.
Fix a number of disassembly errors on gfx90a target caused by
previous incorrect BVH detection code.

Reviewed By: rampitec

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

2 years ago[mlir][Analysis][NFC] Clean up FlatAffineValueConstraints
Matthias Springer [Tue, 17 Aug 2021 01:27:41 +0000 (10:27 +0900)]
[mlir][Analysis][NFC] Clean up FlatAffineValueConstraints

* Rename ids to values in FlatAffineValueConstraints.
* Overall cleanup of comments in FlatAffineConstraints and FlatAffineValueConstraints.

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

2 years agoFix missing qualifier in template type diffing
Weverything [Mon, 16 Aug 2021 23:54:10 +0000 (16:54 -0700)]
Fix missing qualifier in template type diffing

Handle SubstTemplateTypeParmType so qualifiers do not get dropped from
the diagnostic message.

2 years ago[mlir][Analysis][NFC] Split FlatAffineConstraints class
Matthias Springer [Tue, 17 Aug 2021 01:08:08 +0000 (10:08 +0900)]
[mlir][Analysis][NFC] Split FlatAffineConstraints class

* Extract "value" functionality of `FlatAffineConstraints` into a new derived `FlatAffineValueConstraints` class. Current users of `FlatAffineConstraints` can use `FlatAffineValueConstraints` without additional code changes, thus NFC.
* `FlatAffineConstraints` no longer associates dimensions with SSA Values. All functionality that requires this, is moved to `FlatAffineValueConstraints`.
* `FlatAffineConstraints` no longer makes assumptions about where Values associated with dimensions are coming from.

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

2 years ago[SamplePGO][NFC] Dump function profiles in order
Hongtao Yu [Mon, 16 Aug 2021 21:17:43 +0000 (14:17 -0700)]
[SamplePGO][NFC] Dump function profiles in order

Sample profiles are stored in a string map which is basically an unordered map. Printing out profiles by simply walking the string map doesn't enforce an order. I'm sorting the map in the decreasing order of total samples to enable a more stable dump, which is good for comparing two dumps.

Reviewed By: wenlei, wlei

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

2 years ago[clang] Expose unreachable fallthrough annotation warning
Nathan Chancellor [Tue, 17 Aug 2021 00:11:07 +0000 (17:11 -0700)]
[clang] Expose unreachable fallthrough annotation warning

The Linux kernel has a macro called IS_ENABLED(), which evaluates to a
constant 1 or 0 based on Kconfig selections, allowing C code to be
unconditionally enabled or disabled at build time. For example:

int foo(struct *a, int b) {
    switch (b) {
    case 1:
        if (a->flag || !IS_ENABLED(CONFIG_64BIT))
            return 1;
        __attribute__((fallthrough));
    case 2:
        return 2;
    default:
        return 3;
    }
}

There is an unreachable warning about the fallthrough annotation in the
first case because !IS_ENABLED(CONFIG_64BIT) can be evaluated to 1,
which looks like

        return 1;
        __attribute__((fallthrough));

to clang.

This type of warning is pointless for the Linux kernel because it does
this trick all over the place due to the sheer number of configuration
options that it has.

Add -Wunreachable-code-fallthrough, enabled under -Wunreachable-code, so
that projects that want to warn on unreachable code get this warning but
projects that do not care about unreachable code can still use
-Wimplicit-fallthrough without having to make changes to their code
base.

Fixes PR51094.

Reviewed By: aaron.ballman, nickdesaulniers

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

2 years ago[MLIR] Add a bitcast method to DenseElementsAttr
Geoffrey Martin-Noble [Thu, 5 Aug 2021 23:29:59 +0000 (16:29 -0700)]
[MLIR] Add a bitcast method to DenseElementsAttr

This method bitcasts a DenseElementsAttr elementwise to one of the same
shape with a different element type.

Reviewed By: rriddle

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

2 years ago[tsan] Another attempt to fix GCC 8.3 build after D107911
Douglas Yung [Tue, 17 Aug 2021 00:01:57 +0000 (17:01 -0700)]
[tsan] Another attempt to fix GCC 8.3 build after D107911

This removes the -Werror compilation flag for x64 linux to work around a gcc bug.

GCC 8.3 reports '__tsan::v3::Event::type’ is too small to hold all values of â€˜enum class __tsan::v3::EventType’
incorrectly which gets promoted to an error and causes the build to fail.

2 years ago[lldb] Fix -Wunused-but-set-variable
Fangrui Song [Mon, 16 Aug 2021 23:41:17 +0000 (16:41 -0700)]
[lldb] Fix -Wunused-but-set-variable

2 years ago[SamplePGO] Fixing a memory issue when creating profiles on-demand
Hongtao Yu [Mon, 16 Aug 2021 16:21:13 +0000 (09:21 -0700)]
[SamplePGO] Fixing a memory issue when creating profiles on-demand

There is a on-dmeand creation of function profile during top-down processing in the sample loader when merging uninlined callees.  During the profile creation, a stack string object is used to store a newly-created MD5 name, which is then used by reference as hash key in the profile map. This makes the hash key a dangling reference when later on the stack string object is deallocated.

The issue only happens with md5 profile use and was exposed by context split work for CS profile. I'm making a fix by storing newly created names in the reader.

Reviewed By: wenlei, wmi, wlei

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

2 years agoClean up test for -f{,no-}implicit-modules-uses-lock
Duncan P. N. Exon Smith [Mon, 16 Aug 2021 23:18:11 +0000 (16:18 -0700)]
Clean up test for -f{,no-}implicit-modules-uses-lock

@arichardson pointed out in post-commit review for
https://reviews.llvm.org/D95583 (b714f73defc8e075) that `-verify` has an
optional argument that works a lot like `FileCheck`'s `-check-prefix`.
Use it to simplify the test for `-fno-implicit-modules-use-lock`!

2 years ago[tsan] Fix GCC 8.3 build after D107911
Vitaly Buka [Mon, 16 Aug 2021 23:15:57 +0000 (16:15 -0700)]
[tsan] Fix GCC 8.3 build after D107911

gcc 8.3 reports:
__tsan::v3::Event::type’ is too small to hold all values of â€˜enum class __tsan::v3::EventType’

2 years ago[NFC] Remove/replace some confusing attribute getters on Function
Arthur Eubanks [Mon, 16 Aug 2021 23:07:47 +0000 (16:07 -0700)]
[NFC] Remove/replace some confusing attribute getters on Function

2 years ago[sanitizer] Define 32bit uptr as uint
Vitaly Buka [Sat, 14 Aug 2021 23:51:10 +0000 (16:51 -0700)]
[sanitizer] Define 32bit uptr as uint

This makes it consistent with uintptr_t.

It's 45138f788c9b3c4ac5d9ae4479841c411c15190e with Darwin fix.

Reviewed By: kstoimenov

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

2 years agoRevert "[sanitizer] Fix MAC build after D108163"
Vitaly Buka [Mon, 16 Aug 2021 22:42:17 +0000 (15:42 -0700)]
Revert "[sanitizer] Fix MAC build after D108163"

They still fail to fix Darwin builds
https://green.lab.llvm.org/green/job/clang-stage1-RA/23399/consoleFull#462858634a1ca8a51-895e-46c6-af87-ce24fa4cd561

This reverts commit ae0628f716cc05ad28adf963538a67e69d58d21d.
This reverts commit 2c6448cdc2f68f8c28fd0bd9404182b81306e6e6.

2 years ago[M68k] Do not pass llvm::Function& to M68kCCState
Min-Yih Hsu [Mon, 16 Aug 2021 00:19:33 +0000 (17:19 -0700)]
[M68k] Do not pass llvm::Function& to M68kCCState

Previously we're passing `llvm::Function&` into `M68kCCState` to lower
arguments in fastcc. However, that reference might not be available if
it's a library call and we only need its argument types. Therefore,
now we're simply passing a list of argument llvm::Type-s.

This fixes PR-50752.

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

2 years ago[AsmPrinter] fix nullptr dereference for MBBs with hasAddressTaken property without BB
Afanasyev Ivan [Mon, 16 Aug 2021 22:26:57 +0000 (15:26 -0700)]
[AsmPrinter] fix nullptr dereference for MBBs with hasAddressTaken property without BB

Basic block pointer is dereferenced unconditionally for MBBs with
hasAddressTaken property.

MBBs might have hasAddressTaken property without reference to BB.
Backend developers must assign fake BB to MBB to workaround this issue
and it should be fixed.

Reviewed By: rnk

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

2 years ago[libc] dedup handling of size 4 for memset
Guillaume Chatelet [Mon, 16 Aug 2021 22:28:53 +0000 (22:28 +0000)]
[libc] dedup handling of size 4 for memset

2 years ago[sanitizer] Fix MAC build after D108163
Vitaly Buka [Mon, 16 Aug 2021 22:21:54 +0000 (15:21 -0700)]
[sanitizer] Fix MAC build after D108163

2 years ago[libc] Optimize Loop strategy
Guillaume Chatelet [Mon, 16 Aug 2021 22:12:00 +0000 (22:12 +0000)]
[libc] Optimize Loop strategy

Since the precondition for loop is `size >= T::kSize` we always expect
at least one run of the loop. This patch transforms the for-loop into a
do/while-loop which saves at least one test.

We also add a second template parameter to allow the Tail operation to
differ from the loop operation.

2 years ago[ARM] Create MQQPR and MQQQQPR register classes
David Green [Mon, 16 Aug 2021 21:58:12 +0000 (22:58 +0100)]
[ARM] Create MQQPR and MQQQQPR register classes

Similar to the MQPR register class as the MVE equivalent to QPR, this
adds MQQPR and MQQQQPR register classes for the MVE equivalents of QQPR
and QQQQPR registers. The MVE MQPR seemed have worked out quite well,
and adding MQQPR and MQQQQPR allows us to a little more accurately
specify the number of registers, calculating register pressure limits a
little better.

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

2 years ago[scudo] Use stdint types for internal types (redo)
Kostya Kortchinsky [Mon, 16 Aug 2021 18:59:15 +0000 (11:59 -0700)]
[scudo] Use stdint types for internal types (redo)

This is a redo of D108089 that broke some 32-bit builds.

`scudo::uptr` was defined as an `unsigned long` on 32-b platform,
while a `uintptr_t` is usually defined as an `unsigned int`.
This worked, this was not consistent, particularly with regard to
format string specifiers.

As suggested by Vitaly, since we are including `stdint.h`, define
the internal scudo integer types to those.

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

2 years ago[sanitizer] Define 32bit uptr as uint
Vitaly Buka [Sat, 14 Aug 2021 23:51:10 +0000 (16:51 -0700)]
[sanitizer] Define 32bit uptr as uint

This makes it consistent with uintptr_t.

It's 45138f788c9b3c4ac5d9ae4479841c411c15190e with Darwin fix.

Reviewed By: kstoimenov

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

2 years ago[mlir][tosa] Fixed depthwise conv parallel/reduction indices order
Rob Suderman [Mon, 16 Aug 2021 20:47:00 +0000 (13:47 -0700)]
[mlir][tosa] Fixed depthwise conv parallel/reduction indices order

Reduction axis should come after all parallel axis to work with vectorization.

Reviewed By: NatashaKnk

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

2 years ago[Remarks] Emit optimization remarks for atomics generating CAS loop
Anshil Gandhi [Mon, 16 Aug 2021 20:56:01 +0000 (14:56 -0600)]
[Remarks] Emit optimization remarks for atomics generating CAS loop

Implements ORE in AtomicExpand pass to report atomics generating a
compare and swap loop.

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

2 years agoAh, fix formatting, I didn't notice lldb-instr's code
Jason Molenda [Mon, 16 Aug 2021 20:46:12 +0000 (13:46 -0700)]
Ah, fix formatting, I didn't notice lldb-instr's code
additions were unusually formatted.

2 years ago[ARM][TypePromotion] Re-generate test checks. NFC
Craig Topper [Mon, 16 Aug 2021 20:36:16 +0000 (13:36 -0700)]
[ARM][TypePromotion] Re-generate test checks. NFC

Tests were missing load/store alignment. One test in casts.ll had
no check lines.

2 years agoCorrectly update reproducer hooks for SB API I added
Jason Molenda [Mon, 16 Aug 2021 20:40:07 +0000 (13:40 -0700)]
Correctly update reproducer hooks for SB API I added

In 9ea6dd5cfac0b233fbb148c1e2d0f81f816737c8 /
https://reviews.llvm.org/D88387 where I added skinny corefile
creation, I added new SB API and tried to manually update the hooks
for the reproducers. I missed a spot, and I should have used
lldb-instr to update the instrumentation automatically.

2 years ago[hwasan] Ignore lit config.enable_aliases on non-x86.
Evgenii Stepanov [Sat, 14 Aug 2021 00:15:52 +0000 (17:15 -0700)]
[hwasan] Ignore lit config.enable_aliases on non-x86.

This re-enables a number of Android tests that have been lost in
check-hwasan.

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

2 years ago[clang-offload-wrapper] Add standard notes for ELF offload images
Vyacheslav Zakharin [Fri, 13 Aug 2021 00:23:28 +0000 (17:23 -0700)]
[clang-offload-wrapper] Add standard notes for ELF offload images

The patch adds ELF notes into SHT_NOTE sections of ELF offload images
passed to clang-offload-wrapper.

The new notes use a null-terminated "LLVMOMPOFFLOAD" note name.
There are currently three types of notes:

VERSION: a string (not null-terminated) representing the ELF offload
image structure. The current version '1.0' does not put any restrictions
on the structure of the image. If we ever need to come up with a common
structure for ELF offload images (e.g. to be able to analyze the images
in libomptarget in some standard way), then we will introduce new versions.

PRODUCER: a vendor specific name of the producing toolchain.
Upstream LLVM uses "LLVM" (not null-terminated).

PRODUCER_VERSION: a vendor specific version of the producing toolchain.
Upstream LLVM uses LLVM_VERSION_STRING with optional <space> LLVM_REVISION.

All three notes are not mandatory currently.

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

2 years agoAllow rematerialization of virtual reg uses
Stanislav Mekhanoshin [Mon, 9 Aug 2021 18:12:15 +0000 (11:12 -0700)]
Allow rematerialization of virtual reg uses

Currently isReallyTriviallyReMaterializableGeneric() implementation
prevents rematerialization on any virtual register use on the grounds
that is not a trivial rematerialization and that we do not want to
extend liveranges.

It appears that LRE logic does not attempt to extend a liverange of
a source register for rematerialization so that is not an issue.
That is checked in the LiveRangeEdit::allUsesAvailableAt().

The only non-trivial aspect of it is accounting for tied-defs which
normally represent a read-modify-write operation and not rematerializable.

The test for a tied-def situation already exists in the
/CodeGen/AMDGPU/remat-vop.mir,
test_no_remat_v_cvt_f32_i32_sdwa_dst_unused_preserve.

The change has affected ARM/Thumb, Mips, RISCV, and x86. For the targets
where I more or less understand the asm it seems to reduce spilling
(as expected) or be neutral. However, it needs a review by all targets'
specialists.

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

2 years ago[lld-macho] Ignore LLVM segments to prevent duplicate syms
Vincent Lee [Thu, 12 Aug 2021 05:08:56 +0000 (22:08 -0700)]
[lld-macho] Ignore LLVM segments to prevent duplicate syms

There was an instance of a third-party archive containing multiple
_llvm symbols from different files that clashed with each other
producing duplicate symbols. Symbols under the LLVM segment
don't seem to be producing any meaningful value, so just ignore them.

Reviewed By: #lld-macho, int3

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

2 years ago[profile] Add static keyword to binary id functions
Gulfem Savrun Yeniceri [Mon, 16 Aug 2021 18:55:31 +0000 (18:55 +0000)]
[profile] Add static keyword to binary id functions

This patch adds static keyword to internal functions that write
binary id to restrict visibility to the file that they are declared.

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

2 years ago[Bazel] Update for 957334382c
Geoffrey Martin-Noble [Mon, 16 Aug 2021 19:12:38 +0000 (12:12 -0700)]
[Bazel] Update for 957334382c

Update LLVM configuration to define `HAVE_UNW_ADD_DYNAMIC_FDE` for macOS
since https://github.com/llvm/llvm-project/commit/957334382c moved that
to a define.

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

2 years agoReapply commit b7425e956
Rong Xu [Mon, 16 Aug 2021 19:16:43 +0000 (12:16 -0700)]
Reapply commit b7425e956

The commit b7425e956: [NFC] fix typos
is harmless but was reverted by accident. Reapply.

2 years agoPrevent machine licm if remattable with a vreg use
Stanislav Mekhanoshin [Mon, 9 Aug 2021 17:18:52 +0000 (10:18 -0700)]
Prevent machine licm if remattable with a vreg use

Check if a remateralizable nstruction does not have any virtual
register uses. Even though rematerializable RA might not actually
rematerialize it in this scenario. In that case we do not want to
hoist such instruction out of the loop in a believe RA will sink
it back if needed.

This already has impact on AMDGPU target which does not check for
this condition in its isTriviallyReMaterializable implementation
and have instructions with virtual register uses enabled. The
other targets are not impacted at this point although will be when
D106408 lands.

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

2 years ago[MemorySSA] Remove -enable-mssa-loop-dependency option
Nikita Popov [Sat, 14 Aug 2021 15:46:47 +0000 (17:46 +0200)]
[MemorySSA] Remove -enable-mssa-loop-dependency option

This option has been enabled by default for quite a while now.
The practical impact of removing the option is that MSSA use
cannot be disabled in default pipelines (both LPM and NPM) and
in manual LPM invocations. NPM can still choose to enable/disable
MSSA using loop vs loop-mssa.

The next step will be to require MSSA for LICM and drop the
AST-based implementation entirely.

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

2 years ago[mlir][linalg] Clear unused linalg tc operations
Robert Suderman [Mon, 16 Aug 2021 18:46:58 +0000 (11:46 -0700)]
[mlir][linalg] Clear unused linalg tc operations

These operations are not lowered to from any source dialect and are only
used for redundant tests. Removing these named ops, along with their
associated tests, will make migration to YAML operations much more
convenient.

Reviewed By: stellaraccident

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

2 years ago[mlir][sparse][python] make imports more selective
Aart Bik [Mon, 16 Aug 2021 17:31:17 +0000 (10:31 -0700)]
[mlir][sparse][python] make imports more selective

Reviewed By: bixia

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

2 years ago[MemorySSA] Remove unnecessary MSSA dependencies
Nikita Popov [Sat, 14 Aug 2021 15:55:08 +0000 (17:55 +0200)]
[MemorySSA] Remove unnecessary MSSA dependencies

LoopLoadElimination, LoopVersioning and LoopVectorize currently
fetch MemorySSA when construction LoopAccessAnalysis. However,
LoopAccessAnalysis does not actually use MemorySSA and we can pass
nullptr instead.

This saves one MemorySSA calculation in the default pipeline, and
thus improves compile-time.

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

2 years ago[PassBuilder] Don't use MemorySSA for standalone LoopRotate passes
Nikita Popov [Sat, 14 Aug 2021 14:21:56 +0000 (16:21 +0200)]
[PassBuilder] Don't use MemorySSA for standalone LoopRotate passes

Two standalone LoopRotate passes scheduled using
createFunctionToLoopPassAdaptor() currently enable MemorySSA.
However, while LoopRotate can preserve MemorySSA, it does not use
it, so requiring MemorySSA is unnecessary.

This change doesn't have a practical compile-time impact by itself,
because subsequent passes still request MemorySSA.

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

2 years agoRevert "[scudo] Use stdint types for internal scudo types"
Kostya Kortchinsky [Mon, 16 Aug 2021 18:13:48 +0000 (11:13 -0700)]
Revert "[scudo] Use stdint types for internal scudo types"

This reverts commit 5fc841d8a278ea16bae457deba35d0db6b716dd6.

2 years agoRevert "[NFC] Fix typos"
Kostya Kortchinsky [Mon, 16 Aug 2021 18:12:35 +0000 (11:12 -0700)]
Revert "[NFC] Fix typos"

This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.

2 years ago[Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the...
Alfsonso Gregory [Mon, 16 Aug 2021 18:07:50 +0000 (19:07 +0100)]
[Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

It is completely unused and not needed to be kept, so let us remove it.

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

2 years ago[scudo] Use stdint types for internal scudo types
Kostya Kortchinsky [Sun, 15 Aug 2021 16:09:46 +0000 (09:09 -0700)]
[scudo] Use stdint types for internal scudo types

`scudo::uptr` was defined as an `unsigned long` on 32-b platform,
while a `uintptr_t` is usually defined as an `unsigned int`.
This worked, this was not consistent, particularly with regard to
format string specifiers.

As suggested by Vitaly, since we are including `stdint.h`, define
the internal `scudo` integer types to those.

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

2 years ago[NFC] Fix typos
Rong Xu [Mon, 16 Aug 2021 17:15:30 +0000 (10:15 -0700)]
[NFC] Fix typos

s/senstive/senstive/g

2 years ago[NFC][AArch64] Fix unused var in release build
Jordan Rupprecht [Mon, 16 Aug 2021 17:04:32 +0000 (10:04 -0700)]
[NFC][AArch64] Fix unused var in release build

2 years ago[NFC] Trim trailing whitespaces in `llvm/CMakeLists.txt`
Shilei Tian [Mon, 16 Aug 2021 16:49:59 +0000 (12:49 -0400)]
[NFC] Trim trailing whitespaces in `llvm/CMakeLists.txt`

2 years ago[X86] Add i128 funnel shift tests
Simon Pilgrim [Mon, 16 Aug 2021 16:25:34 +0000 (17:25 +0100)]
[X86] Add i128 funnel shift tests

Test coverage for D108058

2 years agoFix whitespace typo in 94b4598
Paul Robinson [Mon, 16 Aug 2021 16:27:48 +0000 (09:27 -0700)]
Fix whitespace typo in 94b4598

2 years ago[profile] Don't use pragma comment linker on mingw
Nikita Popov [Sun, 15 Aug 2021 21:43:34 +0000 (23:43 +0200)]
[profile] Don't use pragma comment linker on mingw

At least when compiling with gcc, this is not supported and will
result in errors when linking against the profiler runtime. Only
use the pragma comment linker based code with MSVC, but not with
a mingw toolchain. This also undoes D107620, which shouldn't be
relevant anymore.

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

2 years ago[PS4] stp[n]cpy not available on PS4
Paul Robinson [Mon, 16 Aug 2021 15:42:21 +0000 (08:42 -0700)]
[PS4] stp[n]cpy not available on PS4

2 years ago[lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage
Raphael Isemann [Mon, 16 Aug 2021 15:39:10 +0000 (17:39 +0200)]
[lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage

Regression tests for D108088 .

Reviewed By: mib

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

2 years ago[TypePromotion] Don't mutate the result type of SwitchInst.
Craig Topper [Mon, 16 Aug 2021 15:42:00 +0000 (08:42 -0700)]
[TypePromotion] Don't mutate the result type of SwitchInst.

SwitchInst should have a void result type.

Add a check to the verifier to catch this error.

Reviewed By: samparker

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

2 years ago[libc++][NFC] Replace uses of 'constexpr friend' by 'friend constexpr'
Louis Dionne [Mon, 16 Aug 2021 15:42:30 +0000 (11:42 -0400)]
[libc++][NFC] Replace uses of 'constexpr friend' by 'friend constexpr'

This is done for consistency, since that's what we do everywhere else
in the library.

2 years ago[lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage
Dimitry Andric [Sun, 15 Aug 2021 15:59:32 +0000 (17:59 +0200)]
[lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage

When assertions are turned off, the `llvm::Error` value created at the
start of this function is overwritten using the move-assignment
operator, but the success value is never checked. Whenever a TypeSystem
cannot be found or created, this can lead to lldb core dumping with:

    Program aborted due to an unhandled Error:
    Error value was Success. (Note: Success values must still be checked prior to being destroyed).

Fix this by not creating a `llvm::Error` value in advance, and directly
returning the result of `llvm::make_error` instead, whenever an error is
encountered.

See also: <https://bugs.freebsd.org/253881> and
<https://bugs.freebsd.org/257829>.

Reviewed By: teemperor

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

2 years ago[DAG] Fold concat_vectors(concat_vectors(x,y),concat_vectors(a,b)) -> concat_vectors...
Simon Pilgrim [Mon, 16 Aug 2021 14:53:31 +0000 (15:53 +0100)]
[DAG] Fold concat_vectors(concat_vectors(x,y),concat_vectors(a,b)) -> concat_vectors(x,y,a,b)

Follow-up to D107068, attempt to fold nested concat_vectors/undefs, as long as both the vector and inner subvector types are legal.

This exposed the same issue in ARM's MVE LowerCONCAT_VECTORS_i1 (raised as PR51365) and AArch64's performConcatVectorsCombine which both assumed concat_vectors only took 2 subvector operands.

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

2 years ago[OpenMP] Add a few small fixes
Peyton, Jonathan L [Mon, 28 Jun 2021 21:27:27 +0000 (16:27 -0500)]
[OpenMP] Add a few small fixes

* Add comment to help ensure new construct data are added in two places
* Check for division by zero in the loop worksharing code
* Check for syntax errors in parrange parsing

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

2 years ago[OpenMP] Fix incorrect parameters to sscanf_s call
Peyton, Jonathan L [Tue, 13 Jul 2021 19:42:27 +0000 (14:42 -0500)]
[OpenMP] Fix incorrect parameters to sscanf_s call

On Windows, the documentation states that when using sscanf_s,
each %c and %s specifier must also have additional size parameter.
This patch adds the size parameter in the one place where %c is
used.

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

2 years agoRevert 54a61c94f93 and its follow up in 547b712500e
Jeremy Morse [Mon, 16 Aug 2021 14:43:38 +0000 (15:43 +0100)]
Revert 54a61c94f93 and its follow up in 547b712500e

These were part of D107823, however asan  has found something excitingly
wrong happening:

https://lab.llvm.org/buildbot/#/builders/5/builds/10543/steps/13/logs/stdio

2 years ago[InstCombine] allow for constant-folding in GEP transform
Sanjay Patel [Mon, 16 Aug 2021 14:28:46 +0000 (10:28 -0400)]
[InstCombine] allow for constant-folding in GEP transform

This would crash the reduced test or as described in
https://llvm.org/PR51485
...because we can't mark a constant (-expression) with 'inbounds'.

2 years agoFix type in DenseMap<SmallBitVector, *> to match V.size()
Renato Golin [Mon, 16 Aug 2021 10:53:30 +0000 (11:53 +0100)]
Fix type in DenseMap<SmallBitVector, *> to match V.size()

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