Skip to content

Commit aceb87d

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into main-merge-true16-logical
2 parents 5fa2f79 + b4c4c79 commit aceb87d

File tree

286 files changed

+8325
-3135
lines changed

Some content is hidden

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

286 files changed

+8325
-3135
lines changed

bolt/test/X86/encoding-validation.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
44
# RUN: ld.lld %t.o -o %t.exe -q
5-
# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding |& FileCheck %s
5+
# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding 2>&1 | FileCheck %s
66

77
.text
88
.globl _start

bolt/test/X86/gotpcrelx.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# RUN: ld.lld %t.o -o %t.pie.exe -q -pie
1111
# RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax
1212
# RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \
13-
# RUN: |& FileCheck --check-prefix=BOLT %s
13+
# RUN: 2>&1 | FileCheck --check-prefix=BOLT %s
1414
# RUN: llvm-bolt %t.pie.exe -o %t.null --print-cfg --print-only=_start \
15-
# RUN: |& FileCheck --check-prefix=PIE-BOLT %s
15+
# RUN: 2>&1 | FileCheck --check-prefix=PIE-BOLT %s
1616
# RUN: llvm-bolt %t.no-relax.exe -o %t.null --print-cfg --print-only=_start \
17-
# RUN: |& FileCheck --check-prefix=NO-RELAX-BOLT %s
17+
# RUN: 2>&1 | FileCheck --check-prefix=NO-RELAX-BOLT %s
1818
# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
1919
# RUN: %t.out | FileCheck --check-prefix=DISASM %s
2020

bolt/test/X86/icf-jump-tables.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# REQUIRES: system-linux
55

66
# RUN: %clang %cflags -O1 -g %p/../Inputs/icf-jump-tables.c -o %t.exe -Wl,-q
7-
# RUN: llvm-bolt %t.exe --icf -o %t.bolt |& FileCheck %s
7+
# RUN: llvm-bolt %t.exe --icf -o %t.bolt 2>&1 | FileCheck %s
88

99
## Check that BOLT successfully folded a function with jump table:
1010
# CHECK: ICF folded {{.*}}. {{[^0]}} functions had jump tables.

bolt/test/X86/indirect-goto-pie.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ REQUIRES: x86_64-linux
66

77
RUN: %clang %S/Inputs/indirect_goto.c -o %t -fpic -pie -Wl,-q
88
RUN: not llvm-bolt %t -o %t.bolt --relocs=1 --print-cfg --print-only=main \
9-
RUN: |& FileCheck %s
9+
RUN: 2>&1 | FileCheck %s
1010

1111
## Check that processing works if main() is skipped.
1212
RUN: llvm-bolt %t -o %t.bolt --relocs=1 --skip-funcs=main

bolt/test/X86/jump-table-func-entry.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: %clang %cflags %t.o -o %t.exe -no-pie -Wl,-q
88

99
# RUN: llvm-bolt %t.exe --print-normalized --print-only=foo -o %t.out \
10-
# RUN: |& FileCheck %s
10+
# RUN: 2>&1 | FileCheck %s
1111

1212

1313

bolt/test/X86/keep-nops.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
66
# RUN: ld.lld %t.o -o %t.exe -q
77
# RUN: llvm-bolt %t.exe -o %t.bolt.exe --keep-nops --relocs --print-finalized \
8-
# RUN: |& FileCheck --check-prefix=CHECK-BOLT %s
8+
# RUN: 2>&1 | FileCheck --check-prefix=CHECK-BOLT %s
99
# RUN: llvm-objdump -d %t.bolt.exe | FileCheck %s
1010

1111
.text

bolt/test/X86/linux-bug-table.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## Verify bug entry bindings again after unreachable code elimination.
1616

1717
# RUN: llvm-bolt %t.out -o %t.out.1 --print-only=_start --print-normalized \
18-
# RUN: |& FileCheck --check-prefix=CHECK-REOPT %s
18+
# RUN: 2>&1 | FileCheck --check-prefix=CHECK-REOPT %s
1919

2020
# CHECK: BOLT-INFO: Linux kernel binary detected
2121
# CHECK: BOLT-INFO: parsed 2 bug table entries

bolt/test/X86/linux-orc.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## Verify reading contents of ORC sections.
1111

12-
# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null |& FileCheck %s \
12+
# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null 2>&1 | FileCheck %s \
1313
# RUN: --check-prefix=CHECK-ORC
1414

1515
# CHECK-ORC: BOLT-INFO: ORC unwind information:
@@ -27,19 +27,19 @@
2727
## Verify ORC bindings to instructions.
2828

2929
# RUN: llvm-bolt %t.exe --print-normalized --dump-orc --print-orc -o %t.out \
30-
# RUN: --keep-nops=0 --bolt-info=0 |& FileCheck %s
30+
# RUN: --keep-nops=0 --bolt-info=0 2>&1 | FileCheck %s
3131

3232

3333
## Verify ORC bindings after rewrite.
3434

3535
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
36-
# RUN: |& FileCheck %s
36+
# RUN: 2>&1 | FileCheck %s
3737

3838
## Verify ORC binding after rewrite when some of the functions are skipped.
3939

4040
# RUN: llvm-bolt %t.exe -o %t.out --skip-funcs=bar --bolt-info=0 --keep-nops=0
4141
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
42-
# RUN: |& FileCheck %s
42+
# RUN: 2>&1 | FileCheck %s
4343

4444
# CHECK: BOLT-INFO: Linux kernel binary detected
4545
# CHECK: BOLT-INFO: parsed 9 ORC entries

bolt/test/X86/linux-pci-fixup.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
44
# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
55
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
6-
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out |& FileCheck %s
6+
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out 2>&1 | FileCheck %s
77

88
## Check that BOLT correctly parses the Linux kernel .pci_fixup section and
99
## verify that PCI fixup hook in the middle of a function is detected.

bolt/test/X86/linux-smp-locks.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
88
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
99
# RUN: llvm-bolt %t.exe --print-normalized --keep-nops=0 --bolt-info=0 -o %t.out \
10-
# RUN: |& FileCheck %s
10+
# RUN: 2>&1 | FileCheck %s
1111

1212
## Check the output of BOLT with NOPs removed.
1313

14-
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
14+
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
1515

1616
# CHECK: BOLT-INFO: Linux kernel binary detected
1717
# CHECK: BOLT-INFO: parsed 2 SMP lock entries

bolt/test/X86/linux-static-calls.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
## Verify static calls bindings to instructions.
1010

1111
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
12-
# RUN: --bolt-info=0 |& FileCheck %s
12+
# RUN: --bolt-info=0 2>&1 | FileCheck %s
1313

1414
## Verify the bindings again on the rewritten binary with nops removed.
1515

16-
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
16+
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
1717

1818
# CHECK: BOLT-INFO: Linux kernel binary detected
1919
# CHECK: BOLT-INFO: parsed 2 static call entries

bolt/test/X86/linux-static-keys.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
## Verify static keys jump bindings to instructions.
1212

1313
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
14-
# RUN: --bolt-info=0 |& FileCheck %s
14+
# RUN: --bolt-info=0 2>&1 | FileCheck %s
1515

1616
## Verify that profile is matched correctly.
1717

1818
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
19-
# RUN: --bolt-info=0 --data %t.fdata |& \
20-
# RUN: FileCheck --check-prefix=CHECK-FDATA %s
19+
# RUN: --bolt-info=0 --data %t.fdata 2>&1 \
20+
# RUN: | FileCheck --check-prefix=CHECK-FDATA %s
2121

2222
## Verify the bindings again on the rewritten binary with nops removed.
2323

24-
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
24+
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
2525

2626
# CHECK: BOLT-INFO: Linux kernel binary detected
2727
# CHECK: BOLT-INFO: parsed 2 static keys jump entries

bolt/test/X86/pt_gnu_relro.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# READELF: 04 .got
2323

2424
# RUN: llvm-bolt %t.exe --relocs -o %t.null -v=1 \
25-
# RUN: |& FileCheck --check-prefix=BOLT %s
25+
# RUN: 2>&1 | FileCheck --check-prefix=BOLT %s
2626
# BOLT: BOLT-INFO: marking .got as GNU_RELRO
2727

2828
.globl _start

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
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-
# RUN: llvm-bolt %t.exe -v=1 -o %t.out |& FileCheck %s
21+
# RUN: llvm-bolt %t.exe -v=1 -o %t.out 2>&1 | FileCheck %s
2222

2323
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
2424
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main

bolt/test/X86/vararg.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
REQUIRES: x86_64-linux
66

77
RUN: %clangxx %cxxflags -no-pie %p/../Inputs/vararg.s -o %t -Wl,-q
8-
RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* |& FileCheck %s
8+
RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* 2>&1 | FileCheck %s
99

1010
CHECK: IsSimple : 0
1111
CHECK: Entry Point

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
2020
# RUN: %clang %cflags %S/Inputs/unclaimed-jt-entries.c -no-pie %t.o -o %t.exe -Wl,-q
21-
# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly |& FileCheck %s
21+
# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly 2>&1 | FileCheck %s
2222

2323
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func
2424
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func

clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ struct Header {
136136
}
137137
StringRef verbatim() const { return std::get<Verbatim>(Storage); }
138138

139-
/// Absolute path for the header when it's a physical file. Otherwise just
140-
/// the spelling without surrounding quotes/brackets.
139+
/// For phiscal files, either absolute path or path relative to the execution
140+
/// root. Otherwise just the spelling without surrounding quotes/brackets.
141141
llvm::StringRef resolvedPath() const;
142142

143143
private:

clang-tools-extra/include-cleaner/lib/Analysis.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
8282
const PragmaIncludes *PI, const Preprocessor &PP,
8383
llvm::function_ref<bool(llvm::StringRef)> HeaderFilter) {
8484
auto &SM = PP.getSourceManager();
85-
const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
85+
const auto MainFile = *SM.getFileEntryRefForID(SM.getMainFileID());
8686
llvm::DenseSet<const Include *> Used;
8787
llvm::StringSet<> Missing;
8888
if (!HeaderFilter)
@@ -95,37 +95,38 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
9595
for (const Header &H : Providers) {
9696
if (H.kind() == Header::Physical &&
9797
(H.physical() == MainFile ||
98-
(ResourceDir && H.physical().getDir() == *ResourceDir))) {
98+
H.physical().getDir() == ResourceDir)) {
9999
Satisfied = true;
100100
}
101101
for (const Include *I : Inc.match(H)) {
102102
Used.insert(I);
103103
Satisfied = true;
104104
}
105105
}
106-
if (!Satisfied && !Providers.empty() &&
107-
Ref.RT == RefType::Explicit &&
108-
!HeaderFilter(Providers.front().resolvedPath())) {
109-
// Check if we have any headers with the same spelling, in edge
110-
// cases like `#include_next "foo.h"`, the user can't ever
111-
// include the physical foo.h, but can have a spelling that
112-
// refers to it.
113-
auto Spelling = spellHeader(
114-
{Providers.front(), PP.getHeaderSearchInfo(), MainFile});
115-
for (const Include *I : Inc.match(Header{Spelling})) {
116-
Used.insert(I);
117-
Satisfied = true;
118-
}
119-
if (!Satisfied)
120-
Missing.insert(std::move(Spelling));
106+
// Bail out if we can't (or need not) insert an include.
107+
if (Satisfied || Providers.empty() || Ref.RT != RefType::Explicit)
108+
return;
109+
if (HeaderFilter(Providers.front().resolvedPath()))
110+
return;
111+
// Check if we have any headers with the same spelling, in edge
112+
// cases like `#include_next "foo.h"`, the user can't ever
113+
// include the physical foo.h, but can have a spelling that
114+
// refers to it.
115+
auto Spelling = spellHeader(
116+
{Providers.front(), PP.getHeaderSearchInfo(), MainFile});
117+
for (const Include *I : Inc.match(Header{Spelling})) {
118+
Used.insert(I);
119+
Satisfied = true;
121120
}
121+
if (!Satisfied)
122+
Missing.insert(std::move(Spelling));
122123
});
123124

124125
AnalysisResults Results;
125126
for (const Include &I : Inc.all()) {
126127
if (Used.contains(&I) || !I.Resolved ||
127-
HeaderFilter(I.Resolved->getFileEntry().tryGetRealPathName()) ||
128-
(ResourceDir && I.Resolved->getFileEntry().getDir() == *ResourceDir))
128+
HeaderFilter(I.Resolved->getName()) ||
129+
I.Resolved->getDir() == ResourceDir)
129130
continue;
130131
if (PI) {
131132
if (PI->shouldKeep(*I.Resolved))
@@ -137,7 +138,7 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
137138
// Since most private -> public mappings happen in a verbatim way, we
138139
// check textually here. This might go wrong in presence of symlinks or
139140
// header mappings. But that's not different than rest of the places.
140-
if (MainFile->tryGetRealPathName().ends_with(PHeader))
141+
if (MainFile.getName().ends_with(PHeader))
141142
continue;
142143
}
143144
}

clang-tools-extra/include-cleaner/lib/HTMLReport.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
#include "AnalysisInternal.h"
17+
#include "clang-include-cleaner/IncludeSpeller.h"
1718
#include "clang-include-cleaner/Types.h"
1819
#include "clang/AST/ASTContext.h"
1920
#include "clang/AST/PrettyPrinter.h"
@@ -167,22 +168,6 @@ class Reporter {
167168
return "semiused";
168169
}
169170

170-
std::string spellHeader(const Header &H) {
171-
switch (H.kind()) {
172-
case Header::Physical: {
173-
bool IsAngled = false;
174-
std::string Path = HS.suggestPathToFileForDiagnostics(
175-
H.physical(), MainFE->tryGetRealPathName(), &IsAngled);
176-
return IsAngled ? "<" + Path + ">" : "\"" + Path + "\"";
177-
}
178-
case Header::Standard:
179-
return H.standard().name().str();
180-
case Header::Verbatim:
181-
return H.verbatim().str();
182-
}
183-
llvm_unreachable("Unknown Header kind");
184-
}
185-
186171
void fillTarget(Ref &R) {
187172
// Duplicates logic from walkUsed(), which doesn't expose SymbolLocations.
188173
for (auto &Loc : locateSymbol(R.Sym))
@@ -204,7 +189,7 @@ class Reporter {
204189
R.Includes.end());
205190

206191
if (!R.Headers.empty())
207-
R.Insert = spellHeader(R.Headers.front());
192+
R.Insert = spellHeader({R.Headers.front(), HS, MainFE});
208193
}
209194

210195
public:

clang-tools-extra/include-cleaner/lib/Types.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "TypesInternal.h"
1111
#include "clang/AST/Decl.h"
1212
#include "clang/Basic/FileEntry.h"
13-
#include "llvm/ADT/ArrayRef.h"
1413
#include "llvm/ADT/STLExtras.h"
1514
#include "llvm/ADT/SmallString.h"
1615
#include "llvm/ADT/SmallVector.h"
@@ -48,7 +47,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
4847
llvm::StringRef Header::resolvedPath() const {
4948
switch (kind()) {
5049
case include_cleaner::Header::Physical:
51-
return physical().getFileEntry().tryGetRealPathName();
50+
return physical().getName();
5251
case include_cleaner::Header::Standard:
5352
return standard().name().trim("<>\"");
5453
case include_cleaner::Header::Verbatim:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class Action : public clang::ASTFrontendAction {
164164
writeHTML();
165165

166166
llvm::StringRef Path =
167-
SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
167+
SM.getFileEntryRefForID(SM.getMainFileID())->getName();
168168
assert(!Path.empty() && "Main file path not known?");
169169
llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());
170170

0 commit comments

Comments
 (0)