Skip to content

Commit 8d008b6

Browse files
committed
Merge remote-tracking branch 'intel_llvm/sycl-web' into llvmspirv_pulldown
2 parents e83e16d + 16592a3 commit 8d008b6

File tree

859 files changed

+34419
-17578
lines changed

Some content is hidden

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

859 files changed

+34419
-17578
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/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-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) {

clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ namespace clang::tidy::bugprone {
1818

1919
void BadSignalToKillThreadCheck::registerMatchers(MatchFinder *Finder) {
2020
Finder->addMatcher(
21-
callExpr(allOf(callee(functionDecl(hasName("::pthread_kill"))),
22-
argumentCountIs(2)),
21+
callExpr(callee(functionDecl(hasName("::pthread_kill"))),
22+
argumentCountIs(2),
2323
hasArgument(1, integerLiteral().bind("integer-literal")))
2424
.bind("thread-kill"),
2525
this);

clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ AST_MATCHER_P(Expr, hasDefinition, ast_matchers::internal::Matcher<Expr>,
528528

529529
const char *const VarDeclName = "variable-declaration";
530530
auto DREHasDefinition = ignoringImpCasts(declRefExpr(
531-
allOf(to(varDecl().bind(VarDeclName)),
532-
hasAncestor(compoundStmt(hasDescendant(binaryOperator(
533-
hasLHS(declRefExpr(to(varDecl(equalsBoundNode(VarDeclName))))),
534-
hasRHS(ignoringImpCasts(InnerMatcher)))))))));
531+
to(varDecl().bind(VarDeclName)),
532+
hasAncestor(compoundStmt(hasDescendant(binaryOperator(
533+
hasLHS(declRefExpr(to(varDecl(equalsBoundNode(VarDeclName))))),
534+
hasRHS(ignoringImpCasts(InnerMatcher))))))));
535535

536536
if (DREHasDefinition.matches(*SimpleNode, Finder, Builder))
537537
return true;
@@ -581,9 +581,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
581581

582582
// - Example: std::string str = "foo"; str.size();
583583
auto SizeOrLength =
584-
cxxMemberCallExpr(
585-
allOf(on(expr(AnyOfStringTy).bind("Foo")),
586-
has(memberExpr(member(hasAnyName("size", "length"))))))
584+
cxxMemberCallExpr(on(expr(AnyOfStringTy).bind("Foo")),
585+
has(memberExpr(member(hasAnyName("size", "length")))))
587586
.bind(WrongLengthExprName);
588587

589588
// - Example: char src[] = "foo"; sizeof(src);
@@ -641,8 +640,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
641640

642641
// - Example: foo[bar[baz]].qux; (or just ParmVarDecl)
643642
auto DestUnknownDecl =
644-
declRefExpr(allOf(to(varDecl(AnyOfCharTy).bind(DestVarDeclName)),
645-
expr().bind(UnknownDestName)))
643+
declRefExpr(to(varDecl(AnyOfCharTy).bind(DestVarDeclName)),
644+
expr().bind(UnknownDestName))
646645
.bind(DestExprName);
647646

648647
auto AnyOfDestDecl = ignoringImpCasts(
@@ -659,10 +658,10 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
659658
hasRHS(ignoringImpCasts(
660659
anyOf(characterLiteral(equals(0U)), integerLiteral(equals(0))))));
661660

662-
auto SrcDecl = declRefExpr(
663-
allOf(to(decl().bind(SrcVarDeclName)),
664-
anyOf(hasAncestor(cxxMemberCallExpr().bind(SrcExprName)),
665-
expr().bind(SrcExprName))));
661+
auto SrcDecl =
662+
declRefExpr(to(decl().bind(SrcVarDeclName)),
663+
anyOf(hasAncestor(cxxMemberCallExpr().bind(SrcExprName)),
664+
expr().bind(SrcExprName)));
666665

667666
auto AnyOfSrcDecl =
668667
ignoringImpCasts(anyOf(stringLiteral().bind(SrcExprName),

clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,29 @@ void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {
2525

2626
auto HasWaitDescendantCpp = hasDescendant(
2727
cxxMemberCallExpr(
28-
anyOf(
29-
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
30-
allOf(hasName("::std::condition_variable::wait"),
31-
parameterCountIs(1)))))),
32-
onImplicitObjectArgument(
33-
declRefExpr(to(varDecl(hasType(references(recordDecl(
34-
hasName("::std::condition_variable")))))))),
35-
HasUniqueLock),
36-
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
37-
allOf(hasName("::std::condition_variable::wait_for"),
38-
parameterCountIs(2)))))),
39-
onImplicitObjectArgument(
40-
declRefExpr(to(varDecl(hasType(references(recordDecl(
41-
hasName("::std::condition_variable")))))))),
42-
HasUniqueLock),
43-
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
44-
allOf(hasName("::std::condition_variable::wait_until"),
45-
parameterCountIs(2)))))),
46-
onImplicitObjectArgument(
47-
declRefExpr(to(varDecl(hasType(references(recordDecl(
48-
hasName("::std::condition_variable")))))))),
49-
HasUniqueLock)
28+
anyOf(allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
29+
hasName("::std::condition_variable::wait"),
30+
parameterCountIs(1))))),
31+
onImplicitObjectArgument(
32+
declRefExpr(to(varDecl(hasType(references(recordDecl(
33+
hasName("::std::condition_variable")))))))),
34+
HasUniqueLock),
35+
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
36+
hasName("::std::condition_variable::wait_for"),
37+
parameterCountIs(2))))),
38+
onImplicitObjectArgument(
39+
declRefExpr(to(varDecl(hasType(references(recordDecl(
40+
hasName("::std::condition_variable")))))))),
41+
HasUniqueLock),
42+
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
43+
hasName("::std::condition_variable::wait_until"),
44+
parameterCountIs(2))))),
45+
onImplicitObjectArgument(
46+
declRefExpr(to(varDecl(hasType(references(recordDecl(
47+
hasName("::std::condition_variable")))))))),
48+
HasUniqueLock)
5049

51-
))
50+
))
5251
.bind("wait"));
5352

5453
auto HasWaitDescendantC = hasDescendant(

clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ static std::optional<uint64_t> tryEvaluateSizeExpr(const Expr *SizeExpr,
2626

2727
void SuspiciousMemoryComparisonCheck::registerMatchers(MatchFinder *Finder) {
2828
Finder->addMatcher(
29-
callExpr(allOf(callee(namedDecl(
30-
anyOf(hasName("::memcmp"), hasName("::std::memcmp")))),
31-
unless(isInstantiationDependent())))
29+
callExpr(callee(namedDecl(
30+
anyOf(hasName("::memcmp"), hasName("::std::memcmp")))),
31+
unless(isInstantiationDependent()))
3232
.bind("call"),
3333
this);
3434
}

clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void NonTrivialTypesLibcMemoryCallsCheck::registerMatchers(
7272
return expr(unaryOperator(
7373
hasOperatorName("&"),
7474
hasUnaryOperand(declRefExpr(
75-
allOf(hasType(cxxRecordDecl(Constraint)),
76-
hasType(Bind ? qualType().bind("Record") : qualType()))))));
75+
hasType(cxxRecordDecl(Constraint)),
76+
hasType(Bind ? qualType().bind("Record") : qualType())))));
7777
};
7878
auto IsRecordSizeOf =
7979
expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record"))));

clang-tools-extra/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ namespace clang::tidy::concurrency {
1818
void ThreadCanceltypeAsynchronousCheck::registerMatchers(MatchFinder *Finder) {
1919
Finder->addMatcher(
2020
callExpr(
21-
allOf(callee(functionDecl(hasName("::pthread_setcanceltype"))),
22-
argumentCountIs(2)),
21+
callee(functionDecl(hasName("::pthread_setcanceltype"))),
22+
argumentCountIs(2),
2323
hasArgument(0, isExpandedFromMacro("PTHREAD_CANCEL_ASYNCHRONOUS")))
2424
.bind("setcanceltype"),
2525
this);

clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) {
123123
// Matching on initialization operations where the initial value is a newly
124124
// created owner, but the LHS is not an owner.
125125
Finder->addMatcher(
126-
traverse(TK_AsIs, namedDecl(varDecl(allOf(hasInitializer(CreatesOwner),
127-
unless(IsOwnerType)))
126+
traverse(TK_AsIs, namedDecl(varDecl(hasInitializer(CreatesOwner),
127+
unless(IsOwnerType))
128128
.bind("bad_owner_creation_variable"))),
129129
this);
130130

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
5959
unless(hasParentIgnoringImpCasts(explicitCastExpr())),
6060
unless(isInsideOfRangeBeginEndStmt()),
6161
unless(hasSourceExpression(ignoringParens(stringLiteral()))),
62-
unless(hasSourceExpression(ignoringParens(conditionalOperator(
63-
allOf(hasTrueExpression(stringLiteral()),
64-
hasFalseExpression(stringLiteral())))))))
62+
unless(hasSourceExpression(ignoringParens(
63+
conditionalOperator(hasTrueExpression(stringLiteral()),
64+
hasFalseExpression(stringLiteral()))))))
6565
.bind("cast")),
6666
this);
6767
}

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
8787

8888
void MultipleInheritanceCheck::registerMatchers(MatchFinder *Finder) {
8989
// Match declarations which have bases.
90-
Finder->addMatcher(
91-
cxxRecordDecl(allOf(hasBases(), isDefinition())).bind("decl"), this);
90+
Finder->addMatcher(cxxRecordDecl(hasBases(), isDefinition()).bind("decl"),
91+
this);
9292
}
9393

9494
void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {

0 commit comments

Comments
 (0)