platform/upstream/llvm.git
4 years agogn build: Merge 0dc0572b48e
LLVM GN Syncbot [Fri, 8 Nov 2019 14:31:11 +0000 (14:31 +0000)]
gn build: Merge 0dc0572b48e

4 years ago[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
Jason Liu [Fri, 8 Nov 2019 14:26:28 +0000 (09:26 -0500)]
[XCOFF][AIX] Differentiate usage of label symbol and csect symbol

Summary:
 We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.

This patch intend to do the following:
    1. Construct a QualName (A name include the storage mapping class)
       MCSymbolXCOFF for every MCSectionXCOFF.
    2. Keep a pointer to that QualName inside of MCSectionXCOFF.
    3. Use that QualName whenever we need a symbol refers to that
       MCSectionXCOFF.
    4. Adapt the snowball effect from the above changes in
       XCOFFObjectWriter.cpp.

Reviewers: xingxue, DiggerLin, sfertile, daltenty, hubert.reinterpretcast

Reviewed By: DiggerLin, daltenty

Subscribers: wuzish, nemanjai, mgorny, hiraditya, kbarton, jsji, llvm-commits

Tags: #llvm

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

4 years ago[AMDGPU][MC] Corrected src0 for v_movrelsd_b32 and v_movrelsd_2_b32
Dmitry Preobrazhensky [Fri, 8 Nov 2019 13:38:56 +0000 (16:38 +0300)]
[AMDGPU][MC] Corrected src0 for v_movrelsd_b32 and v_movrelsd_2_b32

See https://bugs.llvm.org/show_bug.cgi?id=40903

Reviewers: arsenm, rampitec

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

4 years ago[LV] Apply sink-after & interleave-groups as VPlan transformations (NFCI)
Gil Rapaport [Mon, 7 Oct 2019 14:24:33 +0000 (17:24 +0300)]
[LV] Apply sink-after & interleave-groups as VPlan transformations (NFCI)

This recommits 100e797adb433724a17c9b42b6533cd634cb796b (reverted in
009e032634b3bd7fc32071ac2344b12142286477 for failing an assert). While the
root cause was independently reverted in eaff3004019f97c64c88ab76da6b25106b659b30,
this commit includes a LIT to make sure IVDescriptor's SinkAfter logic does not
try to sink branch instructions.

4 years agoBinaryStream - fix static analyzer warnings. NFCI.
Simon Pilgrim [Fri, 8 Nov 2019 13:10:52 +0000 (13:10 +0000)]
BinaryStream - fix static analyzer warnings. NFCI.
 - uninitialized variables
 - documention warnings
 - shadow variable names

4 years ago[clang-format] update comments in clang-format.py for python3 compatibility
paulhoad [Fri, 8 Nov 2019 13:15:45 +0000 (13:15 +0000)]
[clang-format] update comments in clang-format.py for python3 compatibility

Summary:
D23319 introduced python3 compatibility to clang-format.py, this is however not reflected by the documentation in the comments at the beginning of the file, which show how to use the script with python2 in .vimrc. While the actual mapping a user might want to use may well differ from my suggestion, I think it's nice to show the python2 and python3 version, such that a user can pick from the suggestions instead of googeling the python3 replacement for `:pyf` which they might not be familiar with.

EDIT: picking reviewers according to https://llvm.org/docs/Phabricator.html#finding-potential-reviewers

Reviewers: klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: ilya-biryukov, cfe-commits, llvm-commits, ychen

Patch By: pseyfert

Tags: #clang-tools-extra, #llvm, #clang

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

4 years agoRevert "test commit"
Abel Kocsis [Fri, 8 Nov 2019 13:09:09 +0000 (14:09 +0100)]
Revert "test commit"

This reverts commit b0a03f29d9a2d316d6be99e6a4825114f240c0b2.

4 years agoRevert "test commit"
Abel Kocsis [Fri, 8 Nov 2019 13:08:46 +0000 (14:08 +0100)]
Revert "test commit"

This reverts commit 3ffce13f8c7ecb21c5729aa358f1f9fc008bbea2.

4 years agoRevert "Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1"""
Abel Kocsis [Fri, 8 Nov 2019 13:08:15 +0000 (14:08 +0100)]
Revert "Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1"""

This reverts commit 3182027282c59c51d5080d83365917fccd695854.

4 years agoRevert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1""
Abel Kocsis [Fri, 8 Nov 2019 13:00:44 +0000 (14:00 +0100)]
Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1""

This reverts commit 6b45e1bc11e91ea7b57a6ab1c19461a86dba33f8.

4 years agotest commit
Abel Kocsis [Fri, 8 Nov 2019 12:37:24 +0000 (13:37 +0100)]
test commit

4 years agotest commit
Abel Kocsis [Fri, 8 Nov 2019 12:35:49 +0000 (13:35 +0100)]
test commit

4 years agoRevert "[clang] Report sanitizer blacklist as a dependency in cc1"
Jeremy Morse [Fri, 8 Nov 2019 11:33:40 +0000 (11:33 +0000)]
Revert "[clang] Report sanitizer blacklist as a dependency in cc1"

This reverts commit 03b84e4f6d0e1c04f22d69cc445f36e1f713beb4.

This breaks dfsan tests with a linking failure, in for example this build:

  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24312

Reverting this patch locally makes those tests succeed.

4 years agoRevert "[compiler-rt] Fix tests after 03b84e4f6d0"
Jeremy Morse [Fri, 8 Nov 2019 11:33:11 +0000 (11:33 +0000)]
Revert "[compiler-rt] Fix tests after 03b84e4f6d0"

This reverts commit bdeb2724f0aa9c518f94d998d24d8620a1e88727.

(Reverting 03b84e4f6d0, so this must come out as well)

4 years agoReland: [TII] Use optional destination and source pair as a return value; NFC
Djordje Todorovic [Fri, 8 Nov 2019 10:19:58 +0000 (11:19 +0100)]
Reland: [TII] Use optional destination and source pair as a return value; NFC

Refactor usage of isCopyInstrImpl, isCopyInstr and isAddImmediate methods
to return optional machine operand pair of destination and source
registers.

Patch by Nikola Prica

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

4 years ago[lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL logic
Raphael Isemann [Fri, 8 Nov 2019 11:28:49 +0000 (12:28 +0100)]
[lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL logic

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[lldb][NFC] Refactor some IsClangType checks in ClangASTContext
Raphael Isemann [Fri, 8 Nov 2019 11:03:28 +0000 (12:03 +0100)]
[lldb][NFC] Refactor some IsClangType checks in ClangASTContext

Summary:
All type in these functions need be valid and Clang types, so
we might as well replace these checks with IsClangType.

Also lets IsClangType explicitly check for validity instead of
assuming that the TypeSystem is a nullptr.

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[cmake] Enable thin lto cache when building with lld-link
Russell Gallop [Fri, 8 Nov 2019 10:46:24 +0000 (10:46 +0000)]
[cmake] Enable thin lto cache when building with lld-link

This was enabled for other platforms. Added option for Windows/lld-link.

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

4 years agoRevert d91ed80 "[codeview] Reference types in type parent scopes"
Hans Wennborg [Fri, 8 Nov 2019 10:30:33 +0000 (11:30 +0100)]
Revert d91ed80 "[codeview] Reference types in type parent scopes"

This triggered asserts in the Chromium build, see https://crbug.com/1022729 for
details and reproducer.

> Without this change, when a nested tag type of any kind (enum, class,
> struct, union) is used as a variable type, it is emitted without
> emitting the parent type. In CodeView, parent types point to their inner
> types, and inner types do not point back to their parents. We already
> walk over all of the parent scopes to build the fully qualified name.
> This change simply requests their type indices as we go along to enusre
> they are all emitted.
>
> Fixes PR43905
>
> Reviewers: akhuang, amccarth
>
> Differential Revision: https://reviews.llvm.org/D69924

4 years ago[RAGreedy] Enable -consider-local-interval-cost for AArch64
Sanne Wouda [Fri, 8 Nov 2019 09:25:57 +0000 (09:25 +0000)]
[RAGreedy] Enable -consider-local-interval-cost for AArch64

Summary:
The greedy register allocator occasionally decides to insert a large number of
unnecessary copies, see below for an example.  The -consider-local-interval-cost
option (which X86 already enables by default) fixes this.  We enable this option
for AArch64 only after receiving feedback that this change is not beneficial for
PowerPC.

We evaluated the impact of this change on compile time, code size and
performance benchmarks.

This option has a small impact on compile time, measured on CTMark. A 0.1%
geomean regression on -O1 and -O2, and 0.2% geomean for -O3, with at most 0.5%
on individual benchmarks.

The effect on both code size and performance on AArch64 for the LLVM test suite
is nil on the geomean with individual outliers (ignoring short exec_times)
between:

                 best     worst
  size..text     -3.3%    +0.0%
  exec_time      -5.8%    +2.3%

On SPEC CPU® 2017 (compiled for AArch64) there is a minor reduction (-0.2% at
most) in code size on some benchmarks, with a tiny movement (-0.01%) on the
geomean.  Neither intrate nor fprate show any change in performance.

This patch makes the following changes.

- For the AArch64 target, enableAdvancedRASplitCost() now returns true.

- Ensures that -consider-local-interval-cost=false can disable the new
  behaviour if necessary.

This matrix multiply example:

   $ cat test.c
   long A[8][8];
   long B[8][8];
   long C[8][8];

   void run_test() {
     for (int k = 0; k < 8; k++) {
       for (int i = 0; i < 8; i++) {
 for (int j = 0; j < 8; j++) {
   C[i][j] += A[i][k] * B[k][j];
 }
       }
     }
   }

results in the following generated code on AArch64:

  $ clang --target=aarch64-arm-none-eabi -O3 -S test.c -o -
  [...]
                                        // %for.cond1.preheader
                                        // =>This Inner Loop Header: Depth=1
        add     x14, x11, x9
        str     q0, [sp, #16]           // 16-byte Folded Spill
        ldr     q0, [x14]
        mov     v2.16b, v15.16b
        mov     v15.16b, v14.16b
        mov     v14.16b, v13.16b
        mov     v13.16b, v12.16b
        mov     v12.16b, v11.16b
        mov     v11.16b, v10.16b
        mov     v10.16b, v9.16b
        mov     v9.16b, v8.16b
        mov     v8.16b, v31.16b
        mov     v31.16b, v30.16b
        mov     v30.16b, v29.16b
        mov     v29.16b, v28.16b
        mov     v28.16b, v27.16b
        mov     v27.16b, v26.16b
        mov     v26.16b, v25.16b
        mov     v25.16b, v24.16b
        mov     v24.16b, v23.16b
        mov     v23.16b, v22.16b
        mov     v22.16b, v21.16b
        mov     v21.16b, v20.16b
        mov     v20.16b, v19.16b
        mov     v19.16b, v18.16b
        mov     v18.16b, v17.16b
        mov     v17.16b, v16.16b
        mov     v16.16b, v7.16b
        mov     v7.16b, v6.16b
        mov     v6.16b, v5.16b
        mov     v5.16b, v4.16b
        mov     v4.16b, v3.16b
        mov     v3.16b, v1.16b
        mov     x12, v0.d[1]
        fmov    x15, d0
        ldp     q1, q0, [x14, #16]
        ldur    x1, [x10, #-256]
        ldur    x2, [x10, #-192]
        add     x9, x9, #64             // =64
        mov     x13, v1.d[1]
        fmov    x16, d1
        ldr     q1, [x14, #48]
        mul     x3, x15, x1
        mov     x14, v0.d[1]
        fmov    x17, d0
        mov     x18, v1.d[1]
        fmov    x0, d1
        mov     v1.16b, v3.16b
        mov     v3.16b, v4.16b
        mov     v4.16b, v5.16b
        mov     v5.16b, v6.16b
        mov     v6.16b, v7.16b
        mov     v7.16b, v16.16b
        mov     v16.16b, v17.16b
        mov     v17.16b, v18.16b
        mov     v18.16b, v19.16b
        mov     v19.16b, v20.16b
        mov     v20.16b, v21.16b
        mov     v21.16b, v22.16b
        mov     v22.16b, v23.16b
        mov     v23.16b, v24.16b
        mov     v24.16b, v25.16b
        mov     v25.16b, v26.16b
        mov     v26.16b, v27.16b
        mov     v27.16b, v28.16b
        mov     v28.16b, v29.16b
        mov     v29.16b, v30.16b
        mov     v30.16b, v31.16b
        mov     v31.16b, v8.16b
        mov     v8.16b, v9.16b
        mov     v9.16b, v10.16b
        mov     v10.16b, v11.16b
        mov     v11.16b, v12.16b
        mov     v12.16b, v13.16b
        mov     v13.16b, v14.16b
        mov     v14.16b, v15.16b
        mov     v15.16b, v2.16b
        ldr     q2, [sp]                // 16-byte Folded Reload
        fmov    d0, x3
        mul     x3, x12, x1
  [...]

With -consider-local-interval-cost the same section of code results in the
following:

  $ clang --target=aarch64-arm-none-eabi -mllvm -consider-local-interval-cost -O3 -S test.c -o -
  [...]
  .LBB0_1:                              // %for.cond1.preheader
                                        // =>This Inner Loop Header: Depth=1
        add     x14, x11, x9
        ldp     q0, q1, [x14]
        ldur    x1, [x10, #-256]
        ldur    x2, [x10, #-192]
        add     x9, x9, #64             // =64
        mov     x12, v0.d[1]
        fmov    x15, d0
        mov     x13, v1.d[1]
        fmov    x16, d1
        ldp     q0, q1, [x14, #32]
        mul     x3, x15, x1
        cmp     x9, #512                // =512
        mov     x14, v0.d[1]
        fmov    x17, d0
        fmov    d0, x3
        mul     x3, x12, x1
  [...]

Reviewers: SjoerdMeijer, samparker, dmgreen, qcolombet

Reviewed By: dmgreen

Subscribers: ZhangKang, jsji, wuzish, ppc-slack, lkail, steven.zhang, MatzeB, qcolombet, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years agoKeep symbols passed by -init and -fini
Rui Ueyama [Fri, 8 Nov 2019 05:39:14 +0000 (14:39 +0900)]
Keep symbols passed by -init and -fini

Previously, symbols passed by -init and -fini look as if they are
not referenced by anyone, and the LTO might eliminate them.
This patch fixes the issue.

Fixes a bug reported in https://bugs.llvm.org/show_bug.cgi?id=43927

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

4 years ago[RISCV] Fix evaluation of %pcrel_lo
Roger Ferrer Ibanez [Fri, 8 Nov 2019 08:26:30 +0000 (08:26 +0000)]
[RISCV] Fix evaluation of %pcrel_lo

The following testcase

  function:
  .Lpcrel_label1:
   auipc a0, %pcrel_hi(other_function)
   addi a1, a0, %pcrel_lo(.Lpcrel_label1)
   .p2align 2          # Causes a new fragment to be emitted

   .type other_function,@function
  other_function:
   ret

exposes an odd behaviour in which only the %pcrel_hi relocation is
evaluated but not the %pcrel_lo.

  $ llvm-mc -triple riscv64 -filetype obj t.s | llvm-objdump  -d -r -

  <stdin>: file format ELF64-riscv

  Disassembly of section .text:
  0000000000000000 function:
         0: 17 05 00 00 auipc a0, 0
         4: 93 05 05 00 mv a1, a0
   0000000000000004:  R_RISCV_PCREL_LO12_I other_function+4

  0000000000000008 other_function:
         8: 67 80 00 00 ret

The reason seems to be that in RISCVAsmBackend::shouldForceRelocation we
only consider the fragment but in RISCVMCExpr::evaluatePCRelLo we
consider the section. This usually works but there are cases where the
section may still be the same but the fragment may be another one. In
that case we end forcing a %pcrel_lo relocation without any %pcrel_hi.

This patch makes RISCVAsmBackend::shouldForceRelocation use the section,
if any, to determine if the relocation must be forced or not.

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

4 years ago[Analyzer] Checker for Debugging Iterator Checkers
Adam Balogh [Fri, 8 Nov 2019 07:56:31 +0000 (08:56 +0100)]
[Analyzer] Checker for Debugging Iterator Checkers

For white-box testing correct container and iterator modelling it is essential
to access the internal data structures stored for container and iterators. This
patch introduces a simple debug checkers called debug.IteratorDebugging to
achieve this.

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

4 years ago[NFC][IndVarS] Adjust a comment
Daniil Suchkov [Fri, 8 Nov 2019 07:51:36 +0000 (14:51 +0700)]
[NFC][IndVarS] Adjust a comment

(test commit)

4 years ago[CR] ConstantRange::sshl_sat(): check sigdness of the min/max, not ranges
Roman Lebedev [Fri, 8 Nov 2019 07:32:56 +0000 (10:32 +0300)]
[CR] ConstantRange::sshl_sat(): check sigdness of the min/max, not ranges

This was pointed out in review,
but forgot to stage this change into the commit itself..

4 years ago[ConstantRange] Add `ushl_sat()`/`sshl_sat()` methods.
Roman Lebedev [Fri, 8 Nov 2019 07:24:46 +0000 (10:24 +0300)]
[ConstantRange] Add `ushl_sat()`/`sshl_sat()` methods.

Summary:
To be used in `ConstantRange::shlWithNoOverflow()`,
may in future be useful for when saturating shift/mul ops are added.

Unlike `ConstantRange::shl()`, these are precise.

Reviewers: nikic, spatel, reames

Reviewed By: nikic

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[BPF] turn on -mattr=+alu32 for cpu version v3 and later
Yonghong Song [Thu, 7 Nov 2019 18:55:59 +0000 (10:55 -0800)]
[BPF] turn on -mattr=+alu32 for cpu version v3 and later

-mattr=+alu32 has shown good performance vs. without this attribute.
Based on discussion at
  https://lore.kernel.org/bpf/1ec37838-966f-ec0b-5223-ca9b6eb0860d@fb.com/T/#t
cpu version v3 should support -mattr=+alu32.
This patch enabled alu32 if cpu version is v3, either specified by user
or probed by the llvm.

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

4 years agoReordering KextImageInfo::LoadImageUsingMemoryModule
Jason Molenda [Fri, 8 Nov 2019 03:34:09 +0000 (19:34 -0800)]
Reordering KextImageInfo::LoadImageUsingMemoryModule
so we only call ModulesDidLoad at the end of the method
after the new module has been added to the target and
the sections have all been adjusted to their actual
load addresses.  Solves a problem where an operating
system plugin in the kernel could be loaded multiple
times; the first before the binary had even been
added to the target.

<rdar://problem/50523558>

4 years ago[PowerPC][Altivec] Fix offsets for vec_xl and vec_xst
Nemanja Ivanovic [Fri, 8 Nov 2019 02:58:11 +0000 (20:58 -0600)]
[PowerPC][Altivec] Fix offsets for vec_xl and vec_xst

As we currently have it implemented in altivec.h, the offsets for these two
intrinsics are element offsets. The documentation in the ABI (as well as the
implementation in both XL and GCC) states that these should be byte offsets.

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

4 years ago[PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne
Nemanja Ivanovic [Fri, 8 Nov 2019 02:40:32 +0000 (20:40 -0600)]
[PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne

We currently emit a double precision comparison instruction for this, whereas we
need to emit the single precision version.

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

4 years ago[PowerPC] Option for enabling absolute jumptables with command line
Nemanja Ivanovic [Fri, 8 Nov 2019 01:31:00 +0000 (19:31 -0600)]
[PowerPC] Option for enabling absolute jumptables with command line

This option allows the user to specify the use of absolute jumptables instead
of relative which is the default on most PPC subtargets.

Patch by Kamauu Bridgeman

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

4 years ago[creduce] Fixed a typo in the error message we're looking for.
Artem Belevich [Fri, 8 Nov 2019 01:16:12 +0000 (17:16 -0800)]
[creduce] Fixed a typo in the error message we're looking for.

4 years ago[analyzer] Add test cases for the unsupported C++ constructor modeling.
Artem Dergachev [Fri, 8 Nov 2019 00:17:39 +0000 (16:17 -0800)]
[analyzer] Add test cases for the unsupported C++ constructor modeling.

Namely, for the following items:
- Handle constructors within new[];
- Handle constructors for default arguments.

Update the open projects page with a link to the newly added tests
and more hints for potential contributors.

Patch by Daniel Krupp!

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

4 years ago[analyzer] PR41729: CStringChecker: Improve strlcat and strlcpy modeling.
Artem Dergachev [Thu, 7 Nov 2019 23:58:01 +0000 (15:58 -0800)]
[analyzer] PR41729: CStringChecker: Improve strlcat and strlcpy modeling.

- Fix false positive reports of strlcat.
- The return value of strlcat and strlcpy is now correctly calculated.
- The resulting string length of strlcat and strlcpy is now correctly
  calculated.

Patch by Daniel Krupp!

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

4 years ago[llvm/test] Update test comments
Shu-Chun Weng [Thu, 7 Nov 2019 23:47:41 +0000 (15:47 -0800)]
[llvm/test] Update test comments

4 years ago[MC] Delete defaulted constructor llvm::AsmCond::AsmCond
Fangrui Song [Fri, 8 Nov 2019 00:02:32 +0000 (16:02 -0800)]
[MC] Delete defaulted constructor llvm::AsmCond::AsmCond

4 years ago[InstCombine] Don't transform bitcasts between x86_mmx and v1i64 into insertelement...
Craig Topper [Thu, 7 Nov 2019 22:59:14 +0000 (14:59 -0800)]
[InstCombine] Don't transform bitcasts between x86_mmx and v1i64 into insertelement/extractelement

x86_mmx is conceptually a vector already. Don't introduce an extra conversion between it and scalar i64.

I'm using VectorType::isValidElementType which checks for floating point, integer, and pointers to hopefully make this more readable than just blacklisting x86_mmx.

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

4 years ago[InstCombine] auto-generate complete checks; NFC
Sanjay Patel [Thu, 7 Nov 2019 23:06:26 +0000 (18:06 -0500)]
[InstCombine] auto-generate complete checks; NFC

4 years agoModernize TestWeakSymbols Makefile
Fred Riss [Thu, 7 Nov 2019 22:03:07 +0000 (14:03 -0800)]
Modernize TestWeakSymbols Makefile

4 years ago[SEH] Defer checking filter expression types until instantiaton
Reid Kleckner [Thu, 7 Nov 2019 22:13:26 +0000 (14:13 -0800)]
[SEH] Defer checking filter expression types until instantiaton

While here, wordsmith the error a bit. Now clang says:
  error: filter expression has non-integral type 'Foo'

Fixes PR43779

Reviewers: amccarth

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

4 years agoCorrectly update isSignalFrame when unwinding the stack via dwarf.
Sterling Augustine [Thu, 31 Oct 2019 19:45:20 +0000 (12:45 -0700)]
Correctly update isSignalFrame when unwinding the stack via dwarf.

A "signal frame" is a function or block of code where execution arrives via a signal or interrupt, rather than via a normal call instruction. In fact, a particular instruction is interrupted by the signal and needs to be restarted. Therefore, when the signal handler is complete, execution needs to return to the interrupted instruction, rather than the instruction immediately following the call instruction, as in a normal call.

Stack unwinders need to know this to correctly unwind signal frames. Dwarf handily provides an "S" in the CIE augmentation string to describe this case, and the libunwind API provides various functions to for unwinders to determine it,.

The llvm libunwind implementation correctly sets it's internal variable "isSignalFrame" when initializing an unwind context. However, upon stepping up the stack, the current implementation correctly reads the augmentation string and sets it in the CIE info (which it then discards), libunwind doesn't update it's internal unwind context data structure.

This change fixes that, and provides compatibility with both the canonical libunwind and the libgcc implementation.

Reviewers: jfb

Subscribers: christof, libcxx-commits

Tags: #libc

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

4 years agogn build: Merge 25ee861372f
LLVM GN Syncbot [Thu, 7 Nov 2019 22:43:50 +0000 (22:43 +0000)]
gn build: Merge 25ee861372f

4 years ago[debugify] Move the Debugify pass from tools/opt to lib/Transform/Utils
Daniel Sanders [Thu, 7 Nov 2019 00:08:01 +0000 (16:08 -0800)]
[debugify] Move the Debugify pass from tools/opt to lib/Transform/Utils

Summary:
I need to make use of this pass from a driver program that isn't opt.
Therefore this patch moves this pass into the LLVM library so that it is
available for use elsewhere.

There was one function I kept in tools/opt which is exportDebugifyStats()
this is because it's serializing the statistics into a human readable
format and this seemed more in keeping with opt than a library function

Reviewers: vsk, aprantl

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[compiler-rt] Fix tests after 03b84e4f6d0
Jan Korous [Thu, 7 Nov 2019 22:40:22 +0000 (14:40 -0800)]
[compiler-rt] Fix tests after 03b84e4f6d0

Fallout from:
[clang] Report sanitizer blacklist as a dependency in cc1

Default blacklists are now passed via -fsanitize-system-blacklist from driver to cc1.

4 years agoBreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakp...
Jim Ingham [Thu, 7 Nov 2019 20:44:03 +0000 (12:44 -0800)]
BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakpoint_dummy_options
causing the -D option for breakpoint set command to be incorrectly parsed.

Patch by Martin Svensson.

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

4 years ago[clang] Report sanitizer blacklist as a dependency in cc1
Jan Korous [Thu, 7 Nov 2019 21:56:14 +0000 (13:56 -0800)]
[clang] Report sanitizer blacklist as a dependency in cc1

Previously these were reported from the driver which blocked clang-scan-deps from getting the full set of dependencies from cc1 commands.

Also the default sanitizer blacklist that is added in driver was never reported as a dependency. I introduced -fsanitize-system-blacklist cc1 option to keep track of which blacklists were user-specified and which were added by driver and clang -MD now also reports system blacklists as dependencies.

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

4 years agoRevert "[MachineVerifier] Improve verification of live-in lists.
Galina Kistanova [Thu, 7 Nov 2019 22:02:13 +0000 (14:02 -0800)]
Revert "[MachineVerifier] Improve verification of live-in lists.

This reverts commit b7b170c to give the author more time to address failing tests on the expensive checks buildbots.

4 years ago[codeview] Reference types in type parent scopes
Reid Kleckner [Wed, 6 Nov 2019 23:04:52 +0000 (15:04 -0800)]
[codeview] Reference types in type parent scopes

Without this change, when a nested tag type of any kind (enum, class,
struct, union) is used as a variable type, it is emitted without
emitting the parent type. In CodeView, parent types point to their inner
types, and inner types do not point back to their parents. We already
walk over all of the parent scopes to build the fully qualified name.
This change simply requests their type indices as we go along to enusre
they are all emitted.

Fixes PR43905

Reviewers: akhuang, amccarth

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

4 years ago[Diagnostics] Teach -Wnull-dereference about address_space attribute
Dávid Bolvanský [Thu, 7 Nov 2019 19:47:09 +0000 (20:47 +0100)]
[Diagnostics] Teach -Wnull-dereference about address_space attribute

Summary:
Clang should not warn for:

> test.c:2:12: warning: indirection of non-volatile null pointer will be deleted,
>       not trap [-Wnull-dereference]
>     return *(int __attribute__((address_space(256))) *) 0;
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Solves PR42292.

Reviewers: aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[CodeGenModule] Group blocks runtime globals together, NFC
Vedant Kumar [Thu, 7 Nov 2019 20:46:26 +0000 (12:46 -0800)]
[CodeGenModule] Group blocks runtime globals together, NFC

4 years ago[lldb] Improve assert in GDBRemoteCommunicationReplayServer
Jonas Devlieghere [Thu, 7 Nov 2019 19:13:47 +0000 (11:13 -0800)]
[lldb] Improve assert in GDBRemoteCommunicationReplayServer

While investigating an issue where a different packet was sent during
replay I noticed how annoying it is that the existing assert doesn't
specify what packet is actually different. It's printed to the log, but
enabling logging has the potential to change LLDB's behavior. The same
is true when debugging LLDB while it's replaying the reproducer.

I replaced the assert with a printf of the unexpected packet followed by
a fatal_error wrapped in ifndef NDEBUG. The behavior is the same as the
previous assert, just with more/better context.

4 years ago[InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx...
Craig Topper [Thu, 7 Nov 2019 20:37:24 +0000 (12:37 -0800)]
[InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx and <1 x i64>.

As the test cases show, we end up with an insert/extract and a
bitcast to/from i64. x86_mmx is for some purposes conceptually a
vector. We shouldn't be adding scalar conversions around it.

Since _m64 is defined as <1 x i64> and intrinsics use x86_mmx
as their input/output these extra scalar operations prevent
the X86 backend from generating good code especially on 32-bit
targets where i64 gets split.

4 years ago[Sema] Fixes a crash with a templated destructor
Mark de Wever [Thu, 7 Nov 2019 20:22:03 +0000 (21:22 +0100)]
[Sema] Fixes a crash with a templated destructor

The issue was introduced by D33189 which fixed PR33189.

Fixes PR38671: "destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember

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

4 years ago[clang] Add -fdebug-default-version for specifying the default DWARF version
David Blaikie [Thu, 7 Nov 2019 20:00:22 +0000 (12:00 -0800)]
[clang] Add -fdebug-default-version for specifying the default DWARF version

This flag decouples specifying the DWARF version from enabling/disabling
DWARF in general (or the gN level - gmlt/limited/standalone, etc) while
still allowing existing -gdwarf-N flags to override this default.

Patch by Caroline Tice!

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

4 years agoWrong debug info generated at -O2 (-O0 is correct)
Vedant Kumar [Thu, 7 Nov 2019 19:19:41 +0000 (11:19 -0800)]
Wrong debug info generated at -O2 (-O0 is correct)

Instcombiner pass was erasing trivially dead instruction without updating dependent llvm.dbg.value.
which was not showing programmer current state of variables while debugging.
As a part of this fix I did following,
Iterate throught all the users (llvm.dbg) of a instruction which is trivially dead and set each if them undef, Before deleting the instruction.
Now user will see optimized out, when try to print those variables.
This fixes
https://bugs.llvm.org/show_bug.cgi?id=43893

This is my first fix to llvm.

Patch by kamlesh kumar!

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

4 years agocrashlog.py: Improve regular expressions
Adrian Prantl [Thu, 7 Nov 2019 18:50:37 +0000 (10:50 -0800)]
crashlog.py: Improve regular expressions

This is yet another change to the regular expressions in crashlog.py
that fix a few edge cases, and attempt to improve the readability
quite a bit in the process. My last change to support spaces in
filenames introduced a bug that caused the version/archspec field to
be parsed as part of the image name.

For example, in "0x1111111 - 0x22222 +MyApp Pro arm64 <01234>", the
name of the image was recognized as "MyApp Pro arm64" instead of
"MyApp Pro" with a "version" of arm64.

The bugfix makes the space following an optional field mandatory
*inside* the optional group.

rdar://problem/56883435

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

4 years agoRevert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"
Edward Jones [Thu, 7 Nov 2019 18:19:09 +0000 (18:19 +0000)]
Revert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"

This reverts commit 7adab7719e55e1b29bfd521dcc73f202139e8f41.

4 years agoFDRRecords - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:41:49 +0000 (18:41 +0000)]
FDRRecords - fix uninitialized variable warnings. NFCI.

4 years agoImutAVLTree::validateTree - fix null dereference typo warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:41:01 +0000 (18:41 +0000)]
ImutAVLTree::validateTree - fix null dereference typo warning. NFCI.

Noticed by static analyzer.

4 years agocanFoldMergeOpcode returns a bool result not an unsigned. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:00:43 +0000 (18:00 +0000)]
canFoldMergeOpcode returns a bool result not an unsigned. NFCI.

4 years agoFix warning about unused std::unique result, erase shifted elements
Reid Kleckner [Thu, 7 Nov 2019 18:37:04 +0000 (10:37 -0800)]
Fix warning about unused std::unique result, erase shifted elements

This is actually a functional change. I haven't added any new test
coverage. I'm just trying to fix the warning and hoping for the best.

4 years ago[AsmWritter] Fixed "null check after dereferencing" warning
Dávid Bolvanský [Wed, 6 Nov 2019 18:20:48 +0000 (19:20 +0100)]
[AsmWritter] Fixed "null check after dereferencing" warning

Summary: The 'BB->getParent()' pointer was utilized before it was verified against nullptr. Check lines: 3567, 3581.

Reviewers: jyknight, RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[RISCV] Fix up tests on Windows after new usage of sys::path::append
Reid Kleckner [Thu, 7 Nov 2019 17:53:56 +0000 (09:53 -0800)]
[RISCV] Fix up tests on Windows after new usage of sys::path::append

4 years ago[XCOFF] Add back extern template declarations
Reid Kleckner [Thu, 7 Nov 2019 17:42:25 +0000 (09:42 -0800)]
[XCOFF] Add back extern template declarations

The extern template declarations were fine. The duplicate explicit
instantiations were both in the .cpp file.

4 years agoRevert "[XCOFF] Fix link errors from explicit template instantiation"
Reid Kleckner [Thu, 7 Nov 2019 17:39:13 +0000 (09:39 -0800)]
Revert "[XCOFF] Fix link errors from explicit template instantiation"

This reverts commit c989993ba1a666f04f7aee7df51d9f4de0588b71.

maskray already fixed the explicit instantiation definition in the .cpp
file, and these extern template declarations seem to be causing
warnings that I don't understand.

4 years ago[XCOFF] Fix link errors from explicit template instantiation
Reid Kleckner [Thu, 7 Nov 2019 17:27:43 +0000 (09:27 -0800)]
[XCOFF] Fix link errors from explicit template instantiation

I happen to be using clang-cl+lld-link locally, and I get these link
errors:

lld-link: error: undefined symbol: public: unsigned short __cdecl llvm::object::XCOFFSectionHeader<struct llvm::object::XCOFFSectionHeader64>::getSectionType(void) const
>>> referenced by C:\src\llvm-project\llvm\tools\llvm-readobj\XCOFFDumper.cpp:106
>>>               tools\llvm-readobj\CMakeFiles\llvm-readobj.dir\XCOFFDumper.cpp.obj:(public: virtual void __cdecl `anonymous namespace'::XCOFFDumper::printSectionHeaders(void))

I suspect this is because the explicit template instaniation appears
before the inline method definitions in the .cpp file, so they aren't
available at the point of instantiation. Move the explicit instantiation
later.

Also, forward declare the explicit instantiation for good measure.

4 years ago[llvm-ar] Support verbose mode for operation 'x'
Fangrui Song [Wed, 6 Nov 2019 18:19:30 +0000 (10:19 -0800)]
[llvm-ar] Support verbose mode for operation 'x'

Reviewed By: jhenderson, kongyi

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

4 years ago[XCOFF] Move explicit instantions after member function definitions to fix clang...
Fangrui Song [Thu, 7 Nov 2019 17:25:31 +0000 (09:25 -0800)]
[XCOFF] Move explicit instantions after member function definitions to fix clang builds

4 years ago[InstCombine] canonicalize shift+logic+shift to reduce dependency chain
Sanjay Patel [Thu, 7 Nov 2019 17:08:10 +0000 (12:08 -0500)]
[InstCombine] canonicalize shift+logic+shift to reduce dependency chain

shift (logic (shift X, C0), Y), C1 --> logic (shift X, C0+C1), (shift Y, C1)

This is an IR translation of an existing SDAG transform added here:
rL370617

So we again have 9 possible patterns with a commuted IR variant of each pattern:
https://rise4fun.com/Alive/VlI
https://rise4fun.com/Alive/n1m
https://rise4fun.com/Alive/1Vn

Part of the motivation is to allow easier recognition and subsequent
canonicalization of bswap patterns as discussed in PR43146:
https://bugs.llvm.org/show_bug.cgi?id=43146

We had to delay this transform because it used to allow the SLP vectorizer
to create awful reductions out of simple load-combines.
That problem was fixed with:
rL375025
(we'll bring back load combining in IR someday...)

The backend is also better equipped to deal with these patterns now
using hooks like TLI.getShiftAmountThreshold().

The only remaining potential controversy is that the -reassociate pass
tends to reverse this kind of pattern (to help GVN?). But since -reassociate
doesn't do anything with these specific patterns, there is no conflict currently.

Finally, there's a new pass proposal at D67383 for general tree-height-reduction
reassociation, and it could use a cost model to decide how to optimally rearrange
these kinds of ops for a target. That patch appears to be stalled.

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

4 years agoX86FrameLowering - fix bool to unsigned cast static analyzer warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:48:35 +0000 (16:48 +0000)]
X86FrameLowering - fix bool to unsigned cast static analyzer warnings. NFCI.

4 years agoMachineMemOperand::getBaseAlignment() - fix "shift of i32 then extended to i64" stati...
Simon Pilgrim [Thu, 7 Nov 2019 16:46:55 +0000 (16:46 +0000)]
MachineMemOperand::getBaseAlignment() - fix "shift of i32 then extended to i64" static analyzer warning. NFCI.

4 years agoTypeRecord - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:45:36 +0000 (16:45 +0000)]
TypeRecord - fix uninitialized variable warnings. NFCI.

4 years agoPostRAScheduler - fix uninitialized variable warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:45:01 +0000 (16:45 +0000)]
PostRAScheduler - fix uninitialized variable warning. NFCI.

4 years agoManagedStringPool - pre-increment iterator. NFC.
Simon Pilgrim [Thu, 7 Nov 2019 16:43:47 +0000 (16:43 +0000)]
ManagedStringPool - pre-increment iterator. NFC.

4 years agoX86CondBrFolding - remove non-existent fixBranchProb function. NFC.
Simon Pilgrim [Thu, 7 Nov 2019 16:41:48 +0000 (16:41 +0000)]
X86CondBrFolding - remove non-existent fixBranchProb function. NFC.

4 years agoAsmWriterOperand - fix uninitialized variable warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 15:35:07 +0000 (15:35 +0000)]
AsmWriterOperand - fix uninitialized variable warning. NFCI.

4 years agoUsing crtp to refactor the xcoff section header
diggerlin [Thu, 7 Nov 2019 16:51:34 +0000 (11:51 -0500)]
Using crtp to refactor the xcoff section header

SUMMARY:
According to https://reviews.llvm.org/D68575#inline-617586, Create a NFC patch for it.

Using crtp to refactor the xcoff section header
Move the define of SectionFlagsReservedMask and SectionFlagsTypeMask from XCOFFDumper.cpp to XCOFFObjectFile.h

Reviewers: hubert.reinterpretcast,jasonliu
Subscribers: rupprecht, seiyai,hiraditya

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

4 years ago[lldb] Comment typo fix
Jan Kratochvil [Thu, 7 Nov 2019 16:48:25 +0000 (17:48 +0100)]
[lldb] Comment typo fix

4 years agocomment shiftamountthreshold
joanlluch [Thu, 7 Nov 2019 16:41:05 +0000 (17:41 +0100)]
comment shiftamountthreshold

4 years ago[openmp] [test] Skip one more test that kills NetBSD buildbot
Michał Górny [Thu, 7 Nov 2019 16:29:13 +0000 (17:29 +0100)]
[openmp] [test] Skip one more test that kills NetBSD buildbot

4 years ago[OPENMP][DOCS] Update OpenMP status (NFC)
Alexey Bataev [Thu, 7 Nov 2019 16:07:56 +0000 (11:07 -0500)]
[OPENMP][DOCS] Update OpenMP status (NFC)

Summary: This is updating the OpenMP status table. Cray has volunteered for `defaultmap` and supporting `in_reduction` on the `target` construct, so the status on those entries from was changed from "unclaimed". Also, a new entry was added for supporting non-contiguous arrays sections on the `target update` directive.

Reviewers: ABataev, hfinkel, jdoerfert, kkwli0

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

Tags: #clang

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

4 years ago[Sema] Suppress -Wchar-subscripts if the index is a literal char
Edward Jones [Thu, 7 Nov 2019 15:44:38 +0000 (15:44 +0000)]
[Sema] Suppress -Wchar-subscripts if the index is a literal char

Assume that the user knows what they're doing if they provide a char
literal as an array index. This more closely matches the behavior of
GCC.

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

4 years ago[GWP-ASan] Respect compiler-rt's -fno-lto
Mitch Phillips [Thu, 7 Nov 2019 15:41:08 +0000 (07:41 -0800)]
[GWP-ASan] Respect compiler-rt's -fno-lto

https://bugs.llvm.org/show_bug.cgi?id=43722

GWP-ASan didn't include SANITIZER_COMMON_CFLAGS, and thus would produce
LLVM bitcode files, when compiler-rt is generally built without LTO.

4 years ago[RISCV] Add riscv{32,64} to ALL_CRT_SUPPORTED_ARCH list
Edward Jones [Thu, 3 Oct 2019 14:00:55 +0000 (15:00 +0100)]
[RISCV] Add riscv{32,64} to ALL_CRT_SUPPORTED_ARCH list

This allows crtbegin and crtend to be built, allowing RISC-V
to no longer rely on implementations from libgcc.

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

4 years ago[SDAG] reduce code duplication; NFC
Sanjay Patel [Thu, 7 Nov 2019 15:28:25 +0000 (10:28 -0500)]
[SDAG] reduce code duplication; NFC

4 years agoAdd support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-except...
Melanie Blower [Tue, 5 Nov 2019 21:41:21 +0000 (13:41 -0800)]
Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=

    Add options to control floating point behavior: trapping and
    exception behavior, rounding, and control of optimizations that affect
    floating point calculations. More details in UsersManual.rst.

    Reviewers: rjmccall

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

4 years ago[RISCV] Improve sysroot computation if no GCC install detected
Edward Jones [Thu, 3 Oct 2019 13:49:08 +0000 (14:49 +0100)]
[RISCV] Improve sysroot computation if no GCC install detected

If a GCC installed is not detected, the driver would default to
the root of the filesystem. This is not ideal when this doesn't
match the install directory of the toolchain and can cause
undesireable behavior such as picking up system libraries or
the system linker when cross-compiling.

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

4 years ago[SDAG] reduce code duplication; NFC
Sanjay Patel [Thu, 7 Nov 2019 15:14:49 +0000 (10:14 -0500)]
[SDAG] reduce code duplication; NFC

4 years ago[OpenCL] Add geometric and relational builtin functions
Sven van Haastregt [Thu, 7 Nov 2019 15:00:19 +0000 (15:00 +0000)]
[OpenCL] Add geometric and relational builtin functions

Add the geometric and relational builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

4 years ago[OpenCL] Add integer builtin functions
Sven van Haastregt [Wed, 6 Nov 2019 11:53:19 +0000 (11:53 +0000)]
[OpenCL] Add integer builtin functions

This patch adds the integer builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

4 years ago[lldb] Add -m option to 'target modules dump symtab' to disable demangling
Raphael Isemann [Thu, 7 Nov 2019 14:47:01 +0000 (15:47 +0100)]
[lldb] Add -m option to 'target modules dump symtab' to disable demangling

Summary: This option was added downstream in swift-lldb. This upstreams this option as it seems useful and also adds the missing tests.

Reviewers: #lldb, kwk, labath

Reviewed By: kwk, labath

Subscribers: labath, kwk, abidh, JDevlieghere, lldb-commits

Tags: #lldb, #upstreaming_lldb_s_downstream_patches

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

4 years agoSampleProfWriter - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 13:51:35 +0000 (13:51 +0000)]
SampleProfWriter - fix uninitialized variable warnings. NFCI.

4 years agoCodeGen: set correct result for atomic compound expressions
Tim Northover [Thu, 7 Nov 2019 13:36:03 +0000 (13:36 +0000)]
CodeGen: set correct result for atomic compound expressions

Atomic compound expressions try to use atomicrmw if possible, but this
path doesn't set the Result variable, leaving it to crash in later code
if anything ever tries to use the result of the expression. This fixes
that issue by recalculating the new value based on the old one
atomically loaded.

4 years ago[libc++] Fix potential OOB in poisson_distribution
Louis Dionne [Thu, 7 Nov 2019 12:06:14 +0000 (12:06 +0000)]
[libc++] Fix potential OOB in poisson_distribution

See details in the original Chromium bug report:
    https://bugs.chromium.org/p/chromium/issues/detail?id=994957

4 years ago[ConstantRange][LVI] Use overflow flags from `sub` to constrain the range
Roman Lebedev [Thu, 7 Nov 2019 13:18:03 +0000 (16:18 +0300)]
[ConstantRange][LVI] Use overflow flags from `sub` to constrain the range

Summary:
This notably improves non-negativity deduction:
```
| statistic                              |     old |     new | delta | % change |
| correlated-value-propagation.NumAShrs  |     209 |     227 |    18 |  8.6124% |
| correlated-value-propagation.NumAddNSW |    4972 |    4988 |    16 |  0.3218% |
| correlated-value-propagation.NumAddNUW |    7141 |    7148 |     7 |  0.0980% |
| correlated-value-propagation.NumAddNW  |   12113 |   12136 |    23 |  0.1899% |
| correlated-value-propagation.NumAnd    |     442 |     445 |     3 |  0.6787% |
| correlated-value-propagation.NumNSW    |    7160 |    7176 |    16 |  0.2235% |
| correlated-value-propagation.NumNUW    |   13306 |   13316 |    10 |  0.0752% |
| correlated-value-propagation.NumNW     |   20466 |   20492 |    26 |  0.1270% |
| correlated-value-propagation.NumSDivs  |     207 |     212 |     5 |  2.4155% |
| correlated-value-propagation.NumSExt   |    6279 |    6679 |   400 |  6.3704% |
| correlated-value-propagation.NumSRems  |      28 |      29 |     1 |  3.5714% |
| correlated-value-propagation.NumShlNUW |    2793 |    2796 |     3 |  0.1074% |
| correlated-value-propagation.NumShlNW  |    3964 |    3967 |     3 |  0.0757% |
| correlated-value-propagation.NumUDivs  |     353 |     358 |     5 |  1.4164% |
| instcount.NumAShrInst                  |   13763 |   13741 |   -22 | -0.1598% |
| instcount.NumAddInst                   |  277349 |  277348 |    -1 | -0.0004% |
| instcount.NumLShrInst                  |   27437 |   27463 |    26 |  0.0948% |
| instcount.NumOrInst                    |  102677 |  102678 |     1 |  0.0010% |
| instcount.NumSDivInst                  |    8732 |    8727 |    -5 | -0.0573% |
| instcount.NumSExtInst                  |   80872 |   80468 |  -404 | -0.4996% |
| instcount.NumSRemInst                  |    1679 |    1678 |    -1 | -0.0596% |
| instcount.NumTruncInst                 |   62154 |   62153 |    -1 | -0.0016% |
| instcount.NumUDivInst                  |    2526 |    2527 |     1 |  0.0396% |
| instcount.NumURemInst                  |    1589 |    1590 |     1 |  0.0629% |
| instcount.NumZExtInst                  |   69405 |   69809 |   404 |  0.5821% |
| instcount.TotalInsts                   | 7439575 | 7439574 |    -1 |  0.0000% |
```

Reviewers: nikic, reames, spatel

Reviewed By: nikic

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[OpenCL] Add math and common builtin functions
Sven van Haastregt [Tue, 5 Nov 2019 19:47:21 +0000 (19:47 +0000)]
[OpenCL] Add math and common builtin functions

Add the remaining math and common builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

4 years ago[libc++] Fixed copy/copy_n/copy_backward for compilers that do not support is_constan...
Louis Dionne [Thu, 7 Nov 2019 12:30:32 +0000 (12:30 +0000)]
[libc++] Fixed copy/copy_n/copy_backward for compilers that do not support is_constant_evaluated.

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

4 years ago[libc++] Fix some constexpr tests broken by D68837
Louis Dionne [Wed, 6 Nov 2019 14:52:26 +0000 (14:52 +0000)]
[libc++] Fix some constexpr tests broken by D68837

This doesn't fix all the issues with D68837

4 years ago[ThinLTO] Import readonly vars with refs
evgeny [Thu, 7 Nov 2019 12:13:35 +0000 (15:13 +0300)]
[ThinLTO] Import readonly vars with refs

Patch allows importing declarations of functions and variables, referenced
by the initializer of some other readonly variable.
Differential revision: https://reviews.llvm.org/D69561

4 years ago[SLP] allow forming 2-way reduction patterns
Sanjay Patel [Wed, 6 Nov 2019 22:24:09 +0000 (17:24 -0500)]
[SLP] allow forming 2-way reduction patterns

We have a vector compare reduction problem seen in PR39665 comment 2:
https://bugs.llvm.org/show_bug.cgi?id=39665#c2

Or slightly reduced here:

define i1 @cmp2(<2 x double> %a0) {
  %a = fcmp ogt <2 x double> %a0, <double 1.0, double 1.0>
  %b = extractelement <2 x i1> %a, i32 0
  %c = extractelement <2 x i1> %a, i32 1
  %d = and i1 %b, %c
  ret i1 %d
}

SLP would not attempt to turn this into a vector reduction because there is an
artificial lower limit on that transform. We can not completely remove that limit
without inducing regressions though, so this patch just hacks an extra attempt at
creating a 2-way reduction to the end of the analysis.

As shown in the test file, we are still not getting some of the motivating cases,
so follow-on patches will be needed to solve those cases.

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