Skip to content

Commit 3c09908

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents 535e874 + b4ab53c commit 3c09908

File tree

395 files changed

+9514
-5557
lines changed

Some content is hidden

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

395 files changed

+9514
-5557
lines changed

.ci/metrics/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
# Lists the Github workflows we want to track. Maps the Github job name to
2222
# the metric name prefix in grafana.
2323
# This metric name is also used as a key in the job->name map.
24-
GITHUB_WORKFLOW_TO_TRACK = {"LLVM Premerge Checks": "github_llvm_premerge_checks"}
24+
GITHUB_WORKFLOW_TO_TRACK = {"CI Checks": "github_llvm_premerge_checks"}
2525

2626
# Lists the Github jobs to track for a given workflow. The key is the stable
2727
# name (metric name) of the workflow (see GITHUB_WORKFLOW_TO_TRACK).
2828
# Each value is a map to link the github job name to the corresponding metric
2929
# name.
3030
GITHUB_JOB_TO_TRACK = {
3131
"github_llvm_premerge_checks": {
32-
"Linux Premerge Checks (Test Only - Please Ignore Results)": "premerge_linux",
33-
"Windows Premerge Checks (Test Only - Please Ignore Results)": "premerge_windows",
32+
"Build and Test Linux (Test Only - Please Ignore Results)": "premerge_linux",
33+
"Build and Test Windows (Test Only - Please Ignore Results)": "premerge_windows",
3434
}
3535
}
3636

.github/workflows/premerge.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: LLVM Premerge Checks
1+
name: CI Checks
22

33
permissions:
44
contents: read
@@ -25,7 +25,7 @@ concurrency:
2525

2626
jobs:
2727
premerge-checks-linux:
28-
name: Linux Premerge Checks (Test Only - Please Ignore Results)
28+
name: Build and Test Linux (Test Only - Please Ignore Results)
2929
if: >-
3030
github.repository_owner == 'llvm' &&
3131
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -74,7 +74,7 @@ jobs:
7474
include-hidden-files: 'true'
7575

7676
premerge-checks-windows:
77-
name: Windows Premerge Checks (Test Only - Please Ignore Results)
77+
name: Build and Test Windows (Test Only - Please Ignore Results)
7878
if: >-
7979
github.repository_owner == 'llvm' &&
8080
(github.event_name != 'pull_request' || github.event.action != 'closed')

bolt/lib/Passes/PatchEntries.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,10 @@ Error PatchEntries::runOnFunctions(BinaryContext &BC) {
9898
});
9999

100100
if (!Success) {
101-
// We can't change output layout for AArch64 due to LongJmp pass
102-
if (BC.isAArch64()) {
103-
if (opts::ForcePatch) {
104-
BC.errs() << "BOLT-ERROR: unable to patch entries in " << Function
105-
<< "\n";
106-
return createFatalBOLTError("");
107-
}
108-
109-
continue;
110-
}
111-
112101
// If the original function entries cannot be patched, then we cannot
113102
// safely emit new function body.
114103
BC.errs() << "BOLT-WARNING: failed to patch entries in " << Function
115-
<< ". The function will not be optimized.\n";
104+
<< ". The function will not be optimized\n";
116105
Function.setIgnored();
117106
continue;
118107
}

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
497497
// memory profiling data.
498498
Manager.registerPass(std::make_unique<ReorderData>());
499499

500+
// Patch original function entries
501+
if (BC.HasRelocations)
502+
Manager.registerPass(std::make_unique<PatchEntries>());
503+
500504
if (BC.isAArch64()) {
501505
Manager.registerPass(
502506
std::make_unique<ADRRelaxationPass>(PrintAdrRelaxation));
@@ -524,10 +528,6 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
524528
// Assign each function an output section.
525529
Manager.registerPass(std::make_unique<AssignSections>());
526530

527-
// Patch original function entries
528-
if (BC.HasRelocations)
529-
Manager.registerPass(std::make_unique<PatchEntries>());
530-
531531
// This pass turns tail calls into jumps which makes them invisible to
532532
// function reordering. It's unsafe to use any CFG or instruction analysis
533533
// after this point.

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ bool IncludeFixerActionFactory::runInvocation(
8989
assert(Invocation->getFrontendOpts().Inputs.size() == 1);
9090

9191
// Set up Clang.
92-
clang::CompilerInstance Compiler(PCHContainerOps);
93-
Compiler.setInvocation(std::move(Invocation));
92+
CompilerInstance Compiler(std::move(Invocation), std::move(PCHContainerOps));
9493
Compiler.setFileManager(Files);
9594

9695
// Create the compiler's actual diagnostics engine. We want to drop all

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI,
145145
CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get());
146146
}
147147

148-
auto Clang = std::make_unique<CompilerInstance>(
149-
std::make_shared<PCHContainerOperations>());
150-
Clang->setInvocation(std::move(CI));
148+
auto Clang = std::make_unique<CompilerInstance>(std::move(CI));
151149
Clang->createDiagnostics(*VFS, &DiagsClient, false);
152150

153151
if (auto VFSWithRemapping = createVFSFromCompilerInvocation(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ Improvements to clang-doc
8888
Improvements to clang-query
8989
---------------------------
9090

91+
Improvements to include-cleaner
92+
-------------------------------
93+
- Deprecated the ``-insert`` and ``-remove`` command line options, and added
94+
the ``-disable-remove`` and ``-disable-insert`` command line options as
95+
replacements. The previous command line options were confusing because they
96+
did not imply the default state of the option (which is inserts and removes
97+
being enabled). The new options are easier to understand the semantics of.
98+
9199
Improvements to clang-tidy
92100
--------------------------
93101

clang-tools-extra/include-cleaner/test/tool.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ int x = foo();
66
// CHANGE: - "foobar.h"
77
// CHANGE-NEXT: + "foo.h"
88

9-
// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
9+
// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
1010
// INSERT-NOT: - "foobar.h"
1111
// INSERT: + "foo.h"
1212

13-
// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
13+
// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
1414
// REMOVE: - "foobar.h"
1515
// REMOVE-NOT: + "foo.h"
1616

@@ -58,3 +58,16 @@ int x = foo();
5858
// RUN: FileCheck --match-full-lines --check-prefix=EDIT3 %s < %t.cpp
5959
// EDIT3: #include "foo.h"
6060
// EDIT3-NOT: {{^}}#include "foobar.h"{{$}}
61+
62+
// RUN: clang-include-cleaner -insert=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
63+
// RUN: FileCheck --check-prefix=DEPRECATED-INSERT %s
64+
// DEPRECATED-INSERT: warning: '-insert=0' is deprecated in favor of '-disable-insert'. The old flag was confusing since it suggested that inserts were disabled by default, when they were actually enabled.
65+
66+
// RUN: clang-include-cleaner -remove=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
67+
// RUN: FileCheck --check-prefix=DEPRECATED-REMOVE %s
68+
// DEPRECATED-REMOVE: warning: '-remove=0' is deprecated in favor of '-disable-remove'. The old flag was confusing since it suggested that removes were disabled by default, when they were actually enabled.
69+
70+
// RUN: clang-include-cleaner -insert=false -remove=false -print=changes %s -- -I%S/Inputs/ 2>&1 | \
71+
// RUN: FileCheck --check-prefix=DEPRECATED-BOTH %s
72+
// DEPRECATED-BOTH: warning: '-insert=0' is deprecated in favor of '-disable-insert'. The old flag was confusing since it suggested that inserts were disabled by default, when they were actually enabled.
73+
// DEPRECATED-BOTH: warning: '-remove=0' is deprecated in favor of '-disable-remove'. The old flag was confusing since it suggested that removes were disabled by default, when they were actually enabled.

clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,31 @@ cl::opt<bool> Edit{
9090
cl::desc("Apply edits to analyzed source files"),
9191
cl::cat(IncludeCleaner),
9292
};
93-
9493
cl::opt<bool> Insert{
9594
"insert",
96-
cl::desc("Allow header insertions"),
95+
cl::desc(
96+
"Allow header insertions (deprecated. Use -disable-insert instead)"),
9797
cl::init(true),
9898
cl::cat(IncludeCleaner),
9999
};
100100
cl::opt<bool> Remove{
101101
"remove",
102-
cl::desc("Allow header removals"),
102+
cl::desc("Allow header removals (deprecated. Use -disable-remove instead)"),
103103
cl::init(true),
104104
cl::cat(IncludeCleaner),
105105
};
106+
cl::opt<bool> DisableInsert{
107+
"disable-insert",
108+
cl::desc("Disable header insertions"),
109+
cl::init(false),
110+
cl::cat(IncludeCleaner),
111+
};
112+
cl::opt<bool> DisableRemove{
113+
"disable-remove",
114+
cl::desc("Disable header removals"),
115+
cl::init(false),
116+
cl::cat(IncludeCleaner),
117+
};
106118

107119
std::atomic<unsigned> Errors = ATOMIC_VAR_INIT(0);
108120

@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction {
183195
auto Results =
184196
analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI,
185197
getCompilerInstance().getPreprocessor(), HeaderFilter);
186-
if (!Insert)
198+
199+
if (!Insert) {
200+
llvm::errs()
201+
<< "warning: '-insert=0' is deprecated in favor of "
202+
"'-disable-insert'. "
203+
"The old flag was confusing since it suggested that inserts "
204+
"were disabled by default, when they were actually enabled.\n";
205+
}
206+
207+
if (!Remove) {
208+
llvm::errs()
209+
<< "warning: '-remove=0' is deprecated in favor of "
210+
"'-disable-remove'. "
211+
"The old flag was confusing since it suggested that removes "
212+
"were disabled by default, when they were actually enabled.\n";
213+
}
214+
215+
if (!Insert || DisableInsert)
187216
Results.Missing.clear();
188-
if (!Remove)
217+
if (!Remove || DisableRemove)
189218
Results.Unused.clear();
190219
std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath));
191220

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,14 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
618618
llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(),
619619
/*BufferName=*/""));
620620

621-
auto Clang = std::make_unique<CompilerInstance>(
622-
std::make_shared<PCHContainerOperations>());
623-
Clang->createDiagnostics(*VFS);
621+
auto DiagOpts = llvm::makeIntrusiveRefCnt<DiagnosticOptions>();
622+
auto Diags = CompilerInstance::createDiagnostics(*VFS, DiagOpts.get());
623+
auto Invocation = std::make_unique<CompilerInvocation>();
624+
ASSERT_TRUE(CompilerInvocation::CreateFromArgs(*Invocation, {Filename.data()},
625+
*Diags, "clang"));
624626

625-
Clang->setInvocation(std::make_unique<CompilerInvocation>());
626-
ASSERT_TRUE(CompilerInvocation::CreateFromArgs(
627-
Clang->getInvocation(), {Filename.data()}, Clang->getDiagnostics(),
628-
"clang"));
627+
auto Clang = std::make_unique<CompilerInstance>(std::move(Invocation));
628+
Clang->createDiagnostics(*VFS);
629629

630630
auto *FM = Clang->createFileManager(VFS);
631631
ASSERT_TRUE(Clang->ExecuteAction(*Inputs.MakeAction()));

0 commit comments

Comments
 (0)