1. May 18, 2021
    • Marius Brehler's avatar
      dfd929d2
    • Balazs Benics's avatar
      [ASTimporter] Remove decl from lookup only if it has decl context · 88ee91cd
      Balazs Benics authored
      In the case of TypedefDecls we set the DeclContext after we imported it.
      It turns out, it could lead to null pointer dereferences during the
      cleanup part of a failed import.
      
      This patch demonstrates this issue and fixes it by checking if the
      DeclContext is available or not.
      
      Reviewed By: shafik
      
      Differential Revision: https://reviews.llvm.org/D102640
      88ee91cd
    • Raphael Isemann's avatar
      [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB · bbea3610
      Raphael Isemann authored
      A long time ago LLDB wanted to start using StringRef instead of
      C-Strings/ConstString but was blocked by the fact that the StringRef constructor
      that takes a C-string was asserting that the C-string isn't a nullptr. To
      workaround this, D24697 introduced a special function called `withNullAsEmpty`
      and that's what LLDB (and only LLDB) started to use to build StringRefs from
      C-strings.
      
      A bit later it seems that `withNullAsEmpty` was declared too awkward to use and
      instead the assert in the StringRef constructor got removed (see D24904). The
      rest of LLDB was then converted to StringRef by just calling the now perfectly
      usable implicit constructor.
      
      However, all the calls to `withNullAsEmpty` just remained and are now just
      strange artefacts in the code base that just look out of place. It's also
      curiously a LLDB-exclusive function and no other project ever called it since
      it's introduction half a decade ago.
      
      This patch removes all uses of `withNullAsEmpty`. The follow up will be to
      remove the function from StringRef.
      
      Reviewed By: JDevlieghere
      
      Differential Revision: https://reviews.llvm.org/D102597
      bbea3610
    • Vitaly Buka's avatar
      2e92f1a9
    • David Green's avatar
      [RDA] Fix printing of regs / reg units. NFC · b3d38327
      David Green authored
      It was printing RegUnits as Regs, leading to much confusion in the debug
      logs.
      b3d38327
    • Sander de Smalen's avatar
      [LV] Return both fixed and scalable Max VF from computeMaxVF. · 81fdc73e
      Sander de Smalen authored
      This patch introduces a new class, MaxVFCandidates, that holds the
      maximum vectorization factors that have been computed for both scalable
      and fixed-width vectors.
      
      This patch is intended to be NFC for fixed-width vectors, although
      considering a scalable max VF (which is disabled by default) pessimises
      tail-loop elimination, since it can no longer determine if any chosen VF
      (less than fixed/scalable MaxVFs) is guaranteed to handle all vector
      iterations if the trip-count is known. This issue will be addressed in
      a future patch.
      
      Reviewed By: fhahn, david-arm
      
      Differential Revision: https://reviews.llvm.org/D98721
      81fdc73e
    • Dmitry Vyukov's avatar
      sanitizer_common/symbolizer: fix crashes during exit · 00a10075
      Dmitry Vyukov authored
      Override __cxa_atexit and ignore callbacks.
      This prevents crashes in a configuration when the symbolizer
      is built into sanitizer runtime and consequently into the test process.
      LLVM libraries have some global objects destroyed during exit,
      so if the test process triggers any bugs after that, the symbolizer crashes.
      An example stack trace of such crash:
      
      For the standalone llvm-symbolizer this does not hurt,
      we just don't destroy few global objects on exit.
      
      Reviewed By: kda
      
      Differential Revision: https://reviews.llvm.org/D102470
      00a10075
    • Pushpinder Singh's avatar
      [AMDGPU][Libomptarget] Rename & move g_executables to private · d7503c3b
      Pushpinder Singh authored
      This patch moves g_executables to private member of Runtime class
      and is renamed to HSAExecutables following LLVM naming convention.
      
      This movement required making Runtime::Initialize and Runtime::Finalize
      non-static. Verified the correctness of this change by running
      libomptarget tests on gfx906.
      
      Reviewed By: JonChesterfield
      
      Differential Revision: https://reviews.llvm.org/D102600
      d7503c3b
    • Ten Tzen's avatar
      [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1 · 797ad701
      Ten Tzen authored
      This patch is the Part-1 (FE Clang) implementation of HW Exception handling.
      
      This new feature adds the support of Hardware Exception for Microsoft Windows
      SEH (Structured Exception Handling).
      This is the first step of this project; only X86_64 target is enabled in this patch.
      
      Compiler options:
      For clang-cl.exe, the option is -EHa, the same as MSVC.
      For clang.exe, the extra option is -fasync-exceptions,
      plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.
      
      NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.
      
      The rules for C code:
      For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow
      three rules:
      * First, no exception can move in or out of _try region., i.e., no "potential
        faulty instruction can be moved across _try boundary.
      * Second, the order of exceptions for instructions 'directly' under a _try
        must be preserved (not applied to those in callees).
      * Finally, global states (local/global/heap variables) that can be read
        outside of _try region must be updated in memory (not just in register)
        before the subsequent exception occurs.
      
      The impact to C++ code:
      Although SEH is a feature for C code, -EHa does have a profound effect on C++
      side. When a C++ function (in the same compilation unit with option -EHa ) is
      called by a SEH C function, a hardware exception occurs in C++ code can also
      be handled properly by an upstream SEH _try-handler or a C++ catch(...).
      As such, when that happens in the middle of an object's life scope, the dtor
      must be invoked the same way as C++ Synchronous Exception during unwinding
      process.
      
      Design:
      A natural way to achieve the rules above in LLVM today is to allow an EH edge
      added on memory/computation instruction (previous iload/istore idea) so that
      exception path is modeled in Flow graph preciously. However, tracking every
      single memory instruction and potential faulty instruction can create many
      Invokes, complicate flow graph and possibly result in negative performance
      impact for downstream optimization and code generation. Making all
      optimizations be aware of the new semantic is also substantial.
      
      This design does not intend to model exception path at instruction level.
      Instead, the proposed design tracks and reports EH state at BLOCK-level to
      reduce the complexity of flow graph and minimize the performance-impact on CPP
      code under -EHa option.
      
      One key element of this design is the ability to compute State number at
      block-level. Our algorithm is based on the following rationales:
      
      A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping
      into a _try is not allowed. The single entry must start with a seh_try_begin()
      invoke with a correct State number that is the initial state of the SEME.
      Through control-flow, state number is propagated into all blocks. Side exits
      marked by seh_try_end() will unwind to parent state based on existing
      SEHUnwindMap[].
      Note side exits can ONLY jump into parent scopes (lower state number).
      Thus, when a block succeeds various states from its predecessors, the lowest
      State triumphs others.  If some exits flow to unreachable, propagation on those
      paths terminate, not affecting remaining blocks.
      For CPP code, object lifetime region is usually a SEME as SEH _try.
      However there is one rare exception: jumping into a lifetime that has Dtor but
      has no Ctor is warned, but allowed:
      
      Warning: jump bypasses variable with a non-trivial destructor
      
      In that case, the region is actually a MEME (multiple entry multiple exits).
      Our solution is to inject a eha_scope_begin() invoke in the side entry block to
      ensure a correct State.
      
      Implementation:
      Part-1: Clang implementation described below.
      
      Two intrinsic are created to track CPP object scopes; eha_scope_begin() and eha_scope_end().
      _scope_begin() is immediately added after ctor() is called and EHStack is pushed.
      So it must be an invoke, not a call. With that it's also guaranteed an
      EH-cleanup-pad is created regardless whether there exists a call in this scope.
      _scope_end is added before dtor(). These two intrinsics make the computation of
      Block-State possible in downstream code gen pass, even in the presence of
      ctor/dtor inlining.
      
      Two intrinsic, seh_try_begin() and seh_try_end(), are added for C-code to mark
      _try boundary and to prevent from exceptions being moved across _try boundary.
      All memory instructions inside a _try are considered as 'volatile' to assure
      2nd and 3rd rules for C-code above. This is a little sub-optimized. But it's
      acceptable as the amount of code directly under _try is very small.
      
      Part-2 (will be in Part-2 patch): LLVM implementation described below.
      
      For both C++ & C-code, the state of each block is computed at the same place in
      BE (WinEHPreparing pass) where all other EH tables/maps are calculated.
      In addition to _scope_begin & _scope_end, the computation of block state also
      rely on the existing State tracking code (UnwindMap and InvokeStateMap).
      
      For both C++ & C-code, the state of each block with potential trap instruction
      is marked and reported in DAG Instruction Selection pass, the same place where
      the state for -EHsc (synchronous exceptions) is done.
      If the first instruction in a reported block scope can trap, a Nop is injected
      before this instruction. This nop is needed to accommodate LLVM Windows EH
      implementation, in which the address in IPToState table is offset by +1.
      (note the purpose of that is to ensure the return address of a call is in the
      same scope as the call address.
      
      The handler for catch(...) for -EHa must handle HW exception. So it is
      'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches
      C++ exceptions).
      Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW
      exceptions can be passed through.
      
      Original llvm-dev [RFC] discussions can be found in these two threads below:
      https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
      https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html
      
      Differential Revision: https://reviews.llvm.org/D80344/new/
      797ad701
    • Pushpinder Singh's avatar
      [AMDGPU][libomptarget] Remove unused global variables · 3bc2b97b
      Pushpinder Singh authored
      This initial patch removes some unused variables from global namespace.
      There will more incoming patches for moving global variables to classes
      or static members.
      
      Reviewed By: JonChesterfield
      
      Differential Revision: https://reviews.llvm.org/D102598
      3bc2b97b
    • Serguei Katkov's avatar
    • Alexander Shaposhnikov's avatar
      [lld][MachO] Adjust isCodeSection signature · dc2c6cf2
      Alexander Shaposhnikov authored
      This diff changes the type of the argument of isCodeSection to const InputSection *.
      NFC.
      
      Test plan: make check-lld-macho
      
      Differential revision: https://reviews.llvm.org/D102664
      dc2c6cf2
    • Adam Nemet's avatar
      [GVN] Improve analysis for missed optimization remark · ab1f6ffa
      Adam Nemet authored
      This change tries to handle multiple dominating users of the pointer operand
      by choosing the most immediately dominating one, if possible.  While making
      this change I also found that the previous implementation had a missing break
      statement, making all loads with an odd number of dominating users emit an
      OtherAccess value, so that has also been fixed.
      
      Patch by Henrik G Olsson!
      
      Differential Revision: https://reviews.llvm.org/D79097
      ab1f6ffa
    • Chen Zheng's avatar
      [PowerPC] only check the load instruction result number 0. · 15d4ed6d
      Chen Zheng authored
      Reviewed By: nemanjai
      
      Differential Revision: https://reviews.llvm.org/D102596
      15d4ed6d
    • Sam Clegg's avatar
      [lld][WebAssembly] Refactor input chunk class hierarchy. NFC · 5a9b25e1
      Sam Clegg authored
      The main motivation for this refactor is to remove the subclass
      relationship between the InputSegment and MergeInputSegment and
      SyntenticMergedInputSegment so that we can use the merging classes for
      debug sections which are not data segments.
      
      In the process of refactoring I also remove all the virtual functions
      from the class hierarchy and try to reuse techniques used in the ELF
      linker (see `lld/ELF/InputSections.h`).
      
      Differential Revision: https://reviews.llvm.org/D102546
      5a9b25e1
    • Philip Reames's avatar
      Revert "[LV] Unconditionally branch from middle to scalar preheader if the... · ed9d7078
      Philip Reames authored
      Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute (try 3)"
      
      This reverts commit 6d3e3ae8.
      
      Still seeing PPC build bot failures, and one arm self host bot failing.  I'm officially stumped, and need help from a bot owner to reduce.
      ed9d7078
    • Stella Stamenova's avatar
      Revert "[ADT] Add new type traits for type pack indexes" · 2d1f2ba7
      Stella Stamenova authored
      This reverts commit a6d3987b.
      2d1f2ba7
    • Michael Kruse's avatar
      [Polly] Add support for -polly-dump-after(-file) with the NPM. · ad568f42
      Michael Kruse authored
      For the same reason as with -polly-dump-before, it is only supported
      with -polly-position=early.
      ad568f42
    • Serguei Katkov's avatar
      [Inliner] Copy attributes when deoptimize intrinsic is inlined · 7bed58d2
      Serguei Katkov authored
      During inlining of call-site with deoptimize intrinsic callee we miss
      attributes set on this call site. As a result attributes like deopt-lowering are
      disappeared resulting in inefficient behavior of register allocator in codegen.
      
      Just copy attributes for deoptimize call like we do for others calls.
      
      Reviewers: reames, apilipenko
      Reviewed By: reames
      Subscribers: llvm-commits
      Differential Revision: https://reviews.llvm.org/D102602
      7bed58d2
    • Michael Kruse's avatar
      [Polly] Add support for -polly-dump-before(-file) with the NPM. · 29bef8e4
      Michael Kruse authored
      Only supported with -polly-position=early. Unfortunately, the
      extension point callpack for VectorizerStart only passes a
      FunctionPassManager, making it impossible to add a module pass.
      29bef8e4
    • Arthur Eubanks's avatar
      [NFC] Pass GV value type instead of pointer type to GetOrCreateLLVMGlobal · 9f7d552c
      Arthur Eubanks authored
      For opaque pointers, to avoid PointerType::getElementType().
      
      Reviewed By: dblaikie
      
      Differential Revision: https://reviews.llvm.org/D102638
      9f7d552c
    • Arthur Eubanks's avatar
      cc64ece7
    • Adam Nemet's avatar
      [Matrix] Fold the transpose into the matmul operand used to fetch scalars · fcffd087
      Adam Nemet authored
      For column-major this is:
        A * B^t
      whereas for row-major:
        A^t * B
      
      Differential Revision: https://reviews.llvm.org/D101762
      fcffd087
    • Rob Suderman's avatar
      [mlir][tosa] Cleanup of tosa.rescale lowering to linalg · a91fb432
      Rob Suderman authored
      Comment was poorly written. Changed to bail on contradictory information in
      the double round.
      
      Reviewed By: NatashaKnk
      
      Differential Revision: https://reviews.llvm.org/D102651
      a91fb432
    • Med Ismail Bennani's avatar
      [lldb/API] Use a valid LineEntry object in SBCompileUnit::FindLineEntryIndex · 1b4d5b3b
      Med Ismail Bennani authored
      This patch updates `SBCompileUnit::FindLineEntryIndex` to pass a valid
      `LineEntry` pointer to `CompileUnit::FindLineEntry`.
      
      This caused `LineTable::FindLineEntryIndexByFileIndexImpl` to return its
      `best_match` initial value (UINT32_MAX).
      
      rdar://78115426
      
      Differential Revision: https://reviews.llvm.org/D102658
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      1b4d5b3b
    • Nico Weber's avatar
      [lld/mac] Inline a check · bc588f99
      Nico Weber authored
      `match()` can only return for non-empty vectors, but at least in
      non-LTO builds that isn't clear to the compiler. Help it out.
      This is a minor but measurable speedup on my machine (but less
      than what we might've lost in https://reviews.llvm.org/D100818#2764272 --
      bot note higher N on this measurement here, so higher confidence here):
      
          % ministat at_main at_branch
          x at_main
          + at_branch
              N           Min           Max        Median           Avg        Stddev
          x  30     3.9243979     4.0395119      3.987375     3.9826236   0.027567796
          +  30     3.8495831     4.0009291      3.931325     3.9347135   0.037832878
          Difference at 95.0% confidence
                  -0.0479101 +/- 0.0171102
                  -1.20298% +/- 0.429622%
                  (Student's t, pooled s = 0.0331007)
      
      No behavior change.
      
      Eventually we should apply these lists at symbol parse time instead of
      every time shouldExportSymbol() though :)
      
      Differential Revision: https://reviews.llvm.org/D102655
      bc588f99
    • Philip Reames's avatar
      [LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute (try 3) · 6d3e3ae8
      Philip Reames authored
      Resubmit after fixing test/Transforms/LoopVectorize/ARM/mve-gather-scatter-tailpred.ll
      
      Previous commit message...
      
      This is a resubmit of 3e5ce4 (which was reverted by 7fe41ac3).  The original commit caused a PPC build bot failure we never really got to the bottom of.  I can't reproduce the issue, and the bot owner was non-responsive.  In the meantime, we stumbled across an issue which seems possibly related, and worked around a latent bug in 80e80250.  My best guess is that the original patch exposed that latent issue at higher frequency, but it really is just a guess.
      
      Original commit message follows...
      
      If we know that the scalar epilogue is required to run, modify the CFG to end the middle block with an unconditional branch to scalar preheader. This is instead of a conditional branch to either the preheader or the exit block.
      
      The motivation to do this is to support multiple exit blocks. Specifically, the current structure forces us to identify immediate dominators and *which* exit block to branch from in the middle terminator. For the multiple exit case - where we know require scalar will hold - these questions are ill formed.
      
      This is the last change needed to support multiple exit loops, but since the diffs are already large enough, I'm going to land this, and then enable separately. You can think of this as being NFCIish prep work, but the changes are a bit too involved for me to feel comfortable tagging the review that way.
      
      Differential Revision: https://reviews.llvm.org/D94892
      6d3e3ae8
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Do not check denorm for LDS FP atomic with unsafe flag · 45764efb
      Stanislav Mekhanoshin authored
      This is already how it is handled for global and flat atomics.
      
      Differential Revision: https://reviews.llvm.org/D102366
      45764efb
    • Philip Reames's avatar
      Revert "[LV] Unconditionally branch from middle to scalar preheader if the... · d16da734
      Philip Reames authored
      Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute"
      
      This reverts commit c23ce54b.  I apparently missed some newly added non-x86 tests.
      d16da734
    • Philip Reames's avatar
      [LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute · c23ce54b
      Philip Reames authored
      This is a resubmit of 3e5ce4 (which was reverted by 7fe41ac3).  The original commit caused a PPC build bot failure we never really got to the bottom of.  I can't reproduce the issue, and the bot owner was non-responsive.  In the meantime, we stumbled across an issue which seems possibly related, and worked around a latent bug in 80e80250.  My best guess is that the original patch exposed that latent issue at higher frequency, but it really is just a guess.
      
      Original commit message follows...
      
      If we know that the scalar epilogue is required to run, modify the CFG to end the middle block with an unconditional branch to scalar preheader. This is instead of a conditional branch to either the preheader or the exit block.
      
      The motivation to do this is to support multiple exit blocks. Specifically, the current structure forces us to identify immediate dominators and *which* exit block to branch from in the middle terminator. For the multiple exit case - where we know require scalar will hold - these questions are ill formed.
      
      This is the last change needed to support multiple exit loops, but since the diffs are already large enough, I'm going to land this, and then enable separately. You can think of this as being NFCIish prep work, but the changes are a bit too involved for me to feel comfortable tagging the review that way.
      
      Differential Revision: https://reviews.llvm.org/D94892
      c23ce54b
    • Ben Shi's avatar
      [RISCV][test] Add new tests of or/xor in the zbs extension · 3cf7983c
      Ben Shi authored
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D102625
      3cf7983c
    • Ben Shi's avatar
      [clang][AVR] Redefine [u]int16_t to be compatible with avr-gcc · b99e2c56
      Ben Shi authored
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D102547
      b99e2c56
    • Jim Ingham's avatar
      Revert "Reset the wakeup timeout when we re-enter the continue wait." · 82a38837
      Jim Ingham authored
      This reverts commit bd5751f3.
      This patch series is causing us to every so often miss switching
      the state from eStateRunning to eStateStopped when we get the stop
      packet from the debug server.
      
      Reverting till I can figure out how that could be happening.
      82a38837
    • Scott Linder's avatar
      [ADT] Add new type traits for type pack indexes · a6d3987b
      Scott Linder authored
      Similar versions of these already exist, this effectively just just
      factors them out into STLExtras. I plan to use these in future patches.
      
      Differential Revision: https://reviews.llvm.org/D100672
      a6d3987b
    • Scott Linder's avatar
      af5247c9
    • Eli Friedman's avatar
      [AArch64][SVE] Implement extractelement of i1 vectors. · 3dd49ec1
      Eli Friedman authored
      The implementation just extends the vector to a larger element type, and
      extracts from that.  Not fancy, but generates reasonable code.
      
      There was discussion in the review of doing the promotion in
      target-independent code, but I'm sticking with this to avoid making
      LegalizeDAG infrastructure more complicated.
      
      Differential Revision: https://reviews.llvm.org/D87651
      3dd49ec1
    • Philip Reames's avatar
      Do actual DCE in LoopUnroll (try 3) · b6320eeb
      Philip Reames authored
      Recommitting after fixing a bug found post commit.  Amusingly, try 1 had been correct, and by reverting to incorporate last minute review feedback, I introduce the bug.  Oops.  :)
      
      The problem was that recursively deleting an instruction can delete instructions beyond the current iterator (via a dead phi), thus invalidating iteration.  Test case added in LoopUnroll/dce.ll to cover this case.
      
      LoopUnroll does a limited DCE pass after unrolling, but if you have a chain of dead instructions, it only deletes the last one. Improve the code to recursively delete all trivially dead instructions.
      
      Differential Revision: https://reviews.llvm.org/D102511
      b6320eeb
    • Arthur Eubanks's avatar
      ceb1ac98
    • Heejin Ahn's avatar
      [WebAssembly] Nullify DBG_VALUE_LISTs in DebugValueManager · 6e1c1dac
      Heejin Ahn authored
      WebAssemblyDebugValueManager class currently does not handle
      DBG_VALUE_LIST instructions correctly for two reasons, which are
      explained in https://bugs.llvm.org/show_bug.cgi?id=50361.
      
      This effectively nullifies DBG_VALUE_LISTs in
      WebAssemblyDebugValueManager so that the info will appear as "optimized
      out" in debuggers but still be at least correct in the meantime.
      
      Reviewed By: dschuff, jmorse
      
      Differential Revision: https://reviews.llvm.org/D102589
      6e1c1dac
    • River Riddle's avatar
      [mlir][NFC] Remove stale `createLowerAffinePass` declaration · e2e1a78a
      River Riddle authored
      This pass isn't defined in the Transforms/ library anymore.
      e2e1a78a