1. Feb 02, 2024
    • Markus Böck's avatar
      [mlir] Start moving some builtin type formats to the dialect · e67e980c
      Markus Böck authored
      Most types and attributes in the builtin dialect are parsed and printed using special-purpose printers and parsers for that type. They also use the low-level `Printer` rather than the `AsmPrinter`, making the implementations inconsistent compared to all other dialects in MLIR.
      
      This PR starts moving some builtin types to be parsed using the usual `print` and `parse` methods like all other MLIR dialects. This has the following advantages:
      * The implementation now looks like any other dialect's types
      * It is now possible to use `assemblyFormat` for builtin types and attributes
      * The code can be easily moved to other dialects if desired
      * Arguably better layering and less code
      * As a side-effect, it is now also possible to write `!builtin.<type>` for any types moved
      
      A future benefit would include being able to print types and attributes in stripped format as well (e.g. `<f32>` vs `complex<f32>`), just like all other dialect types and attributes. This is currently explicitly disabled as it causes a LOT of changes in IR syntax and I believe some ambiguities in the parser.
      
      For the purpose of reviewing and incremental development, this PR only moves `tuple`, `tensor`, `none`, `memref` and `complex`. The plan is to eventually move all attributes and types where the current syntax can be implemented within the dialect.
      
      For backwards compatibility with the existing syntax, the builtin dialect is special-cased in the printer where the `builtin.` prefix is omitted.
      e67e980c
    • Markus Böck's avatar
      clang-format · f9f2f00d
      Markus Böck authored
      f9f2f00d
    • Markus Böck's avatar
      [mlir] Add `Print(Attr|Type)Qualified` trait · 94c47995
      Markus Böck authored
      This PR adds a new trait to attributes and types that force the use of the qualified syntax for attributes and types. More concretely, any attribute or type with the trait must be parsed and printed with the `dialect.mnemonic` prefix.
      
      The motivation for this PR is the dependent PR where it is used to retain backwards-compatibility of syntax, but downstream projects may also use the trait if the subjectively prefer the verbose syntax.
      94c47995
  2. Feb 01, 2024
    • Lucas Duarte Prates's avatar
      [Clang][AArch64] Add ACLE macros for FEAT_PAuth_LR (#80163) · 1bbb797e
      Lucas Duarte Prates authored
      This updates clang's target defines to include the ACLE changes covering
      the FEAT_PAuth_LR architecture extension.
      The changes include:
      * The new `__ARM_FEATURE_PAUTH_LR` feature macro, which is set to 1 when
        FEAT_PAuth_LR is available in the target.
      * A new bit field for the existing `__ARM_FEATURE_PAC_DEFAULT` macro,
        indicating the use of PC as a diversifier for Pointer Authentication
        (from -mbranch-protection=pac-ret+pc).
      
      The approved changes to the ACLE spec can be found here:
      https://github.com/ARM-software/acle/pull/292
      1bbb797e
    • Tom Eccles's avatar
      [flang][HLFIR] Relax verifiers of intrinsic operations (#80132) · e9e01675
      Tom Eccles authored
      The verifiers are currently very strict: requiring intrinsic operations
      to be used only in cases where the Fortran standard permits the
      intrinsic to be used.
      
      There have now been a lot of cases where these verifiers have caused
      bugs in corner cases. In a recent ticket, @jeanPerier pointed out that
      it could be useful for future optimizations if somewhat invalid uses of
      these operations could be allowed in dead code. See this comment:
      https://github.com/llvm/llvm-project/issues/79995#issuecomment-1918118234
      
      In response to all of this, I have decided to relax the intrinsic
      operation verifiers. The intention is now to only disallow operation
      uses that are likely to crash the compiler. Other checks are still
      available under `-strict-intrinsic-verifier`.
      
      The disadvantage of this approach is that IR can now represent intrinsic
      invocations which are incorrect. The lowering and implementation of
      these intrinsic functions is unlikely...
      e9e01675
    • Benjamin Kramer's avatar
      [bazel] Fix a typo from e7d40a87 · ca7fd254
      Benjamin Kramer authored
      ca7fd254
    • Aiden Grossman's avatar
      [llvm-exegesis] Replace --num-repetitions with --min-instructions (#77153) · 415bf200
      Aiden Grossman authored
      This patch replaces --num-repetitions with --min-instructions to make it
      more clear that the value refers to the minimum number of instructions
      in the final assembled snippet rather than the number of repetitions of
      the snippet. This patch also refactors some llvm-exegesis internal
      variable names to reflect the name change.
      
      Fixes #76890.
      415bf200
    • Benjamin Kramer's avatar
      [bazel] Put back the pieces of TableGenGlobalISel that unittests depend on · 395c8175
      Benjamin Kramer authored
      This is a mess and needs to be cleaned up some day.
      395c8175
    • Benjamin Kramer's avatar
      [bazel] Merge TableGenGlobalISel into the tablegen target · 468b2393
      Benjamin Kramer authored
      These two are intertwined enough so it doesn't really make sense to have
      it standalone and hack around it by putting headers into both.
      468b2393
    • Benjamin Kramer's avatar
      [bazel] Add missing header for 7ec996d4 · d0dbd50c
      Benjamin Kramer authored
      d0dbd50c
    • Marius Brehler's avatar
      [mlir][EmitC] Add func, call and return operations and conversions (#79612) · e7d40a87
      Marius Brehler authored
      This adds a `func`, `call` and `return` operation to the EmitC dialect,
      closely related to the corresponding operations of the Func dialect. In
      contrast to the operations of the Func dialect, the EmitC operations do
      not support multiple results. The `emitc.func` op features a
      `specifiers` argument that for example allows, with corresponding
      support in the emitter, to emit `inline static` functions.
      
      Furthermore, this adds patterns and a pass to convert the Func dialect
      to EmitC. A `func.func` op that is `private` is converted to
      `emitc.func` with a `"static"` specifier.
      e7d40a87
    • Wei Wang's avatar
      [Clang][test] Limit library search when linking shared lib (#80253) · ae931b47
      Wei Wang authored
      Don't search for unnecessary libs when linking the shared lib. This
      allows the test to run in chroot environment.
      ae931b47
    • jeanPerier's avatar
      [flang][NFC] Cache derived type translation in lowering (#80179) · 84564e10
      jeanPerier authored
      Derived type translation is proving expensive in modern fortran apps
      with many big derived types with dozens of components and parents.
      
      Extending the cache that prevent recursion is proving to have little
      cost on apps with small derived types and significant gain (can divide
      compile time by 2) on modern fortran apps.
      
      It is legal since the cache lifetime is less than the MLIRContext
      lifetime that owns the cached mlir::Type.
      
      Doing so also exposed that the current caching was incorrect, the type
      symbol is the same for kind parametrized derived types regardless of the
      kind parameters. Instances with different kinds should lower to
      different MLIR types. See added test.
      Using the type scopes fixes the problem.
      84564e10
    • Matthias Springer's avatar
      [mlir][Transforms] `GreedyPatternRewriteDriver`: Hash ops separately (#78312) · 5fdf8c6f
      Matthias Springer authored
      The greedy pattern rewrite driver has multiple "expensive checks" to
      detect invalid rewrite pattern API usage. As part of these checks, it
      computes fingerprints for every op that is in scope, and compares the
      fingerprints before and after an attempted pattern application.
      
      Until now, each computed fingerprint took into account all nested
      operations. That is quite expensive because it walks the entire IR
      subtree. It is also redundant in the expensive checks because we already
      compute a fingerprint for every op.
      
      This commit significantly improves the running time of the "expensive
      checks" in the greedy pattern rewrite driver.
      5fdf8c6f
    • Jason Molenda's avatar
      Skip two WatchpointAlgorithm tests for 32-bit lldb's · 90e68086
      Jason Molenda authored
      After iterating with the arm-ubuntu CI bot, I found the crash (a
      std::bad_alloc exception being thrown) was caused by these two
      entries when built on a 32-bit machine.  I probably have an assumption
      about size_t being 64-bits in WatchpointAlgorithms and we have a
      problem when it's actually 32-bits and we're dealing with a real
      64-bit address.  All of the cases where the address can be represented
      in the low 32-bits of the addr_t work correctly, so for now I'm
      skipping these two unit tests when building lldb on a 32-bit host
      until I can review that method and possibly switch to explicit
      uin64_t's.
      .
      90e68086
    • Jason Molenda's avatar
      Done iterating with arm-ubuntu bot, I see the problem test. · eaa3d5e2
      Jason Molenda authored
      Go back to the original form of this file before I add temp
      workaround.
      eaa3d5e2
    • Kazu Hirata's avatar
      [clang] Use StringRef::starts_with (NFC) · b67ce7e3
      Kazu Hirata authored
      b67ce7e3
    • Kazu Hirata's avatar
      [llvm] Use StringRef::starts_with (NFC) · 39fa3048
      Kazu Hirata authored
      39fa3048
    • Kazu Hirata's avatar
      [IR] Use range-based for loops (NFC) · e8512786
      Kazu Hirata authored
      e8512786
    • Pierre van Houtryve's avatar
    • Hugo Trachino's avatar
      [mlir] Use `create` instead of `createOrFold` for ConstantOp as folding has no... · 65066c02
      Hugo Trachino authored
      [mlir] Use `create` instead of `createOrFold` for ConstantOp as folding has no effect (NFC) (#80129)
      
      This aims to clean-up confusing uses of
      builder.createOrFold<ConstantOp> since folding of constants fails.
      65066c02
    • Jason Molenda's avatar
      54f324f3
    • Timm Bäder's avatar
      [clang][Interp] Support GenericSelectionExprs · 48f8b74c
      Timm Bäder authored
      Just delegate to the resulting expression.
      48f8b74c
    • Timm Bäder's avatar
      fa98e286
    • Timm Bäder's avatar
      [clang][Interp] Protect Inc/Dec ops against dummy pointers · a9e83091
      Timm Bäder authored
      We create them more often in C, so it's more likely to happen there.
      a9e83091
    • Jason Molenda's avatar
    • Shengchen Kan's avatar
      [X86][CodeGen] Set mayLoad = 1 for LZCNT/POPCNT/TZCNTrm_(EVEX|NF) · 1395e582
      Shengchen Kan authored
      Promoted and NF LZCNT/POPCNT/TZCNT were supported in #79954.
      B/c null_frag is used in the patterns for these variants, tablgen can
      not infer mayLoad = 1 for them.
      
      This can be tested by MCA tests, which will be added after
      -mcpu=<cpu_with_apx> is supported.
      1395e582
    • Timm Baeder's avatar
      [clang][Interp] Handle imaginary literals (#79130) · 6ff431b0
      Timm Baeder authored
      Initialize the first element to 0 and the second element to the value of
      the subexpression.
      6ff431b0
    • Aiden Grossman's avatar
      [Github] Build stage2-clang-bolt target for CI container · 5d9ffcd7
      Aiden Grossman authored
      Only the stage2-distribution target is built by default for the
      stage2 distribution installation target. This means that we don't get a
      BOLT optimized binary. This patch explicitly builds the
      stage2-clang-bolt target before the distribution installation target so
      that the clang binary is optimized before it gets installed.
      5d9ffcd7
    • Timm Bäder's avatar
      [clang][Interp] complex binary operators aren't always initializing · a8f317ae
      Timm Bäder authored
      The added test case would trigger the removed assertion.
      a8f317ae
    • Jason Molenda's avatar
      Skip 2 of the three test sets to narrow down the arm-ubuntu · fdd98e50
      Jason Molenda authored
      CI bot crash when running this unittest.  The printfs aren't
      printing into the CI log output.
      fdd98e50
    • Emilia Kond's avatar
      [clang-format] Allow decltype in requires clause (#78847) · 9b68c095
      Emilia Kond authored
      If clang-format is not sure whether a `requires` keyword starts a
      requires clause or a requires expression, it looks ahead to see if any
      token disqualifies it from being a requires clause. Among these tokens
      was `decltype`, since it fell through the switch.
      
      This patch allows decltype to exist in a require clause.
      
      I'm not 100% sure this change won't have repercussions, but that just
      means we need more test coverage!
      
      Fixes https://github.com/llvm/llvm-project/issues/78645
      9b68c095
    • Piotr Zegar's avatar
      [clang-tidy] Add AllowStringArrays option to modernize-avoid-c-arrays (#71701) · b777bb78
      Piotr Zegar authored
      Add AllowStringArrays option, enabling the exclusion of array types with
      deduced sizes constructed from string literals. This includes only var
      declarations of array of characters constructed directly from c-strings.
      
      Closes #59475
      b777bb78
    • Chuanqi Xu's avatar
      [C++20] [Modules] Introduce -fskip-odr-check-in-gmf (#79959) · 8eea582d
      Chuanqi Xu authored
      Close https://github.com/llvm/llvm-project/issues/79240
      
      Cite the comment from @mizvekov in
      //github.com/llvm/llvm-project/issues/79240:
      
      > There are two kinds of bugs / issues relevant here:
      >
      > Clang bugs that this change hides
      > Here we can add a Frontend flag that disables the GMF ODR check, just
      > so
      > we can keep tracking, testing and fixing these issues.
      > The Driver would just always pass that flag.
      > We could add that flag in this current issue.
      > Bugs in user code:
      > I don't think it's worth adding a corresponding Driver flag for
      > controlling the above Frontend flag, since we intend it's behavior to
      > become default as we fix the problems, and users interested in testing
      > the more strict behavior can just use the Frontend flag directly.
      
      This patch follows the suggestion:
      - Introduce the CC1 flag `-fskip-odr-check-in-gmf` which is by default
      off, so that the every existing test will still be tested with checking
      ODR violations.
      - Passing `-fskip-odr-check-in-gmf` in the driver to keep the behavior
      we intended.
      - Edit the document to tell the users who are still interested in more
      strict checks can use `-Xclang -fno-skip-odr-check-in-gmf` to get the
      existing behavior.
      8eea582d
    • Shengchen Kan's avatar
      c82a645e
    • Jason Molenda's avatar
      3b76b864
    • Wanyi's avatar
      [llvm-gsymutil] Print one-time DWO file missing warning under --quiet flag (#79882) · 5a8f290d
      Wanyi authored
      FileCheck test added
      ```
      ./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-dwo.yaml
      ```
      
      Manual test steps:
      
      - Create binary with split-dwarf:
      ```
      clang++ -g -gdwarf-4 -gsplit-dwarf main.cpp -o main_split
      ```
      
      - Remove or remane the dwo file to a different name so llvm-gsymutil can't find it
      ```
      mv main_split-main.dwo main_split-main__.dwo
      ```
      
      - Now run llvm-gsymutil conversion, it should print out warning with and
      without the `--quiet` flag
      ```
      $ ./bin/llvm-gsymutil --convert=./main_split
      Input file: ./main_split
      Output file (x86_64): ./main_split.gsym
      warning: Unable to retrieve DWO .debug_info section for main_split-main.dwo
      Loaded 0 functions from DWARF.
      Loaded 12 functions from symbol table.
      Pruned 0 functions, ended with 12 total
      ```
      
      ```
      $ ./bin/llvm-gsymutil --convert=./main_split --quiet
      Input file: ./main_split
      Output file (x86_64): ./main_split.gsym
      warning: Unable to retrieve DWO .debug_info section for some object files. (Remove the --quiet flag for full output)
      Pruned 0 functions, ended with 12 total
      ```
      5a8f290d
    • wangpc's avatar
    • LLVM GN Syncbot's avatar
      [gn build] Port 147d7a64 · 19a10c13
      LLVM GN Syncbot authored
      19a10c13
    • Jason Molenda's avatar
      [lldb] Add support for large watchpoints in lldb (#79962) · 147d7a64
      Jason Molenda authored
      This patch is the next piece of work in my Large Watchpoint proposal,
      https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116
      
      This patch breaks a user's watchpoint into one or more
      WatchpointResources which reflect what the hardware registers can cover.
      This means we can watch objects larger than 8 bytes, and we can watched
      unaligned address ranges. On a typical 64-bit target with 4 watchpoint
      registers you can watch 32 bytes of memory if the start address is
      doubleword aligned.
      
      Additionally, if the remote stub implements AArch64 MASK style
      watchpoints (e.g. debugserver on Darwin), we can watch any power-of-2
      size region of memory up to 2GB, aligned to that same size.
      
      I updated the Watchpoint constructor and CommandObjectWatchpoint to
      create a CompilerType of Array<UInt8> when the size of the watched
      region is greater than pointer-size and we don't have a variable type to
      use. For pointer-size and smaller, we can display the watched granule as
      an integer value; for larger-than-pointer-size we will display as an
      array of bytes.
      
      I have `watchpoint list` now print the WatchpointResources used to
      implement the watchpoint.
      
      I added a WatchpointAlgorithm class which has a top-level static method
      that takes an enum flag mask WatchpointHardwareFeature and a user
      address and size, and returns a vector of WatchpointResources covering
      the request. It does not take into account the number of watchpoint
      registers the target has, or the number still available for use. Right
      now there is only one algorithm, which monitors power-of-2 regions of
      memory. For up to pointer-size, this is what Intel hardware supports.
      AArch64 Byte Address Select watchpoints can watch any number of
      contiguous bytes in a pointer-size memory granule, that is not currently
      supported so if you ask to watch bytes 3-5, the algorithm will watch the
      entire doubleword (8 bytes). The newly default "modify" style means we
      will silently ignore modifications to bytes outside the watched range.
      
      I've temporarily skipped TestLargeWatchpoint.py for all targets. It was
      only run on Darwin when using the in-tree debugserver, which was a proxy
      for "debugserver supports MASK watchpoints". I'll be adding the
      aforementioned feature flag from the stub and enabling full mask
      watchpoints when a debugserver with that feature is enabled, and
      re-enable this test.
      
      I added a new TestUnalignedLargeWatchpoint.py which only has one test
      but it's a great one, watching a 22-byte range that is unaligned and
      requires four 8-byte watchpoints to cover.
      
      I also added a unit test, WatchpointAlgorithmsTests, which has a number
      of simple tests against WatchpointAlgorithms::PowerOf2Watchpoints. I
      think there's interesting possible different approaches to how we cover
      these; I note in the unit test that a user requesting a watch on address
      0x12e0 of 120 bytes will be covered by two watchpoints today, a
      128-bytes at 0x1280 and at 0x1300. But it could be done with a 16-byte
      watchpoint at 0x12e0 and a 128-byte at 0x1300, which would have fewer
      false positives/private stops. As we try refining this one, it's helpful
      to have a collection of tests to make sure things don't regress.
      
      I tested this on arm64 macOS, (genuine) x86_64 macOS, and AArch64
      Ubuntu. I have not modifed the Windows process plugins yet, I might try
      that as a standalone patch, I'd be making the change blind, but the
      necessary changes (see ProcessGDBRemote::EnableWatchpoint) are pretty
      small so it might be obvious enough that I can change it and see what
      the Windows CI thinks.
      
      There isn't yet a packet (or a qSupported feature query) for the gdb
      remote serial protocol stub to communicate its watchpoint capabilities
      to lldb. I'll be doing that in a patch right after this is landed,
      having debugserver advertise its capability of AArch64 MASK watchpoints,
      and have ProcessGDBRemote add eWatchpointHardwareArmMASK to
      WatchpointAlgorithms so we can watch larger than 32-byte requests on
      Darwin.
      
      I haven't yet tackled WatchpointResource *sharing* by multiple
      Watchpoints. This is all part of the goal, especially when we may be
      watching a larger memory range than the user requested, if they then add
      another watchpoint next to their first request, it may be covered by the
      same WatchpointResource (hardware watchpoint register). Also one "read"
      watchpoint and one "write" watchpoint on the same memory granule need to
      be handled, making the WatchpointResource cover all requests.
      
      As WatchpointResources aren't shared among multiple Watchpoints yet,
      there's no handling of running the conditions/commands/etc on multiple
      Watchpoints when their shared WatchpointResource is hit. The goal beyond
      "large watchpoint" is to unify (much more) the Watchpoint and Breakpoint
      behavior and commands. I have a feeling I may be slowly chipping away at
      this for a while.
      
      Re-landing this patch after fixing two undefined behaviors in
      WatchpointAlgorithms found by UBSan and by failures on different
      CI bots.
      
      rdar://108234227
      147d7a64