Skip to content

Commit b7e391d

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3292)
2 parents 295b2c1 + e0e489b commit b7e391d

File tree

156 files changed

+7756
-5668
lines changed

Some content is hidden

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

156 files changed

+7756
-5668
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,10 @@ DataAggregator::getFallthroughsInTrace(BinaryFunction &BF, const Trace &Trace,
906906
if (BF.isPseudo())
907907
return Branches;
908908

909-
if (!BF.isSimple())
909+
// Can only record traces in CFG state
910+
if (!BF.hasCFG())
910911
return std::nullopt;
911912

912-
assert(BF.hasCFG() && "can only record traces in CFG state");
913-
914913
const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(From);
915914
const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset(To);
916915

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -714,21 +714,6 @@ Error RewriteInstance::run() {
714714

715715
preprocessProfileData();
716716

717-
// Skip disassembling if we have a translation table and we are running an
718-
// aggregation job.
719-
if (opts::AggregateOnly && BAT->enabledFor(InputFile)) {
720-
// YAML profile in BAT mode requires CFG for .bolt.org.text functions
721-
if (!opts::SaveProfile.empty() ||
722-
opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML) {
723-
selectFunctionsToProcess();
724-
disassembleFunctions();
725-
processMetadataPreCFG();
726-
buildFunctionsCFG();
727-
}
728-
processProfileData();
729-
return Error::success();
730-
}
731-
732717
selectFunctionsToProcess();
733718

734719
readDebugInfo();

bolt/test/X86/unclaimed-jt-entries.s

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818

1919
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
2020
# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
21+
22+
## Check that non-simple function profile is emitted in perf2bolt mode
23+
# RUN: link_fdata %s %t.exe %t.pa PREAGG
24+
# RUN: llvm-strip -N L5 -N L5_ret %t.exe
25+
# RUN: perf2bolt %t.exe -p %t.pa --pa -o %t.fdata -strict=0 -print-profile \
26+
# RUN: -print-only=main | FileCheck %s --check-prefix=CHECK-P2B
27+
# CHECK-P2B: PERF2BOLT: traces mismatching disassembled function contents: 0
28+
# CHECK-P2B: Binary Function "main"
29+
# CHECK-P2B: IsSimple : 0
30+
# RUN: FileCheck %s --input-file %t.fdata --check-prefix=CHECK-FDATA
31+
# CHECK-FDATA: 1 main 0 1 main 7 0 1
32+
2133
# RUN: llvm-bolt %t.exe -v=1 -o %t.out 2>&1 | FileCheck %s
2234

2335
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
@@ -33,8 +45,10 @@
3345
.size main, .Lend-main
3446
main:
3547
jmp *L4-24(,%rdi,8)
36-
.L5:
48+
# PREAGG: T #main# #L5# #L5_ret# 1
49+
L5:
3750
movl $4, %eax
51+
L5_ret:
3852
ret
3953
.L9:
4054
movl $2, %eax
@@ -58,7 +72,7 @@ L4:
5872
.quad .L3
5973
.quad .L6
6074
.quad .L3
61-
.quad .L5
75+
.quad L5
6276
.quad .L3
6377
.quad .L3
6478
.quad .L3

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,27 @@ serializeLocation(const Location &Loc,
8383
return LocationObj;
8484
}
8585

86-
static json::Value serializeComment(const CommentInfo &I) {
86+
static void insertComment(Object &Description, json::Value &Comment,
87+
StringRef Key) {
88+
auto DescriptionIt = Description.find(Key);
89+
90+
if (DescriptionIt == Description.end()) {
91+
auto CommentsArray = json::Array();
92+
CommentsArray.push_back(Comment);
93+
Description[Key] = std::move(CommentsArray);
94+
Description["Has" + Key.str()] = true;
95+
} else {
96+
DescriptionIt->getSecond().getAsArray()->push_back(Comment);
97+
}
98+
}
99+
100+
static json::Value extractTextComments(Object *ParagraphComment) {
101+
if (!ParagraphComment)
102+
return json::Object();
103+
return *ParagraphComment->get("Children");
104+
}
105+
106+
static Object serializeComment(const CommentInfo &I, Object &Description) {
87107
// taken from PR #142273
88108
Object Obj = Object();
89109

@@ -94,7 +114,7 @@ static json::Value serializeComment(const CommentInfo &I) {
94114
auto &CARef = *ChildArr.getAsArray();
95115
CARef.reserve(I.Children.size());
96116
for (const auto &C : I.Children)
97-
CARef.emplace_back(serializeComment(*C));
117+
CARef.emplace_back(serializeComment(*C, Description));
98118

99119
switch (I.Kind) {
100120
case CommentKind::CK_TextComment: {
@@ -103,9 +123,9 @@ static json::Value serializeComment(const CommentInfo &I) {
103123
}
104124

105125
case CommentKind::CK_BlockCommandComment: {
106-
Child.insert({"Command", I.Name});
107-
Child.insert({"Children", ChildArr});
108-
Obj.insert({commentKindToString(I.Kind), ChildVal});
126+
auto TextCommentsArray = extractTextComments(CARef.front().getAsObject());
127+
if (I.Name == "brief")
128+
insertComment(Description, TextCommentsArray, "BriefComments");
109129
return Obj;
110130
}
111131

@@ -137,7 +157,10 @@ static json::Value serializeComment(const CommentInfo &I) {
137157
if (!I.CloseName.empty())
138158
Child.insert({"CloseName", I.CloseName});
139159
Child.insert({"Children", ChildArr});
140-
Obj.insert({commentKindToString(I.Kind), ChildVal});
160+
if (I.CloseName == "endcode")
161+
insertComment(Description, ChildVal, "CodeComments");
162+
else if (I.CloseName == "endverbatim")
163+
insertComment(Description, ChildVal, "VerbatimComments");
141164
return Obj;
142165
}
143166

@@ -179,8 +202,8 @@ static json::Value serializeComment(const CommentInfo &I) {
179202
case CommentKind::CK_FullComment:
180203
case CommentKind::CK_ParagraphComment: {
181204
Child.insert({"Children", ChildArr});
182-
Obj.insert({commentKindToString(I.Kind), ChildVal});
183-
return Obj;
205+
Child["ParagraphComment"] = true;
206+
return Child;
184207
}
185208

186209
case CommentKind::CK_Unknown: {
@@ -210,12 +233,20 @@ serializeCommonAttributes(const Info &I, json::Object &Obj,
210233
}
211234

212235
if (!I.Description.empty()) {
213-
json::Value DescArray = json::Array();
214-
auto &DescArrayRef = *DescArray.getAsArray();
215-
DescArrayRef.reserve(I.Description.size());
216-
for (const auto &Comment : I.Description)
217-
DescArrayRef.push_back(serializeComment(Comment));
218-
Obj["Description"] = DescArray;
236+
Object Description = Object();
237+
// Skip straight to the FullComment's children
238+
auto &Comments = I.Description.at(0).Children;
239+
for (const auto &CommentInfo : Comments) {
240+
json::Value Comment = serializeComment(*CommentInfo, Description);
241+
// if a ParagraphComment is returned, then it is a top-level comment that
242+
// needs to be inserted manually.
243+
if (auto *ParagraphComment = Comment.getAsObject();
244+
ParagraphComment->get("ParagraphComment")) {
245+
auto TextCommentsArray = extractTextComments(ParagraphComment);
246+
insertComment(Description, TextCommentsArray, "ParagraphComments");
247+
}
248+
}
249+
Obj["Description"] = std::move(Description);
219250
}
220251

221252
// Namespaces aren't SymbolInfos, so they dont have a DefLoc

clang-tools-extra/clang-doc/assets/class-template.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@
128128
<section class="hero section-container">
129129
<div class="hero__title">
130130
<h1 class="hero__title-large">{{TagType}} {{Name}}</h1>
131-
{{#RecordComments}}
131+
{{#Description}}
132132
<div class="hero__subtitle">
133133
{{>Comments}}
134134
</div>
135-
{{/RecordComments}}
135+
{{/Description}}
136136
</div>
137137
</section>
138138
{{#HasPublicMembers}}

clang-tools-extra/clang-doc/assets/comment-template.mustache

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
66
This file defines templates for generating comments
77
}}
8-
{{#FullComment}}
9-
{{#Children}}
10-
{{>Comments}}
11-
{{/Children}}
12-
{{/FullComment}}
8+
{{#BriefComments}}
9+
<div>
10+
{{#.}}
11+
<p>{{TextComment}}</p>
12+
{{/.}}
13+
</div>
14+
{{/BriefComments}}
15+
{{#ParagraphComments}}
16+
<div>
17+
{{#.}}
18+
<p>{{TextComment}}</p>
19+
{{/.}}
20+
</div>
21+
{{/ParagraphComments}}
1322
{{#ParagraphComment}}
1423
{{#Children}}
1524
{{>Comments}}

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,11 +1279,9 @@ void ClangdLSPServer::onHover(const TextDocumentPositionParams &Params,
12791279
R.contents.kind = HoverContentFormat;
12801280
R.range = (*H)->SymRange;
12811281
switch (HoverContentFormat) {
1282-
case MarkupKind::PlainText:
1283-
R.contents.value = (*H)->present().asPlainText();
1284-
return Reply(std::move(R));
12851282
case MarkupKind::Markdown:
1286-
R.contents.value = (*H)->present().asMarkdown();
1283+
case MarkupKind::PlainText:
1284+
R.contents.value = (*H)->present(HoverContentFormat);
12871285
return Reply(std::move(R));
12881286
};
12891287
llvm_unreachable("unhandled MarkupKind");

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ MarkupContent renderDoc(const markup::Document &Doc, MarkupKind Kind) {
193193
Result.value.append(Doc.asPlainText());
194194
break;
195195
case MarkupKind::Markdown:
196-
Result.value.append(Doc.asMarkdown());
196+
if (Config::current().Documentation.CommentFormat ==
197+
Config::CommentFormatPolicy::PlainText)
198+
Result.value.append(Doc.asEscapedMarkdown());
199+
else
200+
Result.value.append(Doc.asMarkdown());
197201
break;
198202
}
199203
return Result;

clang-tools-extra/clangd/Config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ struct Config {
196196
/// Controls highlighting modifiers that are disabled.
197197
std::vector<std::string> DisabledModifiers;
198198
} SemanticTokens;
199+
200+
enum class CommentFormatPolicy {
201+
/// Treat comments as plain text.
202+
PlainText,
203+
/// Treat comments as Markdown.
204+
Markdown,
205+
/// Treat comments as doxygen.
206+
Doxygen,
207+
};
208+
209+
struct {
210+
CommentFormatPolicy CommentFormat = CommentFormatPolicy::PlainText;
211+
} Documentation;
199212
};
200213

201214
} // namespace clangd

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct FragmentCompiler {
198198
compile(std::move(F.InlayHints));
199199
compile(std::move(F.SemanticTokens));
200200
compile(std::move(F.Style));
201+
compile(std::move(F.Documentation));
201202
}
202203

203204
void compile(Fragment::IfBlock &&F) {
@@ -793,6 +794,21 @@ struct FragmentCompiler {
793794
}
794795
}
795796

797+
void compile(Fragment::DocumentationBlock &&F) {
798+
if (F.CommentFormat) {
799+
if (auto Val =
800+
compileEnum<Config::CommentFormatPolicy>("CommentFormat",
801+
*F.CommentFormat)
802+
.map("Plaintext", Config::CommentFormatPolicy::PlainText)
803+
.map("Markdown", Config::CommentFormatPolicy::Markdown)
804+
.map("Doxygen", Config::CommentFormatPolicy::Doxygen)
805+
.value())
806+
Out.Apply.push_back([Val](const Params &, Config &C) {
807+
C.Documentation.CommentFormat = *Val;
808+
});
809+
}
810+
}
811+
796812
constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
797813
constexpr static llvm::SourceMgr::DiagKind Warning =
798814
llvm::SourceMgr::DK_Warning;

0 commit comments

Comments
 (0)