platform/upstream/llvm.git
4 years ago[BuildLibCalls] Add noalias for strcat and stpcpy
Dávid Bolvanský [Sun, 27 Sep 2020 19:32:32 +0000 (21:32 +0200)]
[BuildLibCalls] Add noalias for strcat and stpcpy

strcat:
destination and source shall not overlap. (http://www.cplusplus.com/reference/cstring/strcat/)

stpcpy:
The strings may not overlap, and the destination string dest must be  large enough to receive the copy. (https://man7.org/linux/man-pages/man3/stpcpy.3.html)

Reviewed By: jdoerfert

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

4 years ago[OpenMP] Add Missing _static Director for OpenMP Documentation
Joseph Huber [Sun, 27 Sep 2020 19:35:47 +0000 (15:35 -0400)]
[OpenMP] Add Missing _static Director for OpenMP Documentation

Summary:
Adding a missing directory needed for generating Sphinx documentation without
errors. Directory current contains a placeholder image just to populate the
directory.

4 years ago[CVP] Remove unnecessary block splits in tests (NFC)
Nikita Popov [Sun, 27 Sep 2020 18:44:25 +0000 (20:44 +0200)]
[CVP] Remove unnecessary block splits in tests (NFC)

These are no longer necessary since D69686.

4 years ago[LVI][CVP] Use block value when simplifying icmps
Nikita Popov [Sun, 30 Aug 2020 14:20:12 +0000 (16:20 +0200)]
[LVI][CVP] Use block value when simplifying icmps

Add a flag to getPredicateAt() that allows making use of the block
value. This allows us to take into account range information from
the current block, rather than only information that is threaded
over edges, making the icmp simplification in CVP a lot more
powerful.

I'm not changing getPredicateAt() to use the block value
unconditionally to avoid any impact on the JumpThreading pass,
which is somewhat picky about LVI query order.

Most test changes here are just icmps that now get dropped (while
previously only a result used in a return was replaced). The three
tests in icmp.ll show some representative improvements. Some of
the folds this enables have been covered by IPSCCP in the meantime,
but LVI can reason about some cases which are hard to support in
IPSCCP, such as in test_br_cmp_with_offset.

The compile-time time cost of doing this is fairly minimal, with
a ~0.05% CTMark regression for ReleaseThinLTO:
https://llvm-compile-time-tracker.com/compare.php?from=709d03f8af4da4204849a70f01798e7cebba2e32&to=6236fd503761f43c99f4537121e057a01056f185&stat=instructions

This is because the block values will typically already be queried
and cached by other CVP optimizations anyway.

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

4 years ago[NewPM] Port ConstraintElimination to the new pass manager
Fangrui Song [Sun, 27 Sep 2020 18:12:13 +0000 (11:12 -0700)]
[NewPM] Port ConstraintElimination to the new pass manager

If -enable-constraint-elimination is specified, add it to the -O2/-O3 pipeline.
(-O1 uses a separate function now.)

Reviewed By: fhahn, aeubanks

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

4 years ago[InstCombine] Simplify code. NFCI.
Benjamin Kramer [Sun, 27 Sep 2020 17:10:53 +0000 (19:10 +0200)]
[InstCombine] Simplify code. NFCI.

4 years ago[CVP] Make srem test more robust (NFC)
Nikita Popov [Sun, 27 Sep 2020 16:56:10 +0000 (18:56 +0200)]
[CVP] Make srem test more robust (NFC)

D69686 will be able to determine that the icmp is always false.
As this is not the purpose of the test, use a different modulus
that doesn't trivialize the condition.

4 years ago[LVI] Clarify getValueAt/getValueInBlock doc comments (NFC)
Nikita Popov [Sun, 27 Sep 2020 16:21:19 +0000 (18:21 +0200)]
[LVI] Clarify getValueAt/getValueInBlock doc comments (NFC)

The lattice value returned by getValueInBlock() holds at the start
of the block, not at the end. Also make it clearer what the
difference between getValueInBlock() and getValueAt() is.

4 years ago[LVI] Require context instruction in external API (NFCI)
Nikita Popov [Sun, 27 Sep 2020 15:41:39 +0000 (17:41 +0200)]
[LVI] Require context instruction in external API (NFCI)

Require CxtI in getConstant() and getConstantRange() APIs.
Accordingly drop the BB parameter, as it is implied by
CxtI->getParent().

This makes sure we don't forget to pass the context instruction,
and makes the API contract clearer (also clean up the comments to
that effect -- the value holds at the context instruction, not
the end of the block).

4 years ago[CVP] Pass context instruction when narrowing div/rem
Nikita Popov [Sun, 27 Sep 2020 15:49:37 +0000 (17:49 +0200)]
[CVP] Pass context instruction when narrowing div/rem

This fold was the only place not passing the context instruction.
The tests worked around that fact by introducing a basic block split,
which is now no longer necessary.

4 years ago[X86] Add some basic i128 udiv test coverage
Simon Pilgrim [Sun, 27 Sep 2020 14:59:53 +0000 (15:59 +0100)]
[X86] Add some basic i128 udiv test coverage

4 years ago[X86] Regenerate i128 sdiv tests and add i686 coverage.
Simon Pilgrim [Sun, 27 Sep 2020 14:58:20 +0000 (15:58 +0100)]
[X86] Regenerate i128 sdiv tests and add i686 coverage.

To hopefully help improve the codegen delta in D87976

4 years ago[CostModel] add cl option to check size and latency costs; NFC
Sanjay Patel [Sun, 27 Sep 2020 13:52:56 +0000 (09:52 -0400)]
[CostModel] add cl option to check size and latency costs; NFC

This is a setting used by SimplifyCFG, LoopUnroll, and InlineCost,
but there is apparently no direct test coverage for any of those
cost model values.

4 years ago[ValueTracking] enhance isKnownNeverInfinity to understand sitofp
Sanjay Patel [Sun, 27 Sep 2020 12:24:03 +0000 (08:24 -0400)]
[ValueTracking] enhance isKnownNeverInfinity to understand sitofp

As discussed in D87877, instcombine already has this fold,
but it was missing from the more general ValueTracking logic.

https://alive2.llvm.org/ce/z/PumYZP

4 years ago[InstSimplify] add tests for fcmp with casted op; NFC
Sanjay Patel [Sat, 26 Sep 2020 14:53:29 +0000 (10:53 -0400)]
[InstSimplify] add tests for fcmp with casted op; NFC

This shows missing analysis in ValueTracking's isKnownNeverInfinity().

4 years agoTypo fix; NFC
Aaron Ballman [Sun, 27 Sep 2020 12:30:41 +0000 (08:30 -0400)]
Typo fix; NFC

4 years ago[llvm-objcopy][NFC] refactor error handling. part 2.
Alexey Lapshin [Wed, 23 Sep 2020 17:04:52 +0000 (20:04 +0300)]
[llvm-objcopy][NFC] refactor error handling. part 2.

Remove usages of special error reporting functions(error(),
reportError()). This patch is extracted from D87987.
Errors are reported as Expected<>/Error returning values.
This part is for COFF subfolder of llvm-objcopy.

Testing: check-all.

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

4 years agoFix MIPS and MIPS64 ABI to use ConstString in their register info arrays.
Tatsuo Nomura [Sun, 27 Sep 2020 10:15:34 +0000 (12:15 +0200)]
Fix MIPS and MIPS64 ABI to use ConstString in their register info arrays.

RegInfoBasedABI::GetRegisterInfoByName was failing because mips/mips64 ABIs
don't use ConstString in their register info array.

Reviewed By: #lldb, teemperor

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

4 years ago[AArch64][GlobalISel] Promote scalar G_SHL constant shift amounts to s64.
Amara Emerson [Sun, 27 Sep 2020 08:45:09 +0000 (01:45 -0700)]
[AArch64][GlobalISel] Promote scalar G_SHL constant shift amounts to s64.

This was supposed to be done in the first place as is currently the case for
G_ASHR and G_LSHR but was forgotten when the original shift legalization
overhaul was done last year.

This was exposed because we started falling back on s32 = s32, s64 SHLs
due to a recent combiner change.

Gives a very minor (0.1%) code size -O0 improvement on consumer-typeset.

4 years ago[Legalize][X86] Improve nnan fmin/fmax vector reduction
Nikita Popov [Sat, 12 Sep 2020 21:10:15 +0000 (23:10 +0200)]
[Legalize][X86] Improve nnan fmin/fmax vector reduction

Use +/-Inf or +/-Largest as neutral element for nnan fmin/fmax
reductions. This avoids dropping any FMF flags. Preserving the
nnan flag in particular is important to get a good lowering on X86.

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

4 years ago[AArch64][GlobalISel] Use the look-through constant helper for the shift s32->s64...
Amara Emerson [Sun, 27 Sep 2020 08:22:55 +0000 (01:22 -0700)]
[AArch64][GlobalISel] Use the look-through constant helper for the shift s32->s64 custom legalization.

Almost NFC, except it catches more cases and gives a 0.1% CTMark -O0 size win.

4 years ago[DivRemPairs] Use DenseMapBase::find instead of operator[]. NFC
Fangrui Song [Sun, 27 Sep 2020 08:04:30 +0000 (01:04 -0700)]
[DivRemPairs] Use DenseMapBase::find instead of operator[]. NFC

4 years ago[X86] Add more test cases to inline-asm-flag-output.ll. NFC
Craig Topper [Sun, 27 Sep 2020 06:26:40 +0000 (23:26 -0700)]
[X86] Add more test cases to inline-asm-flag-output.ll. NFC

These are tests to make sure we are able to use the flag directly
in a conditional branch after the inline asm.

4 years agoUpdate Kaleidoscope: Change headers
sunshaoce [Sun, 27 Sep 2020 05:40:50 +0000 (05:40 +0000)]
Update Kaleidoscope: Change headers

Reviewed By: JDevlieghere

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

4 years ago[Machinesink] add one more profitable loop related pattern
Chen Zheng [Sat, 26 Sep 2020 12:30:48 +0000 (08:30 -0400)]
[Machinesink] add one more profitable loop related pattern

Reviewed By: qcolombet

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

4 years ago[LLVM-C] Turn a ShuffleVector Constant Into a Getter.
Robert Widmann [Sat, 26 Sep 2020 23:32:38 +0000 (17:32 -0600)]
[LLVM-C] Turn a ShuffleVector Constant Into a Getter.

It is not a good idea to expose raw constants in the LLVM C API. Replace this with an explicit getter.

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

4 years agoInternalize functions from various tools. NFC
Fangrui Song [Sat, 26 Sep 2020 22:57:09 +0000 (15:57 -0700)]
Internalize functions from various tools. NFC

And internalize some classes if I noticed them:)

4 years ago[NFC][PowerPC] Change PPCSubTarget (introduced from D87671) to Subtarget
Amy Kwan [Fri, 25 Sep 2020 17:58:16 +0000 (12:58 -0500)]
[NFC][PowerPC] Change PPCSubTarget (introduced from D87671) to Subtarget

In D87671, it introduced PPCSubTarget in PPCISelDAGToDAG. This should have been
Subtarget instead. This patch changes PPCSubTarget into Subtarget.

4 years agoFix sphinx warnings in AttributeReference, NFC
Aaron Puchert [Sat, 26 Sep 2020 22:46:24 +0000 (00:46 +0200)]
Fix sphinx warnings in AttributeReference, NFC

The previous attempt in d34c8c70 didn't help (the problem was missing
indentation), and another issue was introduced by a51d51a0.

4 years ago[ConstraintElimination] Internalize function/class and delete an implied condition...
Fangrui Song [Sat, 26 Sep 2020 22:04:39 +0000 (15:04 -0700)]
[ConstraintElimination] Internalize function/class and delete an implied condition. NFC

Delete an implied condition (E.NumIn <= CB.NumIn)

4 years ago[X86] Add 64-bit target tests
Simon Pilgrim [Sat, 26 Sep 2020 21:07:51 +0000 (22:07 +0100)]
[X86] Add 64-bit target tests

4 years agoThread safety analysis: Improve documentation for ASSERT_CAPABILITY
Russell Yanofsky [Sat, 26 Sep 2020 20:11:43 +0000 (22:11 +0200)]
Thread safety analysis: Improve documentation for ASSERT_CAPABILITY

Previous description didn't actually state the effect the attribute has on
thread safety analysis (causing analysis to assume the capability is held).

Previous description was also ambiguous about (or slightly overstated) the
noreturn assumption made by thread safety analysis, implying the assumption had
to be true about the function's behavior in general, and not just its behavior
in places where it's used. Stating the assumption specifically should avoid a
perceived need to disable thread safety analysis in places where only asserting
that a specific capability is held would be better.

Reviewed By: aaronpuchert, vasild

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

4 years ago[flang] SAVE statement should not apply to nested scoping units
Riccardo Bertossa [Sat, 26 Sep 2020 19:41:20 +0000 (12:41 -0700)]
[flang] SAVE statement should not apply to nested scoping units

SAVE statement, according to 8.6.14, must apply to the same scoping
unit, that excludes nested scoping units. For example, if the SAVE
statement is found in a MODULE, the functions contained in that module
should not inherit the SAVE attribute. I think that the code was doing
this, failing the following source:

```
MODULE pippo
SAVE

CONTAINS
PURE FUNCTION fft_stick_index( )
   IMPLICIT NONE
   INTEGER :: fft_stick_index
   INTEGER :: mc  !error: A pure subprogram may not have a variable with the SAVE attribute
END FUNCTION

END MODULE
```

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

4 years ago[InstCombine] Add basic vector test coverage for icmp_eq/ne zero combines
Simon Pilgrim [Sat, 26 Sep 2020 19:08:43 +0000 (20:08 +0100)]
[InstCombine] Add basic vector test coverage for icmp_eq/ne zero combines

4 years agoRevert "[DSE] Switch to MemorySSA-backed DSE by default."
Florian Hahn [Sat, 26 Sep 2020 16:56:15 +0000 (17:56 +0100)]
Revert "[DSE] Switch to MemorySSA-backed DSE by default."

There appears to be a mis-compile with MemorySSA-backed DSE in
combination with llvm.lifetime.end. It currently appears like
DSE is doing the right thing and the llvm.lifetime.end markers
are incorrect. The reverted patch uncovers the mis-compile.

This patch temporarily switches back to the legacy DSE
implementation, while we investigate.

This reverts commit 9d172c8e9c845a36b61dc12c27de8acdbef8b247.

4 years ago[gn build] update TODO
Nico Weber [Sat, 26 Sep 2020 16:42:50 +0000 (12:42 -0400)]
[gn build] update TODO

4 years ago[mlir] Fix capitalization typo
Jacques Pienaar [Sat, 26 Sep 2020 16:18:35 +0000 (09:18 -0700)]
[mlir] Fix capitalization typo

Was testing on case insensitive config :-/

4 years ago[mlir] Updates to generate dialect rather than op docs
Jacques Pienaar [Sat, 26 Sep 2020 16:02:35 +0000 (09:02 -0700)]
[mlir] Updates to generate dialect rather than op docs

4 years ago[mlir] Fix passes.md's naming & add missing
Jacques Pienaar [Sat, 26 Sep 2020 15:47:25 +0000 (08:47 -0700)]
[mlir] Fix passes.md's naming & add missing

4 years ago[X86] Cleanup check-prefixes for vector-mul.ll tests
Simon Pilgrim [Sat, 26 Sep 2020 14:49:19 +0000 (15:49 +0100)]
[X86] Cleanup check-prefixes for vector-mul.ll tests

Many x86/x64 SSE tests codegen are the same so avoid duplication

4 years ago[DAG] Fold vector mul(x,0)/mul(x,1) to a clearing mask
Simon Pilgrim [Sat, 26 Sep 2020 13:31:17 +0000 (14:31 +0100)]
[DAG] Fold vector mul(x,0)/mul(x,1) to a clearing mask

If we're multiplying all elements of a vector by '0' or '1' then we can more efficiently perform this as a clearing mask (that is likely to further simplify to a shuffle blend).

This was noticed when reviewing D87502 but seems to help idiv/irem by constant cases even more as '0'/'1' values are often used for 'passthrough' cases.

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

4 years agoMachineCSE.cpp - use auto const& iterators in for-range loops to avoid copies. NFCI.
Simon Pilgrim [Fri, 25 Sep 2020 21:33:15 +0000 (22:33 +0100)]
MachineCSE.cpp - use auto const& iterators in for-range loops to avoid copies. NFCI.

4 years agoRun test on particular target only
Serge Pavlov [Sat, 26 Sep 2020 13:23:42 +0000 (20:23 +0700)]
Run test on particular target only

The test `AST/const-fpfeatures-diag.c` requires setting strict FP
semantics, so it fails on targets where support of such semantic
is limited.

4 years ago[TableGen] Add/edit Doxygen comments to match "TableGen Backend Developer's Guide."
Paul C. Anagnostopoulos [Thu, 24 Sep 2020 15:58:07 +0000 (11:58 -0400)]
[TableGen] Add/edit Doxygen comments to match "TableGen Backend Developer's Guide."

4 years ago[DSE] Unify & fix mem terminator location checks.
Florian Hahn [Sat, 26 Sep 2020 10:03:25 +0000 (11:03 +0100)]
[DSE] Unify & fix mem terminator location checks.

When looking for memory defs killed by memory terminators the code
currently incorrectly ignores the size argument of llvm.lifetime.end.

This patch updates the code to use isMemTerminator and updates
isMemTerminator to use isOverwrite() to make sure locations that are
outside the range marked as dead by llvm.lifetime.end are not
considered. Note that isOverwrite is only used for llvm.lifetime.end,
because free-like functions make the whole underlying object dead.

4 years ago[DSE] Add tests with lifetime.end that only mark parts of the obj as dead.
Florian Hahn [Sat, 26 Sep 2020 09:13:12 +0000 (10:13 +0100)]
[DSE] Add tests with lifetime.end that only mark parts of the obj as dead.

llvm.lifetime.end accepts a size parameters to limit the size of the
location marked as dead. Add a few tests with stores to locations after
the part that has been marked as dead.

4 years ago[FPEnv] Evaluate constant expressions under non-default rounding modes
Serge Pavlov [Thu, 17 Sep 2020 07:10:07 +0000 (14:10 +0700)]
[FPEnv] Evaluate constant expressions under non-default rounding modes

The change implements evaluation of constant floating point expressions
under non-default rounding modes. The main objective was to support
evaluation of global variable initializers, where constant rounding mode
may be specified by `#pragma STDC FENV_ROUND`.

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

4 years ago[LoopDelete][Assume] Allow deleting loops with assumes
Tyker [Sat, 26 Sep 2020 10:31:12 +0000 (12:31 +0200)]
[LoopDelete][Assume] Allow deleting loops with assumes

This pervent very poor optimization caused by a signle assume like https://godbolt.org/z/EK3oMh

baseline flags: -O3
patched flags: -O3 -mllvm --enable-knowledge-retention

Before the patch
```
Metric: compile_time
Program                                                      baseline patched diff
             test-suite :: CTMark/tramp3d-v4/tramp3d-v4.test  20.72    29.74  43.5%
                     test-suite :: CTMark/Bullet/bullet.test  24.39    24.91   2.2%
               test-suite :: CTMark/7zip/7zip-benchmark.test  37.39    38.06   1.8%
                      test-suite :: CTMark/kimwitu++/kc.test  11.76    11.94   1.5%
                   test-suite :: CTMark/sqlite3/sqlite3.test  12.94    12.91  -0.3%
                       test-suite :: CTMark/SPASS/SPASS.test  11.72    11.70  -0.2%
                     test-suite :: CTMark/lencod/lencod.test  16.12    16.10  -0.1%
                   test-suite :: CTMark/ClamAV/clamscan.test  13.31    13.30  -0.1%
              test-suite :: CTMark/mafft/pairlocalalign.test   9.12     9.12  -0.1%
 test-suite :: CTMark/consumer-typeset/consumer-typeset.test   9.34     9.34  -0.1%
                                          Geomean difference                   4.2%

Metric: compiler_Kinst_count
Program                                                      baseline     patched      diff
             test-suite :: CTMark/tramp3d-v4/tramp3d-v4.test 107576069.87 172886418.90 60.7%
                     test-suite :: CTMark/Bullet/bullet.test 123291865.66 125457117.96  1.8%
                      test-suite :: CTMark/kimwitu++/kc.test  56347884.64  57298544.14  1.7%
               test-suite :: CTMark/7zip/7zip-benchmark.test 180637699.58 183341656.57  1.5%
                   test-suite :: CTMark/sqlite3/sqlite3.test  66723788.85  66664692.80 -0.1%
                   test-suite :: CTMark/ClamAV/clamscan.test  69581500.56  69597863.92  0.0%
                     test-suite :: CTMark/lencod/lencod.test  94236501.48  94216545.32 -0.0%
                       test-suite :: CTMark/SPASS/SPASS.test  58516756.95  58505089.07 -0.0%
 test-suite :: CTMark/consumer-typeset/consumer-typeset.test  48832815.53  48841989.39  0.0%
              test-suite :: CTMark/mafft/pairlocalalign.test  49682720.53  49686324.34  0.0%
                                          Geomean difference                            5.4%
```

After the patch
```
Metric: compile_time
Program                                                      baseline patched diff
             test-suite :: CTMark/tramp3d-v4/tramp3d-v4.test  20.70    22.40   8.2%
               test-suite :: CTMark/7zip/7zip-benchmark.test  37.13    38.05   2.5%
                     test-suite :: CTMark/Bullet/bullet.test  24.25    24.83   2.4%
                      test-suite :: CTMark/kimwitu++/kc.test  11.69    11.94   2.2%
                   test-suite :: CTMark/ClamAV/clamscan.test  13.19    13.36   1.3%
                     test-suite :: CTMark/lencod/lencod.test  16.02    16.19   1.1%
 test-suite :: CTMark/consumer-typeset/consumer-typeset.test   9.29     9.36   0.7%
                       test-suite :: CTMark/SPASS/SPASS.test  11.64    11.73   0.7%
              test-suite :: CTMark/mafft/pairlocalalign.test   9.10     9.15   0.5%
                   test-suite :: CTMark/sqlite3/sqlite3.test  12.95    12.96   0.0%
                                          Geomean difference                   1.9%

Metric: compiler_Kinst_count
Program                                                      baseline     patched      diff
             test-suite :: CTMark/tramp3d-v4/tramp3d-v4.test 107590933.61 114044834.72  6.0%
                      test-suite :: CTMark/kimwitu++/kc.test  56344526.77  57235806.29  1.6%
                     test-suite :: CTMark/Bullet/bullet.test 123291285.10 125128334.97  1.5%
               test-suite :: CTMark/7zip/7zip-benchmark.test 180641540.10 183155706.39  1.4%
                   test-suite :: CTMark/sqlite3/sqlite3.test  66725619.22  66668713.92 -0.1%
                       test-suite :: CTMark/SPASS/SPASS.test  58509029.85  58478704.75 -0.1%
 test-suite :: CTMark/consumer-typeset/consumer-typeset.test  48843711.23  48826894.68 -0.0%
                     test-suite :: CTMark/lencod/lencod.test  94233305.79  94207544.23 -0.0%
                   test-suite :: CTMark/ClamAV/clamscan.test  69587887.66  69603549.90  0.0%
              test-suite :: CTMark/mafft/pairlocalalign.test  49686968.65  49689291.04  0.0%
                                          Geomean difference                            1.0%
```

Reviewed By: jdoerfert, efriedma

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

4 years ago[CodeGen] Do not call `emitGlobalConstantLargeInt` for constant requires 8 bytes...
Simon Atanasyan [Thu, 24 Sep 2020 21:01:07 +0000 (00:01 +0300)]
[CodeGen] Do not call `emitGlobalConstantLargeInt` for constant requires 8 bytes to store

This is a fix for PR47630. The regression is caused by the D78011. After
this change the code starts to call the `emitGlobalConstantLargeInt` even
for constants which requires eight bytes to store.

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

4 years ago[SelectionDAG] Add guard to automatically insert flags
Qiu Chaofan [Sat, 26 Sep 2020 05:46:40 +0000 (13:46 +0800)]
[SelectionDAG] Add guard to automatically insert flags

This is like FastMathFlagGuard in IR. Since we use SDAG instance to get
values, it's with SelectionDAG. By creating a FlagInserter in current
scope, all values created by getNode will get the flags if no Flags
argument provided.

In this patch, I applied it to floating point operations folding part in
DAG combiner, and removed Flags passing to getNode to show its effect.
Other places in DAG combiner and other helper methods similar to getNode
also need this. They can be done in follow-up patches.

Reviewed By: spatel

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

4 years ago[Driver] Fix formatting as suggested by clang-format (NFC)
Dmitry Antipov [Sat, 26 Sep 2020 05:52:08 +0000 (08:52 +0300)]
[Driver] Fix formatting as suggested by clang-format (NFC)

4 years ago[Driver] Perform Linux distribution detection only once
Dmitry Antipov [Sat, 26 Sep 2020 05:44:08 +0000 (08:44 +0300)]
[Driver] Perform Linux distribution detection only once

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

4 years ago[bindings/go] Fix TestAttributes after D88241
Fangrui Song [Sat, 26 Sep 2020 03:31:31 +0000 (20:31 -0700)]
[bindings/go] Fix TestAttributes after D88241

4 years agoCommon code preparation for tblgen-types patch
John Demme [Sat, 26 Sep 2020 02:18:54 +0000 (02:18 +0000)]
Common code preparation for tblgen-types patch

Cleanup and add methods which https://reviews.llvm.org/D86904 requires. Breaking up to lower review load.

Reviewed By: mehdi_amini

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

4 years ago[Clang][OpenMP] Added support for nowait target in CodeGen via regular task
Shilei Tian [Sat, 26 Sep 2020 02:10:22 +0000 (22:10 -0400)]
[Clang][OpenMP] Added support for nowait target in CodeGen via regular task

Previously for nowait target, CG emitted a function call to `__tgt_target_nowait`, etc. However, in OpenMP RTL, these functions just directly call the no-nowait version, which means nowait is not working as expected.

OpenMP specification says a target is acutally a target task, which is an untied and detachable task. It is natural to go to the direction that generates a task for a nowait target. However, OpenMP task has a problem that it must be within to a parallel region; otherwise the task will be executed immediately. As a result, if we directly wrap to a regular task, the `target nowait` outside of a parallel region is still a synchronous version.

In D77609, I added the support for unshackled task in OpenMP RTL. Basically, unshackled task is a task that is not bound to any parallel region. So all nowait target will be tranformed into an unshackled task. In order to distinguish from regular task, a new flag bit is set for unshackled task. This flag will be used by RTL for later process.

Since all target tasks are allocated via `__kmpc_omp_target_task_alloc`, and in current `libomptarget`, `__kmpc_omp_target_task_alloc` just calls `__kmpc_omp_task_alloc`. Therefore, we can modify the flag in `__kmpc_omp_target_task_alloc` so that we don't need to modify the FE too much. If users choose to opt out the feature, they just need to use a RTL w/o support of unshackled threads.

As a result, in this patch, the `target nowait` region is simply wrapped into a regular task. Later once we have RTL support for unshackled tasks, the wrapped tasks can be executed by unshackled threads w/o changes in the FE.

Reviewed By: jdoerfert

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

4 years ago[AArch64][GlobalISel] If a G_BUILD_VECTOR operands are all G_CONSTANT then assign...
Amara Emerson [Sat, 26 Sep 2020 00:38:10 +0000 (17:38 -0700)]
[AArch64][GlobalISel] If a G_BUILD_VECTOR operands are all G_CONSTANT then assign to gpr bank.

Even if the type is s8/s16, assigning to gpr is preferable with constants because
worst case we can select via a constant pool load, and without cross-bank copies
to the FPR bank more patterns can be imported later.

4 years ago[LowerTypeTests][NewPM] Add constructor that uses command line flags
Arthur Eubanks [Thu, 17 Sep 2020 17:36:39 +0000 (10:36 -0700)]
[LowerTypeTests][NewPM] Add constructor that uses command line flags

This matches the legacy PM pass by having one constructor use command
line flags, and the other use parameters to the pass.

This fixes all tests under Transforms/LowerTypeTests using NPM.

Reviewed By: ychen, pcc

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

4 years ago[AArch64][GlobalISel] Add a few more vector type combinations for shift selection.
Amara Emerson [Sat, 26 Sep 2020 00:21:03 +0000 (17:21 -0700)]
[AArch64][GlobalISel] Add a few more vector type combinations for shift selection.

4 years ago[lldb/bindings] Fix -Wformat after D88123
Fangrui Song [Sat, 26 Sep 2020 00:33:12 +0000 (17:33 -0700)]
[lldb/bindings] Fix -Wformat after D88123

4 years ago[RISCV] Update driver tests
Evandro Menezes [Fri, 25 Sep 2020 23:07:12 +0000 (18:07 -0500)]
[RISCV] Update driver tests

Add the RISC-V Bullet core to the driver tests.

4 years ago[RISCV] Scheduler description for Bullet
Michael Collison [Fri, 25 Sep 2020 22:59:08 +0000 (17:59 -0500)]
[RISCV] Scheduler description for Bullet

Add the pipeline model for the RISC-V Bullet micro architecture.

Co-authored-by: Evandro Menezes <evandro.menezes@sifive.com>
4 years ago[Object][MachO] Refine the interface of Slice
Alexander Shaposhnikov [Fri, 25 Sep 2020 23:02:23 +0000 (16:02 -0700)]
[Object][MachO] Refine the interface of Slice

This patch performs a minor cleanup of the class Slice:
static methods and constructors which take a pointer but assume that
it's not null now take the argument by reference.
NFC.

Test plan: make check-all

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

4 years ago[IR] Improve the description for Constant::isNormalFP to list all things that are...
Craig Topper [Thu, 24 Sep 2020 22:01:54 +0000 (15:01 -0700)]
[IR] Improve the description for Constant::isNormalFP to list all things that are not normal instead of just denormal. NFC

4 years ago[RISCV] Fix formatting (NFC)
Evandro Menezes [Fri, 25 Sep 2020 20:44:44 +0000 (15:44 -0500)]
[RISCV] Fix formatting (NFC)

4 years ago[LangRef] Clarify the behavior of memory access instructions when pointers/sizes...
Juneyoung Lee [Sun, 20 Sep 2020 22:12:12 +0000 (07:12 +0900)]
[LangRef] Clarify the behavior of memory access instructions when pointers/sizes aren't well-defined

This is a patch to LangRef that clarifies the behavior of load/store/memset/memcpy/memmove when the pointers or sizes are not well-defined
as well.

MSan detects a case when e.g., only lower bits of address are garbage when `-msan-check-access-address` is enabled, and it does not directly conflict with this patch because a C program should not use a pointer with undef bits and reasonable optimizations do not convert a well-defined pointer into a pointer with undef bits.

This patch contains a definition of a well-defined value as well.

Reviewed By: jdoerfert

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

4 years agoC API: functions to get mask of a ShuffleVector
Craig Disselkoen [Fri, 25 Sep 2020 21:34:23 +0000 (14:34 -0700)]
C API: functions to get mask of a ShuffleVector

This commit fixes a regression (from LLVM 10 to LLVM 11 RC3) in the LLVM
C API.

Previously, commit 1ee6ec2bf removed the mask operand from the
ShuffleVector instruction, storing the mask data separately in the
instruction instead; this reduced the number of operands of
ShuffleVector from 3 to 2. AFAICT, this change unintentionally caused
a regression in the LLVM C API. Specifically, it is no longer possible
to get the mask of a ShuffleVector instruction through the C API. This
patch introduces new functions which together allow a C API user to get
the mask of a ShuffleVector instruction, restoring the functionality
which was previously available through LLVMGetOperand().

This patch also adds tests for this change to the llvm-c-test
executable, which involved adding support for InsertElement,
ExtractElement, and ShuffleVector itself (as well as constant vectors)
to echo.cpp. Previously, vector operations weren't tested at all in
echo.ll.

I also fixed some typos in comments and help-text nearby these changes,
which I happened to spot while developing this patch. Since the typo
fixes are technically unrelated other than being in the same files, I'm
happy to take them out if you'd rather they not be included in the patch.

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

4 years ago[TRE][NFC] Refactor Basic Block Processing
Layton Kifer [Fri, 25 Sep 2020 21:33:07 +0000 (14:33 -0700)]
[TRE][NFC] Refactor Basic Block Processing

Simplify and improve readability.

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

4 years ago[AArch64][SVE] Drop "argmemonly" from gather/scatter with vector base.
Eli Friedman [Wed, 23 Sep 2020 22:09:47 +0000 (15:09 -0700)]
[AArch64][SVE] Drop "argmemonly" from gather/scatter with vector base.

The intrinsics don't have any pointer arguments, so "argmemonly" makes
optimizations think they don't write to memory at all.

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

4 years agoAdd the ability to write target stop-hooks using the ScriptInterpreter.
Jim Ingham [Tue, 22 Sep 2020 22:55:18 +0000 (15:55 -0700)]
Add the ability to write target stop-hooks using the ScriptInterpreter.

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

4 years agoSema: add support for `__attribute__((__swift_private__))`
Saleem Abdulrasool [Mon, 14 Sep 2020 23:45:07 +0000 (23:45 +0000)]
Sema: add support for `__attribute__((__swift_private__))`

This attribute allows declarations to be restricted to the framework
itself, enabling Swift to remove the declarations when importing
libraries.  This is useful in the case that the functions can be
implemented in a more natural way for Swift.

This is based on the work of the original changes in
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c

Differential Revision: https://reviews.llvm.org/D87720
Reviewed By: Aaron Ballman

4 years ago[msan] Skip memcpy interceptor called by gethostname
Vitaly Buka [Fri, 25 Sep 2020 22:26:26 +0000 (15:26 -0700)]
[msan] Skip memcpy interceptor called by gethostname

No test as reproducer requires particular glibc build.

Reviewed By: eugenis

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

4 years agoAdd support for firmware/standalone LC_NOTE "main bin spec" corefiles
Jason Molenda [Fri, 25 Sep 2020 21:08:44 +0000 (14:08 -0700)]
Add support for firmware/standalone LC_NOTE "main bin spec" corefiles

When a Mach-O corefile has an LC_NOTE "main bin spec" for a
standalone binary / firmware, with only a UUID and no load
address, try to locate the binary and dSYM by UUID and if
found, load it at offset 0 for the user.

Add a test case that tests a firmware/standalone corefile
with both the "kern ver str" and "main bin spec" LC_NOTEs.

<rdar://problem/68193804>

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

4 years ago[lsan] Add interceptor for pthread_detach.
Marco Vanotti [Fri, 25 Sep 2020 21:17:22 +0000 (14:17 -0700)]
[lsan] Add interceptor for pthread_detach.

This commit adds an interceptor for the pthread_detach function,
calling into ThreadRegistry::DetachThread, allowing for thread contexts
to be reused.

Without this change, programs may fail when they create more than 8K
threads.

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

Reviewed By: vitalybuka

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

4 years agoRevert "[IRSim] Adding basic implementation of llvm-sim."
Andrew Litteken [Fri, 25 Sep 2020 21:18:48 +0000 (16:18 -0500)]
Revert "[IRSim] Adding basic implementation of llvm-sim."

This reverts commit 15645d044bcfe2a0f63156048b302f997a717688.

4 years agoFix copy+paste typo in doxygen parameter name to fix Wdocumentation. NFCI.
Simon Pilgrim [Fri, 25 Sep 2020 21:09:51 +0000 (22:09 +0100)]
Fix copy+paste typo in doxygen parameter name to fix Wdocumentation. NFCI.

4 years ago[InstCombine] matchRotate - support (uniform) constant rotation amounts (PR46895)
Simon Pilgrim [Fri, 25 Sep 2020 21:03:10 +0000 (22:03 +0100)]
[InstCombine] matchRotate - support (uniform) constant rotation amounts (PR46895)

This patch adds handling of rotation patterns with constant shift amounts - the next bit will be how we want to support non-uniform constant vectors.

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

4 years ago[InstCombine] Fix test name to match type. NFCI.
Simon Pilgrim [Fri, 25 Sep 2020 21:00:19 +0000 (22:00 +0100)]
[InstCombine] Fix test name to match type. NFCI.

We're testing a <2 x i36> not <2 x i16>

4 years ago[IRSim] Adding basic implementation of llvm-sim.
Andrew Litteken [Thu, 17 Sep 2020 20:43:40 +0000 (15:43 -0500)]
[IRSim] Adding basic implementation of llvm-sim.

This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs

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

4 years ago[InstCombine] collectBitParts - add fshl/fshr handling
Simon Pilgrim [Fri, 25 Sep 2020 19:34:44 +0000 (20:34 +0100)]
[InstCombine] collectBitParts - add fshl/fshr handling

Pulled from D87452, this is a fixed version of the collectBitParts fshl/fshr handling which as @nikic noticed wasn't checking for different providers or had correct bit ordering (which was hid by only testing shift amounts of bitwidth/2).

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

4 years ago[LoopReroll][NewPM] Port -loop-reroll to NPM
Arthur Eubanks [Sat, 19 Sep 2020 00:25:40 +0000 (17:25 -0700)]
[LoopReroll][NewPM] Port -loop-reroll to NPM

Reviewed By: asbirlea

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

4 years agoAdd a verifier check that rejects non-distinct DISubprogram function
Adrian Prantl [Thu, 24 Sep 2020 23:59:36 +0000 (16:59 -0700)]
Add a verifier check that rejects non-distinct DISubprogram function
attachments. They would crash the backend, which expects all
DISubprograms that are not part of the type system to have a unit field.

Clang right before https://reviews.llvm.org/D79967 would generate this
kind of broken IR.

rdar://problem/69534688

Thanks to Fangrui for fixing an assembler test I had missed!

https://reviews.llvm.org/D88270

4 years ago[lldb] Pass reference instead of pointer in protected SBAddress methods.
Jonas Devlieghere [Fri, 25 Sep 2020 18:15:44 +0000 (11:15 -0700)]
[lldb] Pass reference instead of pointer in protected SBAddress methods.

Every call to the protected SBAddress constructor and the SetAddress
method takes the address of a valid object which means we might as well
pass it as a const reference instead of a pointer and drop the null
check.

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

4 years ago[WebAssembly] Check features before making SjLj vars thread-local
Thomas Lively [Fri, 25 Sep 2020 18:45:16 +0000 (11:45 -0700)]
[WebAssembly] Check features before making SjLj vars thread-local

1c5a3c4d3823 updated the variables inserted by Emscripten SjLj lowering to be
thread-local, depending on the CoalesceFeaturesAndStripAtomics pass to downgrade
them to normal globals if the target features did not support TLS. However, this
had the unintended side effect of preventing all non-TLS-supporting objects from
being linked into modules with shared memory, because stripping TLS marks an
object as thread-unsafe. This patch fixes the problem by only making the SjLj
lowering variables thread-local if the target machine supports TLS so that it
never introduces new usage of TLS that will be stripped. Since SjLj lowering
works on Modules instead of Functions, this required that the
WebAssemblyTargetMachine have its feature string updated to reflect the
coalesced features collected from all the functions so that a
WebAssemblySubtarget can be created without using any particular function.

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

4 years ago[Coroutine] Split PHI Nodes in `cleanuppad` blocks in a way that obeys EH pad rules
Daniel Paoliello [Fri, 25 Sep 2020 18:26:40 +0000 (11:26 -0700)]
[Coroutine] Split PHI Nodes in `cleanuppad` blocks in a way that obeys EH pad rules

Issue Details:
In order to support coroutine splitting, any multi-value PHI node in a coroutine is split into multiple blocks with single-value PHI Nodes, which then allows a subsequent transform to generate `reload` instructions as required (i.e., to reload the value if required if the coroutine has been resumed). This causes issues with EH pads (`catchswitch` and `catchpad`) as all pads within a `catchswitch` must have the same unwind destination, but the coroutine splitting logic may modify them to each have a unique unwind destination if there is a PHI node in the unwind `cleanuppad` that is set from values in the `catchswitch` and `cleanuppad` blocks.

Fix Details:
During splitting, if such a PHI node is detected, then create a "dispatcher" `cleanuppad` as well as the blocks with single-value PHI Nodes: thus the "dispatcher" is the unwind destination and it will detect which predecessor called it and then branch to the appropriate single-value PHI node block, which will then branch back to the original `cleanuppad` block.

Reviewed By: GorNishanov, lxfind

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

4 years ago[lld-macho] Ignore a few more undocumented flags
Jez Ng [Wed, 12 Aug 2020 23:57:55 +0000 (16:57 -0700)]
[lld-macho] Ignore a few more undocumented flags

Reviewed By: #lld-macho, compnerd

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

4 years ago[lld-macho] Always include custom syslibroot when running tests
Jez Ng [Sat, 19 Sep 2020 04:40:12 +0000 (21:40 -0700)]
[lld-macho] Always include custom syslibroot when running tests

This greatly reduces the amount of boilerplate in our tests.

Reviewed By: #lld-macho, compnerd

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

4 years ago[lld-macho] Support absolute symbols
Jez Ng [Fri, 18 Sep 2020 15:40:46 +0000 (08:40 -0700)]
[lld-macho] Support absolute symbols

They operate like Defined symbols but with no associated InputSection.

Note that `ld64` seems to treat the weak definition flag like a no-op for
absolute symbols, so I have replicated that behavior.

Reviewed By: #lld-macho, smeenai

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

4 years ago[lld-macho] Allow the entry symbol to be dynamically bound
Jez Ng [Thu, 17 Sep 2020 17:20:16 +0000 (10:20 -0700)]
[lld-macho] Allow the entry symbol to be dynamically bound

Apparently this is used in real programs. I've handled this by reusing
the logic we already have for branch (function call) relocations.

Reviewed By: #lld-macho, smeenai

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

4 years ago[lld-macho] Support -bundle
Jez Ng [Tue, 1 Sep 2020 06:23:37 +0000 (23:23 -0700)]
[lld-macho] Support -bundle

Not 100% sure but it appears that bundles are almost identical to
dylibs, aside from the fact that they do not contain `LC_ID_DYLIB`. ld64's code
seems to treat bundles and dylibs identically in most places.

Supporting bundles allows us to run e.g. XCTests, as all test suites are
compiled into bundles which get dynamically loaded by the `xctest` test runner.

Reviewed By: #lld-macho, smeenai

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

4 years ago[lld-macho] Implement support for PIC
Jez Ng [Sat, 5 Sep 2020 17:55:33 +0000 (10:55 -0700)]
[lld-macho] Implement support for PIC

* Implement rebase opcodes. Rebase opcodes tell dyld where absolute
  addresses have been encoded in the binary. If the binary is not loaded
  at its preferred address, dyld has to rebase these addresses by adding
  an offset to them.
* Support `-pie` and use it to test rebase opcodes.

This is necessary for absolute address references in dylibs, bundles etc
to work.

Reviewed By: #lld-macho, gkm

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

4 years ago[NFC] Fix comment for DataOp
clementval [Fri, 25 Sep 2020 18:27:23 +0000 (14:27 -0400)]
[NFC] Fix comment for DataOp

4 years ago[flang][OpenMP] Place the insertion point to the start of the block
Sourabh Singh Tomar [Fri, 25 Sep 2020 18:25:43 +0000 (23:55 +0530)]
[flang][OpenMP] Place the insertion point to the start of the block

After skeleton of the `Parallel Op` is created set the insertion point to start of the block. So that later `CodeGen` can proceed.

Note: This patch reflects the work that can be upstreamed from PR(merged)
PR: https://github.com/flang-compiler/f18-llvm-project/pull/424

Reviewed By: schweitz, kiranchandramohan

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

4 years agoOpaquePtr: Add type to sret attribute
Matt Arsenault [Wed, 23 Sep 2020 17:06:59 +0000 (13:06 -0400)]
OpaquePtr: Add type to sret attribute

Make the corresponding change that was made for byval in
b7141207a483d39b99c2b4da4eb3bb591eca9e1a. Like byval, this requires a
bulk update of the test IR tests to include the type before this can
be mandatory.

4 years ago[SCEV] Add support for `x != 0` to CollectCondition.
Florian Hahn [Fri, 25 Sep 2020 09:01:31 +0000 (10:01 +0100)]
[SCEV] Add support for `x != 0` to CollectCondition.

Add support for NE predicates with 0 constants. Those can be translated
to UMaxExpr(x, 1).

4 years ago[SCEV] Add another test using info from loop guards for BTC with NE.
Florian Hahn [Fri, 25 Sep 2020 17:51:12 +0000 (18:51 +0100)]
[SCEV] Add another test using info from loop guards for BTC with NE.

4 years agoMove PassBuilder::registerParseTopLevelPipelineCallback out-of-line
Hans Wennborg [Fri, 25 Sep 2020 17:49:15 +0000 (19:49 +0200)]
Move PassBuilder::registerParseTopLevelPipelineCallback out-of-line

For some mysterious reason it doesn't build with clang-cl when compiled
as part of the includes in clang's CodeGenAction.cpp
(crbug.com/1132292).

4 years agoRevert "Add a verifier check that rejects non-distinct DISubprogram function"
Adrian Prantl [Fri, 25 Sep 2020 17:51:54 +0000 (10:51 -0700)]
Revert "Add a verifier check that rejects non-distinct DISubprogram function"

This reverts commit e17f52d623cc146b7d9bf5a2e02965043508b4c4.

while investigating bot breakage.

4 years agoAArch64/GlobalISel: Narrow stack passed argument access size
Matt Arsenault [Fri, 25 Sep 2020 14:26:36 +0000 (10:26 -0400)]
AArch64/GlobalISel: Narrow stack passed argument access size

This fixes a verifier error in the testcase from bug 47619.

The stack passed s3 value was widened to 4-bytes, and producing a
4-byte memory access with a < 1 byte result type. We need to either
widen the result type or narrow the access size. This copies the code
directly from the AMDGPU handling, which narrows the load size. I
don't like that every target has to handle this, but this is currently
broken on the 11 release branch and this is the simplest fix.

This reverts commit 42bfa7c63b85e76fe16521d1671afcafaf8f64ed.

4 years ago[MLIR] Fix for updating function signature in normalizing memrefs
Haruki Imai [Fri, 25 Sep 2020 17:19:23 +0000 (22:49 +0530)]
[MLIR] Fix for updating function signature in normalizing memrefs

Normalizing memrefs failed when a caller of symbolic use in a function
can not be casted to `CallOp`. This patch avoids the failure by checking
the result of the casting. If the caller can not be casted to `CallOp`,
it is skipped.

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

4 years agoFix Assembler/disubprogram.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4
Fangrui Song [Fri, 25 Sep 2020 17:26:35 +0000 (10:26 -0700)]
Fix Assembler/disubprogram.ll after e17f52d623cc146b7d9bf5a2e02965043508b4c4