1. Jul 15, 2022
  2. Jul 14, 2022
    • Philip Reames's avatar
      [SCEVExpander] Allow udiv with isKnownNonZero(RHS) + add vscale case · 3bc09c7d
      Philip Reames authored
      Motivation here is to unblock LSRs ability to use ICmpZero uses - the major effect of which is to enable count down IVs. The test changes reflect this goal, but the potential impact is much broader since this isn't a change in LSR at all.
      
      SCEVExpander needs(*) to prove that expanding the expression is safe anywhere the SCEV expression is valid. In general, we can't expand any node which might fault (or exhibit UB) unless we can either a) prove it won't fault, or b) guard the faulting case. We'd been allowing non-zero constants here; this change extends it to non-zero values.
      
      vscale is never zero. This is already implemented in ValueTracking, and this change just adds the same logic in SCEV's range computation (which in turn drives isKnownNonZero). We should common up some logic here, but let's do that in separate changes.
      
      (*) As an aside, "needs" is such an interesting word here. First, we don't actually need to guard this at all; we could choose to emit a select for the RHS of ever udiv and remove this code entirely. Secondly, the property being checked here is way too strong. What the client actually needs is to expand the SCEV at some particular point in some particular loop. In the examples, the original urem dominates that loop and yet we completely ignore that information when analyzing legality. I don't plan to actively pursue either direction, just noting it for future reference.
      
      Differential Revision: https://reviews.llvm.org/D129710
      3bc09c7d
    • Dmitry Vyukov's avatar
      tsan: fix a bug in trace part switching · ab02680b
      Dmitry Vyukov authored
      Callers of TraceSwitchPart expect that TraceAcquire will always succeed
      after the call. It's possible that TryTraceFunc/TraceMutexLock in TraceSwitchPart
      that restore the current stack/mutexset filled the trace part exactly up
      to the TracePart::kAlignment gap and the next TraceAcquire won't succeed.
      Skip the alignment gap after writing initial stack/mutexset to avoid that.
      
      Reviewed By: melver
      
      Differential Revision: https://reviews.llvm.org/D129777
      ab02680b
    • Brendon Cahoon's avatar
      Revert "[UnifyLoopExits] Reduce number of guard blocks" · 58fec782
      Brendon Cahoon authored
      This reverts commit e13248ab.
      
      Need to revert because the transformation cannot occur for basic
      blocks that contain convergent instructions.
      58fec782
    • Dawid Jurczak's avatar
      d71128d9
    • Warren Ristow's avatar
      [Reassociate] Cleanup minor missed optimizations · 230c8c56
      Warren Ristow authored
      In analyzing issue #56483, it was noticed that running `opt` with
      `-reassociate` was missing some minor optimizations. For example,
      there were cases where the running `opt` on IR with floating-point
      instructions that have the `fast` flags applied, sometimes resulted in
      less efficient code than the input IR (things like dead instructions
      left behind, and missed reassociations). These were sometimes noted
      in the test-files with TODOs, to investigate further. This commit
      fixes some of these problems, removing some TODOs in the process.
      
      FTR, I refer to these as "minor" missed optimizations, because when
      running a full clang/llvm compilation, these inefficiencies are not
      happening, as other passes clean that residue up. Regardless, having
      cleaner IR produced by `opt`, makes assessing the quality of fixes done
      in `opt` easier.
      230c8c56
    • Andy Yankovsky's avatar
      [lldb] Add support for using integral const static data members in the expression evaluator · 48678721
      Andy Yankovsky authored
      This adds support for using const static integral data members as described by C++11 [class.static.data]p3
      to LLDB's expression evaluator.
      
      So far LLDB treated these data members are normal static variables. They already work as intended when they are declared in the class definition and then defined in a namespace scope. However, if they are declared and initialised in the class definition but never defined in a namespace scope, all LLDB expressions that use them will fail to link when LLDB can't find the respective symbol for the variable.
      
      The reason for this is that the data members which are only declared in the class are not emitted into any object file so LLDB can never resolve them. Expressions that use these variables are expected to directly use their constant value if possible. Clang can do this for us during codegen, but it requires that we add the constant value to the VarDecl we generate for these data members.
      
      This patch implements this by:
      * parsing the constant values from the debug info and adding it to variable declarations we encounter.
      * ensuring that LLDB doesn't implicitly try to take the address of expressions that might be an lvalue that points to such a special data member.
      
      The second change is caused by LLDB's way of storing lvalues in the expression parser. When LLDB parses an expression, it tries to keep the result around via two mechanisms:
      
      1. For lvalues, LLDB generates a static pointer variable and stores the address of the last expression in it: `T *$__lldb_expr_result_ptr = &LastExpression`
      2. For everything else, LLDB generates a static variable of the same type as the last expression and then direct initialises that variable: `T $__lldb_expr_result(LastExpression)`
      
      If we try to print a special const static data member via something like `expr Class::Member`, then LLDB will try to take the address of this expression as it's an lvalue. This means LLDB will try to take the address of the variable which causes that Clang can't replace the use with the constant value. There isn't any good way to detect this case (as there a lot of different expressions that could yield an lvalue that points to such a data member), so this patch also changes that we only use the first way of capturing the result if the last expression does not have a type that could potentially indicate it's coming from such a special data member.
      
      This change shouldn't break most workflows for users. The only observable side effect I could find is that the implicit persistent result variables for const int's now have their own memory address:
      
      Before this change:
      ```
      (lldb) p i
      (const int) $0 = 123
      (lldb) p &$0
      (const int *) $1 = 0x00007ffeefbff8e8
      (lldb) p &i
      (const int *) $2 = 0x00007ffeefbff8e8
      ```
      
      After this change we capture `i` by value so it has its own value.
      ```
      (lldb) p i
      (const int) $0 = 123
      (lldb) p &$0
      (const int *) $1 = 0x0000000100155320
      (lldb) p &i
      (const int *) $2 = 0x00007ffeefbff8e8
      ```
      
      Reviewed By: Michael137
      
      Differential Revision: https://reviews.llvm.org/D81471
      48678721
    • Nikolas Klauser's avatar
      [libc++] Test the size of basic_string · 2619ce8b
      Nikolas Klauser authored
      Reviewed By: ldionne, #libc
      
      Spies: hubert.reinterpretcast, arichardson, mstorsjo, libcxx-commits
      
      Differential Revision: https://reviews.llvm.org/D127672
      2619ce8b
    • Nikita Popov's avatar
      159feac1
    • Brendon Cahoon's avatar
      Revert "[StructurizeCFG] Improve basic block ordering" · c945d88d
      Brendon Cahoon authored
      This reverts commit f1b05a0a.
      
      Need to revert to due to issues identified with testing. The
      transformation is incorrect for blocks that contain convergent
      instructions.
      c945d88d
    • Thomas Raoux's avatar
      [mlir][vector] Support distribution of vector.reduce with accumulator · ffa7384f
      Thomas Raoux authored
      Right now the pattern was ignoring the optional accumulator.
      
      Differential Revision: https://reviews.llvm.org/D129719
      ffa7384f
    • Jeff Bailey's avatar
      Add support for three more string_view functions · 897b8014
      Jeff Bailey authored
      Add support for three more string_view functions
      
      1) starts_with(char)
      2) ends_with(char)
      3) find_first_of(char, size_t)
      
      Reimplemented trim in terms of the new starts_with and ends_with.
      
      Tested:
      New unit tests.
      
      Reviewed By: gchatelet
      
      Differential Revision: https://reviews.llvm.org/D129618
      897b8014
    • Ella Ma's avatar
      [analyzer] Fixing SVal::getType returns Null Type for NonLoc::ConcreteInt in boolean type · 32fe1a4b
      Ella Ma authored
      In method `TypeRetrievingVisitor::VisitConcreteInt`, `ASTContext::getIntTypeForBitwidth` is used to get the type for `ConcreteInt`s.
      However, the getter in ASTContext cannot handle the boolean type with the bit width of 1, which will make method `SVal::getType` return a Null `Type`.
      In this patch, a check for this case is added to fix this problem by returning the bool type directly when the bit width is 1.
      
      Differential Revision: https://reviews.llvm.org/D129737
      32fe1a4b
    • Matthias Springer's avatar
      [mlir][linalg][NFC] Cleanup: Drop linalg.inplaceable attribute · 74902cc9
      Matthias Springer authored
      bufferization.writable is used in most cases instead. All remaining test cases are updated. Some code that is no longer needed is deleted.
      
      Differential Revision: https://reviews.llvm.org/D129739
      74902cc9
    • Adam Czachorowski's avatar
      [clang] Do not crash on "requires" after a fatal error occurred. · cab3cfd0
      Adam Czachorowski authored
      The code would assume that SubstExpr() cannot fail on concept
      specialization. This is incorret - we give up on some things after fatal
      error occurred, since there's no value in doing futher work that the
      user will not see anyway. In this case, this lead to crash.
      
      The fatal error is simulated in tests with -ferror-limit=1, but this
      could happen in other cases too.
      
      Fixes https://github.com/llvm/llvm-project/issues/55401
      
      Differential Revision: https://reviews.llvm.org/D129499
      cab3cfd0
    • Michał Górny's avatar
      [lldb] [llgs] Convert m_debugged_processes into a map of structs · 355c7916
      Michał Górny authored
      Convert the m_debugged_processes map from NativeProcessProtocol pointers
      to structs, and combine the additional set(s) holding the additional
      process properties into a flag field inside this struct.  This is
      desirable since there are more properties to come and having a single
      structure with all information should be cleaner and more efficient than
      using multiple sets for that.
      
      Suggested by Pavel Labath in D128893.
      
      Differential Revision: https://reviews.llvm.org/D129652
      355c7916
    • Alina Sbirlea's avatar
      Turn on flag to not re-run simplification pipeline. · 846d10f1
      Alina Sbirlea authored
      This patch turns on the flag `-enable-no-rerun-simplification-pipeline`, which means the simplification pipeline will not be rerun on unchanged functions in the CGSCCPass Manager.
      
      Compile time improvement:
      https://llvm-compile-time-tracker.com/compare.php?from=17457be1c393ff691cca032b04ea1698fedf0301&to=882301ebb893c8ef9f09fe1ea871f7995426fa07&stat=instructions
      
      No meaningful run time regressions observed in the llvm test suite and
      in additional internal workloads at this time.
      
      The example test in `test/Other/no-rerun-function-simplification-pipeline.ll` is a good means to understand the effect of this change:
      ```
      define void @f1(void()* %p) alwaysinline {
        call void %p()
        ret void
      }
      
      define void @f2() #0 {
        call void @f1(void()* @f2)
        call void @f3()
        ret void
      }
      
      define void @f3() #0 {
        call void @f2()
        ret void
      }
      ```
      
      There are two SCCs formed by the ModuleToPostOrderCGSCCAdaptor: (f1) and (f2, f3).
      
      The pass manager runs on the first SCC, leading to running the simplification pipeline (function and loop passes) on f1. With the flag on, after this, the output will have `Running analysis: ShouldNotRunFunctionPassesAnalysis on f1`.
      
      Next, the pass manager runs on the second SCC: (f2, f3). Since f1() was inlined, f2() now calls itself, and also calls f3(), while f3() only calls f2().
      So the pass manager for the SCC first runs the Inliner on (f2, f3), then the simplification pipeline on f2.
      With the flag on, the output will have `Running analysis: ShouldNotRunFunctionPassesAnalysis on f2`; unless the inliner makes a change, this analysis remains preserved which means there's no reason to rerun the simplification pipeline. With the flag off, there is a second run of the simplification pipeline run on f2.
      
      Next, the same flow occurs for f3. The simplification pipeline is run on f3 a single time with the flag on, along with `ShouldNotRunFunctionPassesAnalysis on f3`, and twice with the flag off.
      The reruns occur only on f2 and f3 due to the additional ref edges.
      846d10f1
    • Nikolas Klauser's avatar
      [libc++] Allow setting _LIBCPP_OVERRIDABLE_FUNC_VIS · 0f050528
      Nikolas Klauser authored
      Chromium changes this flag to be able to use a custom new/delete from a
      dylib.
      0f050528
    • Nimish Mishra's avatar
      [flang][OpenMP] Added semantic checks for hint clause · 7dc18a62
      Nimish Mishra authored
      This patch improves semantic checks for hint clause.
      It checks "hint-expression is a constant expression
      that evaluates to a scalar value with kind
      `omp_sync_hint_kind` and a value that is a valid
      synchronization hint."
      
      Reviewed By: peixin
      
      Differential Revision: https://reviews.llvm.org/D127615
      7dc18a62
    • Nimish Mishra's avatar
      [flang][OpenMP] Lowering support for atomic update construct · a56b76d9
      Nimish Mishra authored
      This patch adds lowering support for atomic update construct. A region
      is associated with every `omp.atomic.update` operation wherein resides:
      (1) the evaluation of the expression on the RHS of the atomic assignment
      statement, and (2) a `omp.yield` operation that yields the extended value
      of expression evaluated in (1).
      
      Reviewed By: peixin
      
      Differential Revision: https://reviews.llvm.org/D125668
      a56b76d9
    • Nikita Popov's avatar
      [LoopPredication] Use isSafeToExpandAt() member function (NFC) · 9e6e631b
      Nikita Popov authored
      As a followup to D129630, this switches a usage of the freestanding
      function in LoopPredication to use the member variant instead. This
      was the last use of the freestanding function, so drop it entirely.
      9e6e631b
    • Nikita Popov's avatar
      [SCEVExpander] Make CanonicalMode handing in isSafeToExpand() more robust (PR50506) · dcf4b733
      Nikita Popov authored
      isSafeToExpand() for addrecs depends on whether the SCEVExpander
      will be used in CanonicalMode. At least one caller currently gets
      this wrong, resulting in PR50506.
      
      Fix this by a) making the CanonicalMode argument on the freestanding
      functions required and b) adding member functions on SCEVExpander
      that automatically take the SCEVExpander mode into account. We can
      use the latter variant nearly everywhere, and thus make sure that
      there is no chance of CanonicalMode mismatch.
      
      Fixes https://github.com/llvm/llvm-project/issues/50506.
      
      Differential Revision: https://reviews.llvm.org/D129630
      dcf4b733
    • Namhyung Kim's avatar
      [llvm-objdump] Create fake sections for a ELF core file · 69b312cd
      Namhyung Kim authored
      The linux perf tools use /proc/kcore for disassembly kernel functions.
      Actually it copies the relevant parts to a temp file and then pass it to
      objdump. But it doesn't have section headers so llvm-objdump cannot
      handle it.
      
      Let's create fake section headers for the program headers. It'd have a
      single section for each segment to cover the entire range. And for this
      purpose we can consider only executable code segments.
      
      With this change, I can see the following command shows proper outputs.
      
      perf annotate --stdio --objdump=/path/to/llvm-objdump
      
      Differential Revision: https://reviews.llvm.org/D128705
      69b312cd
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Retire LinalgPromotion pattern · 5a001136
      Nicolas Vasilache authored
      This revision removes the LinalgPromotion pattern and adds a `transform.structured.promotion` op.
      Since the LinalgPromotion transform allows the injection of arbitrary C++ via lambdas, the current
      transform op does not handle it.
      It is left for future work to decide what the right transform op control is for those cases.
      
      Note the underlying implementation remains unchanged and the mechanism is still controllable by
      lambdas from the API.
      
      During this refactoring it was also determined that the `dynamicBuffers` option does not actually
      connect to a change of behavior in the algorithm.
      This also exhibits that the related test is wrong (and dangerous).
      Both the option and the test are therefore removed.
      
      Lastly, a test that connects patterns using the filter-based mechanism is removed: all the independent
      pieces are already tested separately.
      
      Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785
      
      Differential Revision: https://reviews.llvm.org/D129649
      5a001136
    • Muhammad Usman Shahid's avatar
      Rewording "static_assert" diagnostics · b7e77ff2
      Muhammad Usman Shahid authored
      This patch rewords the static assert diagnostic output. Failing a
      _Static_assert in C should not report that static_assert failed. This
      changes the wording to be more like GCC and uses "static assertion"
      when possible instead of hard coding the name. This also changes some
      instances of 'static_assert' to instead be based on the token in the
      source code.
      
      Differential Revision: https://reviews.llvm.org/D129048
      b7e77ff2
    • zhongyunde's avatar
      [IndVars] Eliminate redundant type cast between unsigned integer and float · fc6092fd
      zhongyunde authored
      Extend for unsigned integer according the comment of D129191.
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D129358
      fc6092fd
    • Aaron Puchert's avatar
      Thread safety analysis: Don't erase TIL_Opcode type (NFC) · e0c66c69
      Aaron Puchert authored
      This is mainly for debugging, but it also eliminates some casts.
      e0c66c69
    • Aaron Puchert's avatar
      Thread safety analysis: Support builtin pointer-to-member operators · bfe63ab6
      Aaron Puchert authored
      We consider an access to x.*pm as access of the same kind into x, and
      an access to px->*pm as access of the same kind into *px. Previously we
      missed reads and writes in the .* case, and operations to the pointed-to
      data for ->* (we didn't miss accesses to the pointer itself, because
      that requires an LValueToRValue cast that we treat independently).
      
      We added support for overloaded operator->* in D124966.
      
      Reviewed By: aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D129514
      bfe63ab6
    • Sunho Kim's avatar
      18a6ab5b
    • LLVM GN Syncbot's avatar
      [gn build] Port 3e9cc543 · fdcd9599
      LLVM GN Syncbot authored
      fdcd9599
    • gbreynoo's avatar
      Revert "[llvm-ar][test] Add testing for bitcode file handling" · 8564b2ab
      gbreynoo authored
      This reverts commit 264b9a48.
      
      Due to build bot test failure.
      8564b2ab
    • Simon Moll's avatar
      [VP] Add test to show optimization opportunities · 173d4b84
      Simon Moll authored
      Add vp.add test cases that can are optimized with D92086 to show the
      potential of generalized pattern rewriting.
      
      Reviewed By: frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D129746
      173d4b84