1. Dec 20, 2020
    • Roman Lebedev's avatar
      [SimplifyCFG] Teach FoldTwoEntryPHINode() to preserve DomTree · 4be8707e
      Roman Lebedev authored
      Still boring, simply drop all edges to successors of DomBlock,
      and add an edge to to BB instead.
      4be8707e
    • Roman Lebedev's avatar
      [NFCI][SimlifyCFG] simplifyOnce(): also perform DomTree validation · b43b77ff
      Roman Lebedev authored
      And that exposes that a number of tests don't *actually* manage to
      maintain DomTree validity, which is inline with my observations.
      
      Once again, SimlifyCFG pass currently does not require/preserve DomTree
      by default, so this is effectively NFC.
      b43b77ff
    • Andrew Litteken's avatar
      [IRSim][IROutliner] Limit to extracting regions that only require · c52bcf3a
      Andrew Litteken authored
      inputs.
      
      Extracted regions can have both inputs and outputs.  In addition, the
      CodeExtractor removes inputs that are only used in llvm.assumes, and
      sunken allocas (values are used entirely in the extracted region as
      denoted by lifetime intrinsics).  We also cannot combine sections that
      have different constants in the same structural location, and these
      constants will have to elevated to argument. This patch limits the
      extracted regions to those that only require inputs, and do not have any
       other special cases.
      
      We test that we do not outline the wrong constants in:
      test/Transforms/IROutliner/outliner-different-constants.ll
      test/Transforms/IROutliner/outliner-different-globals.ll
      test/Transforms/IROutliner/outliner-constant-vs-registers.ll
      
      We test that correctly outline in:
      test/Transforms/IROutliner/outlining-same-globals.ll
      test/Transforms/IROutliner/outlining-same-constants.ll
      test/Transforms/IROutliner/outlining-different-structure.ll
      
      Reviewers: paquette, plofti
      
      Differential Revision: https://reviews.llvm.org/D86977
      c52bcf3a
    • Craig Topper's avatar
      [X86] Teach assembler to accept vmsave/vmload/vmrun/invlpga/skinit with or... · f47b0731
      Craig Topper authored
      [X86] Teach assembler to accept vmsave/vmload/vmrun/invlpga/skinit with or without the fixed register operands
      
      These instructions read their inputs from fixed registers rather
      than using a modrm byte. We shouldn't require the user to list them
      when parsing assembly. This matches the GNU assembler.
      
      This patch adds InstAliases so we can accept either form. It also
      changes the printing code to use the form without registers. This
      will change the behavior of llvm-objdump, but should be consistent
      with binutils objdump. This also matches what we already do in LLVM for
      clzero and monitorx which also used fixed registers.
      
      I need to add and improve tests before this can be commited. The
      disassembler tests exist, but weren't checking the fixed register
      so they pass before and after this change.
      
      Fixes https://github.com/ClangBuiltLinux/linux/issues/1216
      
      Differential Revision: https://reviews.llvm.org/D93524
      f47b0731
    • Kazu Hirata's avatar
      [Analysis] Remove dead function getInstTypePair (NFC) · a6516a82
      Kazu Hirata authored
      The last use of getInstTypePair with two parameters was removed on on
      Jan 9, 2015 in commit 33d7f9de.  It
      seems to be unused since then.
      a6516a82
    • Kazu Hirata's avatar
      [Target, Transforms] Use contains (NFC) · 56edfcad
      Kazu Hirata authored
      56edfcad
    • Juneyoung Lee's avatar
  2. Dec 19, 2020
    • Mark de Wever's avatar
      [NFC][libc++] Fixes swapped comments. · 5740f96d
      Mark de Wever authored
      5740f96d
    • Zakk Chen's avatar
      [RISCV] Define vlxe/vsxe/vsuxe intrinsics. · 9cf3b1b6
      Zakk Chen authored
      
      
      Define vlxe/vsxe intrinsics and lower to vlxei<EEW>/vsxei<EEW>
      instructions.
      
      We work with @rogfer01 from BSC to come out this patch.
      
      Authored-by: default avatarRoger Ferrer Ibanez <rofirrim@gmail.com>
      Co-Authored-by: default avatarZakk Chen <zakk.chen@sifive.com>
      
      Differential Revision: https://reviews.llvm.org/D93471
      9cf3b1b6
    • Kristof Beyls's avatar
      [ARM] Add clang command line support for -mharden-sls= · 9c895aea
      Kristof Beyls authored
      The command line syntax is identical to the -mharden-sls= command line
      syntax for AArch64 targets.
      
      Differential Revision: https://reviews.llvm.org/D93221
      9c895aea
    • Kristof Beyls's avatar
      [ARM] harden-sls-blr: avoid r12 and lr in indirect calls. · df8ed392
      Kristof Beyls authored
      As a linker is allowed to clobber r12 on function calls, the code
      transformation that hardens indirect calls is not correct in case a
      linker does so.  Similarly, the transformation is not correct when
      register lr is used.
      
      This patch makes sure that r12 or lr are not used for indirect calls
      when harden-sls-blr is enabled.
      
      Differential Revision: https://reviews.llvm.org/D92469
      df8ed392
    • Kristof Beyls's avatar
      [ARM] Harden indirect calls against SLS · a4c1f516
      Kristof Beyls authored
      To make sure that no barrier gets placed on the architectural execution
      path, each indirect call calling the function in register rN, it gets
      transformed to a direct call to __llvm_slsblr_thunk_mode_rN.  mode is
      either arm or thumb, depending on the mode of where the indirect call
      happens.
      
      The llvm_slsblr_thunk_mode_rN thunk contains:
      
      bx rN
      <speculation barrier>
      
      Therefore, the indirect call gets split into 2; one direct call and one
      indirect jump.
      This transformation results in not inserting a speculation barrier on
      the architectural execution path.
      
      The mitigation is off by default and can be enabled by the
      harden-sls-blr subtarget feature.
      
      As a linker is allowed to clobber r12 on function calls, the
      above code transformation is not correct in case a linker does so.
      Similarly, the transformation is not correct when register lr is used.
      Avoiding r12/lr being used is done in a follow-on patch to make
      reviewing this code easier.
      
      Differential Revision: https://reviews.llvm.org/D92468
      a4c1f516
    • Kristof Beyls's avatar
      [ARM] Implement harden-sls-retbr for Thumb mode · 320fd331
      Kristof Beyls authored
      The only non-trivial consideration in this patch is that the formation
      of TBB/TBH instructions, which is done in the constant island pass, does
      not understand the speculation barriers inserted by the SLSHardening
      pass. As such, when harden-sls-retbr is enabled for a function, the
      formation of TBB/TBH instructions in the constant island pass is
      disabled.
      
      Differential Revision: https://reviews.llvm.org/D92396
      320fd331
    • LLVM GN Syncbot's avatar
      [gn build] Port 195f4427 · c061cb52
      LLVM GN Syncbot authored
      c061cb52
    • Kristof Beyls's avatar
      [ARM] Implement harden-sls-retbr for ARM mode · 195f4427
      Kristof Beyls authored
      Some processors may speculatively execute the instructions immediately
      following indirect control flow, such as returns, indirect jumps and
      indirect function calls.
      
      To avoid a potential miss-speculatively executed gadget after these
      instructions leaking secrets through side channels, this pass places a
      speculation barrier immediately after every indirect control flow where
      control flow doesn't return to the next instruction, such as returns and
      indirect jumps, but not indirect function calls.
      
      Hardening of indirect function calls will be done in a later,
      independent patch.
      
      This patch is implementing the same functionality as the AArch64 counter
      part implemented in https://reviews.llvm.org/D81400.
      For AArch64, returns and indirect jumps only occur on RET and BR
      instructions and hence the function attribute to control the hardening
      is called "harden-sls-retbr" there. On AArch32, there is a much wider
      variety of instructions that can trigger an indirect unconditional
      control flow change.  I've decided to stick with the name
      "harden-sls-retbr" as introduced for the corresponding AArch64
      mitigation.
      
      This patch implements this for ARM mode. A future patch will extend this
      to also support Thumb mode.
      
      The inserted barriers are never on the correct, architectural execution
      path, and therefore performance overhead of this is expected to be low.
      To ensure these barriers are never on an architecturally executed path,
      when the harden-sls-retbr function attribute is present, indirect
      control flow is never conditionalized/predicated.
      
      On targets that implement that Armv8.0-SB Speculation Barrier extension,
      a single SB instruction is emitted that acts as a speculation barrier.
      On other targets, a DSB SYS followed by a ISB is emitted to act as a
      speculation barrier.
      
      These speculation barriers are implemented as pseudo instructions to
      avoid later passes to analyze them and potentially remove them.
      
      The mitigation is off by default and can be enabled by the
      harden-sls-retbr subtarget feature.
      
      Differential Revision: https://reviews.llvm.org/D92395
      195f4427
    • Kazu Hirata's avatar
      [Analysis, CodeGen, IR] Use contains (NFC) · 805d5959
      Kazu Hirata authored
      805d5959
    • Jonas Devlieghere's avatar
      [lldb] Simplify the is_finalized logic in process and make it thread safe. · a913a583
      Jonas Devlieghere authored
      This is a speculative fix when looking at the finalization code in
      Process. It tackles the following issues:
      
       - Adds synchronization to prevent races between threads.
       - Marks the process as finalized/invalid as soon as Finalize is called
         rather than at the end.
       - Simplifies the code by using only a single instance variable to track
         finalization.
      
      Differential revision: https://reviews.llvm.org/D93479
      a913a583
    • Tim Keith's avatar
      [flang] Fix bug in IMPLICIT NONE(EXTERNAL) · bf0870d8
      Tim Keith authored
      We were only checking the restrictions of IMPLICIT NONE(EXTERNAL) when a
      procedure name is first encountered. But it can also happen with an
      existing symbol, e.g. if an external function's return type is declared
      before is it called. This change adds a check in that branch too.
      
      Differential Revision: https://reviews.llvm.org/D93552
      bf0870d8
    • Jacques Pienaar's avatar
      [FileCheck] Add a literal check directive modifier · 44f399cc
      Jacques Pienaar authored
      Introduce CHECK modifiers that change the behavior of the CHECK
      directive. Also add a LITERAL modifier for cases where matching could
      end requiring escaping strings interpreted as regex where only
      literal/fixed string matching is desired (making the CHECK's more
      difficult to write/fragile and difficult to interpret).
      44f399cc
    • Sam McCall's avatar
      2b62e623
    • Aditya Kumar's avatar
      [HotColdSplit] Reflect full cost of parameters in split penalty · 1ab4db0f
      Aditya Kumar authored
      Make the penalty for splitting a region more accurately reflect the cost
      of materializing all of the inputs/outputs to/from the region.
      
      This almost entirely eliminates code growth within functions which
      undergo splitting in key internal frameworks, and reduces the size of
      those frameworks between 2.6% to 3%.
      
      rdar://49167240
      
      Patch by: Vedant Kumar(@vsk)
      Reviewers: hiraditya,rjf,t.p.northover
      Reviewed By: hiraditya,rjf
      
      Differential Revision: https://reviews.llvm.org/D59715
      1ab4db0f
    • Sam McCall's avatar
      [clangd] Don't cancel requests based on "updates" with same content · 2fced5a0
      Sam McCall authored
      There's an unfortunate collision between two features:
       - we implicitly cancel certain requests when the file changes, to avoid
         the queue getting clogged building old revisions to service stale requests
       - we "reparse-if-needed" by synthesizing a file change, e.g. on didSave
      
      We could explicitly mark these synthetic requests to avoid this, but
      looking for changes in file content clutters our APIs less and is
      arguably the correct thing to do in any case.
      
      Fixes https://github.com/clangd/clangd/issues/620
      2fced5a0
    • Akira Hatanaka's avatar
      [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't · ffd982f7
      Akira Hatanaka authored
      inserted when the original call had a 'returned' argument
      
      The code is testing whether the instruction BBI points to is the call
      that is paired up with the retainRV/claimRV call, but it doesn't work
      when the call has a 'returned' argument since GetArgRCIdentityRoot looks
      through 'returned' arguments.
      
      rdar://72485383
      ffd982f7
    • Kazushi (Jam) Marukawa's avatar
      [VE] Support copy of vector mask registers · af83b74d
      Kazushi (Jam) Marukawa authored
      Support VM and VMP registers in copyPhysReg() function.  Also add
      regression tests.
      
      Reviewed By: simoll
      
      Differential Revision: https://reviews.llvm.org/D93547
      af83b74d
    • Sam McCall's avatar
      [clangd] Make our printing policies for Hover more consistent, especially tags · b0615642
      Sam McCall authored
      Different cases were using a bunch of different variants of the printing policy.
      Each of these had something going for it, but the result was inconsistent.
      
      Goals:
        - single printing policy used (almost) everywhere
        - avoid unidiomatic tags like `class vector<class X>`
        - be informative and easy to understand
      
      For tags, the solution I wound up with is: we print only the outer tag and only
      in the simplest cases where this elaboration won't cause confusion.
      
      For example:
       - class X
       - enum Foo
       - vector<int>
       - X*
      
      This seems to strike a nice balance of providing plenty of info/context in common
      cases while never being confusing.
      
      Differential Revision: https://reviews.llvm.org/D93553
      b0615642
    • Harald van Dijk's avatar
      [X86] Avoid generating invalid R_X86_64_GOTPCRELX relocations · adc55b5a
      Harald van Dijk authored
      We need to make sure not to emit R_X86_64_GOTPCRELX relocations for
      instructions that use a REX prefix. If a REX prefix is present, we need to
      instead use a R_X86_64_REX_GOTPCRELX relocation. The existing logic for
      CALL64m, JMP64m, etc. already handles this by checking the HasREX parameter
      and using it to determine which relocation type to use. Do this for all
      instructions that can use relaxed relocations.
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D93561
      adc55b5a
    • Richard Smith's avatar
      [www] Remove '$Date$' marker from cxx_dr_status. · f5cef870
      Richard Smith authored
      This doesn't actually work (any more?), and instead renders as a literal
      $Date$ on the website.
      f5cef870
    • Fraser Cormack's avatar
    • Sanjay Patel's avatar
      [SLP] fix typo; NFC · 37d0dda7
      Sanjay Patel authored
      37d0dda7
    • Richard Smith's avatar
      ed13d8c6
    • Richard Smith's avatar
      [c++2b] Add tests for feature test macros. · 72d8f79f
      Richard Smith authored
      72d8f79f
    • Richard Smith's avatar
      939ba0b5
    • Richard Smith's avatar
    • Fraser Cormack's avatar
      [RISCV] Assume no-op addrspacecasts by default · d4ed253d
      Fraser Cormack authored
      To support OpenCL, which typically uses SPIR as an IR, non-zero address
      spaces must be accounted for. This patch makes the RISC-V target assume
      no-op address space casts across the board, which effectively removes
      the need to support addrspacecast instructions in the backend.
      
      For a RISC-V implementation with different configurations or specialized
      address spaces where casts aren't no-ops, the function can be adjusted
      as required.
      
      Reviewed By: jrtc27
      
      Differential Revision: https://reviews.llvm.org/D93536
      d4ed253d
    • Chih-Ping Chen's avatar
      Rename files with same (case insensitive) name · 08c4b405
      Chih-Ping Chen authored
      Patch by: Aditya Kumar.
      
      Differential Revision: https://reviews.llvm.org/D93559
      08c4b405
    • Craig Topper's avatar
      [RISCV] Add intrinsics for vsetvli instruction · 69c8d121
      Craig Topper authored
      This patch adds two IR intrinsics for vsetvli instruction. One to set the vector length to a user specified value and one to set it to vlmax. The vlmax uses the X0 source register encoding.
      
      Clang builtins will follow in a separate patch
      
      Differential Revision: https://reviews.llvm.org/D92973
      69c8d121
    • Fangrui Song's avatar
      [TableGen] Fix D90844 introduced non-determinism due to iteration over a... · 9c978dd6
      Fangrui Song authored
      [TableGen] Fix D90844 introduced non-determinism due to iteration over a std::map over allocated object pointers
      
      993eaf2d (D90844) is still wrong.
      The allocated const Record* pointers do not have an order guarantee
      so switching from DenseMap to std::map does not help.
      
      ProcModelMapTy = std::map<const Record*, unsigned>
      
      Sort the values instead.
      9c978dd6
    • Nikita Popov's avatar
      [InstCombine] Regenerate test checks (NFC) · 2af2f58e
      Nikita Popov authored
      2af2f58e
    • Craig Topper's avatar
      [RISCV] Sign extend constant arguments to V intrinsics when promoting to XLen. · 09468a91
      Craig Topper authored
      The default behavior for any_extend of a constant is to zero extend.
      This occurs inside of getNode rather than allowing type legalization
      to promote the constant which would sign extend. By using sign extend
      with getNode the constant will be sign extended. This gives a better
      chance for isel to find a simm5 immediate since all xlen bits are
      examined there.
      
      For instructions that use a uimm5 immediate, this change only affects
      constants >= 128 for i8 or >= 32768 for i16. Constants that large
      already wouldn't have been eligible for uimm5 and would need to use a
      scalar register.
      
      If the instruction isn't able to use simm5 or the immediate is
      too large, we'll need to materialize the immediate in a register.
      As far as I know constants with all 1s in the upper bits should
      materialize as well or better than all 0s.
      
      Longer term we should probably have a SEW aware PatFrag to ignore
      the bits above SEW before checking simm5.
      
      I updated about half the test cases in some tests to use a negative
      constant to get coverage for this.
      
      Reviewed By: evandro
      
      Differential Revision: https://reviews.llvm.org/D93487
      09468a91
    • Nikita Popov's avatar
      [DSE] Use correct memory location for read clobber check · 1f114500
      Nikita Popov authored
      MSSA DSE starts at a killing store, finds an earlier store and
      then checks that the earlier store is not read along any paths
      (without being killed first). However, it uses the memory location
      of the killing store for that, not the earlier store that we're
      attempting to eliminate.
      
      This has a number of problems:
      
      * Mismatches between what BasicAA considers aliasing and what DSE
        considers an overwrite (even though both are correct in isolation)
        can result in miscompiles. This is PR48279, which D92045 tries to
        fix in a different way. The problem is that we're using a location
        from a store that is potentially not executed and thus may be UB,
        in which case analysis results can be arbitrary.
      * Metadata on the killing store may be used to determine aliasing,
        but there is no guarantee that the metadata is valid, as the specific
        killing store may not be executed. Using the metadata on the earlier
        store is valid (it is the store we're removing, so on any execution
        where its removal may be observed, it must be executed).
      * The location is imprecise. For full overwrites the killing store
        will always have a location that is larger or equal than the earlier
        access location, so it's beneficial to use the earlier access
        location. This is not the case for partial overwrites, in which
        case either location might be smaller. There is some room for
        improvement here.
      
      Using the earlier access location means that we can no longer cache
      which accesses are read for a given killing store, as we may be
      querying different locations. However, it turns out that simply
      dropping the cache has no notable impact on compile-time.
      
      Differential Revision: https://reviews.llvm.org/D93523
      1f114500