1. Dec 13, 2023
    • paperchalice's avatar
      [CodeGen] Add analyses to help for porting GC passes (#74972) · 06aa8b18
      paperchalice authored
      - `CollectorMetadataAnalysis` provides `GCStrategyMap`.
      - `GCFunctionAnalysis` provides `GCFunctionInfo`.
      
      `GCStrategyMap` owns `GCStrategy` pointers and this
      pass is used by `AsmPrinter` to iterate all GC strategies.
      
      Most passes that require `GCModuleInfo` actually require the
      `GCFunctionInfo`,
      so add `GCFunctionAnalysis` for convenience.
      06aa8b18
    • Mariya Podchishchaeva's avatar
      [clang] Substitute alias templates from correct context (#75069) · dbf67ea1
      Mariya Podchishchaeva authored
      Current context set to where alias was met, not where it is declared
      caused incorrect access check in case alias referenced private members
      of the parent class.
      This is a recommit of 6b1aa319 with a slight modification in order to fix
      reported regression.
      
      Fixes https://github.com/llvm/llvm-project/issues/41693
      dbf67ea1
    • Pierre van Houtryve's avatar
      [GlobalISel] Change MatchTable entries to 1 byte each (#74429) · a110e991
      Pierre van Houtryve authored
      See
      https://discourse.llvm.org/t/rfc-make-globalisel-match-table-entries-1-byte-instead-of-8/75411
      
      This helps reduce llc's binary size, at the cost of some added
      complexity to the MatchTable machinery.
      a110e991
    • Mariya Podchishchaeva's avatar
      [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (#70829) · a01307a6
      Mariya Podchishchaeva authored
      Normally warning is not reported when a field has default initializer.
      Do so for anonymous unions with default initializers as well. No release
      note since it is a regression in clang 18.
      
      Fixes https://github.com/llvm/llvm-project/issues/70384
      a01307a6
    • David Green's avatar
      b003fed2
    • Vitaly Buka's avatar
      [test][hwasan] Add `__hwasan_enable_allocator_tagging` · 912506b7
      Vitaly Buka authored
      It's required for hwasan `aliasing` mode.
      912506b7
    • Yeting Kuo's avatar
      [RISCV] Bump zicfilp to 0.4 (#75134) · 6095e211
      Yeting Kuo authored
      Bump to https://github.com/riscv/riscv-cfi/releases/tag/v0.4.0. Actually
      there is no functional change here.
      6095e211
    • Vitaly Buka's avatar
      [test][sanitizer] Convert test from C++ to C · 0efc1674
      Vitaly Buka authored
      This avoids internal libstdc++ leaks.
      0efc1674
    • Fangrui Song's avatar
      [ELF,test] Improve PROVIDE tests · 215c5656
      Fangrui Song authored
      215c5656
    • Vitaly Buka's avatar
      41d19fbe
    • Sizov Nikita's avatar
      [InstCombine] Fold `binop (select cond, a, b), (select cond, b, a)` to `binop a, b` (#74953) · 88cc35b2
      Sizov Nikita authored
      ```
      CommutativeBinOp(select(V, A, B), select(V, B, A) --> CommutativeBinOp(A, B)
      CommutativeIntrinsicCall(select(V, A, B), select(V, B, A), ...) --> CommutativeIntrinsicCall(A, B, ...)
      ```
      
      https://alive2.llvm.org/ce/z/8CDUZ4
      
      Closes #73904
      88cc35b2
    • Eric's avatar
      Add libc++ main builder status badge (#75283) · f68435ff
      Eric authored
      Also add links to github actions workflow.
      f68435ff
    • serge-sans-paille's avatar
      Disable PGO instrumentation on naked function (#75224) · 4b5224a2
      serge-sans-paille authored
      We only allow for assembly code in naked function, and PGO
      instrumentation (esp. temporal instrumentation that introduces a
      function call) can wreak havoc in this.
      
      Fix #74573
      4b5224a2
    • Vitaly Buka's avatar
      [test][sanitizer] Remove unnececary `printf` and `gettid` · 3bedc93d
      Vitaly Buka authored
      Fixes sanitizer-ppc64le-linux bot.
      3bedc93d
    • Yingchi Long's avatar
      [BPF] improve error handling by custom lowering & fail() (#75088) · ddf85b92
      Yingchi Long authored
      Currently on mcpu=v3 we do not support sdiv, srem instructions. And the
      backend crashes with stacktrace & coredump, which is misleading for end
      users, as this is not a "bug"
      
      Add llvm bug reporting for sdiv/srem on ISel legalize-op phase.
      
      For clang frontend we can get detailed location & bug report.
      
          $ build/bin/clang -g -target bpf -c local/sdiv.c
      local/sdiv.c:1:35: error: unsupported signed division, please convert to
      unsigned div/mod.
              1 | int sdiv(int a, int b) { return a / b; }
                |                                   ^
          1 error generated.
      
      Fixes: #70433
      Fixes: #48647
      
      This also improves error handling for dynamic stack allocation:
      
          local/vla.c:2:3: error: unsupported dynamic stack allocation
              2 |   int b[n];
                |   ^
          1 error generated.
      
      Fixes: https://github.com/llvm/llvm-project/issues/57171
      ddf85b92
    • Matheus Izvekov's avatar
      Revert "[coroutines] Use DILocation from new storage for hoisted dbg.declare" (#75282) · 2fb060ef
      Matheus Izvekov authored
      Reverts llvm/llvm-project#75104
      
      Original commit causes clang to generate invalid IR:
      ```
      mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
        call void @llvm.dbg.declare(metadata ptr %4, metadata !34468, metadata !DIExpression(DW_OP_plus_uconst, 176)), !dbg !34467
      ```
      2fb060ef
    • Tacet's avatar
      [ASan][libc++] std::basic_string annotations (#72677) · 9ed20568
      Tacet authored
      This commit introduces basic annotations for `std::basic_string`,
      mirroring the approach used in `std::vector` and `std::deque`.
      Initially, only long strings with the default allocator will be
      annotated. Short strings (_SSO - short string optimization_) and strings
      with non-default allocators will be annotated in the near future, with
      separate commits dedicated to enabling them. The process will be similar
      to the workflow employed for enabling annotations in `std::deque`.
      
      **Please note**: these annotations function effectively only when libc++
      and libc++abi dylibs are instrumented (with ASan). This aligns with the
      prevailing behavior of Memory Sanitizer.
      
      To avoid breaking everything, this commit also appends
      `_LIBCPP_INSTRUMENTED_WITH_ASAN` to `__config_site` whenever libc++ is
      compiled with ASan. If this macro is not defined, string annotations are
      not enabled. However, linking a binary that does **not** annotate
      strings with a dynamic library that annotates strings, is not permitted.
      
      Originally proposed here: https://reviews.llvm.org/D132769
      
      Related patches on Phabricator:
      - Turning on annotations for short strings:
      https://reviews.llvm.org/D147680
      - Turning on annotations for all allocators:
      https://reviews.llvm.org/D146214
      
      This PR is a part of a series of patches extending AddressSanitizer C++
      container overflow detection capabilities by adding annotations, similar
      to those existing in `std::vector` and `std::deque` collections. These
      enhancements empower ASan to effectively detect instances where the
      instrumented program attempts to access memory within a collection's
      internal allocation that remains unused. This includes cases where
      access occurs before or after the stored elements in `std::deque`, or
      between the `std::basic_string`'s size (including the null terminator)
      and capacity bounds.
      
      The introduction of these annotations was spurred by a real-world
      software bug discovered by Trail of Bits, involving an out-of-bounds
      memory access during the comparison of two strings using the
      `std::equals` function. This function was taking iterators
      (`iter1_begin`, `iter1_end`, `iter2_begin`) to perform the comparison,
      using a custom comparison function. When the `iter1` object exceeded the
      length of `iter2`, an out-of-bounds read could occur on the `iter2`
      object. Container sanitization, upon enabling these annotations, would
      effectively identify and flag this potential vulnerability.
      
      This Pull Request introduces basic annotations for `std::basic_string`.
      Long strings exhibit structural similarities to `std::vector` and will
      be annotated accordingly. Short strings are already implemented, but
      will be turned on separately in a forthcoming commit. Look at [a
      comment](https://github.com/llvm/llvm-project/pull/72677#issuecomment-1850554465)
      below to read about SSO issues at current moment.
      
      Due to the functionality introduced in
      [D132522](https://github.com/llvm/llvm-project/commit/dd1b7b797a116eed588fd752fbe61d34deeb24e4),
      the `__sanitizer_annotate_contiguous_container` function now offers
      compatibility with all allocators. However, enabling this support will
      be done in a subsequent commit. For the time being, only strings with
      the default allocator will be annotated.
      
      If you have any questions, please email:
      - advenam.tacet@trailofbits.com
      - disconnect3d@trailofbits.com
      9ed20568
    • Vitaly Buka's avatar
      [NFC][lsan] clang-format includes · e1e5f354
      Vitaly Buka authored
      e1e5f354
    • Matheus Izvekov's avatar
    • paperchalice's avatar
    • Vitaly Buka's avatar
      [test][sanitizer] Allow fork_threaded test on Msan, Tsan, Ubsan (#75260) · 18b41576
      Vitaly Buka authored
      They already include workarounds.
      18b41576
    • Matt Arsenault's avatar
      llvm-reduce: Handle disjoint flag · b2c7cac3
      Matt Arsenault authored
      b2c7cac3
    • Matt Arsenault's avatar
      llvm-reduce: Handle nneg flag · 82d75023
      Matt Arsenault authored
      82d75023
    • Cyndy Ishida's avatar
      Revert "[TextAPI] Add missing link to libObject" and "[TextAPI] Add DylibReader (#75006)" · 1fef0fac
      Cyndy Ishida authored
      This reverts commit aa217eb0.
      This reverts commit 634feddc.
      
      This breaks buildbots by introducing cycle dependency between libObject
      and TextAPI and breaks gcc compiles on buildbots.
      1fef0fac
    • Vitaly Buka's avatar
      6d8fe3dc
    • Cyndy Ishida's avatar
      [TextAPI] Add missing link to libObject · aa217eb0
      Cyndy Ishida authored
      * Reported in buildbot failures
      aa217eb0
    • Cyndy Ishida's avatar
      [TextAPI] Add DylibReader (#75006) · 634feddc
      Cyndy Ishida authored
      Add support for reading binary Mach-o dynamic libraries. It uses
      libObject APIs for extracting information relavant to TAPI and tbd
      files. This includes but is not limited to load commands encode data
      like install names, current/compat versions and symbols.
      634feddc
    • Nico Weber's avatar
      [gn] port 27259f17 · 53ecd3a2
      Nico Weber authored
      53ecd3a2
    • Craig Topper's avatar
      [RISCV] Reduce the size of the index used for RVV intrinsics. NFC (#74906) · 0523bf1e
      Craig Topper authored
      Rather than using size_t, use uint32_t. We don't have more than 4
      billion intrinsics.
      0523bf1e
    • Greg Clayton's avatar
      [lldb] Make only one function that needs to be implemented when searching for types (#74786) · dd958779
      Greg Clayton authored
      This patch revives the effort to get this Phabricator patch into
      upstream:
      
      https://reviews.llvm.org/D137900
      
      This patch was accepted before in Phabricator but I found some
      -gsimple-template-names issues that are fixed in this patch.
      
      A fixed up version of the description from the original patch starts
      now.
      
      This patch started off trying to fix Module::FindFirstType() as it
      sometimes didn't work. The issue was the SymbolFile plug-ins didn't do
      any filtering of the matching types they produced, and they only looked
      up types using the type basename. This means if you have two types with
      the same basename, your type lookup can fail when only looking up a
      single type. We would ask the Module::FindFirstType to lookup "Foo::Bar"
      and it would ask the symbol file to find only 1 type matching the
      basename "Bar", and then we would filter out any matches that didn't
      match "Foo::Bar". So if the SymbolFile found "Foo::Bar" first, then it
      would work, but if it found "Baz::Bar" first, it would return only that
      type and it would be filtered out.
      
      Discovering this issue lead me to think of the patch Alex Langford did a
      few months ago that was done for finding functions, where he allowed
      SymbolFile objects to make sure something fully matched before parsing
      the debug information into an AST type and other LLDB types. So this
      patch aimed to allow type lookups to also be much more efficient.
      
      As LLDB has been developed over the years, we added more ways to to type
      lookups. These functions have lots of arguments. This patch aims to make
      one API that needs to be implemented that serves all previous lookups:
      
      - Find a single type
      - Find all types
      - Find types in a namespace
      
      This patch introduces a `TypeQuery` class that contains all of the state
      needed to perform the lookup which is powerful enough to perform all of
      the type searches that used to be in our API. It contain a vector of
      CompilerContext objects that can fully or partially specify the lookup
      that needs to take place.
      
      If you just want to lookup all types with a matching basename,
      regardless of the containing context, you can specify just a single
      CompilerContext entry that has a name and a CompilerContextKind mask of
      CompilerContextKind::AnyType.
      
      Or you can fully specify the exact context to use when doing lookups
      like: CompilerContextKind::Namespace "std"
      CompilerContextKind::Class "foo"
      CompilerContextKind::Typedef "size_type"
      
      This change expands on the clang modules code that already used a
      vector<CompilerContext> items, but it modifies it to work with
      expression type lookups which have contexts, or user lookups where users
      query for types. The clang modules type lookup is still an option that
      can be enabled on the `TypeQuery` objects.
      
      This mirrors the most recent addition of type lookups that took a
      vector<CompilerContext> that allowed lookups to happen for the
      expression parser in certain places.
      
      Prior to this we had the following APIs in Module:
      
      ```
      void
      Module::FindTypes(ConstString type_name, bool exact_match, size_t max_matches,
                        llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
                        TypeList &types);
      
      void
      Module::FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
                        llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
                        TypeMap &types);
      
      void Module::FindTypesInNamespace(ConstString type_name,
                                        const CompilerDeclContext &parent_decl_ctx,
                                        size_t max_matches, TypeList &type_list);
      ```
      
      The new Module API is much simpler. It gets rid of all three above
      functions and replaces them with:
      
      ```
      void FindTypes(const TypeQuery &query, TypeResults &results);
      ```
      The `TypeQuery` class contains all of the needed settings:
      
      - The vector<CompilerContext> that allow efficient lookups in the symbol
      file classes since they can look at basename matches only realize fully
      matching types. Before this any basename that matched was fully realized
      only to be removed later by code outside of the SymbolFile layer which
      could cause many types to be realized when they didn't need to.
      - If the lookup is exact or not. If not exact, then the compiler context
      must match the bottom most items that match the compiler context,
      otherwise it must match exactly
      - If the compiler context match is for clang modules or not. Clang
      modules matches include a Module compiler context kind that allows types
      to be matched only from certain modules and these matches are not needed
      when d oing user type lookups.
      - An optional list of languages to use to limit the search to only
      certain languages
      
      The `TypeResults` object contains all state required to do the lookup
      and store the results:
      - The max number of matches
      - The set of SymbolFile objects that have already been searched
      - The matching type list for any matches that are found
      
      The benefits of this approach are:
      - Simpler API, and only one API to implement in SymbolFile classes
      - Replaces the FindTypesInNamespace that used a CompilerDeclContext as a
      way to limit the search, but this only worked if the TypeSystem matched
      the current symbol file's type system, so you couldn't use it to lookup
      a type in another module
      - Fixes a serious bug in our FindFirstType functions where if we were
      searching for "foo::bar", and we found a "baz::bar" first, the basename
      would match and we would only fetch 1 type using the basename, only to
      drop it from the matching list and returning no results
      dd958779
    • paperchalice's avatar
      [CodeGen] Port `CFGuard` to new pass manager (#75146) · 27259f17
      paperchalice authored
      Port `CFGuard` to new pass manager, add a pass parameter to choose guard
      mechanism.
      27259f17
    • Arthur Eubanks's avatar
      Revert "[X86] Set SHF_X86_64_LARGE for globals with explicit well-known large... · 19fff858
      Arthur Eubanks authored
      Revert "[X86] Set SHF_X86_64_LARGE for globals with explicit well-known large section name (#74381)"
      
      This reverts commit 323451ab.
      
      Code with these section names in the wild doesn't compile because
      support for large globals in the small code model is not complete yet.
      19fff858
    • Aart Bik's avatar
      [mlir][sparse] refactor utilities into transform/utils dir (#75250) · 365777ec
      Aart Bik authored
      Separates actual transformation files from supporting utility files in
      the transforms directory. Includes a bazel overlay fix for the build (as
      well as a bit of cleanup of that file to be less verbose and more
      flexible).
      365777ec
    • Stella Laurenzo's avatar
      Add missing dep on MLIRToLLVMIRTranslationRegistration to mlir-opt. (#75111) · 8eff5704
      Stella Laurenzo authored
      I was not able to fully triage why this just started failing on one of
      our bots as it seems that the use was added 4 months ago. I would assume
      that it was accidentally coming in transitively in some way as the dep
      was definitely missing.
      
      For context, this started failing in [our
      byo_llvm](https://github.com/openxla/iree/blob/main/build_tools/llvm/byo_llvm.sh)
      build on a stock build of MLIR on top of an existing LLVM. We were
      getting:
      
      ```
      ld.lld: error: undefined symbol: mlir::registerSPIRVDialectTranslation(mlir::DialectRegistry&)                                                        >>> referenced by mlir-opt.cpp
      >>>               tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o:(main)
      ```
      8eff5704
    • Vitaly Buka's avatar
      [asan] Switch initialization to "double-checked locking" · 9567b33f
      Vitaly Buka authored
      This allows to remove `asan_init_is_running` which likely had a data
      race.
      
      Simplifies https://github.com/llvm/llvm-project/pull/74086 and reduces a difference between platforms.
      
      Reviewers: zacklj89, eugenis, dvyukov
      
      Reviewed By: zacklj89, dvyukov
      
      Pull Request: https://github.com/llvm/llvm-project/pull/74387
      9567b33f
    • Craig Topper's avatar
      8227072f
    • michaelrj-google's avatar
      [libc] Add bind function (#74014) · 8180ea86
      michaelrj-google authored
      This patch adds the bind function to go with the socket function. It
      also cleans up a lot of socket related data structures.
      8180ea86
    • Fangrui Song's avatar
      [bazel] Port 4b344677 · cd9a6416
      Fangrui Song authored
      cd9a6416
    • Sam Clegg's avatar
      [lld][WebAssembly] Don't set importUndefined when -shared is used. NFC (#75241) · 97b25d91
      Sam Clegg authored
      `importUndefined` is only used a couple of places and both of those
      already handle `isPIC` separately.
      97b25d91
    • Mark de Wever's avatar
      [libc++][module] Fixes std::string UDL. (#75000) · 7d34f8c0
      Mark de Wever authored
      The fix changes the way the validation script determines the qualified
      name of a declaration. Inline namespaces without a reserved name are now
      always part of the name. The Clang code only does this when the names
      are ambigious. This method is often used for the operator""foo for UDLs.
      
      Adjusted the newly flagged issue and removed a work-around in the test
      code that is no longer required.
      
      Fixes https://github.com/llvm/llvm-project/issues/72427
      7d34f8c0