1. Jul 24, 2021
    • LLVM GN Syncbot's avatar
      [gn build] Port 6aa9e746 · fcb3bb58
      LLVM GN Syncbot authored
      fcb3bb58
    • Ayke van Laethem's avatar
      [AVR] Only support sp, r0 and r1 in llvm.read_register · 4d7f5c0a
      Ayke van Laethem authored
      Most other registers are allocatable and therefore cannot be used.
      
      This issue was flagged by the machine verifier, because reading other
      registers is considered reading from an undefined register.
      
      Differential Revision: https://reviews.llvm.org/D96969
      4d7f5c0a
    • Ayke van Laethem's avatar
      [AVR] Fix rotate instructions · 41f905b2
      Ayke van Laethem authored
      This patch fixes some issues with the RORB pseudo instruction.
      
        - A minor issue in which the instructions were said to use the SREG,
          which is not true.
        - An issue with the BLD instruction, which did not have an output operand.
        - A major issue in which invalid instructions were generated. The fix
          also reduce RORB from 4 to 3 instructions, so it's also a small
          optimization.
      
      These issues were flagged by the machine verifier.
      
      Differential Revision: https://reviews.llvm.org/D96957
      41f905b2
    • Ayke van Laethem's avatar
      [AVR] Expand large shifts early in IR · 6aa9e746
      Ayke van Laethem authored
      This patch makes sure shift instructions such as this one:
      
          %result = shl i32 %n, %amount
      
      are expanded just before the IR to SelectionDAG conversion to a loop so
      that calls to non-existing library functions such as __ashlsi3 are
      avoided. The generated code is currently pretty bad but there's a lot of
      room for improvement: the shift itself can be done in just four
      instructions.
      
      Differential Revision: https://reviews.llvm.org/D96677
      6aa9e746
    • Ayke van Laethem's avatar
      [AVR] Improve 8/16 bit atomic operations · 431a9414
      Ayke van Laethem authored
      There were some serious issues with atomic operations. This patch should
      fix the biggest issues.
      
      For details on the issue take a look at this Compiler Explorer sample:
      https://godbolt.org/z/n3ndhn
      
      Code:
      
          void atomicadd(_Atomic char *val) {
              *val += 5;
          }
      
      Output:
      
          atomicadd:
              movw    r26, r24
              ldi     r24, 5     ; 'operand' register
              in      r0, 63
              cli
              ld      r24, X     ; load value
              add     r24, r26   ; value += X
              st      X, r24     ; store value back
              out     63, r0
              ret                ; return the wrong value (in r24)
      
      There are various problems with this.
      
       - The value to add (5) is stored in r24. However, the value to add to
         is loaded in the same register: r24.
       - The `add` instruction adds half of the pointer to the loaded value,
         instead of (attempting to) add the operand with value 5.
       - The output value of the cmpxchg instruction (which is not used in
         this code sample) is the new value with 5 added, not the old value.
         The LangRef specifies that it has to be the old value, before the
         operation.
      
      This patch fixes the first two and leaves the third problem to be fixed
      at a later date. I believe atomics were mostly broken before this patch,
      with this patch they should become usable as long as you ignore the
      output of the atomic operation. In particular it fixes the following
      things:
      
       - It sets the earlyclobber flag for the input ('$operand' operand) so
         that the register allocator puts it in a different register than the
         output value.
       - It fixes a number of issues with the pseudo op expansion pass, for
         example now it adds the $operand field instead of the pointer. This
         fixes most machine instruction verifier issues (other flagged issues
         are unrelated to atomics).
      
      Differential Revision: https://reviews.llvm.org/D97127
      431a9414
    • Ayke van Laethem's avatar
      [AVR] Set R31R30 as clobbered after ADJCALLSTACKDOWN · 8544ce80
      Ayke van Laethem authored
      In most cases, using R31R30 is fine because the call (which always
      precedes ADJCALLSTACKDOWN) will clobber R31R30 anyway. However, in some
      rare cases the register allocator might insert an instruction between
      the call and the ADJCALLSTACKDOWN instruction and expect the register
      pair to be live afterwards. I think this happens as a result of
      rematerialization. Therefore, to fix this, the instruction needs to have
      Defs set to R31R30.
      
      Setting the Defs field does have the effect of making the instruction
      look dead, which it certainly is not. This is fixed by setting
      hasSideEffects to true.
      
      Differential Revision: https://reviews.llvm.org/D97745
      8544ce80
    • Ayke van Laethem's avatar
      [AVR] Do not chain stores in call frame setup · feda08b7
      Ayke van Laethem authored
      Previously, AVRTargetLowering::LowerCall attempted to keep stack stores
      in order with chains. Perhaps this worked in the past, but it does not
      work now: it appears that the SelectionDAG legalization phase removes
      these chains. Therefore, I've removed these chains entirely to match
      X86 (which, similar to AVR, also prefers to use push instructions over
      stack-relative stores to set up a call frame). With this change, all the
      stack stores are in a somewhat reasonable order.
      
      Differential Revision: https://reviews.llvm.org/D97853
      feda08b7
    • Ayke van Laethem's avatar
      [lld][WebAssembly] Align __heap_base · 13ca0c87
      Ayke van Laethem authored
      __heap_base was not aligned. In practice, it will often be aligned
      simply because it follows the stack, but when the stack is placed at the
      beginning (with the --stack-first option), the __heap_base might be
      unaligned. It could even be byte-aligned.
      
      At least wasi-libc appears to expect that __heap_base is aligned:
      https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/dlmalloc/src/malloc.c#L5224
      
      While WebAssembly itself does not appear to require any alignment for
      memory accesses, it is sometimes required when sharing a pointer
      externally. For example, WASI might expect alignment up to 8:
      https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-timestamp-u64
      
      This issue got introduced with the addition of the --stack-first flag:
      https://reviews.llvm.org/D46141
      I suspect the lack of alignment wasn't intentional here.
      
      Differential Revision: https://reviews.llvm.org/D106499
      13ca0c87
    • Butygin's avatar
      [mlir] ConversionTarget legality callbacks refactoring · b7a46498
      Butygin authored
      * Get rid of Optional<std::function> as std::function already have a null state
      * Add private setLegalityCallback function to set legality callback for unknown ops
      * Get rid of unknownOpsDynamicallyLegal flag, use unknownLegalityFn state insted. This causes behavior change when user first calls markUnknownOpDynamicallyLegal with callback and then without but I am not sure is the original behavior was really a 'feature', or just oversignt in the original implementation.
      
      Differential Revision: https://reviews.llvm.org/D105496
      b7a46498
    • Melanie Blower's avatar
      [clang][patch] Remove test artifact before running test for consistent results · 05ae3035
      Melanie Blower authored
      Fix non-deterministic test behavior by removing previously-created
      test directory, see comments in D95159
      05ae3035
    • Simon Pilgrim's avatar
      [DAG] Add initial SelectionDAG::isGuaranteedNotToBeUndefOrPoison framework (PR51129) · c261a06b
      Simon Pilgrim authored
      I've setup the basic framework for the isGuaranteedNotToBeUndefOrPoison call and updated DAGCombiner::visitFREEZE to use it, further Opcodes can be handled when we have test coverage.
      
      I'm not aware of any vector test freeze coverage so the DemandedElts (and the Depth) args are not being used yet - but they are in place.
      
      SelectionDAG::isGuaranteedNotToBePoison wrappers have also been added.
      
      Differential Revision: https://reviews.llvm.org/D106668
      c261a06b
    • Sanjay Patel's avatar
      [x86] add more tests for add with CMOV of constants; NFC · 937e7c60
      Sanjay Patel authored
      See D106607 / https://llvm.org/PR51069 for details.
      937e7c60
    • Alexander Belyaev's avatar
      [llvm] Inline getAssociatedFunction() in LLVM_DEBUG. · edb05d55
      Alexander Belyaev authored
      Function* F is used only inside LLVM_DEBUG, so that it causes unused
      variable warning.
      edb05d55
    • hyeongyu kim's avatar
      [InstCombine] Add freezeAllUsesOfArgument to visitFreeze · aca5aeb7
      hyeongyu kim authored
      In D106041, a freeze was added before the branch condition to solve the miscompilation problem of SimpleLoopUnswitch.
      However, I found that the added freeze disturbed other optimizations in the following situations.
      ```
      arg.fr = freeze(arg)
      use(arg.fr)
      ...
      use(arg)
      ```
      It is a problem that occurred when arg and arg.fr were recognized as different values.
      Therefore, changing to use arg.fr instead of arg throughout the function eliminates the above problem.
      Thus, I add a function that changes all uses of arg to freeze(arg) to visitFreeze of InstCombine.
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D106233
      aca5aeb7
    • George Balatsouras's avatar
      Revert D106195 "[dfsan] Add wrappers for v*printf functions" · 228bea6a
      George Balatsouras authored
      This reverts commit bf281f36.
      
      This commit causes dfsan to segfault.
      228bea6a
    • Nikita Popov's avatar
      [SimplifyCFG] Add additional if conversion tests (NFC) · 9706dd49
      Nikita Popov authored
      Test a readonly call in between, as well as the combination of
      an atomic and simple store.
      9706dd49
    • Markus Böck's avatar
      [CMake] Add LIBXML2_DEFINITIONS when testing for symbol existance · ffe32b5c
      Markus Böck authored
      Currently when linking LLVM against Libxml2, a simple check is performed to check whether it can be linked successfully. This check currently adds the include directories and the libraries for libxml2, but not definitions found by the config.
      
      This causes issues on Windows when trying to link against a static libxml2. Libxml2 requires LIBXML_STATIC to be defined in the preprocessor to be able to link statically. This definition is put into LIBXML2_DEFINITIONS in the cmake config, but not properly forwarded to check_symbol_exists leading to it failing as it could not find xmlReadMemory in a DLL.
      
      This patch simply appends the content of LIBXML2_DEFINITIONS to the symbol check definitions, fixing the issue.
      
      Differential Revision: https://reviews.llvm.org/D106740
      ffe32b5c
    • Azharuddin Mohammed's avatar
      [CMake] Don't LTO optimize targets on Darwin, but only if its not ThinLTO · 8da3b7d8
      Azharuddin Mohammed authored
      This is just a workaround. Pass the `-mllvm,-O0` link flags only if its
      not ThinLTO. Doing that with ThinLTO currently results in an error:
      
      ```
      Remaining virtual register operands
      UNREACHABLE executed at .../llvm/lib/CodeGen/MachineRegisterInfo.cpp:209!
      ```
      8da3b7d8
    • Amara Emerson's avatar
      [GlobalISel] Add GUnmerge, GMerge, GConcatVectors, GBuildVector abstractions. NFC. · 5ec0f051
      Amara Emerson authored
      Use these to slightly simplify some code in the artifact combiner.
      5ec0f051
    • Lang Hames's avatar
      Re-re-re-apply "[ORC][ORC-RT] Add initial native-TLV support to MachOPlatform." · eda6afda
      Lang Hames authored
      The ccache builders have recevied a config update that should eliminate the
      build issues seen previously.
      eda6afda
    • LLVM GN Syncbot's avatar
      [gn build] Port 96709823 · 698fef3e
      LLVM GN Syncbot authored
      698fef3e
    • Kuter Dinel's avatar
      [AMDGPU] Deduce attributes with the Attributor · 96709823
      Kuter Dinel authored
      This patch introduces a pass that uses the Attributor to deduce AMDGPU specific attributes.
      
      Reviewed By: jdoerfert, arsenm
      
      Differential Revision: https://reviews.llvm.org/D104997
      96709823
    • peter klausler's avatar
      [flang] runtime: fix problems with I/O around EOF & delimited characters · 4d42e16e
      peter klausler authored
      When a WRITE overwrites an endfile record, we need to forget
      that there was an endfile record.  When doing a BACKSPACE
      after an explicit ENDFILE statement, the position afterwards
      must be upon the endfile record.
      
      Attempts to join list-directed delimited character input across
      record boundaries was due to a bad reading of the standard
      and has been deleted, now that the requirements are better understood.
      This problem would cause a read attempt past EOF if a delimited
      character input value was at the end of a record.
      
      It turns out that delimited list-directed (and NAMELIST) character
      output is required to emit contiguous doubled instances of the
      delimiter character when it appears in the output value.  When
      fixed-size records are being emitted, as is the case with internal
      output, this is not possible when the problematic character falls
      on the last position of a record.  No two other Fortran compilers
      do the same thing in this situation so there is no good precedent
      to follow.
      
      Because it seems least wrong, with this patch we now emit one copy
      of the delimiter as the last character of the current record and
      another as the first character of the next record.  (The
      second-least-wrong alternative might be to flag a runtime error,
      but that seems harsh since it's not an explicit error in the standard,
      and the output may not have to be usable later as input anyway.)
      Consequently, the output is not suitable for use as list-directed or
      NAMELIST input.
      
      If a later standard were to clarify this case, this behavior will of
      course change as needed to conform.
      
      Differential Revision: https://reviews.llvm.org/D106695
      4d42e16e
    • peter klausler's avatar
      [flang] Runtime: Reset list-directed input state for each NAMELIST item · e093cbb7
      peter klausler authored
      NAMELIST I/O formatting uses the runtime infrastructure for
      list-directed I/O.  List-directed input processing has same state
      that requires reinitialization for each successive NAMELIST input
      item.  This patch fixes bugs with "null" items and repetition counts
      on NAMELIST input items after the first in the group.
      
      Differential Revision: https://reviews.llvm.org/D106694
      e093cbb7
    • Omar Emara's avatar
      [LLDB][GUI] Check fields validity in actions · 80ac12b7
      Omar Emara authored
      This patch adds a virtual method HasError to fields, it can be
      overridden by fields that have errors. Additionally, a form method
      CheckFieldsValidity was added to be called by actions that expects all
      the field to be valid.
      
      Differential Revision: https://reviews.llvm.org/D106459
      80ac12b7
    • Omar Emara's avatar
      [LLDB][GUI] Add Platform Plugin Field · e160b398
      Omar Emara authored
      This patch adds a new Platform Plugin Field. It is a choices field that
      lists all the available platform plugins and can retrieve the name of the
      selected plugin. The default selected plugin is the currently selected
      one. This patch also allows for arbitrary scrolling to make scrolling
      easier when setting choices.
      
      Differential Revision: https://reviews.llvm.org/D106483
      e160b398
    • Walter Erquinigo's avatar
      [source maps] fix source mapping when there are multiple matching rules · ef8c6849
      Walter Erquinigo authored
      D104406 introduced an error in which, if there are multiple matchings rules for a given path, lldb was only checking for the validity in the filesystem of the first match instead of looking exhaustively one by one until a valid file is found.
      
      Besides that, a call to consume_front was being done incorrectly, as it was modifying the input, which renders subsequent matches incorrect.
      
      I added a test that checks for both cases.
      
      Differential Revision: https://reviews.llvm.org/D106723
      ef8c6849
    • Philip Reames's avatar
      e9d4bb43
    • Philip Reames's avatar
      ec43def7
    • Fangrui Song's avatar
      [LangRef] Clarify comdat · d5401315
      Fangrui Song authored
      * ELF supports `nodeduplicate`.
      * ELF calls the concept "section group". `GRP_COMDAT` emulates the PE COMDAT deduplication feature.
      * "COMDAT group" is an ELF term. Avoid it for PE/COFF.
      * WebAssembly supports comdat but only supports the `any` selection kind. https://bugs.llvm.org/show_bug.cgi?id=50531
      * A comdat must be included or omitted as a unit. Both the compiler and the linker must obey this rule.
      * A global object can be a member of at most one comdat.
      * COFF requires a non-local linkage for non-`nodeduplicate` selection kinds.
      * llvm.global_ctors/.llvm.global_dtors: if the third field is used on ELF, it must reference a global variable or function in a comdat
      
      Reviewed By: rnk
      
      Differential Revision: https://reviews.llvm.org/D106300
      d5401315
    • Kuter Dinel's avatar
      [Attributor][FIX] checkForAllInstructions, correctly handle declarations · 0cd964ff
      Kuter Dinel authored
      checkForAllInstructions was not handling declarations correctly.
      It should have been returning false when it gets called on a declaration
      
      The patch also fixes a test case for AAFunctionReachability for it to be able
      to pass after the changes to the checkForAllinstructions.
      
      Differential Revision: https://reviews.llvm.org/D106625
      0cd964ff
    • Stella Stamenova's avatar
      [cmake] Export LLVM_HOST_TRIPLE in the LLVMConfig.cmake · 328bb2ca
      Stella Stamenova authored
      This is referenced in several of the cmake files that are part of an llvm install and it is also useful by downstream components such as onnx-mlir.
      
      Differential Revision: https://reviews.llvm.org/D106686
      328bb2ca
    • Philip Reames's avatar
      [SCEV] Fix bug involving zero step and non-invariant RHS in trip count logic · 4a3dc7dc
      Philip Reames authored
      Eli pointed out the issue when reviewing D104140. The max trip count logic makes an assumption that the value of IV changes. When the step is zero, the nowrap fact becomes trivial, and thus there's nothing preventing the loop from being nearly infinite. (The "nearly" part is because mustprogress may disallow an infinite loop while still allowing 999999999 iterations before RHS happens to allow an exit.)
      
      This is very difficult to see in practice. You need a means to produce a loop varying RHS in a mustprogress loop which doesn't allow the loop to be infinite. In most cases, LICM or SCEV are smart enough to remove the loop varying expressions.
      
      Differential Revision: https://reviews.llvm.org/D106327
      4a3dc7dc
    • Siva Chandra Reddy's avatar
      [libc] Accommodate Fuchsia's death test framework in fenv tests. · c24c18bb
      Siva Chandra Reddy authored
      Fuchsia's death test framework runs the closure which can die in a
      different thread. Hence, the FP exceptions which cause the closure to
      die should be enalbed in the closure.
      
      Reviewed By: michaelrj
      
      Differential Revision: https://reviews.llvm.org/D106683
      c24c18bb
    • Nico Weber's avatar
      92c085e7
    • Geoffrey Martin-Noble's avatar
      [Bazel] Swap stray td_srcs to deps · 3f2c1e99
      Geoffrey Martin-Noble authored
      This is the last instance of td_srcs in MLIR core build files. `deps` is
      generally preferred. There are still some cases where `td_srcs` is
      useful where creating a td_library would just be another layer of
      indirection, so not (yet) dropping it entirely.
      
      Differential Revision: https://reviews.llvm.org/D106716
      3f2c1e99
    • Roman Lebedev's avatar
    • Nikita Popov's avatar
      [ConstantFold] Fix GEP of GEP fold with opaque pointers · f623b3a2
      Nikita Popov authored
      This was previously combining indices even though they operate on
      different types. For non-opaque pointers, the condition is
      automatically satisfied based on the pointer types being equal.
      f623b3a2
    • Nikita Popov's avatar
      [ConstantFold] Extract GEP of GEP fold (NFCI) · 923727e8
      Nikita Popov authored
      Move this fold into a separate function and clean up the control
      flow a bit.
      923727e8
    • Thomas Lively's avatar
      [WebAssembly] Codegen for pmin and pmax · 85157c00
      Thomas Lively authored
      Replace the clang builtins and LLVM intrinsics for {f32x4,f64x2}.{pmin,pmax}
      with standard codegen patterns. Since wasm_simd128.h uses an integer vector as
      the standard single vector type, the IR for the pmin and pmax intrinsic
      functions contains bitcasts that would not be there otherwise. Add extra codegen
      patterns that can still select the pmin and pmax instructions in the presence of
      these bitcasts.
      
      Differential Revision: https://reviews.llvm.org/D106612
      85157c00