1. Jan 24, 2021
    • Florian Hahn's avatar
      [FuzzMutate] Add mutator to modify instruction flags. · 166d40f2
      Florian Hahn authored
      This patch adds a new InstModificationIRStrategy to mutate flags/options
      for instructions. For example, it may add or remove nuw/nsw flags from
      add, mul, sub, shl instructions or change the predicate for icmp
      instructions.
      
      Subtle changes such as those mentioned above should lead to a more
      interesting range of inputs. The presence or absence of overflow flags
      can expose subtle bugs, for example.
      
      Reviewed By: bogner
      
      Differential Revision: https://reviews.llvm.org/D94905
      166d40f2
    • Michael Kruse's avatar
      [Polly] Track defined behavior for PHI predecessor computation. · 3b9677e1
      Michael Kruse authored
      ZoneAlgorithms's computePHI relies on being provided with consistent a
      schedule to compute the statement prodecessors of a statement containing
      PHINodes. Otherwise unexpected results such as PHI nodes with multiple
      predecessors can occur which would result in problems in the
      algorithms expecting consistent data.
      
      In the added test case, statement instances are scrubbed from the
      SCoP their execution would result in undefined behavior (Due to a nsw
      overflow). As already being undefined behavior in LLVM-IR, neither
      AssumedContext nor InvalidContext are updated, giving computePHI no
      means to avoid these cases.
      
      Intoduce a new SCoP property, the DefinedBehaviorContext, that among
      the runtime-checked conditions, also tracks the assumptions not needing
      a runtime check, in particular those affecting the assumed control flow.
      This replaces the manual combination of the 3 other contexts that was
      already done in computePHI and setNewAccessRelation. Curr...
      3b9677e1
    • Michael Kruse's avatar
      [Polly] Allow param sets for dumpPw(). · 02e8a5ad
      Michael Kruse authored
      02e8a5ad
    • Michael Kruse's avatar
      de0457a0
    • Michael Kruse's avatar
      [Polly] Gist new access relations using the SCoP context. · a5b89511
      Michael Kruse authored
      This simplifies the access relations.
      a5b89511
    • Kazu Hirata's avatar
      [llvm] Use pop_back_val (NFC) · 1238378f
      Kazu Hirata authored
      1238378f
    • Kazu Hirata's avatar
      [Target] Use llvm::append_range (NFC) · cc7a2382
      Kazu Hirata authored
      cc7a2382
    • Kazu Hirata's avatar
      [llvm] Forward-declare ICFLoopSafetyInfo (NFC) · 2f1ffa94
      Kazu Hirata authored
      LoopUtils.h needs ICFLoopSafetyInfo but relies on a forward
      declaration of ICFLoopSafetyInfo in IVDescriptors.h.  This patch adds
      a forward declaration right in LoopUtils.h.
      
      While we are at it, this patch removes the one in IVDescriptors.h,
      where it is unnecessary.
      2f1ffa94
    • Florian Hahn's avatar
      [InstCombine] Set MadeIRChange in replaceInstUsesWith. · d60b74c2
      Florian Hahn authored
      Some utilities used by InstCombine, like SimplifyLibCalls, may add new
      instructions and replace the uses of a call, but return nullptr because
      the inserted call produces multiple results.
      
      Previously, the replaced library calls would get removed by
      InstCombine's deleter, but after
      29207707 this may not happen, if the
      willreturn attribute is missing.
      
      As a work-around, update replaceInstUsesWith to set MadeIRChange, if it
      replaces any uses. This catches the cases where it is used as replacer
      by utilities used by InstCombine and seems useful in general; updating
      uses will modify the IR.
      
      This fixes an expensive-check failure when replacing
      @__sinpif/@__cospifi with @__sincospif_sret.
      d60b74c2
    • Mark de Wever's avatar
      [libc++] Implements concept destructible · a8e06361
      Mark de Wever authored
      Implements parts of:
      - P0898R3 Standard Library Concepts
      - P1754 Rename concepts to standard_case for C++20, while we still can
      
      Reviewed By: ldionne, miscco, #libc
      
      Differential Revision: https://reviews.llvm.org/D91004
      a8e06361
    • Dan Liew's avatar
      [ASan] Fix broken Windows build due to 596d534a. · 757b93bb
      Dan Liew authored
      In that change I forgot to update the call to
      `AsanThread::ThreadStart()` in `asan_win.cpp`.
      757b93bb
    • Ben Shi's avatar
      [AVR] Optimize 16-bit comparison with constant · 1eb8c5cd
      Ben Shi authored
      Reviewed By: dylanmckay
      
      Differential Revision: https://reviews.llvm.org/D93976
      1eb8c5cd
    • Sanjay Patel's avatar
      [SLP] fix fast-math-flag propagation on FP reductions · a6f02212
      Sanjay Patel authored
      As shown in the test diffs, we could miscompile by
      propagating flags that did not exist in the original
      code.
      
      The flags required for fmin/fmax reductions will be
      fixed in a follow-up patch.
      a6f02212
    • Sanjay Patel's avatar
      39e1e53a
    • Florian Hahn's avatar
      [Local] Treat calls that may not return as being alive. · 29207707
      Florian Hahn authored
      With the addition of the `willreturn` attribute, functions that may
      not return (e.g. due to an infinite loop) are well defined, if they are
      not marked as `willreturn`.
      
      This patch updates `wouldInstructionBeTriviallyDead` to not consider
      calls that may not return as dead.
      
      This patch still provides an escape hatch for intrinsics, which are
      still assumed as willreturn unconditionally. It will be removed once
      all intrinsics definitions have been reviewed and updated.
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D94106
      29207707
  2. Jan 23, 2021
    • Ben Shi's avatar
      [AVR] Optimize 8-bit logic left/right shifts · 25531a1d
      Ben Shi authored
      Reviewed By: dylanmckay
      
      Differential Revision: https://reviews.llvm.org/D89047
      25531a1d
    • Pedro Tammela's avatar
      [lldb/Lua] add 'Lua' before naming versions · 2bbc762b
      Pedro Tammela authored
      NFC
      2bbc762b
    • Pedro Tammela's avatar
      [lldb/Lua] add initial Lua typemaps · 5997e898
      Pedro Tammela authored
      This patch adds the integer handling typemaps and the typemap for
      string returning functions.
      
      The integer handling typemaps overrides SWIG's own typemaps to distinct
      the handling of integers from floating point.
      
      The typemap for string returning functions is a port of Python's
      typemap.
      
      Differential Revision: https://reviews.llvm.org/D94937
      5997e898
    • LLVM GN Syncbot's avatar
      [gn build] Port 0057cc5a · d5c4de40
      LLVM GN Syncbot authored
      d5c4de40
    • Ayke van Laethem's avatar
    • Roman Lebedev's avatar
      [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set,... · 022da61f
      Roman Lebedev authored
      [SimplifyCFG] Change 'LoopHeaders' to be ArrayRef<WeakVH>, not a naked set, thus avoiding dangling pointers
      
      If i change it to AssertingVH instead, a number of existing tests fail,
      which means we don't consistently remove from the set when deleting blocks,
      which means newly-created blocks may happen to appear in that set
      if they happen to occupy the same memory chunk as did some block
      that was in the set originally.
      
      There are many places where we delete blocks,
      and while we could probably consistently delete from LoopHeaders
      when deleting a block in transforms located in SimplifyCFG.cpp itself,
      transforms located elsewhere (Local.cpp/BasicBlockUtils.cpp) also may
      delete blocks, and it doesn't seem good to teach them to deal with it.
      
      Since we at most only ever delete from LoopHeaders,
      let's just delegate to WeakVH to do that automatically.
      
      But to be honest, personally, i'm not sure that the idea
      behind LoopHeaders is sound.
      022da61f
    • LLVM GN Syncbot's avatar
      [gn build] Port 2325157c · dbf87da7
      LLVM GN Syncbot authored
      dbf87da7
    • Ayke van Laethem's avatar
      [Clang] Move assembler into a separate file · 2325157c
      Ayke van Laethem authored
      This change adds an AssemblerInvocation class, similar to the
      CompilerInvocation class. It can be used to invoke cc1as directly.
      
      The project I'm working on wants to compile Clang and use it as a static
      library. For that to work, there must be a way to invoke the assembler
      programmatically, using the same arguments as you would otherwise pass
      to cc1as.
      
      Differential Revision: https://reviews.llvm.org/D63852
      2325157c
    • Nikita Popov's avatar
      [LSR] Add test for PR46943 (NFC) · a49a3a3e
      Nikita Popov authored
      LSR should be dropping nowrap flags when adding new postinc users.
      a49a3a3e
    • Florian Hahn's avatar
      [LTO] Store target attributes as vector of strings (NFC). · 08dbcc14
      Florian Hahn authored
      The target features are obtained as a list of features/attributes.
      Instead of storing them in a single string, store the vector. This
      matches lto::Config's behavior and simplifies the transition to
      lto::backend().
      
      Reviewed By: tejohnson
      
      Differential Revision: https://reviews.llvm.org/D95224
      08dbcc14
    • Jeroen Dobbelaere's avatar
      [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments. · 2b9a834c
      Jeroen Dobbelaere authored
      Insert a llvm.experimental.noalias.scope.decl intrinsic that identifies where a noalias argument was inlined.
      
      This patch includes some refactorings from D90104.
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D93040
      2b9a834c
    • Simon Pilgrim's avatar
      [Support] TrigramIndex::insert - pass std::String argument by const reference. NFCI. · 344afa85
      Simon Pilgrim authored
      Avoid string copies and fix clang-tidy warning.
      344afa85
    • Roger Ferrer Ibanez's avatar
      [RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making... · d4ce0623
      Roger Ferrer Ibanez authored
      [RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making them immediately unreachable from the stack pointer
      
      In RISC-V there is a single addressing mode of the form imm(reg) where
      imm is a signed integer of 12-bit with a range of [-2048..2047] bytes
      from reg.
      
      The test MultiSource/UnitTests/C++11/frame_layout of the LLVM test-suite
      exercises several scenarios with the stack, including function calls
      where the stack will need to be realigned to to a local variable having
      a large alignment of 4096 bytes.
      
      In situations of large stacks, the RISC-V backend (in
      RISCVFrameLowering) reserves an extra emergency spill slot which can be
      used (if no free register is found) by the register scavenger after the
      frame indexes have been eliminated. PrologEpilogInserter already takes
      care of keeping the emergency spill slots as close as possible to the
      stack pointer or frame pointer (depending on what the function will
      use). However there is a final alignment step to honour the maximum
      alignment of the stack that, when using the stack pointer to access the
      emergency spill slots, has the side effect of setting them farther from
      the stack pointer.
      
      In the case of the frame_layout testcase, the net result is that we do
      have an emergency spill slot but it is so far from the stack pointer
      (more than 2048 bytes due to the extra alignment of a variable to 4096
      bytes) that it becomes unreachable via any immediate offset.
      
      During elimination of the frame index, many (regular) offsets of the
      stack may be immediately unreachable already. Their address needs to be
      computed using a register. A virtual register is created and later
      RegisterScavenger should be able to find an unused (physical) register.
      However if no register is available, RegisterScavenger will pick a
      physical register and spill it onto an emergency stack slot, while we
      compute the offset (restoring the chosen register after all this). This
      assumes that the emergency stack slot is easily reachable (this is,
      without requiring another register!).
      
      This is the assumption we seem to break when we perform the extra
      alignment in PrologEpilogInserter.
      
      We can "float" the emergency spill slots by increasing (in absolute
      value) their offsets from the incoming stack pointer. This way the
      emergency spill slots will remain close to the stack pointer (once the
      function has allocated storage for the stack, including the needed
      realignment). The new size computed in PrologEpilogInserter is padding
      so it should be OK to move the emergency spill slots there. Also because
      we're increasing the alignment, the new location should stay aligned for
      the purpose of the emergency spill slots.
      
      Note that this change also impacts other backends as shown by the tests.
      Changes are minor adjustments to the emergency stack slot offset.
      
      Differential Revision: https://reviews.llvm.org/D89239
      d4ce0623
    • Sergey Dmitriev's avatar
      [llvm-link] Fix for an assertion when linking global with appending linkage · 267a57a6
      Sergey Dmitriev authored
      This patch fixes llvm-link assertion when linking external variable
      declaration with a definition with appending linkage.
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D95126
      267a57a6
    • Dan Liew's avatar
      [ASan] Stop blocking child thread progress from parent thread in `pthread_create` interceptor. · 596d534a
      Dan Liew authored
      Previously in ASan's `pthread_create` interceptor we would block in the
      `pthread_create` interceptor waiting for the child thread to start.
      
      Unfortunately this has bad performance characteristics because the OS
      scheduler doesn't know the relationship between the parent and child
      thread (i.e. the parent thread cannot make progress until the child
      thread makes progress) and may make the wrong scheduling decision which
      stalls progress.
      
      It turns out that ASan didn't use to block in this interceptor but was
      changed to do so to try to address
      http://llvm.org/bugs/show_bug.cgi?id=21621/.
      
      In that bug the problem being addressed was a LeakSanitizer false
      positive. That bug concerns a heap object being passed
      as `arg` to `pthread_create`. If:
      
      * The calling thread loses a live reference to the object (e.g.
        `pthread_create` finishes and the thread no longer has a live
        reference to the object).
      * Leak checking is triggered.
      * The child thread has not yet started (once it starts it will have a
        live reference).
      
      then the heap object will incorrectly appear to be leaked.
      
      This bug is covered by the `lsan/TestCases/leak_check_before_thread_started.cpp` test case.
      
      In b029c510 ASan was changed to block
      in `pthread_create()` until the child thread starts so that `arg` is
      kept alive for the purposes of leaking check.
      
      While this change "works" its problematic due to the performance
      problems it causes. The change is also completely unnecessary if leak
      checking is disabled (via detect_leaks runtime option or
      CAN_SANITIZE_LEAKS compile time config).
      
      This patch does two things:
      
      1. Takes a different approach to solving the leak false positive by
         making LSan's leak checking mechanism treat the `arg` pointer of
         created but not started threads as reachable.  This is done by
         implementing the `ForEachRegisteredThreadContextCb` callback for
         ASan.
      
      2. Removes the blocking behaviour in the ASan `pthread_create`
         interceptor.
      
      rdar://problem/63537240
      
      Differential Revision: https://reviews.llvm.org/D95184
      596d534a
    • Kazu Hirata's avatar
      [llvm] Use static_assert instead of assert (NFC) · 49231c1f
      Kazu Hirata authored
      Identified with misc-static-assert.
      49231c1f
    • Kazu Hirata's avatar
      [llvm] Use isAlpha/isAlnum (NFC) · 5f843b2d
      Kazu Hirata authored
      5f843b2d
    • Kazu Hirata's avatar
      [Analysis] Use llvm::append_range (NFC) · a3254904
      Kazu Hirata authored
      a3254904
    • George Koehler's avatar
      [PowerPC] Fix va_arg in C++, Objective-C on 32-bit ELF targets · 018984ae
      George Koehler authored
      In the PPC32 SVR4 ABI, a va_list has copies of registers from the function call.
      va_arg looked in the wrong registers for (the pointer representation of) an
      object in Objective-C, and for some types in C++. Fix va_arg to look in the
      general-purpose registers, not the floating-point registers. Also fix va_arg
      for some C++ types, like a member function pointer, that are aggregates for
      the ABI.
      
      Anthony Richardby found the problem in Objective-C. Eli Friedman suggested
      part of this fix.
      
      Fixes https://bugs.llvm.org/show_bug.cgi?id=47921
      
      Reviewed By: efriedma, nemanjai
      
      Differential Revision: https://reviews.llvm.org/D90329
      018984ae
    • Xun Li's avatar
      [Coroutine] Improve coro-elide-musttail.ll test · 6c435645
      Xun Li authored
      The test wasn't sensitive to alias analysis. As you can seen from D95117 when AA is added by default this is affected.
      Updating the test so that it coveres both cases for AA analysis.
      Note that this patch depends on D95117 to land first.
      
      Differential Revision: https://reviews.llvm.org/D95247
      6c435645
    • Craig Topper's avatar
    • Dan Liew's avatar
      [LSan] Introduce a callback mechanism to allow adding data reachable from... · dd922bc2
      Dan Liew authored
      [LSan] Introduce a callback mechanism to allow adding data reachable from ThreadContexts to the frontier.
      
      This mechanism is intended to provide a way to treat the `arg` pointer
      of a created (but not yet started) thread as reachable. In future
      patches this will be implemented in `GetAdditionalThreadContextPtrs`.
      
      A separate implementation of `GetAdditionalThreadContextPtrs` exists
      for ASan and LSan runtimes because they need to be implemented
      differently in future patches.
      
      rdar://problem/63537240
      
      Differential Revision: https://reviews.llvm.org/D95183
      dd922bc2
    • Fangrui Song's avatar
      [test] Add -mtriple · 6fe193bf
      Fangrui Song authored
      6fe193bf
    • Fangrui Song's avatar
      [ELF][test] Add a test about --exclude-libs applying to version symbols · eda973bb
      Fangrui Song authored
      D94280 also fixed PR48702.
      eda973bb
    • Cassie Jones's avatar
      Recommit "[AArch64][GlobalISel] Make G_USUBO legal and select it." · bd64ad3f
      Cassie Jones authored
      The expansion for wide subtractions includes G_USUBO.
      
      Differential Revision: https://reviews.llvm.org/D95032
      
      This was miscompiling on ubsan bots.
      bd64ad3f