diff --git a/.github/workflows/hlsl-test-all.yaml b/.github/workflows/hlsl-test-all.yaml index b6530fe11b840..d8055c4642113 100644 --- a/.github/workflows/hlsl-test-all.yaml +++ b/.github/workflows/hlsl-test-all.yaml @@ -52,11 +52,6 @@ jobs: repository: llvm/offload-golden-images ref: main path: golden-images - - name: Setup Windows - if: runner.os == 'Windows' - uses: llvm/actions/setup-windows@main - with: - arch: amd64 - name: Build DXC run: | cd DXC diff --git a/.github/workflows/libclang-abi-tests.yml b/.github/workflows/libclang-abi-tests.yml index b92b61de05088..0d3f9fe3f69ea 100644 --- a/.github/workflows/libclang-abi-tests.yml +++ b/.github/workflows/libclang-abi-tests.yml @@ -101,8 +101,6 @@ jobs: ref: ${{ github.sha }} repo: ${{ github.repository }} steps: - - name: Install Ninja - uses: llvm/actions/install-ninja@42d80571b13f4599bbefbc7189728b64723c7f78 # main - name: Download source code uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index d40ed5babb459..b68e9493ce9c7 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -37,9 +37,7 @@ on: os_list: required: false type: string - # Use windows-2019 due to: - # https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317 - default: '["ubuntu-24.04", "windows-2019", "macOS-13"]' + default: '["ubuntu-24.04"]' python_version: required: false @@ -67,11 +65,6 @@ jobs: matrix: os: ${{ fromJSON(inputs.os_list) }} steps: - - name: Setup Windows - if: startsWith(matrix.os, 'windows') - uses: llvm/actions/setup-windows@main - with: - arch: amd64 # On Windows, starting with win19/20220814.1, cmake choose the 32-bit # python3.10.6 libraries instead of the 64-bit libraries when building # lldb. Using this setup-python action to make 3.10 the default @@ -80,9 +73,6 @@ jobs: uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 with: python-version: ${{ inputs.python_version }} - - name: Install Ninja - if: runner.os != 'Linux' - uses: llvm/actions/install-ninja@main # actions/checkout deletes any existing files in the new git directory, # so this needs to either run before ccache-action or it has to use # clean: false. diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml index 8594e1e91ee99..f2ac8e5ee5865 100644 --- a/.github/workflows/premerge.yaml +++ b/.github/workflows/premerge.yaml @@ -146,7 +146,8 @@ jobs: with: max-size: "2000M" - name: Install Ninja - uses: llvm/actions/install-ninja@main + run: | + brew install ninja - name: Build and Test run: | source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py) diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 765cd06469977..35496e8c63fe5 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -199,15 +199,6 @@ jobs: with: ref: ${{ needs.prepare.outputs.ref }} - - name: Install Ninja - uses: llvm/actions/install-ninja@a1ea791b03c8e61f53a0e66f2f73db283aa0f01e # main - - - name: Setup Windows - if: startsWith(runner.os, 'Windows') - uses: llvm/actions/setup-windows@main - with: - arch: amd64 - - name: Set Build Prefix id: setup-stage shell: bash diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index 7c0eb9651feaa..c6afd0bc07cbd 100644 --- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -833,6 +833,10 @@ bool OverlayCDB::setCompileCommand(PathRef File, std::unique_ptr OverlayCDB::getProjectModules(PathRef File) const { auto MDB = DelegatingCDB::getProjectModules(File); + if (!MDB) { + log("Failed to get compilation Database for {0}", File); + return {}; + } MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command, PathRef CommandPath) { Mangler(Command, CommandPath); diff --git a/clang-tools-extra/clangd/test/modules_no_cdb.test b/clang-tools-extra/clangd/test/modules_no_cdb.test new file mode 100644 index 0000000000000..8f92be2c7b3f3 --- /dev/null +++ b/clang-tools-extra/clangd/test/modules_no_cdb.test @@ -0,0 +1,66 @@ +# A smoke test to check that clangd works without compilation database +# +# Windows have different escaping modes. +# FIXME: We should add one for windows. +# UNSUPPORTED: system-windows +# +# RUN: rm -fr %t +# RUN: mkdir -p %t +# RUN: split-file %s %t +# +# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc +# +# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \ +# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc + +#--- A.h +void printA(); + +#--- Use.cpp +#include "A.h" +void foo() { + print +} + +#--- definition.jsonrpc.tmpl +{ + "jsonrpc": "2.0", + "id": 0, + "method": "initialize", + "params": { + "processId": 123, + "rootPath": "clangd", + "capabilities": { + "textDocument": { + "completion": { + "completionItem": { + "snippetSupport": true + } + } + } + }, + "trace": "off" + } +} +--- +{ + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file://DIR/Use.cpp", + "languageId": "cpp", + "version": 1, + "text": "#include \"A.h\"\nvoid foo() {\n print\n}\n" + } + } +} + +# CHECK: "message"{{.*}}printA{{.*}}(fix available) + +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}} +--- +{"jsonrpc":"2.0","id":2,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index 441a37a4902b7..cc59dbd13621d 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -182,8 +182,11 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight( // We only need to think about streams that begin with a qualifier. if (Tok->isNot(QualifierType)) return Tok; + + const auto *Next = Tok->getNextNonComment(); + // Don't concern yourself if nothing follows the qualifier. - if (!Tok->Next) + if (!Next) return Tok; // Skip qualifiers to the left to find what preceeds the qualifiers. @@ -247,9 +250,15 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight( }(); // Find the last qualifier to the right. - const FormatToken *LastQual = Tok; - while (isQualifier(LastQual->getNextNonComment())) - LastQual = LastQual->getNextNonComment(); + const auto *LastQual = Tok; + for (; isQualifier(Next); Next = Next->getNextNonComment()) + LastQual = Next; + + if (!LastQual || !Next || + (LastQual->isOneOf(tok::kw_const, tok::kw_volatile) && + Next->isOneOf(Keywords.kw_override, Keywords.kw_final))) { + return Tok; + } // If this qualifier is to the right of a type or pointer do a partial sort // and return. diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 934605733542f..3df071a197c67 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2385,17 +2385,17 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { const FormatToken *LeftSquare = FormatTok; nextToken(); if (Previous) { + const auto *PrevPrev = Previous->getPreviousNonComment(); + if (Previous->is(tok::star) && PrevPrev && PrevPrev->isTypeName(LangOpts)) + return false; if (Previous->closesScope()) { // Not a potential C-style cast. if (Previous->isNot(tok::r_paren)) return false; - const auto *BeforeRParen = Previous->getPreviousNonComment(); // Lambdas can be cast to function types only, e.g. `std::function` // and `int (*)()`. - if (!BeforeRParen || !BeforeRParen->isOneOf(tok::greater, tok::r_paren)) + if (!PrevPrev || !PrevPrev->isOneOf(tok::greater, tok::r_paren)) return false; - } else if (Previous->is(tok::star)) { - Previous = Previous->getPreviousNonComment(); } if (Previous && Previous->Tok.getIdentifierInfo() && !Previous->isOneOf(tok::kw_return, tok::kw_co_await, tok::kw_co_yield, diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index cc3cc0f6906cc..ecc696c539226 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -1295,7 +1295,10 @@ void WhitespaceManager::alignArrayInitializers() { bool FoundComplete = false; for (unsigned InsideIndex = ChangeIndex + 1; InsideIndex < ChangeEnd; ++InsideIndex) { - if (Changes[InsideIndex].Tok == C.Tok->MatchingParen) { + const auto *Tok = Changes[InsideIndex].Tok; + if (Tok->is(tok::pp_define)) + break; + if (Tok == C.Tok->MatchingParen) { alignArrayInitializers(ChangeIndex, InsideIndex + 1); ChangeIndex = InsideIndex + 1; FoundComplete = true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 8db0500573ec0..760c5a4ce4195 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -22429,6 +22429,19 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) { "});", Style); + verifyNoCrash( + "PANEL_Ic PANEL_ic[PANEL_IC_NUMBER] =\n" + " {\n" + " {PIC(0), PIC(0), PIC(99), PIC(81), 0}, // Backbox\n" + " {PIC(1), PIC(83), PIC(191), PIC(137), 0}, // AK47\n" + "\n" + "#define PICALL1(a, b, c, d) \\\n" + " { PIC(a), PIC(b), PIC(c), PIC(d), 1 }\n" + "\n" + " PICALL1(1, 1, 75, 50),\n" + "};", + Style); + Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; verifyFormat("#define FOO \\\n" " int foo[][2] = { \\\n" diff --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp index f42f2e307f713..55bdda32453ba 100644 --- a/clang/unittests/Format/QualifierFixerTest.cpp +++ b/clang/unittests/Format/QualifierFixerTest.cpp @@ -215,6 +215,8 @@ TEST_F(QualifierFixerTest, RightQualifier) { Style); verifyFormat("void foo() const override;", Style); verifyFormat("void foo() const override LLVM_READONLY;", Style); + verifyFormat("MOCK_METHOD(ReturnType, myMethod, (int), (const override));", + Style); verifyFormat("void foo() const final;", Style); verifyFormat("void foo() const final LLVM_READONLY;", Style); verifyFormat("void foo() const LLVM_READONLY;", Style); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 04dc69180960c..810c716b7a411 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2248,6 +2248,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { EXPECT_TOKEN(Tokens[3], tok::l_square, TT_LambdaLSquare); EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_LambdaDefinitionLParen); EXPECT_TOKEN(Tokens[10], tok::l_square, TT_ArraySubscriptLSquare); + + Tokens = annotate("foo = bar * [] { return 2; }();"); + ASSERT_EQ(Tokens.size(), 15u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator); + EXPECT_TOKEN(Tokens[4], tok::l_square, TT_LambdaLSquare); + EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace); } TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) { diff --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake index 9a88bb87157c1..908d52f238128 100644 --- a/cmake/Modules/LLVMVersion.cmake +++ b/cmake/Modules/LLVMVersion.cmake @@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR) set(LLVM_VERSION_MINOR 1) endif() if(NOT DEFINED LLVM_VERSION_PATCH) - set(LLVM_VERSION_PATCH 6) + set(LLVM_VERSION_PATCH 8) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index 16caf699a4c24..ea5f2e8f8e022 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -1287,7 +1287,7 @@ uptr GetPageSize() { uptr ReadBinaryName(/*out*/ char *buf, uptr buf_len) { # if SANITIZER_HAIKU - int cookie = 0; + int32_t cookie = 0; image_info info; const char *argv0 = ""; while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { @@ -1987,7 +1987,10 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const { # elif SANITIZER_NETBSD uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR]; # elif SANITIZER_HAIKU - uptr err = ucontext->uc_mcontext.r13; + uptr err = 0; // FIXME: ucontext->uc_mcontext.r13; + // The err register was added on the main branch and not + // available with the current release. To be reverted later. + // https://github.com/haiku/haiku/commit/11adda21aa4e6b24f71a496868a44d7607bc3764 # elif SANITIZER_SOLARIS && defined(__i386__) const int Err = 13; uptr err = ucontext->uc_mcontext.gregs[Err]; @@ -2617,6 +2620,11 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { *pc = ucontext->uc_mcontext.mc_eip; *bp = ucontext->uc_mcontext.mc_ebp; *sp = ucontext->uc_mcontext.mc_esp; +# elif SANITIZER_HAIKU + ucontext_t *ucontext = (ucontext_t *)context; + *pc = ucontext->uc_mcontext.eip; + *bp = ucontext->uc_mcontext.ebp; + *sp = ucontext->uc_mcontext.esp; # else ucontext_t *ucontext = (ucontext_t *)context; # if SANITIZER_SOLARIS diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h index 24966523f3a02..41d60c8d59fbe 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -629,7 +629,7 @@ typedef unsigned long __sanitizer_sigset_t; # elif SANITIZER_APPLE typedef unsigned __sanitizer_sigset_t; # elif SANITIZER_HAIKU -typedef unsigned long __sanitizer_sigset_t; +typedef unsigned long long __sanitizer_sigset_t; # elif SANITIZER_LINUX struct __sanitizer_sigset_t { // The size is determined by looking at sizeof of real sigset_t on linux. diff --git a/libcxx/include/__config b/libcxx/include/__config index 4261753c0bf1f..699e195da2e07 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -28,7 +28,7 @@ // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is // defined to XXYYZZ. -# define _LIBCPP_VERSION 210106 +# define _LIBCPP_VERSION 210108 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index 01752cdc6a9da..cfb33daa024a7 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -939,7 +939,7 @@ void ECCodeMapChunk::writeTo(uint8_t *buf) const { auto table = reinterpret_cast(buf); for (uint32_t i = 0; i < map.size(); i++) { const ECCodeMapEntry &entry = map[i]; - uint32_t start = entry.first->getRVA(); + uint32_t start = entry.first->getRVA() & ~0xfff; table[i].StartOffset = start | entry.type; table[i].Length = entry.last->getRVA() + entry.last->getSize() - start; } diff --git a/lld/test/COFF/arm64ec-codemap.test b/lld/test/COFF/arm64ec-codemap.test index 050261117be2e..bbc682d19920f 100644 --- a/lld/test/COFF/arm64ec-codemap.test +++ b/lld/test/COFF/arm64ec-codemap.test @@ -7,6 +7,7 @@ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym2.s -o arm64e RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec.s -o data-sec.obj RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec2.s -o data-sec2.obj RUN: llvm-mc -filetype=obj -triple=arm64ec-windows empty-sec.s -o arm64ec-empty-sec.obj +RUN: llvm-mc -filetype=obj -triple=arm64ec-windows entry-thunk.s -o entry-thunk.obj RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-func-sym.s -o x86_64-func-sym.obj RUN: llvm-mc -filetype=obj -triple=x86_64-windows empty-sec.s -o x86_64-empty-sec.obj RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj @@ -162,15 +163,17 @@ RUN: loadconfig-arm64ec.obj -dll -noentry -merge:test=.testdata -merge: RUN: llvm-readobj --coff-load-config testcm.dll | FileCheck -check-prefix=CODEMAPCM %s CODEMAPCM: CodeMap [ -CODEMAPCM-NEXT: 0x4008 - 0x4016 X64 +CODEMAPCM-NEXT: 0x4000 - 0x4016 X64 CODEMAPCM-NEXT: ] RUN: llvm-objdump -d testcm.dll | FileCheck -check-prefix=DISASMCM %s DISASMCM: Disassembly of section .testdat: DISASMCM-EMPTY: DISASMCM-NEXT: 0000000180004000 <.testdat>: -DISASMCM-NEXT: 180004000: 00000001 udf #0x1 -DISASMCM-NEXT: 180004004: 00000000 udf #0x0 +DISASMCM-NEXT: 180004000: 01 00 addl %eax, (%rax) +DISASMCM-NEXT: 180004002: 00 00 addb %al, (%rax) +DISASMCM-NEXT: 180004004: 00 00 addb %al, (%rax) +DISASMCM-NEXT: 180004006: 00 00 addb %al, (%rax) DISASMCM-NEXT: 180004008: b8 03 00 00 00 movl $0x3, %eax DISASMCM-NEXT: 18000400d: c3 retq DISASMCM-NEXT: 18000400e: 00 00 addb %al, (%rax) @@ -207,6 +210,14 @@ DISASMMS-NEXT: 0000000180006000 : DISASMMS-NEXT: 180006000: 528000a0 mov w0, #0x5 // =5 DISASMMS-NEXT: 180006004: d65f03c0 ret +Test the code map that includes an ARM64EC function padded by its entry-thunk offset. + +RUN: lld-link -out:testpad.dll -machine:arm64ec entry-thunk.obj loadconfig-arm64ec.obj -dll -noentry -include:func +RUN: llvm-readobj --coff-load-config testpad.dll | FileCheck -check-prefix=CODEMAPPAD %s +CODEMAPPAD: CodeMap [ +CODEMAPPAD: 0x1000 - 0x1010 ARM64EC +CODEMAPPAD-NEXT: ] + #--- arm64-func-sym.s .text @@ -266,3 +277,22 @@ x86_64_func_sym2: .section .empty1, "xr" .section .empty2, "xr" .section .empty3, "xr" + +#--- entry-thunk.s + .section .text,"xr",discard,func + .globl func + .p2align 2, 0x0 +func: + mov w0, #1 + ret + + .section .wowthk$aa,"xr",discard,thunk + .globl thunk + .p2align 2 +thunk: + ret + + .section .hybmp$x,"yi" + .symidx func + .symidx thunk + .word 1 // entry thunk diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h index e9f3820319281..3a19d0f95843a 100644 --- a/llvm/include/llvm/MC/MCSection.h +++ b/llvm/include/llvm/MC/MCSection.h @@ -299,8 +299,8 @@ class MCFragment { /// data. class MCEncodedFragment : public MCFragment { uint8_t BundlePadding = 0; - uint32_t ContentStart = 0; - uint32_t ContentEnd = 0; + uint32_t ContentSize = 0; + uint64_t ContentStart = 0; uint32_t FixupStart = 0; uint32_t FixupEnd = 0; @@ -361,22 +361,23 @@ class MCEncodedFragment : public MCFragment { // Content-related functions manage parent's storage using ContentStart and // ContentSize. - void clearContents() { ContentEnd = ContentStart; } + void clearContents() { ContentSize = 0; } // Get a SmallVector reference. The caller should call doneAppending to update - // `ContentEnd`. + // `ContentSize`. SmallVectorImpl &getContentsForAppending() { SmallVectorImpl &S = getParent()->ContentStorage; - if (LLVM_UNLIKELY(ContentEnd != S.size())) { + if (LLVM_UNLIKELY(ContentStart + ContentSize != S.size())) { // Move the elements to the end. Reserve space to avoid invalidating // S.begin()+I for `append`. - auto Size = ContentEnd - ContentStart; auto I = std::exchange(ContentStart, S.size()); - S.reserve(S.size() + Size); - S.append(S.begin() + I, S.begin() + I + Size); + S.reserve(S.size() + ContentSize); + S.append(S.begin() + I, S.begin() + I + ContentSize); } return S; } - void doneAppending() { ContentEnd = getParent()->ContentStorage.size(); } + void doneAppending() { + ContentSize = getParent()->ContentStorage.size() - ContentStart; + } void appendContents(ArrayRef Contents) { getContentsForAppending().append(Contents.begin(), Contents.end()); doneAppending(); @@ -388,11 +389,11 @@ class MCEncodedFragment : public MCFragment { LLVM_ABI void setContents(ArrayRef Contents); MutableArrayRef getContents() { return MutableArrayRef(getParent()->ContentStorage) - .slice(ContentStart, ContentEnd - ContentStart); + .slice(ContentStart, ContentSize); } ArrayRef getContents() const { return ArrayRef(getParent()->ContentStorage) - .slice(ContentStart, ContentEnd - ContentStart); + .slice(ContentStart, ContentSize); } // Fixup-related functions manage parent's storage using FixupStart and @@ -410,7 +411,7 @@ class MCEncodedFragment : public MCFragment { .slice(FixupStart, FixupEnd - FixupStart); } - size_t getSize() const { return ContentEnd - ContentStart; } + size_t getSize() const { return ContentSize; } }; /// Fragment for data and encoded instructions. diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp index 13ed8f28d5507..2052e9a75d89b 100644 --- a/llvm/lib/CodeGen/SelectOptimize.cpp +++ b/llvm/lib/CodeGen/SelectOptimize.cpp @@ -502,7 +502,7 @@ static Value *getTrueOrFalseValue( } else { assert((isa(AuxI) || isa(AuxI)) && "Unexpected opcode"); - CBO->setOperand(CondIdx, ConstantInt::get(CBO->getType(), -1)); + CBO->setOperand(CondIdx, ConstantInt::getAllOnesValue(CBO->getType())); } unsigned OtherIdx = 1 - CondIdx; diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp index a7330692571de..97f591fbf0e28 100644 --- a/llvm/lib/MC/MCSection.cpp +++ b/llvm/lib/MC/MCSection.cpp @@ -84,11 +84,11 @@ LLVM_DUMP_METHOD void MCSection::dump( void MCEncodedFragment::setContents(ArrayRef Contents) { auto &S = getParent()->ContentStorage; - if (ContentStart + Contents.size() > ContentEnd) { + if (Contents.size() > ContentSize) { ContentStart = S.size(); S.resize_for_overwrite(S.size() + Contents.size()); } - ContentEnd = ContentStart + Contents.size(); + ContentSize = Contents.size(); llvm::copy(Contents, S.begin() + ContentStart); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index e6486e247209b..5c3127e2d3dc6 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -216,6 +216,18 @@ static MachineInstr *findStartOfTree(MachineOperand &MO, return Def; } +// FAKE_USEs are no-ops, so remove them here so that the values used by them +// will be correctly dropped later. +static void removeFakeUses(MachineFunction &MF) { + SmallVector ToDelete; + for (auto &MBB : MF) + for (auto &MI : MBB) + if (MI.isFakeUse()) + ToDelete.push_back(&MI); + for (auto *MI : ToDelete) + MI->eraseFromParent(); +} + bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { LLVM_DEBUG(dbgs() << "********** Make Locals Explicit **********\n" "********** Function: " @@ -226,6 +238,8 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { WebAssemblyFunctionInfo &MFI = *MF.getInfo(); const auto *TII = MF.getSubtarget().getInstrInfo(); + removeFakeUses(MF); + // Map non-stackified virtual registers to their local ids. DenseMap Reg2Local; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp index bc91c6424b63e..fd13ef9a1921d 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -866,6 +866,10 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) { if (Insert->isDebugValue()) continue; + // Ignore FAKE_USEs, which are no-ops and will be deleted later. + if (Insert->isFakeUse()) + continue; + // Iterate through the inputs in reverse order, since we'll be pulling // operands off the stack in LIFO order. CommutingState Commuting; diff --git a/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp index 5ef6ffb58a7c1..667fdb746175f 100644 --- a/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp @@ -90,6 +90,9 @@ PreservedAnalyses RealtimeSanitizerPass::run(Module &M, [&](Function *Ctor, FunctionCallee) { appendToGlobalCtors(M, Ctor, 0); }); for (Function &F : M) { + if (F.empty()) + continue; + if (F.hasFnAttribute(Attribute::SanitizeRealtime)) runSanitizeRealtime(F); diff --git a/llvm/test/CodeGen/AArch64/selectopt-cast.ll b/llvm/test/CodeGen/AArch64/selectopt-cast.ll index b862458e99fe2..47cc736ad6880 100644 --- a/llvm/test/CodeGen/AArch64/selectopt-cast.ll +++ b/llvm/test/CodeGen/AArch64/selectopt-cast.ll @@ -901,3 +901,49 @@ loop: exit: ret void } + +define void @sext_i128() { +; CHECK-LABEL: @sext_i128( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[I:%.*]] = icmp slt i128 0, 0 +; CHECK-NEXT: [[I2:%.*]] = sext i1 [[I]] to i128 +; CHECK-NEXT: [[I3:%.*]] = or i128 [[I2]], 0 +; CHECK-NEXT: [[I4:%.*]] = icmp slt i128 [[I3]], 0 +; CHECK-NEXT: [[I5:%.*]] = sext i1 [[I4]] to i128 +; CHECK-NEXT: [[I4_FROZEN:%.*]] = freeze i1 [[I4]] +; CHECK-NEXT: br i1 [[I4_FROZEN]], label [[SELECT_TRUE_SINK:%.*]], label [[SELECT_END:%.*]] +; CHECK: select.true.sink: +; CHECK-NEXT: [[TMP0:%.*]] = add i128 -1, 0 +; CHECK-NEXT: br label [[SELECT_END]] +; CHECK: select.end: +; CHECK-NEXT: [[I6:%.*]] = phi i128 [ [[TMP0]], [[SELECT_TRUE_SINK]] ], [ 0, [[LOOP]] ] +; CHECK-NEXT: [[I7:%.*]] = icmp slt i128 [[I6]], 0 +; CHECK-NEXT: [[I8:%.*]] = sext i1 [[I7]] to i128 +; CHECK-NEXT: [[I7_FROZEN:%.*]] = freeze i1 [[I7]] +; CHECK-NEXT: br i1 [[I7_FROZEN]], label [[SELECT_TRUE_SINK2:%.*]], label [[SELECT_END1:%.*]] +; CHECK: select.true.sink2: +; CHECK-NEXT: [[TMP1:%.*]] = add i128 -1, 0 +; CHECK-NEXT: br label [[SELECT_END1]] +; CHECK: select.end1: +; CHECK-NEXT: [[I9:%.*]] = phi i128 [ [[TMP1]], [[SELECT_TRUE_SINK2]] ], [ 0, [[SELECT_END]] ] +; CHECK-NEXT: [[I10:%.*]] = or i128 [[I9]], 0 +; CHECK-NEXT: br label [[LOOP]] +; +entry: + br label %loop + +loop: + %i = icmp slt i128 0, 0 + %i2 = sext i1 %i to i128 + %i3 = or i128 %i2, 0 + %i4 = icmp slt i128 %i3, 0 + %i5 = sext i1 %i4 to i128 + %i6 = add i128 %i5, 0 + %i7 = icmp slt i128 %i6, 0 + %i8 = sext i1 %i7 to i128 + %i9 = add i128 %i8, 0 + %i10 = or i128 %i9, 0 + br label %loop +} diff --git a/llvm/test/CodeGen/WebAssembly/fake-use.ll b/llvm/test/CodeGen/WebAssembly/fake-use.ll new file mode 100644 index 0000000000000..a18ce33566df0 --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/fake-use.ll @@ -0,0 +1,25 @@ +; RUN: llc < %s | llvm-mc -triple=wasm32-unknown-unknown + +target triple = "wasm32-unknown-unknown" + +define void @fake_use() { + %t = call i32 @foo() + tail call void (...) @llvm.fake.use(i32 %t) + ret void +} + +; %t shouldn't be converted to TEE in RegStackify, because the FAKE_USE will be +; deleted in the beginning of ExplicitLocals. +define void @fake_use_no_tee() { + %t = call i32 @foo() + tail call void (...) @llvm.fake.use(i32 %t) + call void @use(i32 %t) + ret void +} + +declare i32 @foo() +declare void @use(i32 %t) +; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) +declare void @llvm.fake.use(...) #0 + +attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } diff --git a/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_attrib_declare.ll b/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_attrib_declare.ll new file mode 100644 index 0000000000000..3526a010ce489 --- /dev/null +++ b/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_attrib_declare.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -passes='rtsan' -S | FileCheck %s + +declare void @declared_realtime_function() sanitize_realtime #0 + +declare void @declared_blocking_function() sanitize_realtime_blocking #0 + +; RealtimeSanitizer pass should ignore attributed functions that are just declarations +; CHECK: declared_realtime_function +; CHECK-EMPTY: +; CHECK: declared_blocking_function +; CHECK-EMPTY: diff --git a/llvm/utils/gn/secondary/llvm/version.gni b/llvm/utils/gn/secondary/llvm/version.gni index 4e9eeaa7ae954..8c7f81568cd5e 100644 --- a/llvm/utils/gn/secondary/llvm/version.gni +++ b/llvm/utils/gn/secondary/llvm/version.gni @@ -1,4 +1,4 @@ llvm_version_major = 21 llvm_version_minor = 1 -llvm_version_patch = 6 +llvm_version_patch = 8 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch" diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py index 8fefb89de8e36..1be36556e4f73 100644 --- a/llvm/utils/lit/lit/__init__.py +++ b/llvm/utils/lit/lit/__init__.py @@ -2,7 +2,7 @@ __author__ = "Daniel Dunbar" __email__ = "daniel@minormatter.com" -__versioninfo__ = (21, 1, 6) +__versioninfo__ = (21, 1, 8) __version__ = ".".join(str(v) for v in __versioninfo__) + "dev" __all__ = [] diff --git a/llvm/utils/mlgo-utils/mlgo/__init__.py b/llvm/utils/mlgo-utils/mlgo/__init__.py index 84985323c64fa..76e2671a0e567 100644 --- a/llvm/utils/mlgo-utils/mlgo/__init__.py +++ b/llvm/utils/mlgo-utils/mlgo/__init__.py @@ -4,7 +4,7 @@ from datetime import timezone, datetime -__versioninfo__ = (21, 1, 6) +__versioninfo__ = (21, 1, 8) __version__ = ( ".".join(str(v) for v in __versioninfo__) + "dev"