1. Oct 27, 2023
  2. Oct 25, 2023
  3. Oct 24, 2023
  4. Oct 23, 2023
  5. Oct 17, 2023
    • Fangrui Song's avatar
      [asan] Ensure __asan_register_elf_globals is called in COMDAT asan.module_ctor (#67745) · 888437e1
      Fangrui Song authored
      On ELF platforms, when there is no global variable and the unique module ID is
      non-empty, COMDAT asan.module_ctor is created with no
      `__asan_register_elf_globals` calls. If this COMDAT is the prevailing copy
      selected by the linker, the linkage unit will have no
      `__asan_register_elf_globals` call: the redzone will not be poisoned and ODR
      violation checker will not work (#67677).
      
      This behavior is benign for -fno-sanitize-address-globals-dead-stripping because
      asan.module_ctor functions that call `__asan_register_globals`
      (`InstrumentGlobalsWithMetadataArray`) do not use COMDAT.
      
      To fix #67677:
      
      * Use COMDAT for -fsanitize-address-globals-dead-stripping on ELF platforms.
      * Call `__asan_register_elf_globals` even if there is no global variable.
      * If the unique module ID is empty, don't call SetComdatForGlobalMetadata:
        placing `@.str` in a COMDAT would incorrectly discard internal COMDAT `@.str`
        in other compile units.
      
      Alternatively, when there is no global variable, asan.module_ctor is not COMDAT
      and does not call `__asan_register_elf_globals`. However, the asan.module_ctor
      function cannot be eliminated by the linker.
      
      Tested the following script. Only ELF -fsanitize-address-globals-dead-stripping has changed behaviors.
      ```
      echo > a.cc  # no global variable, empty uniqueModuleId
      echo 'void f() {}' > b.cc  # with global variable, with uniqueModuleId
      echo 'int g;' > c.cc  # with global variable
      for t in x86_64-linux-gnu arm64-apple-macosx x86_64-windows-msvc; do
        for gc in -f{,no-}sanitize-address-globals-dead-stripping; do
          for f in a.cc b.cc c.cc; do
            echo /tmp/Rel/bin/clang -S --target=$t -fsanitize=address $gc $f -o -
            /tmp/Rel/bin/clang -S --target=$t -fsanitize=address $gc $f -o - | sed -n '/asan.module_ctor/,/ret/p'
          done
        done
      done
      ```
      
      ---
      
      Identical to commit 16eed8c9.
      6420d330 is an incorrect revert for genuine
      purely internal issues.
      888437e1
    • Owen Pan's avatar
      [clang-format][doc] Update the Linux kernel coding style URL · 2e00f4ca
      Owen Pan authored
      (cherry picked from commit 8902f12e)
      2e00f4ca
    • Owen Pan's avatar
      [clang-format] Fix a serious bug in git-clang-format (#65723) · aeb83c37
      Owen Pan authored
      When applying format changes to staged files, git-clang-format
      erroneously checks out all files in the index and thus may overwrite
      unstaged changes.
      
      Fixes #65643.
      
      (cherry picked from commit 743659be)
      aeb83c37
    • Artem Dergachev's avatar
      [LSan] Mark create_thread_leak.cpp as UNSUPPORTED: darwin. · 268faa37
      Artem Dergachev authored
      It started to fail in a flaky manner a few days ago on GreenDragon buildbots
      (i.e. x86_64-darwin). I didn't track down the root cause but LSan isn't
      actually supported on darwin anyway, so UNSUPPORTED seems appropriate.
      
      Prior art: 3ff080b5.
      
      (cherry picked from commit 0a3519d5)
      268faa37
    • Nikita Popov's avatar
      [PowerPC] Use zext instead of anyext in custom and combine (#68784) · 491a91e8
      Nikita Popov authored
      This custom combine currently converts `and(anyext(x),c)` into
      `anyext(and(x,c))`. This is not correct, because the original expression
      guaranteed that the high bits are zero, while the new one sets them to
      undef.
      
      Emit `zext(and(x,c))` instead.
      
      Fixes https://github.com/llvm/llvm-project/issues/68783.
      
      (cherry picked from commit 127ed9ae)
      491a91e8
    • Nikita Popov's avatar
      [PowerPC] Add test for #68783 (NFC) · 8ce6b65c
      Nikita Popov authored
      (cherry picked from commit 0ead1fae)
      8ce6b65c
  6. Oct 16, 2023
    • Owen Pan's avatar
      [clang-format] Fix a bug in RemoveParentheses: ReturnStatement (#67911) · 7a23a5d4
      Owen Pan authored
      Don't remove the outermost parentheses surrounding a return statement
      expression when inside a function/lambda that has the decltype(auto)
      return type.
      
      Fixed #67892.
      
      (cherry picked from commit 75441a68)
      7a23a5d4
    • Noah Goldstein's avatar
      [X86] Fix logic for optimizing movmsk(bitcast(shuffle(x))); PR67287 · be4016e5
      Noah Goldstein authored
      Prior logic would remove the shuffle iff all of the elements in `x`
      where used. This is incorrect.
      
      The issue is `movmsk` only cares about the highbits, so if the width
      of the elements in `x` is smaller than the width of the elements
      for the `movmsk`, then the shuffle, even if it preserves all the elements,
      may change which ones are used by the highbits.
      
      For example:
      `movmsk64(bitcast(shuffle32(x, (1,0,3,2))))`
      
      Even though the shuffle mask `(1,0,3,2)` preserves all the elements, it
      flips which will be relevant to the `movmsk64` (x[1] and x[3]
      before and x[0] and x[2] after).
      
      The fix here, is to ensure that the shuffle mask can be scaled to the
      element width of the `movmsk` instruction. This ensure that the
      "high" elements stay "high". This is overly conservative as it
      misses cases like `(1,1,3,3)` where the "high" elements stay
      intact despite not be scalable, but for an relatively edge-case
      optimization that should generally be handled during
      simplifyDemandedBits, it seems okay.
      
      (cherry picked from commit 1684c65b)
      be4016e5
    • Noah Goldstein's avatar
      496b1740
    • Martin Storsjö's avatar
      [clang] [MinGW] Explicitly always pass the -fno-use-init-array (#68571) · f50c6382
      Martin Storsjö authored
      On MinGW targets, the .ctors section is always used for constructors.
      
      When using the .ctors section, the constructors need to be emitted in
      reverse order to get them execute in the right order. (Constructors with
      a specific priority are sorted separately by the linker later.) In LLVM,
      in CodeGen/AsmPrinter/AsmPrinter.cpp, there's code that reverses them
      before writing them out, executed when using the .ctors section. This
      logic is done whenever TM.Options.UseInitArray is set to false. Thus,
      make sure to set UseInitArray to false for this target.
      
      This fixes https://github.com/llvm/llvm-project/issues/55938.
      
      (cherry picked from commit a2b8c49c)
      f50c6382
    • DianQK's avatar
      [LVI][CVP] Treat undef like a full range (#68190) · d10b731a
      DianQK authored
      When converting to ConstantRange, we should treat undef like a full range.
      Fixes #68381.
      
      (cherry picked from commit 81857940)
      d10b731a
  7. Oct 10, 2023
    • Simon Pilgrim's avatar
      [X86] combineConcatVectorOps - only concatenate single-use subops · 37b79e77
      Simon Pilgrim authored
      We could maybe extend this by allowing the lowest subop to have multiple uses and extract the lowest subvector result of the concatenated op, but let's just get the fix in first.
      
      Fixes #67333
      37b79e77
    • Tobias Hieta's avatar
      Bump version to 17.0.3 · 5a13ce2d
      Tobias Hieta authored
      5a13ce2d
    • Arvind Mukund's avatar
      [clang] Correct behavior of `LLVM_UNREACHABLE_OPTIMIZE=OFF` for `Release` builds (#68284) · e7b3b94c
      Arvind Mukund authored
      ```c++
      AArch64SVEPcsAttr *AArch64SVEPcsAttr::CreateImplicit(ASTContext &Ctx, SourceRange Range, Spelling S) {
        AttributeCommonInfo I(Range, NoSemaHandlerAttribute, (
          S == GNU_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, GNU_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
          S == CXX11_clang_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_CXX11, CXX11_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
          S == C23_clang_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_C23, C23_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
          (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
        return CreateImplicit(Ctx, I);
      }
      ```
      
      ```c++
      AArch64SVEPcsAttr *AArch64SVEPcsAttr::CreateImplicit(ASTContext &Ctx, SourceRange Range, Spelling S) {
        AttributeCommonInfo I(Range, NoSemaHandlerAttribute, [&]() {
          switch (S) {
          case GNU_aarch64_sve_pcs:
            return AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, GNU_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
          case CXX11_clang_aarch64_sve_pcs:
            return AttributeCommonInfo::Form{AttributeCommonInfo::AS_CXX11, CXX11_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
          case C23_clang_aarch64_sve_pcs:
            return AttributeCommonInfo::Form{AttributeCommonInfo::AS_C23, C23_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
          default:
            llvm_unreachable("Unknown attribute spelling!");
            return AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
          }
        }());
        return CreateImplicit(Ctx, I);
      }
      ```
      
      Fixes https://github.com/llvm/llvm-project/issues/68237
      Conflicts:
      	clang/docs/ReleaseNotes.rst
      e7b3b94c
    • Martin Storsjö's avatar
      [LLD] [COFF] Fix handling of comdat .drectve sections (#68116) · f0a687d8
      Martin Storsjö authored
      This can happen when manually emitting strings into .drectve sections
      with `__attribute__((section(".drectve")))`, which is a way to emulate
      `#pragma comment(linker, "...")` for mingw compilers, without requiring
      building with -fms-extensions.
      
      Normally, this doesn't generate any comdat, but if compiled with
      -fsanitize=address, this section does get turned into a comdat section.
      
      This fixes #67261. This issue can be seen as a regression; a change in
      the "lli" tool in 17.x triggers this case, if compiled with ASAN
      enabled, triggering this unsupported corner case in LLD. With this
      change, LLD can handle it.
      
      (cherry picked from commit 503bc5f6)
      f0a687d8
    • Tom Stellard's avatar
      workflows/release-binaries: Use more cores to avoid the 6 hour timeout (#67874) · 8a8ade49
      Tom Stellard authored
      (cherry picked from commit 95b2c6b3)
      8a8ade49
    • Martin Storsjö's avatar
      [AArch64] Disable loop alignment for Windows targets (#67894) · 1090b91a
      Martin Storsjö authored
      This should fix #66912. When emitting SEH unwind info, we need to be
      able to calculate the exact length of functions before alignments are
      fixed. Until that limitation is overcome, just disable all loop
      alignment on Windows targets.
      
      (cherry picked from commit 6ae36c01)
      1090b91a
    • Shoaib Meenai's avatar
      [Sema] Use underlying type of scoped enum for -Wformat diagnostics (#67378) · 69c8c966
      Shoaib Meenai authored
      Right now, `-Wformat` for a scoped enum will suggest a cast based on the
      format specifier being used. This can lead to incorrect results, e.g.
      attempting to format a scoped enum with `%s` would suggest casting to
      `char *` instead of fixing the specifier. Change the logic to treat the
      scoped enum's underlying type as the intended type to be printed, and
      suggest format specifier changes and casts based on that.
      
      (cherry picked from commit 0b07b06e)
      69c8c966
  8. Oct 03, 2023
  9. Sep 29, 2023