platform/upstream/llvm.git
3 years agoRevert "Recommit [NFC] Refactor DiagnosticBuilder and PartialDiagnostic"
Reid Kleckner [Thu, 24 Sep 2020 18:14:05 +0000 (11:14 -0700)]
Revert "Recommit [NFC] Refactor DiagnosticBuilder and PartialDiagnostic"

This reverts commit 8e780a1653e6f87755a447e921b8f929d8b70996.

DiagnosticBuilder is a value type, created on the stack everywhere. IMO
we should not be adding a vtable to it, and making very operator<< use a
virtual interface. There are other feasible designs for implementing
this. The original review, D84362, was approved by @tra, who is
responsible for Clang's CUDA support, but it wasn't reviewed by @rsmith
or anyone responsible for clang's diagnostic library.

3 years agoRevert "Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host devic...
Reid Kleckner [Thu, 24 Sep 2020 18:13:42 +0000 (11:13 -0700)]
Revert "Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host device functions""

This reverts commit e39da8ab6a286ac777d5fe7799f1eb782cf99938.

This depends on a change that needs additional design review and needs
to be reverted.

3 years ago[APFloat] prevent NaN morphing into Inf on conversion (PR43907)
Sanjay Patel [Thu, 24 Sep 2020 17:44:29 +0000 (13:44 -0400)]
[APFloat] prevent NaN morphing into Inf on conversion (PR43907)

We shift the significand right on a truncation, but that needs to be made NaN-safe:
always set at least 1 bit in the significand.
https://llvm.org/PR43907

See D88238 for the likely follow-up (but needs some plumbing fixes before it can proceed).

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

3 years ago[SLP] Remove LHS and RHS from OperationData.
Craig Topper [Thu, 24 Sep 2020 16:55:39 +0000 (09:55 -0700)]
[SLP] Remove LHS and RHS from OperationData.

These were only really used for 2 things. One was to check if the operand matches the phi if it exists. The other was for the createOp method to build the reduction.

For the first case we still have the operation we just need to know how to index its operands. So I've modified getLHS/getRHS to just use the opcode/kind to know how to find the right operands on an instruction that is now passed in.

For the other case we had to create an OperationData object to set the LHS/RHS values and copy the opcode/kind from another object. We would then just call createOp on that temporary object. Instead I've made LHS/RHS arguments to createOp and removed all these temporary objects.

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

3 years ago[OPENMP]Fix PR47621: Variable used by task inside a template function is not made...
Alexey Bataev [Thu, 24 Sep 2020 13:07:24 +0000 (09:07 -0400)]
[OPENMP]Fix PR47621: Variable used by task inside a template function is not made firstprivate by default

Need to fix a check for the variable if it is declared in the inner
OpenMP region to be able to firstprivatize it.

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

3 years ago[Scalar] ConstantHoistingPass - iterate with const references. NFCI.
Simon Pilgrim [Thu, 24 Sep 2020 17:28:21 +0000 (18:28 +0100)]
[Scalar] ConstantHoistingPass - iterate with const references. NFCI.

Fix some clang-tidy warnings.

3 years ago[AArch64] Regenerate dag-numsignbits.ll checks
Simon Pilgrim [Thu, 24 Sep 2020 17:03:59 +0000 (18:03 +0100)]
[AArch64] Regenerate dag-numsignbits.ll checks

To improve the codegen diff in D87502

3 years ago[AMDGPU] global-isel support for RT
Stanislav Mekhanoshin [Thu, 17 Sep 2020 18:44:52 +0000 (11:44 -0700)]
[AMDGPU] global-isel support for RT

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

3 years ago[OPENMP]PR47606: Do not update the lastprivate item if it was captured by reference...
Alexey Bataev [Wed, 23 Sep 2020 19:27:51 +0000 (15:27 -0400)]
[OPENMP]PR47606: Do not update the lastprivate item if it was captured by reference as firstprivate data member.

No need to make final copy from the firsptrivate/lastprivate copy to the original item if the item is a data memeber.
Firstprivate copy creates a copy by reference and the original item gets
updated correctly when updating the lastprivate shared variable.

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

3 years ago[AArch64][GlobalISel] Implement __builtin_return_address for PAC-RET
Momchil Velikov [Thu, 24 Sep 2020 15:34:27 +0000 (16:34 +0100)]
[AArch64][GlobalISel] Implement __builtin_return_address for PAC-RET

This patch implements stripping of the PAC in the return address for GlobalISel.

Implementation for when not using GLobalISel is in
https://reviews.llvm.org/D75044 The analogous GCC patch is
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=a70d5d81c41048556fd86eaa1036018a6bfba115

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

3 years ago[IRSim][NFC] Removing dead variables from IRSimilarityIdentifier.cpp
Andrew Litteken [Thu, 24 Sep 2020 16:41:30 +0000 (11:41 -0500)]
[IRSim][NFC] Removing dead variables from IRSimilarityIdentifier.cpp

As informed by danielkiss.

Follow up to Differential Revision: https://reviews.llvm.org/D86972

3 years ago[OpenMP] cmake option LIBOMPTARGET_NVPTX_MAX_SM for nvptx device RTL
Ye Luo [Thu, 24 Sep 2020 16:39:22 +0000 (12:39 -0400)]
[OpenMP] cmake option LIBOMPTARGET_NVPTX_MAX_SM for nvptx device RTL

It allows customizing MAX_SM for non-flagship GPU and reduces graphic memory usage.

In addition, so far the size is hard-coded up to __CUDA_ARCH__ 700 and is already a hassle for 800.
Introduce MAX_SM for 800 and protect future arch

Reviewed By: JonChesterfield

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

3 years ago[lldb/examples] Add missing declaration in heap.py
Dave Lee [Wed, 23 Sep 2020 16:11:22 +0000 (09:11 -0700)]
[lldb/examples] Add missing declaration in heap.py

Add missing declaration for `malloc_get_all_zones` in heap.py.

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

3 years agoSema: add support for `__attribute__((__swift_newtype__))`
Saleem Abdulrasool [Fri, 11 Sep 2020 20:35:04 +0000 (20:35 +0000)]
Sema: add support for `__attribute__((__swift_newtype__))`

Add the `swift_newtype` attribute which allows a type definition to be
imported into Swift as a new type.  The imported type must be either an
enumerated type (enum) or an object type (struct).

This is based on the work of the original changes in
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c

Differential Revision: https://reviews.llvm.org/D87652
Reviewed By: Aaron Ballman

3 years ago[clang] use string tables for static diagnostic descriptions
Nathan Froyd [Thu, 24 Sep 2020 14:54:28 +0000 (10:54 -0400)]
[clang] use string tables for static diagnostic descriptions

Using a pointer for the description string in StaticDiagInfoRec causes
several problems:

1. We don't need to use a whole pointer to represent the string;
2. The use of pointers incurs runtime relocations for those pointers;
   the relocations take up space on disk and represent runtime overhead;
3. The need to relocate data implies that, on some platforms, the entire
   array containing StaticDiagInfoRecs cannot be shared between processes.

This patch changes the storage scheme for the diagnostic descriptions to
avoid these problems.  We instead generate (effectively) one large
string and then StaticDiagInfoRec conceptually holds offsets into the
string.  We elected to also move the storage of those offsets into a
separate array to further reduce the space required.

On x86-64 Linux, this change removes about 120KB of relocations and
moves about 60KB from the non-shareable .data.rel.ro section to
shareable .rodata.  (The array is about 80KB before this, but we
eliminated 4 bytes/entry by using offsets rather than pointers.)  We
actually reap this benefit twice, because these tables show up in both
libclang.so and libclang-cpp.so and we get the reduction in both places.

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

3 years ago[X86][SSE] combineVectorTruncation - enable (pre-SSSE3) vXi16->vXi8 truncation.
Simon Pilgrim [Thu, 24 Sep 2020 14:28:12 +0000 (15:28 +0100)]
[X86][SSE] combineVectorTruncation - enable (pre-SSSE3) vXi16->vXi8 truncation.

Shuffle combining can now handle this output, and by performing this early in combineVectorTruncation we avoid a scalarization that caused a regression on D87502.

3 years ago[OpenMP] Fix if0 task with dependencies in the runtime
Peyton, Jonathan L [Mon, 7 Sep 2020 07:28:38 +0000 (02:28 -0500)]
[OpenMP] Fix if0 task with dependencies in the runtime

The current GOMP interface for serialized tasks does not take into
account task dependencies. Add the check and wait for dependencies.

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

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

3 years ago[OpenMP] Introduce GOMP taskwait depend in the runtime
Peyton, Jonathan L [Mon, 7 Sep 2020 05:37:55 +0000 (00:37 -0500)]
[OpenMP] Introduce GOMP taskwait depend in the runtime

This change introduces the GOMP_taskwait_depend() function. It implements
the OpenMP 5.0 feature of #pragma omp taskwait with depend() clause by
wrapping around __kmpc_omp_wait_deps().

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

3 years ago[OpenMP] Introduce GOMP mutexinoutset in the runtime
Peyton, Jonathan L [Mon, 7 Sep 2020 05:37:36 +0000 (00:37 -0500)]
[OpenMP] Introduce GOMP mutexinoutset in the runtime

Encapsulate GOMP task dependencies in separate class and introduce the
new mutexinoutset dependency type. This separate class allows
future GOMP task APIs easier access to the task dependency functionality
and better ability to propagate new dependency types to all existing GOMP
task APIs which use task dependencies.

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

3 years ago[OpenMP] Introduce GOMP teams support in runtime
Peyton, Jonathan L [Thu, 3 Sep 2020 19:47:13 +0000 (14:47 -0500)]
[OpenMP] Introduce GOMP teams support in runtime

Implement GOMP_teams_reg() function which enables GOMP support of the
standalone teams construct. The GOMP_parallel* functions were modified
to call __kmp_fork_call() unconditionally so that the teams-specific
code could be reused within __kmp_fork_call() instead of reproduced
inside the GOMP_* functions.

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

3 years ago[NFC][ARM] Remove dead loop.
Sam Parker [Thu, 24 Sep 2020 14:29:05 +0000 (15:29 +0100)]
[NFC][ARM] Remove dead loop.

Remove a loop that just calculated a couple of values that were now
longer needed.

3 years ago[RegisterCoalescer] Fix IMPLICIT_DEF init removal for a register on joining
vpykhtin [Thu, 24 Sep 2020 14:23:51 +0000 (17:23 +0300)]
[RegisterCoalescer] Fix IMPLICIT_DEF init removal for a register on joining

This patch removes redundant IMPLICIT_DEF for subregs which was leading to
incorrect register initialization on joining in some cases.

Reviewed by: qcolombet

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

3 years ago[AMDGPU] Use cast instead of dyn_cast
Jay Foad [Thu, 24 Sep 2020 13:37:17 +0000 (14:37 +0100)]
[AMDGPU] Use cast instead of dyn_cast

3 years ago[AMDGPU] Fix v3f16 handling for getresinfo
Sebastian Neubauer [Wed, 23 Sep 2020 16:01:40 +0000 (18:01 +0200)]
[AMDGPU] Fix v3f16 handling for getresinfo

v3f32 should not be expanded to v4f32. getresinfo with a dmask of 7
created an image sample with a v3f32 return value, which was bitcasted
to a v4f32 in constructRetValue.

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

3 years agoIR: Have byref imply dereferenceable
Matt Arsenault [Thu, 25 Jun 2020 23:17:24 +0000 (19:17 -0400)]
IR: Have byref imply dereferenceable

The langref already states it does, but this wasn't implemented. Also
covers inalloca and preallocated. Also helps fix a dependence on
pointer element types.

3 years agoOpaquePtr: Add helpers for sret to mirror byval
Matt Arsenault [Wed, 23 Sep 2020 15:03:38 +0000 (11:03 -0400)]
OpaquePtr: Add helpers for sret to mirror byval

Sret should really have a type parameter like byval does.

3 years ago[MLIR][SPIRV] Fixed dialect loading in deserialization
George Mitenkov [Thu, 24 Sep 2020 13:49:19 +0000 (16:49 +0300)]
[MLIR][SPIRV] Fixed dialect loading in deserialization

Fixed an error when deserializing the SPIR-V binary
to MLIR SPIR-V. Before, the SPIR-V dialect was not loaded
explicitly into the context, which resulted in unregistered
operation error.

Reviewed By: antiagainst

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

3 years ago[PhaseOrdering] move test with target requirement to x86 dir
Sanjay Patel [Thu, 24 Sep 2020 13:54:14 +0000 (09:54 -0400)]
[PhaseOrdering] move test with target requirement to x86 dir

I'm not sure if the target is actually necessary,
but since it was specified, I'm moving to the
appropriate dir to avoid bot fallout.

3 years ago[PhaseOrdering] move an 'opt' test from x86 codegen; NFC
Sanjay Patel [Thu, 24 Sep 2020 13:47:38 +0000 (09:47 -0400)]
[PhaseOrdering] move an 'opt' test from x86 codegen; NFC

This file comes from 2007, and I'm not entirely sure of the
motivation, but it was going through all of opt and llc.
The llc part is almost certainly unnecessary as shown in
the now auto-generated FileCheck lines.

This test may be affected by a logic change suggested in:
D87835

3 years ago[InstCombine] regenerate test checks; NFC
Sanjay Patel [Thu, 24 Sep 2020 13:33:56 +0000 (09:33 -0400)]
[InstCombine] regenerate test checks; NFC

3 years agolld: Try to fix check-lld on incremental builds after 8f2c31f22b974da
Nico Weber [Thu, 24 Sep 2020 13:33:46 +0000 (09:33 -0400)]
lld: Try to fix check-lld on incremental builds after 8f2c31f22b974da

3 years ago[NFC][RISCV][builtins] Remove some hard-coded values from i-cache clear routine
Alexey Baturo [Thu, 24 Sep 2020 09:04:35 +0000 (10:04 +0100)]
[NFC][RISCV][builtins] Remove some hard-coded values from i-cache clear routine

Remove some hard-coded values from i-cache clear routine

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

3 years ago[MLIR] Normalize memrefs in LoadOp and StoreOp of Standard Ops
Haruki Imai [Thu, 24 Sep 2020 04:04:29 +0000 (09:34 +0530)]
[MLIR] Normalize memrefs in LoadOp and StoreOp of Standard Ops

Added a trait, `MemRefsNormalizable` in LoadOp and StoreOp of Standard Ops
to normalize input memrefs in LoadOp and StoreOp.

Related revision: https://reviews.llvm.org/D86236

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

3 years agoFix f5314d15af4f4514103ea12c74cb208538b8bef5 - [Support] On Unix, let the CrashRecove...
Alexandre Ganea [Thu, 24 Sep 2020 13:07:13 +0000 (09:07 -0400)]
Fix f5314d15af4f4514103ea12c74cb208538b8bef5 - [Support] On Unix, let the CrashRecoveryContext return the signal code

This was causing bots to fail: http://green.lab.llvm.org/green/job/clang-stage1-RA/14828/consoleFull#6384962949ba4694-19c4-4d7e-bec5-911270d8a58c

3 years agoImprove 723fea23079f9c85800e5cdc90a75414af182bfd - Silence 'warning: unused variable...
Alexandre Ganea [Thu, 24 Sep 2020 12:24:10 +0000 (08:24 -0400)]
Improve 723fea23079f9c85800e5cdc90a75414af182bfd - Silence 'warning: unused variable' when compiling with Clang 10.0

3 years agoRecommit "[CUDA][HIP] Defer overloading resolution diagnostics for host device functions"
Yaxun (Sam) Liu [Wed, 23 Sep 2020 22:00:23 +0000 (18:00 -0400)]
Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host device functions"

This recommits 7f1f89ec8d9944559042bb6d3b1132eabe3409de and
40df06cdafc010002fc9cfe1dda73d689b7d27a6 after fixing memory
sanitizer failure.

3 years ago[AArch64] Regenerate dag-combine-mul-shl.ll checks
Simon Pilgrim [Thu, 24 Sep 2020 12:41:47 +0000 (13:41 +0100)]
[AArch64] Regenerate dag-combine-mul-shl.ll checks

3 years ago[ARM] LowoverheadLoops: add an option to disable tail-predication
Sjoerd Meijer [Thu, 24 Sep 2020 10:47:30 +0000 (11:47 +0100)]
[ARM] LowoverheadLoops: add an option to disable tail-predication

This might be useful for testing. We already have an option -tail-predication
but that controls the MVETailPredication pass.  This
-arm-loloops-disable-tail-pred is just for disabling it in the LowoverheadLoops
pass.

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

3 years ago[ARM] Check for LSTP side-effects.
Sam Parker [Thu, 24 Sep 2020 11:55:17 +0000 (12:55 +0100)]
[ARM] Check for LSTP side-effects.

If the LSTP instruction is inserted with an element count low enough
to immediately predicate some lanes as false, this can have some
unintended effects on any proceeding MVE instructions in the
preheader.

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

3 years ago[Support] On Unix, let the CrashRecoveryContext return the signal code
Alexandre Ganea [Thu, 24 Sep 2020 12:14:45 +0000 (08:14 -0400)]
[Support] On Unix, let the CrashRecoveryContext return the signal code

Before this patch, the CrashRecoveryContext was returning -2 upon a signal, like ExecuteAndWait does. This didn't match the behavior on Windows, where the the exception code was returned.

We now return the signal's code, which optionally allows for re-throwing the signal later. Doing so requires all custom handlers to be removed first, through llvm::sys::unregisterHandlers() which we made a public API.

This is part of https://reviews.llvm.org/D70378

3 years ago[lit] Support running tests on Windows without GnuWin32
Zachary Turner [Wed, 23 Sep 2020 21:19:21 +0000 (17:19 -0400)]
[lit] Support running tests on Windows without GnuWin32

Historically, we have told contributors that GnuWin32 is a pre-requisite
because our tests depend on utilities such as sed, grep, diff, and more.
However, Git on Windows includes versions of these utilities in its
installation.  Furthermore, GnuWin32 has not been updated in many years.
For these reasons, it makes sense to have the ability to run llvm tests
in a way that is both:
  a) Easier on the user (less stuff to install)
  b) More up-to-date (The verions that ship with git are at least as
     new, if not newer, than the versions in GnuWin32.

We add support for this here by attempting to detect where Git is
installed using the Windows registry, confirming the existence of
several common Unix tools, and then adding this location to lit's PATH
environment.

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

3 years ago[Support] On Windows, ensure abort() can be catched several times in a row with Crash...
Alexandre Ganea [Tue, 22 Sep 2020 22:22:01 +0000 (18:22 -0400)]
[Support] On Windows, ensure abort() can be catched several times in a row with CrashRecoveryContext

Before this patch, the CrashRecoveryContext would only catch the first abort(). Any further calls to abort() inside subsquent CrashRecoveryContexts would not be catched. This is because the Windows CRT removes the abort() handler before calling it.

This is part of https://reviews.llvm.org/D70378

3 years agoFix a builtbot failure after 3ed04f93e30121867a813a220452b97aebeb1730.
Alexey Lapshin [Thu, 24 Sep 2020 12:07:18 +0000 (15:07 +0300)]
Fix a builtbot failure after 3ed04f93e30121867a813a220452b97aebeb1730.

3 years ago [flang] [OpenMP 4.5] Adding lit test cases for OpenMP Constructs.
Praveen G [Thu, 24 Sep 2020 12:08:11 +0000 (13:08 +0100)]
[flang] [OpenMP 4.5] Adding lit test cases for OpenMP Constructs.

 1. Section 2.5   : Parallel Construct
 2. Section 2.7.1 : Loop Construct
 3. Section 2.7.2 : Sections Construct
 4. Section 2.7.3 : Single Construct
 5. Section 2.7.4 : Workshare Construct
 6. Section 2.8.1 : Simd Construct
 7. Section 2.8.3 : Loop Simd Construct
 8. Section 2.9.1 : Task Construct
 9. Section 2.9.2 : Taskloop Construct
10. Section 2.9.3 : Taskloop Simd Construct

Most of the test cases added as part of this change contains semantic errors except few cases which are semantically correct but thrown a semantic error.

Currently flang is not throwing the errors for these cases and throwing semantic errors for the following correct test cases

{omp-do03.f90 , omp-loop-simd01.f90 , omp-simd02.f90 , omp-taskloop01.f90}

Hence, all the test cases are marked as XFAIL.

Reviewed By: DavidTruby

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

3 years ago[flang][driver] Remove unnecessary includes in the unittest (NFC)
Andrzej Warzynski [Thu, 24 Sep 2020 11:54:07 +0000 (12:54 +0100)]
[flang][driver] Remove unnecessary includes in the unittest (NFC)

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

3 years ago[APFloat] add tests for convert of NAN; NFC
Sanjay Patel [Thu, 24 Sep 2020 11:29:18 +0000 (07:29 -0400)]
[APFloat] add tests for convert of NAN; NFC

More coverage for the bug fix proposed in D87835.

3 years ago[llvm-objcopy][NFC] refactor error handling. part 1.
Alexey Lapshin [Tue, 22 Sep 2020 17:47:02 +0000 (20:47 +0300)]
[llvm-objcopy][NFC] refactor error handling. part 1.

Remove usages of special error reporting functions(error(),
reportError()). This patch is extracted from D87987.
Errors are reported as Expected<>/Error returning values.
This part is for MachO subfolder of llvm-objcopy.

Testing: check-all.

Reviewed By: jhenderson, alexshap

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

3 years ago[NFC][Docs] fix clang-docs compilation
Jonas Toth [Thu, 24 Sep 2020 11:13:27 +0000 (13:13 +0200)]
[NFC][Docs] fix clang-docs compilation

3 years ago[lld][ELF][test] Add a couple of test cases for LTO behaviour
James Henderson [Tue, 22 Sep 2020 13:36:53 +0000 (14:36 +0100)]
[lld][ELF][test] Add a couple of test cases for LTO behaviour

This patch expands two LTO test cases to check other aspects.

1) weak.ll has been expanded to show that it doesn't matter whether the
   first appearance of a weak symbol appears in a bitcode file or native
   object - that one is picked.
2) reproduce-lto.ll has been expanded to show that the bitcode files are
   stored in the reproduce package and that intermediate files (such as
   the LTO-compiled object) are not.

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

Reviewed by: grimar, MaskRay

3 years agoUse different name for auto variable
Serge Pavlov [Thu, 24 Sep 2020 10:27:27 +0000 (17:27 +0700)]
Use different name for auto variable

Without this change GCC 5.4.0 failed to compile JSON.cpp with the error:

    .../llvm-project/llvm/lib/Support/JSON.cpp: In lambda function:
    .../llvm-project/llvm/lib/Support/JSON.cpp:291:29: error: use of 'V' before deduction of 'auto'
           for (const auto &V : *V.getAsArray())

3 years ago[llvm-readelf/obj] - Stop printing wrong addresses for arm32 unwind info for non...
Georgii Rymar [Mon, 21 Sep 2020 15:07:49 +0000 (18:07 +0300)]
[llvm-readelf/obj] - Stop printing wrong addresses for arm32 unwind info for non-relocatable objects.

This is the first patch for https://bugs.llvm.org/show_bug.cgi?id=47581.

Currently -u does not compute function addresses correctly and
dumps broken addresses for non-relocatable objects.

ARM spec says:
"An index table entry consists of 2 words.
The first word contains a prel31 offset (see Relocations) to the start of a function, with bit 31 clear."
...
"The relocated 31 bits form a place-relative signed offset to the referenced entity.
For brevity, this document will refer to the results of these relocations as "prel31 offsets"."

(https://developer.arm.com/documentation/ihi0038/c/?lang=en#index-table-entries)
(https://developer.arm.com/documentation/ihi0038/c/?lang=en#relocations)

Currently we use an address of the SHT_ARM_EXIDX section instead of an address of an entry
in computations. As a result we compute an offset that is not really "place-relative",
but section relative, what is wrong.

The patch fixes this issue.

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

3 years ago[llvm-readobj] - Fix a warning.
Georgii Rymar [Thu, 24 Sep 2020 10:12:51 +0000 (13:12 +0300)]
[llvm-readobj] - Fix a warning.

In a post review comments for D88097 it was mentioned that code
triggers bunch of warnings of the form:

llvm/tools/llvm-readobj/ELFDumper.cpp:5299:28: warning: loop variable 'Note' is always a copy because
the range of type 'iterator_range<llvm::object::ELFFile<llvm::object::ELFType<llvm::support::big, true> >::Elf_Note_Iterator>'
(aka 'iterator_range<Elf_Note_Iterator_Impl<ELFType<(llvm::support::endianness)0U, true> > >') does not return a reference [-Wrange-loop-analysis]
      for (const Elf_Note &Note : this->Obj.notes(P, Err))

It happens because Elf_Note is always copied here:

Elf_Note_Impl<ELFT> operator*() const {
  assert(Nhdr && "dereferenced ELF note end iterator");
  return Elf_Note_Impl<ELFT>(*Nhdr);
}

This patch fixes the issue by removing a reference.

3 years ago[SCEV] Use loop guard info when computing the max BE taken count in howFarToZero.
Florian Hahn [Thu, 24 Sep 2020 10:06:55 +0000 (11:06 +0100)]
[SCEV] Use loop guard info when computing the max BE taken count in howFarToZero.

For some expressions, we can use information from loop guards when
we are looking for a maximum. This patch applies information from
loop guards to the expression used to compute the maximum backedge
taken count in howFarToZero. It currently replaces an unknown
expression X with UMin(X, Y), if the loop is guarded by
X ult Y.

This patch is minimal in what conditions it applies, and there
are a few TODOs to generalize.

This partly addresses PR40961. We will also need an update to
LV to address it completely.

Reviewed By: reames

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

3 years ago[asan][test] Disable malloc-no-intercept.c on Solaris
Rainer Orth [Thu, 24 Sep 2020 09:58:25 +0000 (11:58 +0200)]
[asan][test] Disable malloc-no-intercept.c on Solaris

`TestCases/malloc-no-intercept.c` `FAIL`s on Solaris/x86, e.g. with
`-Dtestfunc=mallinfo`:

  /usr/bin/ld: /tmp/malloc-no-intercept-586529.o: in function `main':
  /vol/llvm/src/llvm-project/dist/compiler-rt/test/asan/TestCases/malloc-no-intercept.c:30: undefined reference to `nonexistent_function'
  clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

This is not surprising, actually:

- `mallinfo` and `mallopt` only exist in `libmalloc`
- `pvalloc` doesn't exist all all
- `cfree` does exist in `libc`, but isn't declared in any public header and
  the OpenSolaris sources reveal that it has a different signature than on
  Linux
- only `memalign` is a public interface

To avoid this, this patch disables the interceptors for all but `meminfo`.
Additionally, the test is marked `UNSUPPORTED` on Solaris since the
`memalign` and `cfree` variants **do** link on Solaris.

Tested on `amd64-pc-solaris2.11`.

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

3 years ago[clangd] Reorder a little bit of init code. NFC
Sam McCall [Thu, 24 Sep 2020 09:55:50 +0000 (11:55 +0200)]
[clangd] Reorder a little bit of init code. NFC

This makes it possible to do something else (run checks) instead of
starting the server, with all config applied.

3 years ago[MLIR][docs] Fix typos
Junda Su [Thu, 24 Sep 2020 09:44:14 +0000 (12:44 +0300)]
[MLIR][docs] Fix typos

Fixed typos in SPIR-V to LLVM manual.

Reviewed By: georgemitenkov

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

3 years ago[llvm] Use instead of in IRSimilarityIdentifierTest.cpp.
Alexander Belyaev [Thu, 24 Sep 2020 09:27:42 +0000 (11:27 +0200)]
[llvm] Use instead of  in IRSimilarityIdentifierTest.cpp.

3 years ago[unittests] Use std::make_tuple to make some toolchains happy again
Mikael Holmen [Thu, 24 Sep 2020 09:18:21 +0000 (11:18 +0200)]
[unittests] Use std::make_tuple to make some toolchains happy again

My toolchain stopped working (LLVM 8.0, libstdc++ 5.4.0) after 577adda:

06:25:37 ../unittests/Support/Path.cpp:91:7: error: chosen constructor is explicit in copy-initialization
06:25:37       {"", false, false},  {"/", true, true},      {"/foo", true, true},
06:25:37       ^~~~~~~~~~~~~~~~~~
06:25:37 /proj/flexasic/app/llvm/8.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../../../include/c++/5.4.0/tuple:479:19: note: explicit constructor declared here
06:25:37         constexpr tuple(_UElements&&... __elements)
06:25:37                   ^

This commit adds explicit calls to std::make_tuple to work around
the problem.

3 years ago[clang][Sema] Use enumerator instead of hard-coded constant
Mikhail Maltsev [Thu, 24 Sep 2020 09:22:54 +0000 (10:22 +0100)]
[clang][Sema] Use enumerator instead of hard-coded constant

Sema::DiagnoseSwiftName uses the constant 12 instead of the
corresponding enumerator ExpectedFunctionWithProtoType. This is
fragile and will fail if a new value gets added in the middle of the
enum.

Reviewed By: aaron.ballman

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

3 years ago[SVE] Add new isKnownXX comparison functions to TypeSize
David Sherwood [Tue, 22 Sep 2020 13:54:25 +0000 (14:54 +0100)]
[SVE] Add new isKnownXX comparison functions to TypeSize

This patch introduces four new comparison functions:

  isKnownLT, isKnownLE, isKnownGT, isKnownGE

that return true if we know at compile time that a particular
condition is met, i.e. that one size is definitely greater than
another. The existing operators <,>,<=,>= remain in the code for
now, but over time we would like to remove them and change the
code to use the isKnownXY routines instead. These functions do
not assert like the existing operators because the caller is
expected to properly deal with cases where we return false by
analysing the scalable properties. I've made more of an effort
to deal with cases where there are mixed comparisons, i.e. between
fixed width and scalable types.

I've also added some knownBitsXY routines to the EVT and MVT
classes that call the equivalent TypeSize::isKnownXY routines.
I've changed the existing bitsXY functions to call their knownBitsXY
equivalents and added asserts that the scalable properties match.
Again, over time we expect to migrate callers to use knownBitsXY
and make the code more aware of the scalable nature of the sizes.

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

3 years ago[mlir] Stop allowing LLVMType Int arguments for GPULaunchFuncOp.
Alexander Belyaev [Wed, 23 Sep 2020 15:31:55 +0000 (17:31 +0200)]
[mlir] Stop allowing LLVMType Int arguments for GPULaunchFuncOp.

Conversion to LLVM becomes confusing and incorrect if someone tries to lower
STD -> LLVM and only then GPULaunchFuncOp to LLVM separately. Although it is
technically allowed now, it works incorrectly because of the argument
promotion. The correct way to use this conversion pattern is to add to the
STD->LLVM patterns before running the pass.

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

3 years ago[llvm-objcopy][MachO] Fix --add-section
Alexander Shaposhnikov [Thu, 24 Sep 2020 08:48:21 +0000 (01:48 -0700)]
[llvm-objcopy][MachO] Fix --add-section

This diff fixes --add-section functionality and simplifies the tests organization.

Test plan: make check-all

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

3 years ago[clangd] Fix comment. NFC
Sam McCall [Thu, 24 Sep 2020 08:49:32 +0000 (10:49 +0200)]
[clangd] Fix comment. NFC

3 years ago[clangd] Disable suffix matching fallback for C during include insertion
Kadir Cetinkaya [Wed, 23 Sep 2020 12:28:57 +0000 (14:28 +0200)]
[clangd] Disable suffix matching fallback for C during include insertion

Clangd currently doesn't respect language and breaks the builds with
include insertion for C. This patch aims to stop the bleeding by not mapping
back to CPP standard library headers.

Improves https://github.com/clangd/clangd/issues/376.

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

3 years ago[flang][NFC] Fix CMake variable name in README.md
Andrzej Warzynski [Thu, 24 Sep 2020 08:34:43 +0000 (09:34 +0100)]
[flang][NFC] Fix CMake variable name in README.md

The CMake variable for the new flang driver is FLANG_BUILD_NEW_DRIVER
rather than BUILD_FLANG_NEW_DRIVER.

3 years ago[flang][driver] Add missing dependency in CMake files
Andrzej Warzynski [Tue, 22 Sep 2020 18:38:04 +0000 (19:38 +0100)]
[flang][driver] Add missing dependency in CMake files

The Flang driver depends on libclangBasic. This means, among other
things, that some of the tablegen files (e.g. diagnostic definitions)
need to be generated before various libclangBasic header files can be
included (e.g. DiagnosticIDs.h). If we are lucky, libclangBasic is
indeed built before various flang driver libraries that depend on it
are. This patch makes sure that this is deterministic - i.e.
libclangBasic is built before the Flang driver libraries are.

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

3 years ago[OpenMP][MLIR] Add assembly format for master op
Kiran Chandramohan [Fri, 11 Sep 2020 20:38:25 +0000 (21:38 +0100)]
[OpenMP][MLIR] Add assembly format for master op

Reviewed By: SouraVX, kiranktp

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

3 years ago[flang][driver] Fix options flag in the frontend driver
Andrzej Warzynski [Tue, 22 Sep 2020 18:08:18 +0000 (19:08 +0100)]
[flang][driver] Fix options flag in the frontend driver

In the frontend driver we should be using FC1Option (frontend driver
options) instead of FlangOption (flang driver options).

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

3 years agoRevert "[lld-macho] Initial support for common symbols"
Muhammad Omair Javaid [Thu, 24 Sep 2020 07:26:40 +0000 (12:26 +0500)]
Revert "[lld-macho] Initial support for common symbols"

This reverts commit 63ace77962543f961f1d566dd1243b1fb37129ef.

Breaks LLDB Arm build:
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/4409

3 years agoRevert "[lld-macho] Implement and test resolution of common symbols"
Muhammad Omair Javaid [Thu, 24 Sep 2020 07:25:47 +0000 (12:25 +0500)]
Revert "[lld-macho] Implement and test resolution of common symbols"

This reverts commit cd7cb0c30305501982ba37b4905bb264b3539ad0.
Break lldb Arm build:
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/4409

3 years ago[IRSim] Adding a basic similarity identifier.
Andrew Litteken [Thu, 17 Sep 2020 20:12:08 +0000 (15:12 -0500)]
[IRSim] Adding a basic similarity identifier.

This takes the mapped instructions from the IRInstructionMapper, and
passes it to the Suffix Tree to find the repeated substrings.  Within
each set of repeated substrings, the IRSimilarityCandidates are compared
against one another for structure, and ensuring that the operands in the
instructions are used in the same way.  Each of these structurally
similarity IRSimilarityCandidates are contained in a SimilarityGroup.

Tests checking for identifying identity of structure, different
isomorphic structure, and different
nonisomoprhic structure are found in
unittests/Analysis/IRSimilarityIdentifierTest.cpp.

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

3 years ago[DWARFYAML] Make the ExtLen field of extended opcodes optional.
Xing GUO [Thu, 24 Sep 2020 06:11:47 +0000 (14:11 +0800)]
[DWARFYAML] Make the ExtLen field of extended opcodes optional.

This patch makes the 'ExtLen' field of extended opcodes optional. We
don't need to manually calculate it in the future.

Reviewed By: jhenderson, MaskRay

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

3 years ago[IRSim][NFC] Removing warning from IRSimilarityIdentifier
Andrew Litteken [Thu, 24 Sep 2020 05:26:21 +0000 (00:26 -0500)]
[IRSim][NFC] Removing warning from IRSimilarityIdentifier

3 years agoDebugInfo: Filter DWARFv5 TUs out of the debug_info unit list when CUs requested
David Blaikie [Fri, 18 Sep 2020 18:30:50 +0000 (11:30 -0700)]
DebugInfo: Filter DWARFv5 TUs out of the debug_info unit list when CUs requested

Since DWARFv5 places TUs in debug_info, some of DWARFContext's APIs have
become a bit erroneous, including TUs in the CU list by accident.
Correct that by providing compile_units (& dwo_compile_units) that
filter out the type units from the debug_info units.

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

3 years ago[dwarfdump] Warn for tags with DW_CHILDREN_yes but no children.
Jonas Devlieghere [Thu, 24 Sep 2020 05:00:57 +0000 (22:00 -0700)]
[dwarfdump] Warn for tags with DW_CHILDREN_yes but no children.

Flag DIEs that have DW_CHILDREN_yes set in their abbreviation but don't
actually have any children.

rdar://59809554

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

3 years ago[Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned...
Amy Kwan [Wed, 23 Sep 2020 22:14:24 +0000 (17:14 -0500)]
[Power10]  Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

This patch implements custom codegen for the vec_replace_elt and
vec_replace_unaligned builtins.

These builtins map to the @llvm.ppc.altivec.vinsw and @llvm.ppc.altivec.vinsd
intrinsics depending on the arguments. The main motivation for doing custom
codegen for these intrinsics is because there are float and double versions of
the builtin. Normally, the converting the float to an integer would be done via
fptoui in the IR. This is incorrect as fptoui truncates the value and we must
ensure the value is not truncated. Therefore, we provide custom codegen to utilize
bitcast instead as bitcasts do not truncate.

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

3 years ago[IRSim] Adding structural comparison to IRSimilarityCandidate.
Andrew Litteken [Wed, 23 Sep 2020 16:04:39 +0000 (11:04 -0500)]
[IRSim] Adding structural comparison to IRSimilarityCandidate.

Just because sequences of instructions are similar to one another,
doesn't mean they are doing the same thing.

This introduces a structural check for the IRSimilarityCandidate that
compares two IRSimilarityCandidates against one another, and in each
instruction creates a mapping between the operands and results, or
checks that the existing mapping is valid.  If this check passes, it
means we have structurally similar IRSimilarityCandidates.

Tests for whether the candidates are found in
unittests/Analysis/IRSimilarityIdentifierTest.cpp.

Recommit of: b27db2bb68163fa5bcb4a8f631a305eb5adb44e5 for Differential
URL.

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

3 years agoRevert "[IRSim] Adding structural comparison to IRSimilarityCandidate."
Andrew Litteken [Thu, 24 Sep 2020 03:40:37 +0000 (22:40 -0500)]
Revert "[IRSim] Adding structural comparison to IRSimilarityCandidate."

This reverts commit b27db2bb68163fa5bcb4a8f631a305eb5adb44e5.

3 years ago[IRSim] Adding structural comparison to IRSimilarityCandidate.
Andrew Litteken [Wed, 23 Sep 2020 16:04:39 +0000 (11:04 -0500)]
[IRSim] Adding structural comparison to IRSimilarityCandidate.

Just because sequences of instructions are similar to one another,
doesn't mean they are doing the same thing.

This introduces a structural check for the IRSimilarityCandidate that
compares two IRSimilarityCandidates against one another, and in each
instruction creates a mapping between the operands and results, or
checks that the existing mapping is valid.  If this check passes, it
means we have structurally similar IRSimilarityCandidates.

Tests for whether the candidates are found in
unittests/Analysis/IRSimilarityIdentifierTest.cpp.

3 years ago[lld-macho][NFC] Make `!= nullptr` implicit
Jez Ng [Thu, 24 Sep 2020 03:09:49 +0000 (20:09 -0700)]
[lld-macho][NFC] Make `!= nullptr` implicit

3 years ago[lld-macho][NFC] Refactor syslibroot / library path lookup
Jez Ng [Sat, 19 Sep 2020 03:51:38 +0000 (20:51 -0700)]
[lld-macho][NFC] Refactor syslibroot / library path lookup

* Move computation of systemLibraryRoots into a separate function, so we
  can add more functionality to it without things becoming unwieldy
* Have `getSearchPaths` and related functions return by value instead of
  by output parameter. NRVO should ensure that performance is unaffected.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Support -weak_lx, -weak_library, -weak_framework
Jez Ng [Fri, 18 Sep 2020 18:38:15 +0000 (11:38 -0700)]
[lld-macho] Support -weak_lx, -weak_library, -weak_framework

They cause their corresponding libraries / frameworks to be loaded via
`LC_LOAD_WEAK_DYLIB` instead of `LC_LOAD_DYLIB`.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Ignore `-mllvm` and its argument
Jez Ng [Wed, 16 Sep 2020 23:07:21 +0000 (16:07 -0700)]
[lld-macho] Ignore `-mllvm` and its argument

Test Plan:

Reviewed By: #lld-macho, compnerd, MaskRay

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

3 years ago[lld-macho] Emit indirect symbol table
Jez Ng [Sat, 5 Sep 2020 01:02:07 +0000 (18:02 -0700)]
[lld-macho] Emit indirect symbol table

Makes it a little easier to read objdump's disassembly.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Implement and test resolution of common symbols
Jez Ng [Tue, 1 Sep 2020 03:57:19 +0000 (20:57 -0700)]
[lld-macho] Implement and test resolution of common symbols

Handle the case where there are both common and non-common definitions
of the same symbol. Add a bunch of tests to ensure compatibility with ld64.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Initial support for common symbols
Jez Ng [Fri, 28 Aug 2020 05:54:43 +0000 (22:54 -0700)]
[lld-macho] Initial support for common symbols

On Unix, it is traditionally allowed to write variable definitions without
initialization expressions (such as "int foo;") to header files. These are
called tentative definitions.

The compiler creates common symbols when it sees tentative definitions. When
linking the final binary, if there are remaining common symbols after name
resolution is complete, the linker converts them to regular defined symbols in
a `__common` section.

This diff implements most of that functionality, though we do not yet handle
the case where there are both common and non-common definitions of the same
symbol.

Reviewed By: #lld-macho, gkm

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

3 years ago[GlobalISel][AMDGPU] Lower G_SMULH/G_UMULH
Pushpinder Singh [Mon, 10 Aug 2020 09:47:50 +0000 (05:47 -0400)]
[GlobalISel][AMDGPU] Lower G_SMULH/G_UMULH

Reviewed By: arsenm, foad

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

3 years ago[NFC] Remove unnecessary default constructors
Arthur Eubanks [Thu, 24 Sep 2020 01:52:35 +0000 (18:52 -0700)]
[NFC] Remove unnecessary default constructors

3 years ago[AMDGPU] Consider all SGPR uses as unique in constant bus verify
Carl Ritson [Thu, 24 Sep 2020 01:28:46 +0000 (10:28 +0900)]
[AMDGPU] Consider all SGPR uses as unique in constant bus verify

Fix the verifier so that overlapping SGPR operands are counted
independently.  We cannot assume that overlapping SGPR accesses
only count as a single constant bus use.
The exception is implicit uses which do not add to constant bus
usage (only) when overlapping.

Reviewed By: rampitec

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

3 years agoRevert "[NewPM] Add callbacks to PassBuilder to run before/after parsing a pass"
Arthur Eubanks [Thu, 24 Sep 2020 01:43:13 +0000 (18:43 -0700)]
Revert "[NewPM] Add callbacks to PassBuilder to run before/after parsing a pass"

This reverts commit 111aa4e36614d9a056cf5040d4d7bbfddeb9ebb2.

3 years ago[X86] Parse data32 call in .code16 as CALLpcrel32
Fangrui Song [Thu, 24 Sep 2020 01:36:50 +0000 (18:36 -0700)]
[X86] Parse data32 call in .code16 as CALLpcrel32

Used by kexec-tools (PR46942)
In GNU as, tc-i386.c:output_jump uses 4-byte immediate if a data32 prefix is present.

Reviewed By: craig.topper

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

3 years ago[X86] Add TDX instructions.
Freddy Ye [Thu, 24 Sep 2020 01:12:28 +0000 (09:12 +0800)]
[X86] Add TDX instructions.

For more details about these instructions, please refer to the latest TDX document: https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html

Reviewed By: craig.topper

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

3 years agoUtility: ignore OS version on non-Darwin targets in `ArchSpec`
Saleem Abdulrasool [Wed, 23 Sep 2020 20:57:55 +0000 (20:57 +0000)]
Utility: ignore OS version on non-Darwin targets in `ArchSpec`

The OS version field is generally not very helpful for non-Darwin
targets.  On Linux, it identifies the kernel version which moves
out-of-sync with the userspace.  On Windows, this field actually ends up
corresponding to the Visual Studio toolset version instead of the OS
version.  Consider non-Darwin targets without an OS version to be fully
specified.

Differential Revision: https://reviews.llvm.org/D88181
Reviewed By: Jonas Devlieghere, Dave Lee

3 years agoExplicitly specify CMAKE_AR in WinMsvc.cmake
Gwen Mittertreiner [Wed, 23 Sep 2020 23:20:06 +0000 (16:20 -0700)]
Explicitly specify CMAKE_AR in WinMsvc.cmake

As of cmake 3.18, cmake changes how it searches for compilers for
Windows (see
https://gitlab.kitware.com/cmake/cmake/-/commit/55196a1440e26917d40e6a7a3eb8d9fb323fa657)
and now finds llvm-ar instead of llvm-lib as CMAKE_AR. This explicitly
specifies CMAKE_AR as llvm-lib so the correct program is found.

Reviewed By: smeenai

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

3 years ago[CGProfile] don't emit cgprofile entry if called function is dllimport
Zequan Wu [Wed, 23 Sep 2020 01:10:26 +0000 (18:10 -0700)]
[CGProfile] don't emit cgprofile entry if called function is dllimport

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

3 years ago[clangd] Improve bad-RPC-payload error messages slightly
Sam McCall [Wed, 23 Sep 2020 23:51:29 +0000 (01:51 +0200)]
[clangd] Improve bad-RPC-payload error messages slightly

3 years ago[libc++] Fix spurious test failure in -fno-exceptions
Louis Dionne [Wed, 23 Sep 2020 23:44:03 +0000 (19:44 -0400)]
[libc++] Fix spurious test failure in -fno-exceptions

3 years agoFix LLDB tweak in 62a47e994fcf5b73e29547d26cd9676b30cb69a3
Sam McCall [Wed, 23 Sep 2020 23:30:42 +0000 (01:30 +0200)]
Fix LLDB tweak in 62a47e994fcf5b73e29547d26cd9676b30cb69a3

3 years ago[JSON] Add error reporting to fromJSON and ObjectMapper
Sam McCall [Wed, 23 Sep 2020 23:14:12 +0000 (01:14 +0200)]
[JSON] Add error reporting to fromJSON and ObjectMapper

Translating between JSON objects and C++ strutctures is common.
From experience in clangd, fromJSON/ObjectMapper work well and save a lot of
code, but aren't adopted elsewhere at least partly due to total lack of error
reporting beyond "ok"/"bad".

The recently-added error model should be rich enough for most applications.
It requires tracking the path within the root object and reporting local
errors at appropriate places.
To do this, we exploit the fact that the call graph of recursive
parse functions mirror the structure of the JSON itself.
The current path is represented as a linked list of segments, each of which is
on the stack as a parameter. Concretely, fromJSON now looks like:
  bool fromJSON(const Value&, T&, Path);

Beyond the signature change, this is reasonably unobtrusive: building
the path segments is mostly handled by ObjectMapper and the vector<T> fromJSON.
However the root caller of fromJSON must now create a Root object to
store the errors, which is a little clunky.

I've added high-level parse<T>(StringRef) -> Expected<T>, but it's not
general enough to be the primary interface I think (at least, not usable in
clangd).

All existing users (mostly just clangd) are updated in this patch,
making this change backwards-compatible is a bit hairy.

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

3 years ago[libunwind] Optimize dl_iterate_phdr's findUnwindSectionsByPhdr
Ryan Prichard [Wed, 23 Sep 2020 21:25:23 +0000 (14:25 -0700)]
[libunwind] Optimize dl_iterate_phdr's findUnwindSectionsByPhdr

Currently, findUnwindSectionsByPhdr is slightly micro-optimized for the
case where the first callback has the target address, and is otherwise
very inefficient -- it decodes .eh_frame_hdr even when no PT_LOAD
matches the PC. (If the FrameHeaderCache is enabled, then the
micro-optimization only helps the first time unwind info is looked up.)

Instead, it makes more sense to optimize for the case where the
callback *doesn't* find the target address, so search for a PT_LOAD
segment first, and only look for the unwind info section if a matching
PT_LOAD is found.

This change helps on an Android benchmark with 100 shared objects,
where the DSO at the end of the dl_iterate_phdr list throws 10000
exceptions. Assuming the frame cache is disabled, this change cuts
about 30-40% off the benchmark's runtime.

Reviewed By: compnerd, saugustine, #libunwind

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