1. Feb 09, 2024
    • Joseph Huber's avatar
      [NVVMReflect][Reland] Force dead branch elimination in NVVMReflect (#81189) · ffabcbcf
      Joseph Huber authored
      Summary:
      The `__nvvm_reflect` function is used to guard invalid code that varies
      between architectures. One problem with this feature is that if it is
      used without optimizations, it will leave invalid code in the module
      that will then make it to the backend. The `__nvvm_reflect` pass is
      already mandatory, so it should do some trivial branch removal to ensure
      that constants are handled correctly. This dead branch elimination only
      works in the trivial case of a compare on a branch and does not touch
      any conditionals that were not realted to the `__nvvm_reflect` call in
      order to preserve `O0` semantics as much as possible. This should allow
      the following to work on NVPTX targets
      
      ```c
      int foo() {
        if (__nvvm_reflect("__CUDA_ARCH") >= 700)
          asm("valid;\n");
      }
      ```
      
      Relanding after fixing a bug.
      ffabcbcf
    • Abdurrahman Akkas's avatar
      f6082691
    • Fangrui Song's avatar
      [ELF] Improve --ro-rosegment/--omagic/--nmagic tests · 6e1f4385
      Fangrui Song authored
      Notably, test that --ro-rosegment with a linker script may unnecessarily
      make a read-only PT_LOAD executable.
      6e1f4385
    • Alexey Z's avatar
      [mlir][tensor] Fix bug in insert_slice canonical. with tensor encoding (#81045) · 4759890f
      Alexey Z authored
      Previously, `InsertSliceOpSourceCastInserter` was incorrectly applied to
      a case when tensor types have an encoding attribute attached to them.
      The type `newSrcType` was missing that attribute from the old `srcType`,
      which made the expression `srcType == newSrcType` false, since
      `tensor<2x2xf32, "foo">` is not equal to `tensor<2x2xf32>`. That lead to
      an endless back and forth between `InsertSliceOpSourceCastInserter` that
      would introduce a cast and `InsertSliceOpCastFolder` that would remove
      it right after.
      4759890f
    • lntue's avatar
      [libc] Only declare float128 math functions in the generated math.h if... · fbf43b01
      lntue authored
      [libc] Only declare float128 math functions in the generated math.h if float128 type is supported. (#81010)
      
      fbf43b01
    • Lang Hames's avatar
      [JITLink][MachO][arm64] Fix error-check order. · 13892608
      Lang Hames authored
      The error check should be performed after the iterator increment, not before
      it. Thanks to @dcb314 for catching this!
      
      Fixes github.com/apple/swift/issues/81119
      13892608
    • Felipe de Azevedo Piovezan's avatar
      [DWARFVerifier] Fix verification of empty line tables (#81162) · 1d4fc381
      Felipe de Azevedo Piovezan authored
      A line table whose sole entry is an end sequence should not have the
      entry's file index verified, as that value corresponds to the initial
      value of the state machine, not to a real file index. In DWARF 5, this
      is particularly problematic as it uses 0-based indexing, and the state
      machine specifies a starting index of 1; in other words, you'd need to
      have _two_ files before such index became legal "by default".
      
      A previous attempt to fix this problem was done [1], but it was too
      specific in its condition, and did not capture all possible cases where
      this issue can happen.
      
      [1]: https://github.com/llvm/llvm-project/pull/77004
      1d4fc381
    • David Blaikie's avatar
    • Valentin Clement's avatar
      [flang] Fix missing generated header · 2572f45c
      Valentin Clement authored
      Fix buildbot failing because of missing  HLFIRTypes.h.inc
      2572f45c
    • Joseph Huber's avatar
      Revert "[NVVMReflect] Force dead branch elimination in NVVMReflect (#81189)" · 0800a360
      Joseph Huber authored
      This reverts commit 9211e67d.
      
      Summary:
      This seemed to crash one one of the CUDA math tests. Revert until it can
      be fixed.
      0800a360
    • Sam Clegg's avatar
    • Joseph Huber's avatar
      [LinkerWrapper] Allow 'all' as a generic bundled architecture (#81193) · 42230e21
      Joseph Huber authored
      Summary:
      Currently, the linker wrapper sorts input files into different link
      jobs according to their architectures. Here we assume each architecture
      is a unique and incompatible link job unless they are specifically
      marked compatible. This patch simply adds an `all` target to represent
      an architecture that should be linked against every single other
      architecture.
      
      This will be useful for modelling generic IR such as the ROCm device
      libraries or the NVPTX libdevice.
      42230e21
    • Joseph Huber's avatar
      [NVVMReflect] Force dead branch elimination in NVVMReflect (#81189) · 9211e67d
      Joseph Huber authored
      Summary:
      The `__nvvm_reflect` function is used to guard invalid code that varies
      between architectures. One problem with this feature is that if it is
      used without optimizations, it will leave invalid code in the module
      that will then make it to the backend. The `__nvvm_reflect` pass is
      already mandatory, so it should do some trivial branch removal to ensure
      that constants are handled correctly. This dead branch elimination only
      works in the trivial case of a compare on a branch and does not touch
      any conditionals that were not realted to the `__nvvm_reflect` call in
      order to preserve `O0` semantics as much as possible. This should allow
      the following to work on NVPTX targets
      
      ```c
      int foo() {
        if (__nvvm_reflect("__CUDA_ARCH") >= 700)
          asm("valid;\n");
      }
      ```
      9211e67d
    • Alex MacLean's avatar
      [NVPTX] Add support for calling aliases (#81170) · 9affa177
      Alex MacLean authored
      The current implementation of aliases tries to remove all the aliases in
      the module to prevent the generic version of `AsmPrinter` from emitting
      them incorrectly. Unfortunately, if the aliases are used this will fail.
      Instead let's override the function to print aliases directly.
      
      In addition, the declarations of the alias functions must occur before
      the uses. To fix this we emit alias declarations as part of
      `emitDeclarations` and only emit the `.alias` directives at the end
      (where we can assume the aliasee has also already been declared).
      9affa177
    • Valentin Clement (バレンタイン クレメン)'s avatar
      [flang] Fix attribute printing for fir.global op (#81197) · 8c106a15
      The custom printer for `fir.global` was eluding all the attributes
      present on the op when printing the attribute dictionary. So any
      attribute that is not part of the pretty printing was therefore
      discarded.
      This patch fix the printer and also make use of the getters for the
      attribute names when they are hardcoded.
      8c106a15
    • Jerry Wu's avatar
      [mlir] Add transformation to wrap scf::while in zero-trip-check (#81050) · f7201505
      Jerry Wu authored
      Add `scf::wrapWhileLoopInZeroTripCheck` to wrap scf while loop in
      zero-trip-check.
      f7201505
    • Luke Lau's avatar
      [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) · 06c89bd5
      Luke Lau authored
      
      
      Otherwise we will crash since target intrinsics don't have their types
      legalized. Let the mgather get legalized first, then do the combine on
      the legal type.
      Fixes #81088
      
      Co-authored-by: default avatarCraig Topper <craig.topper@sifive.com>
      06c89bd5
    • Reid Kleckner's avatar
      Consider aggregate bases when checking if an InitListExpr is constant (#80519) · 3c42e10a
      Reid Kleckner authored
      
      
      This code was correct as written prior to C++17, which allowed bases to
      appear in the initializer list.
      
      This was observable by creating non-constant aggregate initialization at
      file scope in a compound literal, but since that behavior will change
      soon if we implement support for dynamic initialization, I also added a
      unit test for `isConstantInitializer`.
      
      This fixes at least one part of issue #80510 .
      
      ---------
      
      Co-authored-by: default avatarAaron Ballman <aaron@aaronballman.com>
      3c42e10a
    • Davide Italiano's avatar
      7b5a9bb8
    • Maksim Panchenko's avatar
      [BOLT] Always run CheckLargeFunctions in non-relocation mode (#80922) · 7fe97f04
      Maksim Panchenko authored
      We run CheckLargeFunctions pass in non-relocation mode to prevent the
      emission of functions that later could not be written to the output due
      to their large size. The main reason behind the pass is to prevent the
      emission of metadata for such functions since this metadata becomes
      incorrect if the function is left unmodified.
      
      Currently, the pass is enabled in non-relocation mode only when debug
      info output is also enabled. As we emit increasingly more kinds of
      metadata, e.g. for the Linux kernel, it becomes more challenging to
      track metadata that needs to be fixed. Hence, I'm enabling the pass to
      always run in non-relocation mode.
      7fe97f04
    • NAKAMURA Takumi's avatar
      [Bazel] Update for SPIRV · a6f42adf
      NAKAMURA Takumi authored
      a6f42adf
    • Arthur Eubanks's avatar
      [gn build] Add IntrinsicsSPIRV.h generator · 0572dabb
      Arthur Eubanks authored
      This was missing in the gn build for some reason, causing build errors like http://45.33.8.238/linux/130337/step_4.txt after 3b57b647.
      0572dabb
    • Alex MacLean's avatar
      [NVPTX][NFC] cleanup dead vars, use MAKE_CASE (#81161) · 4b54b474
      Alex MacLean authored
      Cleanup some dead variables. In addition, switch to a `MAKE_CASE` macro,
      similar to other targets, to reduce boilerplate.
      4b54b474
    • Craig Topper's avatar
      [RISCV] Use MCPhysReg for AllPopRegs. NFC · f78c9b88
      Craig Topper authored
      MCPhysReg is 2 bytes, while Register is 4 bytes.
      f78c9b88
    • Fangrui Song's avatar
      [DWARFLinkerParallel] Fix member initialization order (#81179) · 7c9c4983
      Fangrui Song authored
      DWARFLinkerImpl::DWARFLinkerImpl initializes
      DebugStrStrings/DebugLineStrStrings/CommonSections using GlobalData
      but GlobalData is initialized after the three members.
      Move GlobalData before.
      
      Fix #81110
      7c9c4983
    • Timm Bäder's avatar
      cdde0d96
    • Derek Schuff's avatar
      [Object][Wasm] Generate symbol info from name section names (#81063) · 58185727
      Derek Schuff authored
      Currently symbol info is generated from a linking section or from export
      names. This PR generates symbols in a WasmObjectFile from the name
      section as well, which allows tools like objdump and nm to show useful
      information for more linked binaries. There are some limitations:
      most notably that we don't assume any particular ABI, so we don't get
      detailed information about data symbols if the segments are merged
      (which is the default).
      
      Covers most of the desired functionality from #76107
      58185727
    • NAKAMURA Takumi's avatar
      [Coverage] MCDCRecordProcessor: Find `ExecVectors` directly (#80816) · 3f9d8d89
      NAKAMURA Takumi authored
      Deprecate `TestVectors`, since no one uses it.
      
      This affects the output order of ExecVectors.
      The current impl emits sorted by binary value of ExecVector. This impl
      emits along the traversal of `buildTestVector()`.
      3f9d8d89
    • Jonas Devlieghere's avatar
      [lldb] Expand background symbol download (#80890) · 5f4b40c9
      Jonas Devlieghere authored
      LLDB has a setting (symbols.enable-background-lookup) that calls
      dsymForUUID on a background thread for images as they appear in the
      current backtrace. Originally, the laziness of only looking up symbols
      for images in the backtrace only existed to bring the number of
      dsymForUUID calls down to a manageable number.
      
      Users have requesting the same functionality but blocking. This gives
      them the same user experience as enabling dsymForUUID globally, but
      without the massive upfront cost of having to download all the images,
      the majority of which they'll likely not need.
      
      This patch renames the setting to have a more generic name
      (symbols.auto-download) and changes its values from a boolean to an
      enum. Users can now specify "off", "background" and "foreground". The
      default remains "off" although I'll probably change that in the near
      future.
      5f4b40c9
    • Philip Reames's avatar
      [RISCV] Consider all subvector extracts within a single VREG cheap (#81032) · b8545e1e
      Philip Reames authored
      This adjusts the isSubVectorExtractCheap callback to consider any
      extract which fits entirely within the first VLEN bits of the src vector
      (and uses a 5 bit immediate for the slide) as cheap. These can be done
      via a single m1 vslide1down.vi instruction.
      
      This allows our generic DAG combine logic to kick in and recognize a few
      more cases where shuffle source is longer than the dest, but that using
      a wider shuffle is still profitable. (Or as shown in the test diff, we
      can split the wider source and do two narrower shuffles.)
      b8545e1e
    • Jonas Devlieghere's avatar
      Revert "[lldb] Expand background symbol lookup" (#81182) · 705fcd4e
      Jonas Devlieghere authored
      Reverts llvm/llvm-project#80890
      705fcd4e
    • John Demme's avatar
      [MLIR][Python] Add method for getting the live operation objects (#78663) · d1fdb416
      John Demme authored
      Currently, a method exists to get the count of the operation objects
      which are still alive. This helps for sanity checking, but isn't
      terribly useful for debugging. This new method returns the actual
      operation objects which are still alive.
      
      This allows Python code like the following:
      
      ```
          gc.collect()
          live_ops = ir.Context.current._get_live_operation_objects()
          for op in live_ops:
            print(f"Warning: {op} is still live. Referrers:")
            for referrer in gc.get_referrers(op)[0]:
              print(f"  {referrer}")
      ```
      d1fdb416
    • Yinying Li's avatar
      [mlir][sparse] Implement parsing n out of m (#79935) · e5924d64
      Yinying Li authored
      1. Add parsing methods for block[n, m].
      2. Encode n and m with the newly extended 64-bit LevelType enum.
      3. Update 2:4 methods names/comments to n:m.
      e5924d64
    • Natalie Chouinard's avatar
      [HLSL][SPIR-V] Add create.handle intrinsic (#81038) · 3b57b647
      Natalie Chouinard authored
      Add a SPIR-V target-specific intrinsic for creating handles, which is
      used for lowering HLSL resources types like RWBuffer.
      
      `llvm/lib/TargetParser/Triple.cpp`: SPIR-V intrinsics use "spv" as the
      target prefix, not "spirv". As far as I can tell, this is the first one
      that is used via the `CGBuiltin` codepath, which relies on
      `getArchTypePrefix`, so I've corrected it here.
      
      `clang/lib/Basic/Targets/SPIR.h`: When records are laid out in the
      lowering from AST to IR, they were incorrectly offset because these
      Pointer attributes were defaulting to 32.
      
      Related to #81036
      3b57b647
    • Jacob Lambert's avatar
    • Philip Reames's avatar
      [RISCV] Consider truncate semantics in performBUILD_VECTORCombine (#81168) · d0f72f88
      Philip Reames authored
      Fixes https://github.com/llvm/llvm-project/issues/80910.
      
      Per the documentation in ISDOpcodes.h, for BUILD_VECTOR "The types of
      the operands must match the vector element type, except that integer
      types are allowed to be larger than the element type, in which case the
      operands are implicitly truncated."
      
      This transform was assuming that the scalar operand type matched the
      result type. This resulted in essentially performing a truncate before a
      binop, instead of after. As demonstrated by the test case changes, this
      is often not legal.
      d0f72f88
    • alex-t's avatar
      [AMDGPU] Compiler should synthesize private buffer resource descriptor from... · 88e52511
      alex-t authored
      [AMDGPU] Compiler should synthesize private buffer resource descriptor from flat_scratch_init (#79586)
      
      This change implements synthesizing the private buffer resource
      descriptor in the kernel prolog instead of using the preloaded kernel
      argument.
      88e52511
    • Jonas Devlieghere's avatar
      [lldb] Expand background symbol download (#80890) · 74fc16aa
      Jonas Devlieghere authored
      LLDB has a setting (symbols.enable-background-lookup) that calls
      dsymForUUID on a background thread for images as they appear in the
      current backtrace. Originally, the laziness of only looking up symbols
      for images in the backtrace only existed to bring the number of
      dsymForUUID calls down to a manageable number.
      
      Users have requesting the same functionality but blocking. This gives
      them the same user experience as enabling dsymForUUID globally, but
      without the massive upfront cost of having to download all the images,
      the majority of which they'll likely not need.
      
      This patch renames the setting to have a more generic name
      (symbols.auto-download) and changes its values from a boolean to an
      enum. Users can now specify "off", "background" and "foreground". The
      default remains "off" although I'll probably change that in the near
      future.
      74fc16aa
    • Jeremy Kun's avatar
    • Krystian Stasiowski's avatar
      [clang-tidy] Fix failing test after #80864 (#81171) · a56fa161
      Krystian Stasiowski authored
      The following test case in
      `clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp` is
      failing:
      ```
      #ifdef PR64602 // Should not crash
      template <class T = void>
      struct S
      {
          auto foo(auto);
      };
      
      template <>
      auto S<>::foo(auto)
      {
          return 1;
      }
      // CHECK8: error: template parameter list matching the non-templated nested type 'S<>' should be empty ('template<>') [clang-diagnostic-error]
      #endif
      ```
      
      #80864 fixes a bug where we would (incorrectly) append invented template
      parameters to empty template parameter lists, which causes this test to
      fail.
      a56fa161