platform/upstream/llvm.git
4 years ago[lldb] Fix UBSan regression in GetSLEB128
Jan Kratochvil [Fri, 5 Jun 2020 09:59:26 +0000 (11:59 +0200)]
[lldb] Fix UBSan regression in GetSLEB128

It regressed recently by my: https://reviews.llvm.org/D81119

4 years ago[VE] Support fixed-point operation instructions in MC layer
Kazushi (Jam) Marukawa [Fri, 5 Jun 2020 09:55:47 +0000 (11:55 +0200)]
[VE] Support fixed-point operation instructions in MC layer

Summary:
Add regression tests of asmparser, mccodeemitter, and disassembler for
fixed-point operation instructions.  In order to support them, we add
MImm parser to asmparser.  Also add a new MPD instruction which is one
of multiply instructions.

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

4 years agoNFC: Formatting fix in TableGEn/OptParserEmitter.cpp
Daniel Grumberg [Fri, 5 Jun 2020 09:46:38 +0000 (10:46 +0100)]
NFC: Formatting fix in TableGEn/OptParserEmitter.cpp

4 years agoMemorySSAUpdater.h - reduce unnecessary includes to forward declarations. NFC.
Simon Pilgrim [Fri, 5 Jun 2020 09:45:42 +0000 (10:45 +0100)]
MemorySSAUpdater.h - reduce unnecessary includes to forward declarations. NFC.

Remove unnecessary MemoryAccess forward declaration as its already included from MemorySSA.h

Move implicit include dependencies down to source files.

4 years agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Fri, 5 Jun 2020 09:41:31 +0000 (10:41 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.

Add llvm_unreachable after switch statement for TestLanguage enum

4 years ago[ARM] Add __bf16 as new Bfloat16 C Type
Ties Stuij [Thu, 4 Jun 2020 23:20:02 +0000 (00:20 +0100)]
[ARM] Add __bf16 as new Bfloat16 C Type

Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.

This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.

The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij

Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli

Reviewed By: SjoerdMeijer

Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits

Tags: #clang

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

4 years ago[Mlir] Implement printer, parser, verifier and builder for shape.reduce.
Alexander Belyaev [Fri, 5 Jun 2020 09:16:53 +0000 (11:16 +0200)]
[Mlir] Implement printer, parser, verifier and builder for shape.reduce.

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

4 years ago[NFC][SCEV] Add test with 'or' with no common bits set
Roman Lebedev [Fri, 5 Jun 2020 09:18:15 +0000 (12:18 +0300)]
[NFC][SCEV] Add test with 'or' with no common bits set

4 years ago[CostModel] Unify getMemoryOpCost
Sam Parker [Fri, 5 Jun 2020 09:09:56 +0000 (10:09 +0100)]
[CostModel] Unify getMemoryOpCost

Use getMemoryOpCost from the generic implementation of getUserCost
and have getInstructionThroughput return the result of that for loads
and stores.

This also means that the X86 implementation of getUserCost can be
removed with the functionality folded into its getMemoryOpCost.

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

4 years ago[mlir] NFC formatting cleanup.
Tres Popp [Fri, 5 Jun 2020 08:12:00 +0000 (10:12 +0200)]
[mlir] NFC formatting cleanup.

4 years ago[mlir] Canonicalization of shape.assuming
Tres Popp [Wed, 20 May 2020 13:56:40 +0000 (15:56 +0200)]
[mlir] Canonicalization of shape.assuming

Summary:
This will inline the region to a shape.assuming in the case that the
input witness is found to be statically true.

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

4 years ago[mlir] Folding and canonicalization of shape.cstr_eq
Tres Popp [Wed, 20 May 2020 13:54:57 +0000 (15:54 +0200)]
[mlir] Folding and canonicalization of shape.cstr_eq

In the case of all inputs being constant and equal, cstr_eq will be
replaced with a true_witness.

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

4 years ago[mlir] Canonicalization and folding of shape.cstr_broadcastable
Tres Popp [Wed, 20 May 2020 13:52:55 +0000 (15:52 +0200)]
[mlir] Canonicalization and folding of shape.cstr_broadcastable

This allows replacing of this op with a true witness in the case of both
inputs being const_shapes and being found to be broadcastable.

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

4 years ago[mlir] Add folding for shape.any
Tres Popp [Wed, 20 May 2020 14:12:57 +0000 (16:12 +0200)]
[mlir] Add folding for shape.any

If any input to shape.any is a const_shape, shape.any can be replaced
with that input.

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

4 years ago[mlir] Folding of shape.assuming_all
Tres Popp [Thu, 4 Jun 2020 10:43:13 +0000 (12:43 +0200)]
[mlir] Folding of shape.assuming_all

This allows assuming_all to be replaced when all inputs are known to be
statically passing witnesses.

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

4 years ago[mlir] Add a shape op that returns a constant witness
Tres Popp [Wed, 20 May 2020 13:56:12 +0000 (15:56 +0200)]
[mlir] Add a shape op that returns a constant witness

This will later be used during canonicalization and folding steps to replace
statically known passing constraints.

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

4 years ago[Mlir] Add assembly format for `shape.mul`.
Alexander Belyaev [Thu, 4 Jun 2020 20:40:48 +0000 (22:40 +0200)]
[Mlir] Add assembly format for `shape.mul`.

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

4 years ago[NFC][SCEV] Some tests for shifts by bitwidth-2/bitwidth-1 w/ no-wrap flags
Roman Lebedev [Fri, 5 Jun 2020 08:23:16 +0000 (11:23 +0300)]
[NFC][SCEV] Some tests for shifts by bitwidth-2/bitwidth-1 w/ no-wrap flags

4 years agoFix gcc5 build of ASTMatchersTest.h
Hans Wennborg [Fri, 5 Jun 2020 08:32:40 +0000 (10:32 +0200)]
Fix gcc5 build of ASTMatchersTest.h

After a180d54 the build was failing with:

In file included from /work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:9:0:
/work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersTest.h:
In function ‘llvm::ArrayRef<clang::TestLanguage> clang::ast_matchers::langCxx11OrLater()’:
/work/llvm.monorepo/clang/unittests/ASTMatchers/ASTMatchersTest.h:64:10:
error: could not convert ‘(const clang::TestLanguage*)(& Result)’ from
‘const clang::TestLanguage*’ to ‘llvm::ArrayRef<clang::TestLanguage>’
   return Result;
          ^

4 years ago[clangd] Populate the parse options to CodeCompletion/SignatureHelp.
Haojian Wu [Wed, 3 Jun 2020 08:34:05 +0000 (10:34 +0200)]
[clangd] Populate the parse options to CodeCompletion/SignatureHelp.

Summary: A followup of D79938.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[VE] Add AND/OR/XOR regression tests
Kazushi (Jam) Marukawa [Fri, 5 Jun 2020 08:03:10 +0000 (10:03 +0200)]
[VE] Add AND/OR/XOR regression tests

Summary:
Add AND/OR/XOR regression tests and separate bit-op tests from exisiting
tests.

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

4 years ago[StackSafety,NFC] Switch tests to aarch64
Vitaly Buka [Fri, 5 Jun 2020 06:52:38 +0000 (23:52 -0700)]
[StackSafety,NFC] Switch tests to aarch64

4 years ago[MLIR] Update linalg.conv lowering to use affine load in the absence of padding
Uday Bondhugula [Mon, 25 May 2020 12:10:44 +0000 (17:40 +0530)]
[MLIR] Update linalg.conv lowering to use affine load in the absence of padding

Update linalg to affine lowering for convop to use affine load for input
whenever there is no padding. It had always been using std.loads because
max in index functions (needed for non-zero padding if not materializing
zeros) couldn't be represented in the non-zero padding cases.

In the future, the non-zero padding case could also be made to use
affine - either by materializing or using affine.execute_region. The
latter approach will not impact the scf/std output obtained after
lowering out affine.

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

4 years agoRevert "Set the captures on a CXXRecordDecl representing a lambda closure type"
Jonas Devlieghere [Fri, 5 Jun 2020 06:34:05 +0000 (23:34 -0700)]
Revert "Set the captures on a CXXRecordDecl representing a lambda closure type"

This reverts commit c13dd74e311d2ac70dd3ea663d800307d1aa5b6b.

4 years agoRevert "PR46209: properly determine whether a copy assignment operator is"
Jonas Devlieghere [Fri, 5 Jun 2020 06:25:01 +0000 (23:25 -0700)]
Revert "PR46209: properly determine whether a copy assignment operator is"

This reverts commit c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a.

4 years ago[nfc] [lldb] clang-format #include files order
Jan Kratochvil [Fri, 5 Jun 2020 06:28:06 +0000 (08:28 +0200)]
[nfc] [lldb] clang-format #include files order

4 years ago[Driver] Migrate some -f/-fno options to use OptInFFlag and OptOutFFlag
Fangrui Song [Fri, 5 Jun 2020 06:25:19 +0000 (23:25 -0700)]
[Driver] Migrate some -f/-fno options to use OptInFFlag and OptOutFFlag

Also assign OptInFFlag and OptOutFFlag to f_Group.

4 years agoRevert "[InstCombine][NFC] Factor out constant check"
Max Kazantsev [Fri, 5 Jun 2020 05:00:44 +0000 (12:00 +0700)]
Revert "[InstCombine][NFC] Factor out constant check"

This reverts commit 9bdb91889020b3e61cba26adb1b9c64a24c09f95.

This refactoring proved to not be useful.

4 years ago[DWARFYAML][debug_aranges] Replace InitialLength with Format and Length.
Xing GUO [Fri, 5 Jun 2020 04:15:34 +0000 (12:15 +0800)]
[DWARFYAML][debug_aranges] Replace InitialLength with Format and Length.

This patch addresses the comment in [D80972](https://reviews.llvm.org/D80972#inline-744217).

Before this patch, the initial length field of .debug_aranges section should be declared as:

```
## 32-bit DWARF
debug_aranges:
  - Length:
      TotalLength: 0x20
    Version: 2
    ...

## 64-bit DWARF
debug_aranges:
  - Length:
      TotalLength:   0xffffffff
      TotalLength64: 0x20
    Version: 2
    ...
```

After this patch:

```
## 32-bit DWARF
debug_aranges:
  - [[Format:  DWARF32]] ## Optional
    Length:  0x20
    Version: 2
    ...

## 64-bit DWARF
debug_aranges:
  - Format:  DWARF64
    Length:  0x20
    Version: 2
```

Current implementation of generating DWARF64 .debug_aranges section is buggy. A follow-up patch will improve it and add test cases for DWARF64.

Reviewed By: jhenderson

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

4 years ago[StackSafety,NFC] Ignore callee declarations
Vitaly Buka [Fri, 5 Jun 2020 02:44:42 +0000 (19:44 -0700)]
[StackSafety,NFC] Ignore callee declarations

It's going to fail FunctionInfo lookup anyway.

4 years ago[AddressSanitizer] Don't use weak linkage for __{start,stop}_asan_globals
Petr Hosek [Fri, 5 Jun 2020 03:18:35 +0000 (20:18 -0700)]
[AddressSanitizer] Don't use weak linkage for __{start,stop}_asan_globals

It should not be necessary to use weak linkage for these. Doing so
implies interposablity and thus PIC generates indirections and
dynamic relocations, which are unnecessary and suboptimal. Aside
from this, ASan instrumentation never introduces GOT indirection
relocations where there were none before--only new absolute relocs
in RELRO sections for metadata, which are less problematic for
special linkage situations that take pains to avoid GOT generation.

Patch By: mcgrathr

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

4 years ago[Driver] Migrate some -f/-fno options to use OptInFFlag and OptOutFFlag
Fangrui Song [Fri, 5 Jun 2020 02:28:54 +0000 (19:28 -0700)]
[Driver] Migrate some -f/-fno options to use OptInFFlag and OptOutFFlag

4 years agoPR46209: properly determine whether a copy assignment operator is
Richard Smith [Fri, 5 Jun 2020 02:16:05 +0000 (19:16 -0700)]
PR46209: properly determine whether a copy assignment operator is
trivial.

We previously took a shortcut by assuming that if a subobject had a
trivial copy assignment operator (with a few side-conditions), we would
always invoke it, and could avoid going through overload resolution.
That turns out to not be correct in the presenve of ref-qualifiers (and
also won't be the case for copy-assignments with requires-clauses
either). Use the same logic for lazy declaration of copy-assignments
that we use for all other special member functions.

4 years agoSet the captures on a CXXRecordDecl representing a lambda closure type
Richard Smith [Fri, 5 Jun 2020 02:15:22 +0000 (19:15 -0700)]
Set the captures on a CXXRecordDecl representing a lambda closure type
before marking it complete.

No functionality change intended.

4 years ago[Statepoint] Migrate a few tests to gc-live bundle format and fix assert
Philip Reames [Fri, 5 Jun 2020 01:15:04 +0000 (18:15 -0700)]
[Statepoint] Migrate a few tests to gc-live bundle format and fix assert

The assert was missed in 0e7c7705, migrating the test revealed the problem.

4 years ago[LiveDebugValues] Cache LexicalScopes::getMachineBasicBlocks, NFCI
Vedant Kumar [Thu, 28 May 2020 22:57:11 +0000 (15:57 -0700)]
[LiveDebugValues] Cache LexicalScopes::getMachineBasicBlocks, NFCI

Summary:
Cache the results from getMachineBasicBlocks in LexicalScopes to speed
up UserValueScopes::dominates queries.  This replaces the caching done
in UserValueScopes. Compared to the old caching method, this reduces
memory traffic when a VarLoc is copied (e.g. when a VarLocMap grows),
and enables caching across basic blocks.

When compiling sqlite 3.5.7 (CTMark version), this patch reduces the
number of calls to getMachineBasicBlocks from 10,207 to 1,093. I also
measured a small compile-time reduction (~ 0.1% of total wall time, on
average, on my machine).

As a drive-by, I made the DebugLoc in UserValueScopes a const reference
to cut down on MetadataTracking traffic.

Reviewers: jmorse, Orlando, aprantl, nikic

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[mlir] Refactor BoolAttr to be a special case of IntegerAttr
River Riddle [Wed, 3 Jun 2020 01:20:38 +0000 (18:20 -0700)]
[mlir] Refactor BoolAttr to be a special case of IntegerAttr

This simplifies a lot of handling of BoolAttr/IntegerAttr. For example, a lot of places currently have to handle both IntegerAttr and BoolAttr. In other places, a decision is made to pick one which can lead to surprising results for users. For example, DenseElementsAttr currently uses BoolAttr for i1 even if the user initialized it with an Array of i1 IntegerAttrs.

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

4 years ago[docs] Referenced llvm workflow in HowToAddABuilder
Mircea Trofin [Wed, 3 Jun 2020 00:48:02 +0000 (17:48 -0700)]
[docs] Referenced llvm workflow in HowToAddABuilder

Reviewers: gkistanova, dblaikie

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[WebAssembly] Fix a testcase to be independent of the sysroot default
Dan Gohman [Thu, 4 Jun 2020 22:55:08 +0000 (15:55 -0700)]
[WebAssembly] Fix a testcase to be independent of the sysroot default

As a followup to D62922, add a sysroot command-line option to this test
to ensure that the output is independent of any default sysroot options,
and adjust the reactor test to be more consistent with the command test.

4 years ago[mlir][Linalg] Add a hoistViewAllocOps helper function
Nicolas Vasilache [Thu, 4 Jun 2020 22:55:26 +0000 (18:55 -0400)]
[mlir][Linalg] Add a hoistViewAllocOps helper function

This revision adds a helper function to hoist alloc/dealloc pairs and
alloca op out of immediately enclosing scf::ForOp if both conditions are true:
   1. all operands are defined outside the loop.
   2. all uses are ViewLikeOp or DeallocOp.

This is now considered Linalg-specific and will be generalized on a per-need basis.

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

4 years ago[Analyzer][NoUncountedMembersChecker] Fix crash for C structs
Jan Korous [Thu, 4 Jun 2020 22:55:44 +0000 (15:55 -0700)]
[Analyzer][NoUncountedMembersChecker] Fix crash for C structs

Fixes https://bugs.llvm.org/show_bug.cgi?id=46177
Fixes second bug reported in https://bugs.llvm.org/show_bug.cgi?id=46142

4 years ago[Statepoint] Switch RS4GC to using gc-live bundle form
Philip Reames [Thu, 4 Jun 2020 22:22:07 +0000 (15:22 -0700)]
[Statepoint] Switch RS4GC to using gc-live bundle form

Now that we have an operand based form for the GC arguments to a statepoint intrinsic, update RS4GC to use it and update tests to reflect. This is pretty straight forward. I nearly landed without review, but figured a second set of eyes didn't hurt.

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

4 years ago[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime
Petr Hosek [Thu, 4 Jun 2020 22:47:05 +0000 (15:47 -0700)]
[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

Follow the model used on Linux, where the clang driver passes the
linker a -u switch to force the profile runtime to be linked in,
rather than having every TU emit a dead function with a reference.

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

4 years agoRevert "[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime"
Petr Hosek [Thu, 4 Jun 2020 22:44:10 +0000 (15:44 -0700)]
Revert "[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime"

This reverts commit d51054217403b47f452619e11318bd214749a845 since
it broke several bots.

4 years agoMake linter happy
Julian Lettner [Thu, 4 Jun 2020 21:48:42 +0000 (14:48 -0700)]
Make linter happy

4 years ago[docs] HowToUpdateDebugInfo: Minor cleanups
Vedant Kumar [Thu, 4 Jun 2020 21:32:46 +0000 (14:32 -0700)]
[docs] HowToUpdateDebugInfo: Minor cleanups

- Change the reference to salvageDebugInfoOrUndef to salvageDebugInfo
  (in accordance with https://reviews.llvm.org/D78369).

- Reorganize a few sections in preparation for an upcoming change that
  attempts to specify rules for updating debug locations.

- Fix some intra-document links.

- Some spelling / wording fixes.

4 years ago[Docs] Add the entry for `Advanced builds` in UserGuide.rst
Yuanfang Chen [Tue, 2 Jun 2020 00:09:40 +0000 (17:09 -0700)]
[Docs] Add the entry for `Advanced builds` in UserGuide.rst

Also add a link to it from ThinLTO.rst.

4 years agoFix undefined behaviour when trying to deref nullptr.
Alexey Bataev [Thu, 4 Jun 2020 21:33:13 +0000 (17:33 -0400)]
Fix undefined behaviour when trying to deref nullptr.

4 years ago[Reassociate] Teach ConvertShiftToMul to preserve nsw flag if the shift amount is...
Craig Topper [Thu, 4 Jun 2020 19:21:04 +0000 (12:21 -0700)]
[Reassociate] Teach ConvertShiftToMul to preserve nsw flag if the shift amount is not bitwidth - 1.

Multiply and shl have different signed overflow behavior in
some cases. But it looks like we should be ok as long as the
shift amount is less than bitwidth - 1.

Alive2: http://volta.cs.utah.edu:8080/z/MM4WZP

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

4 years agoAMDGPU: Fix overriding global FP atomic feature predicates
Matt Arsenault [Thu, 4 Jun 2020 18:37:39 +0000 (14:37 -0400)]
AMDGPU: Fix overriding global FP atomic feature predicates

Global TableGen let override blocks are pretty dangerous and override
any local special cases. In this case, the broader HasFlatGlobalInsts
was overriding the more specific predicate for
FeatureAtomicFaddInsts. Make sure HasFlatGlobalInsts is implied by
FeatureAtomicFaddInsts, and make sure the right predicate is used.

One issue with independently setting the subtarget features on
incompatible targets is all of the encoding families do not define all
opcodes. This will hit an assert on gfx10 for example, since we set
the encoding independently based on the generation and not based on a
feature.

4 years agoAMDGPU: Select strict_fmul
Matt Arsenault [Thu, 28 May 2020 00:12:11 +0000 (20:12 -0400)]
AMDGPU: Select strict_fmul

4 years agoAMDGPU: Select strict_fma
Matt Arsenault [Sat, 23 May 2020 17:56:02 +0000 (13:56 -0400)]
AMDGPU: Select strict_fma

Like with strict_fadd, the legalization is scalarizing the v4f16 when
it should split.

4 years agoAMDGPU: Select strict_fadd
Matt Arsenault [Sat, 23 May 2020 14:41:40 +0000 (10:41 -0400)]
AMDGPU: Select strict_fadd

4 years ago[mlir] Add support for bf16 to StandardToLLVM conversion
Diego Caballero [Thu, 4 Jun 2020 21:08:49 +0000 (14:08 -0700)]
[mlir] Add support for bf16 to StandardToLLVM conversion

Reviewed By: ftynse

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

4 years agoAMDGPU: Add test for fdiv nofpexcept preservation
Matt Arsenault [Mon, 1 Jun 2020 18:04:02 +0000 (14:04 -0400)]
AMDGPU: Add test for fdiv nofpexcept preservation

This logically belongs with 89d48ccabe6a950369b2bd922b1d8e987b856ac7,
but this order was needed to avoid regressions before adding
mayRaiseFPExceptions to relevant instructions.

4 years agoAMDGPU: Set mayRaiseFPException
Matt Arsenault [Wed, 27 May 2020 01:56:53 +0000 (21:56 -0400)]
AMDGPU: Set mayRaiseFPException

This may be missing a few overrides to set it off still in some
special cases. Since the flags set during selection should now be
reliably preserved, this should not change codegen for non-strictfp
functions.

4 years ago[InstCombine] avoid crashing on select-shuffle detection
Sanjay Patel [Thu, 4 Jun 2020 21:25:22 +0000 (17:25 -0400)]
[InstCombine] avoid crashing on select-shuffle detection

As mentioned in the post-commit comments of D81013 -
the mask check API has to assume the shuffle is
not length-changing, but we have not ruled that out
in this code. Use the ShuffleVectorInst call instead.

4 years ago[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime
Petr Hosek [Thu, 4 Jun 2020 21:24:33 +0000 (14:24 -0700)]
[Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

Follow the model used on Linux, where the clang driver passes the
linker a -u switch to force the profile runtime to be linked in,
rather than having every TU emit a dead function with a reference.

Patch By: mcgrathr

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

4 years ago[OpenMP] Improve D2D memcpy to use more efficient driver API
Shilei Tian [Thu, 4 Jun 2020 20:58:37 +0000 (16:58 -0400)]
[OpenMP] Improve D2D memcpy to use more efficient driver API

Summary:
In current implementation, D2D memcpy is first to copy data back to host and then
copy from host to device. This is very efficient if the device supports D2D
memcpy, like CUDA.

In this patch, D2D memcpy will first try to use native supported driver API. If
it fails, fall back to original way. It is worth noting that D2D memcpy in this
scenerio contains two ideas:
- Same devices: this is the D2D memcpy in the CUDA context.
- Different devices: this is the PeerToPeer memcpy in the CUDA context.
My implementation merges this two parts. It chooses the best API according to
the source device and destination device.

Reviewers: jdoerfert, AndreyChurbanov, grokos

Reviewed By: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, openmp-commits

Tags: #openmp

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

4 years ago[CUDA][HIP] Fix implicit HD function resolution
Yaxun (Sam) Liu [Fri, 24 Apr 2020 20:41:24 +0000 (16:41 -0400)]
[CUDA][HIP] Fix implicit HD function resolution

recommit e03394c6a6ff with fix

When implicit HD function calls a function in device compilation,
if one candidate is an implicit HD function, current resolution rule is:

D wins over HD and H
HD and H are equal

this caused regression when there is an otherwise worse D candidate

This patch changes that to

D, HD and H are all equal

The rationale is that we already know for host compilation there is already
a valid candidate in HD and H candidates that will not cause error. Allowing
HD and H gives us a fall back candidate that will not cause error. If D wins,
that means D has to be a better match otherwise, therefore D should also
be a valid candidate that will not cause error. In this way, we can guarantee
no regression.

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

4 years agoAMDGPU: Fix using unencodable instructions in tests
Matt Arsenault [Thu, 4 Jun 2020 19:31:28 +0000 (15:31 -0400)]
AMDGPU: Fix using unencodable instructions in tests

There are a number of MIR tests using instructions on subtargets where
they don't really exist. These are some of the easy cases that don't
require splitting up test functions.

4 years agoAMDGPU/GlobalISel: Fix making LDS FP atomics legal on SI/CI
Matt Arsenault [Thu, 4 Jun 2020 19:21:20 +0000 (15:21 -0400)]
AMDGPU/GlobalISel: Fix making LDS FP atomics legal on SI/CI

4 years agoAMDGPU/GlobalISel: Fix trying to use wave32 for gfx9 test
Matt Arsenault [Thu, 4 Jun 2020 19:14:23 +0000 (15:14 -0400)]
AMDGPU/GlobalISel: Fix trying to use wave32 for gfx9 test

4 years ago[OPENMP50]Codegen for inscan reductions in worksharing directives.
Alexey Bataev [Mon, 4 May 2020 20:19:31 +0000 (16:19 -0400)]
[OPENMP50]Codegen for inscan reductions in worksharing directives.

Summary:
Implemented codegen for reduction clauses with inscan modifiers in
worksharing constructs.

Emits the code for the directive with inscan reductions.
The code is the following:
```
size num_iters = <num_iters>;
<type> buffer[num_iters];
for (i: 0..<num_iters>) {
  <input phase>;
  buffer[i] = red;
}
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
  buffer[i] op= buffer[i-pow(2,k)];
for (0..<num_iters>) {
  red = InclusiveScan ? buffer[i] : buffer[i-1];
  <scan phase>;
}
```

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, arphaman, cfe-commits, caomhin

Tags: #clang

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

4 years ago[WebAssembly] Lower llvm.debugtrap properly
Thomas Lively [Thu, 4 Jun 2020 20:25:10 +0000 (13:25 -0700)]
[WebAssembly] Lower llvm.debugtrap properly

Summary:
Unlike normal traps, debug traps are allowed to return and can have
additional instructions in the same basic block. Without explicit
backend support for debug traps, they are lowered in ISel as normal
traps. Since normal traps are lowered in the WebAssembly backend to
the UNREACHABLE instruction, which is a terminator, using debug traps
could lead to invalid MBBs when there are additional instructions
after the trap. This patch fixes the issue by lowering debug traps to
a new version of the UNREACHABLE instruction, DEBUG_UNREACHABLE, that
is not a terminator.

An alternative approach would have been to make UNREACHABLE not a
terminator, but that breaks a large number of tests. In particular, it
would require removing the traps inserted after noreturn calls to
@llvm.wasm.throw because otherwise the terminator throw would be
followed by a non-terminator UNREACHABLE and we would be back to
having invalid MBBs. Overall the approach in this patch seems simpler.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

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

4 years ago[flang] Fixed crash on forward referenced `len` parameter
Pete Steinfeld [Tue, 26 May 2020 22:12:15 +0000 (15:12 -0700)]
[flang] Fixed crash on forward referenced `len` parameter

Summary:
Using a forward reference to define a `len` parameter causes a crash.
The underlying cause was that a previously declared type had an
erroneous expression for its `LEN` param value.  When this expression
was referenced to evaluate a subsequent expression, bad things happened.
I fixed this by putting in code to detect this case.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[NFC] Move test vscale-factor-out-constant.ll to AArch64 sub-directory.
Huihui Zhang [Thu, 4 Jun 2020 19:43:51 +0000 (12:43 -0700)]
[NFC] Move test vscale-factor-out-constant.ll to AArch64 sub-directory.

Vscale scalable vector is specific to AArch64 target.

Bring back 'uglygep' check.

4 years ago[flang] Add the conversions for types.
Eric Schweitz [Tue, 2 Jun 2020 20:58:12 +0000 (13:58 -0700)]
[flang] Add the conversions for types.

Part of lowering is to convert the front-end types to their FIR dialect representations.  These conversions are done by here in the ConvertType module.

proactively update the code to conform better with LLVM coding conventions

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

4 years ago[mlir] [VectorOps] Add missing comments to CreateMaskOp lowering
aartbik [Wed, 3 Jun 2020 23:54:26 +0000 (16:54 -0700)]
[mlir] [VectorOps] Add missing comments to CreateMaskOp lowering

Summary: Add missing comment to CreateMask. Fixed typo in ConstantMask comment.

Reviewers: nicolasvasilache, rriddle, reidtatge, ftynse

Reviewed By: ftynse

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul

Tags: #mlir

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

4 years ago[SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).
Florian Hahn [Thu, 4 Jun 2020 19:15:21 +0000 (20:15 +0100)]
[SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

We can simplify the code a bit by using iterator_range instead of
plain iterators. Matrix type support here (added in 6f6e91d19337)
already uses an iterator_range.

Reviewers: rjmccall, arphaman, jfb, Bigcheese

Reviewed By: rjmccall

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

4 years agoAST Matchers test: use arrays instead of vectors
Dmitri Gribenko [Thu, 4 Jun 2020 18:20:33 +0000 (20:20 +0200)]
AST Matchers test: use arrays instead of vectors

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[flang] avoid GCC < 8 compiler failure after D80794
Valentin Clement [Thu, 4 Jun 2020 18:47:13 +0000 (14:47 -0400)]
[flang] avoid GCC < 8 compiler failure after D80794

Summary:
Patch D80794 remove the custom flags for release build for flang.
This leads to build failure with GCC < 8. This patch add upperbound check
in order to avoid the -Werror=array-bounds to trigger a build failure.

```
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
```

```
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:810:22: error: array subscript is above array bounds [-Werror=array-bounds]
               product[to] = xy & partMask;
               ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
```

Reviewers: DavidTruby, sscalpone, jdoerfert

Reviewed By: DavidTruby

Subscribers: llvm-commits

Tags: #llvm, #flang

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

4 years ago[PGO] Enable the working set size scaling under the partial sample PGO.
Hiroshi Yamauchi [Mon, 1 Jun 2020 17:45:28 +0000 (10:45 -0700)]
[PGO] Enable the working set size scaling under the partial sample PGO.

Summary: Following up D79831.

Reviewers: davidxl

Subscribers: eraman, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[InstCombine] move vector select ahead of select-shuffle
Sanjay Patel [Thu, 4 Jun 2020 18:17:59 +0000 (14:17 -0400)]
[InstCombine] move vector select ahead of select-shuffle

select Cond, (shuf_sel X, Y), X --> shuf_sel X, (select Cond, Y, X)

A select of a select-shuffle ("blend" in x86 lingo) can be reversed
so that the select is done first.
This is a more limited version of what I was trying in D80658,
but it enables existing demanded bits transforms to catch some of the
motivating cases. The tricky bit in that seems to be that by moving
the shuffle later, we can always guarantee that poison is correctly
inhibited by the shuffle mask in the final value.

Alive2 checks for the basic tests:
http://volta.cs.utah.edu:8080/z/Qqd3RK
http://volta.cs.utah.edu:8080/z/S4wchM
http://volta.cs.utah.edu:8080/z/wf9zPL
http://volta.cs.utah.edu:8080/z/wJeEGk

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

4 years ago[docs] Fix self-contradictory description of llvm_unreachable
Jan Korous [Thu, 4 Jun 2020 03:04:48 +0000 (20:04 -0700)]
[docs] Fix self-contradictory description of llvm_unreachable

Just two paragraphs above it says:
"If the compiler does not support this [skipping code generation for a particular branch], it will fall back
to the "abort" implementation."

And that actually correctly describes llvm_unreachable implementation.

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

4 years agoPropose naming principle for NodeRole and apply it
Eduardo Caldas [Thu, 4 Jun 2020 17:27:35 +0000 (19:27 +0200)]
Propose naming principle for NodeRole and apply it

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[libc++] Avoid warning for large types with std::atomic in the test suite
Louis Dionne [Thu, 4 Jun 2020 18:04:01 +0000 (14:04 -0400)]
[libc++] Avoid warning for large types with std::atomic in the test suite

It is legitimate for the test suite to use types that are slow to use
with std::atomic, since we need coverage for those too. If we don't
disable the warning, it is promoted to an error, which prevents us
from testing such types.

4 years ago[gn build] Port e53f5580578
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:21 +0000 (17:56 +0000)]
[gn build] Port e53f5580578

4 years ago[gn build] Port c973ad1878f
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:21 +0000 (17:56 +0000)]
[gn build] Port c973ad1878f

4 years ago[gn build] Port ba2a01645b5
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:20 +0000 (17:56 +0000)]
[gn build] Port ba2a01645b5

4 years ago[gn build] Port 69fa84a6e95
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:20 +0000 (17:56 +0000)]
[gn build] Port 69fa84a6e95

4 years ago[gn build] Port 6756a2c9533
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:19 +0000 (17:56 +0000)]
[gn build] Port 6756a2c9533

4 years ago[gn build] Port 49a4f3f7d88
LLVM GN Syncbot [Thu, 4 Jun 2020 17:56:19 +0000 (17:56 +0000)]
[gn build] Port 49a4f3f7d88

4 years ago[NFC] Temporarily disable check for 'uglygep' while investigating some buildbot failure.
Huihui Zhang [Thu, 4 Jun 2020 17:46:32 +0000 (10:46 -0700)]
[NFC] Temporarily disable check for 'uglygep' while investigating some buildbot failure.

The purpose of vscale-factor-out-constant.ll is to check we are crashing
with blind cast 'Factor' in a MulExpr to SCEVConstant.

4 years ago[mlir][gpu] Add subgroup Id/Size/Num to GPU dialect
Thomas Raoux [Thu, 4 Jun 2020 17:45:53 +0000 (10:45 -0700)]
[mlir][gpu] Add subgroup Id/Size/Num to GPU dialect

Add SubgroupId, SubgroupSize and NumSubgroups to GPU dialect ops and add the
lowering of those ops to SPIRV.

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

4 years ago[AArch64][GlobalISel] Move GlobalISel source files to a dedicated subdir.
Amara Emerson [Wed, 3 Jun 2020 18:42:09 +0000 (11:42 -0700)]
[AArch64][GlobalISel] Move GlobalISel source files to a dedicated subdir.

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

4 years agoDisable this test for Windows.
Jim Ingham [Thu, 4 Jun 2020 17:49:26 +0000 (10:49 -0700)]
Disable this test for Windows.

The printf expression crashes with the message:

Attempted to dereference an invalid pointer

Someone who knows more about Windows should suggest how to fix this.

4 years agoMake regcoal_remat_empty_subrange.ll test require asserts build.
Hans Wennborg [Thu, 4 Jun 2020 17:44:36 +0000 (19:44 +0200)]
Make regcoal_remat_empty_subrange.ll test require asserts build.

The -stress-sched flag is only available when asserts are enabled.

4 years ago[lldb] Fix SLEB128 decoding
Jan Kratochvil [Thu, 4 Jun 2020 17:41:24 +0000 (19:41 +0200)]
[lldb] Fix SLEB128 decoding

Bug 46181 shows SLEB128 0xED9A924C00011151 decoded as 0xffffffff80011151.
        LLDB show a wrong value for function argument
        https://bugs.llvm.org/show_bug.cgi?id=46181

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

4 years ago[TRE] Allow accumulator elimination when base case returns non-constant
Layton Kifer [Thu, 4 Jun 2020 17:33:03 +0000 (10:33 -0700)]
[TRE] Allow accumulator elimination when base case returns non-constant

Remove the requirement, that when performing accumulator elimination,
all other cases must return the same dynamic constant. We can do this by
initializing the accumulator with the identity value of the accumulation
operation, and inserting an additional operation before any return.

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

4 years ago[LSR][SCEVExpander] Avoid blind cast 'Factor' to SCEVConstant in FactorOutConstant.
Huihui Zhang [Thu, 4 Jun 2020 17:32:36 +0000 (10:32 -0700)]
[LSR][SCEVExpander] Avoid blind cast 'Factor' to SCEVConstant in FactorOutConstant.

Summary:
In SCEVExpander FactorOutConstant(), when GEP indexing into/over scalable vector,
it is legal for the 'Factor' in a MulExpr to be the size of a scalable vector
instead of a compile-time constant.

Current upstream crash with the test attached.

Reviewers: efriedma, sdesmalen, sanjoy.google, mkazantsev

Reviewed By: efriedma

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

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

4 years ago[SVE] Eliminate calls to default-false VectorType::get() from SystemZ
Christopher Tetreault [Thu, 4 Jun 2020 16:57:36 +0000 (09:57 -0700)]
[SVE] Eliminate calls to default-false VectorType::get() from SystemZ

Reviewers: efriedma, jnspaulsson, kmclaughlin, sdesmalen, samparker, uweigand

Reviewed By: uweigand

Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years ago[clang-tidy] ignore builtin varargs from pro-type-vararg-check
Nathan James [Thu, 4 Jun 2020 16:58:23 +0000 (17:58 +0100)]
[clang-tidy] ignore builtin varargs from pro-type-vararg-check

Disables the check from warning on some built in vararg functions, Address [[ https://bugs.llvm.org/show_bug.cgi?id=45860 | Clang-tidy should not consider __builtin_constant_p a variadic function. ]]

Reviewed By: aaron.ballman

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

4 years ago[clang-tidy][modernize-loop-convert] Make loop var type human readable
Zinovy Nis [Tue, 26 May 2020 06:06:59 +0000 (09:06 +0300)]
[clang-tidy][modernize-loop-convert] Make loop var type human readable

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

4 years ago[Doc] update ReleaseNotes with new warning note.
ZequanWu [Thu, 4 Jun 2020 16:45:04 +0000 (09:45 -0700)]
[Doc] update ReleaseNotes with new warning note.

4 years ago[OPENMP]Fix PR46146: Do not consider globalized variables as NRVO candidates.
Alexey Bataev [Mon, 1 Jun 2020 16:39:25 +0000 (12:39 -0400)]
[OPENMP]Fix PR46146: Do not consider globalized variables as NRVO candidates.

Summary:
If the variables must be globalized in OpenMP mode (local automatic
variable, GPU compilation mode, the variable may escape its declaration
context by the reference or by the pointer), it should not be considered
as the NRVO candidate. Otherwise, incorrect the return value of the
function might not be updated.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

4 years ago[gn build] Port b5fc1deb5ba1f3cd432ecb8b86c2536470463163
Fangrui Song [Thu, 4 Jun 2020 16:22:44 +0000 (09:22 -0700)]
[gn build] Port b5fc1deb5ba1f3cd432ecb8b86c2536470463163

4 years ago[libc++] Disable LLVM benchmarks in the Apple build
Louis Dionne [Thu, 4 Jun 2020 16:03:04 +0000 (12:03 -0400)]
[libc++] Disable LLVM benchmarks in the Apple build

4 years ago[llvm-dwarfdump] Add a table header for -debug-line -verbose output
Fangrui Song [Thu, 4 Jun 2020 15:56:17 +0000 (08:56 -0700)]
[llvm-dwarfdump] Add a table header for -debug-line -verbose output

Like non-verbose output, so that it is easy to recognize the `Line,Column,File,ISA,Discriminator` column values.

Reviewed By: JDevlieghere, jhenderson

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

4 years agoUse libClangTesting in the unittest for AST matchers
Dmitri Gribenko [Thu, 4 Jun 2020 15:40:38 +0000 (17:40 +0200)]
Use libClangTesting in the unittest for AST matchers

Summary:
The unittest for AST matchers has its own way to specify language
standards. I unified it with the shared infrastructure from
libClangTesting.

Reviewers: jdoerfert, hlopko

Reviewed By: hlopko

Subscribers: mgorny, sstefan1, cfe-commits

Tags: #clang

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