Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/18.x' into ldc-release…
Browse files Browse the repository at this point in the history
…/18.x
  • Loading branch information
kinke committed Apr 17, 2024
2 parents 77babf8 + e6c3289 commit 9013f36
Show file tree
Hide file tree
Showing 46 changed files with 621 additions and 701 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-lit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
cd llvm/utils/lit
# Remove 'dev' suffix from lit version.
sed -i 's/ + "dev"//g' lit/__init__.py
python3 setup.py sdist
python3 setup.py sdist bdist_wheel
- name: Upload lit to test.pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 1 addition & 1 deletion clang/cmake/caches/Release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# General Options
set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
set(LLVM_RELEASE_ENABLE_PGO OFF CACHE BOOL "")

set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")

Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ def RegCall : DeclOrTypeAttr {
}

def Final : InheritableAttr {
let CanPrintOnLeft = 0;
let Spellings = [CustomKeyword<"final">, CustomKeyword<"sealed">];
let Accessors = [Accessor<"isSpelledAsSealed", [CustomKeyword<"sealed">]>];
let SemaHandler = 0;
Expand Down Expand Up @@ -2472,6 +2473,7 @@ def Overloadable : Attr {
}

def Override : InheritableAttr {
let CanPrintOnLeft = 0;
let Spellings = [CustomKeyword<"override">];
let SemaHandler = 0;
// Omitted from docs, since this is language syntax, not an attribute, as far
Expand Down
20 changes: 10 additions & 10 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3450,10 +3450,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
for (AnnotatedLine *ChildLine : Line.Children)
calculateFormattingInformation(*ChildLine);

Line.First->TotalLength =
Line.First->IsMultiline ? Style.ColumnLimit
: Line.FirstStartColumn + Line.First->ColumnWidth;
FormatToken *Current = Line.First->Next;
auto *First = Line.First;
First->TotalLength = First->IsMultiline
? Style.ColumnLimit
: Line.FirstStartColumn + First->ColumnWidth;
FormatToken *Current = First->Next;
bool InFunctionDecl = Line.MightBeFunctionDecl;
bool AlignArrayOfStructures =
(Style.AlignArrayOfStructures != FormatStyle::AIAS_None &&
Expand All @@ -3475,16 +3476,15 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
IsCtorOrDtor ||
isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
if (!IsCtorOrDtor) {
LineIsFunctionDeclaration = true;
if (!IsCtorOrDtor)
Tok->setFinalizedType(TT_FunctionDeclarationName);
}
LineIsFunctionDeclaration = true;
SeenName = true;
break;
}
}

if (IsCpp && LineIsFunctionDeclaration &&
if (IsCpp && (LineIsFunctionDeclaration || First->is(TT_CtorDtorDeclName)) &&
Line.endsWith(tok::semi, tok::r_brace)) {
auto *Tok = Line.Last->Previous;
while (Tok->isNot(tok::r_brace))
Expand All @@ -3507,7 +3507,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
if (IsCpp) {
if (!LineIsFunctionDeclaration) {
// Annotate */&/&& in `operator` function calls as binary operators.
for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) {
for (const auto *Tok = First; Tok; Tok = Tok->Next) {
if (Tok->isNot(tok::kw_operator))
continue;
do {
Expand Down Expand Up @@ -3644,7 +3644,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {

calculateUnbreakableTailLengths(Line);
unsigned IndentLevel = Line.Level;
for (Current = Line.First; Current; Current = Current->Next) {
for (Current = First; Current; Current = Current->Next) {
if (Current->Role)
Current->Role->precomputeFormattingInfos(Current);
if (Current->MatchingParen &&
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Headers/__stddef_unreachable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*===-----------------------------------------------------------------------===
*/

#ifndef __cplusplus

/*
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
* and needs to behave as if it was textual.
Expand All @@ -15,3 +17,5 @@
(__has_feature(modules) && !__building_module(_Builtin_stddef))
#define unreachable() __builtin_unreachable()
#endif

#endif
20 changes: 20 additions & 0 deletions clang/test/AST/ast-dump-override-final.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file contain tests to check if override and final are dumped in the
// correct positions.

// RUN: %clang_cc1 -ast-print -x c++ %s -o - | FileCheck %s

// CHECK: class A {
class A {
// CHECK-NEXT: virtual void f();
virtual void f();

// CHECK-NEXT: virtual void g() final;
virtual void g() final;
} AA;

// CHECK: class B : public A {
class B : public A {
// CHECK-NEXT: virtual void f() override {
virtual void f() override {
};
} B;
14 changes: 14 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,20 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_FunctionLBrace);
EXPECT_BRACE_KIND(Tokens[4], BK_Block);
EXPECT_BRACE_KIND(Tokens[6], BK_Block);

Tokens = annotate("struct Foo {\n"
" Foo() {};\n"
" ~Foo() {};\n"
"};");
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
EXPECT_TOKEN(Tokens[3], tok::identifier, TT_CtorDtorDeclName);
EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_FunctionLBrace);
EXPECT_BRACE_KIND(Tokens[6], BK_Block);
EXPECT_BRACE_KIND(Tokens[7], BK_Block);
EXPECT_TOKEN(Tokens[10], tok::identifier, TT_CtorDtorDeclName);
EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
EXPECT_BRACE_KIND(Tokens[13], BK_Block);
EXPECT_BRACE_KIND(Tokens[14], BK_Block);
}

TEST_F(TokenAnnotatorTest, StreamOperator) {
Expand Down
42 changes: 42 additions & 0 deletions compiler-rt/lib/builtins/riscv/restore.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#if __riscv_xlen == 32

#ifndef __riscv_32e

.globl __riscv_restore_12
.type __riscv_restore_12,@function
__riscv_restore_12:
Expand Down Expand Up @@ -86,8 +88,29 @@ __riscv_restore_0:
addi sp, sp, 16
ret

#else

.globl __riscv_restore_2
.type __riscv_restore_2,@function
.globl __riscv_restore_1
.type __riscv_restore_1,@function
.globl __riscv_restore_0
.type __riscv_restore_0,@function
__riscv_restore_2:
__riscv_restore_1:
__riscv_restore_0:
lw s1, 0(sp)
lw s0, 4(sp)
lw ra, 8(sp)
addi sp, sp, 12
ret

#endif

#elif __riscv_xlen == 64

#ifndef __riscv_64e

.globl __riscv_restore_12
.type __riscv_restore_12,@function
__riscv_restore_12:
Expand Down Expand Up @@ -161,6 +184,25 @@ __riscv_restore_0:
addi sp, sp, 16
ret

#else

.globl __riscv_restore_2
.type __riscv_restore_2,@function
.globl __riscv_restore_1
.type __riscv_restore_1,@function
.globl __riscv_restore_0
.type __riscv_restore_0,@function
__riscv_restore_2:
__riscv_restore_1:
__riscv_restore_0:
ld s1, 0(sp)
ld s0, 8(sp)
ld ra, 16(sp)
addi sp, sp, 24
ret

#endif

#else
# error "xlen must be 32 or 64 for save-restore implementation
#endif
42 changes: 42 additions & 0 deletions compiler-rt/lib/builtins/riscv/save.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#if __riscv_xlen == 32

#ifndef __riscv_32e

.globl __riscv_save_12
.type __riscv_save_12,@function
__riscv_save_12:
Expand Down Expand Up @@ -92,8 +94,29 @@ __riscv_save_0:
sw ra, 12(sp)
jr t0

#else

.globl __riscv_save_2
.type __riscv_save_2,@function
.globl __riscv_save_1
.type __riscv_save_1,@function
.globl __riscv_save_0
.type __riscv_save_0,@function
__riscv_save_2:
__riscv_save_1:
__riscv_save_0:
addi sp, sp, -12
sw s1, 0(sp)
sw s0, 4(sp)
sw ra, 8(sp)
jr t0

#endif

#elif __riscv_xlen == 64

#ifndef __riscv_64e

.globl __riscv_save_12
.type __riscv_save_12,@function
__riscv_save_12:
Expand Down Expand Up @@ -181,6 +204,25 @@ __riscv_save_0:
sd ra, 8(sp)
jr t0

#else

.globl __riscv_save_2
.type __riscv_save_2,@function
.globl __riscv_save_1
.type __riscv_save_1,@function
.globl __riscv_save_0
.type __riscv_save_0,@function
__riscv_save_2:
__riscv_save_1:
__riscv_save_0:
addi sp, sp, -24
sd s1, 0(sp)
sd s0, 8(sp)
sd ra, 16(sp)
jr t0

#endif

#else
# error "xlen must be 32 or 64 for save-restore implementation
#endif
2 changes: 1 addition & 1 deletion libcxx/include/__format/formatter_floating_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par
// Let P equal the precision if nonzero, 6 if the precision is not
// specified, or 1 if the precision is 0. Then, if a conversion with
// style E would have an exponent of X:
int __p = std::max(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
int __p = std::max<int>(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
if (__result.__exponent == __result.__last)
// if P > X >= -4, the conversion is with style f or F and precision P - 1 - X.
// By including the radix point it calculates P - (1 + X)
Expand Down
29 changes: 10 additions & 19 deletions libcxx/include/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
//
//===----------------------------------------------------------------------===//

#if defined(__need_ptrdiff_t) || defined(__need_size_t) || defined(__need_wchar_t) || defined(__need_NULL) || \
defined(__need_wint_t)

# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif

# include_next <stddef.h>

#elif !defined(_LIBCPP_STDDEF_H)
# define _LIBCPP_STDDEF_H

/*
stddef.h synopsis
Expand All @@ -36,15 +24,18 @@
*/

# include <__config>
#include <__config>

# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

# if __has_include_next(<stddef.h>)
# include_next <stddef.h>
# endif
// Note: This include is outside of header guards because we sometimes get included multiple times
// with different defines and the underlying <stddef.h> will know how to deal with that.
#include_next <stddef.h>

#ifndef _LIBCPP_STDDEF_H
# define _LIBCPP_STDDEF_H

# ifdef __cplusplus
typedef decltype(nullptr) nullptr_t;
Expand Down
7 changes: 7 additions & 0 deletions lld/COFF/Chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,13 @@ void SectionChunk::getRuntimePseudoRelocs(
dyn_cast_or_null<Defined>(file->getSymbol(rel.SymbolTableIndex));
if (!target || !target->isRuntimePseudoReloc)
continue;
// If the target doesn't have a chunk allocated, it may be a
// DefinedImportData symbol which ended up unnecessary after GC.
// Normally we wouldn't eliminate section chunks that are referenced, but
// references within DWARF sections don't count for keeping section chunks
// alive. Thus such dangling references in DWARF sections are expected.
if (!target->getChunk())
continue;
int sizeInBits =
getRuntimePseudoRelocSize(rel.Type, file->ctx.config.machine);
if (sizeInBits == 0) {
Expand Down
41 changes: 41 additions & 0 deletions lld/test/COFF/autoimport-gc.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# REQUIRES: x86
# RUN: split-file %s %t.dir

# RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/lib.s -filetype=obj -o %t.dir/lib.obj
# RUN: lld-link -out:%t.dir/lib.dll -dll -entry:DllMainCRTStartup %t.dir/lib.obj -lldmingw -implib:%t.dir/lib.lib

# RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/main.s -filetype=obj -o %t.dir/main.obj
# RUN: lld-link -lldmingw -out:%t.dir/main.exe -entry:main %t.dir/main.obj %t.dir/lib.lib -opt:ref -debug:dwarf

#--- main.s
.global main
.section .text$main,"xr",one_only,main
main:
ret

.global other
.section .text$other,"xr",one_only,other
other:
movq .refptr.variable(%rip), %rax
movl (%rax), %eax
ret

.section .rdata$.refptr.variable,"dr",discard,.refptr.variable
.global .refptr.variable
.refptr.variable:
.quad variable

.section .debug_info
.long 1
.quad variable
.long 2

#--- lib.s
.global variable
.global DllMainCRTStartup
.text
DllMainCRTStartup:
ret
.data
variable:
.long 42
2 changes: 1 addition & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
set(LLVM_VERSION_MINOR 1)
endif()
if(NOT DEFINED LLVM_VERSION_PATCH)
set(LLVM_VERSION_PATCH 3)
set(LLVM_VERSION_PATCH 4)
endif()
if(NOT DEFINED LLVM_VERSION_SUFFIX)
set(LLVM_VERSION_SUFFIX)
Expand Down
Loading

0 comments on commit 9013f36

Please sign in to comment.