platform/upstream/llvm.git
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

2 years ago[mlir][linalg][bufferize][NFC] Analyze OpOperands instead of OpResults
Matthias Springer [Fri, 7 Jan 2022 15:56:13 +0000 (00:56 +0900)]
[mlir][linalg][bufferize][NFC] Analyze OpOperands instead of OpResults

With this change, the analysis takes a look at OpOperands instead of OpResults. OpOperands can bufferize out-of-place (even if they have no aliasing OpResults). The analysis does no longer care about OpResults.

Previously, only OpResults could bufferize out-of-place, so OpOperands that have no aliasing OpResults were never copied by Comprehensive Bufferize. This does not fit wwell with the new CallOp bufferization that is introduced in a subsequent change. In essence, called FuncOps can then be treated as "black boxes" that may read/write to any bbArg, even if they do not return anything.

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

2 years agoRemove redundant return statements (NFC)
Kazu Hirata [Fri, 7 Jan 2022 15:42:35 +0000 (07:42 -0800)]
Remove redundant return statements (NFC)

Identified by readability-redundant-control-flow.

2 years ago[mlir][linalg][bufferize][NFC] Add explicit inplaceable attrs to test cases
Matthias Springer [Fri, 7 Jan 2022 15:21:50 +0000 (00:21 +0900)]
[mlir][linalg][bufferize][NFC] Add explicit inplaceable attrs to test cases

This is in preparation of fixing CallOp bufferization. Add explicit linalg.inplaceable attrs to all bbArgs, except for the ones where inplaceability should be decided by the analysis.

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

2 years ago[mlir][linalg][bufferize] Fix copy elision in `getResultBuffer`
Matthias Springer [Fri, 7 Jan 2022 15:07:50 +0000 (00:07 +0900)]
[mlir][linalg][bufferize] Fix copy elision in `getResultBuffer`

A buffer copy may not be elided if the to-be-bufferized op is reading the data.

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

2 years ago[Clang] Implement the rest of __builtin_elementwise_* functions.
Jun Zhang [Fri, 7 Jan 2022 15:11:36 +0000 (15:11 +0000)]
[Clang] Implement the rest of __builtin_elementwise_* functions.

The patch implement the rest of __builtin_elementwise_* functions
specified in D111529, including:
* __builtin_elementwise_floor
* __builtin_elementwise_roundeven
* __builtin_elementwise_trunc

Signed-off-by: Jun <jun@junz.org>
Reviewed By: fhahn

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

2 years ago[clang-format] Use range-for loops. NFC.
Marek Kurdej [Fri, 7 Jan 2022 14:21:57 +0000 (15:21 +0100)]
[clang-format] Use range-for loops. NFC.

* Avoid if check on every element of the loop when printing symbols.

2 years ago[RISCV] Add missing e_flag EF_RISCV_TSO
luxufan [Fri, 7 Jan 2022 15:01:07 +0000 (23:01 +0800)]
[RISCV] Add missing e_flag EF_RISCV_TSO

This flag was defined here https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc

Reviewed By: asb, MaskRay, jhenderson

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

2 years ago[libc++] Add missing templated version of `std::lerp`.
Arthur O'Dwyer [Mon, 27 Dec 2021 03:16:45 +0000 (22:16 -0500)]
[libc++] Add missing templated version of `std::lerp`.

Fixes #50806.

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

2 years ago[SCEVExpand] Only create required predicate checks.
Florian Hahn [Fri, 7 Jan 2022 14:44:03 +0000 (14:44 +0000)]
[SCEVExpand] Only create required predicate checks.

Currently generateOverflowCheck always creates code for Step being
negative and positive, followed by a select at the end depending on
Step's sign.

This patch updates the code to only create either the checks for step
being positive or negative, if the sign is known.

Follow-up to D116696.

Reviewed By: reames

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

2 years ago[LoopVersioning] Move loop-versioning test to correct directory.
Florian Hahn [Fri, 7 Jan 2022 14:35:13 +0000 (14:35 +0000)]
[LoopVersioning] Move loop-versioning test to correct directory.

The moved test was incorrectly placed in Analysis/LoopAccessAnalysis as
it runs loop-versioning.

2 years ago[clangd] Polish clangd/inlayHints and expose them by default.
Sam McCall [Wed, 5 Jan 2022 21:40:50 +0000 (22:40 +0100)]
[clangd] Polish clangd/inlayHints and expose them by default.

This means it's a "real feature" in clangd 14, albeit one that requires special
client support.

- remove "preview" from the flag description
- expose the `clangdInlayHints` capability by default
- provide `position` as well as `range`
- support `InlayHintsParams.range` to restrict the range retrieved
- inlay hint list is in document order (sorted by position)

Still to come: control feature via config rather than flag.

Fixes https://github.com/clangd/clangd/issues/313
Protocol doc is in https://github.com/llvm/clangd-www/pull/56/files

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

2 years agosanitizer_common: prefix thread-safety macros with SANITIZER_
Dmitry Vyukov [Wed, 5 Jan 2022 12:35:13 +0000 (13:35 +0100)]
sanitizer_common: prefix thread-safety macros with SANITIZER_

Currently we use very common names for macros like ACQUIRE/RELEASE,
which cause conflicts with system headers.
Prefix all macros with SANITIZER_ to avoid conflicts.

Reviewed By: vitalybuka

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

2 years ago[X86] Combine reduce(add (mul x, y)) to VNNI instruction.
Luo, Yuanke [Mon, 20 Dec 2021 14:35:27 +0000 (22:35 +0800)]
[X86] Combine reduce(add (mul x, y)) to VNNI instruction.

For below C code, we can use VNNI to combine the mul and add operation.
int usdot_prod_qi(unsigned char *restrict a, char *restrict b, int c,
                  int n) {
  int i;
  for (i = 0; i < 32; i++) {
    c += ((int)a[i] * (int)b[i]);
  }
  return c;
}
We didn't support the combine acoss basic block in this patch.

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

2 years agoRevert "Unaligned Access Warning Added"
Archibald Elliott [Fri, 7 Jan 2022 13:07:30 +0000 (13:07 +0000)]
Revert "Unaligned Access Warning Added"

This reverts commits:
2cd2600abaf3c604889b77ab408fdf89d7a21c48
11c67e5a4e99f51ec66c9781710f81955cfd5e24

Due to test failures on Windows.

2 years ago[AMDGPU] Enable divergence-driven 'ctpop' selection
alex-t [Sun, 26 Dec 2021 12:31:39 +0000 (15:31 +0300)]
[AMDGPU] Enable divergence-driven 'ctpop' selection

This change adds the patterns and divergence predicates for the ctpop (bitcount) nodes
to make them selected according to the divergence.

Reviewed By: foad

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

2 years ago[x86] add tests for select with -1 operand; NFC
Sanjay Patel [Thu, 6 Jan 2022 19:12:02 +0000 (14:12 -0500)]
[x86] add tests for select with -1 operand; NFC

2 years ago[mlir][OpDSL] Separate `ReduceFn` and `ReduceFnUse`.
gysit [Fri, 7 Jan 2022 12:49:44 +0000 (12:49 +0000)]
[mlir][OpDSL] Separate `ReduceFn` and `ReduceFnUse`.

The revision distinguishes `ReduceFn` and `ReduceFnUse`. The latter has the reduction dimensions attached while the former specifies the arithmetic function only. This separation allows us to adapt the reduction syntax a little bit and specify the reduction dimensions using square brackets (in contrast to the round brackets used for the values to reduce). It als is a preparation to add reduction function attributes to OpDSL. A reduction function attribute shall only specify the arithmetic function and not the reduction dimensions.

Example:
```
ReduceFn.max_unsigned(D.kh, D.kw)(...)
```
changes to:
```
ReduceFn.max_unsigned[D.kh, D.kw](...)
```

Depends On D115240

Reviewed By: stellaraccident

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

2 years ago[mlir][OpDSL] Rename `PrimFn` to `ArithFn`.
gysit [Fri, 7 Jan 2022 12:37:52 +0000 (12:37 +0000)]
[mlir][OpDSL] Rename `PrimFn` to `ArithFn`.

The revision renames `PrimFn` to `ArithFn`. The name resembles the newly introduced arith dialect that implements most of the arithmetic functions. An exception are log/exp that are part of the math dialect.

Depends On D115239

Reviewed By: stellaraccident

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

2 years ago[mlir][OpDSL] Add `TypeFn` class.
gysit [Fri, 7 Jan 2022 12:23:11 +0000 (12:23 +0000)]
[mlir][OpDSL] Add `TypeFn` class.

This revision introduces a the `TypeFn` class that similar to the `PrimFn` class contains an extensible set of type conversion functions. Having the same mechanism for both type conversion functions and arithmetic functions improves code consistency. Additionally, having an explicit function class and function name is a prerequisite to specify a conversion or arithmetic function via attribute. In a follow up commits, we will introduce function attributes to make OpDSL operations more generic. In particular, the goal is to handle signed and unsigned computation in one operations. Today, there is a linalg.matmul and a linalg.matmul_unsigned.

The commit implements the following changes:
- Introduce the class of type conversion functions `TypeFn`
- Replace the hardwired cast and cast_unsigned ops by the `TypeFn` counterparts
- Adapt the python and C++ code generation paths to support the new cast operations

Example:
```
cast(U, A[D.m, D.k])
```
changes to
```
TypeFn.cast(U, A[D.m, D.k])
```

Depends On D115237

Reviewed By: stellaraccident

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

2 years ago[mlir][python] Use a named object
Adrian Kuegel [Fri, 7 Jan 2022 12:22:32 +0000 (13:22 +0100)]
[mlir][python] Use a named object

Currently, the object would be immediately destroyed after creation.
Found by ClangTidy bugprone-unused-raii.

2 years ago[mlir][OpDSL] Rename `AttributeDef` to `IndexAttrDef`.
gysit [Fri, 7 Jan 2022 08:59:16 +0000 (08:59 +0000)]
[mlir][OpDSL] Rename `AttributeDef` to `IndexAttrDef`.

Renaming `AttributeDef` to `IndexAttrDef` prepares OpDSL to support different kinds of attributes and more closely reflects the purpose of the attribute.

Reviewed By: nicolasvasilache

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

2 years ago[AMDGPU] Regenerate MIR checks for G_[SU]BFX
Jay Foad [Fri, 7 Jan 2022 11:46:01 +0000 (11:46 +0000)]
[AMDGPU] Regenerate MIR checks for G_[SU]BFX

2 years ago[AMDGPU] Regenerate G_[SU]BFX checks using some common prefixes
Jay Foad [Fri, 7 Jan 2022 11:43:15 +0000 (11:43 +0000)]
[AMDGPU] Regenerate G_[SU]BFX checks using some common prefixes

2 years ago[flang] update to reflect MLIR LLVM::GEPOp changes
Alex Zinenko [Fri, 7 Jan 2022 11:46:01 +0000 (12:46 +0100)]
[flang] update to reflect MLIR LLVM::GEPOp changes

2 years ago[GlobalISel] Fix typo Extact to Extract in function name. NFC.
Jay Foad [Fri, 7 Jan 2022 11:04:25 +0000 (11:04 +0000)]
[GlobalISel] Fix typo Extact to Extract in function name. NFC.

2 years ago[mlir] Provide a home for mlir::LLVM::GEPOp::kDynamicIndex
Benjamin Kramer [Fri, 7 Jan 2022 11:04:17 +0000 (12:04 +0100)]
[mlir] Provide a home for mlir::LLVM::GEPOp::kDynamicIndex

C++14 requires this and will trigger linker errors when optimizations
are disabled.

2 years ago[mlir] Use const reference for loop iteration variable.
Adrian Kuegel [Fri, 7 Jan 2022 11:00:53 +0000 (12:00 +0100)]
[mlir] Use const reference for loop iteration variable.

2 years ago[clang][driver] Don't pass -Wunaligned-access to cc1as
Archibald Elliott [Fri, 7 Jan 2022 10:45:26 +0000 (10:45 +0000)]
[clang][driver] Don't pass -Wunaligned-access to cc1as

This is to fix some failing assembler tests.

2 years ago[clang-format] Use prefix increment and decrement. NFC.
Marek Kurdej [Fri, 7 Jan 2022 10:19:53 +0000 (11:19 +0100)]
[clang-format] Use prefix increment and decrement. NFC.

2 years ago[NFC] Pre-commit case for PowerPC perfect shuffle
Qiu Chaofan [Fri, 7 Jan 2022 10:07:26 +0000 (18:07 +0800)]
[NFC] Pre-commit case for PowerPC perfect shuffle

2 years ago[NFCI][IR] MinMaxIntrinsic: add some more helper methods, and use them
Roman Lebedev [Fri, 7 Jan 2022 09:40:06 +0000 (12:40 +0300)]
[NFCI][IR] MinMaxIntrinsic: add some more helper methods, and use them

2 years ago[RISCV] Supplement PACKH instruction pattern
Lian Wang [Fri, 7 Jan 2022 09:18:33 +0000 (17:18 +0800)]
[RISCV] Supplement PACKH instruction pattern

Optimize (rs1 & 255) | ((rs2 & 255) << 8) -> (PACKH rs1, rs2).

Reviewed By: craig.topper

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

2 years ago[CodeGen] Support opaque pointers for inline asm
Nikita Popov [Fri, 7 Jan 2022 09:55:01 +0000 (10:55 +0100)]
[CodeGen] Support opaque pointers for inline asm

This is the last part of D116531. Fetch the type of the indirect
inline asm operand from the elementtype attribute, rather than
the pointer element type.

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

2 years agoUnaligned Access Warning Added
Mubashar Ahmad [Thu, 23 Dec 2021 16:37:44 +0000 (16:37 +0000)]
Unaligned Access Warning Added

Added warning for potential cases of
unaligned access when option
-mno-unaligned-access has been specified

2 years ago[IR] Add ConstraintInfo::hasArg() helper (NFC)
Nikita Popov [Fri, 7 Jan 2022 09:37:26 +0000 (10:37 +0100)]
[IR] Add ConstraintInfo::hasArg() helper (NFC)

Checking whether a constraint corresponds to an argument is a
recurring pattern.

2 years ago[Clang][Sema] Avoid crashing for va_arg expressions with bool argument
Egor Zhdan [Fri, 7 Jan 2022 09:30:25 +0000 (10:30 +0100)]
[Clang][Sema] Avoid crashing for va_arg expressions with bool argument

This change fixes a compiler crash that was introduced in https://reviews.llvm.org/D103611: `Sema::BuildVAArgExpr` attempted to retrieve a corresponding signed type for `bool` by calling `ASTContext::getCorrespondingSignedType`.

rdar://86580370

Reviewed By: aaron.ballman

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

2 years ago[SystemZ][z/OS] Fix test failure when SystemZ target is not built
Jay Foad [Fri, 7 Jan 2022 09:39:01 +0000 (09:39 +0000)]
[SystemZ][z/OS] Fix test failure when SystemZ target is not built

2 years ago[clang-format] Fix `BraceWrapping: AfterFunction` affecting synchronized blocks in...
Marek Kurdej [Fri, 7 Jan 2022 09:02:45 +0000 (10:02 +0100)]
[clang-format] Fix `BraceWrapping: AfterFunction` affecting synchronized blocks in Java.

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

Before this change, BraceWrapping: AfterFunction would affect synchronized blocks in Java, but they should be formatted w.r.t. BraceWrapping: AfterControlStatement.

Using the config:
```
BreakBeforeBraces: Custom
BraceWrapping:
  AfterControlStatement: false
  AfterFunction: true
```

would result in misformatted code like:
```
class Foo {
  void bar()
  {
    synchronized (this)
    {
      a();
      a();
    }
  }
}
```

instead of:
```
class Foo {
  void bar()
  {
    synchronized (this) {
      a();
      a();
    }
  }
}
```

Reviewed By: MyDeveloperDay, owenpan

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

2 years ago[clang-format] Use range-for loops. NFC.
Marek Kurdej [Fri, 7 Jan 2022 08:55:04 +0000 (09:55 +0100)]
[clang-format] Use range-for loops. NFC.

Reviewed By: MyDeveloperDay, owenpan

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

2 years ago[mlir] Require struct indices in LLVM::GEPOp to be constant
Alex Zinenko [Thu, 6 Jan 2022 22:30:15 +0000 (23:30 +0100)]
[mlir] Require struct indices in LLVM::GEPOp to be constant

Recent commits added a possibility for indices in LLVM dialect GEP operations
to be supplied directly as constant attributes to ensure they remain such until
translation to LLVM IR happens. Make this required for indexing into LLVM
struct types to match LLVM IR requirements, otherwise the translation would
assert on constructing such IR.

For better compatibility with MLIR-style operation construction interface,
allow GEP operations to be constructed programmatically using Values pointing
to known constant operations as struct indices.

Depends On D116758

Reviewed By: wsmoses

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

2 years ago[mlir] Add ConstantLike trait to LLVM::ConstantOp
Alex Zinenko [Thu, 6 Jan 2022 22:29:52 +0000 (23:29 +0100)]
[mlir] Add ConstantLike trait to LLVM::ConstantOp

This make LLVM dialect constants to work with `m_constant` matches. Implement
the folding hook for this operation as required by the trait. This in turn
allows LLVM::ConstantOp to properly participate in constant-folding.

Depends On D116757

Reviewed By: wsmoses

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

2 years ago[mlir] Make it possible to directly supply constant values to LLVM GEPOp
Alex Zinenko [Thu, 6 Jan 2022 22:29:15 +0000 (23:29 +0100)]
[mlir] Make it possible to directly supply constant values to LLVM GEPOp

In LLVM IR, the GEP indices that correspond to structures are required to be
i32 constants. MLIR models constants as just values defined by special
operations, and there is no verification that it is the case for structure
indices in GEP. Furthermore, some common transformations such as control flow
simplification may lead to the operands becoming non-constant. Make it possible
to directly supply constant values to LLVM GEPOp to guarantee they remain
constant until the translation to LLVM IR. This is not yet a requirement and
the verifier is not modified, this will be introduced separately.

Reviewed By: wsmoses

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

2 years ago[LibCalls] Infer same attrs for reallocf() as realloc()
Nikita Popov [Fri, 7 Jan 2022 08:48:10 +0000 (09:48 +0100)]
[LibCalls] Infer same attrs for reallocf() as realloc()

reallocf() is the same as realloc() but frees the input pointer
on failure as well. We can infer the same attributes.

Also combine some cases that infer the same attributes and are
logically related.

2 years ago[LegalizeTypes][VP] Add splitting support for vp.select
Victor Perez [Fri, 7 Jan 2022 07:54:08 +0000 (07:54 +0000)]
[LegalizeTypes][VP] Add splitting support for vp.select

Split vp.select in a similar way as vselect, splitting also the length
parameter.

Reviewed By: craig.topper

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

2 years ago[llvm] Use true/false instead of 1/0 (NFC)
Kazu Hirata [Fri, 7 Jan 2022 08:39:13 +0000 (00:39 -0800)]
[llvm] Use true/false instead of 1/0 (NFC)

Identified with modernize-use-bool-literals.

2 years ago[MLIR][Arith] Fold repeated xor and trunc
William S. Moses [Wed, 29 Dec 2021 19:30:34 +0000 (14:30 -0500)]
[MLIR][Arith] Fold repeated xor and trunc

This patch adds two folds. One for a repeated xor (e.g. xor(xor(x, a), a)) and one for a repeated trunc (e.g. trunc(trunc(x))).

Reviewed By: ftynse

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

2 years ago[LoopUnroll] Remove unrelated passes from test (NFC)
Nikita Popov [Fri, 7 Jan 2022 08:20:23 +0000 (09:20 +0100)]
[LoopUnroll] Remove unrelated passes from test (NFC)

Manually run these and use the result as the initial input for
the test.

2 years ago[ModuleUtils] Remove dead arg from filterDeadComdatFunctions() (NFC)
Nikita Popov [Fri, 7 Jan 2022 08:12:16 +0000 (09:12 +0100)]
[ModuleUtils] Remove dead arg from filterDeadComdatFunctions() (NFC)

The module argument is no longer used.

2 years ago[SystemZ] Add missing elementtype in python test (NFC)
Nikita Popov [Fri, 7 Jan 2022 08:07:28 +0000 (09:07 +0100)]
[SystemZ] Add missing elementtype in python test (NFC)

Missed this originally because it does not run locally.

2 years ago[NFC] Fix endif comments to match with include guard
Qiu Chaofan [Fri, 7 Jan 2022 07:52:59 +0000 (15:52 +0800)]
[NFC] Fix endif comments to match with include guard

2 years agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Fri, 7 Jan 2022 07:44:02 +0000 (23:44 -0800)]
Ensure newlines at the end of files (NFC)

2 years ago[X86] add dwarf information for loop stack probe
Erik Desjardins [Fri, 7 Jan 2022 07:02:45 +0000 (15:02 +0800)]
[X86] add dwarf information for loop stack probe

This patch is based on https://reviews.llvm.org/D99585.

While inside the stack probing loop, temporarily change the CFA
to be based on r11/eax, which are already used to hold the loop bound.
The stack pointer cannot be used for CFI here as it changes during the loop,
so it does not have a constant offset to the CFA.

Co-authored-by: YangKeao <keao.yang@yahoo.com>
Reviewed By: nagisa

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

2 years ago[Target] Remove redundant member initialization (NFC)
Kazu Hirata [Fri, 7 Jan 2022 06:01:44 +0000 (22:01 -0800)]
[Target] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

2 years ago[mlir][OpenMP] Added omp.atomic.write lowering to LLVM IR
Shraiysh Vaishay [Wed, 5 Jan 2022 11:31:30 +0000 (17:01 +0530)]
[mlir][OpenMP] Added omp.atomic.write lowering to LLVM IR

This patch adds omp.atomic.write lowering to LLVM IR.
Also, changed the syntax to have equal symbol instead of the comma to
make it more intuitive.

Reviewed By: kiranchandramohan, peixin

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

2 years ago[RISCV][NFC] Use sub operator to generate register list
wangpc [Fri, 7 Jan 2022 04:29:25 +0000 (12:29 +0800)]
[RISCV][NFC] Use sub operator to generate register list

There are several duplicated lines for generating GPRXXX's
register list that can be eliminated by using `sub` operator.

Reviewed By: asb

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

2 years agoRevert "[lldb] Compute fully qualified command names in FindCommandsForApropos"
Dave Lee [Fri, 7 Jan 2022 04:15:19 +0000 (20:15 -0800)]
Revert "[lldb] Compute fully qualified command names in FindCommandsForApropos"

This reverts commit b3bfd595a548cd85b12e4e83729436cb73b26f29.

2 years ago[lldb] Compute fully qualified command names in FindCommandsForApropos
Dave Lee [Sun, 2 Jan 2022 04:07:07 +0000 (20:07 -0800)]
[lldb] Compute fully qualified command names in FindCommandsForApropos

Fixes incomplete command names in `apropos` results.

The full command names given by `apropos` have come from command name string
literals given to `CommandObject` constructors. For most commands, this has
been accurate, but some commands have incorrect strings. This results in
`apropos` output that doesn't tell the user the full command name they might
want learn more about. These strings can be fixed.

There's a seperate issue that can't be fixed as easily: plugin commands. With
the way they're implemented, plugin commands have to exclude the root command
from their command name string. To illustrate, the `language objc` subcommand
has to set its command name string to "objc", which results in apropos printing
results as `objc ...` instead of `language objc ...`.

To fix both of these issues, this commit changes `FindCommandsForApropos` to
derive the fully qualified command name using the keys of subcommand maps.

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

2 years ago[NFC][RISCV] Make the macro names more uniform
Shao-Ce SUN [Fri, 7 Jan 2022 03:09:15 +0000 (11:09 +0800)]
[NFC][RISCV] Make the macro names more uniform

Reviewed By: craig.topper

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

2 years agoRevert "Extract utility function for checking initial value of allocation [NFC]"
Philip Reames [Fri, 7 Jan 2022 03:05:16 +0000 (19:05 -0800)]
Revert "Extract utility function for checking initial value of allocation [NFC]"

This reverts commit 9ce30fe86f58df45b2c5daa601802593601c471d.  Appears to be causing a problem on a buildbot, revert while investigating.

https://green.lab.llvm.org/green//job/clang-stage1-RA/26818/consoleFull#-1502953973d489585b-5106-414a-ac11-3ff90657619c

2 years ago[M68k][NFC] Fix typo. BCNG->BCHG
Jim Lin [Fri, 7 Jan 2022 02:00:21 +0000 (10:00 +0800)]
[M68k][NFC] Fix typo. BCNG->BCHG