platform/upstream/llvm.git
4 years agoRevert "[CUDA][HIP] Fix typo in `BestViableFunction`"
Mitch Phillips [Thu, 19 Sep 2019 21:11:28 +0000 (21:11 +0000)]
Revert "[CUDA][HIP] Fix typo in `BestViableFunction`"

Broke the msan buildbots (see comments on rL372318 for more details).

This reverts commit eb231d15825ac345b546f4c99372d1cac8f14f02.

llvm-svn: 372353

4 years ago[ObjC][ARC] Skip debug instructions when computing the insert point of
Akira Hatanaka [Thu, 19 Sep 2019 20:58:51 +0000 (20:58 +0000)]
[ObjC][ARC] Skip debug instructions when computing the insert point of
objc_release calls

This fixes a bug where the presence of debug instructions would cause
ARC optimizer to change the order of retain and release calls.

rdar://problem/55319419

llvm-svn: 372352

4 years agoDon't false-positive match against binary path.
Mitch Phillips [Thu, 19 Sep 2019 20:44:12 +0000 (20:44 +0000)]
Don't false-positive match against binary path.

copy-rel-abs.s uses llvm-objdump to generate output that's then run
through FileCheck. llvm-objdump prints the file path at the top of the
file, which means that any build path that contains 'zed' will get
false-matched. Ensure that 'zed' is only matched after the 'SYMBOL
TABLE:' output, preventing this from failing if your build directory is
~/build/sanitized-xxx/, or similar.

llvm-svn: 372351

4 years ago[AMDGPU] fixed underflow in getOccupancyWithNumVGPRs
Stanislav Mekhanoshin [Thu, 19 Sep 2019 20:09:04 +0000 (20:09 +0000)]
[AMDGPU] fixed underflow in getOccupancyWithNumVGPRs

The function could return zero if an extreme number or
registers were used. Minimal possible occupancy is 1.

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

llvm-svn: 372350

4 years agollvm-reduce: Follow-up to 372280, now with more-better msan fixing
David Blaikie [Thu, 19 Sep 2019 20:04:04 +0000 (20:04 +0000)]
llvm-reduce: Follow-up to 372280, now with more-better msan fixing

llvm-svn: 372349

4 years ago[lsan] Fix deadlock in dl_iterate_phdr.
Evgeniy Stepanov [Thu, 19 Sep 2019 19:52:57 +0000 (19:52 +0000)]
[lsan] Fix deadlock in dl_iterate_phdr.

Summary:
Do not grab the allocator lock before calling dl_iterate_phdr. This may
cause a lock order inversion with (valid) user code that uses malloc
inside a dl_iterate_phdr callback.

Reviewers: vitalybuka, hctim

Subscribers: jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 372348

4 years agoDon't use invalidated iterators in FlattenCFGPass
Jakub Kuderski [Thu, 19 Sep 2019 19:39:42 +0000 (19:39 +0000)]
Don't use invalidated iterators in FlattenCFGPass

Summary:
FlattenCFG may erase unnecessary blocks, which also invalidates iterators to those erased blocks.
Before this patch, `iterativelyFlattenCFG` could try to increment a BB iterator after that BB has been removed and crash.

This patch makes FlattenCFGPass use `WeakVH` to skip over erased blocks.

Reviewers: dblaikie, tstellar, davide, sanjoy, asbirlea, grosser

Reviewed By: asbirlea

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372347

4 years ago[Analysis] Allow -scalar-evolution-max-iterations more than once
Shoaib Meenai [Thu, 19 Sep 2019 18:21:32 +0000 (18:21 +0000)]
[Analysis] Allow -scalar-evolution-max-iterations more than once

At present, `-scalar-evolution-max-iterations` is a `cl::Optional`
option, which means it demands to be passed exactly zero or one times.
Our build system makes it pretty tricky to guarantee this. We often
accidentally pass the flag more than once (but always with the same
value) which results in an error, after which compilation fails:

```
clang (LLVM option parsing): for the -scalar-evolution-max-iterations option: may only occur zero or one times!
```

It seems reasonable to allow -scalar-evolution-max-iterations to be
passed more than once. Quoting the [[ http://llvm.org/docs/CommandLine.html#controlling-the-number-of-occurrences-required-and-allowed | documentation ]]:

> The cl::ZeroOrMore modifier ... indicates that your program will allow the option to be specified zero or more times.
> ...
> If an option is specified multiple times for an option of the cl::opt class, only the last value will be retained.

Original patch by: Enrico Bern Hardy Tanuwidjaja <etanuwid@fb.com>

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

llvm-svn: 372346

4 years ago[NFC][PowerPC] Fast-isel VSX support test
Jinsong Ji [Thu, 19 Sep 2019 18:18:18 +0000 (18:18 +0000)]
[NFC][PowerPC] Fast-isel VSX support test

We have fixed most of the VSX limitation in Fast-isel,
so we can remove the -mattr=-vsx for most testcases now.

llvm-svn: 372345

4 years agogn build: Merge r372343
GN Sync Bot [Thu, 19 Sep 2019 17:53:03 +0000 (17:53 +0000)]
gn build: Merge r372343

llvm-svn: 372344

4 years ago[SVFS] Vector Function ABI demangling.
Francesco Petrogalli [Thu, 19 Sep 2019 17:47:32 +0000 (17:47 +0000)]
[SVFS] Vector Function ABI demangling.

This patch implements the demangling functionality as described in the
Vector Function ABI. This patch will be used to implement the
SearchVectorFunctionSystem (SVFS) as described in the RFC:

http://lists.llvm.org/pipermail/llvm-dev/2019-June/133484.html

A fuzzer is added to test the demangling utility.

Patch by Sumedh Arani <sumedh.arani@arm.com>

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

llvm-svn: 372343

4 years ago[InstCombine] Simplify @llvm.usub.with.overflow+non-zero check (PR43251)
Roman Lebedev [Thu, 19 Sep 2019 17:25:19 +0000 (17:25 +0000)]
[InstCombine] Simplify @llvm.usub.with.overflow+non-zero check (PR43251)

Summary:
This is again motivated by D67122 sanitizer check enhancement.
That patch seemingly worsens `-fsanitize=pointer-overflow`
overhead from 25% to 50%, which strongly implies missing folds.

In this particular case, given
```
char* test(char& base, unsigned long offset) {
  return &base - offset;
}
```
it will end up producing something like
https://godbolt.org/z/luGEju
which after optimizations reduces down to roughly
```
declare void @use64(i64)
define i1 @test(i8* dereferenceable(1) %base, i64 %offset) {
  %base_int = ptrtoint i8* %base to i64
  %adjusted = sub i64 %base_int, %offset
  call void @use64(i64 %adjusted)
  %not_null = icmp ne i64 %adjusted, 0
  %no_underflow = icmp ule i64 %adjusted, %base_int
  %no_underflow_and_not_null = and i1 %not_null, %no_underflow
  ret i1 %no_underflow_and_not_null
}
```
Without D67122 there was no `%not_null`,
and in this particular case we can "get rid of it", by merging two checks:
Here we are checking: `Base u>= Offset && (Base u- Offset) != 0`, but that is simply `Base u> Offset`

Alive proofs:
https://rise4fun.com/Alive/QOs

The `@llvm.usub.with.overflow` pattern itself is not handled here
because this is the main pattern, that we currently consider canonical.

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

Reviewers: spatel, nikic, xbolva00, majnemer

Reviewed By: xbolva00, majnemer

Subscribers: vsk, majnemer, xbolva00, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372341

4 years ago[AMDGPU] Unnecessary -amdgpu-scalarize-global-loads=false flag removed from min/max...
Alexander Timofeev [Thu, 19 Sep 2019 16:44:38 +0000 (16:44 +0000)]
[AMDGPU] Unnecessary -amdgpu-scalarize-global-loads=false flag removed from min/max lit tests.

Reviewers: arsenm

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

llvm-svn: 372340

4 years ago[Float2Int] avoid crashing on unreachable code (PR38502)
Sanjay Patel [Thu, 19 Sep 2019 16:31:17 +0000 (16:31 +0000)]
[Float2Int] avoid crashing on unreachable code (PR38502)

In the example from:
https://bugs.llvm.org/show_bug.cgi?id=38502
...we hit infinite looping/crashing because we have non-standard IR -
an instruction operand is used before defined.
This and other unusual constructs are allowed in unreachable blocks,
so avoid the problem by using DominatorTree to step around landmines.

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

llvm-svn: 372339

4 years agoReapply r372285 "GlobalISel: Don't materialize immarg arguments to intrinsics"
Matt Arsenault [Thu, 19 Sep 2019 16:26:14 +0000 (16:26 +0000)]
Reapply r372285 "GlobalISel: Don't materialize immarg arguments to intrinsics"

This reverts r372314, reapplying r372285 and the commits which depend
on it (r372286-r372293, and r372296-r372297)

This was missing one switch to getTargetConstant in an untested case.

llvm-svn: 372338

4 years ago[MCA] Improved cost computation for loop carried dependencies in the bottleneck analysis.
Andrea Di Biagio [Thu, 19 Sep 2019 16:05:11 +0000 (16:05 +0000)]
[MCA] Improved cost computation for loop carried dependencies in the bottleneck analysis.

This patch introduces a cut-off threshold for dependency edge frequences with
the goal of simplifying the critical sequence computation.  This patch also
removes the cost normalization for loop carried dependencies.  We didn't really
need to artificially amplify the cost of loop-carried dependencies since it is
already computed as the integral over time of the delay (in cycle).

In the absence of backend stalls there is no need for computing a critical
sequence. With this patch we early exit from the critical sequence computation
if no bottleneck was reported during the simulation.

llvm-svn: 372337

4 years agoMake appendCallNB lambda mutable
Chris Bieneman [Thu, 19 Sep 2019 15:45:12 +0000 (15:45 +0000)]
Make appendCallNB lambda mutable

Lambdas are by deafult const so that they produce the same output every time they are run. This lambda needs to set the value on a captured promise which is a mutating operation, so it must be mutable.

llvm-svn: 372336

4 years agoX86: Add missing test for vshli SimplifyDemandedBitsForTargetNode
Matt Arsenault [Thu, 19 Sep 2019 15:44:00 +0000 (15:44 +0000)]
X86: Add missing test for vshli SimplifyDemandedBitsForTargetNode

This would have caught this regression which triggered the revert of
r372285: https://bugs.chromium.org/p/chromium/issues/detail?id=1005750

llvm-svn: 372335

4 years agoRevert r372325 - Reverting r372323 because it broke color tests on Linux.
Aaron Ballman [Thu, 19 Sep 2019 15:10:51 +0000 (15:10 +0000)]
Revert r372325 - Reverting r372323 because it broke color tests on Linux.

This corrects the testing issues.

llvm-svn: 372334

4 years ago[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)
Simon Pilgrim [Thu, 19 Sep 2019 15:02:47 +0000 (15:02 +0000)]
[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)

This patch converts the DAGCombine isNegatibleForFree/GetNegatedExpression into overridable TLI hooks and includes a demonstration X86 implementation.

The intention is to let us extend existing FNEG combines to work more generally with negatible float ops, allowing it work with target specific combines and opcodes (e.g. X86's FMA variants).

Unlike the SimplifyDemandedBits, we can't just handle target nodes through a Target callback, we need to do this as an override to allow targets to handle generic opcodes as well. This does mean that the target implementations has to duplicate some checks (recursion depth etc.).

I've only begun to replace X86's FNEG handling here, handling FMADDSUB/FMSUBADD negation and some low impact codegen changes (some FMA negatation propagation). We can build on this in future patches.

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

llvm-svn: 372333

4 years ago[DAGCombiner] Add node to the worklist in topological order in scalarizeExtractedVect...
Amaury Sechet [Thu, 19 Sep 2019 14:22:11 +0000 (14:22 +0000)]
[DAGCombiner] Add node to the worklist in topological order in scalarizeExtractedVectorLoad

Summary: As per title.

Reviewers: craig.topper, efriedma, RKSimon, lebedev.ri

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 372327

4 years ago[docs] Break long (>80) line. NFC
Francesco Petrogalli [Thu, 19 Sep 2019 14:19:32 +0000 (14:19 +0000)]
[docs] Break long (>80) line. NFC

llvm-svn: 372326

4 years agoReverting r372323 because it broke color tests on Linux.
Aaron Ballman [Thu, 19 Sep 2019 13:59:53 +0000 (13:59 +0000)]
Reverting r372323 because it broke color tests on Linux.

http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/17919

llvm-svn: 372325

4 years ago[Float2Int] auto-generate complete test checks; NFC
Sanjay Patel [Thu, 19 Sep 2019 13:58:15 +0000 (13:58 +0000)]
[Float2Int] auto-generate complete test checks; NFC

llvm-svn: 372324

4 years agoRemove an unsafe member variable that wasn't needed; NFC.
Aaron Ballman [Thu, 19 Sep 2019 13:51:50 +0000 (13:51 +0000)]
Remove an unsafe member variable that wasn't needed; NFC.

People use the AST dumping interface while debugging, so it's not safe to assume that a declaration will be dumped before a constant expression is dumped. This means the Context member may not get set properly and problems would happen. Rather than rely on the interface that requires the ASTContext, call the generic dump() interface instead; this allows us to remove the Context member variable.

llvm-svn: 372323

4 years ago[OpenCL] Add version handling and add vector ld/st builtins
Sven van Haastregt [Thu, 19 Sep 2019 13:41:51 +0000 (13:41 +0000)]
[OpenCL] Add version handling and add vector ld/st builtins

Allow setting a MinVersion, stating from which OpenCL version a
builtin function is available, and a MaxVersion, stating from which
OpenCL version a builtin function should not be available anymore.

Guard some definitions of the "work-item" builtin functions according
to the OpenCL versions from which they are available.

Add the "vector data load and store" builtin functions (e.g.
vload/vstore), whose signatures differ before and after OpenCL 2.0 in
the pointer argument address spaces.

Patch by Pierre Gondois and Sven van Haastregt.

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

llvm-svn: 372321

4 years ago[TableGen] Support encoding per-HwMode
James Molloy [Thu, 19 Sep 2019 13:39:54 +0000 (13:39 +0000)]
[TableGen] Support encoding per-HwMode

Much like ValueTypeByHwMode/RegInfoByHwMode, this patch allows targets
to modify an instruction's encoding based on HwMode. When the
EncodingInfos field is non-empty the Inst and Size fields of the Instruction
are ignored and taken from EncodingInfos instead.

As part of this promote getHwMode() from TargetSubtargetInfo to MCSubtargetInfo.

This is NFC for all existing targets - new code is generated only if targets
use EncodingByHwMode.

llvm-svn: 372320

4 years agoClean out unused diagnostics. NFC.
Benjamin Kramer [Thu, 19 Sep 2019 13:35:27 +0000 (13:35 +0000)]
Clean out unused diagnostics. NFC.

llvm-svn: 372319

4 years ago[CUDA][HIP] Fix typo in `BestViableFunction`
Michael Liao [Thu, 19 Sep 2019 13:14:03 +0000 (13:14 +0000)]
[CUDA][HIP] Fix typo in `BestViableFunction`

Summary:
- Should consider viable ones only when checking SameSide candidates.
- Replace erasing with clearing viable flag to reduce data
  moving/copying.
- Add one and revise another one as the diagnostic message are more
  relevant compared to previous one.

Reviewers: tra

Subscribers: cfe-commits, yaxunl

Tags: #clang

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

llvm-svn: 372318

4 years ago[clang-tidy] Fix bugprone-argument-comment-check to correctly ignore implicit constru...
Yitzhak Mandelbaum [Thu, 19 Sep 2019 13:12:05 +0000 (13:12 +0000)]
[clang-tidy] Fix bugprone-argument-comment-check to correctly ignore implicit constructors.

Summary:
After revision 370919, this check incorrectly flags certain cases of implicit
constructors. Specifically, if an argument is annotated with an
argument-comment and the argument expression triggers an implicit constructor,
then the argument comment is associated with argument of the implicit
constructor.

However, this only happens when the constructor has more than one argument.
This revision fixes the check for implicit constructors and adds a regression
test for this case.

Note: r370919 didn't cause this bug, it simply uncovered it by fixing another
bug that was masking the behavior.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 372317

4 years ago[DAG] Add SelectionDAG::MaxRecursionDepth constant
Simon Pilgrim [Thu, 19 Sep 2019 12:58:43 +0000 (12:58 +0000)]
[DAG] Add SelectionDAG::MaxRecursionDepth constant

As commented on D67557 we have a lot of uses of depth checks all using magic numbers.

This patch adds the SelectionDAG::MaxRecursionDepth constant and moves over some general cases to use this explicitly.

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

llvm-svn: 372315

4 years agoRevert r372285 "GlobalISel: Don't materialize immarg arguments to intrinsics"
Hans Wennborg [Thu, 19 Sep 2019 12:33:07 +0000 (12:33 +0000)]
Revert r372285 "GlobalISel: Don't materialize immarg arguments to intrinsics"

This broke the Chromium build, causing it to fail with e.g.

  fatal error: error in backend: Cannot select: t362: v4i32 = X86ISD::VSHLI t392, Constant:i8<15>

See llvm-commits thread of r372285 for details.

This also reverts r372286, r372287, r372288, r372289, r372290, r372291,
r372292, r372293, r372296, and r372297, which seemed to depend on the
main commit.

> Encode them directly as an imm argument to G_INTRINSIC*.
>
> Since now intrinsics can now define what parameters are required to be
> immediates, avoid using registers for them. Intrinsics could
> potentially want a constant that isn't a legal register type. Also,
> since G_CONSTANT is subject to CSE and legalization, transforms could
> potentially obscure the value (and create extra work for the
> selector). The register bank of a G_CONSTANT is also meaningful, so
> this could throw off future folding and legalization logic for AMDGPU.
>
> This will be much more convenient to work with than needing to call
> getConstantVRegVal and checking if it may have failed for every
> constant intrinsic parameter. AMDGPU has quite a lot of intrinsics wth
> immarg operands, many of which need inspection during lowering. Having
> to find the value in a register is going to add a lot of boilerplate
> and waste compile time.
>
> SelectionDAG has always provided TargetConstant for constants which
> should not be legalized or materialized in a register. The distinction
> between Constant and TargetConstant was somewhat fuzzy, and there was
> no automatic way to force usage of TargetConstant for certain
> intrinsic parameters. They were both ultimately ConstantSDNode, and it
> was inconsistently used. It was quite easy to mis-select an
> instruction requiring an immediate. For SelectionDAG, start emitting
> TargetConstant for these arguments, and using timm to match them.
>
> Most of the work here is to cleanup target handling of constants. Some
> targets process intrinsics through intermediate custom nodes, which
> need to preserve TargetConstant usage to match the intrinsic
> expectation. Pattern inputs now need to distinguish whether a constant
> is merely compatible with an operand or whether it is mandatory.
>
> The GlobalISelEmitter needs to treat timm as a special case of a leaf
> node, simlar to MachineBasicBlock operands. This should also enable
> handling of patterns for some G_* instructions with immediates, like
> G_FENCE or G_EXTRACT.
>
> This does include a workaround for a crash in GlobalISelEmitter when
> ARM tries to uses "imm" in an output with a "timm" pattern source.

llvm-svn: 372314

4 years ago[ARM] MVE i1 splat
David Green [Thu, 19 Sep 2019 12:17:41 +0000 (12:17 +0000)]
[ARM] MVE i1 splat

We needn't BFI each lane individually into a predicate register when each lane
in the same. A simple sign extend and a vmsr will do.

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

llvm-svn: 372313

4 years ago[cmake] Strip quotes in try_compile_only
Hans Wennborg [Thu, 19 Sep 2019 11:28:32 +0000 (11:28 +0000)]
[cmake] Strip quotes in try_compile_only

After r372209, the compile command can end up including an argument with
quotes in it, e.g.

  -fprofile-instr-use="/foo/bar.profdata"

when invoking the compiler with execute_process, the compiler ends up
getting that argument with quotes and all, and fails to open the file.

This all seems horribly broken, but one way of working around it is to
simply strip the quotes from the string here. If they were there to
protect a path that's got spaces in it, that wasn't going to work
anyway because the string is later split by spaces.

llvm-svn: 372312

4 years agoRevert [llvm-ar] Include a line number when failing to parse an MRI script
Owen Reynolds [Thu, 19 Sep 2019 11:22:59 +0000 (11:22 +0000)]
Revert [llvm-ar] Include a line number when failing to parse an MRI script

Revert r372309 due to buildbot failures

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

llvm-svn: 372311

4 years agoFix -Wdocumentation "@returns in a void function" warning. NFCI.
Simon Pilgrim [Thu, 19 Sep 2019 11:12:04 +0000 (11:12 +0000)]
Fix -Wdocumentation "@returns in a void function" warning. NFCI.

llvm-svn: 372310

4 years ago[llvm-ar] Include a line number when failing to parse an MRI script
Owen Reynolds [Thu, 19 Sep 2019 10:51:43 +0000 (10:51 +0000)]
[llvm-ar] Include a line number when failing to parse an MRI script

Errors that occur when reading an MRI script now include a corresponding
line number.

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

llvm-svn: 372309

4 years agoFix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.
Simon Pilgrim [Thu, 19 Sep 2019 10:47:12 +0000 (10:47 +0000)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.

llvm-svn: 372308

4 years ago[TestCommit] Trivial change to test commit access.
Mark Murray [Thu, 19 Sep 2019 09:24:42 +0000 (09:24 +0000)]
[TestCommit] Trivial change to test commit access.

llvm-svn: 372307

4 years ago[TestCommit] Trivial change to test commit access.
Mark Murray [Thu, 19 Sep 2019 09:02:12 +0000 (09:02 +0000)]
[TestCommit] Trivial change to test commit access.

llvm-svn: 372306

4 years ago[Unroll] Add an option to control complete unrolling
Serguei Katkov [Thu, 19 Sep 2019 06:57:29 +0000 (06:57 +0000)]
[Unroll] Add an option to control complete unrolling

Add an ability to specify the max full unroll count for LoopUnrollPass pass
in pass options.

Reviewers: fhahn, fedor.sergeev
Reviewed By: fedor.sergeev
Subscribers: hiraditya, zzheng, dmgreen, llvm-commits
Differential Revision: https://reviews.llvm.org/D67701

llvm-svn: 372305

4 years ago[X86] Prevent crash in LowerBUILD_VECTORvXi1 for v64i1 vectors on 32-bit targets...
Craig Topper [Thu, 19 Sep 2019 06:50:39 +0000 (06:50 +0000)]
[X86] Prevent crash in LowerBUILD_VECTORvXi1 for v64i1 vectors on 32-bit targets when the vector is a mix of constants and non-constant.

We need to materialize the constants as two 32-bit values that
are casted to v32i1 and then concatenated.

llvm-svn: 372304

4 years ago[ARM] Fix for buildbots
Sam Parker [Thu, 19 Sep 2019 06:50:19 +0000 (06:50 +0000)]
[ARM] Fix for buildbots

I had missed that massive.mir also needed updating.

llvm-svn: 372303

4 years ago[X86] Change a SmallVector& argument to SmallVectorImpl&. NFC
Craig Topper [Thu, 19 Sep 2019 06:27:12 +0000 (06:27 +0000)]
[X86] Change a SmallVector& argument to SmallVectorImpl&. NFC

Avoids repeating the size.

llvm-svn: 372302

4 years ago[X86] Remove unused argument from a helper function. NFC
Craig Topper [Thu, 19 Sep 2019 06:27:07 +0000 (06:27 +0000)]
[X86] Remove unused argument from a helper function. NFC

llvm-svn: 372301

4 years ago[lldb] [Process/gdb-remote] Correct more missing LLDB_INVALID_SIGNAL_NUMBER
Michal Gorny [Thu, 19 Sep 2019 05:49:14 +0000 (05:49 +0000)]
[lldb] [Process/gdb-remote] Correct more missing LLDB_INVALID_SIGNAL_NUMBER

Correct more uses of 0 instead of LLDB_INVALID_SIGNAL_NUMBER.

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

llvm-svn: 372300

4 years ago[Builtins] Delete setjmp_syscall and qsetjmp
Fangrui Song [Thu, 19 Sep 2019 04:41:38 +0000 (04:41 +0000)]
[Builtins] Delete setjmp_syscall and qsetjmp

Similar to the resolution of gcc PR71876.
Nobody uses them or needs the [-Wincomplete-setjmp-declaration]
diagnostic.

llvm-svn: 372299

4 years agoAMDGPU/SILoadStoreOptimizer: Add const to more functions
Tom Stellard [Thu, 19 Sep 2019 04:39:45 +0000 (04:39 +0000)]
AMDGPU/SILoadStoreOptimizer: Add const to more functions

Reviewers: arsenm, pendingchaos, rampitec, nhaehnle, vpykhtin

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372298

4 years agoAMDGPU/GlobalISel: RegBankSelect llvm.amdgcn.ds.swizzle
Matt Arsenault [Thu, 19 Sep 2019 04:11:17 +0000 (04:11 +0000)]
AMDGPU/GlobalISel: RegBankSelect llvm.amdgcn.ds.swizzle

llvm-svn: 372297

4 years agoAMDGPU/GlobalISel: RegBankSelect tbuffer load/store
Matt Arsenault [Thu, 19 Sep 2019 04:11:12 +0000 (04:11 +0000)]
AMDGPU/GlobalISel: RegBankSelect tbuffer load/store

These have the same operand structure as the non-t buffer operations.

llvm-svn: 372296

4 years ago[CLANG][BPF] change __builtin_preserve_access_index() signature
Yonghong Song [Thu, 19 Sep 2019 02:59:43 +0000 (02:59 +0000)]
[CLANG][BPF] change __builtin_preserve_access_index() signature

The clang intrinsic __builtin_preserve_access_index() currently
has signature:
  const void * __builtin_preserve_access_index(const void * ptr)

This may cause compiler warning when:
  - parameter type is "volatile void *" or "const volatile void *", or
  - the assign-to type of the intrinsic does not have "const" qualifier.
Further, this signature does not allow dereference of the
builtin result pointer as it is a "const void *" type, which
adds extra step for the user to do type casting.

Let us change the signature to:
  PointerT __builtin_preserve_access_index(PointerT ptr)
such that the result and argument types are the same.
With this, directly dereferencing the builtin return value
becomes possible.

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

llvm-svn: 372294

4 years agoAMDGPU/GlobalISel: Select llvm.amdgcn.raw.buffer.store.format
Matt Arsenault [Thu, 19 Sep 2019 02:35:08 +0000 (02:35 +0000)]
AMDGPU/GlobalISel: Select llvm.amdgcn.raw.buffer.store.format

This needs special handling due to some subtargets that have a
nonstandard register layout for f16 vectors

Also reject some illegal types on other targets.

llvm-svn: 372293

4 years agoAMDGPU/GlobalISel: Select llvm.amdgcn.raw.buffer.store
Matt Arsenault [Thu, 19 Sep 2019 02:30:27 +0000 (02:30 +0000)]
AMDGPU/GlobalISel: Select llvm.amdgcn.raw.buffer.store

llvm-svn: 372292

4 years agoAMDGPU/GlobalISel: RegBankSelect struct buffer load/store
Matt Arsenault [Thu, 19 Sep 2019 02:26:53 +0000 (02:26 +0000)]
AMDGPU/GlobalISel: RegBankSelect struct buffer load/store

llvm-svn: 372291

4 years agoAMDGPU/GlobalISel: RegBankSelect llvm.amdgcn.raw.buffer.{load|store}
Matt Arsenault [Thu, 19 Sep 2019 02:25:09 +0000 (02:25 +0000)]
AMDGPU/GlobalISel: RegBankSelect llvm.amdgcn.raw.buffer.{load|store}

llvm-svn: 372290

4 years agoAMDGPU/GlobalISel: Attempt to RegBankSelect image intrinsics
Matt Arsenault [Thu, 19 Sep 2019 02:23:06 +0000 (02:23 +0000)]
AMDGPU/GlobalISel: Attempt to RegBankSelect image intrinsics

Images should always have 2 consecutive, mandatory SGPR arguments.

llvm-svn: 372289

4 years agoFix typo
Matt Arsenault [Thu, 19 Sep 2019 02:15:29 +0000 (02:15 +0000)]
Fix typo

llvm-svn: 372288

4 years agoMachineScheduler: Fix assert from not checking subregs
Matt Arsenault [Thu, 19 Sep 2019 02:14:12 +0000 (02:14 +0000)]
MachineScheduler: Fix assert from not checking subregs

The assert would fail if there was a dead def of a subregister if
there was a previous use of a different subregister.

llvm-svn: 372287

4 years agoAMDGPU/GlobalISel: Fix RegBankSelect G_SMULH/G_UMULH pre-gfx9
Matt Arsenault [Thu, 19 Sep 2019 01:42:34 +0000 (01:42 +0000)]
AMDGPU/GlobalISel: Fix RegBankSelect G_SMULH/G_UMULH pre-gfx9

The scalar versions were only introduced in gfx9.

llvm-svn: 372286

4 years agoGlobalISel: Don't materialize immarg arguments to intrinsics
Matt Arsenault [Thu, 19 Sep 2019 01:33:14 +0000 (01:33 +0000)]
GlobalISel: Don't materialize immarg arguments to intrinsics

Encode them directly as an imm argument to G_INTRINSIC*.

Since now intrinsics can now define what parameters are required to be
immediates, avoid using registers for them. Intrinsics could
potentially want a constant that isn't a legal register type. Also,
since G_CONSTANT is subject to CSE and legalization, transforms could
potentially obscure the value (and create extra work for the
selector). The register bank of a G_CONSTANT is also meaningful, so
this could throw off future folding and legalization logic for AMDGPU.

This will be much more convenient to work with than needing to call
getConstantVRegVal and checking if it may have failed for every
constant intrinsic parameter. AMDGPU has quite a lot of intrinsics wth
immarg operands, many of which need inspection during lowering. Having
to find the value in a register is going to add a lot of boilerplate
and waste compile time.

SelectionDAG has always provided TargetConstant for constants which
should not be legalized or materialized in a register. The distinction
between Constant and TargetConstant was somewhat fuzzy, and there was
no automatic way to force usage of TargetConstant for certain
intrinsic parameters. They were both ultimately ConstantSDNode, and it
was inconsistently used. It was quite easy to mis-select an
instruction requiring an immediate. For SelectionDAG, start emitting
TargetConstant for these arguments, and using timm to match them.

Most of the work here is to cleanup target handling of constants. Some
targets process intrinsics through intermediate custom nodes, which
need to preserve TargetConstant usage to match the intrinsic
expectation. Pattern inputs now need to distinguish whether a constant
is merely compatible with an operand or whether it is mandatory.

The GlobalISelEmitter needs to treat timm as a special case of a leaf
node, simlar to MachineBasicBlock operands. This should also enable
handling of patterns for some G_* instructions with immediates, like
G_FENCE or G_EXTRACT.

This does include a workaround for a crash in GlobalISelEmitter when
ARM tries to uses "imm" in an output with a "timm" pattern source.

llvm-svn: 372285

4 years ago[WebAssembly] Sort output data sections to place .bss last
Thomas Lively [Thu, 19 Sep 2019 01:14:59 +0000 (01:14 +0000)]
[WebAssembly] Sort output data sections to place .bss last

Summary:
This was always the intended behavior, but had not been
implemented. This ordering is important for Emscripten when generating
.mem files while compiling to JS, since only zeros at the end of
initialized memory can be dropped.

Fixes https://github.com/emscripten-core/emscripten/issues/8999

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

Tags: #llvm

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

llvm-svn: 372284

4 years agogn build: Merge r372282
GN Sync Bot [Thu, 19 Sep 2019 01:03:39 +0000 (01:03 +0000)]
gn build: Merge r372282

llvm-svn: 372283

4 years agollvm-reduce: Add pass to reduce instructions
David Blaikie [Thu, 19 Sep 2019 00:59:27 +0000 (00:59 +0000)]
llvm-reduce: Add pass to reduce instructions

Patch by Diego Treviño!

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

llvm-svn: 372282

4 years agoInitialize all fields in ABIArgInfo.
Serge Guelton [Thu, 19 Sep 2019 00:54:40 +0000 (00:54 +0000)]
Initialize all fields in ABIArgInfo.

Due to usage of an uninitialized fields, we end up with
a Conditional jump or move depends on uninitialised value

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

Commited on behalf of Martin Liska <mliska@suse.cz>

llvm-svn: 372281

4 years agollvm-reduce: Avoid use-after-free when removing a branch instruction
David Blaikie [Thu, 19 Sep 2019 00:35:32 +0000 (00:35 +0000)]
llvm-reduce: Avoid use-after-free when removing a branch instruction

Found my msan buildbot & pointed out by Nico Weber - thanks Nico!

llvm-svn: 372280

4 years ago[Object] Extend MachOUniversalBinary::getObjectForArch
Alexander Shaposhnikov [Thu, 19 Sep 2019 00:02:12 +0000 (00:02 +0000)]
[Object] Extend MachOUniversalBinary::getObjectForArch

Make the method MachOUniversalBinary::getObjectForArch return MachOUniversalBinary::ObjectForArch
and add helper methods MachOUniversalBinary::getMachOObjectForArch, MachOUniversalBinary::getArchiveForArch
for those who explicitly expect to get a MachOObjectFile or an Archive.

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

Test plan: make check-all

llvm-svn: 372278

4 years ago[utils] Add minimal support for MIR inputs to update_llc_test_checks.py
Roman Tereshin [Wed, 18 Sep 2019 23:44:17 +0000 (23:44 +0000)]
[utils] Add minimal support for MIR inputs to update_llc_test_checks.py

update_{llc,mir}_test_checks.py applicability is determined by the
output (assembly or MIR), not the input, which makes
update_llc_test_checks.py the right tool to generate tests that start at
MIR and stop at the final assembly.

This commit adds the minimal support for this path. Main limitation that
remains:

- MIR has to have LLVM IR section, and the CHECK lines will be inserted
  into the LLVM IR functions that correspond to the MIR functions.

Running
  ../utils/update_llc_test_checks.py --llc-binary ./bin/llc
on a slightly modified  ../test/CodeGen/X86/bad-tls-fold.mir

produces the following diff:

+# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+# RUN: llc %s -o - | FileCheck %s
 --- |
   target triple = "x86_64-unknown-linux-gnu"

@@ -6,17 +7,31 @@
   @i = external thread_local global i32

   define i32 @or() {
+  ; CHECK-LABEL: or:
+  ; CHECK:       # %bb.0: # %entry
+  ; CHECK-NEXT:    movq {{.*}}(%rip), %rax
+  ; CHECK-NEXT:    orq $7, %rax
+  ; CHECK-NEXT:    movq i@{{.*}}(%rip), %rcx
+  ; CHECK-NEXT:    orq %rax, %rcx
+  ; CHECK-NEXT:    movl %fs:(%rcx), %eax
+  ; CHECK-NEXT:    retq
   entry:
     ret i32 undef
   }
-
   define i32 @and() {
+  ; CHECK-LABEL: and:
+  ; CHECK:       # %bb.0: # %entry
+  ; CHECK-NEXT:    movq {{.*}}(%rip), %rax
+  ; CHECK-NEXT:    orq $7, %rax
+  ; CHECK-NEXT:    movq i@{{.*}}(%rip), %rcx
+  ; CHECK-NEXT:    andq %rax, %rcx
+  ; CHECK-NEXT:    movl %fs:(%rcx), %eax
+  ; CHECK-NEXT:    retq
   entry:
     ret i32 undef
   }
 ...

(not applied)

llvm-svn: 372277

4 years ago[utils] Amend update_llc_test_checks.py to non-llc tooling, NFC
Roman Tereshin [Wed, 18 Sep 2019 23:44:16 +0000 (23:44 +0000)]
[utils] Amend update_llc_test_checks.py to non-llc tooling, NFC

Very minor change aiming to make it easier to extend the script
downstream to support non-llc, but llc-like tools. The main objective is
to decrease the probability of merge conflicts.

llvm-svn: 372276

4 years ago[WebAssembly] Restore defaults for stores per memop
Thomas Lively [Wed, 18 Sep 2019 23:18:16 +0000 (23:18 +0000)]
[WebAssembly] Restore defaults for stores per memop

Summary:
Large slowdowns were observed in Rust due to many small, constant
sized copies in conjunction with poorly-optimized memory.copy
implementations. Since memory.copy cannot be expected to be inlined
efficiently by engines at this time, stop using it for the smallest
copies. We continue to lower all memcpy intrinsics to memory.copy,
though.

Reviewers: aheejin, alexcrichton

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

Tags: #llvm

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

llvm-svn: 372275

4 years ago[Docs] Moves topics to new categories
DeForest Richards [Wed, 18 Sep 2019 23:04:31 +0000 (23:04 +0000)]
[Docs] Moves topics to new categories

This commit moves several topics to new categories. It also removes a few duplicate links in Subsystem Documentation.

llvm-svn: 372274

4 years ago[AArch64][GlobalISel] Support lowering musttail calls
Jessica Paquette [Wed, 18 Sep 2019 22:42:25 +0000 (22:42 +0000)]
[AArch64][GlobalISel] Support lowering musttail calls

Since we now lower most tail calls, it makes sense to support musttail.

Instead of always falling back to SelectionDAG, only fall back when a musttail
call was not able to be emitted as a tail call. Once we can handle most
incoming and outgoing arguments, we can change this to a `report_fatal_error`
like in ISelLowering.

Remove the assert that we don't have varargs and a musttail, and replace it
with a return false. Implementing this requires that we implement
`saveVarArgRegisters` from AArch64ISelLowering, which is an entirely different
patch.

Add GlobalISel lines to vararg-tallcall.ll to make sure that we produce correct
code. Right now we only fall back, but eventually this will be relevant.

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

llvm-svn: 372273

4 years agoRemove the obsolete BlockByRefStruct flag from LLVM IR
Adrian Prantl [Wed, 18 Sep 2019 22:38:56 +0000 (22:38 +0000)]
Remove the obsolete BlockByRefStruct flag from LLVM IR

DIFlagBlockByRefStruct is an unused DIFlag that originally was used by
clang to express (Objective-)C block captures in debug info. For the
last year Clang has been emitting complex DIExpressions to describe
block captures instead, which makes all the code supporting this flag
redundant.

This patch removes the flag and all supporting "dead" code, so we can
reuse the bit for something else in the future.

Since this only affects debug info generated by Clang with the block
extension this mostly affects Apple platforms and I don't have any
bitcode compatibility concerns for removing this. The Verifier will
reject debug info that uses the bit and thus degrade gracefully when
LTO'ing older bitcode with a newer compiler.

rdar://problem/44304813

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

llvm-svn: 372272

4 years agollvm-reduce: Remove inaccurate doxy comment about a return that isn't returned
David Blaikie [Wed, 18 Sep 2019 22:38:05 +0000 (22:38 +0000)]
llvm-reduce: Remove inaccurate doxy comment about a return that isn't returned

Addressing post-commit code review feedback from Dávid Bolvanský -
thanks!

llvm-svn: 372271

4 years agollvm-reduce: Fix inconsistencies between int/unsigned usage (standardize on int)
David Blaikie [Wed, 18 Sep 2019 22:30:25 +0000 (22:30 +0000)]
llvm-reduce: Fix inconsistencies between int/unsigned usage (standardize on int)

llvm-svn: 372270

4 years ago[analyzer] PR43102: Fix an assertion and an out-of-bounds error for diagnostic locati...
Kristof Umann [Wed, 18 Sep 2019 22:24:26 +0000 (22:24 +0000)]
[analyzer] PR43102: Fix an assertion and an out-of-bounds error for diagnostic location construction

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

In today's edition of "Is this any better now that it isn't crashing?", I'd like to show you a very interesting test case with loop widening.

Looking at the included test case, it's immediately obvious that this is not only a false positive, but also a very bad bug report in general. We can see how the analyzer mistakenly invalidated `b`, instead of its pointee, resulting in it reporting a null pointer dereference error. Not only that, the point at which this change of value is noted at is at the loop, rather then at the method call.

It turns out that `FindLastStoreVisitor` works correctly, rather the supplied explodedgraph is faulty, because `BlockEdge` really is the `ProgramPoint` where this happens.
{F9855739}
So it's fair to say that this needs improving on multiple fronts. In any case, at least the crash is gone.

Full ExplodedGraph: {F9855743}

Reviewers: NoQ, xazax.hun, baloghadamsoftware, Charusso, dcoughlin, rnkovacs, TWeaver

Subscribers: JesperAntonsson, uabelho, Ka-Ka, bjope, whisperity, szepet, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 372269

4 years agogn build: Merge r372267
GN Sync Bot [Wed, 18 Sep 2019 22:21:52 +0000 (22:21 +0000)]
gn build: Merge r372267

llvm-svn: 372268

4 years agoAdd AutoUpgrade function to add new address space datalayout string to existing datal...
Amy Huang [Wed, 18 Sep 2019 22:15:58 +0000 (22:15 +0000)]
Add AutoUpgrade function to add new address space datalayout string to existing datalayouts.

Summary:
Add function to AutoUpgrade to change the datalayout of old X86 datalayout strings.
This adds "-p270:32:32-p271:32:32-p272:64:64" to X86 datalayouts that are otherwise valid
and don't already contain it.

This also removes the compatibility changes in https://reviews.llvm.org/D66843.
Datalayout change in https://reviews.llvm.org/D64931.

Reviewers: rnk, echristo

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372267

4 years ago[lld][WebAssembly] Fix use after free of archive path
Sam Clegg [Wed, 18 Sep 2019 21:51:03 +0000 (21:51 +0000)]
[lld][WebAssembly] Fix use after free of archive path

This was fixed in the ELF backend in https://reviews.llvm.org/D34554.

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

llvm-svn: 372266

4 years agogn build: Merge r372264
GN Sync Bot [Wed, 18 Sep 2019 21:49:36 +0000 (21:49 +0000)]
gn build: Merge r372264

llvm-svn: 372265

4 years agollvm-reduce: Add pass to reduce basic blocks
David Blaikie [Wed, 18 Sep 2019 21:45:05 +0000 (21:45 +0000)]
llvm-reduce: Add pass to reduce basic blocks

Patch by Diego Treviño!

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

llvm-svn: 372264

4 years agofix build, adjust test also for Windows path separator
Lubos Lunak [Wed, 18 Sep 2019 21:41:45 +0000 (21:41 +0000)]
fix build, adjust test also for Windows path separator

Introduced in 1e9c1d2b7bfc.

llvm-svn: 372263

4 years ago[SimplifyCFG] mergeConditionalStoreToAddress(): try to pacify MSAN
Roman Lebedev [Wed, 18 Sep 2019 21:04:39 +0000 (21:04 +0000)]
[SimplifyCFG] mergeConditionalStoreToAddress(): try to pacify MSAN

MSAN bot complains that there is use-of-uninitialized-value
of this FreeStores later in IsWorthwhile().
Perhaps FreeStores needs to be stored in a vector?

llvm-svn: 372262

4 years agoOn PowerPC, Secure-PLT by default for FreeBSD 13 and higher
Dimitry Andric [Wed, 18 Sep 2019 20:58:03 +0000 (20:58 +0000)]
On PowerPC, Secure-PLT by default for FreeBSD 13 and higher

Summary:
In https://svnweb.freebsd.org/changeset/base/349351, FreeBSD 13 and
higher transitioned to Secure-PLT for PowerPC.  This part contains the
changes in clang's PPC architecture defaults.

Reviewers: emaste, jhibbits, hfinkel

Reviewed By: jhibbits

Subscribers: wuzish, nemanjai, krytarowski, kbarton, MaskRay, jsji, shchenz, steven.zhang, cfe-commits

Tags: #clang

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

llvm-svn: 372261

4 years agoOn PowerPC, Secure-PLT by default for FreeBSD 13 and higher
Dimitry Andric [Wed, 18 Sep 2019 20:57:45 +0000 (20:57 +0000)]
On PowerPC, Secure-PLT by default for FreeBSD 13 and higher

Summary:
In https://svnweb.freebsd.org/changeset/base/349351, FreeBSD 13 and
higher transitioned to Secure-PLT for PowerPC.  This part contains the
changes in llvm's PPC subtarget.

Reviewers: emaste, jhibbits, hfinkel

Reviewed By: jhibbits

Subscribers: wuzish, nemanjai, krytarowski, kbarton, MaskRay, jsji, shchenz, steven.zhang, llvm-commits

Tags: #llvm

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

llvm-svn: 372260

4 years ago[DAGCombine][ARM][X86] (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold
Roman Lebedev [Wed, 18 Sep 2019 20:48:27 +0000 (20:48 +0000)]
[DAGCombine][ARM][X86] (sub Carry, X)  ->  (addcarry (sub 0, X), 0, Carry)  fold

Summary:
`DAGCombiner::visitADDLikeCommutative()` already has a sibling fold:
`(add X, Carry) -> (addcarry X, 0, Carry)`

This fold, as suggested by @efriedma, helps recover from //some//
of the regressions of D62266

Reviewers: efriedma, deadalnix

Subscribers: javed.absar, kristof.beyls, llvm-commits, efriedma

Tags: #llvm

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

llvm-svn: 372259

4 years ago[CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold...
Roman Lebedev [Wed, 18 Sep 2019 20:48:05 +0000 (20:48 +0000)]
[CodeGen][X86][NFC] Tests for (sub Carry, X) -> (addcarry (sub 0, X), 0, Carry) fold (D62392)

llvm-svn: 372258

4 years ago[InstCombine] foldUnsignedUnderflowCheck(): handle last few cases (PR43251)
Roman Lebedev [Wed, 18 Sep 2019 20:10:07 +0000 (20:10 +0000)]
[InstCombine] foldUnsignedUnderflowCheck(): handle last few cases (PR43251)

Summary:
I don't have a direct motivational case for this,
but it would be good to have this for completeness/symmetry.

This pattern is basically the motivational pattern from
https://bugs.llvm.org/show_bug.cgi?id=43251
but with different predicate that requires that the offset is non-zero.

The completeness bit comes from the fact that a similar pattern (offset != zero)
will be needed for https://bugs.llvm.org/show_bug.cgi?id=43259,
so it'd seem to be good to not overlook very similar patterns..

Proofs: https://rise4fun.com/Alive/21b

Also, there is something odd with `isKnownNonZero()`, if the non-zero
knowledge was specified as an assumption, it didn't pick it up (PR43267)

With this, i see no other missing folds for
https://bugs.llvm.org/show_bug.cgi?id=43251

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372257

4 years ago[AArch64] Don't implicitly enable global isel on Darwin if code-model==large.
Lang Hames [Wed, 18 Sep 2019 19:56:55 +0000 (19:56 +0000)]
[AArch64] Don't implicitly enable global isel on Darwin if code-model==large.

Summary:
AArch64 GlobalISel doesn't support MachO's large code model, so this patch
adds a check for that combination before implicitly enabling it.

Reviewers: paquette

Subscribers: kristof.beyls, ributzka, llvm-commits

Tags: #llvm

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

llvm-svn: 372256

4 years ago[SimplifyCFG] mergeConditionalStoreToAddress(): consider cost, not instruction count
Roman Lebedev [Wed, 18 Sep 2019 19:46:57 +0000 (19:46 +0000)]
[SimplifyCFG] mergeConditionalStoreToAddress(): consider cost, not instruction count

Summary:
As it can be see in the changed test, while `div` is really costly,
we were speculating it. This does not seem correct.

Also, the old code would run for every single insturuction in BB,
instead of eagerly bailing out as soon as there are too many instructions.

This function still has a problem that `PHINodeFoldingThreshold` is
per-basic-block, while it should be for all the basic blocks.

Reviewers: efriedma, craig.topper, dmgreen, jmolloy

Reviewed By: jmolloy

Subscribers: xbolva00, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372255

4 years ago[MIPS] For vectors, select `add %x, C` as `sub %x, -C` if it results in inline immediate
Roman Lebedev [Wed, 18 Sep 2019 19:34:41 +0000 (19:34 +0000)]
[MIPS] For vectors, select `add %x, C` as `sub %x, -C` if it results in inline immediate

Summary:
As discussed in https://reviews.llvm.org/D62341#1515637,
for MIPS `add %x, -1` isn't optimal. Unlike X86 there
are no fastpaths to matearialize such `-1`/`1` vector constants,
and `sub %x, 1` results in better codegen,
so undo canonicalization

Reviewers: atanasyan, Petar.Avramovic, RKSimon

Reviewed By: atanasyan

Subscribers: sdardis, arichardson, hiraditya, jrtc27, llvm-commits

Tags: #llvm

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

llvm-svn: 372254

4 years ago[CodeGen][MIPS][NFC] Some standalone tests for D66805 "or vectors, select `add %x...
Roman Lebedev [Wed, 18 Sep 2019 19:34:24 +0000 (19:34 +0000)]
[CodeGen][MIPS][NFC] Some standalone tests for D66805 "or vectors, select `add %x, C` as `sub %x, -C` if it results in inline immediate"

llvm-svn: 372253

4 years ago[OPENMP]Fix for PR43349: Crash for privatized loop bound.
Alexey Bataev [Wed, 18 Sep 2019 19:24:07 +0000 (19:24 +0000)]
[OPENMP]Fix for PR43349: Crash for privatized loop bound.

If the variable, used in the loop boundaries, is not captured in the
construct, this variable must be considered as undefined if it was
privatized.

llvm-svn: 372252

4 years ago[mips] Expand 'lw/sw' instructions for 32-bit GOT
Simon Atanasyan [Wed, 18 Sep 2019 19:19:47 +0000 (19:19 +0000)]
[mips] Expand 'lw/sw' instructions for 32-bit GOT

In case of using 32-bit GOT access to the table requires two instructions
with attached %got_hi and %got_lo relocations. This patch implements
correct expansion of 'lw/sw' instructions in that case.

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

llvm-svn: 372251

4 years agoactually also compile output in tests for -frewrite-includes
Lubos Lunak [Wed, 18 Sep 2019 19:12:14 +0000 (19:12 +0000)]
actually also compile output in tests for -frewrite-includes

Checking that the created output matches something is nice, but
this should also check whether the output makes sense.

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

llvm-svn: 372250

4 years ago[clang-format][PR41899] PointerAlignment: Left leads to useless space in lambda intia...
Paul Hoad [Wed, 18 Sep 2019 19:11:40 +0000 (19:11 +0000)]
[clang-format][PR41899] PointerAlignment: Left leads to useless space in lambda intializer expression

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

```auto lambda = [&a = a]() { a = 2; };```

is formatted as

```auto lambda = [& a = a]() { a = 2; };```

With an extra space if PointerAlignment is set to Left

> The space "& a" looks strange when there is no type in the lambda's intializer expression. This can be worked around with by setting "PointerAlignment: Right", but ideally "PointerAlignment: Left" would not add a space in this case.

Reviewers: klimek, owenpan, krasimir, timwoj

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 372249

4 years agomake -frewrite-includes also rewrite conditions in #if/#elif
Lubos Lunak [Wed, 18 Sep 2019 19:09:41 +0000 (19:09 +0000)]
make -frewrite-includes also rewrite conditions in #if/#elif

Those conditions may use __has_include, which needs to be rewritten.
The existing code has already tried to rewrite just __has_include,
but it didn't work with macro expansion, so e.g. Qt's
"#define QT_HAS_INCLUDE(x) __has_include(x)" didn't get handled
properly. Since the preprocessor run knows what each condition evaluates
to, just rewrite the entire condition. This of course requires that
the -frewrite-include pass has the same setup as the following
compilation, but that has always been the requirement.

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

llvm-svn: 372248

4 years ago[Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd
Erik Pilkington [Wed, 18 Sep 2019 19:05:14 +0000 (19:05 +0000)]
[Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd

Also, add a diagnostic under -Wformat for printing a boolean value as a
character.

rdar://54579473

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

llvm-svn: 372247

4 years ago[clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line...
Paul Hoad [Wed, 18 Sep 2019 18:57:09 +0000 (18:57 +0000)]
[clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab

Summary:
clang-format 8.0 crashes with SIGFPE (floating point exception) when formatting following file:
app.cpp:
void a() {
//line starts with '\t'
}

$ clang-format -style='{TabWidth: 0}' app.cpp

Reviewers: owenpan, klimek, russellmcc, timwoj

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 372246

4 years ago[InstCombine] dropRedundantMaskingOfLeftShiftInput(): some cleanup before upcoming...
Roman Lebedev [Wed, 18 Sep 2019 18:38:40 +0000 (18:38 +0000)]
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): some cleanup before upcoming patch

llvm-svn: 372245

4 years ago[NFC][InstCombine] More tests for PR42563 "Dropping pointless masking before left...
Roman Lebedev [Wed, 18 Sep 2019 18:38:32 +0000 (18:38 +0000)]
[NFC][InstCombine] More tests for PR42563 "Dropping pointless masking before left shift"

For patterns c/d/e we too can deal with the pattern even if we can't
just drop the mask, we can just apply it afterwars:
   https://rise4fun.com/Alive/gslRa

llvm-svn: 372244