1. Feb 23, 2024
    • kadir çetinkaya's avatar
    • Daniel Krupp's avatar
      [analyzer] Fix core.VLASize checker false positive taint reports (#68140) · de04b7d4
      Daniel Krupp authored
      The checker reported a false positive on this code 
      
      void testTaintedSanitizedVLASize(void) {
        int x;
        scanf("%d", &x);
        if (x<1)
          return;
        int vla[x]; // no-warning
      }
      
      After the fix, the checker only emits tainted warning if the vla size is
      coming from a tainted source and it cannot prove that it is positive.
      de04b7d4
    • Kadir Cetinkaya's avatar
      4419b2c2
    • kadir çetinkaya's avatar
      Reland "[clang] Preserve found-decl when constructing VarTemplateIds" (#82612) · 5cb2ebc0
      kadir çetinkaya authored
      Update include-cleaner tests. Now that we have proper found-decls set up
      for VarTemplates, in case of instationtations we point to primary
      templates and not specializations. To be changed in a follow-up patch.
      5cb2ebc0
    • Matthias Springer's avatar
      [mlir][Transforms] Encapsulate dialect conversion options in `ConversionConfig` (#82250) · 5f1319bb
      Matthias Springer authored
      This commit adds a new `ConversionConfig` struct that allows users to
      customize the dialect conversion. This configuration is similar to
      `GreedyRewriteConfig` for the greedy pattern rewrite driver.
      
      A few existing options are moved to this objects, simplifying the
      dialect conversion API.
      5f1319bb
    • Timm Bäder's avatar
      [clang][Interp] Don't diagnose alread invalid function decls · 13acb3af
      Timm Bäder authored
      They have already been diagnosed before. Also improve that test case.
      13acb3af
    • Benjamin Maxwell's avatar
      [mlir][math] Propagate scalability in `convert-math-to-llvm` (#82635) · 78890904
      Benjamin Maxwell authored
      This also generally increases the coverage of scalable vector types in
      the math-to-llvm tests.
      78890904
    • Cullen Rhodes's avatar
      [mlir][ArmSME] Add test-lower-to-arm-sme pipeline (#81732) · b39f5660
      Cullen Rhodes authored
      The ArmSME compilation pipeline has evolved significantly and is now
      sufficiently complex enough that it warrants a proper lowering pipeline
      that encapsulates the various passes and orderings. Currently the
      pipeline is loosely defined in our integration tests, but these have
      diverged and are not using the same passes or ordering everywhere.
      
      This patch introduces a test-lower-to-arm-sme pipeline mirroring
      test-lower-to-llvm that provides some sanity when running e2e examples
      and can be used a reference for targeting ArmSME in MLIR.
      
      All the integration tests are updated to use this pipeline. The
      intention is to productize the pipeline once it becomes more mature.
      b39f5660
    • Matthias Springer's avatar
      [mlir][Transforms] Make `ConversionPatternRewriter` constructor private (#82244) · a622b21f
      Matthias Springer authored
      `ConversionPatternRewriter` objects should not be constructed outside of
      dialect conversions. Some IR modifications performed through a
      `ConversionPatternRewriter` are reflected in the IR in a delayed fashion
      (e.g., only when the dialect conversion is guaranteed to succeed). Using
      a `ConversionPatternRewriter` outside of the dialect conversion is
      incorrect API usage and can bring the IR in an inconsistent state.
      
      Migration guide: Use `IRRewriter` instead of
      `ConversionPatternRewriter`.
      a622b21f
    • Tobias Gysi's avatar
      [MLIR][LLVM] Fix debug intrinsic import (#82637) · 335d34d9
      Tobias Gysi authored
      This revision handles the case that the translation of a scope fails due
      to cyclic metadata. This mainly affects the import of debug intrinsics
      that indirectly take such a scope as metadata argument (e.g. via local
      variable or label metadata). This commit ensures we drop intrinsics with
      such a dependency on cyclic metadata.
      335d34d9
    • Paschalis Mpeis's avatar
      [AArch64][CostModel] Improve scalar frem cost (#80423) · bbdc62e7
      Paschalis Mpeis authored
      In AArch64 the cost of scalar frem is the cost of a call to 'fmod'.
      bbdc62e7
    • Pierre van Houtryve's avatar
      [ARM][GlobalISel] Remove legacy legalizer rules (#82619) · 2ae8bee8
      Pierre van Houtryve authored
      I've been looking at LegacyLegalizerInfo and what its place in GISel is.
      It seems like it's very close to being deleted so I'm checking if we can
      remove the last remaining uses of it.
      
      Looks like we can do a drop-in replacement with the new legalizer for
      ARM.
      2ae8bee8
    • Daniel Kiss's avatar
    • Matthias Springer's avatar
      [mlir][Transforms][NFC] Turn unresolved materializations into `IRRewrite`s (#81761) · 59ff4d13
      Matthias Springer authored
      This commit is a refactoring of the dialect conversion. The dialect
      conversion maintains a list of "IR rewrites" that can be committed (upon
      success) or rolled back (upon failure).
      
      This commit turns the creation of unresolved materializations
      (`unrealized_conversion_cast`) into `IRRewrite` objects. After this
      commit, all steps in `applyRewrites` and `discardRewrites` are calls to
      `IRRewrite::commit` and `IRRewrite::rollback`.
      59ff4d13
    • Matthias Springer's avatar
      [mlir][Transforms][NFC] Turn op creation into `IRRewrite` (#81759) · 9ca70d72
      Matthias Springer authored
      This commit is a refactoring of the dialect conversion. The dialect
      conversion maintains a list of "IR rewrites" that can be committed (upon
      success) or rolled back (upon failure).
      
      Until now, the dialect conversion kept track of "op creation" in
      separate internal data structures. This commit turns "op creation" into
      an `IRRewrite` that can be committed and rolled back just like any other
      rewrite. This commit simplifies the internal state of the dialect
      conversion.
      9ca70d72
    • Timm Bäder's avatar
      [clang][Interp][NFC] Improve Program dump()ing · ace83da3
      Timm Bäder authored
      Add colors as well as more details for global variables.
      ace83da3
    • Chuanqi Xu's avatar
    • Matthias Springer's avatar
      [mlir][Transforms][NFC] Turn op/block arg replacements into `IRRewrite`s (#81757) · d68d2951
      Matthias Springer authored
      This commit is a refactoring of the dialect conversion. The dialect
      conversion maintains a list of "IR rewrites" that can be committed (upon
      success) or rolled back (upon failure).
      
      Until now, op replacements and block argument replacements were kept
      track in separate data structures inside the dialect conversion. This
      commit turns them into `IRRewrite`s, so that they can be committed or
      rolled back just like any other rewrite. This simplifies the internal
      state of the dialect conversion.
      
      Overview of changes:
      * Add two new rewrite classes: `ReplaceBlockArgRewrite` and
      `ReplaceOperationRewrite`. Remove the `OpReplacement` helper class; it
      is now part of `ReplaceOperationRewrite`.
      * Simplify `RewriterState`: `numReplacements` and `numArgReplacements`
      are no longer needed. (Now being kept track of by `numRewrites`.)
      * Add `IRRewrite::cleanup`. Operations should not be erased in `commit`
      because they may still be referenced in other internal state of the
      dialect conversion (`mapping`). Detaching operations is fine.
      * `trackedOps` are now updated during the "commit" phase instead of
      after applying all rewrites.
      d68d2951
    • Balázs Kéri's avatar
      [clang][analyzer] Fix argument invalidations in StreamChecker. (#79470) · 5ca87759
      Balázs Kéri authored
      Specific arguments passed to stream handling functions are changed by
      the function, this means these should be invalidated ("escaped") by the
      analyzer. This change adds the argument invalidation (in specific cases)
      to the checker.
      5ca87759
    • Dani's avatar
      [llvm][AArch64] Do not inline a function with different signing scheme. (#80642) · 6fae3e78
      Dani authored
      If the signing scheme is different that maybe the functions assumes
      different behaviours and dangerous to inline them without analysing
      them. This should be a rare case.
      6fae3e78
    • Dani's avatar
      [llvm][AArch64] Autoupgrade function attributes from Module attributes. (#80640) · 531e8c26
      Dani authored
      `sign-return-address` and similar module attributes should be propagated
      to the function level before modules got merged because module flags may
      contradict and this information is not recoverable.
      Generated code will match with the normal linking flow.
      531e8c26
    • Jonas Devlieghere's avatar
      [lldb] Fix GetTerminalWidth after afd46902 · 354401f8
      Jonas Devlieghere authored
      afd46902 fixed the type of the term-width setting but the getter
      (Debugger::GetTerminalWidth) was still trying to get the terminal width
      as an unsigned. This fixes TestXMLRegisterFlags.py.
      354401f8
    • Freddy Ye's avatar
    • Luke Lau's avatar
      [RISCV] Add asserts for insert/extract_subvector invariants. NFC · d7a28f7a
      Luke Lau authored
      We can currently select insert_subvector and extract_subvector nodes in
      RISCVISelDAGToDAG (this is after custom legalizing in RISCVISelLowering)
      with fixed subvector types.
      
      However decomposeSubvectorInsertExtractToSubRegs is based off of
      scalable subvectors where the indices are scaled by vscale, so any index
      other than 0 will be wrong.
      
      For insert_subvector the vector being inserted into needs to be undef as
      well, because it assumes we can replace a whole subregister which isn't
      always the case for fixed subvectors (e.g. insert <2 x i32> into <4 x
      i32> at index 0 with vlen=128).
      
      We currently maintain these invariants in RISCVISelLowering, so this
      adds asserts in RISCVISelDAGToDAG so we don't break them.
      d7a28f7a
    • Yeting Kuo's avatar
      [RISCV][VP] Introduce vp saturating addition/subtraction and RISC-V support. (#82370) · 850dde06
      Yeting Kuo authored
      This patch also pick the MatchContext framework from DAGCombiner to an
      indiviual header file to make the framework be used from other files in
      llvm/lib/CodeGen/SelectionDAG/.
      850dde06
    • Jonas Devlieghere's avatar
      [lldb] Fix term-width setting (#82736) · afd46902
      Jonas Devlieghere authored
      I noticed that the term-width setting would always report its default
      value (80) despite the driver correctly setting the value with
      SBDebugger::SetTerminalWidth.
      
      ```
      (lldb) settings show term-width
      term-width (int) = 80
      ```
      
      The issue is that the setting was defined as a SInt64 instead of a
      UInt64 while the getter returned an unsigned value. There's no reason
      the terminal width should be a signed value. My best guess it that it
      was using SInt64 because UInt64 didn't support min and max values. I
      fixed that and correct the type and now lldb reports the correct
      terminal width:
      
      ```
      (lldb) settings show term-width
      term-width (unsigned) = 189
      ```
      
      rdar://123488999
      afd46902
    • shkoo's avatar
      [mlir] Fix FunctionOpInterface extraSharedClassDeclaration to be fully namespace qualified (#82682) · 0d72fe97
      shkoo authored
      `extraSharedClassDeclaration` of `FunctionOpInterface` can be inherited
      by other `OpInterfaces` into foreign namespaces, thus types must be
      fully qualified to prevent compiler errors, for example:
      
          def MyFunc : OpInterface<"MyFunc", [FunctionOpInterface]> {
              let cppNamespace = "::MyNamespace";
          }
      0d72fe97
    • Luke Lau's avatar
      [RISCV] Use RISCVSubtarget::getRealVLen() in more places. NFC · 2d50703d
      Luke Lau authored
      Catching a couple of more places where we can use the new query added in
      8603a7b2.
      2d50703d
    • Craig Topper's avatar
      [SelectionDAG][RISCV] Use FP type for legality query for LRINT/LLRINT in... · de41eae4
      Craig Topper authored
      [SelectionDAG][RISCV] Use FP type for legality query for LRINT/LLRINT in LegalizeVectorOps. (#82728)
      
      This matches how LRINT/LLRINT is queried for scalar types in
      LegalizeDAG.
      
      It's confusing if they do different things since a "Legal" vector
      LRINT/LLRINT would get through to LegalizeDAG which would then consider
      it illegal. This doesn't happen currently because RISC-V uses Custom.
      de41eae4
    • Derek Schuff's avatar
      [Symbolizer][WebAssembly] Use wasm-specific getSymbolSize (#82083) · ca09e082
      Derek Schuff authored
      getSymbolSize was recently added to WasmObjectFile and has correct sizes 
      for most symbol types. This makes llvm-symbolizer correctly symbolize
      addresses in the middle of the symbol.
      
      When reworking the test I also noticed that the DWARF info seems to be
      wrong for the first instruction in each function. I noted that in the test
      comments but didn't attempt to fix here.
      ca09e082
    • Heejin Ahn's avatar
      [WebAssembly] Disable multivalue emission temporarily (#82714) · 6e6bf9f8
      Heejin Ahn authored
      We plan to enable multivalue in the features section soon (#80923) for
      other reasons, such as the feature having been standardized for many
      years and other features being developed (e.g. EH) depending on it. This
      is separate from enabling Clang experimental multivalue ABI (`-Xclang
      -target-abi -Xclang experimental-mv`), but it turned out we generate
      some multivalue code in the backend as well if it is enabled in the
      features section.
      
      Given that our backend multivalue generation still has not been much
      used nor tested, and enabling the feature in the features section can be
      a separate decision from how much multialue (including none) we decide
      to generate for now, I'd like to temporarily disable the actual
      generation of multivalue in our backend. To do that, this adds an
      internal flag `-wasm-emit-multivalue` that defaults to false. All our
      existing multivalue tests can use this to test multivalue code. This
      flag can be removed later when we are confident the multivalue
      generation is well tested.
      6e6bf9f8
    • Chuanqi Xu's avatar
      [C++20] [Modules] Allow to compile a pcm with and without -fPIC · 2e5af56b
      Chuanqi Xu authored
      seperately
      
      We can compile a module unit in 2 phase compilaton:
      
      ```
      clang++ -std=c++20 a.cppm --precompile -o a.pcm
      clang++ -std=c++20 a.pcm -c -o a.o
      ```
      
      And it is a general requirement that we need to compile a translation
      unit with and without -fPIC for static and shared libraries.
      
      But for C++20 modules with 2 phase compilation, it may be waste of time
      to compile them 2 times completely. It may be fine to generate one BMI
      and compile it with and without -fPIC seperately.
      
      e.g.,
      
      ```
      clang++ -std=c++20 a.cppm --precompile -o a.pcm
      clang++ -std=c++20 a.pcm -c -o a.o
      clang++ -std=c++20 a.pcm -c -fPIC -o a-PIC.o
      ```
      
      Then we can save the time to parse a.cppm repeatedly.
      2e5af56b
    • huaatian's avatar
      [llvm][cmake] Performing expensive checks requires enabling assert. (#80821) · 5ccf5464
      huaatian authored
      
      
      LLVM will intercept errors using assert() when
      LLVM_ENABLE_EXPENSIVE_CHECKS is ON. So an explicit check is added.
      
      ---------
      
      Co-authored-by: default avatarHua Tian <akiratian@tencent.com>
      5ccf5464
    • Younan Zhang's avatar
      [Clang][Parser] Have the depth of the abbreviated generic lambdas inside a... · 19e518d2
      Younan Zhang authored
      [Clang][Parser] Have the depth of the abbreviated generic lambdas inside a requires clause differ from the surrounding generic lambda (#80656)
      
      A one-line fix, again : )
      
      This fixes https://github.com/llvm/llvm-project/issues/78524 and the
      similar example at
      https://github.com/llvm/llvm-project/issues/78524#issuecomment-1899886951.
      
      We previously increased the template depth by one after parsing the
      attaching requires-clause on a lambda expression. This led to a problem
      where the 'auto' parameters of nested abbreviated generic lambdas,
      inside of a requires-expression, had the same depth as the template
      parameters of the surrounding lambda. Consequently, during the
      concept-checking stage, we ended up substituting these parameters with
      the wrong template arguments because they were at different levels.
      19e518d2
    • Alex MacLean's avatar
      [NVPTX] fixup support for unaligned parameters and returns (#82562) · 590c968e
      Alex MacLean authored
      Add support for unaligned parameters and return values. These must be
      loaded and stored one byte at a time and then bit manipulation is used
      to assemble the correct final result.
      590c968e
    • Joseph Huber's avatar
      [libc] Search the compiler's path for GPU utility tools (#82712) · 7a5c01db
      Joseph Huber authored
      Summary:
      We need some extra tools for the GPU build. Normally we search for these
      from the build itself, but in the case of a `LLVM_PROJECTS_BUILD` or
      some other kind of external build, this directory will not be populated.
      However, the GPU build already requires that the compiler is an
      up-to-date clang, which should always have these present next to the
      binary. Simply add this as a fallback search path. Generally we want it
      to be the second, because it would pick up someone install and then
      become stale.
      7a5c01db
    • Joseph Huber's avatar
      [libc] Silence warnings when building GPU tests (#82701) · 9e84a22e
      Joseph Huber authored
      Summary:
      This patch silences two warnings that may occur during the building of
      GPU tests. These are not informative or helpful and just make the test
      output longer.
      9e84a22e
    • Philip Reames's avatar
      [RISCV] Vector sub (zext, zext) -> sext (sub (zext, zext)) (#82455) · ac518c7c
      Philip Reames authored
      This is legal as long as the inner zext retains at least one bit of
      increase so that the sub overflow case (0 - UINT_MAX) can be
      represented. Alive2 proof: https://alive2.llvm.org/ce/z/BKeV3W
      
      For RVV, restrict this to power of two sizes with the operation type
      being at least e8 to stick to legal extends. We could arguably handle i1
      source types with some care if we wanted to.
      
      This is likely profitable because it may allow us to perform the sub
      instruction in a narrow LMUL (equivalently, in fewer DLEN-sized pieces)
      before widening for the user. We could arguably avoid narrowing below
      DLEN, but the transform should at worst introduce one extra extend and
      one extra vsetvli toggle if the source could previously be handled via
      loads explicit w/EEW.
      ac518c7c
    • Diego Caballero's avatar
      [mlir][Vector] Add missing CHECK rules to vector-transfer-flatten.mlir (#82698) · cd1d4d8d
      Diego Caballero authored
      This test failed after landing #81964 due to a bad merge. I provided a quick fix and this PR is adding the rest of CHECK rules that were not merged properly.
      cd1d4d8d
    • vangthao95's avatar
      [AMDGPU][NFC] Refactor SIInsertWaitcnts zero waitcnt generation (#82575) · f37c6d55
      vangthao95 authored
      Move the allZero* waitcnt generation methods into WaitcntGenerator
      class.
      f37c6d55