platform/upstream/llvm.git
4 years ago[mlir][Linalg] Employ finer-grained control of C interface emission
Nicolas Vasilache [Fri, 3 Apr 2020 04:08:22 +0000 (00:08 -0400)]
[mlir][Linalg] Employ finer-grained control of C interface emission

Summary:
Linalg makes it possible to interface codegen with externally precompiled HPC libraries. The mechanism to allow such interop uses a normalized ABI and the emission of C interface wrappers.

The mechanism controlling these C interface emission is too aggressive and makes it very easy to obtained undefined symbols for external function (e.g. the ones coming from libm).

This revision uses the newly introduced llvm.emit_c_interface function attribute which allows controlling this behavior at a function granularity. As a consequence LinalgToLLVM does not need to activate the C wrapper emission when adding the StdToLLVM patterns.

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

4 years ago[gn build] Port c74dd640fd7
LLVM GN Syncbot [Fri, 3 Apr 2020 20:07:19 +0000 (20:07 +0000)]
[gn build] Port c74dd640fd7

4 years ago[lit] Cleanly exit on user keyboard interrupt
Julian Lettner [Thu, 24 Oct 2019 06:36:29 +0000 (23:36 -0700)]
[lit] Cleanly exit on user keyboard interrupt

Graceful lit shutdown on user keyboard interrupt [Ctrl+C] was a
longstanding goal of mine.  After a few refactorings this revision
finally enables it.  We use the following strategy to deal with
KeyboardInterrupt:
https://noswap.com/blog/python-multiprocessing-keyboardinterrupt

Printing of a helpful summary for interrupted runs (just as the one for
completed runs) will be tackled in future revisions.

Reviewed By: serge-sans-paille, rnk

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

4 years ago[X86] Add a Pass that builds a Condensed CFG for Load Value Injection (LVI) Gadgets
Scott Constable [Fri, 3 Apr 2020 19:12:51 +0000 (12:12 -0700)]
[X86] Add a Pass that builds a Condensed CFG for Load Value Injection (LVI) Gadgets

Adds a new data structure, ImmutableGraph, and uses RDF to find LVI gadgets and add them to a MachineGadgetGraph.

More specifically, a new X86 machine pass finds Load Value Injection (LVI) gadgets consisting of a load from memory (i.e., SOURCE), and any operation that may transmit the value loaded from memory over a covert channel, or use the value loaded from memory to determine a branch/call target (i.e., SINK).

Also adds a new target feature to X86: +lvi-load-hardening

The feature can be added via the clang CLI using -mlvi-hardening.

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

4 years ago[nfc] [lldb] Unindent code - obvious part
Jan Kratochvil [Fri, 3 Apr 2020 19:58:11 +0000 (21:58 +0200)]
[nfc] [lldb] Unindent code - obvious part

It is an obvious part of D77326.

It removes some needless deep indentation and some redundant statements.
It prepares the code for a more clean next patch - DWARF index callbacks
in D77327.

4 years ago[gn build] Port f95a67d8b8a
LLVM GN Syncbot [Fri, 3 Apr 2020 19:47:51 +0000 (19:47 +0000)]
[gn build] Port f95a67d8b8a

4 years agoRevert "[PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC...
Kevin P. Neal [Fri, 3 Apr 2020 19:41:37 +0000 (15:41 -0400)]
Revert "[PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins"

The new test case causes bot failures.

This reverts commit ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf.

4 years agoDon't use relpaths in lit cfg if build/source dir are on different drives.
Andrew Ng [Fri, 3 Apr 2020 19:41:14 +0000 (15:41 -0400)]
Don't use relpaths in lit cfg if build/source dir are on different drives.

See discussion on https://reviews.llvm.org/D77184.

4 years agoTest had incorrect check for nonzero count
Paul Robinson [Fri, 3 Apr 2020 19:36:37 +0000 (12:36 -0700)]
Test had incorrect check for nonzero count

4 years ago[ORC] Improve documention of memory ownership in the new Orc C bindings.
Lang Hames [Fri, 3 Apr 2020 19:25:32 +0000 (12:25 -0700)]
[ORC] Improve documention of memory ownership in the new Orc C bindings.

4 years agoFix typo in test.
Kevin P. Neal [Fri, 3 Apr 2020 19:21:33 +0000 (15:21 -0400)]
Fix typo in test.

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

4 years ago[GraphDiff] Extend GraphDiff to track a list of updates.
Alina Sbirlea [Fri, 27 Mar 2020 22:02:23 +0000 (15:02 -0700)]
[GraphDiff] Extend GraphDiff to track a list of updates.

Summary:
This patch includes two extensions:
1. It extends the GraphDiff to also keep the original list of updates
after legalization, not just the deletes/insert vectors.
It also provides an API to pop the first update (the updates are store
in reverse, such that the first update is at the end of the list)
2. It adds a bool to mark whether the given updates should be applied as
given, or applied in reverse. This moves the task of reversing the
updates (when the caller needs this) to a functionality inside
GraphDiff, versus having the caller do this.

The two changes could be split into two patches, but they seemed
reasonably small to be reviewed together.

Reviewers: kuhar, dblaikie

Subscribers: hiraditya, george.burgess.iv, mgrang, llvm-commits

Tags: #llvm

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

4 years ago[X86] Add RET-hardening Support to mitigate Load Value Injection (LVI)
Scott Constable [Fri, 3 Apr 2020 17:58:38 +0000 (10:58 -0700)]
[X86] Add RET-hardening Support to mitigate Load Value Injection (LVI)

Adding a pass that replaces every ret instruction with the sequence:

pop <scratch-reg>
lfence
jmp *<scratch-reg>

where <scratch-reg> is some available scratch register, according to the
calling convention of the function being mitigated.

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

4 years ago[PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special...
Andrew Wock [Fri, 3 Apr 2020 18:55:27 +0000 (14:55 -0400)]
[PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins

This patch adds a test for the PowerPC fma compiler builtins, some variations
of which negate inputs and outputs. The code to generate IR for these
builtins was untested before this patch.

Originally, the code used the outdated method of subtracting floating point
values from -0.0 as floating point negation. This patch remedies that.

Patch by: Drew Wock <drew.wock@sas.com>
Differential Revision: https://reviews.llvm.org/D76949

4 years ago[compiler-rt] Build with correct ABI (PR38025)
Riyaz V Puthiyapurayil [Fri, 27 Mar 2020 23:17:52 +0000 (16:17 -0700)]
[compiler-rt] Build with correct ABI (PR38025)

Summary:
This patch fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38025 | PR38025 ]]:
Wrong ABI used when building compiler-rt

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

4 years agoSupport: Add specializations for reverseBits to use builtin
Matt Arsenault [Sun, 6 Mar 2016 19:48:28 +0000 (11:48 -0800)]
Support: Add specializations for reverseBits to use builtin

4 years agoCodeGen: Convert some TII hooks to use Register
Matt Arsenault [Fri, 3 Apr 2020 17:22:51 +0000 (13:22 -0400)]
CodeGen: Convert some TII hooks to use Register

4 years agoAMDGPU: Use Register in more places
Matt Arsenault [Fri, 3 Apr 2020 17:07:00 +0000 (13:07 -0400)]
AMDGPU: Use Register in more places

4 years agoAMDGPU: Remove redundant virtual
Matt Arsenault [Fri, 3 Apr 2020 16:50:04 +0000 (12:50 -0400)]
AMDGPU: Remove redundant virtual

4 years ago[libc++] NFC: Remove unused CMake option
Louis Dionne [Fri, 3 Apr 2020 18:42:35 +0000 (14:42 -0400)]
[libc++] NFC: Remove unused CMake option

That option seems to be a remnant that has now been replaced by the
LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY setting.

Fixes PR45347.

4 years ago[clang-tidy] Address false positive in modernize-use-default-member-init
Nathan James [Fri, 3 Apr 2020 18:40:59 +0000 (19:40 +0100)]
[clang-tidy] Address false positive in modernize-use-default-member-init

Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=45363 | incorrect warning emitted by "modernize-use-default-member-init" (new to 10.0.0) ]].

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

4 years ago[AMDGPU] Added label to test. NFC.
Stanislav Mekhanoshin [Fri, 3 Apr 2020 18:36:32 +0000 (11:36 -0700)]
[AMDGPU] Added label to test. NFC.

4 years ago[mlir] DialectConversion: support block creation in ConversionPatternRewriter
Alex Zinenko [Fri, 3 Apr 2020 17:53:13 +0000 (19:53 +0200)]
[mlir] DialectConversion: support block creation in ConversionPatternRewriter

PatternRewriter and derived classes provide a set of virtual methods to
manipulate blocks, which ConversionPatternRewriter overrides to keep track of
the manipulations and undo them in case the conversion fails. However, one can
currently create a block only by splitting another block into two. This not
only makes the API inconsistent (`splitBlock` is allowed in conversion
patterns, but `createBlock` is not), but it also make it impossible for one to
create blocks with argument lists different from those of already existing
blocks since in-place block updates are not supported either. Such
functionality precludes dialect conversion infrastructure from being used more
extensively on region-containing ops, for example, for value-returning "if"
operations. At the same time, ConversionPatternRewriter already allows one to
undo block creation as block creation is one of the primitive operations in
already supported region inlining.

Support block creation in conversion patterns by hooking `createBlock` on the
block action undo mechanism. This requires to make `Builder::createBlock`
virtual, similarly to Op insertion. This is a minimal change to the Builder
infrastructure that will later help support additional use cases such as block
signature changes. `createBlock` now additionally takes the types of the block
arguments that are added immediately so as to avoid in-place argument list
manipulation that would be illegal in conversion patterns.

4 years agoClean up usages of asserting vector getters in Type
Christopher Tetreault [Fri, 3 Apr 2020 18:24:59 +0000 (11:24 -0700)]
Clean up usages of asserting vector getters in Type

Summary:
Remove usages of asserting vector getters in Type in preparation for the
VectorType refactor. The existence of these functions complicates the
refactor while adding little value.

Reviewers: kparzysz, sdesmalen, efriedma

Reviewed By: kparzysz

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[CMAKE] Plumb include_directories() into tablegen()
Stephen Neuendorffer [Tue, 31 Mar 2020 18:45:59 +0000 (11:45 -0700)]
[CMAKE] Plumb include_directories() into tablegen()

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths.  This
becomes unwieldy as there are more users for which these paths are
insufficient.  For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen.  As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful.  There are several users in clang which apparently
don't have the current directory as an include_directories().  This could
be considered separately.

The new version of this path uses list APPEND rather than list TRANSFORM,
in order to be compatible with cmake 3.4.3. If we update to cmake 3.12 then
we can use list TRANSFORM instead.

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

4 years ago[AMDGPU] Propagate AGPR RC from PHI to its PHI operands
Stanislav Mekhanoshin [Thu, 2 Apr 2020 23:06:45 +0000 (16:06 -0700)]
[AMDGPU] Propagate AGPR RC from PHI to its PHI operands

We can fix register class of PHI based on its all AGPR uses.
That leaves behind all PHIs which were already processed
earlier. Propagate RC back to PHI operands of a PHI.

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

4 years ago[libc++] Remove support for specifying LIBCXX_CXX_ABI_SYSTEM manually
Louis Dionne [Fri, 3 Apr 2020 18:08:53 +0000 (14:08 -0400)]
[libc++] Remove support for specifying LIBCXX_CXX_ABI_SYSTEM manually

This was only kept until Chromium fixed their build of libc++, which
they have now done according to
https://bugs.chromium.org/p/chromium/issues/detail?id=1067216

4 years ago[YAMLParser] Scanner::setError - ensure we use the StringRef::iterator argument ...
Simon Pilgrim [Fri, 3 Apr 2020 17:53:38 +0000 (18:53 +0100)]
[YAMLParser] Scanner::setError - ensure we use the StringRef::iterator argument (PR45043)

As detailed on PR45043, static analysis was warning that the StringRef::iterator Position argument was being ignored and the function was hardwired to use the Current iterator.

This patch ensures we use the provided iterator and removes the (barely necessary) setError wrapper that always used Current.

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

4 years ago[VectorCombine] try to form a better extractelement
Sanjay Patel [Fri, 3 Apr 2020 17:53:54 +0000 (13:53 -0400)]
[VectorCombine] try to form a better extractelement

Extracting to the same index that we are going to insert back into
allows forming select ("blend") shuffles and enables further transforms.

Admittedly, this is a quick-fix for a more general problem that I'm
hoping to solve by adding transforms for patterns that start with an
insertelement.

But this might resolve some regressions known to be caused by the
extract-extract transform (although I have not gotten more details on
those yet).

In the motivating case from PR34724:
https://bugs.llvm.org/show_bug.cgi?id=34724

The combination of subsequent instcombine and codegen transforms gets us this improvement:

  vmovshdup %xmm0, %xmm2    ## xmm2 = xmm0[1,1,3,3]
  vhaddps %xmm1, %xmm1, %xmm4
  vmovshdup %xmm1, %xmm3    ## xmm3 = xmm1[1,1,3,3]
  vaddps %xmm0, %xmm2, %xmm0
  vaddps %xmm1, %xmm3, %xmm1
  vshufps $200, %xmm4, %xmm0, %xmm0 ## xmm0 = xmm0[0,2],xmm4[0,3]
  vinsertps $177, %xmm1, %xmm0, %xmm0 ## xmm0 = zero,xmm0[1,2],xmm1[2]

  -->

  vmovshdup %xmm0, %xmm2    ## xmm2 = xmm0[1,1,3,3]
  vhaddps %xmm1, %xmm1, %xmm1
  vaddps %xmm0, %xmm2, %xmm0
  vshufps $200, %xmm1, %xmm0, %xmm0 ## xmm0 = xmm0[0,2],xmm1[0,3]

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

4 years ago[Support/Path] sys::path::replace_path_prefix fix and simplifications
Sylvain Audi [Tue, 31 Mar 2020 21:21:31 +0000 (17:21 -0400)]
[Support/Path] sys::path::replace_path_prefix fix and simplifications

Added unit tests for 2 scenarios that were failing.
Made replace_path_prefix back to 3 parameters instead of 5, simplifying the implementation. The other 2 were always used with the default value.

This commit is intended to be the first of 3:
1) simplify/fix replace_path_prefix.
2) use it in the context of -fdebug-prefix-map and -fmacro-prefix-map (see D76869).
3) Make Windows version of replace_path_prefix insensitive to both case and separators (slash vs backslash).

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

4 years ago[libc++] Remove useless nothing_to_do.pass.cpp tests
Louis Dionne [Fri, 3 Apr 2020 17:17:57 +0000 (13:17 -0400)]
[libc++] Remove useless nothing_to_do.pass.cpp tests

The testing script used to test libc++ historically did not like directories
without any testing files, so these tests had been added. Since this is
not necessary anymore, we can now remove these files. This has the benefit
that the total number of tests reflects the real number of tests more
closely, and we also skip some unnecessary work (especially relevant when
running tests over SSH).

However, some nothing_to_do.pass.cpp tests actually serve the purpose of
documenting that an area of the Standard doesn't need to be tested, or is
tested elsewhere. These files are not removed by this commit.

Removal done with:

  import os
  import itertools
  for (dirpath, dirnames, filenames) in itertools.chain(os.walk('./libcxx/test'),
                                                        os.walk('./libcxxabi/test')):
      if len(filenames + dirnames) > 1 and \
         any(p == 'nothing_to_do.pass.cpp' for p in filenames):
          os.remove(os.path.join(dirpath, 'nothing_to_do.pass.cpp'))

4 years agoRevert "[CMAKE] Plumb include_directories() into tablegen()"
Stephen Neuendorffer [Fri, 3 Apr 2020 17:47:36 +0000 (10:47 -0700)]
Revert "[CMAKE] Plumb include_directories() into tablegen()"

This reverts commit ae044c5b0caa095602b6ef4cca40d57efc26a8f6.

This breaks the buildbots, which use an older version of cmake.

4 years ago[CMAKE] Plumb include_directories() into tablegen()
Stephen Neuendorffer [Tue, 31 Mar 2020 18:45:59 +0000 (11:45 -0700)]
[CMAKE] Plumb include_directories() into tablegen()

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths.  This
becomes unwieldy as there are more users for which these paths are
insufficient.  For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen.  As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful.  There are several users in clang which apparently
don't have the current directory as an include_directories().  This could
be considered separately.

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

4 years ago[X86][SSE] lowerShuffleWithPACK - extend to use chained PACKs for larger truncations
Simon Pilgrim [Fri, 3 Apr 2020 17:25:53 +0000 (18:25 +0100)]
[X86][SSE] lowerShuffleWithPACK - extend to use chained PACKs for larger truncations

Extend lowerShuffleWithPACK/matchShuffleWithPACK/createPackShuffleMask to handle compaction style shuffle masks that can be lowered to chains of PACKSS/PACKUS if their inputs are suitably sign/zero extended.

This helps avoid PSHUFB (and its mask load) for short shuffle chains, shuffle combining will still replace with a PSHUFB if we have enough shuffles as getFauxShuffleMask should recognise the PACKSS/PACKUS chains.

4 years agoRevert "[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if...
Roman Lebedev [Fri, 3 Apr 2020 16:59:47 +0000 (19:59 +0300)]
Revert "[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)"

As discussed in post-commit review in https://reviews.llvm.org/D73501
if the goal of this is to help vectorizer, then we should actually
be teaching vectorizer to do this, because right now this rewrite
is still budget-limited, which isn't what we'd want.

Additionally, while the rest of the patch series was universally profitable,
this particular patch is reportedly (https://reviews.llvm.org/D73501#1905171)
exposing cost-modeling issues on ARM.

So let's just back this particular patch out. Once there's an undo transform,
this could be considered for reintegration.

This reverts commit 44edc6fd2c63b7db43e13cc8caf1fee79bebdb5f.

4 years ago[NFC] Move ARM `opt -indvars` test from Codegen into Transforms
Roman Lebedev [Fri, 3 Apr 2020 16:30:38 +0000 (19:30 +0300)]
[NFC] Move ARM `opt -indvars` test from Codegen into Transforms

They are really not codegen tests.

4 years ago[LoopStrengthReduce] Fix test checks to fix issue reported on D77227
Simon Pilgrim [Fri, 3 Apr 2020 17:09:44 +0000 (18:09 +0100)]
[LoopStrengthReduce] Fix test checks to fix issue reported on D77227

4 years ago[cuda][hip] Fix `RegisterVar` function prototype.
Michael Liao [Fri, 3 Apr 2020 14:17:06 +0000 (10:17 -0400)]
[cuda][hip] Fix `RegisterVar` function prototype.

Summary:
- `RegisterVar` has `void` return type and `size_t` in its variable size
  parameter in HIP or CUDA 9.0+.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[AArch64] Fix swap-compare-operands test names to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 16:48:05 +0000 (17:48 +0100)]
[AArch64] Fix swap-compare-operands test names to fix issue reported on D77354

Load of copy+paste errors in the label checks that needed fixing before the missing ":" could be added

4 years ago[PhaseOrdering] add shuffle tests based on D40633; NFC
Sanjay Patel [Fri, 3 Apr 2020 16:21:34 +0000 (12:21 -0400)]
[PhaseOrdering] add shuffle tests based on D40633; NFC

We got some of the potential optimizations with D76727 and D76844.
There are 2 likely enhancements that we could add to -vector-combine
to get most of the remaining cases:
1. Allow bitcasted shuffle mask narrowing (widen the elements).
2. Combine shuffle-of-shuffle into a single shuffle.

This is already partly handled by the x86 backend, but the
tests here show that we still miss some of the potential
combines.

4 years ago[ARM] Fix incorrect handling of big-endian vmov.i64
John Brawn [Mon, 16 Mar 2020 17:28:11 +0000 (17:28 +0000)]
[ARM] Fix incorrect handling of big-endian vmov.i64

Currently when the target is big-endian vmov.i64 reverses the order of the two
words of the vector. This is correct only when the underlying element type is
32-bit, as actually what it should be doing is considering it a vector of the
underlying type and reversing the elements of that.

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

4 years ago[ARM] Avoid pointless vrev of element-wise vmov
John Brawn [Tue, 17 Mar 2020 17:58:04 +0000 (17:58 +0000)]
[ARM] Avoid pointless vrev of element-wise vmov

If we have an element-wise vmov immediate instruction then a subsequent vrev
with width greater or equal to the vmov element width, then that vrev won't do
anything. Add a DAG combine to convert bitcasts that would become such vrevs
into vector_reg_casts instead.

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

4 years agoRun update_llc_test on test/CodeGen/ARM/vmov.ll
John Brawn [Thu, 2 Apr 2020 17:20:16 +0000 (18:20 +0100)]
Run update_llc_test on test/CodeGen/ARM/vmov.ll

This is in preparation for D76514

4 years ago[InstSimplify] Regenerate compares tests to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 16:29:06 +0000 (17:29 +0100)]
[InstSimplify] Regenerate compares tests to fix issue reported on D77354

4 years ago[lldb/Support] Treat empty FileSpec as an invalid file.
Jonas Devlieghere [Fri, 3 Apr 2020 16:18:47 +0000 (09:18 -0700)]
[lldb/Support] Treat empty FileSpec as an invalid file.

LLDB relies on empty FileSpecs being invalid files, for example, they
don't exists. Currently this assumption does not always hold during
reproducer replay, because we pass the result of GetPath to the VFS.
This is an empty string, which the VFS converts to an absolute directory
by prepending the current working directory, before looking it up in the
YAML mapping. This means that an empty FileSpec will exist when the
current working directory does. This breaks at least one test
(TestAddDsymCommand.py) when ran from replay.

This patch special cases empty FileSpecs and returns a sensible result
before calling GetPath and forwarding the call.

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

4 years ago[lldb/Symbol] Reimplement Symbols::FindSymbolFileInBundle to use the VFS
Jonas Devlieghere [Fri, 3 Apr 2020 15:33:55 +0000 (08:33 -0700)]
[lldb/Symbol] Reimplement Symbols::FindSymbolFileInBundle to use the VFS

This reimplements Symbols::FindSymbolFileInBundle to use the VFS-aware
recursive directory iterator. This is needed for reproducer replay.

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

4 years ago[LoopRotate] Cleanup test checks to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 16:21:37 +0000 (17:21 +0100)]
[LoopRotate] Cleanup test checks to fix issue reported on D77354

4 years ago[PowerPC] Regenerate f128 test to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 16:00:17 +0000 (17:00 +0100)]
[PowerPC] Regenerate f128 test to fix issue reported on D77354

I had to manually edit the file as the update script won't strip checks that don't have the ":" immediately after the prefix

4 years agoInstCombine: Reduce minnum/maxnum if inputs are casted
Matt Arsenault [Fri, 3 Apr 2020 15:09:19 +0000 (11:09 -0400)]
InstCombine: Reduce minnum/maxnum if inputs are casted

4 years ago[ELF] Allow invalid sh_size%sh_entsize!=0 for non-SHF_MERGE sections
Fangrui Song [Fri, 3 Apr 2020 05:10:43 +0000 (22:10 -0700)]
[ELF] Allow invalid sh_size%sh_entsize!=0 for non-SHF_MERGE sections

Fixes https://bugs.llvm.org/show_bug.cgi?id=45370
Fixes https://github.com/Clozure/ccl/issues/273

.stab holds a table of 12-byte entries. GNU as before 2.35 incorrectly
sets sh_entsize(.stab) to 20 on 64-bit architectures:
https://sourceware.org/bugzilla/show_bug.cgi?id=25768

We should not emit the confusing error:
"SHF_MERGE section size (...) must be a multiple of sh_entsize (20)

Reviewed By: grimar, psmith

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

4 years ago[X86] Remove defunct section checks from emulated TLS tests to fix issue reported...
Simon Pilgrim [Fri, 3 Apr 2020 15:45:56 +0000 (16:45 +0100)]
[X86] Remove defunct section checks from emulated TLS tests to fix issue reported on D77354

4 years ago[libc++] Add an alternative Lit test format
Louis Dionne [Mon, 30 Mar 2020 20:25:24 +0000 (16:25 -0400)]
[libc++] Add an alternative Lit test format

This new test format is simpler and more flexible. It creates Lit ShTests
on the fly that reuse existing substitutions (like %{cxx}) instead of
having complex logic in Python to run the tests. This has the benefit
that virtually no coding is required to customize how the test suite is
run -- one can achieve pretty much anything by defining the appropriate
substitutions in a simple lit.cfg file.

For example, in order to run the tests on an embedded device after
building with a specific SDK, one can set the %{cxx} and %{compile_flags}
substitutions to use that SDK, and the %{exec} substitution to the ssh.py
script currently used for .sh.cpp tests with a remote executor. Dealing with
the SSHExecutor becomes unnecessary, since all tests are treated like ShTests.

As a side effect of this design, configuration files for the test
suite can be as simple as:

config.substitutions.append(('%{cxx}', '<path-to-compiler>'))
config.substitutions.append(('%{compile_flags}', '<flags>'))
config.substitutions.append(('%{link_flags}', '<flags>'))
config.substitutions.append(('%{exec}', '<script-to-execute>'))

This should allow storing lit.cfg files for various configurations
directly in the repository instead of relying on complicated logic
in config.py to set up the right flags. I've found numerous problems
in that logic in the past years, and it seems like having simple and
explicit configuration files for the configurations we support is
going to solve most of these problems. Specifically, I am hoping to
store configuration files for testing other Standard Libraries in
the repository.

Improving the interaction with the test suite configuration is still a
work in progress, so for now this test format reuses the substitutions and
available features that are set up by the current config.py.

This new test format should support pretty much everything that the current
test format supports, however it will not be enabled by default at first to
make sure we're satisfied with it. For a short period of time, the new format
will require `--param=use_new_format=True` to be enabled, however it is a very
short term goal to replace the current testing format entirely and to simplify
the configuration accordingly.

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

4 years ago[AST] clang::VectorType supports any size (that fits in unsigned)
Sam McCall [Thu, 2 Apr 2020 20:53:01 +0000 (22:53 +0200)]
[AST] clang::VectorType supports any size (that fits in unsigned)

Summary:
This matches llvm::VectorType.
It moves the size from the type bitfield into VectorType, increasing size by 8
bytes (including padding of 4). This is OK as we don't expect to create terribly
many of these types.

c.f. D77313 which enables large power-of-two sizes without growing VectorType.

Reviewers: efriedma, hokein

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[MSan] Add COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED
Ilya Leoshkevich [Fri, 3 Apr 2020 13:15:06 +0000 (15:15 +0200)]
[MSan] Add COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED

Summary:
MSan not implementing COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED looks
like an omission - this macro makes it possible for those intercepted
functions, which libc needs very early, to work before interceptors are
initialized (i.e. before REAL() is usable).

While currently there are no observable practical problems in this
area, changes in libc or in MSan runtime may provoke them. Therefore,
change MSan to work like ASan and TSan already do - use internal
functions in certain interceptors when initialization is not complete.

Reviewers: eugenis, vitalybuka

Reviewed By: eugenis

Subscribers: #sanitizers

Tags: #sanitizers

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

4 years ago[X86] Fix weak global label issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 15:14:47 +0000 (16:14 +0100)]
[X86] Fix weak global label issue reported on D77354

4 years ago[X86] Fix gisel copy tests to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 15:09:17 +0000 (16:09 +0100)]
[X86] Fix gisel copy tests to fix issue reported on D77354

4 years ago[X86] Fix strong local function/global label issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 14:37:18 +0000 (15:37 +0100)]
[X86] Fix strong local function/global label issue reported on D77354

4 years ago[X86] Cleanup emulated TLS test checks. NFC
Simon Pilgrim [Fri, 3 Apr 2020 14:15:17 +0000 (15:15 +0100)]
[X86] Cleanup emulated TLS test checks. NFC

4 years ago[LoopOps] Return ArrayRefs from accessors instead of iterator_ranges
Benjamin Kramer [Fri, 3 Apr 2020 15:12:40 +0000 (17:12 +0200)]
[LoopOps] Return ArrayRefs from accessors instead of iterator_ranges

Same funcitonality, but a bit friendlier for users passing it along to
APIs that take ArrayRefs.

4 years ago[libc++] Fix is_pointer support for Objective-C++
Louis Dionne [Fri, 3 Apr 2020 15:06:26 +0000 (11:06 -0400)]
[libc++] Fix is_pointer support for Objective-C++

This test regressed with 5ade17e0ca8b, but we never noticed it because
.pass.mm tests were skipped due to a bug in our Lit config. This commit
fixes is_pointer (by essentially reverting tha part of 5ade17e0ca8b) and
also adds .pass.mm tests to the list of supported test suffixes.

We can explore how to support __is_pointer with Objective-C++ qualifiers
as a follow-up -- the main goal of this commit is to fix the regression
quickly and make sure all tests of the suite are run.

4 years ago[Alignment][NFC] Remove documentation and FIXME for deprecated functions
Guillaume Chatelet [Fri, 3 Apr 2020 14:16:09 +0000 (14:16 +0000)]
[Alignment][NFC] Remove documentation and FIXME for deprecated functions

4 years ago[libc++] Add REQUIRES for tests that need -fblocks and -fobjc-arc
Louis Dionne [Thu, 2 Apr 2020 22:28:21 +0000 (18:28 -0400)]
[libc++] Add REQUIRES for tests that need -fblocks and -fobjc-arc

AppleClang seems to support these extensions by default, but other
compilers don't.

4 years agoFix __builtin_amdgcn_workgroup_size_x/y/z return type
Yaxun (Sam) Liu [Fri, 3 Apr 2020 13:24:58 +0000 (09:24 -0400)]
Fix __builtin_amdgcn_workgroup_size_x/y/z return type

https://reviews.llvm.org/D77390

4 years ago[X86] Regenerate soft fp legalization test to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 13:55:13 +0000 (14:55 +0100)]
[X86] Regenerate soft fp legalization test to fix issue reported on D77354

4 years ago[X86] Regenerate stack clash test to fix issue reported on D77354
Simon Pilgrim [Fri, 3 Apr 2020 13:52:24 +0000 (14:52 +0100)]
[X86] Regenerate stack clash test to fix issue reported on D77354

4 years ago[Hexagon] Fix issue with non-preemptible STT_TLS symbols
Sid Manning [Thu, 2 Apr 2020 17:08:53 +0000 (12:08 -0500)]
[Hexagon] Fix issue with non-preemptible STT_TLS symbols

A PC-relative relocation referencing a non-preemptible absolute symbol
(due to STT_TLS) is not representable in -pie/-shared mode.

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

4 years ago[gn build] Port d65557d15d4
LLVM GN Syncbot [Fri, 3 Apr 2020 13:41:09 +0000 (13:41 +0000)]
[gn build] Port d65557d15d4

4 years ago[clangd] Enable some nice clang-tidy checks by default.
Sam McCall [Thu, 2 Apr 2020 23:41:40 +0000 (01:41 +0200)]
[clangd] Enable some nice clang-tidy checks by default.

Reviewers: hokein

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

Tags: #clang

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

4 years agoRevert "Use git-clang-format as Arcanist linter"
Kadir Cetinkaya [Fri, 3 Apr 2020 13:34:37 +0000 (15:34 +0200)]
Revert "Use git-clang-format as Arcanist linter"

This reverts commit 31b6e182f2ce957c86b961e21b9eb82bbcea7c59.

As it was breaking `arc diff` workflow for multiple people.

4 years ago[NFC][XCOFF][AIX] Refactor get/setContainingCsect
jasonliu [Fri, 3 Apr 2020 13:13:13 +0000 (13:13 +0000)]
[NFC][XCOFF][AIX] Refactor get/setContainingCsect

Summary:
For current architect, we always require setContainingCsect to be
called on every MCSymbol got used in XCOFF context.
This is very hard to achieve because symbols gets created everywhere
 and other MCSymbol types(ELF, COFF) do not have similar rules.
It's very easy to miss setting the containing csect, and we would
need to add a lot of XCOFF specialized code around some common code area.

This patch intendeds to do
1. Rely on getFragment().getParent() to get csect from labels.
2. Only use get/setRepresentedCsect (was get/setContainingCsect)
if symbol itself represents a csect.

Reviewers: DiggerLin, hubert.reinterpretcast, daltenty

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

4 years ago[mips][test] Remove redundant and invalid `CHECK-NOT` directives. NFC
Simon Atanasyan [Fri, 3 Apr 2020 13:20:09 +0000 (16:20 +0300)]
[mips][test] Remove redundant and invalid `CHECK-NOT` directives. NFC

1. It's redundant to explicitly check that string does not contain `PAUSE_MM`
   token if check that the `PAUSE` token is followed by an angle bracket.
2. The removed `CHECK-NOT` directives do not have trailing colons.

4 years ago[Alignment][NFC] Deprecate InstrTypes getRetAlignment/getParamAlignment
Guillaume Chatelet [Thu, 2 Apr 2020 15:10:30 +0000 (15:10 +0000)]
[Alignment][NFC] Deprecate InstrTypes getRetAlignment/getParamAlignment

Summary:
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: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[X86][AVX] Add tests showing failure to use chained PACKSS/PACKUS for multi-stage...
Simon Pilgrim [Fri, 3 Apr 2020 12:50:41 +0000 (13:50 +0100)]
[X86][AVX] Add tests showing failure to use chained PACKSS/PACKUS for multi-stage compaction shuffles

The sign/zero extended top bits mean that we could use chained PACK*S ops here

4 years ago[AMDGPU] Allow AGPR in inline asm
Yaxun (Sam) Liu [Thu, 2 Apr 2020 21:16:03 +0000 (17:16 -0400)]
[AMDGPU] Allow AGPR in inline asm

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

4 years ago[lldb][nfc] early exit/continue
Konrad Kleine [Fri, 3 Apr 2020 12:49:47 +0000 (14:49 +0200)]
[lldb][nfc] early exit/continue

Summary:
This commit just tries to invert some `if`'s logic to
`return`/`continue` early.

Reviewers: jankratochvil, teemperor

Reviewed By: jankratochvil, teemperor

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoclang-format: [JS] detect C++ keywords.
Martin Probst [Thu, 2 Apr 2020 14:53:17 +0000 (16:53 +0200)]
clang-format: [JS] detect C++ keywords.

Summary:
C++ defines a number of keywords that are regular identifiers in
JavaScript, e.g. `concept`:

    const concept = 1; // legit JS

This change expands the existing `IsJavaScriptIdentifier(Tok)` function
to return false for C++ keywords that aren't keywords in JS.

Reviewers: krasimir

Subscribers: jfb, cfe-commits

Tags: #clang

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

4 years ago[mlir][vulkan-runner] Add support for 3D memrefs.
Denis Khalikov [Fri, 3 Apr 2020 09:03:00 +0000 (12:03 +0300)]
[mlir][vulkan-runner] Add support for 3D memrefs.

Summary:
Add support for 3D memrefs in mlir-vulkan-runner and simple test.

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

4 years agoDrop unused diagnostic. NFC.
Benjamin Kramer [Fri, 3 Apr 2020 10:46:05 +0000 (12:46 +0200)]
Drop unused diagnostic. NFC.

4 years agoMake helpers static. NFC.
Benjamin Kramer [Fri, 3 Apr 2020 10:45:18 +0000 (12:45 +0200)]
Make helpers static. NFC.

4 years ago[LLD][ELF][ARM] use .reloc directive for Thumb assembler tests
Peter Smith [Mon, 30 Mar 2020 14:04:26 +0000 (15:04 +0100)]
[LLD][ELF][ARM] use .reloc directive for Thumb assembler tests

In the near future llvm-mc will resolve the fixups that generate
R_ARM_THUMB_PC8 and R_ARM_THUMB_PC12 at assembly time (see comments in
D72892), and forbid inter-section references. Change the LLD tests for
these relocations to use .inst and .reloc to avoid LLD tests failing when
this happens. The tests generate the same instructions, relocations
and symbols.

I will need to make equivalent changes for D75349 Arm equivalent
relocations, but this is still in review so these don't need changing
before llvm-mc.

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

4 years ago[Alignment][NFC] Remove unused private functions
Guillaume Chatelet [Thu, 2 Apr 2020 12:24:51 +0000 (12:24 +0000)]
[Alignment][NFC] Remove unused private functions

Summary:
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: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[AMDGPU] Fix CHECK lines
Jay Foad [Fri, 3 Apr 2020 09:06:34 +0000 (10:06 +0100)]
[AMDGPU] Fix CHECK lines

4 years ago[Alignment][NFC] Convert MachineIRBuilder::buildDynStackAlloc to Align
Guillaume Chatelet [Thu, 2 Apr 2020 09:15:06 +0000 (09:15 +0000)]
[Alignment][NFC] Convert MachineIRBuilder::buildDynStackAlloc to Align

Summary:
The change in IRTranslator is not trivial but is NFC as far as I can tell.

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: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoUse --style file instead of --style LLVM
Vitaly Buka [Fri, 3 Apr 2020 08:26:51 +0000 (01:26 -0700)]
Use --style file instead of --style LLVM

LLVM includes .clang-format files which must be respected.

4 years ago[DebugInfo] Salvage debug info when sinking loop invariant instructions
OCHyams [Wed, 1 Apr 2020 15:45:33 +0000 (16:45 +0100)]
[DebugInfo] Salvage debug info when sinking loop invariant instructions

Reviewed By: vsk, aprantl, djtodoro

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

4 years ago[NFC] G_DYN_STACKALLOC realign iff align > 1, update documentation
Guillaume Chatelet [Fri, 3 Apr 2020 08:10:59 +0000 (08:10 +0000)]
[NFC] G_DYN_STACKALLOC realign iff align > 1, update documentation

Summary: I think it would be better to require the alignment to be >= 1. It is currently confusing to allow both values.

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoSilence -Wpessimizing-move warning
scentini [Fri, 3 Apr 2020 07:37:12 +0000 (09:37 +0200)]
Silence -Wpessimizing-move warning

4 years ago[X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI)
Scott Constable [Fri, 3 Apr 2020 04:59:47 +0000 (21:59 -0700)]
[X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI)

This pass replaces each indirect call/jump with a direct call to a thunk that looks like:

lfence
jmpq *%r11

This ensures that if the value in register %r11 was loaded from memory, then
the value in %r11 is (architecturally) correct prior to the jump.
Also adds a new target feature to X86: +lvi-cfi
("cfi" meaning control-flow integrity)
The feature can be added via clang CLI using -mlvi-cfi.

This is an alternate implementation to https://reviews.llvm.org/D75934 That merges the thunk insertion functionality with the existing X86 retpoline code.

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

4 years agoSilence -Wpessimizing-move warning
scentini [Fri, 3 Apr 2020 07:23:59 +0000 (09:23 +0200)]
Silence -Wpessimizing-move warning

4 years ago[DebugInfo] Rename getOffset() to getContribution(). NFC.
Igor Kudrin [Thu, 2 Apr 2020 12:39:56 +0000 (19:39 +0700)]
[DebugInfo] Rename getOffset() to getContribution(). NFC.

The old name was a bit misleading because the functions actually return
contributions to the corresponding sections.

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

4 years ago[DWARF5] Added support for debug_macro section parsing and dumping in llvm-dwarfdump.
Sourabh Singh Tomar [Thu, 26 Mar 2020 07:45:15 +0000 (13:15 +0530)]
[DWARF5] Added support for debug_macro section parsing and dumping in llvm-dwarfdump.

Summary:
This patch adds parsing and dumping DWARFv5 .debug_macro section in llvm-dwarfdump,
it does not introduce any new switch. Existing switch "--debug-macro"
should be used to dump macinfo or macro section.

Reviewed By: dblaikie, ikudrin, jhenderson

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

4 years ago[DAG] Change isGCValue detection for statepoint lowering
Serguei Katkov [Tue, 31 Mar 2020 09:01:28 +0000 (16:01 +0700)]
[DAG] Change isGCValue detection for statepoint lowering

isGCValue should detect whether the deopt value is a GC pointer.
Currently it checks by finding the value in SI.Bases and SI.Ptrs.
However these data structures contain only those values which
have corresponding gc.relocate call. So we can miss GC value if it
does not have gc.relocate call (dead after the call).

Check GC strategy whether pointer is GC one or consider any pointer
to be GC one conservatively.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D77130

4 years agoBugix for buildbot failure at commit 43f031d31264d20cfb8f1ebd606c66e57c231d4d
Xiang1 Zhang [Fri, 3 Apr 2020 05:22:23 +0000 (13:22 +0800)]
Bugix for buildbot failure at commit 43f031d31264d20cfb8f1ebd606c66e57c231d4d
Author: Xiang1 Zhang <xiang1.zhang@intel.com>
Date:   Fri Apr 3 11:25:38 2020 +0800

    Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)

4 years ago[X86] Refactor X86IndirectThunks.cpp to Accommodate Mitigations other than Retpoline
Scott Constable [Fri, 3 Apr 2020 04:59:47 +0000 (21:59 -0700)]
[X86] Refactor X86IndirectThunks.cpp to Accommodate Mitigations other than Retpoline

Introduce a ThunkInserter CRTP base class from which new thunk types can inherit, e.g., thunks to mitigate https://software.intel.com/security-software-guidance/software-guidance/load-value-injection.

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

4 years ago[gn build] Port 71e8021d82c
LLVM GN Syncbot [Fri, 3 Apr 2020 04:56:02 +0000 (04:56 +0000)]
[gn build] Port 71e8021d82c

4 years ago[X86][NFC] Generalize the naming of "Retpoline Thunks" and related code to "Indirect...
Scott Constable [Fri, 3 Apr 2020 04:00:44 +0000 (21:00 -0700)]
[X86][NFC] Generalize the naming of "Retpoline Thunks" and related code to "Indirect Thunks"

There are applications for indirect call/branch thunks other than retpoline for Spectre v2, e.g.,

https://software.intel.com/security-software-guidance/software-guidance/load-value-injection

Therefore it makes sense to refactor X86RetpolineThunks as a more general capability.

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

4 years agoUse git-clang-format as Arcanist linter
Siddhartha Bagaria [Fri, 3 Apr 2020 04:34:51 +0000 (04:34 +0000)]
Use git-clang-format as Arcanist linter

D49116 was using clang-format-diff because at the time of its writing,
it needed to handle the subversion repo as well.

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

4 years agoHandle exp2 with proper vectorization and lowering to SVML calls
laith sakka [Fri, 3 Apr 2020 04:10:54 +0000 (21:10 -0700)]
Handle exp2 with proper vectorization and lowering to SVML calls

Summary:
Add mapping from exp2 math functions
to corresponding SVML calls.

This is a follow up and extension for llvm diff
https://reviews.llvm.org/D19544

Test Plan:
- update test case and run ninja check.
- run tests locally

Reviewers: wenlei, hoyFB, mmasten, mzolotukhin, spatel

Reviewed By: spatel

Subscribers: llvm-commits

Tags: #llvm

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

4 years agoFix a bug in the inliner that causes subsequent double inlining
Hongtao Yu [Fri, 3 Apr 2020 04:07:31 +0000 (21:07 -0700)]
Fix a bug in the inliner that causes subsequent double inlining

Summary:
A recent change in the instruction simplifier enables a call to a function that just returns one of its parameter to be simplified as simply loading the parameter. This exposes a bug in the inliner where double inlining may be involved which in turn may cause compiler ICE when an already-inlined callsite is reused for further inlining.
To put it simply, in the following-like C program, when the function call second(t) is inlined, its code t = third(t) will be reduced to just loading the return value of the callsite first(). This causes the inliner internal data structure to register the first() callsite for the call edge representing the third() call, therefore incurs a double inlining when both call edges are considered an inline candidate. I'm making a fix to break the inliner from reusing a callsite for new call edges.

```
void top()
{
    int t = first();
    second(t);
}

void second(int t)
{
   t = third(t);
   fourth(t);
}

void third(int t)
{
   return t;
}
```
The actual failing case is much trickier than the example here and is only reproducible with the legacy inliner. The way the legacy inliner works is to process each SCC in a bottom-up order. That means in reality function first may be already inlined into top, or function third is either inlined to second or is folded into nothing. To repro the failure seen from building a large application, we need to figure out a way to confuse the inliner so that the bottom-up inlining is not fulfilled. I'm doing this by making the second call indirect so that the alias analyzer fails to figure out the right call graph edge from top to second and top can be processed before second during the bottom-up.  We also need to tweak the test code so that when the inlining of top happens, the function body of second is not that optimized, by delaying the pass of function attribute deducer (i.e, which tells function third has no side effect and just returns its parameter). Since the CGSCC pass is iterative, additional calls are added to top to postpone the inlining of second to the second round right after the first function attribute deducing pass is done. I haven't been able to repro the failure with the new pass manager since the processing order of ininlined callsites is a bit different, but in theory the issue could happen there too.

Note that this fix could introduce a side effect that blocks the simplification of inlined code, specifically for a call site that can be folded to another call site. I hope this can probably be complemented by subsequent inlining or folding, as shown in the attached unit test. The ideal fix should be to separate the use of VMap. However, in reality this failing pattern shouldn't happen often. And even if it happens, there should be a good chance that the non-folded call site will be refolded by iterative inlining or subsequent simplification.

Reviewers: wenlei, davidxl, tejohnson

Reviewed By: wenlei, davidxl

Subscribers: eraman, nikic, hiraditya, llvm-commits

Tags: #llvm

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

4 years agoEnable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)
Xiang1 Zhang [Fri, 3 Apr 2020 03:25:38 +0000 (11:25 +0800)]
Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)

Summary:
This patch comes from H.J.'s https://github.com/hjl-tools/llvm-project/commit/2bd54ce7fa9e94fcd1118b948e14d1b6fc54dfd2

**This patch fix the failed llvm unit tests which running on CET machine. **(e.g. ExecutionEngine/MCJIT/MCJITTests)

The reason we enable IBT at "JIT compiled with CET" is mainly that:  the JIT don't know the its caller program is CET enable or not.
If JIT's caller program is non-CET, it is no problem JIT generate CET code or not.
But if JIT's caller program is CET enabled,  JIT must generate CET code or it will cause Control protection exceptions.

I have test the patch at llvm-unit-test and llvm-test-suite at CET machine. It passed.
and H.J. also test it at building and running VNCserver(Virtual Network Console), it works too.
(if not apply this patch, VNCserver will crash at CET machine.)

Reviewers: hjl.tools, craig.topper, LuoYuanke, annita.zhang, pengfei

Subscribers: tstellar, efriedma, hiraditya, llvm-commits

Tags: #llvm

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