LLVM/llvm 369271lld/trunk/ELF Relocations.cpp, lld/trunk/test/ELF x86-64-dyn-rel-error.s

[ELF] Simplify processRelocAux and allow a corner-case error

After D66007/r369262, if the control flow reaches `if (sym.isUndefined())`, we know:

* The relocation is not a link-time constant => symbol is preemptable => Undefined or 
SharedSymbol
* Not an undef weak.
* -no-pie.
* The symbol type is neither STT_OBJECT nor STT_FUNC.

ld.lld --export-dynamic --unresolved-symbols=ignore-all %t.o can satisfy
these conditions. Delete the isUndefined() test so that we error
`symbol '...' has no type`, because we don't know the type to make the
decision to create copy relocation/canonical PLT.

LLVM/llvm 369270libcxx/trunk/include memory

[libc++] reverts commit a5f5aad568bb7a91ceee47641f3076ac339ef8c7.

The commit being reverted caused segfaults when building
with libc++ and GCC (and possibly other configurations).

Differential Revision: https://reviews.llvm.org/D62868
DeltaFile
+260-110libcxx/trunk/include/memory
+260-1101 files

LLVM/llvm 369269llvm/trunk/lib/Support/Windows Path.inc, llvm/trunk/unittests/Support Path.cpp

Filesystem/Windows: fix inconsistency in readNativeFileSlice API

Summary:
The windows version implementation of readNativeFileSlice, was trying to
match the POSIX behavior of not treating EOF as an error, but it was
only handling the case of reading from a pipe. Attempting to read past
the end of a regular file returns a slightly different error code, which
needs to be handled too. This patch adds ERROR_HANDLE_EOF to the list of
error codes to be treated as an end of file, and adds some unit tests
for the API.

This issue was found while attempting to land D66224, which caused a bunch of
lldb tests to start failing on windows.

Reviewers: rnk, aganea

Subscribers: kristina, llvm-commits

Tags: #llvm

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

LLVM/llvm 369268llvm/trunk/lib/CodeGen/SelectionDAG TargetLowering.cpp, llvm/trunk/test/CodeGen/X86 srem-seteq-vec-nonsplat.ll

[TargetLowering] x s% C == 0 fold: vector divisor with INT_MIN handling

Summary:
The general fold is only valid for positive divisors.
Which effectively means, it is invalid for `INT_MIN` divisors,
and we currently bailout if we see them.

But that is too strict, we can just fix-up the results.
For that, let's do a second computation 'in parallel':
```
Name: srem -> and
Pre: isPowerOf2(C)
%o = srem i8 %X, C
%r = icmp eq %o, 0
  =>
%n = and i8 %X, C-1
%r = icmp eq %n, 0
```
https://rise4fun.com/Alive/Sup

And then just blend results: if the divisor was `INT_MIN`,
pick the value we got via bit-test,
else pick the value from general fold.

There's interesting observation - `ISD::ROTR` is set to

    [14 lines not shown]

LLVM/llvm 369267lldb/trunk/unittests/Utility CompletionRequestTest.cpp

[lldb][NFC] Stop using GetNumberOfMatches in CompletionRequest test

This function is just a wrapper for GetNumberOfResults and will
be removed soon. This patch just changes all calls to GetNumberOfResults
where possible (which is currently just the unit test).

LLVM/llvm 369266llvm/trunk/lib/Target/AArch64 AArch64InstructionSelector.cpp

[nfc] Silent gcc warning

LLVM/llvm 369265llvm/trunk/tools/llvm-objdump COFFDump.cpp

[llvm-objdump] - Restore lost comment.

It was removed by mistake in r369263 (D66417).

LLVM/llvm 369264llvm/trunk/test/CodeGen/X86 avx512-intel-ocl.ll avx512-nontemporal.ll

Automatically generate AVX512 test cases. NFC

LLVM/llvm 369263llvm/trunk/include/llvm/Object COFF.h, llvm/trunk/lib/Object COFFObjectFile.cpp

[Object/COFF.h] - Stop returning std::error_code in a few methods. NFCI.

There are 4 methods that return std::error_code now,
though they do not have to because they are always succeed.
I refactored them.

This allows to simplify the code in tools a bit.

LLVM/llvm 369262lld/trunk/ELF Relocations.cpp, lld/trunk/test/ELF copy-rel-pie-error.s copy-rel-pie2.s

[ELF] Move (copy relocation/canonical PLT) before error checking

In processRelocAux(), we handle errors before copy relocation/canonical PLT.
This makes error checking a bit complex because we have to check for
conditions that will be allowed by copy relocation/canonical PLT.

Instead, move copy relocation/canonical PLT before error checking. This
simplifies the previous clumsy error checking code

`config->shared || (config->pie && expr == R_ABS && type != target->symbolicRel)`

to the simple `config->isPic`. Some diagnostics can be reported in
different ways. The code motion changes diagnostics for some contrived
test cases:

* copy-rel-pie-error.s -> copy-rel-pie2.s:
  It was rejected before but accepted now. ld.bfd also accepts the case.
* copy-errors.s: "cannot preempt symbol" changes to "symbol 'bar' has no type"
* got32{,x}-i386.s: the suggestion changes from "-fPIC or -Wl,-z,notext" to "-fPIE"
* x86-64-dyn-rel-error5.s: one diagnostic changes for -pie case

Reviewed By: peter.smith

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

LLVM/llvm 369261llvm/trunk/lib/CodeGen PeepholeOptimizer.cpp, llvm/trunk/lib/Target/PowerPC PPCInstrVSX.td

[PeepholeOptimizer] Don't assume bitcast def always has input

Summary:
If we have a MI marked with bitcast bits, but without input operands,
PeepholeOptimizer might crash with assert.

eg:
If we apply the changes in PPCInstrVSX.td as in this patch:

[(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;

We will get assert in PeepholeOptimizer.

```
llvm-lit llvm-project/llvm/test/CodeGen/PowerPC/build-vector-tests.ll -v

llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:417: const
llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
const: Assertion `i < getNumOperands() && "getOperand() out of range!"'
failed.
```

The fix is to abort if we found out of bound access.

Reviewers: qcolombet, MatzeB, hfinkel, arsenm

    [9 lines not shown]

LLVM/llvm 369260lld/trunk/ELF/Arch Hexagon.cpp

[ELF][Hexagon] Improve error message for unknown relocations

Like rLLD354040

Previously, for unknown relocation types, in -no-pie/-pie mode, we got something like:

    foo.o: unrecognized relocation ...

In -shared mode:

    error: can't create dynamic relocation ... against symbol: yyy in readonly segment

Delete the default case from Hexagon::getRelExpr and add the error there. We will get 
consistent error message like `error: unknown relocation (1024) against symbol foo`

Reviewed By: sidneym

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

LLVM/llvm 369259cfe/trunk/lib/CodeGen CGLoopInfo.cpp CGLoopInfo.h, cfe/trunk/test/CodeGen loop-info-asan.c

Don't keep stale pointers to LoopInfos.

CGLoopInfo was keeping pointers to parent loop LoopInfos, but when the loop info vector 
grew, it reallocated the storage and invalidated all of the parent pointers, causing 
use-after-free. Manage the lifetimes of the LoopInfos separately so that the pointers 
aren't stale.

Patch by Bevin Hansson.

LLVM/llvm 369258lld/trunk/ELF/Arch Hexagon.cpp, lld/trunk/test/ELF hexagon-gotrel.s

[lld][Hexagon] Add GOTREL relocations.

Add GOTREL relocation support. (S + A - GOT)

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

LLVM/llvm 369257llvm/trunk/lib/Target/RISCV/MCTargetDesc RISCVAsmBackend.cpp, llvm/trunk/test/MC/RISCV linker-relaxation.s fde-reloc.s

[RISCV] Don't force absolute FK_Data_X fixups to relocs

The current behavior of shouldForceRelocation forces relocations for the
majority of fixups when relaxation is enabled. This makes sense for
fixups which incorporate symbols but is unnecessary for simple data
fixups where the fixup target is already resolved to an absolute value.

Differential Revision: https://reviews.llvm.org/D63404
Patch by Edward Jones.

LLVM/llvm 369256llvm/trunk/lib/CodeGen MIRPrinter.cpp, llvm/trunk/lib/CodeGen/MIRParser MIRParser.cpp

[DebugInfo] Allow bundled calls in the MIR's call site info

Summary:
Extend the MIR parser and writer so that the call site information can
refer to calls that are bundled.

Reviewers: aprantl, asowda, NikolaPrica, djtodoro, ivanbaev, vsk

Reviewed By: aprantl

Subscribers: arsenm, hiraditya, llvm-commits

Tags: #debug-info, #llvm

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

LLVM/llvm 369255llvm/trunk/test/Transforms/SLPVectorizer/X86 load-merge.ll

[SLP] add test that requires shuffle of scalars; NFC

LLVM/llvm 369254llvm/trunk/tools/llvm-readobj llvm-readobj.h

[llvm-readobj] unwrapOrError: remove unnecessary llvm_unreachable after r369194

LLVM/llvm 369253cfe/trunk/lib/Sema OpenCLBuiltins.td SemaLookup.cpp, cfe/trunk/test/SemaOpenCL fdeclare-opencl-builtins.cl

[OpenCL] Add generic type handling for builtin functions

Generic types are an abstraction of type sets.  It mimics the way
functions are defined in the OpenCL specification.  For example,
floatN can abstract all the vector sizes of the float type.

This allows to
 * stick more closely to the specification, which uses generic types;
 * factorize definitions of functions with numerous prototypes in the
   tablegen file; and
 * reduce the memory impact of functions with many overloads.

Patch by Pierre Gondois and Sven van Haastregt.

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

LLVM/llvm 369252lldb/trunk/source/Symbol Variable.cpp

[lldb][NFC] Use CompletionRequest in Variable::AutoComplete

LLVM/llvm 369251cfe/trunk/lib/Sema SemaType.cpp, cfe/trunk/test/SemaOpenCLCXX address-space-deduction.cl

[OpenCL] Fix addr space deduction for pointers/references to arrays.

Rewrite the logic for detecting if we are deducing addr space of
a pointee type to take into account special logic for arrays. For
pointers/references to arrays we can have any number of parentheses
expressions as well as nested pointers.

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

LLVM/llvm 369250llvm/trunk/lib/Transforms/Vectorize SLPVectorizer.cpp

[SLP] reduce duplicated code; NFC

LLVM/llvm 369249lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion TestCompletion.py

[lldb][NFC] Add a few more completion tests to increase test coverage

These tests are mostly trying to reach the different completion functions
in CommandCompletions.cpp (::ArchitectureNames, ::DiskFiles, ::Modules).

LLVM/llvm 369248llvm/trunk/lib/MC ELFObjectWriter.cpp

[MC] Simplify ELFObjectWriter::recordRelocation. NFC

LLVM/llvm 369247llvm/trunk/lib/CodeGen MachineSink.cpp, llvm/trunk/test/DebugInfo/MIR/X86 postra-subreg-sink.mir

[DebugInfo] Make postra sinking of DBG_VALUEs subregister-safe

Currently the machine instruction sinker identifies DBG_VALUE insts that
also need to sink by comparing register numbers. Unfortunately this isn't
safe, because (after register allocation) a DBG_VALUE may read a register
that aliases what's being sunk. To fix this, identify the DBG_VALUEs that
need to sink by recording & examining their register units. Register units
gives us the following guarantee:

  "Two registers overlap if and only if they have a common register unit"
  [MCRegisterInfo.h]

Thus we can always identify aliasing DBG_VALUEs if the set of register
units read by the DBG_VALUE, and the register units of the instruction
being sunk, intersect. (MachineSink already uses classes like
"LiveRegUnits" for determining sinking validity anyway).

The test added checks for super and subregister DBG_VALUE reads of a sunk
copy being sunk as well.

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

LLVM/llvm 369246lld/trunk/test/ELF arm-thunk-many-passes.s

[ELF][ARM] Add a test that maxes out the thunk convergence limit

Add a test that takes the maximum amount of passes permitted to converge.
This will make sure that any symbol defined in a linker script gets the
correct value and that any other convergence limit involving symbol address
doesn't restrict Thunk convergence.

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

LLVM/llvm 369245llvm/trunk/include/llvm/Target TargetSelectionDAG.td, llvm/trunk/lib/Target/ARM ARMTargetTransformInfo.cpp ARMTargetTransformInfo.h

[ARM] Add support for MVE vaddv

This patch adds vecreduce_add and the relevant instruction selection for
vaddv.

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

LLVM/llvm 369244llvm/trunk/lib/Target/ARM ARMTargetTransformInfo.cpp, llvm/trunk/test/Analysis/CostModel/ARM cast.ll

[ARM] MVE sext costs

This adds some sext costs for MVE, taken from the length of assembly sequences
that we currently generate.

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

LLVM/llvm 369243llvm/trunk/test/DebugInfo/MIR/X86 livedebugvars-crossbb-interval.mir

[DebugInfo] Test for variable range un-coalescing

LiveDebugVariables can coalesce ranges of variable locations across
multiple basic blocks. However when it recreates DBG_VALUE instructions,
it has to recreate one DBG_VALUE per block, otherwise it doesn't
represent the pre-regalloc layout and variable assignments can go missing.

This feature works -- however while mucking around with LiveDebugVariables,
I commented the relevant code it out and no tests failed. Thus, here's a
test that checks LiveDebugVariables preserves DBG_VALUEs across block
boundaries.

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

LLVM/llvm 369242lldb/trunk/include/lldb/Utility StringList.h, lldb/trunk/source/Commands CommandCompletions.cpp

[lldb][NFC] Remove StringList::AutoComplete

We don't need this very specific function in StringList that
we only call once in LLDB.

LLVM/llvm 369241llvm/trunk/lib/Transforms/IPO Attributor.cpp

Revert [Attributor] Fix: Make sure we set the changed flag

This reverts r369159 (git commit cbaf1fdea2de891bdbc49cdec89ae2077e6b9ed0)

r369160 caused a test to fail under UBSAN. See thread on llvm-commits.

LLVM/llvm 369240lldb/trunk/source/Commands CommandObjectApropos.cpp

[lldb][NFC] Use GetMaxStringLength in CommandObjectApropos::DoExecute

LLVM/llvm 369239llvm/trunk/lib/MC ELFObjectWriter.cpp, llvm/trunk/test/MC/AArch64 adr-diagnostics.s error-location.s

[MC] Delete unnecessary diagnostic: "No relocation available to represent this relative 
expression"

Replace

- error: No relocation available to represent this relative expression

with

+ error: symbol 'undef' can not be undefined in a subtraction expression

or

+ error: Cannot represent a difference across sections

Keep !IsPcRel as an assertion after the two diagnostic checks are done.

LLVM/llvm 369238clang-tools-extra/trunk/clangd SemanticHighlighting.cpp SemanticHighlighting.h, clang-tools-extra/trunk/clangd/test semantic-highlighting.test

[clangd] Added special HighlightingKind for function parameters.

Summary: This means that function parameters are no longer highlighted as 
variable.other.cpp but instead as variable.parameter.cpp which is the more "correct" 
TextMate scope for them.

Reviewers: hokein, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

LLVM/llvm 369237lldb/trunk/include/lldb/Utility StringList.h, lldb/trunk/source/Commands CommandObjectType.cpp

[lldb][NFC] Address review comments to StringList for-loop support

LLVM/llvm 369236llvm/trunk/lib/Transforms/IPO Attributor.cpp

Revert [Attributor] Fix: Do not partially resolve returned calls.

This reverts r369160 (git commit f72d9b1c97b41fff48ad1eecbba59a29c171bff4)

r369160 caused some tests to fail under UBSAN. See thread on llvm-commits.

LLVM/llvm 369235lldb/trunk/include/lldb/Utility RegularExpression.h

[lldb] Remove unused inheritance in RegularExpression

D66174 left inherited llvm::Regex which is now a member variable there.

Approved as a part of: https://reviews.llvm.org/D66392#1634575

LLVM/llvm 369234llvm/trunk/test/tools/llvm-objcopy/MachO basic-executable-copy.test, llvm/trunk/tools/llvm-objcopy/MachO MachOLayoutBuilder.cpp MachOWriter.cpp

Revert r369230 and r369231

Looks these commits break CI builds:

- http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-gn/builds/4159

This commit reverts r369230 and r369231 (git coommit: 4a198a7 and dee9546).

LLVM/llvm 369233llvm/trunk/lib/MC ELFObjectWriter.cpp, llvm/trunk/test/LTO/X86 symver-asm.ll

[MC] Don't emit .symver redirected symbols to the symbol table

GNU as keeps the original symbol in the symbol table for defined @ and
@@, but suppresses it in other cases (@@@ or undefined). The original
symbol is usually undesired:
In a shared object, the original symbol can be localized with a version
script, but it is hard to remove/localize in an archive:

1) a post-processing step removes the undesired original symbol
2) consumers (executable) of the archive are built with the
   version script

Moreover, it can cause linker issues like binutils PR/18703 if the
original symbol name and the base name of the versioned symbol is the
same (both ld.bfd and gold have some code to work around defined @ and
@@). In lld, if it sees f and f at v1:

  --version-script =(printf 'v1 {};') => f and f at v1
  --version-script =(printf 'v1 { f; };') => f at v1 and f@@v1

It can be argued that @@@ added on 2000-11-13 corrected the @ and @@ mistake.

This patch catches some more multiple version errors (defined @ and @@),
and consistently suppress the original symbol. This addresses all the
problems listed above.

    [6 lines not shown]

LLVM/llvm 369232llvm/trunk/lib/Target/X86 X86ISelLowering.cpp, llvm/trunk/test/CodeGen/X86 kshift.ll

[X86] Teach lower1BitShuffle to match right shifts with upper zero elements on types that 
don't natively support KSHIFT.

We can support these by widening to a supported type,
then shifting all the way to the left and then
back to the right to ensure that we shift in zeroes.

LLVM/llvm 369231llvm/trunk/test/tools/llvm-objcopy/MachO basic-executable-copy.test, llvm/trunk/tools/llvm-objcopy/MachO MachOLayoutBuilder.cpp

[llvm-objcopy][MachO] Implement a layout algorithm for executables

Summary: The layout algorithm for relocatable objects and for executable are somewhat 
different. This patch implements the latter one based on the algorithm in LLD 
(MachOFileLayout).

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap

Subscribers: jakehehrlich, abrachet, llvm-commits

Tags: #llvm

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

LLVM/llvm 369230llvm/trunk/tools/llvm-objcopy/MachO MachOLayoutBuilder.cpp MachOWriter.cpp

[llvm-objcopy][MachO] Support load commands used in executables/shared libraries

Summary:
This patch implements copying some load commands that appear in executables/shared 
libraries such as the indirect symbol table.

I don't add tests intentionally because this patch is incomplete: we need a layout 
algorithm for executables/shared libraries. I'll submit it as a separate patch with tests.

Reviewers: alexshap, rupprecht, jhenderson, compnerd

Reviewed By: alexshap

Subscribers: abrachet, mgorny, mgrang, MaskRay, mtrent, jakehehrlich, llvm-commits

Tags: #llvm

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

LLVM/llvm 369229clang-tools-extra/trunk/docs/clangd Features.rst

[clangd] Update features table in the docs with links to LSP extension proposals

Also update the semantic coloring entry to reflect it being supported in
clangd now.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

LLVM/llvm 369228llvm/trunk/lib/Target/X86 X86ISelLowering.cpp

[X86] Fix the lower1BitShuffle code added in r369215 to correctly pass the widened vector 
to the KSHIFT node.

Not sure how to test this as we have tests that exercise this code,
but nothing failed for the types not matching. Since all the k-registers
use equivalent register classes everything just ends up working.

LLVM/llvm 369227llvm/trunk/lib/Target/X86 X86ISelLowering.cpp, llvm/trunk/test/CodeGen/X86 kshift.ll

[X86] Teach lower1BitShuffle to match KSHIFTR that doesn't use Zeroable and only relies on 
undef.

This allows us to widen the type when the KSHIFTR instruction
doesn't exist for the type. If we need to shift in zeroes into
the upper elements we would need more work to guarantee zeroes
when widening.

LLVM/llvm 369226llvm/trunk/lib/Target/X86 X86ISelLowering.cpp, llvm/trunk/test/CodeGen/X86 avx512-skx-insert-subvec.ll

[X86] Teach lower1BitShuffle to recognize padding a subvector with zeros with V2 as the 
source and V1 as the zero vector.

Shuffle canonicalization can swap the sources so the zero vector
might be V1 and the subvector that's being padded can be V2.

LLVM/llvm 369225llvm/trunk/test/CodeGen/X86 avx512-skx-insert-subvec.ll

[X86] Add test case for missed opportunity to recognize a vXi1 shuffle as an insert into a 
zero vector.

We are currently missing this because shuffle canonicalization
puts the zero vector as V1 and the subvector as V2. Our current
code doesn't recognize this case.

LLVM/llvm 369224llvm/trunk/lib/Target/X86 X86ISelLowering.cpp, llvm/trunk/test/CodeGen/X86 avx512-skx-insert-subvec.ll

[X86] Add a special case to LowerCONCAT_VECTORSvXi1 to handle concatenating zero vectors 
followed by one non-zero vector followed by undef vectors.

For such a case we should only need a KSHIFTL, but we were
previously generating a KSHIFTL followed by a KSHIFTR because
we mistakenly believed we need to zero the undef elements.

LLVM/llvm 369223llvm/trunk/test/CodeGen/X86 avx512-skx-insert-subvec.ll

[X86] Add test cases for suboptimal insertion of a vXi1 vector into a larger vector with 
zeros in the lower elements and undef upper elements.

Currently we generate kshifts to clear both the upper and lower
elements, but we only need one kshift.

LLVM/llvm 369222llvm/trunk/lib/Target/X86 X86ISelLowering.cpp

[X86] Replace uses of getZeroVector for vXi1 vectors with DAG.getConstant.

vXi1 vectors don't need special handling.