1. Apr 04, 2020
    • Sanjay Patel's avatar
    • Nico Weber's avatar
      Fix standalone clang builds after fb80b6b2. · 18a18b20
      Nico Weber authored
      When clang is built against a prebuilt LLVM, LLVM_SOURCE_DIR is
      empty, which due to a cmake quirk caused list lengths to get out
      of sync. Add a workaround.
      18a18b20
    • Nick Desaulniers's avatar
      [test] preformat test with update_llc_test_checks.py NFC · 9d9b8a20
      Nick Desaulniers authored
      Summary:
      Prior to landing D76961, preprocess via:
          $ llvm/utils/update_llc_test_checks.py \
            llvm/test/CodeGen/X86/callbr-asm-outputs.ll
      
      Reviewers: void, MaskRay
      
      Reviewed By: void, MaskRay
      
      Subscribers: MaskRay, llvm-commits, srhines
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77356
      9d9b8a20
    • Scott Constable's avatar
      [X86] Add Support for Load Hardening to Mitigate Load Value Injection (LVI) · 62c42e29
      Scott Constable authored
      After finding all such gadgets in a given function, the pass minimally inserts
      LFENCE instructions in such a manner that the following property is satisfied:
      for all SOURCE+SINK pairs, all paths in the CFG from SOURCE to SINK contain at
      least one LFENCE instruction. The algorithm that implements this minimal
      insertion is influenced by an academic paper that minimally inserts memory
      fences for high-performance concurrent programs:
      
      http://www.cs.ucr.edu/~lesani/companion/oopsla15/OOPSLA15.pdf
      
      The algorithm implemented in this pass is as follows:
      
      1. Build a condensed CFG (i.e., a GadgetGraph) consisting only of the following components:
        -SOURCE instructions (also includes function arguments)
        -SINK instructions
        -Basic block entry points
        -Basic block terminators
        -LFENCE instructions
      2. Analyze the GadgetGraph to determine which SOURCE+SINK pairs (i.e., gadgets) are already mitigated by existing LFENCEs. If all gadgets have been mitigated, go to step 6.
      3. Use a heuristic or plugin to approximate minimal LFENCE insertion.
      4. Insert one LFENCE along each CFG edge that was cut in step 3.
      5. Go to step 2.
      6. If any LFENCEs were inserted, return true from runOnFunction() to tell LLVM that the function was modified.
      
      By default, the heuristic used in Step 3 is a greedy heuristic that avoids
      inserting LFENCEs into loops unless absolutely necessary. There is also a
      CLI option to load a plugin that can provide even better optimization,
      inserting fewer fences, while still mitigating all of the LVI gadgets.
      The plugin can be found here: https://github.com/intel/lvi-llvm-optimization-plugin,
      and a description of the pass's behavior with the plugin can be found here:
      https://software.intel.com/security-software-guidance/insights/optimized-mitigation-approach-load-value-injection.
      
      Differential Revision: https://reviews.llvm.org/D75937
      62c42e29
    • Reid Kleckner's avatar
      [OpenMP][NFC] Remove the need to include `OpenMPClause.h` · ba1ffd25
      Reid Kleckner authored
      See rational here: https://reviews.llvm.org/D76173#1922916
      Time to compile Attr.h in isolation goes from 2.6s to 1.8s.
      
      Original patch by Johannes, plus some additions from Reid to fix some
      clang tooling targets.
      
      Effect on transitive includes is marginal, though:
      
      $ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
         | grep '^[-+] ' | sort | uniq -c | sort -nr
          104 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/AST/OpenMPClause.h
           87 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPContext.h
           19 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SmallSet.h
           19 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SetVector.h
           14 -    /usr/include/c++/9/set
      ...
      
      Differential Revision: https://reviews.llvm.org/D76184
      ba1ffd25
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Employ finer-grained control of C interface emission · e33a636e
      Nicolas Vasilache authored
      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
      e33a636e
    • LLVM GN Syncbot's avatar
      [gn build] Port c74dd640 · 275ee5d2
      LLVM GN Syncbot authored
      275ee5d2
    • Julian Lettner's avatar
      [lit] Cleanly exit on user keyboard interrupt · 6f8c4506
      Julian Lettner authored
      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
      6f8c4506
    • Scott Constable's avatar
      [X86] Add a Pass that builds a Condensed CFG for Load Value Injection (LVI) Gadgets · c74dd640
      Scott Constable authored
      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
      c74dd640
    • Jan Kratochvil's avatar
      [nfc] [lldb] Unindent code - obvious part · 80237523
      Jan Kratochvil authored
      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.
      80237523
    • LLVM GN Syncbot's avatar
      [gn build] Port f95a67d8 · b947a846
      LLVM GN Syncbot authored
      b947a846
    • Kevin P. Neal's avatar
      Revert "[PowerPC] Replace subtract-from-zero float in version with fneg in... · 9f1c35d8
      Kevin P. Neal authored
      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 ba87430c.
      9f1c35d8
    • Andrew Ng's avatar
    • Paul Robinson's avatar
      Test had incorrect check for nonzero count · 210f40fe
      Paul Robinson authored
      210f40fe
    • Lang Hames's avatar
    • Kevin P. Neal's avatar
      Fix typo in test. · d7a0516d
      Kevin P. Neal authored
      Differential Revision: https://reviews.llvm.org/D76949
      d7a0516d
    • Alina Sbirlea's avatar
      [GraphDiff] Extend GraphDiff to track a list of updates. · 688450c7
      Alina Sbirlea authored
      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
      688450c7
    • Scott Constable's avatar
      [X86] Add RET-hardening Support to mitigate Load Value Injection (LVI) · f95a67d8
      Scott Constable authored
      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
      f95a67d8
    • Andrew Wock's avatar
      [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC... · ba87430c
      Andrew Wock authored
      [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
      ba87430c
    • Riyaz V Puthiyapurayil's avatar
      [compiler-rt] Build with correct ABI (PR38025) · 96574463
      Riyaz V Puthiyapurayil authored
      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
      96574463
    • Matt Arsenault's avatar
    • Matt Arsenault's avatar
      30ebafaa
    • Matt Arsenault's avatar
      AMDGPU: Use Register in more places · 178050c3
      Matt Arsenault authored
      178050c3
    • Matt Arsenault's avatar
      AMDGPU: Remove redundant virtual · e8dcb6d0
      Matt Arsenault authored
      e8dcb6d0
    • Louis Dionne's avatar
      [libc++] NFC: Remove unused CMake option · 5d14c7b6
      Louis Dionne authored
      That option seems to be a remnant that has now been replaced by the
      LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY setting.
      
      Fixes PR45347.
      5d14c7b6
    • Nathan James's avatar
      [clang-tidy] Address false positive in modernize-use-default-member-init · 2c7ea1c4
      Nathan James authored
      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
      2c7ea1c4
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Added label to test. NFC. · 8c5dc084
      Stanislav Mekhanoshin authored
      8c5dc084
    • Alex Zinenko's avatar
      [mlir] DialectConversion: support block creation in ConversionPatternRewriter · f27f1e8c
      Alex Zinenko authored
      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.
      f27f1e8c
    • Christopher Tetreault's avatar
      Clean up usages of asserting vector getters in Type · b6008096
      Christopher Tetreault authored
      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
      b6008096
    • Stephen Neuendorffer's avatar
      [CMAKE] Plumb include_directories() into tablegen() · 0c0831f7
      Stephen Neuendorffer authored
      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 u...
      0c0831f7
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Propagate AGPR RC from PHI to its PHI operands · 04627950
      Stanislav Mekhanoshin authored
      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
      04627950
    • Louis Dionne's avatar
      [libc++] Remove support for specifying LIBCXX_CXX_ABI_SYSTEM manually · b4b7c989
      Louis Dionne authored
      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
      b4b7c989
    • Simon Pilgrim's avatar
      [YAMLParser] Scanner::setError - ensure we use the StringRef::iterator argument (PR45043) · 22257975
      Simon Pilgrim authored
      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
      22257975
    • Sanjay Patel's avatar
      [VectorCombine] try to form a better extractelement · ce97ce3a
      Sanjay Patel authored
      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
      ce97ce3a
    • Sylvain Audi's avatar
      [Support/Path] sys::path::replace_path_prefix fix and simplifications · e4ae0a2e
      Sylvain Audi authored
      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
      e4ae0a2e
    • Louis Dionne's avatar
      [libc++] Remove useless nothing_to_do.pass.cpp tests · aaaa25e2
      Louis Dionne authored
      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'))
      aaaa25e2
    • Stephen Neuendorffer's avatar
      Revert "[CMAKE] Plumb include_directories() into tablegen()" · f288c216
      Stephen Neuendorffer authored
      This reverts commit ae044c5b.
      
      This breaks the buildbots, which use an older version of cmake.
      f288c216
    • Stephen Neuendorffer's avatar
      [CMAKE] Plumb include_directories() into tablegen() · ae044c5b
      Stephen Neuendorffer authored
      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
      ae044c5b
    • Simon Pilgrim's avatar
      [X86][SSE] lowerShuffleWithPACK - extend to use chained PACKs for larger truncations · 34a497b7
      Simon Pilgrim authored
      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.
      34a497b7
    • Roman Lebedev's avatar
      Revert "[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)" · 7d572ef2
      Roman Lebedev authored
      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 44edc6fd.
      7d572ef2