1. Jun 04, 2024
    • Peter Collingbourne's avatar
      Set llvm_enable_zstd unconditionally · 6fe335de
      Peter Collingbourne authored
      Created using spr 1.3.6-beta.1
      6fe335de
    • pcc's avatar
      gn build: Use -fvisibility-global-new-delete=force-hidden to build libcxx/libcxxabi/libunwind. · fde6a371
      pcc authored
      -fvisibility-global-new-delete-hidden is deprecated and clang was warning
      about it on every build command. These libraries are always built using
      a stage2 compiler, so we can use the new build flag unconditionally.
      
      Reviewers: aeubanks
      
      Reviewed By: aeubanks
      
      Pull Request: https://github.com/llvm/llvm-project/pull/88459
      fde6a371
    • paperchalice's avatar
      Reland "[NewPM][CodeGen] Port selection dag isel to new pass manager" (#94149) · 7652a594
      paperchalice authored
      - Fix build with `EXPENSIVE_CHECKS`
      - Remove unused `PassName::ID` to resolve warning
      - Mark `~SelectionDAGISel` virtual so AArch64 backend can work properly
      7652a594
    • Han-Chung Wang's avatar
      [mlir][vector] Add support for unrolling vector.bitcast ops. (#94064) · 0ea1271e
      Han-Chung Wang authored
      The revision unrolls vector.bitcast like:
      
      ```mlir
      %0 = vector.bitcast %arg0 : vector<2x4xi32> to vector<2x2xi64>
      ```
      
      to
      
      ```mlir
      %cst = arith.constant dense<0> : vector<2x2xi64>
      %0 = vector.extract %arg0[0] : vector<4xi32> from vector<2x4xi32>
      %1 = vector.bitcast %0 : vector<4xi32> to vector<2xi64>
      %2 = vector.insert %1, %cst [0] : vector<2xi64> into vector<2x2xi64>
      %3 = vector.extract %arg0[1] : vector<4xi32> from vector<2x4xi32>
      %4 = vector.bitcast %3 : vector<4xi32> to vector<2xi64>
      %5 = vector.insert %4, %2 [1] : vector<2xi64> into vector<2x2xi64>
      ```
      
      The scalable vector is not supported because of the limitation of
      `vector::createUnrollIterator`. The targetRank could mismatch the final
      rank during unrolling; there is no direct way to query what the final
      rank is from the object.
      0ea1271e
    • Namish Kukreja's avatar
      [ARM64EC] Warn on using disallowed registers in assembly src. (#93618) · 43847c1d
      Namish Kukreja authored
      ARM64EC designates a set of disallowed registers, because a mapping does
      not exist from them to x64. The MSVC assembler (armasm64) has a warning
      for this.
      
      A test is also included as part of the patch.
      
      See the list of disallowed registers below:
      
      https://learn.microsoft.com/en-us/cpp/build/arm64ec-windows-abi-conventions?view=msvc-170#register-mapping
      43847c1d
    • Michael Kruse's avatar
      [lld] Revise IDE folder structure (#89747) · 30e983c4
      Michael Kruse authored
      Update the folder titles for targets in the monorepository that have not
      seen taken care of for some time. These are the folders that targets are
      organized in Visual Studio and XCode
      (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
      when using the respective CMake's IDE generator.
      
       * Ensure that every target is in a folder
       * Use a folder hierarchy with each LLVM subproject as a top-level folder
       * Use consistent folder names between subprojects
       * When using target-creating functions from AddLLVM.cmake, automatically
      deduce the folder. This reduces the number of
      `set_property`/`set_target_property`, but are still necessary when
      `add_custom_target`, `add_executable`, `add_library`, etc. are used. A
      LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
      root CMakeLists.txt.
      30e983c4
    • smanna12's avatar
      [Clang] Prevent null pointer dereference in target attribute mangling (#94228) · ccaccc33
      smanna12 authored
      This patch adds assertions in the getMangledNameImpl() function to
      ensure that the expected target attributes (TargetAttr,
      TargetVersionAttr, and TargetClonesAttr) are not null before they are
      passed to appendAttributeMangling() to prevent potential null pointer
      dereferences and improve the robustness of the attribute mangling
      process.
      
      This assertion will trigger a runtime error with a clear message in
      debug build if any of the expected attributes are missing, facilitating
      early and easier diagnosis and debugging of such issues related to
      attribute mangling.
      ccaccc33
    • antangelo's avatar
      [AArch64] Support preserve_none calling convention (#91046) · ae1596a3
      antangelo authored
      Adds AArch64 support for the `preserve_none` calling convention.
      Registers X0-X7, X9-X15 and X19-X28 are caller save, and can be used to
      pass arguments. Delegates to AAPCS for all other registers.
      
      Closes #87423
      ae1596a3
    • Jon Roelofs's avatar
      update_test_checks: support more arm64_32-apple-watchos triples · 4ee950e7
      Jon Roelofs authored
      Having the version in `get_run_handlers` meant that a RUN line without the
      version in it would not match, and therefore UTC would generate a useless
      catch-all check of the form:
      
      ```
      ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
      ; CHECK: {{.*}}
      ```
      
      This patch also adds `arm64_32` as a base-level run handler, and assumes it
      will always apply to a darwin target (which is currently the case for all
      arm64_32-* triples I see in tree currently).
      4ee950e7
    • Jon Roelofs's avatar
      [llvm][SelectionDAG] Relax llvm.ptrmask's size check on arm64_32 (#94125) · 0b4af3a5
      Jon Roelofs authored
      Since pointers in memory, as well as the index type are both 32 bits,
      but in registers pointers are 64 bits, the mask generated by
      llvm.ptrmask needs to be zero-extended.
      
      Fixes: #94075
      Fixes: rdar://125263567
      0b4af3a5
    • Peter Klausler's avatar
      [flang] Propagate the BIND(C) attribute into procedures from their in… (#93994) · d03cd05f
      Peter Klausler authored
      …terfaces
      
      In "PROCEDURE(iface) :: proc", if "iface" has the BIND(C) attribute,
      then so should proc, as if the declaration had been "PROCEDURE(iface),
      BIND(C) :: proc". This had been working in name resolution only in cases
      where "iface" had been declared before "proc".
      
      Note that if "iface" is declared with an empty binding name
      ("BIND(C,NAME='')"), "proc" does not inherit that property. Use an
      explicit "BIND(C,NAME='')" on the "PROCEDURE" statement for that.
      
      This behavior is not clearly defined in the standard, but seems to match
      what some other Fortran compilers do.
      d03cd05f
    • Peter Klausler's avatar
      [flang][runtime][CUDA] Fix build error (#94281) · bd815a54
      Peter Klausler authored
      I broke the build, and now I'm fixing it.
      bd815a54
    • Krzysztof Drewniak's avatar
      [AMDGPU] Strengthen preload intrinsics to noundef and nonnull (#92801) · e31bfc04
      Krzysztof Drewniak authored
      The various preloaded registers (workitem IDs, workgroup IDs, and
      various implicit pointers) always have a finite, invariant, well-defined
      value throughout a well-defined program.
      
      In cases where the compiler infers or the user declares that some
      implicit input will not be used (ex. via amdgcn-no-workitem-id-y), the
      behavior of the entire program is undefined, since that misdeclaration
      can cause arbitrary other preloaded-register intrinsics to access the
      wrong register. This case is not expected to arise in practice, but
      could occur when the no implicit argument attributes were not cleared
      correctly in the presence of external functions, indrect calls, or other
      means of executing un-analyzable code. Failure to detect that case would
      be a bug in the attributor.
      
      This commit updates the documentation to reflect this long-standing
      reality.
      
      Then, on the basis that all implicit arguments are defined in all
      correct programs, the intrinsics that return those values are
      annototated with `noundef``. Some implicit pointer arguments gain a
      `nonnull`, but the kernel argument segment pointer or implicit argument
      pointers don't necessarily have this property.
      
      This will prevent spurious calls to `freeze` in front-end optimizations
      that destroy user-provided ranges on built-in IDs.
      
      (While I'm here, this commit adds a test for `noundef` on kernel
      arguments which is currently unimplemented)
      e31bfc04
    • Peter Klausler's avatar
      [flang] Disallow branches into SELECT TYPE/RANK cases (#93893) · a4bc44ad
      Peter Klausler authored
      Ensure that a branch cannot be made into a case of a SELECT TYPE or
      SELECT RANK construct.
      a4bc44ad
    • Peter Klausler's avatar
      [flang][runtime] Resilient opening of anonymous unit (#93876) · a8f2d185
      Peter Klausler authored
      When an I/O statement references a unit number that has not been
      explicitly opened or predefined, the I/O runtime support library opens a
      local "fort.N" file. If this fails, the program crashes, even when the
      I/O statement has IOSTAT= or IOMSG= or ERR= control list items. Connect
      the dots to enable resilience in these cases.
      a8f2d185
    • Peter Klausler's avatar
      [flang] Improve handling of NULL() arguments to intrinsics (#93866) · ea2c88f5
      Peter Klausler authored
      Some intrinsics (extends_type_of, same_type_as) can accept a NULL actual
      argument so long as it has a MOLD=. Some intrinsics that are marked in
      the intrinsics table as accepting a NULL actual argument already should
      only do so if it has a MOLD=. Distinguish table entries that accept a
      NULL() only with a MOLD= from the few others that allow a bare NULL()
      and update tests.
      
      Fixes https://github.com/llvm/llvm-project/issues/93845.
      ea2c88f5
    • Peter Klausler's avatar
      [flang] Add warnings about undefinable actuals for ASYNCHRONOUS/VOLAT… (#93851) · caa0a269
      Peter Klausler authored
      …ILE dummies
      
      There's language in the standard (F'2023 15.5.2.5 p21) disallowing an
      actual argument with a vector subscript from associating with a dummy
      argument with either the ASYNCHRONOUS or VOLATILE attributes. This is a
      bug in the standard, as (1) these attributes are actually relevant only
      over the scope of the called procedure, (2) they can be applied in
      nested scopes (internal subprograms and BLOCK) within the called
      procedure, and (3) can be implicit within the called procedure and its
      nested scopes in the case of ASYNCHRONOUS as a side effect of using a
      dummy argument in an asynchronous data transfer statement. So issue a
      warning. This new warning about undefinable actual arguments being
      associated with ASYNCHRONOUS and VOLATILE dummy arguments subsumes an
      existing warning about passing a constant actual to a VOLATILE dummy.
      
      Resolves https://github.com/llvm/llvm-project/issues/93600.
      caa0a269
    • royitaqi's avatar
      Re-merge `A few updates around "transcript"` (#92843) (#94067) · c2d061da
      royitaqi authored
      Problematic PR: https://github.com/llvm/llvm-project/pull/92843
      Reverted by: https://github.com/llvm/llvm-project/pull/94088
      
      
      
      The first PR added a test which fails in Linux builds (see the last few
      comments there).
      This PR contains all the changes in the first PR, plus the fix to the
      said test.
      
      ---------
      
      Co-authored-by: default avatarRoy Shi <royshi@meta.com>
      c2d061da
    • Peter Klausler's avatar
      [flang] Relax constraints on PURE/ELEMENTAL dummy arguments (#93748) · b61d7ec1
      Peter Klausler authored
      The standard requires that dummy arguments to PURE functions be
      INTENT(IN) or VALUE, but PURE subroutines are allowed to have modifiable
      dummy arguments. This makes it impossible to declare atomic operations
      as PURE functions, which consequently makes such atomic operations
      ineligible for use in parallel constructs and DO CONCURRENT.
      
      This patch downgrades this error to a warning by default, which can be
      seen with -pedantic & al. and remain an error with -Werror.
      b61d7ec1
    • William Junda Huang's avatar
      Add option to generate additional debug info for expression dereferencing... · 5cb00785
      William Junda Huang authored
      Add option to generate additional debug info for expression dereferencing pointer to pointers.  (#94100)
      
      This is another attempt to land #81545, which was reverted. 
      
      Fixed test case by adding a target triple so that clang generates the same IR for all platforms
      5cb00785
    • Peter Klausler's avatar
      [flang] Adjust %REF/%VAL semantic checking (#93718) · 930c2d91
      Peter Klausler authored
      In accordance with other compilers, don't require that a %REF() actual
      argument be a modifiable variable. And move the %REF/%VAL semantic
      checks to Semantics/check-call.cpp, where one would expect to find them.
      
      Fixes https://github.com/llvm/llvm-project/issues/93489.
      930c2d91
    • Peter Klausler's avatar
      [flang] Fix type inheritance for statement function dummy arguments (#93624) · 74f4034f
      Peter Klausler authored
      The code that used existing type declarations (if any) for the names
      being used as dummy arguments in a statement function definition would
      apply those types only if they came from EntityDetails symbols. This
      broke a case in which the type was being inherited from a Cray pointee.
      
      Fixes https://github.com/llvm/llvm-project/issues/93484.
      74f4034f
    • Jake Egan's avatar
      [libc++] Handle 0 size case for testing support operator new (#93834) · 037a0528
      Jake Egan authored
      The return of malloc is implementation defined when the requested size
      is 0. On platforms (such as AIX) that return a null pointer for 0 size,
      operator new will throw a bad_alloc exception. operator new should
      return a non null pointer for 0 size instead.
      037a0528
    • Fangrui Song's avatar
      [BOLT,test] Fix lsda.ldscript when MAXPAGESIZE>=0x10000 · 6ef632ad
      Fangrui Song authored
      The intention is to check a section name different from
      .gcc_except_table . Rather than using a linker script, use llvm-objcopy
      --rename-section instead.
      6ef632ad
    • Peter Klausler's avatar
      [flang] Handle USE-associated symbols in module procedure interface b… (#93616) · c93312a6
      Peter Klausler authored
      …lock specification expressions
      
      A subroutine or function interface block is of course allowed to
      USE-associate symbols into its scope and use them for specification
      expressions. This usage works, but crashes the module file output
      generator. Fix.
      
      Fixes https://github.com/llvm/llvm-project/issues/93413.
      c93312a6
    • Paul T Robinson's avatar
      [Driver] Fix the sysroot.c test properly (#94276) · e783d5db
      Paul T Robinson authored
      A DEFAULT_SYSROOT interfered with the test, apparently. See #94055.
      e783d5db
    • Peter Klausler's avatar
      [flang] Better error message for RANK(NULL()) (#93577) · c7593344
      Peter Klausler authored
      We currently complain that the argument may not be a procedure, which is
      confusing. Distinguish the NULL() case from other error cases (which are
      indeed procedures). And clean up the utility predicates used for these
      tests -- the current IsProcedure() is really just a test for a procedure
      designator.
      c7593344
    • Owen Pan's avatar
      [clang-format] Handle AttributeMacros in parseRecord() (#94189) · 13f67978
      Owen Pan authored
      Fixes #94184.
      13f67978
    • Michael Jones's avatar
      [libc][bazel] simplify type_traits with glob (#94079) · 572b4e70
      Michael Jones authored
      Previously the `type_traits` target manually listed all of the type
      traits files. This patch replaces that with a glob to make the build
      simpler.
      572b4e70
    • Mircea Trofin's avatar
      BitcodeWriter: ensure `Buffer` is heap allocated · c49bc1a3
      Mircea Trofin authored
      PR #92983 accidentally changed the buffer allocation in
      `llvm::WriteBitcodeToFile` to be allocated on the stack, which is
      problematic given it's a large-ish buffer (256K)
      c49bc1a3
    • Joseph Huber's avatar
      [libc] Add GPU utility dependencies if present · cf3b37c9
      Joseph Huber authored
      Summary:
      These tools need to be built before we can do the library creation
      stage. If they are generated in the same build then this is not
      guaranteed so we should add explicit dependencies.
      cf3b37c9
    • Florian Hahn's avatar
      [VPlan] Model FOR extract of exit value in VPlan. (#93395) · 07b33013
      Florian Hahn authored
      This patch introduces a new ExtractFromEnd VPInstruction opcode to
      extract the value of a FOR for users outside the loop (i.e. in the
      scalar loop's exits). This moves the first part of fixing first order
      recurrences to VPlan, and removes some additional code to patch up
      live-outs, which is now handled automatically.
      
      The majority of test changes is due to changes in the order of which the
      extracts are generated now. As we are now using VPTransformState to
      generate the extracts, we may be able to re-use existing extracts in the
      loop body in some cases. For scalable vectors, in some cases we now have
      to compute the runtime VF twice, as each extract is now independent, but
      those should be trivial to clean up for later passes (and in line with
      other places in the code that also liberally re-compute runtime VFs).
      
      PR: https://github.com/llvm/llvm-project/pull/93395
      07b33013
    • Peter Klausler's avatar
      [flang][preprocessing] Handle #include after & line continuation (#93382) · 0525c201
      Peter Klausler authored
      Some applications like to use a CPP-style #include directive to pull in
      a common list of arguments, dummy arguments, or COMMON block variables
      after a free-form & line continuation marker. This works naturally with
      compilers that run an actual cpp pass over the input before doing
      anything specific to Fortran, but it's a case that I missed with this
      integrated preprocessor.
      0525c201
    • Peter Klausler's avatar
      [flang] Adjust "doubled operator" expression extension (#93353) · 68f4e46c
      Peter Klausler authored
      Most Fortran compilers accept "doubled operators" as a language
      extension. This is the use of a unary '+' or '-' operator that is not
      the first unparenthesized operator in an expression, as in 'x*-y'.
      
      This compiler has implemented this extension, but in a way that's
      different from other compilers' behavior. I interpreted the unary
      '+'/'-' as a unary operator in the sense of C/C++, giving it a higher
      priority than any binary (dyadic) operator.
      
      All other compilers with this extension, however, give a unary '+'/'-' a
      lower precedence than exponentiation ('**'), a binary operator that
      C/C++ lacks. And this interpretation makes more sense for Fortran,
      anyway, where the standard conforming '-x**y' must mean '-(x**y)'
      already.
      
      This patch makes 'x*-y**z' parse as 'x*-(y**z)', not 'x*(-y)**z)', and
      adds a test to ensure that it does.
      68f4e46c
    • PiJoules's avatar
      [libc][CPP] Add all_of and find_if_not to algorithm.h (#94058) · e44cea59
      PiJoules authored
      This is needed for the allocator implementation for malloc.
      e44cea59
    • OverMighty's avatar
    • Joseph Huber's avatar
      [libc] Correctly find LLVM binaries when built in projects mode for GPU · 2ee7f49a
      Joseph Huber authored
      Summary:
      You can build the GPU libc support in projects mode. There were some
      issues with it not finding the correct binaries. This patch fixes that.
      2ee7f49a
    • Raul Tambre's avatar
      [clang][Sema] Don't issue -Wcast-function-type-mismatch for enums with a... · 2bc098b8
      Raul Tambre authored
      [clang][Sema] Don't issue -Wcast-function-type-mismatch for enums with a matching underlying type (#87793)
      
      Enums are passed as their underlying integral type so they're ABI compatible if the size matches.
      Useful with C APIs that pass user-controlled values to callbacks that can be made type safe by using enumerations (e.g. GStreamer).
      
      Discovered internally in some code after 999d4f84.
      2bc098b8
    • Fangrui Song's avatar
      a088c61d
    • Justin Fargnoli's avatar
      [GitHub] Add NVPTX backend labeler (#94080) · 3e228c8e
      Justin Fargnoli authored
      Add patterns to label NVPTX backend related changes automatically.
      3e228c8e