Skip to content

Commit 5a7faf6

Browse files
authored
Merge branch 'main' into main
2 parents 459fc12 + dc8f2f0 commit 5a7faf6

File tree

1,802 files changed

+67324
-56142
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,802 files changed

+67324
-56142
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,10 @@ BinaryContext::createInstructionPatch(uint64_t Address,
24252425

24262426
std::pair<size_t, size_t>
24272427
BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
2428+
// Use the original size for non-simple functions.
2429+
if (!BF.isSimple() || BF.isIgnored())
2430+
return std::make_pair(BF.getSize(), 0);
2431+
24282432
// Adjust branch instruction to match the current layout.
24292433
if (FixBranches)
24302434
BF.fixBranches();

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,8 @@ bool BinaryFunction::validateCFG() const {
35793579
}
35803580

35813581
void BinaryFunction::fixBranches() {
3582+
assert(isSimple() && "Expected function with valid CFG.");
3583+
35823584
auto &MIB = BC.MIB;
35833585
MCContext *Ctx = BC.Ctx.get();
35843586

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ void DIEBuilder::updateReferences() {
175175
LocExpr.Die.replaceValue(getState().DIEAlloc, LocExpr.Attr, LocExpr.Form,
176176
Value);
177177
}
178-
179-
return;
180178
}
181179

182180
uint32_t DIEBuilder::allocDIE(const DWARFUnit &DU, const DWARFDie &DDie,

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
783783
Inst.setOpcode(RISCV::ADD);
784784
Inst.insert(Inst.begin(), MCOperand::createReg(Reg));
785785
Inst.insert(Inst.begin() + 1, MCOperand::createReg(RISCV::X0));
786-
return;
787786
}
788787

789788
InstructionListType createLoadImmediate(const MCPhysReg Dest,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Check that fixBranches() is not invoked on a broken CFG which could lead to
2+
## unintended consequences including a firing assertion.
3+
4+
# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
5+
# RUN: link_fdata %s %t.o %t.fdata
6+
# RUN: llvm-strip --strip-unneeded %t.o
7+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
8+
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=cdsplit \
9+
# RUN: --data=%t.fdata --reorder-blocks=ext-tsp 2>&1 | FileCheck %s
10+
11+
# CHECK: internal call detected
12+
13+
.text
14+
15+
.globl foo
16+
.type foo, @function
17+
foo:
18+
ret
19+
.size foo, .-foo
20+
21+
## main contains an internal call. ValidateInternalCalls pass will modify CFG
22+
## (making it invalid) and mark the function as non-simple. After that, we
23+
## cannot make any assumption about the CFG.
24+
25+
.globl main
26+
.type main, @function
27+
main:
28+
call .L1
29+
ret
30+
.L1:
31+
pushq %rbp
32+
movq %rsp, %rbp
33+
movl $1, %edi
34+
LLmain_foo1:
35+
call foo
36+
# FDATA: 1 main #LLmain_foo1# 1 foo 0 0 600
37+
movl $4, %edi
38+
xorl %eax, %eax
39+
popq %rbp
40+
retq
41+
.Lmain_end:
42+
.size main, .Lmain_end-main

clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ int main(int argc, char **argv) {
9696
cl::SetVersionPrinter(printVersion);
9797
cl::ParseCommandLineOptions(argc, argv);
9898

99-
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions());
99+
DiagnosticOptions DiagOpts;
100100
DiagnosticsEngine Diagnostics(
101-
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts.get());
101+
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts);
102102

103103
// Determine a formatting style from options.
104104
auto FormatStyleOrError = format::getStyle(FormatStyleOpt, FormatStyleConfig,

clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ int main(int argc, const char **argv) {
126126
if (int Result = Tool.run(Factory.get()))
127127
return Result;
128128
LangOptions DefaultLangOptions;
129-
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
130-
clang::TextDiagnosticPrinter DiagnosticPrinter(errs(), &*DiagOpts);
129+
DiagnosticOptions DiagOpts;
130+
clang::TextDiagnosticPrinter DiagnosticPrinter(errs(), DiagOpts);
131131
DiagnosticsEngine Diagnostics(
132-
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,
132+
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts,
133133
&DiagnosticPrinter, false);
134134
auto &FileMgr = Tool.getFiles();
135135
SourceManager Sources(Diagnostics, FileMgr);

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Support/Error.h"
1919
#include "llvm/Support/MemoryBuffer.h"
2020
#include "llvm/Support/Mustache.h"
21+
#include "llvm/Support/Path.h"
2122

2223
using namespace llvm;
2324
using namespace llvm::json;
@@ -74,7 +75,50 @@ static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
7475

7576
static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
7677

78+
static Error
79+
setupTemplate(std::unique_ptr<MustacheTemplateFile> &Template,
80+
StringRef TemplatePath,
81+
std::vector<std::pair<StringRef, StringRef>> Partials) {
82+
auto T = MustacheTemplateFile::createMustacheFile(TemplatePath);
83+
if (Error Err = T.takeError())
84+
return Err;
85+
Template = std::move(T.get());
86+
for (const auto &[Name, FileName] : Partials)
87+
if (auto Err = Template->registerPartialFile(Name, FileName))
88+
return Err;
89+
return Error::success();
90+
}
91+
7792
static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
93+
// Template files need to use the native path when they're opened,
94+
// but have to be used in POSIX style when used in HTML.
95+
auto ConvertToNative = [](std::string &&Path) -> std::string {
96+
SmallString<128> PathBuf(Path);
97+
llvm::sys::path::native(PathBuf);
98+
return PathBuf.str().str();
99+
};
100+
101+
std::string NamespaceFilePath =
102+
ConvertToNative(CDCtx.MustacheTemplates.lookup("namespace-template"));
103+
std::string ClassFilePath =
104+
ConvertToNative(CDCtx.MustacheTemplates.lookup("class-template"));
105+
std::string CommentFilePath =
106+
ConvertToNative(CDCtx.MustacheTemplates.lookup("comment-template"));
107+
std::string FunctionFilePath =
108+
ConvertToNative(CDCtx.MustacheTemplates.lookup("function-template"));
109+
std::string EnumFilePath =
110+
ConvertToNative(CDCtx.MustacheTemplates.lookup("enum-template"));
111+
std::vector<std::pair<StringRef, StringRef>> Partials = {
112+
{"Comments", CommentFilePath},
113+
{"FunctionPartial", FunctionFilePath},
114+
{"EnumPartial", EnumFilePath}};
115+
116+
if (Error Err = setupTemplate(NamespaceTemplate, NamespaceFilePath, Partials))
117+
return Err;
118+
119+
if (Error Err = setupTemplate(RecordTemplate, ClassFilePath, Partials))
120+
return Err;
121+
78122
return Error::success();
79123
}
80124

clang-tools-extra/clang-doc/support/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ set(LLVM_LINK_COMPONENTS
66

77
add_clang_library(clangDocSupport STATIC
88
File.cpp
9-
)
9+
Utils.cpp
10+
)

0 commit comments

Comments
 (0)