Skip to content

Commit 21f68c7

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW16)
LLVM: llvm/llvm-project@b9ba053 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@0ed2286
2 parents 554ed21 + 4df1181 commit 21f68c7

File tree

1,259 files changed

+94925
-24723
lines changed

Some content is hidden

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

1,259 files changed

+94925
-24723
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ bool BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
20382038
MCInst *PrevInstr = PrevBB->getLastNonPseudoInstr();
20392039
assert(PrevInstr && "no previous instruction for a fall through");
20402040
if (MIB->isUnconditionalBranch(Instr) &&
2041+
!MIB->isIndirectBranch(*PrevInstr) &&
20412042
!MIB->isUnconditionalBranch(*PrevInstr) &&
20422043
!MIB->getConditionalTailCall(*PrevInstr) &&
20432044
!MIB->isReturn(*PrevInstr)) {

bolt/lib/Core/DebugData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ void DebugStrOffsetsWriter::initialize(
11661166
"Dwarf String Offsets Byte Size is not supported.");
11671167
uint32_t Index = 0;
11681168
for (uint64_t Offset = 0; Offset < Contr->Size; Offset += DwarfOffsetByteSize)
1169-
IndexToAddressMap[Index++] = *reinterpret_cast<const uint32_t *>(
1169+
IndexToAddressMap[Index++] = support::endian::read32le(
11701170
StrOffsetsSection.Data.data() + Contr->Base + Offset);
11711171
}
11721172

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
265265
return true;
266266
}
267267

268-
DispImm = Inst.getOperand(I).getImm() << 2;
268+
DispImm = Inst.getOperand(I).getImm() * 4;
269269
return true;
270270
}
271271
return false;

bolt/test/X86/section-end-sym.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Check that BOLT doesn't consider end-of-section symbols (e.g., _etext) as
22
## functions.
33

4-
# REQUIRES: system-linux, asserts
4+
# REQUIRES: x86_64-linux, asserts
55

66
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
77
# RUN: ld.lld %t.o -o %t.exe -q

bolt/test/X86/unreachable-jmp.s

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This checks that we don't create an invalid CFG when there is an
2+
# unreachable direct jump right after an indirect one.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
7+
# RUN: %s -o %t.o
8+
# RUN: link_fdata %s %t.o %t.fdata
9+
# RUN: llvm-strip --strip-unneeded %t.o
10+
# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q -nostdlib
11+
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata \
12+
# RUN: --eliminate-unreachable --print-cfg | FileCheck %s
13+
14+
.globl _start
15+
.type _start, %function
16+
_start:
17+
.cfi_startproc
18+
# FDATA: 0 [unknown] 0 1 _start 0 0 1
19+
push %rbp
20+
mov %rsp, %rbp
21+
push %rbx
22+
push %r14
23+
subq $0x20, %rsp
24+
movq %rdi, %rcx
25+
b:
26+
jmpq *JUMP_TABLE(,%rcx,8)
27+
# FDATA: 1 _start #b# 1 _start #hotpath# 0 20
28+
# Unreachable direct jump here. Our CFG should still make sense and properly
29+
# place this instruction in a new basic block.
30+
jmp .lbb2
31+
.lbb1: je .lexit
32+
.lbb2:
33+
xorq %rax, %rax
34+
addq $0x20, %rsp
35+
pop %r14
36+
pop %rbx
37+
pop %rbp
38+
ret
39+
hotpath:
40+
movq $2, %rax
41+
addq $0x20, %rsp
42+
pop %r14
43+
pop %rbx
44+
pop %rbp
45+
ret
46+
.lexit:
47+
movq $1, %rax
48+
addq $0x20, %rsp
49+
pop %r14
50+
pop %rbx
51+
pop %rbp
52+
ret
53+
.cfi_endproc
54+
.size _start, .-_start
55+
56+
.rodata
57+
.globl JUMP_TABLE
58+
JUMP_TABLE:
59+
.quad .lbb1
60+
.quad .lbb2
61+
.quad hotpath
62+
63+
# No basic blocks above should have 4 successors! That is a bug.
64+
# CHECK-NOT: Successors: {{.*}} (mispreds: 0, count: 20), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0)
65+
# Check successful removal of stray direct jmp
66+
# CHECK: UCE removed 1 block

clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
267267
{"unordered_set$", "<unordered_set>"},
268268
{"utility$", "<utility>"},
269269
{"valarray$", "<valarray>"},
270+
{"variant$", "<variant>"},
270271
{"vector$", "<vector>"},
271272
{"include/complex.h$", "<complex.h>"},
272273
{"include/ctype.h$", "<cctype>"},

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,48 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Options, bool,
117117
}
118118
}
119119

120+
struct ChecksVariant {
121+
std::optional<std::string> AsString;
122+
std::optional<std::vector<std::string>> AsVector;
123+
};
124+
125+
template <>
126+
void yamlize(IO &IO, ChecksVariant &Checks, bool, EmptyContext &Ctx) {
127+
if (!IO.outputting()) {
128+
// Special case for reading from YAML
129+
// Must support reading from both a string or a list
130+
Input &I = reinterpret_cast<Input &>(IO);
131+
if (isa<ScalarNode, BlockScalarNode>(I.getCurrentNode())) {
132+
Checks.AsString = std::string();
133+
yamlize(IO, *Checks.AsString, true, Ctx);
134+
} else if (isa<SequenceNode>(I.getCurrentNode())) {
135+
Checks.AsVector = std::vector<std::string>();
136+
yamlize(IO, *Checks.AsVector, true, Ctx);
137+
} else {
138+
IO.setError("expected string or sequence");
139+
}
140+
}
141+
}
142+
143+
static void mapChecks(IO &IO, std::optional<std::string> &Checks) {
144+
if (IO.outputting()) {
145+
// Output always a string
146+
IO.mapOptional("Checks", Checks);
147+
} else {
148+
// Input as either a string or a list
149+
ChecksVariant ChecksAsVariant;
150+
IO.mapOptional("Checks", ChecksAsVariant);
151+
if (ChecksAsVariant.AsString)
152+
Checks = ChecksAsVariant.AsString;
153+
else if (ChecksAsVariant.AsVector)
154+
Checks = llvm::join(*ChecksAsVariant.AsVector, ",");
155+
}
156+
}
157+
120158
template <> struct MappingTraits<ClangTidyOptions> {
121159
static void mapping(IO &IO, ClangTidyOptions &Options) {
122160
bool Ignored = false;
123-
IO.mapOptional("Checks", Options.Checks);
161+
mapChecks(IO, Options.Checks);
124162
IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
125163
IO.mapOptional("HeaderFileExtensions", Options.HeaderFileExtensions);
126164
IO.mapOptional("ImplementationFileExtensions",

clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) {
3131
stmt(
3232
anyOf(declStmt(hasDescendant(varDecl(hasInitializer(ThreadID))
3333
.bind("tid_dep_var"))),
34-
binaryOperator(allOf(
34+
binaryOperator(
3535
isAssignmentOperator(), hasRHS(ThreadID),
3636
hasLHS(anyOf(
3737
declRefExpr(to(varDecl().bind("tid_dep_var"))),
3838
memberExpr(member(
39-
fieldDecl().bind("tid_dep_field")))))))))
39+
fieldDecl().bind("tid_dep_field"))))))))
4040
.bind("straight_assignment"))),
4141
this);
4242

clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ void SingleWorkItemBarrierCheck::registerMatchers(MatchFinder *Finder) {
2222
Finder->addMatcher(
2323
// Find function declarations...
2424
functionDecl(
25-
allOf(
26-
// That are OpenCL kernels...
27-
hasAttr(attr::Kind::OpenCLKernel),
28-
// And call a barrier function (either 1.x or 2.x version)...
29-
forEachDescendant(callExpr(callee(functionDecl(hasAnyName(
30-
"barrier", "work_group_barrier"))))
31-
.bind("barrier")),
32-
// But do not call an ID function.
33-
unless(hasDescendant(callExpr(callee(functionDecl(
34-
hasAnyName("get_global_id", "get_local_id", "get_group_id",
35-
"get_local_linear_id"))))))))
25+
// That are OpenCL kernels...
26+
hasAttr(attr::Kind::OpenCLKernel),
27+
// And call a barrier function (either 1.x or 2.x version)...
28+
forEachDescendant(callExpr(callee(functionDecl(hasAnyName(
29+
"barrier", "work_group_barrier"))))
30+
.bind("barrier")),
31+
// But do not call an ID function.
32+
unless(hasDescendant(callExpr(callee(functionDecl(
33+
hasAnyName("get_global_id", "get_local_id", "get_group_id",
34+
"get_local_linear_id")))))))
3635
.bind("function"),
3736
this);
3837
}

clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ UnrollLoopsCheck::UnrollLoopsCheck(StringRef Name, ClangTidyContext *Context)
2525

2626
void UnrollLoopsCheck::registerMatchers(MatchFinder *Finder) {
2727
const auto HasLoopBound = hasDescendant(
28-
varDecl(allOf(matchesName("__end*"),
29-
hasDescendant(integerLiteral().bind("cxx_loop_bound")))));
28+
varDecl(matchesName("__end*"),
29+
hasDescendant(integerLiteral().bind("cxx_loop_bound"))));
3030
const auto CXXForRangeLoop =
3131
cxxForRangeStmt(anyOf(HasLoopBound, unless(HasLoopBound)));
3232
const auto AnyLoop = anyOf(forStmt(), whileStmt(), doStmt(), CXXForRangeLoop);
3333
Finder->addMatcher(
34-
stmt(allOf(AnyLoop, unless(hasDescendant(stmt(AnyLoop))))).bind("loop"),
35-
this);
34+
stmt(AnyLoop, unless(hasDescendant(stmt(AnyLoop)))).bind("loop"), this);
3635
}
3736

3837
void UnrollLoopsCheck::check(const MatchFinder::MatchResult &Result) {

0 commit comments

Comments
 (0)