1. Jan 17, 2024
    • Craig Hesling's avatar
      [GitHub] Add python 3.7 to libclang python test (#77219) · 588802a6
      Craig Hesling authored
      This enables the libclang python binding test to check
      the oldest version of Python supported in addition
      to the normal python version.
      
      It is important to check this for issue #76664, since
      many new mainstream python type annotation features
      and best practices are not compatible with older
      versions of python.
      
      Additionally, frustration around ever increasing
      platform dependencies and versions has been raised.
      This will help ensure that python maintains reasonable
      backwards compatibility.
      
      Adding this additional build step will increase the
      run time, but this should always be minimal, since
      the additional libclang compilation should see 100%
      cache hit rate.
      
      Issue #76664.
      Fixes #76601.
      588802a6
    • Craig Hesling's avatar
      [libclang/python] Bump minimum compatibility to Python 3.6 (#77228) · 75f23218
      Craig Hesling authored
      Remove Python 2 support and clean up code that conditions based on
      version.
      
      Issue #76664.
      75f23218
    • Nikita Popov's avatar
      [AsmParser] Implicitly declare intrinsics (#78251) · 34b10678
      Nikita Popov authored
      We currently require that all referenced globals have an explicit
      declaration or definition in the IR. For intrinsics, this requirement is
      redundant, because they cannot be called indirectly (including "direct"
      calls with mismatched function type). The function type used in the call
      directly determines the function type of the intrinsic declaration.
      
      Relax this requirement, and implicitly declare any intrinsics that do
      not have an explicit declaration. This will remove a common annoyance
      when writing tests and alive2 proofs.
      
      (I also plan to introduce a mode where declarations for all missing
      symbols will be automatically added, to make working with incomplete IR
      easier -- but that will be behind a default-disabled flag.)
      34b10678
    • Nikita Popov's avatar
      [GISel] Add debug counter to force sdag fallback (#78257) · 435bcea8
      Nikita Popov authored
      Add a debug counter that allows forcing an sdag fallback after a certain
      number of functions.
      
      The intended use-case is to bisect which function gets miscompiled by
      global isel using `-debug-counter=globalisel-count=N` (in cases where
      sdag doesn't also miscompile it, of course).
      
      The "falling back" debug line is printed unconditionally, because using
      `-debug-only` is usually too spammy for the intended purpose.
      435bcea8
    • Nikita Popov's avatar
      [DAGCombine] Add debug counter (#78259) · cde780c1
      Nikita Popov authored
      Add a debug counter for DAGCombine. This can help with bisecting which
      DAG combine introduced a miscompile.
      cde780c1
    • Nikita Popov's avatar
      [BasicAA] Remove incorrect rule about constant pointers (#76815) · 5f57ad85
      Nikita Popov authored
      BasicAA currently says that any Constant cannot alias an identified
      local object. This is not correct if the local object escaped, as it's
      possible to create a pointer to the escaped object using an inttoptr
      constant expression base.
      
      To compensate for this, make sure that inttoptr constant expressions are
      treated as escape sources, just like inttoptr instructions. This ensures
      that the optimization can still be applied if the local object is
      non-escaping. This is sufficient to still optimize the original
      motivating case from c53e2ecf.
      
      Fixes https://github.com/llvm/llvm-project/issues/76789.
      5f57ad85
    • Dávid Ferenc Szabó's avatar
      [GlobalISel] Improve combines for extend operation by taking hint ins… (#74125) · 55172b70
      Dávid Ferenc Szabó authored
      …tructions into account
      
      Hint instructions like G_ASSERT_ZEXT cann be viewed as a copy. Including
      this fact into the combiner allows the match more patterns involving
      such instructions.
      55172b70
    • Alex Bradbury's avatar
      [RISCV][test] Test showing missed optimisation for spills/fills of GPR<->FPR moves · da0755f7
      Alex Bradbury authored
      The fmv can be removed through appropriate logic in
      RISCVInstrInfo::foldMemoryOperandImpl.
      da0755f7
    • Jason Molenda's avatar
      Return high address masks correctly in Process (#78379) · 54d81936
      Jason Molenda authored
      In https://reviews.llvm.org/D151292 I added the ability to track address
      masks separately for high and low memory addresses, a capability of
      AArch64. I did my testing with manual address mask settings (via
      target.process.highmem-virtual-addressable-bits) but didn't have a real
      corefile that included this metadata and required it.
      
      My intention is that when the high address mask isn't specified, by the
      user (via the setting) or the Process plugin, we fall back to using the
      low address mask. The low and high address mask is the same for almost
      all environments.
      
      But the patch I wrote never uses the Process plugin high address mask if
      it was set, e.g. from corefile metadata. This patch corrects that.
      
      I also have an old patch in Phabractor that was approved to add
      FixAddress methods to SBProcess; I need to pick that patch up and finish
      it (I wanted to add an enum to specify which mask is being requested
      iirc), so I can do address masks tests in API tests.
      
      rdar://120926000
      54d81936
    • Luke Lau's avatar
      [RISCV] Add run line for code size in rvv load/store cost model test. NFC · cbb46d94
      Luke Lau authored
      This illustrates #78352. There are other tests for gathers/scatters and masked
      load/stores which likely have the same issue, but I've left them out for now
      since they don't seem to be affected by fixing RISCVTTIImpl::getMemoryOpCost.
      cbb46d94
    • Fangrui Song's avatar
      [X86] Add "Ws" constraint and "p" modifier for symbolic address/label reference (#77886) · d4cb5d9f
      Fangrui Song authored
      Printing the raw symbol is useful in inline asm (e.g. getting the C++
      mangled name, referencing a symbol in a custom way while ensuring it is
      not optimized out even if internal). Similar constraints are available
      in other targets (e.g. "S" for aarch64/riscv, "Cs" for m68k).
      
      ```
      namespace ns { extern int var, a[4]; }
      void foo() {
        asm(".pushsection .xxx,\"aw\"; .dc.a %p0; .popsection" :: "Ws"(&ns::var));
        asm(".reloc ., BFD_RELOC_NONE, %p0" :: "Ws"(&ns::a[3]));
      }
      ```
      
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105576
      d4cb5d9f
    • Tacet's avatar
      [ASan][libc++][NFC] refactor vector annotations arguments (#78322) · 2b3cdd69
      Tacet authored
      This commit simplifies ASan helper functions in `std::vector` by
      removing arguments which can be calculated later.
      
      Short term it improves readability of helper functions in `std::vector`.
      
      Long term it aims to help with a bigger refactor of container
      annotations.
      2b3cdd69
    • Mark de Wever's avatar
      [libc++][modules] Fixes clang-tidy exports. (#76288) · fb79f80b
      Mark de Wever authored
      As suggested in #71438 we should use
        export import std;
      in the std.compat module.
      
      Using this exports some named declarations from functions and records,
      adding them to the global namespace. Clang correctly does not export
      these and it's an issue in the declaration filtering. Declarations in
      function or record context are not considered a global named
      declaration.
      fb79f80b
    • Mark de Wever's avatar
      [libc++] Clang-tidy enable modernize-use-nullptr. (#76659) · 020ea3e8
      Mark de Wever authored
      Clang-tidy 18 no longer has false positives with the spaceship operator.
      Note that I'm quite sure there are more occurrences in our headers that
      are not caught.
      020ea3e8
    • Mark de Wever's avatar
      [libc++][modules] Increase clang-tidy version used. (#76268) · e6ac33b9
      Mark de Wever authored
      As suggested in #71438 we should use
        export import std;
      in the std.compat module.
      
      Testing this locally failed when building with the clang-tidy-17 plugin.
      The std module was considered corrupt in the test
        libcxx/test/libcxx/module_std_compat.gen.py
      however the test
        libcxx/test/libcxx/module_std.gen.py
      passed. Both test generated identical std.pcm files. Using the
      clang-tidy-18 plugin solves the issue.
      e6ac33b9
    • Mark de Wever's avatar
      [libc++][modules] Adds module testing. (#76246) · 57ca7484
      Mark de Wever authored
      This adds a new module test infrastructure. This requires tagging tests
      using modules. The test runner uses this information to determine the
      compiler flags needed to build and use the module.
      
      Currently modules are build per test, which allows testing them for
      tests with ADDITIONAL_COMPILE_FLAGS. At the moment only 4 tests use
      modules. Therefore the performance penalty is not measurable. If in the
      future more tests use modules it would be good to measure the overhead
      and determine whether it's acceptable.
      57ca7484
    • Mark de Wever's avatar
      [libc++][modules] Removes module testing. (#76083) · d06ae33e
      Mark de Wever authored
      This removes the entire modules testing infrastructure.
      
      The current infrastructure uses CMake to generate the std and std.compat
      module. This requires quite a bit of plumbing and uses CMake. Since
      CMake introduced module support in CMake 3.26, modules have a higher
      CMake requirement than the rest of the LLVM project. (The LLVM project
      requires 3.20.) The main motivation for this approach was how libc++
      generated its modules. Every header had its own module partition. This
      was changed to improve performance and now only two modules remain. The
      code to build these can be manually crafted.
      
      A followup patch will reenable testing modules, using a different
      approach.
      d06ae33e
    • Aviad Cohen's avatar
    • Robin Caloudis's avatar
      [clang][docs] Improve "Obtaining Clang" section (#71313) · e8af89ef
      Robin Caloudis authored
      ## Why
      
      The documentation is written relatively to `clang-llvm`, not the root
      repository directory. However, some steps in the documentation are
      relative to the repository root, which is not correct.
      
      ## What
      Documentation steps have been modified to make them correct and outdated
      ones were updated. Some details:
      * Correct paths in documentation
      * Change `bootstrap.py` -> `configure.py` since bootstraping Ninja has
      [slightly
      changed](https://github.com/ninja-build/ninja/tree/master?tab=readme-ov-file#python)
      e8af89ef
    • Luke Lau's avatar
      [RISCV] Overwrite cpu target features for full arch string in target attribute (#77426) · 069e9b44
      Luke Lau authored
      This patch reworks RISCVTargetInfo::initFeatureMap to fix the issue
      described
      in
      https://github.com/llvm/llvm-project/pull/74889#pullrequestreview-1773445559
      (and is an alternative to #75804)
      
      When a full arch string is specified, a "full" list of extensions is now
      passed
      after the __RISCV_TargetAttrNeedOverride marker feature, which includes
      any
      negative features that disable ISA extensions.
      
      In initFeatureMap, there are now two code paths:
      
      1. If the arch string was overriden, use the "full" list of override
      features,
      only adding back any non-isa features that were specified.
      
      Using the full list of positive and negative features will mean that the
      target-cpu will have no effect on the final arch, e.g.
      __attribute__((target("arch=rv64i"))) with -mcpu=sifive-x280 will have
      the
      features for rv64i, not a mix of both.
      
      2. Otherwise, parse and *append* the list of implied features. By
      appending, we
      turn back on any features that might have been disabled by a negative
      extension, i.e. this handles the case fixed in #74889.
      069e9b44
    • Craig Topper's avatar
      [RISCV][GISel] Don't create generic virtual registers in selectSHXADDOp/selectSHXADD_UWOp. (#78396) · 00d6232d
      Craig Topper authored
      Since we're creating target specific instructions, I think we should be
      creating registers with the GPR register class.
      00d6232d
    • Danila Malyutin's avatar
      [SelectionDAG] Fix isKnownNeverZeroFloat for vectors (#78308) · 46a929f0
      Danila Malyutin authored
      Return true iff all of vector elements are constant AND not zero
      
      Fixes #77805
      
      Previously, it'd return `true` (as in - the value is known to be never
      zero) for any build_vector/splat_vector with non-constant elements.
      46a929f0
    • Fangrui Song's avatar
      [AMDGPU,test] Change llc -march= to -mtriple= (#75982) · 9e9907f1
      Fangrui Song authored
      Similar to 806761a7.
      
      For IR files without a target triple, -mtriple= specifies the full
      target triple while -march= merely sets the architecture part of the
      default target triple, leaving a target triple which may not make sense,
      e.g. amdgpu-apple-darwin.
      
      Therefore, -march= is error-prone and not recommended for tests without
      a target triple. The issue has been benign as we recognize
      $unknown-apple-darwin as ELF instead of rejecting it outrightly.
      
      This patch changes AMDGPU tests to not rely on the default
      OS/environment components. Tests that need fixes are not changed:
      
      ```
        LLVM :: CodeGen/AMDGPU/fabs.f64.ll
        LLVM :: CodeGen/AMDGPU/fabs.ll
        LLVM :: CodeGen/AMDGPU/floor.ll
        LLVM :: CodeGen/AMDGPU/fneg-fabs.f64.ll
        LLVM :: CodeGen/AMDGPU/fneg-fabs.ll
        LLVM :: CodeGen/AMDGPU/r600-infinite-loop-bug-while-reorganizing-vector.ll
        LLVM :: CodeGen/AMDGPU/schedule-if-2.ll
      ```
      9e9907f1
    • Jonas Devlieghere's avatar
      [lldb] Fix trailing whitespace & formatting in Core/Module.cpp (NFC) · 5aea6ba8
      Jonas Devlieghere authored
      I have my editor configured to remove trailing whitespace and every time
      I touch this file I end up with a bunch of clang-format changes to lines
      that were modified because of it. Nobody likes trailing whitespace so
      this cleans up the file.
      5aea6ba8
    • Jonas Devlieghere's avatar
      [lldb] Store SupportFile in CompileUnit (NFC) · ff9fcc74
      Jonas Devlieghere authored
      Store a SupportFile, rather than a FileSpec, in CompileUnit. This commit
      works towards having the SourceManager operate on SupportFiles so that
      it can (1) validate the Checksum and (2) materialize the content of
      inline source information.
      ff9fcc74
    • cor3ntin's avatar
      [Clang] Implement CWG2598: Union of non-literal types (#78195) · 4e64159c
      cor3ntin authored
      A union is considered a literal type unless it has no non-literal
      member.
      
      This resolves CWG2096 (which makes unions with literal members literal)
      and CWG2598 (empty unions are literal types).
      
      Fixes #77924
      4e64159c
    • Jonas Devlieghere's avatar
      [lldb] Store SupportFile in LineEntry (NFC) (#77999) · 933c25e5
      Jonas Devlieghere authored
      Store a SupportFile, rather than a FileSpec, in LineEntry. This commit
      works towards having the SourceManageroperate on SupportFiles so that it
      can (1) validate the Checksum and (2) materialize the content of inline
      source information.
      933c25e5
    • h-vetinari's avatar
      [clang-cl] document correct defaults for `-fms-compatibility-version` / `-fmsc-version` (#76418) · 3e0d71cd
      h-vetinari authored
      The UserManual states wrongly (AFAICT) that these default are not being
      defined for clang-cl, whereas further up the opposite is stated:
      
      
      https://github.com/llvm/llvm-project/blob/c86fe3ee0b92934f5d18394d9a0cdc1d3f0eef64/clang/docs/UsersManual.rst#L3375-L3382
      
      I've chosen to follow that wording, as it's the latest related update.
      
      CC @RIscRIpt who recently touched this in
      b3e6ff33
      CC @AaronBallman who cared about this, c.f.
      8fc0dcf0
      3e0d71cd
    • YunQiang Su's avatar
      Sanitizer/MIPS: Use $t9 for preemptible function call (#76894) · 0a64367a
      YunQiang Su authored
      
      
      Currently, almost all of the shared libraries of MIPS, rely on $t9
      to get the address of current function, instead of PCREL instructions,
      even on MIPSr6. So we have to set $t9 properly.
      
      To get the address of preemptible function, we need the help of GOT.
      MIPS/O32 has .cpload, which can help to generate 3 instructions to get GOT.
      For __mips64, we can get GOT by:
      
      lui $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      daddu $t8, $t8, $t9
      daddiu $t8, $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      
      And then get the address of __interceptor_func, and jump to it
      
      ld $t9, %got_disp(_interceptor" SANITIZER_STRINGIFY(func) ")($t8)
      jr $t9
      
      Fixes #74047
      
      Co-authored-by: default avatarYunQiang Su <yunqiang.su@cipunited.com>
      0a64367a
    • Pranav Kant's avatar
      Disable ConstraintSystemTest for now · 8371cdca
      Pranav Kant authored
      as it started failing after https://github.com/llvm/llvm-project/commit/8e514c572e44eda237417236b4c92176dfce9cd9
      
      Above commit enables llvm::DebugFlag which is a global variable.
      8371cdca
    • Phoebe Wang's avatar
      [X86] Use vXi1 for `k` constraint in inline asm (#77733) · 8d6e82d5
      Phoebe Wang authored
      Fixes #77172
      8d6e82d5
    • Ami-zhang's avatar
      [LoongArch] Add LoongArch V1.1 instructions definitions and MC tests (#78238) · 84bdee28
      Ami-zhang authored
      LoongArch V1.1 instrucions include floating-point approximate reciprocal
      instructions and atomic instrucions. And add testcases for these
      instrucions meanwhile.
      84bdee28
    • Jacques Pienaar's avatar
      [mlir][arith] Add overflow flags support to arith ops (#78376) · 8934b106
      Jacques Pienaar authored
      Add overflow flags support to the following ops:
      * `arith.addi`
      * `arith.subi`
      * `arith.muli`
      
      Example of new syntax:
      ```
      %res = arith.addi %arg1, %arg2 overflow<nsw> : i64
      ```
      Similar to existing LLVM dialect syntax
      ```
      %res = llvm.add %arg1, %arg2 overflow<nsw> : i64
      ```
      
      Tablegen canonicalization patterns updated to always drop flags, proper
      support with tests will be added later.
      
      Updated LLVMIR translation as part of this commit as it currenly written
      in a way that it will crash when new attributes added to arith ops
      otherwise.
      
      Also lower `arith` overflow flags to corresponding SPIR-V op decorations
      
      Discussion
      
      https://discourse.llvm.org/t/rfc-integer-overflow-flags-support-in-arith-dialect/76025
      
      
      
      This effectively rolls forward #77211, #77700 and #77714 while adding a
      test to ensure the Python usage is not broken. More follow up needed but
      unrelated to the core change here. The changes here are minimal and just
      correspond to "textual namespacing" ODS side, no C++ or Python changes
      were needed.
      
      ---------
      
      ---------
      
      Co-authored-by: default avatarIvan Butygin &lt;ivan.butygin@gmail.com&gt;, Yi Wu <yi.wu2@arm.com>
      8934b106
    • Phoebe Wang's avatar
    • antangelo's avatar
      [clang] Emit error for invalid friend functions under [temp.friend]p9 (#78083) · 46a395d8
      antangelo authored
      Emits an error for friend FunctionDecls that either:
      
      * are not templates and have a requires clause
      * are templates, and have a constrained parameter that depends on a
      template parameter from an enclosing template
      
      and are not a definition.
      
      For a non-template friend function with a requires clause, if the
      function is not templated then the original error message indicating
      that such a function is disallowed is shown instead, as the function
      will still be rejected if a definition is added.
      46a395d8
    • jimingham's avatar
      Add the Linux "you can use this binary" bits to run_to_source_breakpoint (#78377) · 705c5b80
      jimingham authored
      Follow-on to a4cd99ea - I forgot you
      have to add ANY shared library you want to use to extra_images...
      705c5b80
    • Younan Zhang's avatar
      [Clang][Sema] Extract ellipsis location from CXXFoldExpr for reattaching... · 29b5f8f9
      Younan Zhang authored
      [Clang][Sema] Extract ellipsis location from CXXFoldExpr for reattaching constraints on NTTPs (#78080)
      
      We build up a `CXXFoldExpr` for immediately declared constraints as per
      C++20 [temp.param]/4. This is done by
      `formImmediatelyDeclaredConstraint` where an `EllipsisLoc` is essential
      to determine whether this is a pack.
      
      On the other hand, when attempting to instantiate a class template,
      member templates might not be instantiated immediately, so we leave them
      intact. For function templates with NTTPs, we reattach constraints if
      possible so that they can be evaluated later. To properly form that, we
      attempted to extract an ellipsis location if the param per se was a
      parameter pack. Unfortunately, for the following NTTP case, we seemingly
      failed to handle:
      
      ```cpp
      template <Constraint auto... Pack>
      void member();
      ```
      
      The NTTPD Pack is neither an `ExpandedParameterPack` nor a
      `PackExpansion` (its type does not expand anything). As a result, we end
      up losing track of the constraints on packs, although we have them
      inside the associated `CXXFoldExpr`.
      
      This patch fixes that by extracting the ellipsis location out of the
      previous constraint expression. Closes
      https://github.com/llvm/llvm-project/issues/63837.
      29b5f8f9
    • jimingham's avatar
      Ensure that the executable module is ModuleList[0] (#78360) · a4cd99ea
      jimingham authored
      We claim in a couple places that the zeroth element of the module list
      for a target is the main executable, but we don't actually enforce that
      in the ModuleList class. As we saw, for instance, in
      
      32dd5b20
      
      it's not all that hard to get this to be off. This patch ensures that
      the first object file of type Executable added to it is moved to the
      front of the ModuleList. I also added a test for this.
      
      In the normal course of operation, where the executable is added first,
      this only adds a check for whether the first element in the module list
      is an executable. If that's true, we just append as normal.
      
      Note, the code in Target::GetExecutableModule doesn't actually agree
      that the zeroth element must be the executable, it instead returns the
      first Module of type Executable. But I can't tell whether that was a
      change in intention or just working around the bug that we don't always
      maintain this ordering. But given we've said this in scripting as well
      as internally, I think we shouldn't change our minds about this.
      a4cd99ea
    • Alexander Richardson's avatar
      [compiler-rt] Drop COMPILER_RT_BUILD_CRT workaround (#78331) · 0266f414
      Alexander Richardson authored
      This variable was explicitly removed from the cache to ease transition
      from existing build directories but that breaks passing
      COMPILER_RT_BUILD_CRT=OFF on the command line. I was surprised to see
      the CRT builds being run for my builtins-only build config (I noticed
      because one of the tests was failing despite having `REQUIRES: crt`).
      
      If I pass `-DCOMPILER_RT_BUILD_CRT=OFF` to cmake and add some prints
      around the `unset` statement it shows the following:
      ```
      -- before unset(): COMPILER_RT_BUILD_CRT=OFF
      -- after unset: COMPILER_RT_BUILD_CRT=
      -- after cmake_dependent_option COMPILER_RT_BUILD_CRT=ON
      ```
      
      Drop this temporary workaround now that over 6 months have passed.
      0266f414
    • Davide Italiano's avatar