Skip to content

Commit ca75a9f

Browse files
committed
[AutoBump] Merge with eff6b64 (Jan 17)
2 parents 2836d49 + eff6b64 commit ca75a9f

File tree

128 files changed

+7754
-2371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+7754
-2371
lines changed

bolt/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ if (BOLT_ENABLE_RUNTIME)
163163
add_llvm_install_targets(install-bolt_rt
164164
DEPENDS bolt_rt bolt
165165
COMPONENT bolt)
166-
set(LIBBOLT_RT_INSTR "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_instr.a")
167-
set(LIBBOLT_RT_HUGIFY "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_hugify.a")
166+
set(LIBBOLT_RT_INSTR "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr.a")
167+
set(LIBBOLT_RT_HUGIFY "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_hugify.a")
168168
endif()
169169

170170
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")

bolt/lib/Passes/Inliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ Inliner::inlineCall(BinaryBasicBlock &CallerBB,
310310
if (MIB.isPseudo(Inst))
311311
continue;
312312

313-
MIB.stripAnnotations(Inst, /*KeepTC=*/BC.isX86());
313+
MIB.stripAnnotations(Inst, /*KeepTC=*/BC.isX86() || BC.isAArch64());
314314

315315
// Fix branch target. Strictly speaking, we don't have to do this as
316316
// targets of direct branches will be fixed later and don't matter
317317
// in the CFG state. However, disassembly may look misleading, and
318318
// hence we do the fixing.
319-
if (MIB.isBranch(Inst)) {
319+
if (MIB.isBranch(Inst) && !MIB.isTailCall(Inst)) {
320320
assert(!MIB.isIndirectBranch(Inst) &&
321321
"unexpected indirect branch in callee");
322322
const BinaryBasicBlock *TargetBB =

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,36 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
133133
public:
134134
using MCPlusBuilder::MCPlusBuilder;
135135

136+
MCPhysReg getStackPointer() const override { return AArch64::SP; }
137+
138+
bool isPush(const MCInst &Inst) const override { return false; }
139+
140+
bool isPop(const MCInst &Inst) const override { return false; }
141+
142+
void createCall(MCInst &Inst, const MCSymbol *Target,
143+
MCContext *Ctx) override {
144+
createDirectCall(Inst, Target, Ctx, false);
145+
}
146+
147+
bool convertTailCallToCall(MCInst &Inst) override {
148+
int NewOpcode;
149+
switch (Inst.getOpcode()) {
150+
default:
151+
return false;
152+
case AArch64::B:
153+
NewOpcode = AArch64::BL;
154+
break;
155+
case AArch64::BR:
156+
NewOpcode = AArch64::BLR;
157+
break;
158+
}
159+
160+
Inst.setOpcode(NewOpcode);
161+
removeAnnotation(Inst, MCPlus::MCAnnotation::kTailCall);
162+
clearOffset(Inst);
163+
return true;
164+
}
165+
136166
bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
137167
CompFuncTy Comp) const override {
138168
const auto &AArch64ExprA = cast<AArch64MCExpr>(A);

bolt/runtime/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ add_library(bolt_rt_instr STATIC
1616
instr.cpp
1717
${CMAKE_CURRENT_BINARY_DIR}/config.h
1818
)
19-
set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
19+
set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
2020
add_library(bolt_rt_hugify STATIC
2121
hugify.cpp
2222
${CMAKE_CURRENT_BINARY_DIR}/config.h
2323
)
24-
set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
24+
set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
2525

2626
if(NOT BOLT_BUILT_STANDALONE)
2727
add_custom_command(TARGET bolt_rt_instr POST_BUILD
28-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr.a" "${LLVM_LIBRARY_DIR}")
28+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr.a" "${LLVM_LIBRARY_DIR}")
2929
add_custom_command(TARGET bolt_rt_hugify POST_BUILD
30-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}")
30+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}")
3131
endif()
3232

3333
set(BOLT_RT_FLAGS
@@ -53,23 +53,23 @@ target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
5353
target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
5454
target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
5555

56-
install(TARGETS bolt_rt_instr DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
57-
install(TARGETS bolt_rt_hugify DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
56+
install(TARGETS bolt_rt_instr DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
57+
install(TARGETS bolt_rt_hugify DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
5858

5959
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
6060
add_library(bolt_rt_instr_osx STATIC
6161
instr.cpp
6262
${CMAKE_CURRENT_BINARY_DIR}/config.h
6363
)
64-
set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
64+
set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
6565
target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
6666
target_compile_options(bolt_rt_instr_osx PRIVATE
6767
-target x86_64-apple-darwin19.6.0
6868
${BOLT_RT_FLAGS})
69-
install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
69+
install(TARGETS bolt_rt_instr_osx DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
7070

7171
if(NOT BOLT_BUILT_STANDALONE)
7272
add_custom_command(TARGET bolt_rt_instr_osx POST_BUILD
73-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr_osx.a" "${LLVM_LIBRARY_DIR}")
73+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/libbolt_rt_instr_osx.a" "${LLVM_LIBRARY_DIR}")
7474
endif()
7575
endif()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## This test checks that inline is properly handled by BOLT on aarch64.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
6+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt --inline-small-functions --print-inline --print-only=_Z3barP1A \
8+
# RUN: %t.exe -o %t.bolt | FileCheck %s
9+
10+
# CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 4 bytes.
11+
# CHECK: Binary Function "_Z3barP1A" after inlining {
12+
# CHECK-NOT: bl _Z3fooP1A
13+
# CHECK: ldr x8, [x0]
14+
# CHECK-NEXT: ldr w0, [x8]
15+
16+
.text
17+
.globl _Z3fooP1A
18+
.type _Z3fooP1A,@function
19+
_Z3fooP1A:
20+
ldr x8, [x0]
21+
ldr w0, [x8]
22+
ret
23+
.size _Z3fooP1A, .-_Z3fooP1A
24+
25+
.globl _Z3barP1A
26+
.type _Z3barP1A,@function
27+
_Z3barP1A:
28+
stp x29, x30, [sp, #-16]!
29+
mov x29, sp
30+
bl _Z3fooP1A
31+
mul w0, w0, w0
32+
ldp x29, x30, [sp], #16
33+
ret
34+
.size _Z3barP1A, .-_Z3barP1A
35+
36+
.globl main
37+
.p2align 2
38+
.type main,@function
39+
main:
40+
mov w0, wzr
41+
ret
42+
.size main, .-main
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## This test checks that inline is properly handled by BOLT on aarch64.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
6+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt --inline-small-functions --print-inline --print-only=test \
8+
# RUN: %t.exe -o %t.bolt | FileCheck %s
9+
10+
#CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 4 bytes.
11+
#CHECK: Binary Function "test" after inlining {
12+
#CHECK-NOT: bl indirect
13+
#CHECK: add w0, w1, w0
14+
#CHECK-NEXT: blr x2
15+
16+
.text
17+
.globl indirect
18+
.type indirect,@function
19+
indirect:
20+
add w0, w1, w0
21+
br x2
22+
.size indirect, .-indirect
23+
24+
.globl test
25+
.type test,@function
26+
test:
27+
stp x29, x30, [sp, #-32]!
28+
stp x20, x19, [sp, #16]
29+
mov x29, sp
30+
mov w19, w1
31+
mov w20, w0
32+
bl indirect
33+
add w8, w19, w20
34+
cmp w0, #0
35+
csinc w0, w8, wzr, eq
36+
ldp x20, x19, [sp, #16]
37+
ldp x29, x30, [sp], #32
38+
ret
39+
.size test, .-test
40+
41+
.globl main
42+
.type main,@function
43+
main:
44+
mov w0, wzr
45+
ret
46+
.size main, .-main
47+
48+

bolt/test/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
host_linux_triple = config.target_triple.split("-")[0] + "-unknown-linux-gnu"
2-
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -pie"
2+
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -Wl,--build-id=none -pie"
33
flags = f"--target={host_linux_triple} -fPIE {common_linker_flags}"
44

55
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))

clang/include/clang/AST/Attr.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class Attr : public AttributeCommonInfo {
6060
unsigned IsLateParsed : 1;
6161
LLVM_PREFERRED_TYPE(bool)
6262
unsigned InheritEvenIfAlreadyPresent : 1;
63+
LLVM_PREFERRED_TYPE(bool)
64+
unsigned DeferDeserialization : 1;
6365

6466
void *operator new(size_t bytes) noexcept {
6567
llvm_unreachable("Attrs cannot be allocated with regular 'new'.");
@@ -80,10 +82,11 @@ class Attr : public AttributeCommonInfo {
8082

8183
protected:
8284
Attr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
83-
attr::Kind AK, bool IsLateParsed)
85+
attr::Kind AK, bool IsLateParsed, bool DeferDeserialization = false)
8486
: AttributeCommonInfo(CommonInfo), AttrKind(AK), Inherited(false),
8587
IsPackExpansion(false), Implicit(false), IsLateParsed(IsLateParsed),
86-
InheritEvenIfAlreadyPresent(false) {}
88+
InheritEvenIfAlreadyPresent(false),
89+
DeferDeserialization(DeferDeserialization) {}
8790

8891
public:
8992
attr::Kind getKind() const { return static_cast<attr::Kind>(AttrKind); }
@@ -105,6 +108,8 @@ class Attr : public AttributeCommonInfo {
105108
void setPackExpansion(bool PE) { IsPackExpansion = PE; }
106109
bool isPackExpansion() const { return IsPackExpansion; }
107110

111+
bool shouldDeferDeserialization() const { return DeferDeserialization; }
112+
108113
// Clone this attribute.
109114
Attr *clone(ASTContext &C) const;
110115

@@ -146,8 +151,9 @@ class InheritableAttr : public Attr {
146151
protected:
147152
InheritableAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
148153
attr::Kind AK, bool IsLateParsed,
149-
bool InheritEvenIfAlreadyPresent)
150-
: Attr(Context, CommonInfo, AK, IsLateParsed) {
154+
bool InheritEvenIfAlreadyPresent,
155+
bool DeferDeserialization = false)
156+
: Attr(Context, CommonInfo, AK, IsLateParsed, DeferDeserialization) {
151157
this->InheritEvenIfAlreadyPresent = InheritEvenIfAlreadyPresent;
152158
}
153159

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===--- AllDiagnosticKinds.inc----------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// \file
10+
/// Defines the Diagnostic IDs in ID sorted order. The order is dictated by
11+
/// the enum in DiagnosticIDs.h#L49-L65.
12+
///
13+
//===----------------------------------------------------------------------===//
14+
15+
// Turn off clang-format, as the order of the includes are important to make
16+
// sure tables based on Diagnostic IDs are partitioned/sorted based on
17+
// DiagID.
18+
19+
// clang-format off
20+
#include "clang/Basic/DiagnosticCommonKinds.inc"
21+
#include "clang/Basic/DiagnosticDriverKinds.inc"
22+
#include "clang/Basic/DiagnosticFrontendKinds.inc"
23+
#include "clang/Basic/DiagnosticSerializationKinds.inc"
24+
#include "clang/Basic/DiagnosticLexKinds.inc"
25+
#include "clang/Basic/DiagnosticParseKinds.inc"
26+
#include "clang/Basic/DiagnosticASTKinds.inc"
27+
#include "clang/Basic/DiagnosticCommentKinds.inc"
28+
#include "clang/Basic/DiagnosticCrossTUKinds.inc"
29+
#include "clang/Basic/DiagnosticSemaKinds.inc"
30+
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
31+
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
32+
#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
33+
// clang-format on

clang/include/clang/Basic/Attr.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,12 @@ class Attr {
713713
// attribute may be documented under multiple categories, more than one
714714
// Documentation entry may be listed.
715715
list<Documentation> Documentation;
716+
// Set to true if deserialization of this attribute must be deferred until
717+
// the parent Decl is fully deserialized (during header module file
718+
// deserialization). E.g., this is the case for the preferred_name attribute,
719+
// since its type deserialization depends on its target Decl type.
720+
// (See https://github.com/llvm/llvm-project/issues/56490 for details).
721+
bit DeferDeserialization = 0;
716722
}
717723

718724
/// Used to define a set of mutually exclusive attributes.
@@ -3254,6 +3260,11 @@ def PreferredName : InheritableAttr {
32543260
let InheritEvenIfAlreadyPresent = 1;
32553261
let MeaningfulToClassTemplateDefinition = 1;
32563262
let TemplateDependent = 1;
3263+
// Type of this attribute depends on the target Decl type.
3264+
// Therefore, its deserialization must be deferred until
3265+
// deserialization of the target Decl is complete
3266+
// (for header modules).
3267+
let DeferDeserialization = 1;
32573268
}
32583269

32593270
def PreserveMost : DeclOrTypeAttr {

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ enum ASTRecordTypes {
740740
CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION = 75,
741741

742742
UPDATE_MODULE_LOCAL_VISIBLE = 76,
743+
744+
UPDATE_TU_LOCAL_VISIBLE = 77,
743745
};
744746

745747
/// Record types used within a source manager block.
@@ -1340,6 +1342,10 @@ enum DeclCode {
13401342
/// only visible from DeclContext in the same module.
13411343
DECL_CONTEXT_MODULE_LOCAL_VISIBLE,
13421344

1345+
/// A record that stores the set of declarations that are only visible
1346+
/// to the TU.
1347+
DECL_CONTEXT_TU_LOCAL_VISIBLE,
1348+
13431349
/// A LabelDecl record.
13441350
DECL_LABEL,
13451351

0 commit comments

Comments
 (0)