platform/upstream/llvm.git
2 years ago[clang][dataflow] Rename `getPointeeLoc` to `getReferentLoc` for ReferenceValue.
Wei Yi Tee [Tue, 14 Jun 2022 22:41:49 +0000 (00:41 +0200)]
[clang][dataflow] Rename `getPointeeLoc` to `getReferentLoc` for ReferenceValue.

We distinguish between the referent location for `ReferenceValue` and pointee location for `PointerValue`. The former must be non-empty but the latter may be empty in the case of a `nullptr`

Reviewed By: gribozavr2, sgatev

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

2 years ago[PS5] Default to 'sce' debugger tuning
Paul Robinson [Tue, 14 Jun 2022 22:26:35 +0000 (15:26 -0700)]
[PS5] Default to 'sce' debugger tuning

2 years agoFunctionPropertiesAnalysis: handle callsite BBs that lose edges
Mircea Trofin [Wed, 8 Jun 2022 21:58:21 +0000 (14:58 -0700)]
FunctionPropertiesAnalysis: handle callsite BBs that lose edges

There could be successors that were reached before but now are only
reachable from elsewhere in the CFG.

Suppose the following diamond CFG (lines are arrows pointing down):
    A
  /   \
 B     C
  \   /
    D
There's a call site in C that is inlined. Upon doing that, it turns out
it expands to:
   call void @llvm.trap()
   unreachable
D isn't reachable from C anymore, but we did discount it when we set up
FunctionPropertiesUpdater, so we need to re-include it here.

The patch also updates loop accounting to use LoopInfo rather than
traverse BBs.

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

2 years ago[llvm] Add DW_CC_nocall to function debug metadata when either return values or argum...
Venkata Ramanaiah Nalamothu [Mon, 6 Jun 2022 15:37:09 +0000 (21:07 +0530)]
[llvm] Add DW_CC_nocall to function debug metadata when either return values or arguments are removed

Adding the `DW_CC_nocall` calling convention to the function debug metadata is needed when either the return values or the arguments of a function are removed as this helps in informing debugger that it may not be safe to call this function or try to interpret the return value.
This translates to setting `DW_AT_calling_convention` with `DW_CC_nocall` for appropriate DWARF DIEs.

The DWARF5 spec (section 3.3.1.1 Calling Convention Information) says:

If the `DW_AT_calling_convention` attribute is not present, or its value is the constant `DW_CC_normal`, then the subroutine may be safely called by obeying the `standard` calling conventions of the target architecture. If the value of the calling convention attribute is the constant `DW_CC_nocall`, the subroutine does not obey standard calling conventions, and it may not be safe for the debugger to call this subroutine.

Reviewed By: dblaikie

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

2 years ago[mlir] Try to work around ambiguity in older clang versions
Benjamin Kramer [Tue, 14 Jun 2022 21:57:57 +0000 (23:57 +0200)]
[mlir] Try to work around ambiguity in older clang versions

mlir/lib/Dialect/Arithmetic/IR/InferIntRangeInterfaceImpls.cpp:366:10: error: chosen constructor is explicit in copy-initialization
  return {leftVal, rightVal};
         ^~~~~~~~~~~~~~~~~~~

2 years ago[bazel] Port b0b00432093b
Benjamin Kramer [Tue, 14 Jun 2022 21:55:50 +0000 (23:55 +0200)]
[bazel] Port b0b00432093b

2 years ago[bazel] Port 75bfc6f29579
Benjamin Kramer [Tue, 14 Jun 2022 21:45:52 +0000 (23:45 +0200)]
[bazel] Port 75bfc6f29579

2 years agoRISCV: handle 64-bit PCREL data relocations
Saleem Abdulrasool [Fri, 10 Jun 2022 22:54:17 +0000 (22:54 +0000)]
RISCV: handle 64-bit PCREL data relocations

We would previously fail to handle 64-bit PC-relative relocations on
RISCV.  This was exposed by trying to build with
`-fprofile-instr-generate`.

The original changes restricted the relocation handling to the text
segment as the paired relocations are undesirable in at least the debug
and .eh_frame sections.  We now make this explicit to handle the general
case for the data relocations as well.

It would be preferable to use `R_RISCV_n_PCREL` when available to avoid
an extra relocation.

Differential Revision: https://reviews.llvm.org/D127549
Reviewed By: luismarques, MaskRay

Fixes: #55971

2 years ago(Reland)[mlir] Add a generic data-flow analysis framework
Mogball [Mon, 13 Jun 2022 21:54:52 +0000 (21:54 +0000)]
(Reland)[mlir] Add a generic data-flow analysis framework

Removes one element of the pointer union to make it work on 32-bit
systems.

This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses.

Reviewed By: phisiart, rriddle

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

2 years ago[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones
Krzysztof Drewniak [Thu, 14 Apr 2022 22:51:23 +0000 (22:51 +0000)]
[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones

If all the arguments to and results of an operation are known to be
non-negative when interpreted as signed (which also implies that all
computations producing those values did not experience signed
overflow), we can replace that operation with an equivalent one that
operates on unsigned values.

Such a replacement, when it is possible, can provide useful hints to
backends, such as by allowing LLVM to replace remainder with bitwise
operations in more cases.

Depends on D124022

Depends on D124023

Reviewed By: Mogball

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

2 years ago[clang] Add tests for statement expression in initializers
Anders Waldenborg [Tue, 7 Jun 2022 10:21:42 +0000 (12:21 +0200)]
[clang] Add tests for statement expression in initializers

The commit 683e83c5
  [Clang][C++2b] P2242R3: Non-literal variables [...] in constexpr
fixed a code generation bug when using (C-extension) statement
expressions inside initializer expressions.

Before that commit a nested static initializer inside the statement
expression would not be emitted, causing it to be zero initialized.

It is a bit surprising (at least to me) that a commit implementing a new
C++ feature would fix this code generation bug. Zooming in it is the
change done in ExprConstant.cpp that helps. That changes so that
"ESR_Failed" is returned in more cases, causing the expression to not be
deemed constant. This fixes the code generation as instead the compiler
has to resort to generating a dynamic initializer.

That commit also meant that some statement expressions (in particular
the ones using static variables) that previously were accepted now are
errors due to not being constant (matching GCC behavior).

Given how a seemingly unrelated change caused this behavior to change,
it is probably a good thing to add at least some rudimentary tests for
these kind expressions.

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

2 years agoRevert "[mlir] Add a generic data-flow analysis framework"
Frederik Gossen [Tue, 14 Jun 2022 21:12:52 +0000 (17:12 -0400)]
Revert "[mlir] Add a generic data-flow analysis framework"

This reverts commit 9dea11728340e54e1fde76320b61a559148c8a3e.
The PointerUnion assumes 3 available bits, which is not the case on 32-bit
machines.

2 years ago[flang] Add failed_images to list of intrinsics and add test
Katherine Rasmussen [Sat, 14 May 2022 04:50:36 +0000 (21:50 -0700)]
[flang] Add failed_images to list of intrinsics and add test

Add failed_images to the list of intrinsic functions. Add a
semantics test for failed_images.

Reviewed By: jeanPerier

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

2 years agoRevert "[mlir] add an option to print op stats in JSON"
Okwan Kwon [Tue, 14 Jun 2022 21:06:54 +0000 (14:06 -0700)]
Revert "[mlir] add an option to print op stats in JSON"

There is a failure from the python pass manager.

This reverts commit 1a19abf38c3afb66b680cea69c8e61ea152e1514.

2 years ago[RISCV] Split out transfer function explicitly in VSETVLI insertion dataflow [nfc]
Philip Reames [Tue, 14 Jun 2022 21:01:29 +0000 (14:01 -0700)]
[RISCV] Split out transfer function explicitly in VSETVLI insertion dataflow [nfc]

In an effort to make this code easier to read and extend, this splits out helper functions for the transfer function of the data flow. Due to the other results computed during the phases, we can't completely abstract away everything, but we can abstract the actual state transitions.

The motivation here is the following upcoming changes:
* The fault first load patch - already approved, this will be rebased over - adds another case into the transferAfter path.
* An upcoming patch to fold the local prepass back into the main algorithm greatly complicates the transferBefore logic.

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

2 years ago[lld-macho] Group undefined symbol diagnostics by symbol
Daniel Bertalan [Tue, 14 Jun 2022 20:35:09 +0000 (16:35 -0400)]
[lld-macho] Group undefined symbol diagnostics by symbol

ld64.lld used to print the "undefined symbol" line for each reference to
an undefined symbol previously:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o:(symbol _baz+0x0)

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o:(symbol _quux+0x1)

Now they are deduplicated:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o:(symbol _baz+0x0)
  >>> referenced by /path/to/bar.o:(symbol _quux+0x1)

As with the other lld ports, only the first 3 references are printed.

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

2 years ago[Matrix] Check if iterator is at beginning of BB in optimizeTranspose.
Florian Hahn [Tue, 14 Jun 2022 20:37:02 +0000 (21:37 +0100)]
[Matrix] Check if iterator is at beginning of BB in optimizeTranspose.

If an instruction at the beginning of a block is erased,  this may
trigger crash due to dereferencing an invalid iterator.

Check if II is at the end before dereferencing it.

Reviewed By: thegameg

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

2 years ago[mlir] add an option to print op stats in JSON
Okwan Kwon [Mon, 13 Jun 2022 20:42:05 +0000 (13:42 -0700)]
[mlir] add an option to print op stats in JSON

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

2 years ago[Clang] Simplify unifying target features
Joseph Huber [Tue, 14 Jun 2022 02:08:52 +0000 (22:08 -0400)]
[Clang] Simplify unifying target features

This patch simplifies how we unify target features. Now we simply
iterate the input in reverse and only insert the feature if it hasn't
been seen yet. The only reason we need to reverse this at the end is to
keep the features in order for the existing tests.

Reviewed By: tra

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

2 years ago[PS5] Make library function availability match PS4
Paul Robinson [Tue, 14 Jun 2022 19:46:50 +0000 (12:46 -0700)]
[PS5] Make library function availability match PS4

2 years agoUpdate ASTImportError.h
Shivam [Tue, 14 Jun 2022 19:15:07 +0000 (00:45 +0530)]
Update ASTImportError.h

2 years ago[Clang][AST] Fixed BindingDecl AST-dump for tuple like structures
isuckatcs [Thu, 26 May 2022 16:59:22 +0000 (18:59 +0200)]
[Clang][AST] Fixed BindingDecl AST-dump for tuple like structures

The AST of a BindingDecl in case of tuple like structures wasn't
properly printed. For these bidnings there is information stored
in BindingDecl::getHoldingVar(), and this information was't
printed in the AST-dump.

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

2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 3/4
Amir Ayupov [Tue, 14 Jun 2022 19:10:34 +0000 (12:10 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 3/4

Group switch cases by opcode:
- V4FMADDPS
- V4FMADDSS
- V4FNMADDPS
- V4FNMADDSS
- VP4DPWSSDS
- VP4DPWSSD

Reviewed By: craig.topper

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

2 years ago[clang][NFC][AST] rename the ImportError to ASTImportError
phyBrackets [Tue, 14 Jun 2022 19:09:24 +0000 (00:39 +0530)]
[clang][NFC][AST] rename the ImportError to ASTImportError

this patch is the continuation of my previous patch regarding the ImportError in ASTImportError.h

Reviewed By: martong

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

2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 2/4
Amir Ayupov [Tue, 14 Jun 2022 19:07:11 +0000 (12:07 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 2/4

Group switch cases by opcode:
- VFCMULCPH
- VFCMULCSH
- VFMULCPH
- VFMULCSH

Reviewed By: craig.topper

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

2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 1/4
Amir Ayupov [Tue, 14 Jun 2022 18:20:36 +0000 (11:20 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 1/4

Group switch cases by opcode:
- VFCMADDCPH
- VFCMADDCSH
- VFMADDCPH
- VFMADDCSH

Reviewed By: craig.topper

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

2 years ago[ValueTracking] recognize sub X, (X -nsw Y) as not overflowing
Sanjay Patel [Tue, 14 Jun 2022 18:51:49 +0000 (14:51 -0400)]
[ValueTracking] recognize sub X, (X -nsw Y) as not overflowing

This extends a similar pattern from D125500.
If we know that operand 1 (RHS) of a subtract is itself a
non-overflowing subtract from operand 0 (LHS), then the
final/outer subtract is also non-overflowing:
https://alive2.llvm.org/ce/z/Bqan8v

InstCombine uses this analysis to trigger a narrowing
optimization, so that is what the first changed test shows.

The last test models the motivating case from issue #48013.
In that example, we determine 'nsw' on the first sub from
the srem, then we determine that the 2nd sub can be narrowed,
and that leads to eliminating both subtracts.

This works for unsigned sub too, but I left that out to keep
the patch minimal. If this looks ok, I will follow up with
that change. There are also several missing subtract narrowing
optimizations demonstrated in the tests above the diffs shown
here - those should be handled in InstCombine with another set
of patches.

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

2 years ago[MLIR][Presburger] Fix spellings of attachment
Groverkss [Tue, 14 Jun 2022 18:19:21 +0000 (23:49 +0530)]
[MLIR][Presburger] Fix spellings of attachment

2 years ago[RISCV] Split out subfields in InsertVSETVLI's demanded fields analysis [nfc]
Philip Reames [Tue, 14 Jun 2022 18:31:19 +0000 (11:31 -0700)]
[RISCV] Split out subfields in InsertVSETVLI's demanded fields analysis [nfc]

At the moment, this just gets the infrastructure in place.  Following changes will start using this in non-trivial ways.

2 years ago[mlir][Arith] Implement InferIntRangeInterface for arithmetic ops
Krzysztof Drewniak [Fri, 22 Apr 2022 19:07:59 +0000 (19:07 +0000)]
[mlir][Arith] Implement InferIntRangeInterface for arithmetic ops

Depends on D124023

Reviewed By: Mogball, rriddle

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

2 years ago[flang] Add team_type to num_images intrinsic call
Katherine Rasmussen [Tue, 31 May 2022 20:15:54 +0000 (13:15 -0700)]
[flang] Add team_type to num_images intrinsic call

num_images had previously been added to the list of intrinsics
before the type team_type had been implemented. Now that team_type
is implemented, add the num_images call that has the team argument.
Update the semantics tests for num_images.

Reviewed By: craig.rasmussen

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

2 years ago[libc++] Find a clang-format everybody is happy with
Nikolas Klauser [Tue, 14 Jun 2022 18:09:03 +0000 (20:09 +0200)]
[libc++] Find a clang-format everybody is happy with

We decided that we want to use clang-format for libc++ but we haven't decided yet how the code should be formatted. We should probably discuss things on discord. This PR is mostly to show how the clang-format would look like and to commit to one once we decided on it. I'll remove the `<string>` diff when I commit this PR.

Reviewed By: ldionne

Spies: EricWF, dschuff, krytarowski, fedor.sergeev, aheejin, mstorsjo, phosek, abrachet, libcxx-commits, arichardson

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

2 years ago[libc++] Use explicit module cache path in tests
Alex Brachet [Tue, 14 Jun 2022 18:06:59 +0000 (18:06 +0000)]
[libc++] Use explicit module cache path in tests

For reference, this test creates about 1.5G in the cache
directory. By default this will go to ~/.cache/clang/
which can fill up quick. This changes the test to put the
cache path in lit temp directories. Size considerations
aside it makes sense for tests to be hermetic and not
touch global system state.

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

2 years ago[MLIR][Presburger] Add values to PresburgerSpace
Groverkss [Tue, 14 Jun 2022 17:41:30 +0000 (23:11 +0530)]
[MLIR][Presburger] Add values to PresburgerSpace

This patch allows attaching user information, called "values" to each
identifier. The values are used to carry information along with variables and
are also used to determine if two variables are identical.

This patch is part of a series of patches to allow attaching user information
with variables in Presburger library.

Reviewed By: ftynse

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

2 years ago[NFC][libcxx] Check def of __LONG_DOUBLE_IEEE128__
David Tenty [Fri, 3 Jun 2022 20:33:53 +0000 (16:33 -0400)]
[NFC][libcxx] Check def of __LONG_DOUBLE_IEEE128__

Follow on to https://reviews.llvm.org/D108352, also check for the
definition of __LONG_DOUBLE_128__ before using it (because AIX doesn't
enable it by default).

Reviewed By: xingxue

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

2 years ago[PS5] Use __gxx_personality_v0 for TSan
Paul Robinson [Tue, 14 Jun 2022 17:22:22 +0000 (10:22 -0700)]
[PS5] Use __gxx_personality_v0 for TSan

2 years ago[analyzer][NFC] Replace getLastArg with hasArg when applicable
Balazs Benics [Tue, 14 Jun 2022 17:28:44 +0000 (19:28 +0200)]
[analyzer][NFC] Replace getLastArg with hasArg when applicable

Depends on D126215.

2 years ago[CMake][compiler-rt] Provide a dedicated option for LLVM unwinder
Petr Hosek [Wed, 27 Apr 2022 06:23:53 +0000 (23:23 -0700)]
[CMake][compiler-rt] Provide a dedicated option for LLVM unwinder

This allows configuring LLVM unwinder separately from the C++ library
matching how we configure it in libcxx.

This also applies changes made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt.

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

2 years ago[libcxx][AIX] Enable ABI list checking for XCOFF
Jake Egan [Tue, 14 Jun 2022 17:15:46 +0000 (13:15 -0400)]
[libcxx][AIX] Enable ABI list checking for XCOFF

The existing nm extractors can't dump the loader symbol table information we need to do the ABI checks for XCOFF, so provide an implementation using the system dump utility. We match the symbol name, whether it's defined, it's import/export status, and its storage mapping class.

Reviewed By: #libc, ldionne

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

2 years ago[analyzer][NFC] Remove unused ExprEngine::evalBinOp functions
Balazs Benics [Tue, 14 Jun 2022 17:15:20 +0000 (19:15 +0200)]
[analyzer][NFC] Remove unused ExprEngine::evalBinOp functions

Reviewed By: martong

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

2 years ago[RISCV] Split out getEEWForLoadStore [nfc]
Philip Reames [Tue, 14 Jun 2022 17:07:56 +0000 (10:07 -0700)]
[RISCV] Split out getEEWForLoadStore [nfc]

Mostly about allowing reuse in an upcoming patch, but also makes the code slightly easier to follow.

2 years ago[analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Balazs Benics [Tue, 14 Jun 2022 16:56:43 +0000 (18:56 +0200)]
[analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions

Depends on D126127

Reviewed By: martong

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

2 years ago[analyzer][NFC] Relocate unary transfer functions
Balazs Benics [Tue, 14 Jun 2022 16:56:43 +0000 (18:56 +0200)]
[analyzer][NFC] Relocate unary transfer functions

This is an initial step of removing the SimpleSValBuilder abstraction. The SValBuilder alone should be enough.

Reviewed By: martong

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

2 years agoremove a duplicated include
Luboš Luňák [Tue, 14 Jun 2022 16:54:52 +0000 (18:54 +0200)]
remove a duplicated include

2 years ago[mlir] Add a generic data-flow analysis framework
Mogball [Mon, 13 Jun 2022 21:54:52 +0000 (21:54 +0000)]
[mlir] Add a generic data-flow analysis framework

This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses.

Reviewed By: phisiart, rriddle

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

2 years agofreeze does not change the constant property
Danila Malyutin [Tue, 14 Jun 2022 14:32:15 +0000 (17:32 +0300)]
freeze does not change the constant property

Traverse through freeze when checking if base is constant

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

2 years ago[PowerPC] Fix combine step for shufflevector.
Stefan Pintilie [Tue, 14 Jun 2022 14:27:03 +0000 (09:27 -0500)]
[PowerPC] Fix combine step for shufflevector.

The combine step for shufflevector will sometimes replace undef in the mask
with a defined value. This can cause an infinite loop in some cases as another
combine will then put the undef back in the mask.

This patch fixes the issue so that undefs are not replaced when doing a combine.

Reviewed By: ZarkoCA, amyk, quinnp, saghir

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

2 years ago[mlir][linalg] Add named ops for depthwise 3d convolution
Benjamin Kramer [Mon, 13 Jun 2022 20:03:56 +0000 (22:03 +0200)]
[mlir][linalg] Add named ops for depthwise 3d convolution

Also complete the set by adding a variant of depthwise 1d convolution
with the multiplier != 1.

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

2 years ago[clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy
Matheus Izvekov [Sun, 29 May 2022 23:22:23 +0000 (01:22 +0200)]
[clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy

This redoes D103040 in a way that `AlwaysIncludeTypeForTemplateArgument = false`
policy is honored for printing template specialization types.
This can be seen for example when printing a canonicalized
dependent TemplateSpecializationType which has integral arguments.

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

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

2 years ago[AMDGPU] Regenerate MIR checks for image instructions
Jay Foad [Tue, 14 Jun 2022 16:00:13 +0000 (17:00 +0100)]
[AMDGPU] Regenerate MIR checks for image instructions

2 years ago[mlir] fix compiler error due to commit landing race
Alex Zinenko [Tue, 14 Jun 2022 16:04:00 +0000 (18:04 +0200)]
[mlir] fix compiler error due to commit landing race

2 years ago[mlir] Introduce transform.alternatives op
Alex Zinenko [Tue, 14 Jun 2022 15:49:47 +0000 (17:49 +0200)]
[mlir] Introduce transform.alternatives op

Introduce a transform dialect op that allows one to attempt different
transformation sequences on the same piece of payload IR until one of them
succeeds. This op fundamentally expands the scope of possibilities in the
transform dialect that, until now, could only propagate transformation failure,
at least using in-tree operations. This requires a more detailed specification
of the execution model for the transform dialect that now indicates how failure
is handled and propagated.

Transformations described by transform operations now have tri-state results,
with some errors being fundamentally irrecoverable (e.g., generating malformed
IR) and some others being recoverable by containing ops. Existing transform ops
directly implementing the `apply` interface method are updated to produce this
directly. Transform ops with the `TransformEachTransformOpTrait` are currently
considered to produce only irrecoverable failures and will be updated
separately.

Reviewed By: springerm

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

2 years ago[InstCombine] add tests for sub with extended operands; NFC
Sanjay Patel [Mon, 13 Jun 2022 17:38:46 +0000 (13:38 -0400)]
[InstCombine] add tests for sub with extended operands; NFC

2 years ago[inliner] Add per-SCC-pass InlineAdvisor printing option
Jin Xin Ng [Tue, 14 Jun 2022 14:52:36 +0000 (07:52 -0700)]
[inliner] Add per-SCC-pass InlineAdvisor printing option

Adds option to print the contents of the Inline Advisor after each SCC Inliner pass

Reviewed By: mtrofin

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

2 years ago[libc] Guard common macro names
Alex Brachet [Tue, 14 Jun 2022 15:05:16 +0000 (15:05 +0000)]
[libc] Guard common macro names

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

2 years ago[NFC] Remove unused function parameter
Serge Pavlov [Tue, 14 Jun 2022 05:25:35 +0000 (12:25 +0700)]
[NFC] Remove unused function parameter

2 years ago[RISCV] simplify emitVSETVLIs handling of vsetvli xN, phi(), vtype case [NFC]
Philip Reames [Tue, 14 Jun 2022 14:45:40 +0000 (07:45 -0700)]
[RISCV] simplify emitVSETVLIs handling of vsetvli xN, phi(), vtype case [NFC]

This is possibly somewhat subjective, but having an explicitly named flag to track the property required and code structure that more closely matches phase 1/2 of the dataflow seems much easier to read.

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

2 years ago[Diagnostics] Fix inconsistent shift-overflow warnings in C++20
Shivam Gupta [Tue, 14 Jun 2022 12:29:13 +0000 (17:59 +0530)]
[Diagnostics] Fix inconsistent shift-overflow warnings in C++20

This fixes https://github.com/llvm/llvm-project/issues/52873.
Don't warn in C++2A mode (and newer), as signed left shifts
always wrap and never overflow. Ref. -
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1236r1.html.

2 years ago[Libomptarget] Add test config for compiling in LTO-mode
Joseph Huber [Fri, 10 Jun 2022 16:30:19 +0000 (12:30 -0400)]
[Libomptarget] Add test config for compiling in LTO-mode

We are planning on making LTO the default compilation mode for
offloading. In order to make sure it works we should run these tests on
the test suite. AMDGPU already uses the LTO compilation path for its
linking, but in LTO mode it also links the static library late.

Performing LTO requires the static library to be built, if we make the
change this will be a hard requirement and the old bitcode library will
go away. This means users will need to use either a two-step build or a
runtimes build for libomptarget.

Reviewed By: JonChesterfield

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

2 years ago[flang] Avoid losing type parameter information
Valentin Clement [Tue, 14 Jun 2022 13:57:24 +0000 (15:57 +0200)]
[flang] Avoid losing type parameter information

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoAdd __config formatting to .git-blame-ignore-revs
Louis Dionne [Tue, 14 Jun 2022 13:52:49 +0000 (09:52 -0400)]
Add __config formatting to .git-blame-ignore-revs

2 years ago[lld-macho] Print the name of functions containing undefined references
Daniel Bertalan [Tue, 14 Jun 2022 13:41:28 +0000 (09:41 -0400)]
[lld-macho] Print the name of functions containing undefined references

The error used to look like this:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o

Now it displays the name of the function that contains the undefined
reference as well:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o:(symbol _baz+0x4)

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

2 years ago[NFC][Thumb] Update frame-chain codegen test to use thumbv6m
Lucas Prates [Tue, 14 Jun 2022 13:16:38 +0000 (14:16 +0100)]
[NFC][Thumb] Update frame-chain codegen test to use thumbv6m

The `llvm/test/CodeGen/Thumb/frame-chain.ll`, recently added by D125094,
currently fails when expensive checks are enabled due to a tMOVr
instruction that is only valid from V6 onwards.

The use of the invalid instruction is unrelated to the contents of the
original patch, and continues to be triggered by this test if its
CodeGen changes are reverted, so this patch updates the test to use V6-M
while the issue is not resolved.

2 years ago[AMDGPU] gfx11 support add_f16
Joe Nash [Mon, 13 Jun 2022 20:38:18 +0000 (16:38 -0400)]
[AMDGPU] gfx11 support add_f16

The instruction was skipped in the earlier large patch adding
VOP2, https://reviews.llvm.org/D126917.

Reviewed By: rampitec, #amdgpu

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

2 years agoRevert "[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock"
Serguei Katkov [Tue, 14 Jun 2022 12:58:55 +0000 (19:58 +0700)]
Revert "[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock"

It looks like it causes buildbot failures.
As an example: https://lab.llvm.org/buildbot/#/builders/121/builds/20364

Revert to investigate...

This reverts commit 6bf27918144cb843cf5ae9a93cb5f936730f3cce.

2 years ago[OpenMP] Fix offload packager not writing to temps correctly
Joseph Huber [Mon, 13 Jun 2022 17:41:50 +0000 (13:41 -0400)]
[OpenMP] Fix offload packager not writing to temps correctly

The offloading packager doesn't have a normal offloading kind. This
would result in its output being sent to the executable name when in
save-temps mode. This would then get overwritten by the actual output.
This patch adds specific checks to make sure that it gets the correct
name.

Reviewed By: tra

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

2 years ago[libc++] Remove macros for IBM compiler
Louis Dionne [Mon, 13 Jun 2022 15:21:16 +0000 (11:21 -0400)]
[libc++] Remove macros for IBM compiler

It's not tested or used anymore -- instead a Clang-based compiler is
used on IBM nowadays.

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

2 years ago[AArch64] Add cost tests for fadd reductions with fast math flags.
Vir Narula [Tue, 14 Jun 2022 13:13:12 +0000 (14:13 +0100)]
[AArch64] Add cost tests for fadd reductions with fast math flags.

Add test coverage showing how the costs of fadd reductions is
overestimated at the moment.

Reviewed By: fhahn

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

2 years ago[ARM] Add more opaque pointer gather/scatter tests. NFC
David Green [Tue, 14 Jun 2022 13:08:43 +0000 (14:08 +0100)]
[ARM] Add more opaque pointer gather/scatter tests. NFC

Some of the newly added tests are incorrect, fixed in D127733.

2 years ago[AArch64][SME] Add ldr/str (fill/spill) intrinsics
David Sherwood [Wed, 8 Jun 2022 14:05:10 +0000 (15:05 +0100)]
[AArch64][SME] Add ldr/str (fill/spill) intrinsics

This patch adds implementations for the fill/spill SME ACLE intrinsics:

    @llvm.aarch64.sme.ldr
    @llvm.aarch64.sme.str

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

2 years ago[AMDGPU] Add a GFX11 MCA test
Jay Foad [Tue, 14 Jun 2022 12:39:11 +0000 (13:39 +0100)]
[AMDGPU] Add a GFX11 MCA test

This mostly just tests that DPFP is 1/32 rate on GFX11, instead of 1/16
rate as on GFX10.

2 years ago[flang] Support PDT declaration with initial comp value in internal procedure
Jean Perier [Tue, 14 Jun 2022 12:32:39 +0000 (14:32 +0200)]
[flang] Support PDT declaration with initial comp value in internal procedure

Lowering was crashing with "fatal internal error: node has not been analyzed"
if a PDT with initial component value was defined inside an internal
procedure. This is because the related expression cannot be analyzed
without the component values (which happens at the instatiation).
These expression do not need to be visited (the instantiations, if any
will be). Use the form of GetExpr that tolerates the parse tree expression
to not be analyzed into an evaluate::Expr when looking through the
symbols used in an internal procedure.

Note that the PDTs TODO will then fire (it happens after the PFT
analysis) as expected if the derived type is used.

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

2 years ago[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records
Lucas Prates [Fri, 6 May 2022 09:31:11 +0000 (10:31 +0100)]
[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

Currently the a AAPCS compliant frame record is not always created for
functions when it should. Although a consistent frame record might not
be required in some cases, there are still scenarios where applications
may want to make use of the call hierarchy made available trough it.

In order to enable the use of AAPCS compliant frame records whilst keep
backwards compatibility, this patch introduces a new command-line option
(`-mframe-chain=[none|aapcs|aapcs+leaf]`) for Aarch32 and Thumb backends.
The option allows users to explicitly select when to use it, and is also
useful to ensure the extra overhead introduced by the frame records is
only introduced when necessary, in particular for Thumb targets.

Reviewed By: efriedma

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

2 years ago[InterleavedLoadComb] Rename uses when inserting new uses.
Florian Hahn [Tue, 14 Jun 2022 12:15:23 +0000 (13:15 +0100)]
[InterleavedLoadComb] Rename uses when inserting new uses.

This fixes a crash due to uses needing to be renamed.

2 years agoRevert "Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder""
Jun Zhang [Tue, 14 Jun 2022 11:52:06 +0000 (19:52 +0800)]
Revert "Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder""

This reverts commit 781ee538da1855876b085989a37ec959e3f2ecd1.

Asan build is still broken :(

2 years ago[analyzer][Casting] Support isa, cast, dyn_cast of SVals
Balazs Benics [Tue, 14 Jun 2022 11:43:04 +0000 (13:43 +0200)]
[analyzer][Casting] Support isa, cast, dyn_cast of SVals

This change specializes the LLVM RTTI mechanism for SVals.
After this change, we can use the well-known `isa`, `cast`, `dyn_cast`.

Examples:

  // SVal V = ...;
  // Loc MyLoc = ...;

  bool IsInteresting = isa<loc::MemRegionVal, loc::GotoLabel>(MyLoc);
  auto MRV = cast<loc::MemRegionVal>(MyLoc);
  Optional<loc::MemRegionVal> MaybeMRV = dyn_cast<loc::MemRegionVal>(V)

The current `SVal::getAs` and `castAs` member functions are redundant at
this point, but I believe that they are still handy.

The member function version is terse and reads left-to-right, which IMO
is a great plus. However, we should probably add a variadic `isa` member
function version to have the same casting API in both cases.

Thanks for the extensive TMP help @bzcheeseman!

Reviewed By: bzcheeseman

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

2 years ago[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock
Serguei Katkov [Thu, 26 May 2022 04:51:36 +0000 (11:51 +0700)]
[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock

GetValueInMiddleOfBlock uses result of GetValueAtEndOfBlockInternal if there is no value
defined for current basic block.

If there is already a value it tries (in this order):

to find single register coming from all predecessors
find existing phi node which matches our incoming registers
build new phi.
The compile time improvement is to use current available value if
it is defined out of current BB or it is a PHI register.
This is due to it can be used in the middle basic block.

Reviewed By: sameerds
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D126523

2 years ago[NFC] Remove dead code
Guillaume Chatelet [Tue, 14 Jun 2022 09:55:55 +0000 (09:55 +0000)]
[NFC] Remove dead code

2 years ago[NFC][Alignment] Use MaybeAlign in CGCleanup/CGExpr
Guillaume Chatelet [Tue, 14 Jun 2022 09:55:27 +0000 (09:55 +0000)]
[NFC][Alignment] Use MaybeAlign in CGCleanup/CGExpr

2 years ago[NFC][Alignment] Use Align in CoroFrame
Guillaume Chatelet [Tue, 14 Jun 2022 09:52:45 +0000 (09:52 +0000)]
[NFC][Alignment] Use Align in CoroFrame

2 years ago[NFC][Alignment] Use Align in SafeStack
Guillaume Chatelet [Tue, 14 Jun 2022 09:50:54 +0000 (09:50 +0000)]
[NFC][Alignment] Use Align in SafeStack

2 years ago[NFC][Alignment] Use Align in shouldAlignPointerArgs
Guillaume Chatelet [Tue, 14 Jun 2022 09:46:14 +0000 (09:46 +0000)]
[NFC][Alignment] Use Align in shouldAlignPointerArgs

2 years ago[NFC][Alignment] use getAlign in AddressSanitizer
Guillaume Chatelet [Tue, 14 Jun 2022 08:45:20 +0000 (08:45 +0000)]
[NFC][Alignment] use getAlign in AddressSanitizer

2 years ago[AMDGPU] Add GFX11 llvm-objdump tests
Jay Foad [Tue, 14 Jun 2022 10:33:09 +0000 (11:33 +0100)]
[AMDGPU] Add GFX11 llvm-objdump tests

2 years agoReland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"
Jun Zhang [Tue, 14 Jun 2022 09:36:41 +0000 (17:36 +0800)]
Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

This reverts commits:
d3ddc251acae631bf5ab4da13878f7e8b5b5a451
d90eecff5c9e7e9f8263de6cd72d70322400829f

This relands below commit with asan fix:

The intent of this patch is to selectively carry some states over to
the Builder so we won't lose the information of the previous symbols.

This used to be several downstream patches of Cling, it aims to fix
errors in Clang Interpreter when trying to use inline functions.
Before this patch:

clang-repl> inline int foo() { return 42;}
clang-repl> int x = foo();

JIT session error: Symbols not found: [ _Z3foov ]
error: Failed to materialize symbols:
{ (main, { x, $.incr_module_1.__inits.0, __orc_init_func.incr_module_1 }) }

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D127730

2 years ago[AArch64][SME] Add load/store intrinsics
Rosie Sumpter [Mon, 6 Jun 2022 15:06:43 +0000 (16:06 +0100)]
[AArch64][SME] Add load/store intrinsics

This patch adds implementations for the load/store SME ACLE intrinsics:
  - @llvm.aarch64.sme.ld1*
  - @llvm.aarch64.sme.st1*

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

2 years ago[AMDGPU][MC][GFX11] Correct ds_swizzle_b32
Dmitry Preobrazhensky [Tue, 14 Jun 2022 09:56:38 +0000 (12:56 +0300)]
[AMDGPU][MC][GFX11] Correct ds_swizzle_b32

Enable offset parsing.

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

2 years ago[SCEV] Add tests where assumes can be used to improve trip multiple.
Alon Kom [Tue, 14 Jun 2022 09:50:22 +0000 (10:50 +0100)]
[SCEV] Add tests where assumes can be used to improve trip multiple.

Add tests combing assume on trip count divisibility (tc % vf) and minimum values (tc > N).
Github issue #55645

Reviewed By: fhahn

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

2 years ago[lldb] Fix TestDyldExecLinux with xml enabled
Pavel Labath [Tue, 14 Jun 2022 09:38:45 +0000 (11:38 +0200)]
[lldb] Fix TestDyldExecLinux with xml enabled

NativeProcessLinux is not able to properly read libraries-svr4 data when
running with ld.so as the "main" executable. Normally, this is not a big
problem, as it returns an error message, and lldb can fallback to manual
library loading.

Unfortunately, lldb-server also does not clear cached svr4 data on exec,
which means that it does *not* return an error when the application
execs from the "regular" to the "ld.so" mode. Instead it returns
incorrect data (it is missing the main executable) and causes
TestDyldExecLinux to fail (but only when building with xml support
enabled).

This patch makes ensures that cached process data is cleared on exec,
fixing the test. Since TestDyldExecLinux has shown to be sensitive to
the way we read library info, I fork it into two (with svr4 enabled and
disabled).

2 years ago[ConstraintElimination] Support constraints with only const ops.
Florian Hahn [Tue, 14 Jun 2022 09:37:12 +0000 (10:37 +0100)]
[ConstraintElimination] Support constraints with only const ops.

Remove the early exit if both constraints contain no variables. This
restriction is unnecessayr for correctness and removing it simplifies
handling of trivial constant conditions in follow-up changes.

2 years ago[llvm-cxxfilt] Add description for --types in help text
gbreynoo [Tue, 14 Jun 2022 09:32:56 +0000 (10:32 +0100)]
[llvm-cxxfilt] Add description for --types in help text

It appears that in the move to tablegen the description of --types was
lost:
https://reviews.llvm.org/D105605

This change adds the missing description.

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

2 years agoAdd lowering TODO for bindings returning derived types or arrays
Jean Perier [Tue, 14 Jun 2022 08:47:40 +0000 (10:47 +0200)]
Add lowering TODO for bindings returning derived types or arrays

Codegen does not support fir.addressof of functions returning derived
types, arrays are descriptors inside GlobalOp region.

This is because the  abstract-result-opt is required to rewrite such
functions (a hidden argument must be added), but this pass is meant to
run in GlobalOp currently.

Such fir.address_of may be created when lowering procedure pointers
initial value (TODO), or when creating derived type descriptors for
types with bindings.

Add a TODO in lowering until abstract-result-opt is modified to run
on GlobalOp too.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

2 years agoReland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1...
Balazs Benics [Tue, 14 Jun 2022 08:22:37 +0000 (10:22 +0200)]
Reland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"

It was previously reverted by 8406839d1926486de900c7cabeea9f841bd3edf2.

---

This flag was introduced by
https://github.com/llvm/llvm-project/commit/6818991d7165f68fe196922d9e5c6648dd57cc47
    commit 6818991d7165f68fe196922d9e5c6648dd57cc47
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
https://github.com/llvm/llvm-project/commit/5c32dfc5fb1cfcff8ae3671284e17daa8da3a188

    commit 5c32dfc5fb1cfcff8ae3671284e17daa8da3a188
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

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

2 years ago[Statepoints] FixupStatepoint: Clear isKill flag if COPY is not deleted.
Denis Antrushin [Wed, 8 Jun 2022 13:53:54 +0000 (20:53 +0700)]
[Statepoints] FixupStatepoint: Clear isKill flag if COPY is not deleted.

When spilling CSRs, FixupStatepoint pass does simple copy propagation,
trying to find COPY instruction which defines register being spilled
and spill COPY source instead. I.e., if we have CSR $x and found
  $x = COPY $y
we will spill $y instead.
But we may be unable to delete COPY instruction for some reason.
Then, spill will be inserted after it, adding another use of $y.
If COPY instruction was last use of $y (killed it), after insertion of
the spill it is not, so `isKill` flag must be cleared. We failed to do
so and this patch fixes this issue.

Reviewed By: skatkov

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

2 years ago[analyzer][NFC] Inline AnalyzerOptions::getUserMode()
Balazs Benics [Tue, 14 Jun 2022 07:42:58 +0000 (09:42 +0200)]
[analyzer][NFC] Inline AnalyzerOptions::getUserMode()

When I read the code I found it easier to reason about if `getUserMode`
is inlined. It might be a personal preference though.

Reviewed By: martong

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

2 years agoReland "[analyzer] Deprecate `-analyzer-store region` flag"
Balazs Benics [Tue, 14 Jun 2022 07:20:41 +0000 (09:20 +0200)]
Reland "[analyzer] Deprecate `-analyzer-store region` flag"

I'm trying to remove unused options from the `Analyses.def` file, then
merge the rest of the useful options into the `AnalyzerOptions.def`.
Then make sure one can set these by an `-analyzer-config XXX=YYY` style
flag.
Then surface the `-analyzer-config` to the `clang` frontend;

After all of this, we can pursue the tablegen approach described
https://discourse.llvm.org/t/rfc-tablegen-clang-static-analyzer-engine-options-for-better-documentation/61488

In this patch, I'm proposing flag deprecations.
We should support deprecated analyzer flags for exactly one release. In
this case I'm planning to drop this flag in `clang-16`.

In the clang frontend, now we won't pass this option to the cc1
frontend, rather emit a warning diagnostic reminding the users about
this deprecated flag, which will be turned into error in clang-16.

Unfortunately, I had to remove all the tests referring to this flag,
causing a mass change. I've also added a test for checking this warning.

I've seen that `scan-build` also uses this flag, but I think we should
remove that part only after we turn this into a hard error.

Reviewed By: martong

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

2 years ago[PowerPC] Correct test RUN line. NFC.
Kai Luo [Tue, 14 Jun 2022 06:55:28 +0000 (14:55 +0800)]
[PowerPC] Correct test RUN line. NFC.

2 years ago[lldb] Fix TCPSocket::Connect when getaddrinfo returns multiple addrs
Pavel Labath [Tue, 14 Jun 2022 06:44:48 +0000 (08:44 +0200)]
[lldb] Fix TCPSocket::Connect when getaddrinfo returns multiple addrs

TCPSocket::Connect() calls SocketAddress::GetAddressInfo() and tries to
connect any of them (in a for loop).

This used to work before commit 4f6d3a376c9f("[LLDB] Fix setting of
success in Socket::Close()") https://reviews.llvm.org/D116768.

As a side effect of that commit, TCPSocket can only connect to the first
address returned by SocketAddress::GetAddressInfo().

1. If the attempt to connect to the first address fails,
   TCPSocket::Connect(), calls CLOSE_SOCKET(GetNativeSocket()), which
   closes the fd, but DOES NOT set m_socket to kInvalidSocketValue.
2. On the second attempt, TCPSocket::CreateSocket() calls
   Socket::Close().
3. Socket::Close() proceeds, because IsValid() is true (m_socket was not
   reset on step 1).
4. Socket::Close() calls ::close(m_socket), which fails
5. Since commit 4f6d3a376c9f("[LLDB] Fix setting of success in
   Socket::Close()"), this is error is detected. Socket::Close() returns
   an error.
6. TCPSocket::CreateSocket() therefore returns an error.
7. TCPSocket::Connect() detects the error and continues, skipping the
   second (and the third, fourth...) address.

This commit fixes the problem by changing step 1: by calling
Socket::Close, instead of directly calling close(m_socket), m_socket is
also se to kInvalidSocketValue. On step 3, Socket::Close() is going to
return immediately and, on step 6, TCPSocket::CreateSocket() does not
fail.

How to reproduce this problem:

On my system, getaddrinfo() resolves "localhost" to "::1" (first) and to
"127.0.0.1" (second).

Start a gdbserver that only listens on 127.0.0.1:

```
gdbserver 127.0.0.1:2159 /bin/cat
Process /bin/cat created; pid = 2146709
Listening on port 2159
```

Start lldb and make it connect to "localhost:2159"

```
./bin/lldb
(lldb) gdb-remote localhost:2159
```

Before 4f6d3a376c9f("[LLDB] Fix setting of success in Socket::Close()"),
this used to work. After that commit, it stopped working. This commit
fixes the problem.

Reviewed By: labath

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

2 years ago[NFC] Fix Wswitch warning triggered by 735e6c
Chuanqi Xu [Tue, 14 Jun 2022 06:44:51 +0000 (14:44 +0800)]
[NFC] Fix Wswitch warning triggered by 735e6c

2 years ago[PowerPC][AtomicExpand] Precommit IR tests for D127609. NFC.
Kai Luo [Tue, 14 Jun 2022 06:22:29 +0000 (14:22 +0800)]
[PowerPC][AtomicExpand] Precommit IR tests for D127609. NFC.