1. Jan 12, 2024
    • Aiden Grossman's avatar
      Update after merge · 8f62b70c
      Aiden Grossman authored
      8f62b70c
    • Aiden Grossman's avatar
      [llvm-exegesis] Refactor individual counter data to ConfiguredEvent · 4300851b
      Aiden Grossman authored
      This further sets things up for validation events. Having a separate
      abstraction for a configured event that is setup as a counter allows for
      much easier creation of more events in the future within a single
      counter group (like validation counters) without duplicating any code.
      4300851b
    • Aiden Grossman's avatar
      Fix formatting · 17a4172d
      Aiden Grossman authored
      17a4172d
    • Aiden Grossman's avatar
      Merge branch 'users/boomanaiden154/exegesis-validation-counters-countergroup'... · ea146f24
      Aiden Grossman authored
      Merge branch 'users/boomanaiden154/exegesis-validation-counters-countergroup' into users/boomanaiden154/exegesis-validation-counters-implementation
      ea146f24
    • Aiden Grossman's avatar
      [llvm-exegesis] Refactor Counter to CounterGroup · e3e47a15
      Aiden Grossman authored
      This refactoring gets things ready for validation counters where the
      plan is to reuse the existing Counter infrastructure to contain event
      groups that consist of a single event that is being measured along with
      validation counters.
      e3e47a15
    • Amir Ayupov's avatar
      [BOLT] Delta-encode function start addresses in BAT (#76902) · 8fb8ad66
      Amir Ayupov authored
      Further reduce the size of BAT section:
      - large binary: to 12716312 bytes (0.33x original),
      - medium binary: to 1649472 bytes (0.28x original),
      - small binary: to 428 bytes (0.30x original).
      
      Test Plan: Updated bolt/test/X86/bolt-address-translation.test
      8fb8ad66
    • Amir Ayupov's avatar
      [BOLT] Delta-encode offsets in BAT (#76900) · bbe07989
      Amir Ayupov authored
      This change further reduces the size of BAT:
      - large binary: to 13073904 bytes (0.34x original),
      - medium binary: to 1703116 bytes (0.29x original),
      - small binary: to 436 bytes (0.30x original).
      
      Test Plan: Updated bolt/test/X86/bolt-address-translation.test
      bbe07989
    • a-n-n-a-l-e-e's avatar
      [libc++] Re-export libc++abi symbols on Apple platforms when using system-libcxxabi (#77218) · b3981edb
      a-n-n-a-l-e-e authored
      When using LIBCXX_CXX_ABI=system-libcxxabi on Apple platforms, we would not
      re-export the libc++abi symbols unlike when LIBCXX_CXX_ABI=libcxxabi. This
      was caused by overly strict string matching in CMake.
      
      https://github.com/NixOS/nixpkgs/issues/269548
      b3981edb
    • Fangrui Song's avatar
      [asan] Enable StackSafetyAnalysis by default · 7740565f
      Fangrui Song authored
      StackSafetyAnalysis determines whether stack-allocated variables are
      guaranteed to be safe from memory access bugs and enables the removal of
      certain unneeded instrumentations.
      (hwasan enables StackSafetyAnalysis in https://reviews.llvm.org/D108381)
      
      In a release build of clang, text sections are 9% smaller.
      
      Test updates:
      
      * asan-stack-safety.ll: test the -asan-use-stack-safety=1 default
      * lifetime-uar-uas.ll: switch to an indexed store to prevent
        StackSafetyAnalysis from optimizing out instrumentation for %c
      * alloca_vla_interact.cpp: add a load to prevent StackSafetyAnalysis
        from optimizing out `__asan_alloca_poison` for the VLA `array`
      * scariness_score_test.cpp: add -asan-use-stack-safety=0 to make a load
        of a `__asan_poison_memory_region`-poisoned local variable fail as
        intended.
      * other .ll tests: add -asan-use-stack-safety=0
      
      Reviewed By: kstoimenov
      
      Pull Request: https://github.com/llvm/llvm-project/pull/77210
      7740565f
    • Valentin Clement's avatar
    • Fangrui Song's avatar
      [StackSafetyAnalysis] Bail out if MemIntrinsic length is -1 (#77837) · a6d40170
      Fangrui Song authored
      Clang generates llvm.memset.p0.i64 with a length of -1 for the following
      code in
      `-stdlib=libc++ -std=c++20` mode
      
      (https://github.com/llvm/llvm-project/pull/77210#issuecomment-1887650010)
      ```cpp
      bool strtof_clamp(const std::string &str);
      void floatsuffix_check(char *yytext_r) {
        std::string text = yytext_r;
        text.resize(text.size() - 1);
        strtof_clamp(text);
      }
      ```
      
      `Sizes = [0xffffffffffffffff, 0)`. `SizeRange = [0, 0-1)`, leading to
      `assert(!isUnsafe(SizeRange));` failure. Bail out if the length is -1.
      Other negative values are handled by the existing condition.
      a6d40170
    • Valentin Clement (バレンタイン クレメン)'s avatar
      [flang][openacc] Do not accept static and num for gang clause on routine dir (#77673) · 238b5790
      Only the dim argument is allowed on the gang clause for the routine
      directive. Reject static and num arguments in the semantic check.
      238b5790
    • Andy Kaylor's avatar
      Add sync-up for floating-point working group (#71885) · 8b61fc71
      Andy Kaylor authored
      Adding a new working group to discuss floating-point issues
      8b61fc71
    • Daniel Thornburgh's avatar
      [Fuchsia] Add stage2 cmake options · 69bc30b9
      Daniel Thornburgh authored
      69bc30b9
    • Philip Reames's avatar
      Revert "[LSR][TTI][RISCV] Disable terminator folding for RISC-V." · 5ce067d5
      Philip Reames authored
      This reverts commit fdb87640, and thus
      re-enables terminator folding for RISCV.  The reported miscompile has
      been fixed in f5dd70c5.
      5ce067d5
    • Valentin Clement (バレンタイン クレメン)'s avatar
      [flang][openacc] Apply mutually exclusive clauses restriction to routine (#77802) · bdfe5d69
      this patch enforce or fix the enforcement of two restrictions from
      section 2.15.1:
      
      > Only the gang, worker, vector, seq and bind clauses may follow a
      device_type clause.
      
      `seq` was not allowed after `device_type` with the current
      implementation.
      
      > Exactly one of the gang, worker, vector, or seq clauses must appear.
      
      This was not properly checked. This patch check correctly for mutually
      exclusion as described in section 2.4. Mutually exclusive clauses may
      appear on the same directive if they apply for different device_type.
      bdfe5d69
    • Krzysztof Parzyszek's avatar
      Revert "[Flang][Parser] Add missing dependencies to CMakeLists.txt (#77483)" · d4473047
      Krzysztof Parzyszek authored
      This reverts commit cc53ec82.
      
      This commit hasn't accomplished anything. The original issue was that
      `DumpTree`, when called from lowering, caused linker errors due to some
      directive-naming functions being absent. Adding FrontendOpenMP to the
      parser library didn't fix that problem, and according to the notes in
      PR #77483, calling `DumpTree` from lowering isn't really supported.
      d4473047
    • Valentin Clement (バレンタイン クレメン)'s avatar
      [mlir][openacc][flang] Simplify gang, vector and worker representation (#77667) · 40f5f905
      The IR representation for gang, vector and worker has grown with the
      support for device_type. This patch simplify the IR representation for
      gang, vector and worker information on the acc.loop operation.
      
      When the only the keyword is present without any values, the information
      is printed at the same place than when there is values. The device_type
      is omitted if there is no values and it is equal to None. Otherwise the
      full information is displayed. First the keyword only device_type
      information and then the values with their device_type.
      40f5f905
    • Joseph Huber's avatar
      [Libomptarget] Fix GPU Dtors referencing possibly deallocated image (#77828) · 37c1a5e3
      Joseph Huber authored
      Summary:
      The constructors and destructors look up a symbol in the ELF quickly to
      determine if they need to be run on the GPU. This allows us to avoid the
      very slow actions required to do the slower lookup using the vendor API.
      
      One problem occurs with how we handle the lifetime of these images.
      Right now there is no invariant to specify the lifetime of the
      underlying binary image that is loaded. In the typical case, this comes
      from the binary itself in the `.llvm.offloading` section, meaning that
      the lifetime of the binary should match the executable itself. This
      would work fine, if it weren't for the fact that the plugin is loaded
      via `dlopen` and can have a teardown order out of sync with the main
      executable.
      
      This was likely what was occuring when this failed on some systems but
      not others. A potential solution would be to simply copy images into
      memory so the runtime does not rely on external references. Another
      would be to manually zero these out after initialization as to prevent
      this mistake from happening accidentally. The former has the benefit of
      making some checks easier, and allowing for constant initialization be
      done on the ELF itself (normally we can't do this because writing to a
      constant section, e.g. .llvm.offloading is a segfault.). The downside
      would be the extra time required to copy the image in bulk (Although we
      are likely doing this in the vendor runtimes as well).
      
      This patch went with a quick solution to simply set a boolean value at
      initialization time if we need to call destructors.
      
      Fixes: https://github.com/llvm/llvm-project/issues/77798
      37c1a5e3
    • Tacet's avatar
      [ASan][libc++] Initialize `__r_` variable with lambda (#77394) · 75efddba
      Tacet authored
      This commit is a refactor (increases readability) and optimization fix.
      
      This is a fixed commit of
      https://github.com/llvm/llvm-project/pull/76200 First reverthed here:
      https://github.com/llvm/llvm-project/commit/1ea7a56057492d9da1124787a9855cc2edca7df9
      
      Please, check original PR for details.
      
      The difference is a return type of the lambda.
      
      Original description:
      
      This commit addresses optimization and instrumentation challenges
      encountered within comma constructors.
      1) _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS does not work in comma
      constructors.
      2) Code inside comma constructors is not always correctly optimized.
      Problematic code examples:
      - `: __r_(((__str.__is_long() ? 0 : (__str.__annotate_delete(), 0)),
      std::move(__str.__r_))) {`
      - `: __r_(__r_([&](){ if(!__s.__is_long()) __s.__annotate_delete();
      return std::move(__s.__r_);}())) {`
      
      However, lambda with argument seems to be correctly optimized. This
      patch uses that fact.
      
      Use of lambda based on idea from @ldionne.
      75efddba
    • Zequan Wu's avatar
      Revert "[asan] Enable StackSafetyAnalysis by default" · e7f79487
      Zequan Wu authored
      This reverts commit 51fbab13.
      This causes the compiler to crash. Will file a issue to track the status.
      e7f79487
    • Kazu Hirata's avatar
      [Dialect] Fix a warning · 3e82663b
      Kazu Hirata authored
      This patch fixes:
      
        mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:3154:8: error: unused
        variable 'rank' [-Werror,-Wunused-variable]
      3e82663b
    • Amir Ayupov's avatar
      [BOLT] Encode BAT using ULEB128 (#76899) · 565f40d6
      Amir Ayupov authored
      Reduces BAT section size, bytes:
      - large binary: 38676872 -> 23262524 (0.60x),
      - medium binary (trunk clang): 5938004 -> 3213504 (0.54x),
      - small binary (X86/bolt-address-translation.test): 1436 -> 680 (0.47x).
      
      Test Plan: Updated bolt/test/X86/bolt-address-translation.test
      565f40d6
    • Amir Ayupov's avatar
      [BOLT] Add BOLT Address Translation documentation (#76899) · a7cf0a1f
      Amir Ayupov authored
      Test Plan: Open the page in browser
      a7cf0a1f
    • Kazu Hirata's avatar
      [flang] Fix a warning · fb094471
      Kazu Hirata authored
      This patch fixes:
      
        flang/unittests/Runtime/CommandTest.cpp:702:14: error: variable
        length arrays are a C99 feature [-Werror,-Wvla-extension]
      fb094471
    • Kazu Hirata's avatar
      [Format] Fix a warning · cf3421de
      Kazu Hirata authored
      This patch fixes:
      
        clang/unittests/Format/TokenAnnotatorTest.cpp:2181:29: error: lambda
        capture 'Style' is not used [-Werror,-Wunused-lambda-capture]
      cf3421de
    • Kazu Hirata's avatar
      [flang] Fix a warning · 18734f60
      Kazu Hirata authored
      This patch fixes:
      
        flang/runtime/extensions.cpp:111:12: error: variable length arrays
        are a C99 feature [-Werror,-Wvla-extension]
      18734f60
    • Hirofumi Nakamura's avatar
      [clang-format] TableGen keywords support. (#77477) · 0cc31579
      Hirofumi Nakamura authored
      Add TableGen keywords to the additional keyword list of the formatter.
      
      This pull request is the splited part from
      https://github.com/llvm/llvm-project/pull/76059 .
      0cc31579
    • Amir Ayupov's avatar
      [BOLT][NFC] Print BAT section size (#76897) · 2bb511e2
      Amir Ayupov authored
      Test Plan: Updated bolt/test/X86/bolt-address-translation.test
      2bb511e2
    • Usman Nadeem's avatar
      [AArch64][SVE2] Generate XAR (#77160) · c3e3aa9c
      Usman Nadeem authored
      Bitwise exclusive OR and rotate right by immediate
      
      Select xar (x, y, imm) for the following pattern:
          or (shl (xor x, y), nBits-imm), (shr (xor x, y), imm)
      
      This is essentially:
          rotr (xor(x, y), imm)
      c3e3aa9c
    • Felix Schneider's avatar
      [mlir][memref] Transpose: allow affine map layouts in result, extend folder (#76294) · 4619e21c
      Felix Schneider authored
      Currently, the `memref.transpose` verifier forces the result type of the
      Op to have an explicit `StridedLayoutAttr` via the method
      `inferTransposeResultType`. This means that the example Op
      given in the documentation is actually invalid because it uses an `AffineMap`
      to specify the layout.
      It also means that we can't "un-transpose" a transposed memref back to
      the implicit layout form, because the verifier will always enforce the
      explicit strided layout.
      
      This patch makes the following changes:
      
      1. The verifier checks whether the canonicalized strided layout of the
      result Type is identitcal to the canonicalized infered result type
      layout. This way, it's only important that the two Types have the same
      strided layout, not necessarily the same representation of it.
      2. The folder is extended to support folding away the trivial case of
      identity permutation and to fold one transposition into another by
      composing the permutation maps.
      4619e21c
    • Felix Schneider's avatar
      [mlir][affine] Add dependency on `UBDialect` for `PoisonAttr` (#77691) · 061b777c
      Felix Schneider authored
      The folder for `AffineApplyOp` will try creating a `PoisonAttr`
      under certain circumstances. However, this will result in a crash if the
      `UBDialect` isn't loaded.
      
      This patch adds a dependency of `AffineDialect` on `UBDialect`.
      061b777c
    • Mats Petersson's avatar
      Add more ZA modes (#77361) · 21e1bf2d
      Mats Petersson authored
      Add more ZA modes
          
       Adds the arm_shared_za and arm_preserves_za attributes to the existing
       arm_new_za attribute. The functionality already exists in LLVM, so just
       "linking the pieces together".
          
      For more details see:
      https://arm-software.github.io/acle/main/acle.html#sme-attributes-relating-to-za
      21e1bf2d
    • Chris Bieneman's avatar
      [NFC] Remove trailing whitespace · c2fd5b73
      Chris Bieneman authored
      This seems to be causing problems that I couldn't reproduce locally.
      c2fd5b73
    • Philip Reames's avatar
      [LSR] Require non-zero step when considering wrap around for term folding (#77809) · f5dd70c5
      Philip Reames authored
      The term folding logic needs to prove that the induction variable does
      not cycle through the same set of values so that testing for the value
      of the IV on the exiting iteration is guaranteed to trigger only on that
      iteration. The prior code checked the no-self-wrap property on the IV,
      but this is insufficient as a zero step is trivially no-self-wrap per
      SCEV's definition but does repeat the same series of values.
      
      In the current form, this has the effect of basically disabling lsr's
      term-folding for all non-constant strides. This is still a net
      improvement as we've disabled term-folding entirely, so being able to
      enable it for constant strides is still a net improvement.
      
      As future work, there's two SCEV weakness worth investigating.
      
      First sext (or i32 %a, 1) to i64 does not return true for
      isKnownNonZero. This is because we check only the unsigned range in that
      query. We could either do query pushdown, or check the signed range as
      well. I tried the second locally and it has very broad impact - i.e. we
      have a bunch of missing optimizations here.
      
      Second, zext (or i32 %a, 1) to i64 as the increment to the IV in
      expensive_expand_short_tc causes the addrec to no longer be provably
      no-self-wrap. I didn't investigate this so it might be necessary, but
      the loop structure is such that I find this result surprising.
      f5dd70c5
    • dancing-leaves's avatar
      [lldb] Fix MaxSummaryLength target property type (#72233) · ee457102
      dancing-leaves authored
      There seems to be a regression since
      https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3.
      `Max String Summary Length` target property is not read properly and the
      default value (1024) is being used instead.
      
      16.0.6:
      ```
      (lldb) settings set target.max-string-summary-length 16
      (lldb) var
      (std::string) longStdString = "0123456789101112131415161718192021222324252627282930313233343536"
      (const char *) longCharPointer = 0x000055555556f310 "0123456789101112131415161718192021222324252627282930313233343536"
      ```
      
      17.0.4:
      ```
      (lldb) settings set target.max-string-summary-length 16
      (lldb) var
      (std::string) longStdString = "0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377"...
      (const char *) longCharPointer = 0x000055555556f310 "*same as line above*"...
      ```
      
      Comparison fails here:
      
      https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Interpreter/OptionValue.cpp#L256
      
      Due to the type difference:
      
      https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Target/Target.cpp#L4611
      
      https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Target/TargetProperties.td#L98
      ee457102
    • Ivan Butygin's avatar
    • erichkeane's avatar
      [OpenACC] Implement 'use_device' clause parsing · dd5ce457
      erichkeane authored
      'use_device' is effectively identical to the 'copy' parsing in that it
      has required parens and no 'special' name, so this is a pretty trivial
      impementation.  There are a number of other similar situation clauses
      I'll do in a followup patch.
      dd5ce457
    • Joseph Huber's avatar
      [Libomptarget] Fix JIT on the NVPTX target by calling ptx manually (#77801) · 3ede817f
      Joseph Huber authored
      Summary:
      Recently a patch added an assertion in the GlobalHandler to indicate
      when an ELF was not used. This began to fire whenever NVPTX JIT was
      used, because the JIT pass output a PTX file instead of an ELF. The
      CUModuleLoad method consumes `.s` internally and compiles it to a cubin,
      however, this is too late as we perform several checks on the ELF
      directly for the presence of certain symbols and to read some necessary
      constants. This results in inconsistent behaviour.
      
      To address this, this patch simply calls `ptxas` manually, similar to
      how `lld` is called for the AMDGPU JIT pass. This is inevitably going to
      be slower than simply passing it to the CUDA routine due to the overhead
      involved in file IO and a fork call, but it's necessary for correctness.
      
      CUDA provides an API for compiling PTX manually. However, this only
      started showing up in CUDA 11.1 and is only provided "officially" in a
      static library. The `libnvidia-ptxjitcompiler.so` next to the CUDA
      driver has the same symbols and can likely be used as a replacement.
      This would be the faster solution. However, given that it's not
      documented it may have some issues.
      3ede817f
    • Luke Lau's avatar
      [RISCV] Add test for strided gather with recursive disjoint or. NFC · 114e6d7b
      Luke Lau authored
      This already gets converted to a strided intrinsic because we currently call
      haveNoCommonBitsSet when checking or instructions, but an upcoming patch will
      change this logic and we want to preserve this case.
      
      Note that this IR is in the form that comes from instcombine. The splats need
      to be inline constexprs, otherwise isSplatValue() will fail. (It can't
      currently handle splats where the shufflevector is an instruction, and the
      insertelement is a constexpr.
      114e6d7b