platform/upstream/llvm.git
4 years ago[mips] Add an assert in getTargetStreamer()
Miloš Stojanović [Mon, 16 Dec 2019 16:03:18 +0000 (17:03 +0100)]
[mips] Add an assert in getTargetStreamer()

Check if the TargetStreamer can be accessed.

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

4 years agogn build: Merge 0add79aec2e
LLVM GN Syncbot [Mon, 16 Dec 2019 16:00:52 +0000 (16:00 +0000)]
gn build: Merge 0add79aec2e

4 years ago[llvm-exegesis][mips] Add SnippetGeneratorTest unit test
Miloš Stojanović [Mon, 16 Dec 2019 15:49:09 +0000 (16:49 +0100)]
[llvm-exegesis][mips] Add SnippetGeneratorTest unit test

Test latency with explicit register dependency, without and with
forbidden registers.

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

4 years ago[OPENMP50]Add if clause in target teams distribute parallel for simd directive.
Alexey Bataev [Mon, 16 Dec 2019 15:27:39 +0000 (10:27 -0500)]
[OPENMP50]Add if clause in target teams distribute parallel for simd directive.

According to OpenMP 5.0, if clause can be used in for simd directive. If
condition in the if clause if false, the non-vectorized version of the
loop must be executed.

4 years agoFix floating point builtins to not promote float->double
Erich Keane [Mon, 16 Dec 2019 15:18:18 +0000 (07:18 -0800)]
Fix floating point builtins to not promote float->double

As brought up in D71467, a group of floating point builtins
automatically promoted floats to doubles because they used the variadic
builtin tag to support an overload set. The result is that the
parameters were treated as a variadic pack, which always promots
float->double.

This resulted in the wrong answer being given in cases with certain
values of NaN.

4 years ago[clang][SystemZ] Add support for -march=native
Ulrich Weigand [Mon, 16 Dec 2019 15:09:09 +0000 (16:09 +0100)]
[clang][SystemZ] Add support for -march=native

Handle -march=native in systemz::getSystemZTargetCPU, similar to
how this is done on other platforms.  Also change the return type
to std::string instead of const char *.

4 years ago[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token...
Sam McCall [Mon, 16 Dec 2019 14:58:03 +0000 (15:58 +0100)]
[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.

4 years agoRevert "[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor...
Sam McCall [Mon, 16 Dec 2019 14:57:43 +0000 (15:57 +0100)]
Revert "[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails."

This reverts commit 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.

4 years ago[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token...
Sam McCall [Mon, 16 Dec 2019 14:46:40 +0000 (15:46 +0100)]
[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

This reverts commit f0604e73a4daa35a10eb17a998657d6c4bd0e971
The issue with movability of Tweak::Selection was addressed in 7dc388bd9596bbf42633f8a8e450224e39740b60

4 years ago[clangd] Make Tweak::Selection movable. NFC
Sam McCall [Mon, 16 Dec 2019 14:46:40 +0000 (15:46 +0100)]
[clangd] Make Tweak::Selection movable. NFC

4 years agoSilence an MSVC "not all control paths" diagnostic; NFC.
Aaron Ballman [Mon, 16 Dec 2019 14:34:45 +0000 (09:34 -0500)]
Silence an MSVC "not all control paths" diagnostic; NFC.

4 years agoRevert "[clangd] Implement "textDocument/documentLink" protocol support"
Dmitri Gribenko [Mon, 16 Dec 2019 14:21:51 +0000 (15:21 +0100)]
Revert "[clangd] Implement "textDocument/documentLink" protocol support"

This reverts commit d6417f5584aa7673fa0212029a96cc9cacb1aad5. The tests
depend on builtin headers, which is not intentionally supported in
clangd tests; these tests are broken in some build environments.

4 years agoRevert "[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove"
Guillaume Chatelet [Mon, 16 Dec 2019 14:19:09 +0000 (15:19 +0100)]
Revert "[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove"

This reverts commit 181ab91efc9fb08dedda10a2fbc5fccb83ce8799.

4 years agogn build: (manually, belatedly) merge r358832
Nico Weber [Mon, 16 Dec 2019 14:02:41 +0000 (09:02 -0500)]
gn build: (manually, belatedly) merge r358832

4 years agogn build: (manually, belatedly) merge r371898
Nico Weber [Mon, 16 Dec 2019 14:01:55 +0000 (09:01 -0500)]
gn build: (manually, belatedly) merge r371898

4 years agoReland [AArch64][MachineOutliner] Return address signing for outlined functions
David Tellenbach [Mon, 16 Dec 2019 12:19:54 +0000 (13:19 +0100)]
Reland [AArch64][MachineOutliner] Return address signing for outlined functions

Summary:
Reland after fixing a bug that allowed outlining of SP modifying instructions
that invalidated return address signing.

During AArch64 frame lowering instructions to enable return address
signing are inserted into functions if needed. Functions generated during
machine outlining don't run through target frame lowering and hence are
missing such instructions.

This patch introduces the following changes:

1. If not all functions that potentially participate in function outlining agree
   on their return address signing scope and their return address signing key,
   outlining is disabled for these functions.
2. If not all functions that potentially participate in function outlining agree
   on their support for v8.3A features, outlining is disabled for these
   functions.
3. If an outlining candidate would outline instructions that modify sp in a way
   that invalidates return address signing, outlining is disabled for that
   particular candidate.
4. If all candidate functions agree on the signing scope, signing key and their
   support for v8.3 features, the outlined function behaves as if it had the
   same scope and key attributes and as if it would provide the same v8.3A
   support as the original functions.

Reviewers: ostannard, paquette

Reviewed By: ostannard

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years agofind_interesting_reviews.py: adapt to github monorepo
Kristof Beyls [Mon, 16 Dec 2019 13:31:12 +0000 (13:31 +0000)]
find_interesting_reviews.py: adapt to github monorepo

4 years ago[lldb] Use file-based synchronization in TestVSCode_attach
Pavel Labath [Mon, 16 Dec 2019 13:09:09 +0000 (14:09 +0100)]
[lldb] Use file-based synchronization in TestVSCode_attach

The is the best method we have at the moment for attach-style tests.

4 years ago[llvm-exegesis] Set up AsmTargetStreamer in readSnippets
Guillaume Chatelet [Fri, 13 Dec 2019 15:14:39 +0000 (16:14 +0100)]
[llvm-exegesis] Set up AsmTargetStreamer in readSnippets

Summary: This is a follow up on D71137 properly setting up the AsmTargetStreamer prior to AsmParser::Run call.

Reviewers: courbet, mstojanovic

Subscribers: tschuett, mikhail.ramalho, llvm-commits, petarj, atanasyan

Tags: #llvm

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

4 years ago[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove
Guillaume Chatelet [Fri, 13 Dec 2019 16:54:50 +0000 (17:54 +0100)]
[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove

Summary:
This patch introduces a set of functions to enable deprecation of IRBuilder functions without breaking out of tree clients.
Functions will be deprecated one by one and as in tree code is cleaned up.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[AArch64][SVE2] Add intrinsics for binary narrowing operations
Andrzej Warzynski [Mon, 16 Dec 2019 12:22:42 +0000 (12:22 +0000)]
[AArch64][SVE2] Add intrinsics for binary narrowing operations

Summary:
The following intrinsics for binary narrowing add and sub operations are
added:
  * @llvm.aarch64.sve.addhnb
  * @llvm.aarch64.sve.addhnt
  * @llvm.aarch64.sve.raddhnb
  * @llvm.aarch64.sve.raddhnt
  * @llvm.aarch64.sve.subhnb
  * @llvm.aarch64.sve.subhnt
  * @llvm.aarch64.sve.rsubhnb
  * @llvm.aarch64.sve.rsubhnt

Reviewers: sdesmalen, rengolin, efriedma

Reviewed By: sdesmalen, efriedma

Subscribers: tschuett, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[AArch64] Enable emission of stack maps for non-Mach-O binaries on AArch64.
Kristof Beyls [Mon, 16 Dec 2019 11:57:05 +0000 (11:57 +0000)]
[AArch64] Enable emission of stack maps for non-Mach-O binaries on AArch64.

The emission of stack maps in AArch64 binaries has been disabled for all
binary formats except Mach-O since rL206610, probably mistakenly, as far
as I can tell. This patch reverts this to its intended state.

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

Patch by Loic Ottet.

4 years ago[Aarch64][SVE] Add intrinsics for scatter stores
Andrzej Warzynski [Mon, 16 Dec 2019 11:51:10 +0000 (11:51 +0000)]
[Aarch64][SVE] Add intrinsics for scatter stores

Summary:
This patch adds the following SVE intrinsics for scatter stores:
* 64-bit offsets:
  * @llvm.aarch64.sve.st1.scatter (unscaled)
  * @llvm.aarch64.sve.st1.scatter.index (scaled)
* 32-bit unscaled offsets:
  * @llvm.aarch64.sve.st1.scatter.uxtw (zero-extended offset)
  * @llvm.aarch64.sve.st1.scatter.sxtw (sign-extended-offset)
* 32-bit scaled offsets:
  * @llvm.aarch64.sve.st1.scatter.uxtw.index (zero-extended offset)
  * @llvm.aarch64.sve.st1.scatter.sxtw.index (sign-extended offset)
* vector base + immediate:
  * @llvm.aarch64.sve.st1.scatter.imm

Reviewers: rengolin, efriedma, sdesmalen

Reviewed By: efriedma, sdesmalen

Subscribers: kmclaughlin, eli.friedman, tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years ago[lldb] Add unit test for ClangASTImporter
Raphael Isemann [Mon, 16 Dec 2019 09:06:38 +0000 (10:06 +0100)]
[lldb] Add unit test for ClangASTImporter

4 years agoAdd initial tests for update_{llc_,cc_,}test_checks.py
Alex Richardson [Fri, 13 Dec 2019 10:25:15 +0000 (10:25 +0000)]
Add initial tests for update_{llc_,cc_,}test_checks.py

Summary:
This commit adds basic tests for these update script to validate that
they still work as expected. In the future we could extend these tests
whenever new features are added to avoid introducing regressions.

Reviewers: xbolva00, MaskRay, jdoerfert

Reviewed By: jdoerfert

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[lldb][NFC] Remove all overloads of Copy/DeportType in ClangASTImporter
Raphael Isemann [Mon, 16 Dec 2019 10:52:36 +0000 (11:52 +0100)]
[lldb][NFC] Remove all overloads of Copy/DeportType in ClangASTImporter

The overloads that don't take a CompilerType serve no purpose as we
always have a CompilerType in the scope where we call them. Instead
just call the overload that takes a CompilerType and delete the
now unused other overloaded methods.

4 years ago[lldb] Centralize desugaring of decltype-like types in ClangASTContext
Pavel Labath [Tue, 10 Dec 2019 13:54:41 +0000 (14:54 +0100)]
[lldb] Centralize desugaring of decltype-like types in ClangASTContext

Summary:
These types were handled in some places, but not others. This resulted
in (for example) not being able to display members of structs whose
types were defined using these constructs.

Using getLocallyUnqualifiedSingleStepDesugaredType for these types is
not fully equivalent, as it will only desugar them if the types are not
instantiation-dependent, whereas previously we did that unconditionally.

It's not clear to me which behavior is correct here, but the test suite
does not seem to care either way.

Reviewers: teemperor, shafik

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoFix whitespace.
Jay Foad [Mon, 16 Dec 2019 10:41:38 +0000 (10:41 +0000)]
Fix whitespace.

4 years ago[BasicBlockUtils] Fix dbg.value elimination problem in MergeBlockIntoPredecessor
Bjorn Pettersson [Fri, 13 Dec 2019 14:53:40 +0000 (15:53 +0100)]
[BasicBlockUtils] Fix dbg.value elimination problem in MergeBlockIntoPredecessor

Summary:
In commit d60f34c20a2f31335c8d5626e (llvm-svn 317128,
PR35113) MergeBlockIntoPredecessor was changed into
discarding some dbg.value intrinsics referring to
PHI values, post-splice due to loop rotation.

That elimination of dbg.value intrinsics did not
consider which dbg.value to keep depending on the
context (e.g. if the variable is changing its value
several times inside the basic block).

In the past that hasn't been such a big problem since
CodeGenPrepare::placeDbgValues has moved the dbg.value
to be next to the PHI node anyway. But after commit
00e238896cd8ad3a7d7 CodeGenPrepare isn't doing that
any longer, so we need to be more careful when avoiding
duplicate dbg.value intrinsics in MergeBlockIntoPredecessor.

This patch replaces the code that tried to avoid duplicate
dbg.values by using the RemoveRedundantDbgInstrs helper.

Reviewers: aprantl, jmorse, vsk

Reviewed By: aprantl, vsk

Subscribers: jholewinski, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[LoopRotate] Add test case to show dbg value problem
Bjorn Pettersson [Fri, 13 Dec 2019 14:44:29 +0000 (15:44 +0100)]
[LoopRotate] Add test case to show dbg value problem

Summary:
In commit d60f34c20a2f31335c8d5626e (llvm-svn 317128,
PR35113) MergeBlockIntoPredecessor was changed into
discarding some dbg.value intrinsics referring to
PHI values, post-splice due to loop rotation.

That elimination of dbg.value intrinsics does not
consider which dbg.value to keep based on the context.
Such as always keeping the one that comes first textually,
or the need to keep several of them in case the variable
is changing it's value several times inside the basic block.

In the past that hasn't been such a big problem since
CodeGenPrepare::placeDbgValues has moved the dbg.value
to be next to the PHI node anyway. But after commit
00e238896cd8ad3a7d7 CodeGenPrepare isn't doing that
any longer, so we need to be more careful when avoiding
duplicate dbg.value intrinsics in MergeBlockIntoPredecessor.

This patch is just a pre commit of the test case.

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[BasicBlockUtils] Add utility to remove redundant dbg.value instrs
Bjorn Pettersson [Thu, 12 Dec 2019 19:51:13 +0000 (20:51 +0100)]
[BasicBlockUtils] Add utility to remove redundant dbg.value instrs

Summary:
Add a RemoveRedundantDbgInstrs to BasicBlockUtils with the
goal to remove redundant dbg intrinsics from a basic block.

This can be useful after various transforms, as it might
be simpler to do a filtering of dbg intrinsics after the
transform than during the transform.
One primary use case would be to replace a too aggressive
removal done by MergeBlockIntoPredecessor, seen at loop
rotate (not done in this patch).

The elimination algorithm currently focuses on dbg.value
intrinsics and is doing two iterations over the BB.

First we iterate backward starting at the last instruction
in the BB. Whenever a consecutive sequence of dbg.value
instructions are found we keep the last dbg.value for
each variable found (variable fragments are identified
using the  {DILocalVariable, FragmentInfo, inlinedAt}
triple as given by the DebugVariable helper class).

Next we iterate forward starting at the first instruction
in the BB. Whenever we find a dbg.value describing a
DebugVariable (identified by {DILocalVariable, inlinedAt})
we save the {DIValue, DIExpression} that describes that
variables value. But if the variable already was mapped
to the same {DIValue, DIExpression} pair we instead drop
the second dbg.value.

To ease the process of making lit tests for this utility a
new pass is introduced called RedundantDbgInstElimination.
It can be executed by opt using -redundant-dbg-inst-elim.

Reviewers: aprantl, jmorse, vsk

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoFix for AMDGPU MUL_I24 known bits calculation
Jay Foad [Mon, 16 Dec 2019 10:21:54 +0000 (10:21 +0000)]
Fix for AMDGPU MUL_I24 known bits calculation

Summary:
At present, the code calculating known bits of AMDGPU MUL_I24 confuses the concepts of "non-negative number" and "positive number".

In some situations, it results in incorrect code. I have a case where the optimizer replaces the result of calculating MUL_I24(-5, 0) with -8.

Reviewers: foad, arsenm

Reviewed By: arsenm

Subscribers: foad, arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Patch by Eugene Kuznetsov.

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

4 years ago[NFC] Fix typos in Clangd and Clang
Kirill Bobyrev [Mon, 16 Dec 2019 09:33:56 +0000 (10:33 +0100)]
[NFC] Fix typos in Clangd and Clang

Reviewed by: Jim

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

4 years ago[lldb][NFC] Move definition of ClangASTMetadata out of ClangExternalASTSourceCommon.h
Raphael Isemann [Mon, 16 Dec 2019 09:37:06 +0000 (10:37 +0100)]
[lldb][NFC] Move definition of ClangASTMetadata out of ClangExternalASTSourceCommon.h

Changing metadata of a ClangASTContext currently requires to include
the unrelated ClangExternalASTSourceCommon.h header because it actually defines
the ClangASTMetadata class.

This also removes the dependency from ClangASTImporter to ClangExternalASTSourceCommon.

4 years ago[CodegenPrepare] Guard against degenerate branches
Valentin Churavy [Sat, 14 Dec 2019 15:33:30 +0000 (10:33 -0500)]
[CodegenPrepare] Guard against degenerate branches

Summary:
Guard against a potential crash observed in https://github.com/JuliaLang/julia/issues/32994#issuecomment-524249628
If two branches are collapsed we can encounter a degenerate conditional branch `TBB==FBB`.
The subsequent code assumes that they differ, so we exit out early.

Reviewers: ributzka, spatel

Subscribers: loladiro, dexonsmith, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[ARM] Move MVE opcode helper functions to ARMBaseInstrInfo. NFC.
Sjoerd Meijer [Mon, 16 Dec 2019 09:11:47 +0000 (09:11 +0000)]
[ARM] Move MVE opcode helper functions to ARMBaseInstrInfo. NFC.

In ARMLowOverheadLoops.cpp, MVETailPredication.cpp, and MVEVPTBlock.cpp we have
quite a few helper functions all looking at the opcodes of MVE instructions.
This moves all these utility functions to ARMBaseInstrInfo.

Diferential Revision: https://reviews.llvm.org/D71426

4 years ago[lldb][NFC] Fix file header of TestClangASTContext.cpp
Raphael Isemann [Mon, 16 Dec 2019 08:34:16 +0000 (09:34 +0100)]
[lldb][NFC] Fix file header of TestClangASTContext.cpp

4 years ago[clangd] Get rid of raw string literals in macro calls
Kadir Cetinkaya [Mon, 16 Dec 2019 08:17:24 +0000 (09:17 +0100)]
[clangd] Get rid of raw string literals in macro calls

4 years ago[lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin
Raphael Isemann [Mon, 16 Dec 2019 08:00:58 +0000 (09:00 +0100)]
[lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin

ResolveDeclOrigin was just an inconvenience method around GetDeclOrigin.

4 years agoFix title underline in LangRef
Dmitri Gribenko [Fri, 13 Dec 2019 21:33:53 +0000 (22:33 +0100)]
Fix title underline in LangRef

The docs didn't compile:
http://lab.llvm.org:8011/builders/llvm-sphinx-docs/builds/38906

4 years ago[lldb][NFC] Remove unnecessary includes in source/Commands
Raphael Isemann [Mon, 16 Dec 2019 07:36:25 +0000 (08:36 +0100)]
[lldb][NFC] Remove unnecessary includes in source/Commands

Summary: This removes most of unnecessary includes in the `source/Commands` directory. This was generated by IWYU and a script that fixed all the bogus reports from IWYU. Patch is tested on Linux and macOS.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: krytarowski, lldb-commits

Tags: #lldb

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

4 years ago[lldb][NFC] Replace ClangASTImporter's use of map/set with SmallPtrSet and DenseMap
Raphael Isemann [Mon, 16 Dec 2019 07:16:56 +0000 (08:16 +0100)]
[lldb][NFC] Replace ClangASTImporter's use of map/set with SmallPtrSet and DenseMap

We have several pointer->pointer mappings in the ClangASTImporter implemented using
STL data structures. This moves these variables to the appropriate LLVM data structures
that are intended for mapping pointers.

4 years agoMark the major papers for C++20 consistent comparisons as "done", and
Richard Smith [Mon, 16 Dec 2019 06:20:06 +0000 (22:20 -0800)]
Mark the major papers for C++20 consistent comparisons as "done", and
start publishing the corresponding feature-test macro.

4 years ago[c++20] Compute exception specifications for defaulted comparisons.
Richard Smith [Fri, 13 Dec 2019 22:11:04 +0000 (14:11 -0800)]
[c++20] Compute exception specifications for defaulted comparisons.

This requires us to essentially fully form the body of the defaulted
comparison, but from an unevaluated context. Naively this would require
generating the function definition twice; instead, we ensure that the
function body is implicitly defined before performing the check, and
walk the actual body where possible.

4 years agoProperly compute whether statement expressions can throw, rather than
Richard Smith [Fri, 13 Dec 2019 22:10:13 +0000 (14:10 -0800)]
Properly compute whether statement expressions can throw, rather than
conservatively assuming they always can.

Also fix cases where we would not consider the computation of a VLA type
when determining whether an expression can throw. We don't yet properly
determine whether a VLA can throw, but no longer incorrectly claim it
can never throw.

4 years agoResolve exception specifications after marking the corresponding
Richard Smith [Fri, 13 Dec 2019 22:06:24 +0000 (14:06 -0800)]
Resolve exception specifications after marking the corresponding
function as referenced, not before.

No functionality change intended. This is groundwork for computing the
exception specification of a defaulted comparison, for which we'd like
to use the implicit body where possible.

4 years ago[ELF] Delete redundant isLive() check. NFC
Fangrui Song [Mon, 16 Dec 2019 05:40:11 +0000 (21:40 -0800)]
[ELF] Delete redundant isLive() check. NFC

4 years ago[examples] Rename LLJITWithJITLink to LLJITWithCustomObjectLinkingLayer.
Lang Hames [Mon, 16 Dec 2019 04:30:01 +0000 (20:30 -0800)]
[examples] Rename LLJITWithJITLink to LLJITWithCustomObjectLinkingLayer.

LLJIT now uses JITLink/ObjectLinkingLayer by default where available, so
these steps aren't required to use it. The tutorial is still useful though:
Clients can use it to test altervative linking layer implementations (e.g.
handing off to the system linker) or to test implementations of JITLink that
are still under development.

4 years ago[Orc][LLJIT] Automatically use JITLink for LLJIT on supported platforms.
Lang Hames [Mon, 16 Dec 2019 03:51:35 +0000 (19:51 -0800)]
[Orc][LLJIT] Automatically use JITLink for LLJIT on supported platforms.

JITLink (which underlies ObjectLinkingLayer) is a replacement for RuntimeDyld.
It supports the native code model, and linker plugins that enable a wider range
of features than RuntimeDyld.

Currently only enabled for MachO/x86-64 and MachO/arm64. New architectures will
be added as JITLink support for them is developed.

4 years ago[examples] Update LLJITWithJITLink example for change in c0143f37dab.
Lang Hames [Mon, 16 Dec 2019 04:24:17 +0000 (20:24 -0800)]
[examples] Update LLJITWithJITLink example for change in c0143f37dab.

4 years ago[llvm-objcopy][ELF] -O binary: use LMA instead of sh_offset to decide where to write...
Fangrui Song [Wed, 4 Dec 2019 21:48:19 +0000 (13:48 -0800)]
[llvm-objcopy][ELF] -O binary: use LMA instead of sh_offset to decide where to write section contents

.text sh_address=0x1000 sh_offset=0x1000
.data sh_address=0x3000 sh_offset=0x2000

In an objcopy -O binary output, the distance between two sections equal
their LMA differences (0x3000-0x1000), instead of their sh_offset
differences (0x2000-0x1000). This patch changes our behavior to match
GNU.

This rule gets more complex when the containing PT_LOAD has
p_vaddr!=p_paddr. GNU objcopy essentially computes
sh_offset-p_offset+p_paddr for each candidate section, and removes the
gap before the first address.

Added tests to binary-paddr.test to catch the compatibility problem.

Reviewed By: jhenderson

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

4 years ago[llvm-objcopy][MachO] Implement --add-section
Seiya Nuta [Mon, 16 Dec 2019 05:05:06 +0000 (14:05 +0900)]
[llvm-objcopy][MachO] Implement --add-section

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap, jhenderson

Subscribers: mgorny, jakehehrlich, abrachet, llvm-commits

Tags: #llvm

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

4 years ago[MC] Delete STT_SECTION special cases from MCSymbolELF::setType and setBinding
Fangrui Song [Mon, 16 Dec 2019 04:32:08 +0000 (20:32 -0800)]
[MC] Delete STT_SECTION special cases from MCSymbolELF::setType and setBinding

The special cases added by rL293936 were no longer needed after rL296180
disallowed redefinition of section symbols.

4 years ago[PowerPC] Fix %llvm.ppc.altivec.vc* lowering
Jim Lin [Mon, 16 Dec 2019 02:18:50 +0000 (10:18 +0800)]
[PowerPC] Fix %llvm.ppc.altivec.vc* lowering

Summary:
r372285 changed LLVM to use a `TargetConstant` for parameters of intrinsics that are required to be immediates.

Since that commit, use of `%llvm.ppc.altivec.vc{fsx,fux,tsxs,tuxs}` intrinsics has not worked, and resulted in a `LLVM ERROR: Cannot select: intrinsic %llvm.ppc.altivec.vc*` error. The intrinsics' TableGen definitions matched on `imm` instead of `timm`.

This commit updates those definitions to use `timm`.

Fixes: https://llvm.org/PR44239

Reviewers: hfinkel, nemanjai, #powerpc, Jim

Reviewed By: Jim

Subscribers: qiucf, wuzish, Jim, hiraditya, kbarton, jsji, shchenz, llvm-commits

Tags: #llvm

Patched by vddvss (Colin Samples).

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

4 years ago[ORC] Make ObjectLinkingLayer own its jitlink::MemoryManager.
Lang Hames [Mon, 16 Dec 2019 01:23:36 +0000 (17:23 -0800)]
[ORC] Make ObjectLinkingLayer own its jitlink::MemoryManager.

This relieves ObjectLinkingLayer clients of the responsibility of holding the
memory manager. This makes it easier to select between RTDyldObjectLinkingLayer
(which already owned its memory manager factory) and ObjectLinkingLayer at
runtime as clients aren't required to hold a jitlink::MemoryManager field just
in case ObjectLinkingLayer is selected.

4 years ago[MC] Assume CommentStream is non-null in MCDisassembler::tryAdding*
Fangrui Song [Mon, 16 Dec 2019 00:18:23 +0000 (16:18 -0800)]
[MC] Assume CommentStream is non-null in MCDisassembler::tryAdding*

AArch64/ARM/X86 call the two functions. CommentStream is always
initialized.

4 years ago[MC] Ignore VK_WEAKREF in MCValue::getAccessVariant
Fangrui Song [Mon, 16 Dec 2019 00:03:56 +0000 (16:03 -0800)]
[MC] Ignore VK_WEAKREF in MCValue::getAccessVariant

MCSymbolRefExpr::getVariantKindForName does not return VK_WEAKREF, so this code path is not exercised. Moreoever, .weakref is probably a feature that nobody uses.

4 years ago[MC] Delete unused MCAsmInfoELF::UsesNonexecutableStackSection after EM_WEBASSEMBLY...
Fangrui Song [Sun, 15 Dec 2019 23:39:30 +0000 (15:39 -0800)]
[MC] Delete unused MCAsmInfoELF::UsesNonexecutableStackSection after EM_WEBASSEMBLY was removed in D48744

This removes remnant of D15969 which hasn't been removed by D48744.

4 years ago[Kaleidoscope][BuildingAJIT] Add a missing std::move.
Lang Hames [Sun, 15 Dec 2019 23:35:49 +0000 (15:35 -0800)]
[Kaleidoscope][BuildingAJIT] Add a missing std::move.

This should fix the build failure described in
https://github.com/llvm/llvm-project/issues/63.

4 years ago[lldb] Remove RTTI in ClangExternalASTSourceCommon based on a global map of known...
Raphael Isemann [Sun, 15 Dec 2019 21:39:36 +0000 (22:39 +0100)]
[lldb] Remove RTTI in ClangExternalASTSourceCommon based on a global map of known instances

Summary:
Currently we do our RTTI check for ClangExternalASTSourceCommon by using this global map of
ClangExternalASTSourceCommon where every instance is registering and deregistering itself
on creation/destruction. Then we can do the RTTI check by looking up in this map from ClangASTContext.

This patch removes this whole thing and just adds LLVM-style RTTI support to ClangExternalASTSourceCommon
which is possible with D71397.

Reviewers: labath, aprantl

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[AST] Use a reference in a range-based for
Mark de Wever [Sun, 15 Dec 2019 20:17:07 +0000 (21:17 +0100)]
[AST] Use a reference in a range-based for

This avoids unneeded copies when using a range-based for loops.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

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

4 years ago[clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource
Raphael Isemann [Sun, 15 Dec 2019 15:09:20 +0000 (16:09 +0100)]
[clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

Summary:
We currently have some very basic LLVM-style RTTI support in the ExternalASTSource class hierarchy
based on the `SemaSource` bool( to discriminate it form the ExternalSemaSource). As ExternalASTSource
is supposed to be subclassed we should have extendable LLVM-style RTTI in this class hierarchy to make life easier
for projects building on top of Clang.

Most notably the current RTTI implementation forces LLDB to implement RTTI for its
own ExternalASTSource class (ClangExternalASTSourceCommon) by keeping a global set of
ExternalASTSources that are known to be ClangExternalASTSourceCommon. Projects
using Clang currently have to dosimilar workarounds to get RTTI support for their subclasses.

This patch turns this into full-fledged LLVM-style RTTI based on a static `ID` variable similar to
other LLVM class hierarchies. Also removes the friend declaration from ExternalASTSource to
its child class that was only used to grant access to the `SemaSource` member.

Reviewers: aprantl, dblaikie, rjmccall

Reviewed By: aprantl

Subscribers: riccibruno, labath, lhames, cfe-commits

Tags: #clang

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

4 years agogn build: Merge bbc9f6c2ef0
LLVM GN Syncbot [Sun, 15 Dec 2019 15:30:33 +0000 (15:30 +0000)]
gn build: Merge bbc9f6c2ef0

4 years ago[clang-tidy] Add cert-oop58-cpp check
Gabor Bencze [Sun, 15 Dec 2019 15:25:54 +0000 (16:25 +0100)]
[clang-tidy] Add cert-oop58-cpp check
The check warns when (a member of) the copied object is assigned to in a
copy constructor or copy assignment operator. Based on
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object

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

4 years ago[InstSimplify] fold splat of inserted constant to vector constant
Sanjay Patel [Sun, 15 Dec 2019 14:32:03 +0000 (09:32 -0500)]
[InstSimplify] fold splat of inserted constant to vector constant

shuf (inselt ?, C, IndexC), undef, <IndexC, IndexC...> --> <C, C...>

This is another missing shuffle fold pattern uncovered by the
shuffle correctness fix from D70246.

The problem was visible in the post-commit thread example, but
we managed to overcome the limitation for that particular case
with D71220.

This is something like the inverse of the previous fix - there
we didn't demand the inserted scalar, and here we are only
demanding an inserted scalar.

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

4 years ago[DAG] Add SimplifyDemandedBits support for BSWAP
Sanjay Patel [Sun, 15 Dec 2019 13:52:34 +0000 (08:52 -0500)]
[DAG] Add SimplifyDemandedBits support for BSWAP

This exposes a shortcoming for AArch64, and that is tracked by PR40881:
https://bugs.llvm.org/show_bug.cgi?id=40881

Patch by: @RKSimon (Simon Pilgrim)

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

4 years ago[analyzer] Add support for namespaces to GenericTaintChecker
Borsik Gabor [Sat, 23 Nov 2019 21:28:46 +0000 (22:28 +0100)]
[analyzer] Add support for namespaces to GenericTaintChecker

This patch introduces the namespaces for the configured functions and
also enables the use of the member functions.

I added an optional Scope field for every configured function. Functions
without Scope match for every function regardless of the namespace.
Functions with Scope will match if the full name of the function starts
with the Scope.
Multiple functions can exist with the same name.

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

4 years ago[IR] Include more target specific intrinsic headers
Heejin Ahn [Sun, 15 Dec 2019 03:19:35 +0000 (19:19 -0800)]
[IR] Include more target specific intrinsic headers

After D71320, target-specific intrinsic headers should be included.

4 years ago[LegalizeTypes] Teach BitcastToInt_ATOMIC_SWAP to only create FP16_TO_FP when called...
Craig Topper [Sat, 14 Dec 2019 22:49:17 +0000 (14:49 -0800)]
[LegalizeTypes] Teach BitcastToInt_ATOMIC_SWAP to only create FP16_TO_FP when called from PromoteFloatResult.

There's also a call from SoftenFloatResult that should not be promoted.

The change test case would fail with the new RUN line prior to
this change.

4 years ago[LegalizeTypes] In PromoteFloatOp_SETCC, don't both querying for transforming the...
Craig Topper [Sat, 14 Dec 2019 22:40:43 +0000 (14:40 -0800)]
[LegalizeTypes] In PromoteFloatOp_SETCC, don't both querying for transforming the result type.

The result type is already legal, is doesnt' need to be
transformed.

4 years ago[cxx_status] Fix paper number for "Concept auto" paper.
Richard Smith [Sat, 14 Dec 2019 22:52:24 +0000 (14:52 -0800)]
[cxx_status] Fix paper number for "Concept auto" paper.

4 years agoRevert "AArch64: Fix frame record chain"
Logan Chien [Sat, 14 Dec 2019 21:58:40 +0000 (13:58 -0800)]
Revert "AArch64: Fix frame record chain"

Breaks aosp-O3-polly-before-vectorizer-unprofitable with the following
error message:

void llvm::emitFrameOffset(llvm::MachineBasicBlock &,
MachineBasicBlock::iterator, const llvm::DebugLoc &, unsigned int,
unsigned int, llvm::StackOffset, const llvm::TargetInstrInfo *,
MachineInstr::MIFlag, bool, bool, bool *): Assertion `(DestReg !=
AArch64::SP || Bytes % 16 == 0) && "SP increment/decrement not 16-byte
aligned"' failed.

This reverts commit d4e10e6adb1b629b3fc1b78f7e281fbcec392edb.

4 years agogn build: (manually and belatedly) merge ed153ef044fd
Nico Weber [Sat, 14 Dec 2019 19:12:25 +0000 (14:12 -0500)]
gn build: (manually and belatedly) merge ed153ef044fd

4 years agoAArch64: Fix frame record chain
Logan Chien [Thu, 28 Nov 2019 06:56:34 +0000 (22:56 -0800)]
AArch64: Fix frame record chain

The commit r369122 may keep LR and FP register (aka. frame record) in
the middle of a frame, thus we must add the offsets to ensure the FP
register always points to innermost frame record on the stack.

According to AAPCS64[1], a conforming code shall construct a linked list
of stack frames that can be traversed with frame records.  This commit
is also essential to frame-pointer-based stack unwinder (e.g.  the stack
unwinder in linx-perf-tools.)

[1] https://github.com/ARM-software/software-standards/blob/master/abi/aapcs64/aapcs64.rst#the-frame-pointer

Test: llvm-lit ${LLVM_SRC}/test/CodeGen/AArch64/framelayout-frame-record.ll
Test: llvm-lit ${LLVM_SRC}/test/CodeGen/AArch64

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

4 years ago[perf-training] Make training data location configurable
Shoaib Meenai [Sat, 14 Dec 2019 03:35:49 +0000 (19:35 -0800)]
[perf-training] Make training data location configurable

We may wish to keep the PGO training data outside the repository. Add a
CMake variable to allow referencing an external lit testsuite.

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

4 years ago[AArch64][test] Fix machine-outliner-size-info.mir after D71168
Fangrui Song [Sat, 14 Dec 2019 17:44:34 +0000 (09:44 -0800)]
[AArch64][test] Fix machine-outliner-size-info.mir after D71168

4 years ago[clang] Fix modules build after addition of TypeBitCodes.def
Raphael Isemann [Sat, 14 Dec 2019 17:18:59 +0000 (18:18 +0100)]
[clang] Fix modules build after addition of TypeBitCodes.def

In revision 139006ceb641f038a2b19cac1174316e57004ed6 the Serialization
folder got its first def file 'TypeBitCodes.def'. This broke the
modules build as this .def file was not textually included but implicitly
converted into a module due to our umbrella directive.

This patch fixes this by explicitly marking the .def file as textual.

4 years ago[AArch64] add tests for fcvtl2; NFC
Sanjay Patel [Sat, 14 Dec 2019 16:08:36 +0000 (11:08 -0500)]
[AArch64] add tests for fcvtl2; NFC

4 years agoFix build with older (still supported) gcc versions.
Nico Weber [Sat, 14 Dec 2019 15:13:15 +0000 (10:13 -0500)]
Fix build with older (still supported) gcc versions.

Older gccs can't handle multiline raw string literals in
macro parameters.

4 years agogn build: Merge 91dd67ef724
Nico Weber [Sat, 14 Dec 2019 14:44:46 +0000 (09:44 -0500)]
gn build: Merge 91dd67ef724

4 years agoRevert "[clangd] Fall back to selecting token-before-cursor if token-after-cursor...
Nico Weber [Sat, 14 Dec 2019 13:13:29 +0000 (08:13 -0500)]
Revert "[clangd] Fall back to selecting token-before-cursor if token-after-cursor fails."

This reverts commit b60896fad926754f715acc5d771555aaaa577e0f.
Breaks building with gcc:

/usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted function ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’
     { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0,
                 from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: note: ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ is implicitly deleted because the default definition would be ill-formed:
   struct Selection {
          ^~~~~~~~~
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: error: use of deleted function ‘clang::clangd::SelectionTree::SelectionTree(const clang::clangd::SelectionTree&)’
In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0,
                 from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28,
                 from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/Selection.h:96:3: note: declared here
   SelectionTree(const SelectionTree &) = delete;
   ^~~~~~~~~~~~~

e.g. here:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/2714
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/41866

4 years agogn build: (manually) merge 6404bd236 and d505e57cc2
Nico Weber [Sat, 14 Dec 2019 12:44:36 +0000 (07:44 -0500)]
gn build: (manually) merge 6404bd236 and d505e57cc2

4 years agoMove ASTRecordWriter into its own header; NFC.
John McCall [Sat, 14 Dec 2019 08:17:03 +0000 (03:17 -0500)]
Move ASTRecordWriter into its own header; NFC.

Similar motivations to the movement of ASTRecordReader:
AbstractBasicWriter.h already has quite a few dependencies,
and it's going to get pretty large as we generate more and more
into it.  Meanwhile, most clients don't depend on this detail of
the implementation and shouldn't need to be recompiled.

I've also made OMPClauseWriter private, like it belongs.

4 years agoMove ASTRecordReader into its own header; NFC.
John McCall [Sat, 14 Dec 2019 08:01:28 +0000 (03:01 -0500)]
Move ASTRecordReader into its own header; NFC.

AbstractBasicReader.h has quite a few dependencies already,
and that's only likely to increase.  Meanwhile, ASTRecordReader
is really an implementation detail of the ASTReader that is only
used in a small number of places.

I've kept it in a public header for the use of projects like Swift
that might want to plug in to Clang's serialization framework.

I've also moved OMPClauseReader into an implementation file,
although it can't be made private because of friendship.

4 years ago[NFC][llvm][MIRVRegNamerUtils] Refactoring GetHashableMO into switch-statement.
Puyan Lotfi [Sat, 14 Dec 2019 05:58:44 +0000 (00:58 -0500)]
[NFC][llvm][MIRVRegNamerUtils] Refactoring GetHashableMO into switch-statement.

This refactors the if-statements handling the hashing of various
MachineOperand types into a switch-statement. The purpose is to cover
all the basis for all MachineOperand types while being very deliberate
about which MachineOperand types we are not handling and why (better
added comments). This patch is a NFC redo of https://reviews.llvm.org/D71396.
Much of the changes present in D71396 will come in smaller follow-up patches
that will add support for hashing the MachineOperand types that aren't
covered piece-meal with tests for each new case.

4 years ago[Attributor][Tests] Copy & use the ArgumentPromotion tests
Johannes Doerfert [Sat, 14 Dec 2019 06:47:29 +0000 (00:47 -0600)]
[Attributor][Tests] Copy & use the ArgumentPromotion tests

4 years ago[ArgPromo][Tests] Run update_test_checks on all ArgumentPromotion tests
Johannes Doerfert [Thu, 10 Oct 2019 07:10:51 +0000 (02:10 -0500)]
[ArgPromo][Tests] Run update_test_checks on all ArgumentPromotion tests

Summary:
In preparation of D65531 as well as the reuse of these tests for the
Attributor, we modernize them and use the update_test_checks to simplify
updates.

This was done with the update_test_checks after D68819 and D68850.

Reviewers: hfinkel, vsk, dblaikie, davidxl, tejohnson, tstellar, echristo, chandlerc, efriedma, lebedev.ri

Subscribers: bollu, arphaman, llvm-commits

Tags: #llvm

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

4 years agoMSVC build fix: forget some unneeded and incorrect friends.
John McCall [Sat, 14 Dec 2019 05:55:26 +0000 (00:55 -0500)]
MSVC build fix: forget some unneeded and incorrect friends.

On MSVC, friend declarations are (incorrectly) visible even if
not otherwise declared, which causes them to interfere with
lookup.  ASTTypeWriter is actually in an anonymous namespace
and cannot be ASTWriter's friend.  The others simply don't need
to be anymore.

4 years ago[Attributor] Annotate call sites of declarations with a callback
Johannes Doerfert [Sat, 14 Dec 2019 05:41:02 +0000 (23:41 -0600)]
[Attributor] Annotate call sites of declarations with a callback

Even if a declaration is called, if there is a callback we might need
the information during CG-SCC traversal (D70767).

4 years ago[Attributor][NFC] Add more simple test situations for callbacks
Johannes Doerfert [Sat, 14 Dec 2019 05:39:48 +0000 (23:39 -0600)]
[Attributor][NFC] Add more simple test situations for callbacks

4 years ago[Attributor][NFC] Reorder test functions
Johannes Doerfert [Sat, 14 Dec 2019 05:38:05 +0000 (23:38 -0600)]
[Attributor][NFC] Reorder test functions

Since one of the functions has a personality the attribute set is
printed. If the function is the first it should (hopefully) always be #0

4 years ago[Attributor][NFC] Simplify debug printing for abstract attributes
Johannes Doerfert [Sat, 14 Dec 2019 05:35:45 +0000 (23:35 -0600)]
[Attributor][NFC] Simplify debug printing for abstract attributes

This also fixes a type in the debug printing of AANoAlias.

4 years agoAbstract serialization: TableGen the (de)serialization code for Types.
John McCall [Sat, 14 Dec 2019 02:54:44 +0000 (21:54 -0500)]
Abstract serialization: TableGen the (de)serialization code for Types.

The basic technical design here is that we have three levels
of readers and writers:

- At the lowest level, there's a `Basic{Reader,Writer}` that knows
  how to emit the basic structures of the AST.  CRTP allows this to
  be metaprogrammed so that the client only needs to support a handful
  of primitive types (e.g. `uint64_t` and `IdentifierInfo*`) and more
  complicated "inline" structures such as `DeclarationName` can just
  be emitted in terms of those primitives.

  In Clang's binary-serialization code, these are
  `ASTRecord{Reader,Writer}`.  For now, a large number of basic
  structures are still emitted explicitly by code on those classes
  rather than by either TableGen or CRTP metaprogramming, but I
  expect to move more of these over.

- In the middle, there's a `Property{Reader,Writer}` which is
  responsible for processing the properties of a larger object.  The
  object-level reader/writer asks the property-level reader/writer to
  project out a particular property, yielding a basic reader/writer
  which will be used to read/write the property's value, like so:

  ```
    propertyWriter.find("count").writeUInt32(node->getCount());
  ```

  Clang's binary-serialization code ignores this level (it uses
  the basic reader/writer as the property reader/writer and has the
  projection methods just return `*this`) and simply relies on the
  roperties being read/written in a stable order.

- At the highest level, there's an object reader/writer (e.g.
  `Type{Reader,Writer}` which emits a logical object with properties.
  Think of this as writing something like a JSON dictionary literal.

I haven't introduced support for bitcode abbreviations yet --- it
turns out that there aren't any operative abbreviations for types
besides the QualType one --- but I do have some ideas of how they
should work.  At any rate, they'll be necessary in order to handle
statements.

I'm sorry for not disentangling the patches that added basic and type
reader/writers; I made some effort to, but I ran out of energy after
disentangling a number of other patches from the work.

Negligible impact on module size, time to build a set of about 20
fairly large modules, or time to read a few declarations out of them.

4 years agoAbstract serialization: TableGen "basic" reader/writer CRTP
John McCall [Sat, 14 Dec 2019 02:52:16 +0000 (21:52 -0500)]
Abstract serialization: TableGen "basic" reader/writer CRTP
classes that serialize basic values

4 years agoStandardize the reader methods in ASTReader; NFC.
John McCall [Fri, 13 Dec 2019 08:37:23 +0000 (03:37 -0500)]
Standardize the reader methods in ASTReader; NFC.

There are three significant changes here:

- Most of the methods to read various embedded structures (`APInt`,
  `NestedNameSpecifier`, `DeclarationName`, etc.) have been moved
  from `ASTReader` to `ASTRecordReader`.  This cleans up quite a
  bit of code which was passing around `(F, Record, Idx)` arguments
  everywhere or doing explicit indexing, and it nicely parallels
  how it works on the writer side.  It also sets us up to then move
  most of these methods into the `BasicReader`s that I'm introducing
  as part of abstract serialization.

  As part of this, several of the top-level reader methods (e.g.
  `readTypeRecord`) have been converted to use `ASTRecordReader`
  internally, which is a nice readability improvement.

- I've standardized most of these method names on `readFoo` rather
  than `ReadFoo` (used in some of the helper structures) or `GetFoo`
  (used for some specific types for no apparent reason).

- I've changed a few of these methods to return their result instead
  of reading into an argument passed by reference.  This is partly
  for general consistency and partly because it will make the
  metaprogramming easier with abstract serialization.

4 years agoExtract the TypeClass <-> TypeCode map into a .def file; NFC.
John McCall [Wed, 11 Dec 2019 08:30:22 +0000 (03:30 -0500)]
Extract the TypeClass <-> TypeCode map into a .def file; NFC.

4 years agoEnable better node-hierarchy metaprogramming; NFC.
John McCall [Tue, 10 Dec 2019 21:23:43 +0000 (16:23 -0500)]
Enable better node-hierarchy metaprogramming; NFC.

4 years agoExtract out WrappedRecord as a convenience base class; NFC.
John McCall [Tue, 10 Dec 2019 21:20:36 +0000 (16:20 -0500)]
Extract out WrappedRecord as a convenience base class; NFC.

4 years agoAdd a function to get the ExceptionSpecInfo of a function type; NFC.
John McCall [Tue, 10 Dec 2019 21:14:41 +0000 (16:14 -0500)]
Add a function to get the ExceptionSpecInfo of a function type; NFC.

4 years agoIntroduce some types and functions to make it easier to work with
John McCall [Mon, 28 Oct 2019 16:45:53 +0000 (09:45 -0700)]
Introduce some types and functions to make it easier to work with
the tblgen AST node hierarchies.

Not totally NFC because both of the emitters now emit in a different
order.  The type-nodes emitter now visits nodes in hierarchy order,
which means we could use range checks in classof if we had any types
that would benefit from that; currently we do not.  The AST-nodes
emitter now uses a multimap keyed by the name of the record; previously
it was using `Record*`, which of couse isn't stable across processes
and may have led to non-reproducible builds in some circumstances.