platform/upstream/llvm.git
3 years ago[analyzer][solver] Use all sources of constraints
Valeriy Savchenko [Thu, 1 Jul 2021 09:51:52 +0000 (12:51 +0300)]
[analyzer][solver] Use all sources of constraints

Prior to this patch, we always gave priority to constraints that we
actually know about symbols in question.  However, these can get
outdated and we can get better results if we look at all possible
sources of knowledge, including sub-expressions.

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

3 years ago[lld/mac] Implement -arch_multiple
Nico Weber [Tue, 6 Jul 2021 00:52:09 +0000 (20:52 -0400)]
[lld/mac] Implement -arch_multiple

This is the other flag clang passes when calling clang with two -arch
flags (which means with this, `clang -arch x86_64 -arch arm64 -fuse-ld=lld ...`
now no longer prints any warnings \o/). Since clang calls the linker several
times in that setup, it's not clear to the user from which invocation the
errors are. The flag's help text is

    Specifies that the linker should augment error and warning messages
    with the architecture name.

In ld64, the only effect of the flag is that undefined symbols are prefaced
with

    Undefined symbols for architecture x86_64:

instead of the usual "Undefined symbols:". So for now, let's add this
only to undefined symbol errors too. That's probably the most common
linker diagnostic.

Another idea would be to prefix errors and warnings with "ld64.lld(x86_64):"
instead of the usual "ld64.lld:", but I'm not sure if people would
misunderstand that as a comment about the arch of ld itself.
But open to suggestions on what effect this flag should have :) And we
don't have to get it perfect now, we can iterate on it.

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

3 years ago[PowerPC] Removed a test case meant for a later patch
Albion Fung [Tue, 6 Jul 2021 03:20:14 +0000 (22:20 -0500)]
[PowerPC] Removed a test case meant for a later patch

A test case meant for a later patch was accidentally
included.

Original Patch: https://reviews.llvm.org/D105236

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

3 years ago[PowerPC] Implament Load and Reserve and Store Conditional Builtins
Albion Fung [Tue, 6 Jul 2021 02:34:37 +0000 (21:34 -0500)]
[PowerPC] Implament Load and Reserve and Store Conditional Builtins

This patch implaments the load and reserve and store conditional
builtins for the PowerPC target, in order to have feature parody with
xlC on AIX.

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

3 years ago[clang] fixes named return of variables with dependent alignment
Matheus Izvekov [Fri, 2 Jul 2021 22:56:16 +0000 (00:56 +0200)]
[clang] fixes named return of variables with dependent alignment

Named return of a variable with aligned attribute would
trip an assert in case alignment was dependent.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

3 years ago[lld/mac] Implement -final_output
Nico Weber [Mon, 5 Jul 2021 23:46:09 +0000 (19:46 -0400)]
[lld/mac] Implement -final_output

This is one of two flags clang passes to the linker when giving calling
clang with multiple -arch flags.

I think it'd make sense to also use finalOutput instead of outputFile
in CodeSignatureSection() and when replacing @executable_path, but
ld64 doesn't do that, so I'll at least put those in separate commits.

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

3 years ago[lld/mac] Implement -umbrella
Nico Weber [Mon, 5 Jul 2021 18:40:52 +0000 (14:40 -0400)]
[lld/mac] Implement -umbrella

I think this is an old way for doing what is done with
-reexport_library these days, but it's e.g. still used in libunwind's
build (the opensource.apple.com one, not the llvm one).

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

3 years ago[lld-macho] Only emit one BIND_OPCODE_SET_SYMBOL per symbol
Jez Ng [Tue, 6 Jul 2021 00:00:09 +0000 (20:00 -0400)]
[lld-macho] Only emit one BIND_OPCODE_SET_SYMBOL per symbol

Size-wise, BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM is the most
expensive opcode, since it comes with an associated symbol string. We
were previously emitting it once per binding, instead of once per
symbol. This diff groups all bindings for a given symbol together and
ensures we only emit one such opcode per symbol. This matches ld64's
behavior.

While this is a relatively small win on chromium_framework (-72KiB), for
programs that have more dynamic bindings, the difference can be quite
large.

This change is perf-neutral when linking chromium_framework.

Reviewed By: #lld-macho, thakis

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

3 years ago[clang] unbreak Index/preamble-reparse-changed-module.m with LLVM_APPEND_VC_REV=NO...
Steven Wan [Mon, 5 Jul 2021 23:51:00 +0000 (19:51 -0400)]
[clang] unbreak Index/preamble-reparse-changed-module.m with LLVM_APPEND_VC_REV=NO after 9964b0e

See revision b8b7a9d for prior art.

3 years ago[compiler-rt][iwyu] explicitly includes `<new>` in xray_utils.cpp
Christopher Di Bella [Sun, 4 Jul 2021 02:20:10 +0000 (02:20 +0000)]
[compiler-rt][iwyu] explicitly includes `<new>` in xray_utils.cpp

Compiling compiler-rt with Clang modules and libc++ revealed that the
global `operator new` is being called without including `<new>`.

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

3 years ago[clang] Add -fdump-record-layouts-canonical option
David Tenty [Mon, 5 Jul 2021 21:35:23 +0000 (17:35 -0400)]
[clang] Add -fdump-record-layouts-canonical option

This option implies -fdump-record-layouts but dumps record layout information with canonical field types, which can be more useful in certain cases when comparing structure layouts.

Reviewed By: stevewan

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

3 years ago[Bazel] Fix build for 98f078324fc51da460660920f4a1aa308bfc3547
Benjamin Kramer [Mon, 5 Jul 2021 20:39:42 +0000 (22:39 +0200)]
[Bazel] Fix build for 98f078324fc51da460660920f4a1aa308bfc3547

3 years ago[Bazel] Fix build for 35d4593e6b555f852088211f5561c0e360c98c91
Benjamin Kramer [Mon, 5 Jul 2021 20:39:10 +0000 (22:39 +0200)]
[Bazel] Fix build for 35d4593e6b555f852088211f5561c0e360c98c91

3 years ago[AIX] Add _AIX73 version macro
Jake Egan [Mon, 5 Jul 2021 20:27:23 +0000 (16:27 -0400)]
[AIX] Add _AIX73 version macro

This patch defines _AIX73 version macro for AIX 7.3.

It extends the following patch https://reviews.llvm.org/D61530.

Reviewed By: xgupta

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

3 years ago[ARM] Fix arm.mve.pred.v2i range upper limit
David Green [Mon, 5 Jul 2021 20:06:30 +0000 (21:06 +0100)]
[ARM] Fix arm.mve.pred.v2i range upper limit

The range metadata specifies a half open range, so our top limit was one
off.

3 years ago[profile][test] Improve coverage-linkage.cpp
Fangrui Song [Mon, 5 Jul 2021 19:46:06 +0000 (12:46 -0700)]
[profile][test] Improve coverage-linkage.cpp

3 years ago[ObjC][ARC] Prevent moving objc_retain calls past objc_release calls
Akira Hatanaka [Mon, 5 Jul 2021 19:16:15 +0000 (12:16 -0700)]
[ObjC][ARC] Prevent moving objc_retain calls past objc_release calls
that release the retained object

This patch fixes what looks like a longstanding bug in ARC optimizer
where it reverses the order of objc_retain calls and objc_release calls
that retain and release the same object.

The code in ARC optimizer that is responsible for code motion takes the
following steps:

1. Traverse the CFG bottom-up and determine how far up objc_release
   calls can be moved. Determine the insertion points for the
   objc_release calls, but don't actually move them.
2. Traverse the CFG top-down and determine how far down objc_retain
   calls can be moved. Determine the insertion points for the
   objc_retain calls, but don't actually move them.
3. Try to move the objc_retain and objc_release calls if they can't be
   removed.

The problem is that the insertion points for the objc_retain calls are
determined in step 2 without taking into consideration the insertion
points for objc_release calls determined in step 1, so the order of an
objc_retain call and an objc_release call can be reversed, which is
incorrect, even though each step is correct in isolation.

To fix this bug, this patch teaches the top-down traversal step to take
into consideration the insertion points for objc_release calls
determined in the bottom-up traversal step. Code motion for an
objc_retain call is disabled if there is a possibility that it can be
moved past an objc_release call that releases the retained object.

rdar://79292791

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

3 years ago[libc++] NFC: Sort header lists in test scripts
Louis Dionne [Mon, 5 Jul 2021 18:58:26 +0000 (14:58 -0400)]
[libc++] NFC: Sort header lists in test scripts

3 years ago[gn build] (manually) port 98f078324fc5 (llvm-strings Opts.td)
Nico Weber [Mon, 5 Jul 2021 18:43:05 +0000 (14:43 -0400)]
[gn build] (manually) port 98f078324fc5 (llvm-strings Opts.td)

3 years ago[M68k][GloballSel] Lower outgoing return values in IRTranslator
Sushma Unnibhavi [Mon, 5 Jul 2021 18:39:09 +0000 (11:39 -0700)]
[M68k][GloballSel] Lower outgoing return values in IRTranslator

Implementation of lowerReturn in the IRTranslator for the M68k backend.

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

3 years ago[llvm-strings] Switch command line parsing from llvm::cl to OptTable
Fangrui Song [Mon, 5 Jul 2021 17:46:17 +0000 (10:46 -0700)]
[llvm-strings] Switch command line parsing from llvm::cl to OptTable

Some behavior changes:

* `-t=d` is removed. Use `-t d` instead.
* one-dash long options like `-all` are supported. Use `--all` instead.
* `--all=0` or `--all=false` cannot be used. (Note: `--all` is silently ignored anyway)
* `--help-list` is removed. This is a `cl::` specific option.

Nobody is likely leveraging any of the above.

Advantages:

* `-t` diagnostic gets improved.
* in the absence of `HideUnrelatedOptions`, `--help` will not list unrelated options if linking against libLLVM-13git.so or linker GC is not used.
* Decrease the probability of cl::opt collision if we do decide to support multiplexing

Note: because the tool is so simple, used more for forensics instead of a building
tool, and its long options are unlikely used in one-dash form, I just drop the
one-dash form in this patch.

Reviewed By: jhenderson

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

3 years ago[MLIR] Fix memref get constant bound size and shape method
Uday Bondhugula [Mon, 28 Jun 2021 19:39:51 +0000 (01:09 +0530)]
[MLIR] Fix memref get constant bound size and shape method

Fix FlatAffineConstraints::getConstantBoundOnDimSize to ensure that
returned bounds on dim size are always non-negative regardless of the
constraints on that dimension. Add an assertion at the user.

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

3 years agoPrecommit another test for https://reviews.llvm.org/D104953
Akira Hatanaka [Mon, 5 Jul 2021 17:12:16 +0000 (10:12 -0700)]
Precommit another test for https://reviews.llvm.org/D104953

3 years ago[AArch64ISelDAGToDAG] Fix ORRWrs/ORRXrs usefulbits calculation bug
Tiehu Zhang [Mon, 5 Jul 2021 16:12:37 +0000 (00:12 +0800)]
[AArch64ISelDAGToDAG] Fix ORRWrs/ORRXrs usefulbits calculation bug

For the following case:

    t8: i32 = or t7, t4
    t10: i32 = ORRWrs t8, t8, TargetConstant:i32<73>

Current code wrongly returns (t8 >> shiftConstant) as the
UsefulBits of t8, which in fact is (t8 | (t8 >> shiftConstant)).

Reviewed by: sdesmalen, mdchen

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

3 years agoFix typo in help text for -aarch64-enable-branch-targets.
Paul Walker [Mon, 5 Jul 2021 15:02:25 +0000 (16:02 +0100)]
Fix typo in help text for -aarch64-enable-branch-targets.

3 years ago[mlir] Unbreak building mlir-reduce
Marius Brehler [Mon, 5 Jul 2021 15:01:12 +0000 (15:01 +0000)]
[mlir] Unbreak building mlir-reduce

Unbreaks building mlir-reduce when `DLLVM_INCLUDE_TESTS` is set to OFF.
The dependency MLIRTestDialect is only available if building with tests.

Reviewed By: ftynse

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

3 years ago[MCParser][z/OS] Mark a few tests as unsupported for the z/OS Target
Anirudh Prasad [Mon, 5 Jul 2021 15:06:38 +0000 (11:06 -0400)]
[MCParser][z/OS] Mark a few tests as unsupported for the z/OS Target

- Background here is that that these sets of tests are "invalid" to be run on z/OS
- The reason is because these test constructs that HLASM never supports (HLASM doesn't support GNU style directives)
- Usually tests are geared towards a particular target via the use of a triple that targets just that platform, but these tests require the use of a "default triple"
- Thus, we mark these tests as "UNSUPPORTED" for z/OS since we don't want to run these for z/OS

Reviewed By: yusra.syeda, abhina.sreeskantharajan

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

3 years ago[LV] Extend FIXME in test add in 91ee1e379901af3.
Florian Hahn [Mon, 5 Jul 2021 14:56:03 +0000 (15:56 +0100)]
[LV] Extend FIXME in test add in 91ee1e379901af3.

3 years ago[LV] Add initial test cases with small clamped indices.
Florian Hahn [Thu, 1 Jul 2021 16:39:31 +0000 (17:39 +0100)]
[LV] Add initial test cases with small clamped indices.

3 years ago[mlir] Change custom syntax of emitc.include op to resemble C
Simon Camphausen [Mon, 5 Jul 2021 14:39:28 +0000 (16:39 +0200)]
[mlir] Change custom syntax of emitc.include op to resemble C

This changes the custom syntax of the emitc.include operation for standard includes.

Reviewed By: marbre

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

3 years ago[libc++] NFC: Add note about how the libcxx website gets updated
Louis Dionne [Mon, 5 Jul 2021 14:25:26 +0000 (10:25 -0400)]
[libc++] NFC: Add note about how the libcxx website gets updated

3 years ago[InstCombine] fold icmp slt/sgt of offset value with constant
Sanjay Patel [Mon, 5 Jul 2021 13:57:39 +0000 (09:57 -0400)]
[InstCombine] fold icmp slt/sgt of offset value with constant

This follows up patches for the unsigned siblings:
0c400e895306
c7b658aeb526

We are translating an offset signed compare to its
unsigned equivalent when one end of the range is
at the limit (zero or unsigned max).

(X + C2) >s C --> X <u (SMAX - C) (if C == C2 - 1)
(X + C2) <s C --> X >u (C ^ SMAX) (if C == C2)

This probably does not show up much in IR derived
from C/C++ source because that would likely have
'nsw', and we have folds for that already.

As with the previous unsigned transforms, the folds
could be generalized to handle non-constant patterns:

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

  ; sgt
  define i1 @src(i8 %a, i8 %c) {
    %c2 = add i8 %c, 1
    %t = add i8 %a, %c2
    %ov = icmp sgt i8 %t, %c
    ret i1 %ov
  }

  define i1 @tgt(i8 %a, i8 %c) {
    %c_off = sub i8 127, %c ; SMAX
    %ov = icmp ult i8 %a, %c_off
    ret i1 %ov
  }

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

  ; slt
  define i1 @src(i8 %a, i8 %c) {
    %t = add i8 %a, %c
    %ov = icmp slt i8 %t, %c
    ret i1 %ov
  }

  define i1 @tgt(i8 %a, i8 %c) {
    %c_offnot = xor i8 %c, 127 ; SMAX
    %ov = icmp ugt i8 %a, %c_offnot
    ret i1 %ov
  }

3 years ago[InstCombine][tests] add tests for signed icmp with constant and offset; NFC
Sanjay Patel [Mon, 5 Jul 2021 13:13:38 +0000 (09:13 -0400)]
[InstCombine][tests] add tests for signed icmp with constant and offset; NFC

3 years ago[AArch64][CostModel] Add cost model for experimental.vector.splice
Caroline Concatto [Fri, 18 Jun 2021 14:39:03 +0000 (15:39 +0100)]
[AArch64][CostModel] Add cost model for experimental.vector.splice

This patch adds a new  ShuffleKind SK_Splice and then handle the cost in
getShuffleCost, as in experimental.vector.reverse.

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

3 years ago[X86] Twist shuffle mask when fold HOP(SHUFFLE(X,Y),SHUFFLE(X,Y)) -> SHUFFLE(HOP...
Wang, Pengfei [Mon, 5 Jul 2021 13:08:49 +0000 (21:08 +0800)]
[X86] Twist shuffle mask when fold HOP(SHUFFLE(X,Y),SHUFFLE(X,Y)) -> SHUFFLE(HOP(X,Y))

This patch fixes PR50823.

The shuffle mask should be twisted twice before gotten the correct one due to the difference between inner HOP and outer.

Reviewed By: RKSimon

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

3 years ago[libc++] NFC: Sort headers in CMakeLists.txt
Louis Dionne [Mon, 5 Jul 2021 13:25:15 +0000 (09:25 -0400)]
[libc++] NFC: Sort headers in CMakeLists.txt

3 years ago[CostModel][X86] Handle costs for insert/extractelement with non-immediate indices...
Simon Pilgrim [Mon, 5 Jul 2021 12:19:47 +0000 (13:19 +0100)]
[CostModel][X86] Handle costs for insert/extractelement with non-immediate indices via stack

Determine the insert/extractelement costs when performing this as a sequence of aliased loads+stores via the stack.

3 years ago[CostModel][X86] Adjust i32/i64 to f32/f64 scalar based on llvm-mca reports (+ Agner).
Simon Pilgrim [Fri, 2 Jul 2021 16:05:50 +0000 (17:05 +0100)]
[CostModel][X86] Adjust i32/i64 to f32/f64 scalar based on llvm-mca reports (+ Agner).

Older SSE targets have slower gpr->fpu scalar conversions - we also need to account for uitofp i32 > f32/f64 being lowered as sitofp i64 -> f32/f64

3 years ago[InstSimplify] fold extractelement of splat with variable extract index
Sanjay Patel [Mon, 5 Jul 2021 12:14:20 +0000 (08:14 -0400)]
[InstSimplify] fold extractelement of splat with variable extract index

We already have a fold for variable index with constant vector,
but if we can determine a scalar splat value, then it does not
matter whether that value is constant or not.

We overlooked this fold in D102404 and earlier patches,
but the fixed vector variant is shown in:
https://llvm.org/PR50817

Alive2 agrees on that:
https://alive2.llvm.org/ce/z/HpijPC

The same logic applies to scalable vectors.

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

3 years ago[clangd] NFC: Remove outdated comment
Kirill Bobyrev [Mon, 5 Jul 2021 11:58:54 +0000 (13:58 +0200)]
[clangd] NFC: Remove outdated comment

3 years ago[SLPVectorizer] Fix crash in vectorizeChainsInBlock for scalable vector.
Caroline Concatto [Mon, 21 Jun 2021 14:22:58 +0000 (15:22 +0100)]
[SLPVectorizer] Fix crash in vectorizeChainsInBlock for scalable vector.

The function vectorizeChainsInBlock does not support scalable vector,
because function like canReuseExtract and isCommutative in the code
path assert with scalable vectors.

This patch avoids vectorizing blocks that have extract instructions with scalable
vector..

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

3 years ago[C++][Sema] Ignore top-level qualifiers in casts
Ole Strohm [Tue, 29 Jun 2021 10:09:24 +0000 (11:09 +0100)]
[C++][Sema] Ignore top-level qualifiers in casts

Ignore top-level qualifiers in casts, which fixes issues in reinterpret_cast.

This rule comes from [expr.type]/8.2.2 which explains that casting to a
pr-qualified type should actually cast to the unqualified type. In C++
this is only done for types that aren't classes or arrays.

Fixes: PR49221

Reviewed By: Anastasia

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

3 years ago[AArch64][SVE] Improve fixed length codegen for common vector shuffle case
Bradley Smith [Tue, 22 Jun 2021 15:34:15 +0000 (16:34 +0100)]
[AArch64][SVE] Improve fixed length codegen for common vector shuffle case

Improve codegen when lowering the common vector shuffle case from the
vectorizer (op1[last]:op2[0:last-1]). This patch only handles this
common case as it is difficult to handle this more generally when using
fixed length vectors, due to being unable to use the SVE ext instruction.

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

3 years ago[DAGCombiner] Add support for mulhi const folding in DAGCombiner
David Stuttard [Thu, 13 May 2021 13:08:56 +0000 (14:08 +0100)]
[DAGCombiner] Add support for mulhi const folding in DAGCombiner

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

Change-Id: I4ffaaa32301795ba8a339567a68e77fe0862b869

3 years agoAdd MulOp lowering from Complex dialect to Standard/Math dialect.
Adrian Kuegel [Thu, 1 Jul 2021 08:49:04 +0000 (10:49 +0200)]
Add MulOp lowering from Complex dialect to Standard/Math dialect.

The lowering handles special cases with NaN or infinity like C++.

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

3 years ago[DAGCombiner] Pre-commit test to demonstrate mulhi const folding
David Stuttard [Mon, 5 Jul 2021 10:08:03 +0000 (11:08 +0100)]
[DAGCombiner] Pre-commit test to demonstrate mulhi const folding

D103323 will fold this

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

Change-Id: I64947215eb531fbd70b52a72203b39e43fefafcc

3 years ago[AArch64] Cost-model i8 vector loads/stores
Sjoerd Meijer [Thu, 1 Jul 2021 13:45:54 +0000 (14:45 +0100)]
[AArch64] Cost-model i8 vector loads/stores

Loads of <4 x i8> vectors were modeled as extremely expensive. And while we
don't have a load instruction that supports this, it isn't that expensive to
create a vector of i8 elements. The codegen for this was fixed/optimised in
D105110. This now tweaks the cost model and enables SLP vectorisation of my
motivating case loadi8.ll.

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

3 years ago[mlir] Escape strings of opaque attributes
Markus Böck [Mon, 5 Jul 2021 10:13:36 +0000 (12:13 +0200)]
[mlir] Escape strings of opaque attributes

Opaque attributes that currently contain string literals can't currently be properly roundtripped as they are not printed as escaped strings. This leads to incorrect tokens being generated and the parser to almost certainly fail. This patch simply uses llvm::printEscapedString from LLVM. It escapes all non printable characters and quotes to \xx hex literals, and backslashes to two backslashes. This syntax is supported by MLIRs Lexer as well. The same function is also currently in use for the same purpose in printSymbolReference, printAttribute for StringAttr and many more in AsmPrinter.cpp.

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

3 years ago[DebugInfo] CGP+HWasan: Handle dbg.values with duplicate location ops
Stephen Tozer [Mon, 5 Jul 2021 08:45:08 +0000 (09:45 +0100)]
[DebugInfo] CGP+HWasan: Handle dbg.values with duplicate location ops

This patch fixes an issue which occurred in CodeGenPrepare and
HWAddressSanitizer, which both at some point create a map of Old->New
instructions and update dbg.value uses of these. They did this by
iterating over the dbg.value's location operands, and if an instance of
the old instruction was found, replaceVariableLocationOp would be
called on that dbg.value. This would cause an error if the same operand
appeared multiple times as a location operand, as the first call to
replaceVariableLocationOp would update all uses of the old instruction,
invalidating the old iterator and eventually hitting an assertion.

This has been fixed by no longer iterating over the dbg.value's location
operands directly, but by first collecting them into a set and then
iterating over that, ensuring that we never attempt to replace a
duplicated operand multiple times.

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

3 years ago[AMDGPU] Stop mulhi from doing 24 bit mul for uniform values
David Stuttard [Thu, 13 May 2021 13:08:36 +0000 (14:08 +0100)]
[AMDGPU] Stop mulhi from doing 24 bit mul for uniform values

Added support to check if architecture supports s_mulhi which is used as part of
the decision whether or not to use valu 24 bit mul (if the mulhi gets
transformed to a valu op anyway, then may as well use it).

This is an extension of the work in D97063

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

Change-Id: I80b1323de640a52623d69ac005a97d06a5d42a14

3 years ago[docs] Fix linking issues in LibASTMatchers tutorial
Georgy Komarov [Sun, 4 Jul 2021 17:45:40 +0000 (20:45 +0300)]
[docs] Fix linking issues in LibASTMatchers tutorial

Update CMakeLists.txt in the tutorial to reflect the latest changes in
LLVM. The demo project cannot be linked without added libraries.

Reviewed By: xgupta

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

3 years ago[lld-macho][nfc] Add REQUIRES: x86 to test
Jez Ng [Mon, 5 Jul 2021 07:39:35 +0000 (03:39 -0400)]
[lld-macho][nfc] Add REQUIRES: x86 to test

I didn't realize that llvm-objdump's features were arch-specific.

This should fix the non-x86 buildbots.

3 years ago[mlir] Add LogOp lowering from Complex dialect to Standard/Math dialect.
Adrian Kuegel [Fri, 2 Jul 2021 11:20:13 +0000 (13:20 +0200)]
[mlir] Add LogOp lowering from Complex dialect to Standard/Math dialect.

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

3 years ago[RISCV] Pass FeatureBitset by reference rather than by value. NFCI
Craig Topper [Mon, 5 Jul 2021 05:59:20 +0000 (22:59 -0700)]
[RISCV] Pass FeatureBitset by reference rather than by value. NFCI

FeatureBitset is 4 64-bit values in an array. It's better passed by
reference rather than copying it.

I may be adding FeatureBitset as an argument to another function
and noticed this while working on that.

3 years ago[lld-macho] Parse relocations quickly by assuming sorted order
Jez Ng [Mon, 5 Jul 2021 05:13:30 +0000 (01:13 -0400)]
[lld-macho] Parse relocations quickly by assuming sorted order

clang and gcc both seem to emit relocations in reverse order of
address. That means we can match relocations to their containing
subsections in `O(relocs + subsections)` rather than the `O(relocs *
log(subsections))` that our previous binary search implementation
required.

Unfortunately, `ld -r` can still emit unsorted relocations, so we have a
fallback code path for that (less common) case.

Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W:

      N           Min           Max        Median           Avg        Stddev
  x  20          4.04          4.11         4.075        4.0775   0.018027756
  +  20          3.95          4.02          3.98         3.985   0.020900768
  Difference at 95.0% confidence
          -0.0925 +/- 0.0124919
          -2.26855% +/- 0.306361%
          (Student's t, pooled s = 0.0195172)

Reviewed By: #lld-macho, thakis

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

3 years ago[llvm-readobj][XCOFF] Add support for printing the String Table.
Esme-Yi [Mon, 5 Jul 2021 04:16:58 +0000 (04:16 +0000)]
[llvm-readobj][XCOFF] Add support for printing the String Table.

Summary: The patch adds the StringTable dumping to
llvm-readobj. Currently only XCOFF is supported.

Reviewed By: jhenderson

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

3 years ago[XCOFF][NFC] add DWARF section support in XCOFF object writer
Chen Zheng [Mon, 5 Jul 2021 02:53:30 +0000 (02:53 +0000)]
[XCOFF][NFC] add DWARF section support in XCOFF object writer

Reviewed By: jsji

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

3 years ago[mlir-reduce] Improve diagnostic message and clean build dependency
Chia-hung Duan [Mon, 5 Jul 2021 02:15:11 +0000 (10:15 +0800)]
[mlir-reduce] Improve diagnostic message and clean build dependency

Reviewed By: rriddle

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

3 years ago[mlir-tblgen] Avoid ODS verifier duplication
Chia-hung Duan [Tue, 29 Jun 2021 10:38:55 +0000 (18:38 +0800)]
[mlir-tblgen] Avoid ODS verifier duplication

Different constraints may share the same predicate, in this case, we
will generate duplicate ODS verification function.

Reviewed By: jpienaar

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

3 years ago[clangd] Type hints for structured bindings
Nathan Ridge [Mon, 14 Jun 2021 07:23:35 +0000 (03:23 -0400)]
[clangd] Type hints for structured bindings

Hints are shown for the individual bindings, not the aggregate.

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

3 years ago[X86] Refine code of generating BB labels in Keylocker
Xiang1 Zhang [Fri, 2 Jul 2021 08:21:39 +0000 (16:21 +0800)]
[X86] Refine code of generating BB labels in Keylocker

Reviewed By: craig.topper

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

3 years ago[mlir][NFC] MemRef cleanup: Remove helper functions
Matthias Springer [Mon, 5 Jul 2021 01:04:01 +0000 (10:04 +0900)]
[mlir][NFC] MemRef cleanup: Remove helper functions

Remove `getDynOperands` and `createOrFoldDimOp` from MemRef.h to decouple MemRef a bit from Tensor. These two functions are used in other dialects/transforms.

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

3 years ago[lld/mac] Fix function offset on 1st-level unwind table sentinel
Nico Weber [Sun, 4 Jul 2021 02:23:42 +0000 (22:23 -0400)]
[lld/mac] Fix function offset on 1st-level unwind table sentinel

Two bugs:
1. This tries to take the address of the last symbol plus the length
   of the last symbol. However, the sorted vector is cuPtrVector,
   not cuVector. Also, cuPtrVector has tombstone values removed
   and cuVector doesn't. If there was a stripped value at the end,
   the "last" element's value was UINT64_MAX, which meant the
   sentinel value was one less than the length of that "last"
   dead symbol.

2. We have to subtract in.header->addr. For 64-bit binaries that's
   (1 << 32) and functionAddress is 32-bit so this is a no-op, but
   for 32-bit binaries the sentinel's value was too large.

I believe this has no effect in practice since the first-level
binary search code in libunwind (in UnwindCursor.hpp) does:

    uint32_t low = 0;
    uint32_t high = sectionHeader.indexCount();
    uint32_t last = high - 1;
    while (low < high) {
      uint32_t mid = (low + high) / 2;
        if ((mid == last) ||
            (topIndex.functionOffset(mid + 1) > targetFunctionOffset)) {
          low = mid;
          break;
        } else {
        low = mid + 1;
      }

So the address of the last entry in the first-level table isn't really
checked -- except for the very end, but the check against `last` means
we just run the loop once more than necessary. But it makes `unwinddump` output
look less confusing, and it's what it looks was the intention here.

(No test since I can't think of a way to make FileCheck check that one
number is larger than another.)

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

3 years ago[lld/mac] Don't crash on 32-bit output binaries when dead-stripping
Nico Weber [Sun, 4 Jul 2021 01:57:43 +0000 (21:57 -0400)]
[lld/mac] Don't crash on 32-bit output binaries when dead-stripping

Fixes PR50974.

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

3 years ago[libunwind] reflow some debug logs for better greppability
Nico Weber [Fri, 2 Jul 2021 14:03:32 +0000 (10:03 -0400)]
[libunwind] reflow some debug logs for better greppability

"bad second level page" and "second level compressed unwind table"
can now be grepped for.

(Also remove one of the two spaces between "second" and "level"
in the second message.)

3 years ago[Polly][Isl] Update isl to isl-0.24-47-g8853f375
patacca [Sun, 4 Jul 2021 17:49:41 +0000 (19:49 +0200)]
[Polly][Isl] Update isl to isl-0.24-47-g8853f375

This is needed for the new functions exposed in the C++ interface as used in https://reviews.llvm.org/D104994

Reviewed By: Meinersbur

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

3 years ago[mlir][OpAsmParser] Add parseString method
Markus Böck [Sun, 4 Jul 2021 15:12:02 +0000 (17:12 +0200)]
[mlir][OpAsmParser] Add parseString method

Basically every kind of parseOptional* method in DialectAsmParser has a corresponding parse* method which will emit an error if the requested token has not been found. An odd one out of this rule is parseOptionalString which does not have a corresponding parseString method.

This patch adds that method and implements it in basically the same fashion as parseKeyword, by first going through parseOptionalString and emitting an error on failure.

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

3 years ago[IR] Deprecate GetElementPtrInst::CreateInBounds without element type
Nikita Popov [Sun, 4 Jul 2021 14:30:18 +0000 (16:30 +0200)]
[IR] Deprecate GetElementPtrInst::CreateInBounds without element type

This API is not compatible with opaque pointers, the method
accepting an explicit pointer element type should be used instead.

Thankfully there were few in-tree users. The BPF case still ends
up using the pointer element type for now and needs something like
D105407 to avoid doing so.

3 years ago[NFC] Fix a few whitespace issues and typos.
Paul Walker [Thu, 1 Jul 2021 12:07:28 +0000 (13:07 +0100)]
[NFC] Fix a few whitespace issues and typos.

3 years ago[IRBuilder] Add type argument to CreateMaskedLoad/Gather
Nikita Popov [Sat, 3 Jul 2021 12:57:41 +0000 (14:57 +0200)]
[IRBuilder] Add type argument to CreateMaskedLoad/Gather

Same as other CreateLoad-style APIs, these need an explicit type
argument to support opaque pointers.

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

3 years ago[llvm][iwyu] explicitly includes <functional> and <utility>
Christopher Di Bella [Sun, 4 Jul 2021 02:22:37 +0000 (02:22 +0000)]
[llvm][iwyu] explicitly includes <functional> and <utility>

Compiling LLVM with Clang modules and libc++ identified that
`Support/Printable.h` and `ADL/SmallVector.h` were using features that
live in these headers.

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

3 years ago[clangd][iwyu] explicitly includes `<atomic>`
Christopher Di Bella [Sun, 4 Jul 2021 02:17:43 +0000 (02:17 +0000)]
[clangd][iwyu] explicitly includes `<atomic>`

Compiling clangd with Clang modules and libc++ revealed that
`support/Threading.h` uses `std::atomic` but wasn't including the
correct header.

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

3 years ago[analyzer] Fix calculating offset for fields with an empty type
Georgy Komarov [Fri, 28 May 2021 08:58:50 +0000 (11:58 +0300)]
[analyzer] Fix calculating offset for fields with an empty type

Fix offset calculation routines in padding checker to avoid assertion
errors described in bugzilla issue 50426. The fields that are subojbects
of zero size, marked with [[no_unique_address]] or empty bitfields will
be excluded from padding calculation routines.

Reviewed By: NoQ

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

3 years ago[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.
Simon Pilgrim [Sat, 3 Jul 2021 18:00:25 +0000 (19:00 +0100)]
[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.

These are identical and can be just const.

3 years ago[X86][SSE] Add mulhu/mulhs constant folding tests
Simon Pilgrim [Sat, 3 Jul 2021 16:01:59 +0000 (17:01 +0100)]
[X86][SSE] Add mulhu/mulhs constant folding tests

These should be folded by D103323

3 years ago[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible...
Simon Pilgrim [Sat, 3 Jul 2021 15:32:41 +0000 (16:32 +0100)]
[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible. NFC.

This also allows us to use KnownBits::extractBits in one case.

3 years ago[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls...
Simon Pilgrim [Sat, 3 Jul 2021 14:58:52 +0000 (15:58 +0100)]
[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls. NFC.

3 years ago[IRBuilder] Avoid fetching pointer element type in some assertions
Nikita Popov [Sat, 3 Jul 2021 10:44:21 +0000 (12:44 +0200)]
[IRBuilder] Avoid fetching pointer element type in some assertions

Specifically the CreateMaskedStore and CreateMaskedScatter APIs.
The CreateMaskedLoad and CreateMaskedGather APIs will need an
additional type argument.

3 years ago[flang][driver] Add support for `--version` in the bash wrapper
Andrzej Warzynski [Fri, 2 Jul 2021 15:02:08 +0000 (16:02 +0100)]
[flang][driver] Add support for `--version` in the bash wrapper

The bash wrapper script, `flang`, calls `flang-new -fc1` under the hood,
which does not support `--version` (this is consistent with `clang -cc1
--version`). This change is needed for `flang --version` to work as
expected.

Note that `flang --version` (the Flang bash wrapper script for the
compiler driver) gives rather minimal output compared to `flang-new
--version` (the Flang compiler driver). As the wrapper script is just a
temporary solution for us, this should be sufficient.

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

3 years ago[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to...
Roman Lebedev [Sat, 3 Jul 2021 07:45:44 +0000 (10:45 +0300)]
[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to transfer execution to unreachable

This replaces the current ad-hoc implementation,
by syncing the code from InstCombine's implementation in `InstCombinerImpl::visitUnreachableInst()`,
with one exception that here in SimplifyCFG we are allowed to remove EH instructions.

Effectively, this now allows SimplifyCFG to remove calls (iff they won't throw and will return),
arithmetic/logic operations, etc.

Reviewed By: nikic

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

3 years ago[AArch64] Add S/UQXTRN tablegen patterns.
David Green [Sat, 3 Jul 2021 06:57:19 +0000 (07:57 +0100)]
[AArch64] Add S/UQXTRN tablegen patterns.

This adds simple patterns for signed and unsigned saturating extract
narrow instructions. They combine a min/max/truncate into a single
instruction, providing that the immediates on the min/max are correct
for the saturation type. This is just handled in tablegen with some
extra patterns.

v2i64->v2i32 is not handled here as the min/max nodes are not legal,
making the lowering quite different.

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

3 years ago[AIX] Adjust CSR order to avoid breaking ABI regarding traceback
Kai Luo [Sat, 3 Jul 2021 04:45:11 +0000 (04:45 +0000)]
[AIX] Adjust CSR order to avoid breaking ABI regarding traceback

Allocate non-volatile registers in order to be compatible with ABI, regarding gpr_save.

Quoted from https://www.ibm.com/docs/en/ssw_aix_72/assembler/assembler_pdf.pdf page55,
> The preferred method of using GPRs is to use the volatile registers first. Next, use the nonvolatile registers
> in descending order, starting with GPR31.

This patch is based on @jsji 's initial draft.

Tested on test-suite and SPEC, found no degradation.

Reviewed By: jsji, ZarkoCA, xingxue

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

3 years ago[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from...
Craig Topper [Sat, 3 Jul 2021 00:36:27 +0000 (17:36 -0700)]
[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from VT to MemVT.

Use getMemoryVT() in MGATHER/MSCATTER DAG combines instead of
using the passthru or store value VT for this argument.

3 years ago[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions
Fangrui Song [Sat, 3 Jul 2021 00:08:25 +0000 (17:08 -0700)]
[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions

D74751 added `ClearDSOLocalOnDeclarations` and dropped dso_local for
isDeclarationForLinker `GlobalValue`s. It missed a case for imported
declarations (`doImportAsDefinition` is false while `isPerformingImport` is
true). This can lead to a linker error for a default visibility symbol in
`ld.lld -shared`.

When `ClearDSOLocalOnDeclarations` is true, we check
`isPerformingImport() && !doImportAsDefinition(&GV)` along with
`GV.isDeclarationForLinker()`. The new condition checks an imported declaration.

This patch fixes a `LLVMPolly.so` link error using a trunk clang -DLLVM_ENABLE_LTO=Thin.

Reviewed By: tejohnson

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

3 years agoRevert "Create synthetic symbol names on demand to improve memory consumption and...
Jonas Devlieghere [Fri, 2 Jul 2021 23:17:25 +0000 (16:17 -0700)]
Revert "Create synthetic symbol names on demand to improve memory consumption and startup times."

This reverts commit c8164d0276b97679e80db01adc860271ab4a5d11 and
43f6dad2344247976d5777f56a1fc29e39c6c717 because it breaks
TestDyldTrieSymbols.py on GreenDragon.

3 years agoRevert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"
Jonas Devlieghere [Fri, 2 Jul 2021 22:45:15 +0000 (15:45 -0700)]
Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"

This reverts commit 8cd35ad854ab4458fd509447359066ea3578b494.

It breaks `TestMembersAndLocalsWithSameName.py` on GreenDragon and
Mikael Holmén points out in D104827 that bitcode files created with the
patch cannot be parsed with binaries built before it.

3 years ago[mlir][sparse] support for negation and subtractions
Aart Bik [Fri, 2 Jul 2021 19:26:18 +0000 (12:26 -0700)]
[mlir][sparse] support for negation and subtractions

This revision extends the sparse compiler support from fp/int addition and multiplication to fp/int negation and subtraction, thereby increasing the scope of sparse kernels that can be compiled.

Reviewed By: gussmith23

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

3 years agoLex: add a callback for `#pragma mark`
Saleem Abdulrasool [Fri, 2 Jul 2021 19:43:01 +0000 (19:43 +0000)]
Lex: add a callback for `#pragma mark`

Allow a preprocessor observer to be notified of mark pragmas.  Although
this does not impact code generation in any way, it is useful for other
clients, such as clangd, to be able to identify any marked regions.

Reviewed By: dgoldman

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

3 years ago[lldb] Update shebang in heap.py and crashlog.py
Jonas Devlieghere [Fri, 2 Jul 2021 22:33:46 +0000 (15:33 -0700)]
[lldb] Update shebang in heap.py and crashlog.py

3 years agoFix test so it doesn't try to write to the test directory, only to %t
David Blaikie [Fri, 2 Jul 2021 21:59:50 +0000 (14:59 -0700)]
Fix test so it doesn't try to write to the test directory, only to %t

3 years ago[mlir][Vector] NFC - Compress vector to outerproduct lowering.
Nicolas Vasilache [Fri, 2 Jul 2021 15:32:53 +0000 (15:32 +0000)]
[mlir][Vector] NFC - Compress vector to outerproduct lowering.

The implementation has become too unwieldy and cognitive overhead wins.
Instead compress the implementation in preparation for additional lowering paths.

This is a resubmit of https://reviews.llvm.org/D105359 without ordering ambiguities.

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

3 years agoName all DEATH tests using 'DeathTest' suffix.
Mitch Phillips [Fri, 2 Jul 2021 20:50:52 +0000 (13:50 -0700)]
Name all DEATH tests using 'DeathTest' suffix.

gtest highly recommends this prefix, and runs death tests first
(https://github.com/google/googletest/blob/master/docs/advanced.md#death-test-naming).
This may help with some spurious bot failures like
https://lab.llvm.org/buildbot/#/builders/169/builds/1290/steps/25/logs/stdio.

Reviewed By: cryptoad, vitalybuka

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

3 years ago[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll
Roman Lebedev [Fri, 2 Jul 2021 20:29:18 +0000 (23:29 +0300)]
[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll

It is being affected by an upcoming SimplifyCFG change.

3 years ago[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator
Roman Lebedev [Fri, 2 Jul 2021 20:14:21 +0000 (23:14 +0300)]
[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator

These rely on the fact that currently simplifycfg won't really propagate
said `unreachable`, but that is about to change.

3 years ago[lldb/test] Fix failure caused by synthetic symbol name refactoring
Med Ismail Bennani [Fri, 2 Jul 2021 20:01:21 +0000 (20:01 +0000)]
[lldb/test] Fix failure caused by synthetic symbol name refactoring

This patch fixes a failure in `TestFunctionStarts.py` that appeared
following a change of implementation for synthetic symbol names:

https://reviews.llvm.org/D105160

The failure is caused because the previously mentioned patch removes the
object file basename from the generated synthetic symbol names to allow
them to be shared in the constant string pool.

Hence, that last check is not necessary anymore.

rdar://80092322

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years ago[GlobalISel] Clean up CombinerHelper::apply* functions to return void.
Amara Emerson [Fri, 2 Jul 2021 20:07:00 +0000 (13:07 -0700)]
[GlobalISel] Clean up CombinerHelper::apply* functions to return void.

For some reason we/I started writing these as returning bool when the return value
is actually ignored by the combiner.

3 years ago[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.
Joachim Meyer [Fri, 2 Jul 2021 19:54:39 +0000 (21:54 +0200)]
[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.

This broke ARM builds e.g.: https://lab.llvm.org/buildbot/#/builders/187/builds/212

3 years ago[NFC][SimplifyCFG] Autogenerate checklines in a few tests
Roman Lebedev [Fri, 2 Jul 2021 19:35:14 +0000 (22:35 +0300)]
[NFC][SimplifyCFG] Autogenerate checklines in a few tests

3 years ago[lldb] [gdb-remote client] Support switching PID along with TID
Michał Górny [Sun, 11 Apr 2021 11:04:54 +0000 (13:04 +0200)]
[lldb] [gdb-remote client] Support switching PID along with TID

Extend the SetCurrentThread() method to support specifying an alternate
PID to switch to.  This makes it possible to issue requests to forked
processes.

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

3 years ago[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing...
Amara Emerson [Sun, 27 Jun 2021 06:36:46 +0000 (23:36 -0700)]
[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing mode usage.

We're trying to match a few pointer computation patterns here for
re-association opportunities.
1) Isolating a constant operand to be on the RHS, e.g.:
   G_PTR_ADD(BASE, G_ADD(X, C)) -> G_PTR_ADD(G_PTR_ADD(BASE, X), C)

2) Folding two constants in each sub-tree as long as such folding
   doesn't break a legal addressing mode.
   G_PTR_ADD(G_PTR_ADD(BASE, C1), C2) -> G_PTR_ADD(BASE, C1+C2)

AArch64 code size improvements on CTMark with -Os:
Program              before  after   diff
 pairlocalalign      251048  251044 -0.0%
 consumer-typeset    421820  421812 -0.0%
 kc                  431348  431320 -0.0%
 SPASS               413404  413300 -0.0%
 clamscan            384396  384220 -0.0%
 tramp3d-v4          370640  370412 -0.1%
 lencod              432096  431772 -0.1%
 bullet              479400  478796 -0.1%
 sqlite3             288504  288072 -0.1%
 7zip-benchmark      573796  570768 -0.5%
 Geomean difference                 -0.1%

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