Skip to content

Commit 3b20827

Browse files
authored
Merge pull request #179 from sx-aurora-dev/feature/merge-upstream-20220329
Feature/merge upstream 20220329
2 parents 75375c9 + e4d6a60 commit 3b20827

File tree

750 files changed

+25057
-14077
lines changed

Some content is hidden

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

750 files changed

+25057
-14077
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class BinaryFunction {
172172

173173
mutable MCSymbol *FunctionConstantIslandLabel{nullptr};
174174
mutable MCSymbol *FunctionColdConstantIslandLabel{nullptr};
175+
176+
// Returns constant island alignment
177+
uint16_t getAlignment() const { return sizeof(uint64_t); }
175178
};
176179

177180
static constexpr uint64_t COUNT_NO_PROFILE =
@@ -2047,6 +2050,10 @@ class BinaryFunction {
20472050
return *std::prev(CodeIter) <= *DataIter;
20482051
}
20492052

2053+
uint16_t getConstantIslandAlignment() const {
2054+
return Islands ? Islands->getAlignment() : 1;
2055+
}
2056+
20502057
uint64_t
20512058
estimateConstantIslandSize(const BinaryFunction *OnBehalfOf = nullptr) const {
20522059
if (!Islands)
@@ -2074,9 +2081,13 @@ class BinaryFunction {
20742081
Size += NextMarker - *DataIter;
20752082
}
20762083

2077-
if (!OnBehalfOf)
2078-
for (BinaryFunction *ExternalFunc : Islands->Dependency)
2084+
if (!OnBehalfOf) {
2085+
for (BinaryFunction *ExternalFunc : Islands->Dependency) {
2086+
Size = alignTo(Size, ExternalFunc->getConstantIslandAlignment());
20792087
Size += ExternalFunc->estimateConstantIslandSize(this);
2088+
}
2089+
}
2090+
20802091
return Size;
20812092
}
20822093

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ void BinaryEmitter::emitConstantIslands(BinaryFunction &BF, bool EmitColdPart,
500500
if (Islands.DataOffsets.empty() && Islands.Dependency.empty())
501501
return;
502502

503+
// AArch64 requires CI to be aligned to 8 bytes due to access instructions
504+
// restrictions. E.g. the ldr with imm, where imm must be aligned to 8 bytes.
505+
const uint16_t Alignment = OnBehalfOf
506+
? OnBehalfOf->getConstantIslandAlignment()
507+
: BF.getConstantIslandAlignment();
508+
Streamer.emitCodeAlignment(Alignment, &*BC.STI);
509+
503510
if (!OnBehalfOf) {
504511
if (!EmitColdPart)
505512
Streamer.emitLabel(BF.getFunctionConstantIslandLabel());

bolt/lib/Passes/LongJmp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ uint64_t LongJmpPass::tentativeLayoutRelocColdPart(
308308
LLVM_DEBUG(dbgs() << Func->getPrintName() << " cold tentative: "
309309
<< Twine::utohexstr(DotAddress) << "\n");
310310
DotAddress += Func->estimateColdSize();
311+
DotAddress = alignTo(DotAddress, Func->getConstantIslandAlignment());
311312
DotAddress += Func->estimateConstantIslandSize();
312313
}
313314
return DotAddress;
@@ -364,6 +365,8 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
364365
DotAddress += Func->estimateSize();
365366
else
366367
DotAddress += Func->estimateHotSize();
368+
369+
DotAddress = alignTo(DotAddress, Func->getConstantIslandAlignment());
367370
DotAddress += Func->estimateConstantIslandSize();
368371
++CurrentIndex;
369372
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This test checks that the constant island is aligned after BOLT tool.
2+
// In case the nop before .Lci will be removed the pointer to exit function
3+
// won't be alinged and the test will fail.
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
6+
# RUN: %s -o %t.o
7+
# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -Wl,-q \
8+
# RUN: -nostartfiles -nodefaultlibs -lc
9+
# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0 -trap-old-code
10+
# RUN: llvm-objdump -d --disassemble-symbols='$d' %t.bolt | FileCheck %s
11+
12+
.text
13+
.align 4
14+
.global
15+
.type dummy, %function
16+
dummy:
17+
add x0, x0, #1
18+
ret
19+
20+
.global
21+
.type exitOk, %function
22+
exitOk:
23+
mov x0, #0
24+
bl exit
25+
26+
.global _start
27+
.type _start, %function
28+
_start:
29+
adrp x0, .Lci
30+
ldr x0, [x0, #:lo12:.Lci]
31+
blr x0
32+
mov x1, #1
33+
bl exit
34+
nop
35+
# CHECK: {{0|8}} <$d>:
36+
.Lci:
37+
.xword exitOk
38+
.xword 0

bolt/test/runtime/AArch64/adrrelaxationpass.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ br:
4141
.word 0xff
4242

4343
# CHECK: <main>:
44-
# CHECK-NEXT: adr x0, #28
44+
# CHECK-NEXT: adr x0, #{{[0-9][0-9]*}}
4545
# CHECK-NEXT: adrp x1, 0x{{[1-8a-f][0-9a-f]*}}
4646
# CHECK-NEXT: add x1, x1, #{{[1-8a-f][0-9a-f]*}}
4747
# CHECK-NEXT: adrp x2, 0x{{[1-8a-f][0-9a-f]*}}
4848
# CHECK-NEXT: add x2, x2, #{{[1-8a-f][0-9a-f]*}}
49-
# CHECK-NEXT: adr x3, #4
49+
# CHECK-NEXT: adr x3, #{{[0-9][0-9]*}}

clang-tools-extra/clangd/test/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# Set CLANG_TOOLS_DIR to buildtree/bin, or buildtree/%(build_mode)s/bin if the
2-
# location is dynamic. The latter must be interpolated by lit configs.
3-
# FIXME: this is duplicated in many places.
4-
if (CMAKE_CFG_INTDIR STREQUAL ".")
5-
set(LLVM_BUILD_MODE ".")
6-
else ()
7-
set(LLVM_BUILD_MODE "%(build_mode)s")
8-
endif ()
9-
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
10-
111
set(CLANGD_TEST_DEPS
122
clangd
133
ClangdTests

clang-tools-extra/clangd/test/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
77
config.python_executable = "@Python3_EXECUTABLE@"
88
# Support substitution of the tools and libs dirs with user parameters. This is
99
# used when we can't determine the tool dir at configuration time.
10-
config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
10+
config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@")
1111
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
1212
config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
1313

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ The improvements are...
9696
Improvements to clang-tidy
9797
--------------------------
9898

99+
- Added trace code to help narrow down any checks and the relevant source code
100+
that result in crashes.
101+
99102
New checks
100103
^^^^^^^^^^
101104

clang-tools-extra/pseudo/include/clang-pseudo/Forest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
//
1818
//===----------------------------------------------------------------------===//
1919

20+
#ifndef CLANG_PSEUDO_FOREST_H
21+
#define CLANG_PSEUDO_FOREST_H
22+
2023
#include "clang-pseudo/Grammar.h"
2124
#include "clang-pseudo/Token.h"
2225
#include "llvm/ADT/ArrayRef.h"
@@ -176,3 +179,5 @@ class ForestArena {
176179

177180
} // namespace pseudo
178181
} // namespace clang
182+
183+
#endif // CLANG_PSEUDO_FOREST_H

clang-tools-extra/pseudo/lib/Forest.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,23 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
4646
};
4747
CountVisits(this);
4848

49+
// The box-drawing characters that should be added as a child is rendered.
50+
struct LineDecoration {
51+
std::string Prefix; // Prepended to every line.
52+
llvm::StringRef First; // added to the child's line.
53+
llvm::StringRef Subsequent; // added to descendants' lines.
54+
};
55+
4956
// We print a "#<id>" for nonterminal forest nodes that are being dumped
5057
// multiple times.
5158
llvm::DenseMap<const ForestNode *, size_t> ReferenceIds;
5259
std::string Result;
5360
constexpr Token::Index KEnd = std::numeric_limits<Token::Index>::max();
54-
std::function<void(const ForestNode *, unsigned, Token::Index,
55-
llvm::Optional<SymbolID>)>
56-
Dump = [&](const ForestNode *P, unsigned Level, Token::Index End,
57-
llvm::Optional<SymbolID> ElidedParent) {
61+
std::function<void(const ForestNode *, Token::Index, llvm::Optional<SymbolID>,
62+
LineDecoration &LineDec)>
63+
Dump = [&](const ForestNode *P, Token::Index End,
64+
llvm::Optional<SymbolID> ElidedParent,
65+
LineDecoration LineDec) {
5866
llvm::ArrayRef<const ForestNode *> Children;
5967
auto EndOfElement = [&](size_t ChildIndex) {
6068
return ChildIndex + 1 == Children.size()
@@ -72,18 +80,19 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
7280
if (Children[I]->startTokenIndex() == P->startTokenIndex() &&
7381
EndOfElement(I) == End) {
7482
return Dump(
75-
Children[I], Level, End,
76-
/*ElidedParent=*/ElidedParent.getValueOr(P->symbol()));
83+
Children[I], End,
84+
/*ElidedParent=*/ElidedParent.getValueOr(P->symbol()),
85+
LineDec);
7786
}
7887
}
7988
}
8089

81-
// FIXME: pretty ascii trees
8290
if (End == KEnd)
8391
Result += llvm::formatv("[{0,3}, end) ", P->startTokenIndex());
8492
else
8593
Result += llvm::formatv("[{0,3}, {1,3}) ", P->startTokenIndex(), End);
86-
Result.append(2 * Level, ' ');
94+
Result += LineDec.Prefix;
95+
Result += LineDec.First;
8796
if (ElidedParent.hasValue()) {
8897
Result += G.symbolName(*ElidedParent);
8998
Result += "~";
@@ -99,12 +108,23 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
99108
}
100109
Result.push_back('\n');
101110

102-
++Level;
103-
for (size_t I = 0; I < Children.size(); ++I)
104-
Dump(Children[I], Level,
105-
P->kind() == Sequence ? EndOfElement(I) : End, llvm::None);
111+
auto OldPrefixSize = LineDec.Prefix.size();
112+
LineDec.Prefix += LineDec.Subsequent;
113+
for (size_t I = 0; I < Children.size(); ++I) {
114+
if (I == Children.size() - 1) {
115+
LineDec.First = "└─";
116+
LineDec.Subsequent = " ";
117+
} else {
118+
LineDec.First = "├─";
119+
LineDec.Subsequent = "";
120+
}
121+
Dump(Children[I], P->kind() == Sequence ? EndOfElement(I) : End,
122+
llvm::None, LineDec);
123+
}
124+
LineDec.Prefix.resize(OldPrefixSize);
106125
};
107-
Dump(this, 0, KEnd, llvm::None);
126+
LineDecoration LineDec;
127+
Dump(this, KEnd, llvm::None, LineDec);
108128
return Result;
109129
}
110130

0 commit comments

Comments
 (0)