1. Aug 23, 2020
  2. Aug 22, 2020
    • Michael Kruse's avatar
      [Polly] Ensure consistent Scop::InstStmtMap. NFC. · 8e06bf6b
      Michael Kruse authored
      InstStmtMap became inconsistent with ScopStmt::getInstructions() after
      the statement's instructions is modified, e.g. by being considered
      unused by the Simplify pass or being moved by ForwardOpTree.
      
      Change ScopStmt::setInstructions() to also update its parent's
      InstStmtMap. Also add assertions checking the consistency.
      8e06bf6b
    • Michael Kruse's avatar
      [Polly] Fix use-after-free. · 6983741e
      Michael Kruse authored
      VirtualUse of type UseKind::Inter expects the definition of a
      llvm::Value to be represented in another statement. In the bug report
      that statement has been removed due to its domain being empty.
      Scop::InstStmtMap for the llvm::Value's defintion still pointed to the
      removed statement, which resulted in the use-after-free.
      
      The defintion statement was removed by Simplify because it was
      considered to not be reachable by other uses; trivially because it is
      never executed due to its empty domain. However, no such thing happend
      to the using statement using the value altough its domain is also empty.
      
      Fix by always removing statements with empty domains in Simplify since
      these are not properly analyzable. A UseKind::Inter should always have a
      statement with its defintion due to LLVM's SSA form.
      Scop::removeStmtNotInDomainMap() also removes statements with empty
      domains but does so without considering the context as used by
      Simplify's analyzes.
      
      In another angle, InstStmtMap pointing to removed statements should not
      happen either and ForwardOpTree would have bailed out if the llvm::Value
      definition was not represented by a statement. This will be corrected in
      a followup-commit.
      
      This fixes llvm.org/PR47098
      6983741e
    • Matt Arsenault's avatar
      GlobalISel: Merge FewerElements for G_BUILD_VECTOR/G_CONCAT_VECTORS · 901e3317
      Matt Arsenault authored
      This switches from using G_EXTRACT in odd cases to widen with undef
      and unmerge.
      901e3317
    • Simon Pilgrim's avatar
    • Jeremy Morse's avatar
      Fix some builds after 20bb9fe5 · 2d9be9e3
      Jeremy Morse authored
      -Wsuggest-override indicates this VarLocBasedLDV method needs the
      override keyword.
      2d9be9e3
    • LLVM GN Syncbot's avatar
      [gn build] Port 20bb9fe5 · eeb46367
      LLVM GN Syncbot authored
      eeb46367
    • Jeremy Morse's avatar
      [LiveDebugValues] Install an implementation-picking LiveDebugValues pass · 20bb9fe5
      Jeremy Morse authored
      This patch renames the current LiveDebugValues class to "VarLocBasedLDV"
      and removes the pass-registration code from it. It creates a separate
      LiveDebugValues class that deals with pass registration and management,
      that calls through to VarLocBasedLDV::ExtendRanges when
      runOnMachineFunction is called. This is done through the "LDVImpl"
      abstract class, so that a future patch can install the new
      instruction-referencing LiveDebugValues implementation and have it
      picked at runtime.
      
      No functional change is intended, just shuffling responsibilities.
      
      Differential Revision: https://reviews.llvm.org/D83046
      20bb9fe5
    • Simon Pilgrim's avatar
      Enable constexpr on BITREVERSE builtin intrinsics (PR47249) · e7d9182a
      Simon Pilgrim authored
      This enables us to use the __builtin_bitreverse 8/16/32/64 intrinsics inside constexpr code.
      
      Differential Revision: https://reviews.llvm.org/D86339
      e7d9182a
    • Simon Pilgrim's avatar
      Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249) · 2ceac91e
      Simon Pilgrim authored
      This enables us to use the __builtin_rotateleft / __builtin_rotateright 8/16/32/64 intrinsics inside constexpr code.
      
      Differential Revision: https://reviews.llvm.org/D86342
      2ceac91e
    • Sanjay Patel's avatar
      [InstCombine] canonicalize 'not' ops before logical shifts · ec06b381
      Sanjay Patel authored
      This reverses the existing transform that would uniformly canonicalize any 'xor' after any shift. In the case of logical shifts, that turns a 'not' into an arbitrary 'xor' with constant, and that's probably not as good for analysis, SCEV, or codegen.
      
      The SCEV motivating case is discussed in:
      http://bugs.llvm.org/PR47136
      
      There's an analysis motivating case at:
      http://bugs.llvm.org/PR38781
      
      I did draft a patch that would do the same for 'ashr' but that's questionable because it's just swapping the position of a 'not' and uncovers at least 2 missing folds that we would probably need to deal with as preliminary steps.
      
      Alive proofs:
      https://rise4fun.com/Alive/BBV
      
        Name: shift right of 'not'
        Pre: C2 == (-1 u>> C1)
        %a = lshr i8 %x, C1
        %r = xor i8 %a, C2
        =>
        %n = xor i8 %x, -1
        %r = lshr i8 %n, C1
      
        Name: shift left of 'not'
        Pre: C2 == (-1 << C1)
        %a = shl i8 %x, C1
        %r = xor i8 %a, C2
        =>
        %n = xor i8 %x, -1
        %r = shl i8 %n, C1
      
        Name: ashr of 'not'
        %a = ashr i8 %x, C1
        %r = xor i8 %a, -1
        =>
        %n = xor i8 %x, -1
        %r = ashr i8 %n, C1
      
      Differential Revision: https://reviews.llvm.org/D86243
      ec06b381
    • Sanjay Patel's avatar
      [DAGCombiner] clean up merge of truncated stores; NFC · 2fc7c852
      Sanjay Patel authored
      This code handles the special-case of i8 stores,
      but it could be generalized to deal with other types.
      2fc7c852
    • Simon Pilgrim's avatar
      [docs] Replace "constexpr expressions" with "constant expressions". · 436a35a7
      Simon Pilgrim authored
      Based off comment from @rsmith on D86339
      436a35a7
    • Nathan James's avatar
      [clang-tidy] readability-simplify-boolean-expr detects negated literals · df5335a3
      Nathan James authored
      Adds support for detecting cases like `if (!true) ...`.
      Addresses [[ https://bugs.llvm.org/show_bug.cgi?id=47166 | readability-simplify-boolean-expr not detected for negated boolean literals. ]]
      
      Reviewed By: aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D86176
      df5335a3
    • LLVM GN Syncbot's avatar
      [gn build] Port fba06e3c · cfc76d2b
      LLVM GN Syncbot authored
      cfc76d2b
    • Jeremy Morse's avatar
      [LiveDebugValues][NFC] Move LiveDebugValues source for refactor · fba06e3c
      Jeremy Morse authored
      This is a pure file move of LiveDebugValues.cpp ahead of the pass being
      refactored, with an experimental new implementation to follow.
      
      The motivation for these changes can be found here:
      
        http://lists.llvm.org/pipermail/llvm-dev/2020-June/142368.html
      
      And the other related changes can be found in the phabricator stack for
      this revision:
      
      Differential Revision: https://reviews.llvm.org/D83304
      fba06e3c
    • Dimitry Andric's avatar
      Instantiate Error in Target::GetEntryPointAddress() only when necessary · 1ce07cd6
      Dimitry Andric authored
      When `Target::GetEntryPointAddress()` calls `exe_module->GetObjectFile()->GetEntryPointAddress()`, and the returned
      `entry_addr` is valid, it can immediately be returned.
      
      However, just before that, an `llvm::Error` value has been setup, but in this case it is not consumed before returning, like is done further below in the function.
      
      In https://bugs.freebsd.org/248745 we got a bug report for this, where a very simple test case aborts and dumps core:
      
      ```
      * thread #1, name = 'testcase', stop reason = breakpoint 1.1
          frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5
         1	int main(int argc, char *argv[])
         2	{
      -> 3	    return 0;
         4	}
      (lldb) p argc
      Program aborted due to an unhandled Error:
      Error value was Success. (Note: Success values must still be checked prior to being destroyed).
      
      Thread 1 received signal SIGABRT, Aborted.
      thr_kill () at thr_kill.S:3
      3	thr_kill.S: No such file or directory.
      (gdb) bt
      #0  thr_kill () at thr_kill.S:3
      #1  0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52
      #2  0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
      #3  0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112
      #4  0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267
      #5  0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67
      #6  0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114
      #7  0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97
      #8  0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604
      #9  0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347
      #10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383
      #11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301
      #12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331
      #13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190
      #14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372
      #15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414
      #16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646
      #17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003
      #18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762
      #19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760
      #20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548
      #21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903
      #22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946
      #23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169
      #24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675
      #25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890```
      
      Fix the incorrect error catch by only instantiating an `Error` object if it is necessary.
      
      Reviewed By: JDevlieghere
      
      Differential Revision: https://reviews.llvm.org/D86355
      1ce07cd6
    • Florian Hahn's avatar
      [DSE,MemorySSA] Use BatchAA for AA queries. · 5e7e2162
      Florian Hahn authored
      We can use BatchAA to avoid some repeated AA queries. We only remove
      stores, so I think we will get away with using a single BatchAA instance
      for the complete run.
      
      The changes in AliasAnalysis.h mirror the changes in D85583.
      
      The change improves compile-time by roughly 1%.
      http://llvm-compile-time-tracker.com/compare.php?from=67ad786353dfcc7633c65de11601d7823746378e&to=10529e5b43809808e8c198f88fffd8f756554e45&stat=instructions
      
      This is part of the patches to bring down compile-time to the level
      referenced in
      http://lists.llvm.org/pipermail/llvm-dev/2020-August/144417.html
      
      Reviewed By: asbirlea
      
      Differential Revision: https://reviews.llvm.org/D86275
      5e7e2162
    • George Mitenkov's avatar
      [MLIR][SPIRVToLLVM] Updated the documentation for the conversion · b65ba704
      George Mitenkov authored
      This patch updates the SPIR-V to LLVM conversion manual.
      Particularly, the following sections are added:
      - `spv.EntryPoint`/`spv.ExecutionMode` handling
      - Mapping for `spv.AccessChain`
      - Change in allowed storage classes for `spv.globalVariable`
      - Change of the runner section name
      
      Reviewed By: mravishankar
      
      Differential Revision: https://reviews.llvm.org/D86288
      b65ba704
    • Fangrui Song's avatar
    • Uday Bondhugula's avatar
      [MLIR][NFC] Update MLIR vim syntax file - std ops + types · b8cc449b
      Uday Bondhugula authored
      Update vim syntax file to include more std ops, and for int types.
      
      Differential Revision: https://reviews.llvm.org/D86370
      b8cc449b
    • Sourabh Singh Tomar's avatar
      Fix arm bot failure after f91d18ea · 12edd4b3
      Sourabh Singh Tomar authored
      llc doesn't seem to automatically pick default `--triple`.
      using `%llc_dwarf` should fix this.
      
      Builder:
      http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/20310
      
      Error log:
      bin/llc: error: : error: unable to get target for 'x86_64-unknown-linux-gnu', see --version and --triple.
      12edd4b3
    • Sourabh Singh Tomar's avatar
      [DebugInfo][flang]Added support for representing Fortran assumed length strings · f91d18ea
      Sourabh Singh Tomar authored
      This patch adds support for representing Fortran `character(n)`.
      
      Primarily patch is based out of D54114 with appropriate modifications.
      
      Test case IR is generated using our downstream classic-flang. We're in process
      of upstreaming flang PR's but classic-flang has dependencies on llvm, so
      this has to get in first.
      
      Patch includes functional test case for both IR and corresponding
      dwarf, furthermore it has been manually tested as well using GDB.
      
      Source snippet:
      ```
       program assumedLength
         call sub('Hello')
         call sub('Goodbye')
         contains
         subroutine sub(string)
                 implicit none
                 character(len=*), intent(in) :: string
                 print *, string
         end subroutine sub
       end program assumedLength
      ```
      
      GDB:
      ```
      (gdb) ptype string
      type = character (5)
      (gdb) p string
      $1 = 'Hello'
      ```
      
      Reviewed By: aprantl, schweitz
      
      Differential Revision: https://reviews.llvm.org/D86305
      f91d18ea