platform/upstream/llvm.git
2 years ago[clang][dataflow] Generate readable form of input and output of satisfiability checking.
Wei Yi Tee [Tue, 12 Jul 2022 18:38:52 +0000 (18:38 +0000)]
[clang][dataflow] Generate readable form of input and output of satisfiability checking.

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

2 years ago[SCEV][NFC] Make getStrengthenedNoWrapFlagsFromBinOp return optional
Max Kazantsev [Wed, 13 Jul 2022 11:53:29 +0000 (18:53 +0700)]
[SCEV][NFC] Make getStrengthenedNoWrapFlagsFromBinOp return optional

2 years agoMove instruction predicate verification to emitInstruction
David Green [Wed, 13 Jul 2022 11:53:32 +0000 (12:53 +0100)]
Move instruction predicate verification to emitInstruction

D25618 added a method to verify the instruction predicates for an
emitted instruction, through verifyInstructionPredicates added into
<Target>MCCodeEmitter::encodeInstruction. This is a very useful idea,
but the implementation inside MCCodeEmitter made it only fire for object
files, not assembly which most of the llvm test suite uses.

This patch moves the code into the <Target>_MC::verifyInstructionPredicates
method, inside the InstrInfo.  The allows it to be called from other
places, such as in this patch where it is called from the
<Target>AsmPrinter::emitInstruction methods which should trigger for
both assembly and object files. It can also be called from other places
such as verifyInstruction, but that is not done here (it tends to catch
errors earlier, but in reality just shows all the mir tests that have
incorrect feature predicates). The interface was also simplified
slightly, moving computeAvailableFeatures into the function so that it
does not need to be called externally.

The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently
show errors in the test-suite, so have been disabled with FIXME
comments.

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

2 years ago[BOLT][AArch64] Handle gold linker veneers
Vladislav Khmelevsky [Wed, 6 Jul 2022 21:01:33 +0000 (00:01 +0300)]
[BOLT][AArch64] Handle gold linker veneers

The gold linker veneers are written between functions without symbols,
so we to handle it specially in BOLT.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

2 years ago[LLDB] Fix TestConvenienceVariables.test AArch64/Windows
Muhammad Omair Javaid [Wed, 13 Jul 2022 11:44:19 +0000 (16:44 +0500)]
[LLDB] Fix TestConvenienceVariables.test AArch64/Windows

This patch fixes TestConvenienceVariables.test for AArch64 Windows.
Clang/LLD was unable to find printf apparently available as a macro
definition in stdio.h.

2 years agoRevert "[libc++] Implement ranges::find_end, ranges::search{, _n}"
Nikolas Klauser [Wed, 13 Jul 2022 11:41:25 +0000 (13:41 +0200)]
Revert "[libc++] Implement ranges::find_end, ranges::search{, _n}"

This reverts commit 76a76518507ccc59ccdad5b83f44dc8c3d9593c7.

2 years ago[clang][dataflow] Rename `Status` field in a `Solver::Result` struct to `SATCheckStatus`.
Wei Yi Tee [Tue, 12 Jul 2022 18:38:36 +0000 (18:38 +0000)]
[clang][dataflow] Rename `Status` field in a `Solver::Result` struct to `SATCheckStatus`.

Previously, `Status` was named after the enum type `Status` which caused the enum to be hidden by the non-type declaration of the `Status` field. This patch fixes this issue by using different names for the field and type.

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

2 years ago[LLDB] Fix TestThreadAPI.py for AArch64/Windows
Muhammad Omair Javaid [Wed, 13 Jul 2022 11:28:25 +0000 (16:28 +0500)]
[LLDB] Fix TestThreadAPI.py for AArch64/Windows

This patch fixes TestThreadAPI for AArch64 windows by switching over to
PDB debug info instead of DWARF. This is needed to step over library
functions like printf as there is debug info mismatch between DWARF and
PDB. PDB DWARF interworking is not fully supported by LLDB at the
moment.

2 years ago[mlir][Linalg] Retire TestLinalgCodegenStrategy pass.
Nicolas Vasilache [Wed, 13 Jul 2022 10:14:58 +0000 (03:14 -0700)]
[mlir][Linalg] Retire TestLinalgCodegenStrategy pass.

This pass tests patterns that are already tested elsewhere by applying them in a semi-targeted
fashion using anchor function and op names.

From now on, targeted tests should use the transform dialect interpreter.

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

2 years ago[LLDB] XFail TestLoadUnload.test_static_init_during_load AArch64/Windows
Muhammad Omair Javaid [Wed, 13 Jul 2022 11:15:11 +0000 (16:15 +0500)]
[LLDB] XFail TestLoadUnload.test_static_init_during_load AArch64/Windows

This patch fixes marks TestLoadUnload.test_static_init_during_load as
xfail for AArch64 windows. It is failing similar to Linux and already
marked xfail for linux.

2 years ago[libc++] Implement ranges::find_end, ranges::search{, _n}
Nikolas Klauser [Tue, 12 Jul 2022 19:28:40 +0000 (21:28 +0200)]
[libc++] Implement ranges::find_end, ranges::search{, _n}

Reviewed By: var-const, #libc, huixie90

Spies: h-vetinari, huixie90, libcxx-commits, mgorny

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

2 years ago[Test] Add test showing that we can make a check loop-invariant
Max Kazantsev [Wed, 13 Jul 2022 11:01:09 +0000 (18:01 +0700)]
[Test] Add test showing that we can make a check loop-invariant

2 years ago[LLDB] Fix pointers.test for AArch64/Windows
Muhammad Omair Javaid [Wed, 13 Jul 2022 10:52:33 +0000 (15:52 +0500)]
[LLDB] Fix pointers.test for AArch64/Windows

pointers.test started failing again for AArch64 windows after D125509
This patch fixes the test to make it pass on AArch64 windows again.

LLDB AArch64 Windows buildbot running at:
https://lab.llvm.org/staging/#/builders/207

2 years ago[ARM] Fix subtarget features for Thumb2 tests. NFC
David Green [Wed, 13 Jul 2022 10:42:21 +0000 (11:42 +0100)]
[ARM] Fix subtarget features for Thumb2 tests. NFC

These mir tests were using instructions that require feature predicates
that were not enabled.

2 years ago[gn build] Port c9666d2339e5
LLVM GN Syncbot [Wed, 13 Jul 2022 10:35:56 +0000 (10:35 +0000)]
[gn build] Port c9666d2339e5

2 years ago[clang][dataflow] Generate readable form of boolean values.
Wei Yi Tee [Tue, 12 Jul 2022 18:36:26 +0000 (18:36 +0000)]
[clang][dataflow] Generate readable form of boolean values.

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

2 years ago[clang][dataflow] Refactor boolean creation as a test utility.
Wei Yi Tee [Tue, 12 Jul 2022 18:35:34 +0000 (18:35 +0000)]
[clang][dataflow] Refactor boolean creation as a test utility.

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

2 years ago[lld-macho] Add LOH_ARM64_ADRP_LDR_GOT_LDR optimization hint support
Daniel Bertalan [Sat, 9 Jul 2022 10:17:29 +0000 (12:17 +0200)]
[lld-macho] Add LOH_ARM64_ADRP_LDR_GOT_LDR optimization hint support

This hint instructs the linker to relax a GOT-indirect load.
If the referenced symbol is external and its GOT entry is within +/- 1
MiB, the GOT entry can be loaded with a single literal ldr instruction.
If the referenced symbol is local, its address may be loaded directly if
it's close enough, or with an adr(p) + ldr pair if it's not.

This type accounts for more than half of all LOHs in chromium_framework.

This commit moves the eligibility checks into helper functions to
improve the readability of the LOH processing code. Ho functional
changes are intended to the previously implemented LOH types.

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

2 years ago[clang][dataflow] Refactor boolean creation as a test utility.
Wei Yi Tee [Tue, 12 Jul 2022 18:47:18 +0000 (18:47 +0000)]
[clang][dataflow] Refactor boolean creation as a test utility.

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

2 years ago[InstCombine][SVE] Bail out of isSafeToLoadUnconditionally for scalable types
Peter Waller [Mon, 11 Jul 2022 10:56:15 +0000 (10:56 +0000)]
[InstCombine][SVE] Bail out of isSafeToLoadUnconditionally for scalable types

`isSafeToLoadUnconditionally` currently assumes sized types. Bail out for now.
This fixes a TypeSize warning reachable from instcombine via (load (select
cond, ptr, ptr)).

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

2 years ago[Test] Fix bailout blocks
Max Kazantsev [Wed, 13 Jul 2022 10:02:02 +0000 (17:02 +0700)]
[Test] Fix bailout blocks

2 years ago[PowerPC] Regenerate pr35402.ll test checks
Simon Pilgrim [Wed, 13 Jul 2022 10:01:26 +0000 (11:01 +0100)]
[PowerPC] Regenerate pr35402.ll test checks

2 years ago[lldb] Fix build with GCC 9 after "[ADT] Use Empty Base Optimization for Allocators"
Martin Storsjö [Wed, 13 Jul 2022 09:53:31 +0000 (12:53 +0300)]
[lldb] Fix build with GCC 9 after "[ADT] Use Empty Base Optimization for Allocators"

This fixes this compilation error, after
a565509308f9372c4de1c4c32afde461a42e81c8:

In file included from ../tools/lldb/include/lldb/Host/Host.h:14,
                 from ../tools/lldb/source/Host/common/File.cpp:28:
../tools/lldb/include/lldb/Utility/Environment.h: In copy constructor ‘lldb_private::Environment::Environment(const lldb_private::Environment&)’:
../tools/lldb/include/lldb/Utility/Environment.h:60:49: error: call of overloaded ‘StringMap(const lldb_private::Environment&)’ is ambiguous
   60 |   Environment(const Environment &RHS) : Base(RHS) {}
      |                                                 ^
In file included from ../include/llvm/Support/YAMLTraits.h:16,
                 from ../tools/lldb/include/lldb/Utility/ConstString.h:15,
                 from ../tools/lldb/include/lldb/Utility/FileSpec.h:15,
                 from ../tools/lldb/include/lldb/Host/FileSystem.h:14,
                 from ../tools/lldb/source/Host/common/File.cpp:27:
../include/llvm/ADT/StringMap.h:137:3: note: candidate: ‘llvm::StringMap<ValueTy, AllocatorTy>::StringMap(const llvm::StringMap<ValueTy, AllocatorTy>&) [with ValueTy = std::__cxx11::basic_string<char>; AllocatorTy = llvm::MallocAllocator]’
  137 |   StringMap(const StringMap &RHS)
      |   ^~~~~~~~~
../include/llvm/ADT/StringMap.h:122:12: note: candidate: ‘llvm::StringMap<ValueTy, AllocatorTy>::StringMap(AllocatorTy) [with ValueTy = std::__cxx11::basic_string<char>; AllocatorTy = llvm::MallocAllocator]’
  122 |   explicit StringMap(AllocatorTy A)
      |            ^~~~~~~~~

2 years ago[X86] Regenerate fp_constant_op.ll test checks
Simon Pilgrim [Wed, 13 Jul 2022 09:49:56 +0000 (10:49 +0100)]
[X86] Regenerate fp_constant_op.ll test checks

2 years ago[LAA] Precommit some extra tests for forked pointers
Graham Hunter [Tue, 12 Jul 2022 14:13:46 +0000 (15:13 +0100)]
[LAA] Precommit some extra tests for forked pointers

  * Converted tests to use opaque pointers
  * Added suggested test for inbounds GEP
  * Added a test for forks on both the base and offset terms of a GEP
  * Added a test for a select of a select
  * Added a test for a GEP with >2 operands
  * Added a test for vector GEPs

2 years agoUse has_value instead of hasValue (NFC)
Kazu Hirata [Wed, 13 Jul 2022 08:58:03 +0000 (01:58 -0700)]
Use has_value instead of hasValue (NFC)

2 years ago[AArch64][SVE] Prefer SIMD&FP variant of clast[ab]
Cullen Rhodes [Fri, 8 Jul 2022 15:18:27 +0000 (15:18 +0000)]
[AArch64][SVE] Prefer SIMD&FP variant of clast[ab]

The scalar variant with GPR source/dest has considerably higher latency
than the SIMD&FP scalar variant across a variety of micro-architectures:

  Core           Scalar    SIMD&FP
  --------------------------------
  Neoverse V1     9 cyc      3 cyc
  Neoverse N2     8 cyc      3 cyc
  Cortex A510     8 cyc      4 cyc
  A64FX          29 cyc      6 cyc

2 years ago[AsmParser] Fix a warning
Kazu Hirata [Wed, 13 Jul 2022 08:52:53 +0000 (01:52 -0700)]
[AsmParser] Fix a warning

This patch fixes:

  llvm/lib/AsmParser/LLParser.cpp:466:34: error: moving a temporary
  object prevents copy elision [-Werror,-Wpessimizing-move]

2 years ago[LoopVectorize] Ensure the VPReductionRecipe is placed after all it's inputs
David Sherwood [Mon, 11 Jul 2022 14:31:37 +0000 (15:31 +0100)]
[LoopVectorize] Ensure the VPReductionRecipe is placed after all it's inputs

When vectorising ordered reductions we call a function
LoopVectorizationPlanner::adjustRecipesForReductions to replace the
existing VPWidenRecipe for the fadd instruction with a new
VPReductionRecipe. We attempt to insert the new recipe in the same
place, but this is wrong because createBlockInMask may have
generated new recipes that VPReductionRecipe now depends upon. I
have changed the insertion code to append the recipe to the
VPBasicBlock instead.

Added a new RUN with tail-folding enabled to the existing test:

  Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll

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

2 years ago[IndVars] Simplify instructions after replacing header phi with preheader value
Nikita Popov [Thu, 7 Jul 2022 15:04:37 +0000 (17:04 +0200)]
[IndVars] Simplify instructions after replacing header phi with preheader value

After replacing a loop phi with the preheader value, it's usually
possible to simplify some of the using instructions, so do that as
part of replaceLoopPHINodesWithPreheaderValues().

Doing this as part of IndVars is valuable, because it may make GEPs
in the loop have constant offsets and allow the following SROA run
to succeed (as demonstrated in the PhaseOrdering test).

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

2 years ago[AsmParser] Report invalid data layout more gracefully
Nikita Popov [Wed, 13 Jul 2022 08:15:51 +0000 (10:15 +0200)]
[AsmParser] Report invalid data layout more gracefully

Report this as a normal LLParser error, rather than a fatal error.

2 years ago[Clang] Add a warning on invalid UTF-8 in comments.
Corentin Jabot [Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)]
[Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

Reviewed By: aaron.ballman, #clang-language-wg

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

2 years ago[AsmParser] Use toString() (NFC)
Nikita Popov [Wed, 13 Jul 2022 08:04:06 +0000 (10:04 +0200)]
[AsmParser] Use toString() (NFC)

2 years ago[RISCV] Add early-exit to RVV stack computation. NFCI.
Fraser Cormack [Wed, 13 Jul 2022 05:41:27 +0000 (06:41 +0100)]
[RISCV] Add early-exit to RVV stack computation. NFCI.

This patch was split off from D126465, where an early-exit is necessary
as it checks the VLEN and that asserts that V instructions are present.

Since this makes logical sense on its own, I think it's worth landing
regardless of D126465.

Reviewed By: kito-cheng

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

2 years ago[mlir] Use has_value instead of hasValue (NFC)
Kazu Hirata [Wed, 13 Jul 2022 07:57:02 +0000 (00:57 -0700)]
[mlir] Use has_value instead of hasValue (NFC)

2 years ago[IndVars] Call replaceLoopPHINodesWithPreheaderValues() for already constant exits
Nikita Popov [Wed, 6 Jul 2022 15:08:05 +0000 (17:08 +0200)]
[IndVars] Call replaceLoopPHINodesWithPreheaderValues() for already constant exits

Currently we only call replaceLoopPHINodesWithPreheaderValues() if
optimizeLoopExits() replaces the exit with an unconditional exit.
However, it is very common that this already happens as part of
eliminateIVComparison(), in which case we're leaving behind the
dead header phi.

Tweak the early bailout for already-constant exits to also call
replaceLoopPHINodesWithPreheaderValues().

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

2 years ago[AIX] follow-up of D124654.
esmeyi [Wed, 13 Jul 2022 07:39:08 +0000 (03:39 -0400)]
[AIX] follow-up of D124654.
Report an error when alias symbols are not emitted all.

2 years ago[ELF][RISCV] Use unshifted value for overflow check
Fangrui Song [Wed, 13 Jul 2022 07:28:29 +0000 (00:28 -0700)]
[ELF][RISCV] Use unshifted value for overflow check

The unshifted value indicates an displacement in bytes which is more meaningful.

2 years ago[LoongArch] Add codegen support for atomic fence, atomic load and atomic store
gonglingqin [Wed, 13 Jul 2022 07:14:09 +0000 (15:14 +0800)]
[LoongArch] Add codegen support for atomic fence, atomic load and atomic store

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

2 years ago[LoongArch] Add codegen support for converting between unsigned integer and floating...
gonglingqin [Wed, 13 Jul 2022 07:11:23 +0000 (15:11 +0800)]
[LoongArch] Add codegen support for converting between unsigned integer and floating-point

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

2 years ago[LoongArch] Add codegen support for fpround, fpextend and converting between signed...
gonglingqin [Wed, 13 Jul 2022 07:03:12 +0000 (15:03 +0800)]
[LoongArch] Add codegen support for fpround, fpextend and converting between signed integer and floating-point

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

2 years ago[InstCombine] add tests for xor_of_icmps. nfc
Chenbing Zheng [Wed, 13 Jul 2022 07:18:48 +0000 (15:18 +0800)]
[InstCombine] add tests for xor_of_icmps. nfc

2 years ago[ELF] Fix displacement computation for intra-section branch after D127611
Fangrui Song [Wed, 13 Jul 2022 07:17:17 +0000 (00:17 -0700)]
[ELF] Fix displacement computation for intra-section branch after D127611

D127611 computed st_value is inaccurate:

* For a backward branch, the destination address may be wrong if there is no
  relaxable relocation between it and the current location due to `if (remove)`.
  We may incorrectly relax a branch to c.j which ends up an overflow.
* For a forward branch, the destination address may be overestimated
  and lose relaxation opportunities.

To fix the issues,

* Don't reset st_value to the original value.
* Save the st_value delta from the previous iteration into valueDelta, and use
  `sa[0].d->value -= delta - valueDelta.find(sa[0].d)->second`.

2 years ago[mlir] Allow empty lists for DenseArrayAttr.
Adrian Kuegel [Wed, 13 Jul 2022 06:52:38 +0000 (08:52 +0200)]
[mlir] Allow empty lists for DenseArrayAttr.

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

2 years ago[libc][NFC] Move thread platform data pointer to thread attributes.
Siva Chandra Reddy [Wed, 13 Jul 2022 07:07:56 +0000 (07:07 +0000)]
[libc][NFC] Move thread platform data pointer to thread attributes.

Along the way, added constexpr constructors to the Thread data
structures.

2 years ago[RISCV][test] Add test of binop followed by extractelement.
jacquesguan [Tue, 12 Jul 2022 07:57:28 +0000 (15:57 +0800)]
[RISCV][test] Add test of binop followed by extractelement.

Reviewed By: reames

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

2 years ago[RISCV] Add scheduling resources for vector segment instructions.
Monk Chiang [Thu, 30 Jun 2022 06:17:57 +0000 (23:17 -0700)]
[RISCV] Add scheduling resources for vector segment instructions.

Add scheduling resources for vector segment instructions

Reviewed By: craig.topper

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

2 years ago[clang, clang-tools-extra] Use has_value instead of hasValue (NFC)
Kazu Hirata [Wed, 13 Jul 2022 05:47:41 +0000 (22:47 -0700)]
[clang, clang-tools-extra] Use has_value instead of hasValue (NFC)

2 years ago[llvm] Use has_value instead of hasValue (NFC)
Kazu Hirata [Wed, 13 Jul 2022 05:25:42 +0000 (22:25 -0700)]
[llvm] Use has_value instead of hasValue (NFC)

2 years ago[ELF][test] Remove unneeded --mcpu=future from llvm-objdump commands
Fangrui Song [Wed, 13 Jul 2022 04:08:52 +0000 (21:08 -0700)]
[ELF][test] Remove unneeded --mcpu=future from llvm-objdump commands

2 years ago[ELF][test] Remove unneeded --mcpu=pwr10 from llvm-objdump commands
Fangrui Song [Wed, 13 Jul 2022 04:07:45 +0000 (21:07 -0700)]
[ELF][test] Remove unneeded --mcpu=pwr10 from llvm-objdump commands

llvm-objdump has defaulted to decode all known instructions for PPC64.

2 years ago[mlir][sparse]Replace redundant indices checks in sparse_tensor.conversion
Anlun Xu [Wed, 6 Jul 2022 23:03:33 +0000 (16:03 -0700)]
[mlir][sparse]Replace redundant indices checks in sparse_tensor.conversion

Replace some redundant indices checks with the correct checks

Reviewed By: aartbik

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

2 years agoRe-land "[dsymutil] Account for DW_OP_convert being CU relative"
Jonas Devlieghere [Tue, 12 Jul 2022 21:18:19 +0000 (14:18 -0700)]
Re-land "[dsymutil] Account for DW_OP_convert being CU relative"

Currently, dsymutil treats the DW_OP_convert operand as absolute instead
of CU relative, as described by in the DWARFv5 spec, 2.5.1.6:

  "[DW_OP_convert] takes one operand, which is an unsigned LEB128 integer
  that represents the offset of a debugging information entry in the current
  compilation unit"

This patch makes dsymutil correctly treat the offset as CU relative,
preventing a crash when there are multiple compilation units.

Big thanks to Akira Hatanaka for figuring out this issue and providing
both a reduced test case and a proposed fix.

2 years ago[bazel] add missing gmock dependency to //clang/unittests:format_tests
Jorge Gorbe Moya [Wed, 13 Jul 2022 01:13:17 +0000 (18:13 -0700)]
[bazel] add missing gmock dependency to //clang/unittests:format_tests

2 years ago[lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Konstantin Varlamov [Wed, 13 Jul 2022 00:52:14 +0000 (17:52 -0700)]
[lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.

Change the mechanism in `iterator_operations.h` to pass around a generic
policy tag indicating whether an internal function is being invoked from
a "classic" STL algorithm or a ranges algorithm. `IterOps` is now
a template class specialized on the policy tag.

The advantage is that this mechanism is more generic and allows defining
arbitrary conditions in a clean manner.

Also add a few more iterator functions to `IterOps`.

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

2 years ago[NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp
Jorge Gorbe Moya [Wed, 13 Jul 2022 00:40:41 +0000 (17:40 -0700)]
[NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp

2 years ago[clang] Implement ElaboratedType sugaring for types written bare
Matheus Izvekov [Mon, 11 Oct 2021 16:15:36 +0000 (18:15 +0200)]
[clang] Implement ElaboratedType sugaring for types written bare

Without this patch, clang will not wrap in an ElaboratedType node types written
without a keyword and nested name qualifier, which goes against the intent that
we should produce an AST which retains enough details to recover how things are
written.

The lack of this sugar is incompatible with the intent of the type printer
default policy, which is to print types as written, but to fall back and print
them fully qualified when they are desugared.

An ElaboratedTypeLoc without keyword / NNS uses no storage by itself, but still
requires pointer alignment due to pre-existing bug in the TypeLoc buffer
handling.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D112374

2 years ago[NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when...
Jorge Gorbe Moya [Tue, 12 Jul 2022 23:46:07 +0000 (16:46 -0700)]
[NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled.

2 years ago[LinkerWrapper] Tweak save-temps output name
Joseph Huber [Tue, 12 Jul 2022 23:40:54 +0000 (19:40 -0400)]
[LinkerWrapper] Tweak save-temps output name

Summary:
A previous patch added the Task to the output filename when doing
`save-temps` the majority of cases there is only a single task so we
only add the task explicitly to differentiate it from the first one.

2 years agoRevert "[dsymutil] Account for DW_OP_convert being CU relative"
Nico Weber [Tue, 12 Jul 2022 23:36:21 +0000 (19:36 -0400)]
Revert "[dsymutil] Account for DW_OP_convert being CU relative"

This reverts commit 7f3000fa8b321f7fae169a615734de74a737b5d4.
Breaks tests on Windows, see commits on https://reviews.llvm.org/rG7f3000fa

2 years ago[trace] Avoid a crash in the dumper when disassembling fails
Walter Erquinigo [Tue, 12 Jul 2022 19:41:30 +0000 (12:41 -0700)]
[trace] Avoid a crash in the dumper when disassembling fails

In rare situations, disassemblying would fail that produce an invalid
InstructionSP object. We need to check that it's valid before using.

With this change, now the dumper doesn't crash with dumping instructions of
ioctl. In fact, it now dumps this output

 {
    "id": 6135,
    "loadAddress": "0x7f4bfe5c7515",
    "module": "libc.so.6",
    "symbol": "ioctl",
    "source": "glibc/2.34/src/glibc-2.34/sysdeps/unix/syscall-template.S",
    "line": 120,
    "column": 0
 }

Anyway, we need to investigate why the diassembler failed disassembling that
instruction. From over 2B instructions I was disassembling today, just this
one failed, so this could be a bug in LLVM's core disassembler.

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

2 years ago[trace] Add a flag to the decoder to output the instruction type
Walter Erquinigo [Tue, 12 Jul 2022 23:09:03 +0000 (16:09 -0700)]
[trace] Add a flag to the decoder to output the instruction type

To build complex binding upon instruction trace, additional metadata 'instruction type' is needed.

This diff has followings:
 - Add a flag -k  / --kind for instruction dump
 - Remove SetGranularity and SetIgnoreErros from Trace cursor

Sample output:

```
(lldb) thread trace dump instruction -k
thread #1: tid = 3198805
  libc.so.6`_IO_puts + 356
    2107: 0x00007ffff7163594 (    return)     retq
    2106: 0x00007ffff7163592 (     other)     popq   %r13
    2105: 0x00007ffff7163590 (     other)     popq   %r12
    2104: 0x00007ffff716358f (     other)     popq   %rbp
    2103: 0x00007ffff716358e (     other)     popq   %rbx
    2102: 0x00007ffff716358c (     other)     movl   %ebx, %eax
    2101: 0x00007ffff7163588 (     other)     addq   $0x8, %rsp
    2100: 0x00007ffff7163570 ( cond jump)     je     0x89588                   ; <+344>
    2099: 0x00007ffff716356e (     other)     decl   (%rdx)
    2098: 0x00007ffff7163565 ( cond jump)     je     0x8956e                   ; <+318>
    2097: 0x00007ffff716355e (     other)     cmpl   $0x0, 0x33c02b(%rip)      ; __libc_multiple_threads
    2096: 0x00007ffff7163556 (     other)     movq   $0x0, 0x8(%rdx)
    2095: 0x00007ffff7163554 ( cond jump)     jne    0x89588                   ; <+344>
    2094: 0x00007ffff7163550 (     other)     subl   $0x1, 0x4(%rdx)
    2093: 0x00007ffff7163549 (     other)     movq   0x88(%rbp), %rdx
    2092: 0x00007ffff7163547 ( cond jump)     jne    0x89588                   ; <+344>
    2091: 0x00007ffff7163540 (     other)     testl  $0x8000, (%rbp)           ; imm = 0x8000
    2090: 0x00007ffff716353c (     other)     cmovaq %rax, %rbx
    2089: 0x00007ffff7163535 (     other)     cmpq   $0x7fffffff, %rbx         ; imm = 0x7FFFFFFF
    2088: 0x00007ffff7163530 (     other)     movl   $0x7fffffff, %eax         ; imm = 0x7FFFFFFF
```

Reviewed By: wallace

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

2 years ago[mlir][vector] Fix crash in vector.reduction canonicalization
Thomas Raoux [Tue, 12 Jul 2022 22:44:39 +0000 (22:44 +0000)]
[mlir][vector] Fix crash in vector.reduction canonicalization

since vector.reduce support accumulator in all the cases remove the
assert assuming old definition.

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

2 years agoAdd coverage for missing (urem x, (lshr pow2, y)) -> (and x, (add (lshr pow2, y)...
Philip Reames [Tue, 12 Jul 2022 22:59:25 +0000 (15:59 -0700)]
Add coverage for missing (urem x, (lshr pow2, y)) -> (and x, (add (lshr pow2, y), -1)) transform

2 years ago[ADT] Use Empty Base Optimization for Allocators
Nathan James [Tue, 12 Jul 2022 22:57:03 +0000 (23:57 +0100)]
[ADT] Use Empty Base Optimization for Allocators

In D94439, BumpPtrAllocator changed its implementation to use an empty base optimization for the underlying allocator.
This patch builds on that by extending its functionality to more classes as well as enabling the underlying allocator to be a reference type, something not currently possible as you can't derive from a reference.

The main place this sees use is in StringMaps which often use the default MallocAllocator, yet have to pay the size of a pointer for no reason.

Reviewed By: dblaikie

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

2 years ago{RISCV] Test coverage for improved lowering assuming vscale is pow-of-two
Philip Reames [Tue, 12 Jul 2022 22:40:17 +0000 (15:40 -0700)]
{RISCV] Test coverage for improved lowering assuming vscale is pow-of-two

2 years agoRevert "[Clang] Add a warning on invalid UTF-8 in comments."
Jonas Devlieghere [Tue, 12 Jul 2022 22:16:14 +0000 (15:16 -0700)]
Revert "[Clang] Add a warning on invalid UTF-8 in comments."

This reverts commit cc309721d20c8e544ae7a10a66735ccf4981a11c because it
breaks the following tests on GreenDragon:

  TestDataFormatterObjCCF.py
  TestDataFormatterObjCExpr.py
  TestDataFormatterObjCKVO.py
  TestDataFormatterObjCNSBundle.py
  TestDataFormatterObjCNSData.py
  TestDataFormatterObjCNSError.py
  TestDataFormatterObjCNSNumber.py
  TestDataFormatterObjCNSURL.py
  TestDataFormatterObjCPlain.py
  TestDataFormatterObjNSException.py

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45288/

2 years ago[mlir][VectorToLLVM] Fix bug in lowering of vector.reduce fmax/fmin
Thomas Raoux [Tue, 12 Jul 2022 21:38:10 +0000 (21:38 +0000)]
[mlir][VectorToLLVM] Fix bug in lowering of vector.reduce fmax/fmin

The lowering of fmax/fmin reduce was ignoring the optional accumulator.

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

2 years ago[dsymutil] Account for DW_OP_convert being CU relative
Jonas Devlieghere [Tue, 12 Jul 2022 21:18:19 +0000 (14:18 -0700)]
[dsymutil] Account for DW_OP_convert being CU relative

Currently, dsymutil treats the DW_OP_convert operand as absolute instead
of CU relative, as described by in the DWARFv5 spec, 2.5.1.6:

  "[DW_OP_convert] takes one operand, which is an unsigned LEB128 integer
  that represents the offset of a debugging information entry in the current
  compilation unit"

This patch makes dsymutil correctly treat the offset as CU relative,
preventing a crash when there are multiple compilation units.

Big thanks to Akira Hatanaka for figuring out this issue and providing
both a reduced test case and a proposed fix.

2 years ago[lld-macho][nfc] Change force-load.s test to actually test
Jez Ng [Tue, 12 Jul 2022 21:54:18 +0000 (17:54 -0400)]
[lld-macho][nfc] Change force-load.s test to actually test

I'd forgotten to change a copypasted line...

2 years agoRevert "[GISel] Unify use of getStackGuard"
Kai Nacke [Tue, 12 Jul 2022 21:00:43 +0000 (17:00 -0400)]
Revert "[GISel] Unify use of getStackGuard"

This reverts commit e60b4fb2b777118c0ff664a6347851df14fcf75b.

2 years ago[X86] Move isInRange(ArrayRef<int>) inside assert to fix NDEBUG builds. NFC.
Simon Pilgrim [Tue, 12 Jul 2022 20:51:01 +0000 (21:51 +0100)]
[X86] Move isInRange(ArrayRef<int>) inside assert to fix NDEBUG builds. NFC.

Fix unused static function warning introduced by D129207

2 years ago[GISel] Unify use of getStackGuard
Kai Nacke [Tue, 12 Jul 2022 16:56:23 +0000 (12:56 -0400)]
[GISel] Unify use of getStackGuard

Some rework of getStackGuard() based on comments in
https://reviews.llvm.org/D129505.

- getStackGuard() now creates and returns the destination
  register, simplifying calls
- the pointer type is passed to getStackGuard() to avoid
  recomputation
- removed PtrMemTy in emitSPDescriptorParent(), because
  this type is only used here when loading the value but
  not when storing the value

Reviewed By: arsenm

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

2 years ago[Attributor] Don't crash if getAnalysisResultForFunction() returns null LoopInfo
Augie Fackler [Tue, 12 Jul 2022 20:03:34 +0000 (16:03 -0400)]
[Attributor] Don't crash if getAnalysisResultForFunction() returns null LoopInfo

I have no idea what's going on here. This code was moved
around/introduced in change cb26b01d57f5 and starts crashing with a NULL
dereference once I apply https://reviews.llvm.org/D123090. I assume that
I've unwittingly taught the attributor enough that it's able to do more
clever things than in the past, and it's able to trip on this case. I
make no claims about the correctness of this patch, but it passes tests
and seems to fix all the crashes I've been seeing.

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

2 years ago[lldb] Fix macOS Ventura version number checks
Jonas Devlieghere [Tue, 12 Jul 2022 20:27:30 +0000 (13:27 -0700)]
[lldb] Fix macOS Ventura version number checks

Unlike Python 2 which reports 10.16 on any recent macOS, Python 3
correctly reports Ventura as macOS 13.

2 years ago[mlir] Switch create to use NamedAttrList&&
Jacques Pienaar [Tue, 12 Jul 2022 20:24:09 +0000 (13:24 -0700)]
[mlir] Switch create to use NamedAttrList&&

Avoids needing the two parallel functions as NamedAttrList already takes care
of caching DictionaryAttr and implicitly can convert from either.

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

2 years ago[ORC] Remove unused function declaration. (NFC)
Sunho Kim [Tue, 12 Jul 2022 20:10:50 +0000 (05:10 +0900)]
[ORC] Remove unused function declaration. (NFC)

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

2 years ago[lldb] Make the g_arguments_data constexpr and fix the static assert
Jonas Devlieghere [Tue, 12 Jul 2022 17:56:01 +0000 (10:56 -0700)]
[lldb] Make the g_arguments_data constexpr and fix the static assert

This fixes the static assert that's meant to keep the g_arguments_data
table in sync with the CommandArgumentType enumeration. Indeed, the
assert didn't fire even though the current code is missing an entry.
This patches fixes that as well.

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

2 years ago[AMDGPU] Regenerate local-memory.amdgcn.ll test checks
Simon Pilgrim [Tue, 12 Jul 2022 20:09:34 +0000 (21:09 +0100)]
[AMDGPU] Regenerate local-memory.amdgcn.ll test checks

2 years ago[clangd] Remove `allCommitCharacters`
Sam McCall [Tue, 12 Jul 2022 17:50:07 +0000 (19:50 +0200)]
[clangd] Remove `allCommitCharacters`

This was added in 2a095ff6f5028b76, however it never worked with VSCode
due to bugs in vscode-languageclient
(https://github.com/microsoft/vscode-languageserver-node/issues/673).
Now that it does work, we can tell the interactions with text editing, with
snippets, and vscode's select-first-completion behavior are bad.

The spec is vague and clients could do something reasonable with the
current values. However they could clearly do something unreasonable
too, and over time behavior+spec tends to converge on VSCode's behavior.

This addresses https://github.com/clangd/vscode-clangd/pull/358
See also https://github.com/clangd/vscode-clangd/pull/358 which hotfixes
this on the client-side (as we can't apply this change retroactively to
clangd 12-14).

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

2 years agoPretty printer test fixes
David Blaikie [Tue, 12 Jul 2022 19:29:00 +0000 (19:29 +0000)]
Pretty printer test fixes

2 years ago[JITLink][COFF] Fix compiler warnings.
sunho [Tue, 12 Jul 2022 19:25:14 +0000 (04:25 +0900)]
[JITLink][COFF] Fix compiler warnings.

2 years agoSpeculatively fix this C DR test
Aaron Ballman [Tue, 12 Jul 2022 19:16:10 +0000 (15:16 -0400)]
Speculatively fix this C DR test

There is a failing bot:
http://45.33.8.238/macm1/40002/step_7.txt

It looks to be failing because of a regex and how it handles whitespace,
so modifying the CHECK line slightly to account for that.

2 years ago[libc++][test] Adds spaceship support to macros.
Mark de Wever [Tue, 12 Jul 2022 17:22:43 +0000 (19:22 +0200)]
[libc++][test] Adds spaceship support to macros.

This was already reviewed as D128603. This contains only the updates to
the test script.

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

2 years ago[clang/ios] Make -mios-version-min the canonical spelling over -miphoneos-version-min
Nico Weber [Tue, 12 Jul 2022 15:51:04 +0000 (11:51 -0400)]
[clang/ios] Make -mios-version-min the canonical spelling over -miphoneos-version-min

Like https://reviews.llvm.org/D129226, but for iOS.

No behavior change.

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

2 years ago[JITLink][COFF] Add missing REQUIRES: asserts.
Sunho Kim [Tue, 12 Jul 2022 19:05:08 +0000 (04:05 +0900)]
[JITLink][COFF] Add missing REQUIRES: asserts.
This fixes the buildbot failure in release only buildbots.

2 years ago[gn build] Port db995d72db14
LLVM GN Syncbot [Tue, 12 Jul 2022 18:54:07 +0000 (18:54 +0000)]
[gn build] Port db995d72db14

2 years ago[JITLink][COFF] Initial COFF support.
Sunho Kim [Tue, 12 Jul 2022 18:50:37 +0000 (03:50 +0900)]
[JITLink][COFF] Initial COFF support.

Adds initial COFF support in JITLink. This is able to run a hello world c program in x86 windows successfully.

Implemented
- COFF object loader
- Static local symbols
- Absolute symbols
- External symbols
- Weak external symbols
- Common symbols
- COFF jitlink-check support
- All COMDAT selection type execpt largest
- Implicit symobl size calculation
- Rel32 relocation with PLT stub.
- IMAGE_REL_AMD64_ADDR32NB relocation

Reviewed By: lhames

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

2 years ago[TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types.
Craig Topper [Sat, 9 Jul 2022 23:40:52 +0000 (16:40 -0700)]
[TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types.

To convert CTLZ to popcount we do

x = x | (x >> 1);
x = x | (x >> 2);
...
x = x | (x >>16);
x = x | (x >>32); // for 64-bit input
return popcount(~x);

This smears the most significant set bit across all of the bits
below it then inverts the remaining 0s and does a population count.

To support non-power of 2 types, the last shift amount must be
more than half of the size of the type. For i15, the last shift
was previously a shift by 4, with this patch we add another shift
of 8.

Fixes PR56457.

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

2 years ago[RISCV] Pre-commit test for PR56457. NFC
Craig Topper [Sat, 9 Jul 2022 23:39:57 +0000 (16:39 -0700)]
[RISCV] Pre-commit test for PR56457. NFC

2 years ago[LLD] Two tweaks to symbol ordering scheme
YongKang Zhu [Tue, 12 Jul 2022 18:34:12 +0000 (11:34 -0700)]
[LLD] Two tweaks to symbol ordering scheme

When `--symbol-ordering-file` is specified, the linker today will always put
hot contributions in the middle of cold ones when targeting RISC machine, so
to minimize the chances that branch thunks need be generated for hot code
calling into cold code. This is not necessary when user specifies an ordering
of read-only data (vs. function) symbols, or when output section is small such
that no branch thunk would ever be required. The latter is common for mobile
apps. For example, among all the native ARM64 libraries in Facebook Instagram
App for Android, 80% of them have text section smaller than 64KB and the
largest text section seen is less than 8MB, well below the distance that a
BRANCH26 can reach.

Reviewed By: MaskRay

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

2 years ago[libc++][NFC] Add MVS guard for locale_mgmt_zos.h
David Tenty [Mon, 11 Jul 2022 15:36:19 +0000 (11:36 -0400)]
[libc++][NFC] Add MVS guard for locale_mgmt_zos.h

This header need not be included on non-z/OS IBM platforms (and indeed
will add nothing when it is), so add a guard. This let's us remove the
header without things breaking when shipping libc++ for AIX.

Reviewed By: hubert.reinterpretcast, fanbo-meng

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

2 years agoChange default C dialect for PS5 to gnu17/gnu18.
Sunil Srivastava [Tue, 12 Jul 2022 18:13:11 +0000 (11:13 -0700)]
Change default C dialect for PS5 to gnu17/gnu18.

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

2 years agoBuild Windows releases with libxml enabled, to unbreak llvm-mt
Hans Wennborg [Tue, 12 Jul 2022 15:58:21 +0000 (17:58 +0200)]
Build Windows releases with libxml enabled, to unbreak llvm-mt

Recent CMake versions have started to prefer llvm-mt when using
clang-cl, which doesn't work at all when llvm-mt is built without
libxml which has been the case so far.

See https://github.com/llvm/llvm-project/issues/55817

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

2 years ago[lldb] Fix TestDataFormatterLibcxxString broken by D129490
Pavel Labath [Tue, 12 Jul 2022 18:05:20 +0000 (20:05 +0200)]
[lldb] Fix TestDataFormatterLibcxxString broken by D129490

We need to check for the error inside the value object to avoid reading
garbage through invalid (target) pointers.

2 years agoUpdate the status for more C DRs
Aaron Ballman [Tue, 12 Jul 2022 18:06:13 +0000 (14:06 -0400)]
Update the status for more C DRs

This mostly finishes the DRs in the 200s. There are a few DRs left
which will require more thought and work to test.

2 years agoReland "[LLDB][NFC] Decouple dwarf location table from DWARFExpression."
Zequan Wu [Tue, 12 Jul 2022 17:30:49 +0000 (10:30 -0700)]
Reland "[LLDB][NFC] Decouple dwarf location table from DWARFExpression."

This reland 227dffd0b6d78154516ace45f6ed28259c7baa48 and
562c3467a6738aa89203f72fc1d1343e5baadf3c with failed api tests fixed by keeping
function base file addres in DWARFExpressionList.

2 years ago[~NFC] Fix printf() type punning warning in asan_globals.cpp
Mitch Phillips [Tue, 12 Jul 2022 17:48:19 +0000 (10:48 -0700)]
[~NFC] Fix printf() type punning warning in asan_globals.cpp

2 years ago[coroutine] add nomerge function attribute to `llvm.coro.save`
Yuanfang Chen [Tue, 12 Jul 2022 17:39:16 +0000 (10:39 -0700)]
[coroutine] add nomerge function attribute to `llvm.coro.save`

It is illegal to merge two `llvm.coro.save` calls unless their
`llvm.coro.suspend` users are also merged. Marks it "nomerge" for
the moment.

This reverts D129025.

Alternative to D129025, which affects other token type users like WinEH.

Reviewed By: ChuanqiXu

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

2 years ago[libc++] Fixes CI.
Mark de Wever [Tue, 12 Jul 2022 17:38:28 +0000 (19:38 +0200)]
[libc++] Fixes CI.