Skip to content

Commit 5f484c1

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:68bcba6d7a1c into amd-gfx:fe02a5576f8e
Local branch amd-gfx fe02a55 Merged main:384562495bae into amd-gfx:401ed9d8228d Remote branch main 68bcba6 Revert "[AMDGPU] Use COV6 by default (llvm#118515)"
2 parents fe02a55 + 68bcba6 commit 5f484c1

File tree

293 files changed

+7262
-13573
lines changed

Some content is hidden

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

293 files changed

+7262
-13573
lines changed

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
4646
if (BF.isIgnored())
4747
continue;
4848

49+
MCInst &FirstInstruction = *(BF.begin()->begin());
4950
const MCSymbol *VeneerTargetSymbol = 0;
5051
uint64_t TargetAddress;
51-
if (BC.MIB->matchAbsLongVeneer(BF, TargetAddress)) {
52+
if (BC.MIB->isTailCall(FirstInstruction)) {
53+
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction);
54+
} else if (BC.MIB->matchAbsLongVeneer(BF, TargetAddress)) {
5255
if (BinaryFunction *TargetBF =
5356
BC.getBinaryFunctionAtAddress(TargetAddress))
5457
VeneerTargetSymbol = TargetBF->getSymbol();
55-
} else {
56-
MCInst &FirstInstruction = *(BF.begin()->begin());
57-
if (BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer"))
58-
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
58+
} else if (BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer")) {
59+
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
5960
}
6061

6162
if (!VeneerTargetSymbol)

bolt/test/AArch64/veneer-lld-abs.s

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
## Check that llvm-bolt correctly recognizes long absolute thunks generated
2-
## by LLD.
1+
## Check that llvm-bolt correctly recognizes veneers/thunks for absolute code
2+
## generated by LLD.
33

44
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
55
# RUN: %clang %cflags -fno-PIC -no-pie %t.o -o %t.exe -nostdlib \
@@ -12,40 +12,63 @@
1212

1313
.text
1414
.balign 4
15-
.global foo
16-
.type foo, %function
17-
foo:
18-
adrp x1, foo
15+
.global far_function
16+
.type far_function, %function
17+
far_function:
1918
ret
20-
.size foo, .-foo
19+
.size far_function, .-far_function
20+
21+
.global near_function
22+
.type near_function, %function
23+
near_function:
24+
ret
25+
.size near_function, .-near_function
26+
27+
## Force relocations against .text.
28+
.reloc 0, R_AARCH64_NONE
2129

2230
.section ".mytext", "ax"
2331
.balign 4
2432

25-
.global __AArch64AbsLongThunk_foo
26-
.type __AArch64AbsLongThunk_foo, %function
27-
__AArch64AbsLongThunk_foo:
33+
## This version of a thunk is always generated by LLD for function calls
34+
## spanning more than 256MB.
35+
.global __AArch64AbsLongThunk_far_function
36+
.type __AArch64AbsLongThunk_far_function, %function
37+
__AArch64AbsLongThunk_far_function:
2838
ldr x16, .L1
2939
br x16
30-
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_foo>:
40+
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_far_function>:
3141
# CHECK-INPUT-NEXT: ldr
3242
# CHECK-INPUT-NEXT: br
3343
.L1:
34-
.quad foo
35-
.size __AArch64AbsLongThunk_foo, .-__AArch64AbsLongThunk_foo
44+
.quad far_function
45+
.size __AArch64AbsLongThunk_far_function, .-__AArch64AbsLongThunk_far_function
46+
47+
## If a callee is closer than 256MB away, LLD may generate a thunk with a direct
48+
## jump to the callee. Note, that the name might still include "AbsLong".
49+
.global __AArch64AbsLongThunk_near_function
50+
.type __AArch64AbsLongThunk_near_function, %function
51+
__AArch64AbsLongThunk_near_function:
52+
b near_function
53+
# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_near_function>:
54+
# CHECK-INPUT-NEXT: b {{.*}} <near_function>
55+
.size __AArch64AbsLongThunk_near_function, .-__AArch64AbsLongThunk_near_function
3656

37-
## Check that the thunk was removed from .text and _start() calls foo()
57+
## Check that thunks were removed from .text, and _start calls functions
3858
## directly.
3959

40-
# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_foo
60+
# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_{{.*}}
4161

4262
.global _start
4363
.type _start, %function
4464
_start:
4565
# CHECK-INPUT-LABEL: <_start>:
4666
# CHECK-OUTPUT-LABEL: <_start>:
47-
bl __AArch64AbsLongThunk_foo
48-
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_foo>
49-
# CHECK-OUTPUT-NEXT: bl {{.*}} <foo>
67+
bl __AArch64AbsLongThunk_far_function
68+
bl __AArch64AbsLongThunk_near_function
69+
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_far_function>
70+
# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_near_function>
71+
# CHECK-OUTPUT-NEXT: bl {{.*}} <far_function>
72+
# CHECK-OUTPUT-NEXT: bl {{.*}} <near_function>
5073
ret
5174
.size _start, .-_start

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
935935
and [Non-trapping float-to-int Conversions] language features, which are
936936
[widely implemented in engines].
937937

938+
A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition of
939+
the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
940+
-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
941+
and -mextended-const.
942+
938943
[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
939944
[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
940945
[widely implemented in engines]: https://webassembly.org/features/
946+
[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
941947

942948
AVR Support
943949
^^^^^^^^^^^
@@ -975,6 +981,10 @@ AST Matchers
975981

976982
- Add ``exportDecl`` matcher to match export declaration.
977983

984+
- Ensure ``hasType`` and ``hasDeclaration`` match Objective-C interface declarations.
985+
986+
- Ensure ``pointee`` matches Objective-C pointer types.
987+
978988
clang-format
979989
------------
980990

clang/docs/tools/dump_ast_matchers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import collections
77
import re
8+
import os
89

910
try:
1011
from urllib.request import urlopen
@@ -18,7 +19,11 @@
1819
CLASS_INDEX_PAGE = None
1920
print("Unable to get %s: %s" % (CLASS_INDEX_PAGE_URL, e))
2021

21-
MATCHERS_FILE = "../../include/clang/ASTMatchers/ASTMatchers.h"
22+
CURRENT_DIR = os.path.dirname(__file__)
23+
MATCHERS_FILE = os.path.join(
24+
CURRENT_DIR, "../../include/clang/ASTMatchers/ASTMatchers.h"
25+
)
26+
HTML_FILE = os.path.join(CURRENT_DIR, "../LibASTMatchersReference.html")
2227

2328
# Each matcher is documented in one row of the form:
2429
# result | name | argA
@@ -590,7 +595,7 @@ def sort_table(matcher_type, matcher_map):
590595
narrowing_matcher_table = sort_table("NARROWING", narrowing_matchers)
591596
traversal_matcher_table = sort_table("TRAVERSAL", traversal_matchers)
592597

593-
reference = open("../LibASTMatchersReference.html").read()
598+
reference = open(HTML_FILE).read()
594599
reference = re.sub(
595600
r"<!-- START_DECL_MATCHERS.*END_DECL_MATCHERS -->",
596601
node_matcher_table,

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,7 +4044,7 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
40444044
AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
40454045
hasType,
40464046
AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
4047-
CXXBaseSpecifier),
4047+
CXXBaseSpecifier, ObjCInterfaceDecl),
40484048
internal::Matcher<Decl>, InnerMatcher, 1) {
40494049
QualType QT = internal::getUnderlyingType(Node);
40504050
if (!QT.isNull())
@@ -7445,7 +7445,8 @@ extern const AstTypeMatcher<RValueReferenceType> rValueReferenceType;
74457445
AST_TYPELOC_TRAVERSE_MATCHER_DECL(
74467446
pointee, getPointee,
74477447
AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
7448-
PointerType, ReferenceType));
7448+
PointerType, ReferenceType,
7449+
ObjCObjectPointerType));
74497450

74507451
/// Matches typedef types.
74517452
///

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ inline QualType getUnderlyingType(const FriendDecl &Node) {
161161
inline QualType getUnderlyingType(const CXXBaseSpecifier &Node) {
162162
return Node.getType();
163163
}
164+
inline QualType getUnderlyingType(const ObjCInterfaceDecl &Node) {
165+
return Node.getTypeForDecl()->getPointeeType();
166+
}
164167

165168
/// Unifies obtaining a `TypeSourceInfo` from different node types.
166169
template <typename T,
@@ -1113,6 +1116,11 @@ class HasDeclarationMatcher : public MatcherInterface<T> {
11131116
return matchesDecl(Node.getDecl(), Finder, Builder);
11141117
}
11151118

1119+
bool matchesSpecialized(const ObjCInterfaceDecl &Node, ASTMatchFinder *Finder,
1120+
BoundNodesTreeBuilder *Builder) const {
1121+
return matchesDecl(Node.getCanonicalDecl(), Finder, Builder);
1122+
}
1123+
11161124
/// Extracts the operator new of the new call and returns whether the
11171125
/// inner matcher matches on it.
11181126
bool matchesSpecialized(const CXXNewExpr &Node,
@@ -1213,7 +1221,7 @@ using HasDeclarationSupportedTypes =
12131221
ElaboratedType, InjectedClassNameType, LabelStmt, AddrLabelExpr,
12141222
MemberExpr, QualType, RecordType, TagType,
12151223
TemplateSpecializationType, TemplateTypeParmType, TypedefType,
1216-
UnresolvedUsingType, ObjCIvarRefExpr>;
1224+
UnresolvedUsingType, ObjCIvarRefExpr, ObjCInterfaceDecl>;
12171225

12181226
/// A Matcher that allows binding the node it matches to an id.
12191227
///

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,13 @@ def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>;
294294
// Name of this warning in GCC.
295295
def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>;
296296

297+
def VariadicMacroArgumentsOmitted : DiagGroup<"variadic-macro-arguments-omitted">;
298+
297299
// Warnings for C code which is not compatible with previous C standards.
298300
def CPre11Compat : DiagGroup<"pre-c11-compat">;
299301
def CPre11CompatPedantic : DiagGroup<"pre-c11-compat-pedantic",
300302
[CPre11Compat]>;
301-
def CPre23Compat : DiagGroup<"pre-c23-compat">;
303+
def CPre23Compat : DiagGroup<"pre-c23-compat", [VariadicMacroArgumentsOmitted]>;
302304
def CPre23CompatPedantic : DiagGroup<"pre-c23-compat-pedantic",
303305
[CPre23Compat]>;
304306
def : DiagGroup<"pre-c2x-compat", [CPre23Compat]>;
@@ -906,7 +908,7 @@ def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
906908
def Visibility : DiagGroup<"visibility">;
907909
def ZeroLengthArray : DiagGroup<"zero-length-array">;
908910
def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
909-
def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">;
911+
def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments", [VariadicMacroArgumentsOmitted]>;
910912
def MisleadingIndentation : DiagGroup<"misleading-indentation">;
911913
def PtrAuthNullPointers : DiagGroup<"ptrauth-null-pointers">;
912914

@@ -1199,7 +1201,7 @@ def CXX17 : DiagGroup<"c++17-extensions", [CXX17Attrs]>;
11991201

12001202
// A warning group for warnings about using C++20 features as extensions in
12011203
// earlier C++ versions.
1202-
def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator, CXX20Attrs]>;
1204+
def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator, CXX20Attrs, VariadicMacroArgumentsOmitted]>;
12031205

12041206
// A warning group for warnings about using C++23 features as extensions in
12051207
// earlier C++ versions.
@@ -1226,7 +1228,7 @@ def C11 : DiagGroup<"c11-extensions">;
12261228
def C99 : DiagGroup<"c99-extensions", [C99Designator]>;
12271229

12281230
// A warning group for warnings about using C23 features as extensions.
1229-
def C23 : DiagGroup<"c23-extensions">;
1231+
def C23 : DiagGroup<"c23-extensions", [VariadicMacroArgumentsOmitted]>;
12301232

12311233
def : DiagGroup<"c2x-extensions", [C23]>;
12321234

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,14 @@ def ext_embedded_directive : Extension<
486486
InGroup<DiagGroup<"embedded-directive">>;
487487
def ext_c_missing_varargs_arg : Extension<
488488
"passing no argument for the '...' parameter of a variadic macro is "
489-
"a C23 extension">, InGroup<C23>;
489+
"a C23 extension">, InGroup<VariadicMacroArgumentsOmitted>;
490490
def ext_cxx_missing_varargs_arg : Extension<
491491
"passing no argument for the '...' parameter of a variadic macro is "
492-
"a C++20 extension">, InGroup<CXX20>;
492+
"a C++20 extension">, InGroup<VariadicMacroArgumentsOmitted>;
493493
def warn_c17_compat_missing_varargs_arg : Warning<
494494
"passing no argument for the '...' parameter of a variadic macro is "
495495
"incompatible with C standards before C23">,
496-
InGroup<CPre23Compat>, DefaultIgnore;
496+
InGroup<VariadicMacroArgumentsOmitted>, DefaultIgnore;
497497
def warn_cxx17_compat_missing_varargs_arg : Warning<
498498
"passing no argument for the '...' parameter of a variadic macro is "
499499
"incompatible with C++ standards before C++20">,

clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,8 @@ AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasValueType,
11141114
AST_TYPELOC_TRAVERSE_MATCHER_DEF(
11151115
pointee,
11161116
AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
1117-
PointerType, ReferenceType));
1117+
PointerType, ReferenceType,
1118+
ObjCObjectPointerType));
11181119

11191120
const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective>
11201121
ompExecutableDirective;

clang/lib/ASTMatchers/Dynamic/Registry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ RegistryMaps::RegistryMaps() {
243243
REGISTER_MATCHER(equalsBoundNode);
244244
REGISTER_MATCHER(equalsIntegralValue);
245245
REGISTER_MATCHER(explicitCastExpr);
246+
REGISTER_MATCHER(exportDecl);
246247
REGISTER_MATCHER(expr);
247248
REGISTER_MATCHER(exprWithCleanups);
248249
REGISTER_MATCHER(fieldDecl);

clang/lib/Basic/Targets/WebAssembly.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static constexpr Builtin::Info BuiltinInfo[] = {
3131
};
3232

3333
static constexpr llvm::StringLiteral ValidCPUNames[] = {
34-
{"mvp"}, {"bleeding-edge"}, {"generic"}};
34+
{"mvp"}, {"bleeding-edge"}, {"generic"}, {"lime"}};
3535

3636
StringRef WebAssemblyTargetInfo::getABI() const { return ABI; }
3737

@@ -167,6 +167,17 @@ bool WebAssemblyTargetInfo::initFeatureMap(
167167
Features["reference-types"] = true;
168168
Features["sign-ext"] = true;
169169
};
170+
auto addLime1Features = [&]() {
171+
// Lime1:
172+
// <https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1>
173+
Features["bulk-memory-opt"] = true;
174+
Features["call-indirect-overlong"] = true;
175+
Features["extended-const"] = true;
176+
Features["multivalue"] = true;
177+
Features["mutable-globals"] = true;
178+
Features["nontrapping-fptoint"] = true;
179+
Features["sign-ext"] = true;
180+
};
170181
auto addBleedingEdgeFeatures = [&]() {
171182
addGenericFeatures();
172183
Features["atomics"] = true;
@@ -180,6 +191,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
180191
};
181192
if (CPU == "generic") {
182193
addGenericFeatures();
194+
} else if (CPU == "lime1") {
195+
addLime1Features();
183196
} else if (CPU == "bleeding-edge") {
184197
addBleedingEdgeFeatures();
185198
}

clang/lib/Basic/Targets/X86.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
11621162
.Case("pconfig", true)
11631163
.Case("pku", true)
11641164
.Case("popcnt", true)
1165+
.Case("prefer-256-bit", true)
11651166
.Case("prefetchi", true)
11661167
.Case("prfchw", true)
11671168
.Case("ptwrite", true)

clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ class MallocSizeofChecker : public Checker<check::ASTCodeBody> {
211211
continue;
212212

213213
const TypeSourceInfo *TSI = nullptr;
214-
if (CallRec.CastedExprParent.is<const VarDecl *>()) {
215-
TSI = CallRec.CastedExprParent.get<const VarDecl *>()
216-
->getTypeSourceInfo();
214+
if (const auto *VD =
215+
dyn_cast<const VarDecl *>(CallRec.CastedExprParent)) {
216+
TSI = VD->getTypeSourceInfo();
217217
} else {
218218
TSI = CallRec.ExplicitCastType;
219219
}

clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ const PointerToMemberData *BasicValueFactory::accumCXXBase(
196196
const NamedDecl *ND = nullptr;
197197
llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList;
198198

199-
if (PTMDT.isNull() || PTMDT.is<const NamedDecl *>()) {
200-
if (PTMDT.is<const NamedDecl *>())
201-
ND = PTMDT.get<const NamedDecl *>();
199+
if (PTMDT.isNull() || isa<const NamedDecl *>(PTMDT)) {
200+
if (const auto *NDP = dyn_cast_if_present<const NamedDecl *>(PTMDT))
201+
ND = NDP;
202202

203203
BaseSpecList = CXXBaseListFactory.getEmptyList();
204204
} else {
205-
const PointerToMemberData *PTMD = PTMDT.get<const PointerToMemberData *>();
205+
const auto *PTMD = cast<const PointerToMemberData *>(PTMDT);
206206
ND = PTMD->getDeclaratorDecl();
207207

208208
BaseSpecList = PTMD->getCXXBaseList();

0 commit comments

Comments
 (0)