Skip to content

Commit d07884b

Browse files
authored
Merge branch 'main' into wcspbrk
2 parents 85dec85 + d4791f5 commit d07884b

File tree

394 files changed

+86090
-37257
lines changed

Some content is hidden

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

394 files changed

+86090
-37257
lines changed

.ci/monolithic-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function at-exit {
3838

3939
ccache --print-stats > artifacts/ccache_stats.txt
4040
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
41-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/
41+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
4242

4343
# If building fails there will be no results files.
4444
shopt -s nullglob

.ci/monolithic-windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function at-exit {
3333
mkdir -p artifacts
3434
sccache --show-stats >> artifacts/sccache_stats.txt
3535
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
36-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/
36+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
3737

3838
# If building fails there will be no results files.
3939
shopt -s nullglob

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
/mlir/**/Transforms/SROA.* @moxinilian
129129

130130
# BOLT
131-
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9
131+
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9 @paschalis-mpeis
132132

133133
# Bazel build system.
134134
/utils/bazel/ @rupprecht @keith @aaronmondal

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,19 @@ void RewriteInstance::discoverFileObjects() {
13411341
}
13421342
}
13431343
}
1344+
1345+
// The linker may omit data markers for absolute long veneers. Introduce
1346+
// those markers artificially to assist the disassembler.
1347+
for (BinaryFunction &BF :
1348+
llvm::make_second_range(BC->getBinaryFunctions())) {
1349+
if (BF.getOneName().starts_with("__AArch64AbsLongThunk_") &&
1350+
BF.getSize() == 16 && !BF.getSizeOfDataInCodeAt(8)) {
1351+
BC->errs() << "BOLT-WARNING: missing data marker detected in veneer "
1352+
<< BF << '\n';
1353+
BF.markDataAtOffset(8);
1354+
BC->AddressToConstantIslandMap[BF.getAddress() + 8] = &BF;
1355+
}
1356+
}
13441357
}
13451358

13461359
if (!BC->IsLinuxKernel) {

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66
# RUN: -fuse-ld=lld -Wl,-q
77
# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s
88
# RUN: llvm-objcopy --remove-section .rela.mytext %t.exe
9-
# RUN: llvm-bolt %t.exe -o %t.bolt --elim-link-veneers=true --lite=0
9+
# RUN: llvm-bolt %t.exe -o %t.bolt
1010
# RUN: llvm-objdump -d -j .text %t.bolt | \
1111
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
1212

13+
## Occasionally, we see the linker not generating $d symbols for long veneers
14+
## causing BOLT to fail veneer elimination.
15+
# RUN: llvm-objcopy --remove-symbol-prefix=\$d %t.exe %t.no-marker.exe
16+
# RUN: llvm-bolt %t.no-marker.exe -o %t.no-marker.bolt \
17+
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
18+
# RUN: llvm-objdump -d -j .text %t.no-marker.bolt | \
19+
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
20+
21+
# CHECK-BOLT-NOT: BOLT-WARNING: unable to disassemble instruction
22+
# CHECK-BOLT: BOLT-WARNING: missing data marker detected in veneer __AArch64AbsLongThunk_far_function
23+
1324
.text
1425
.balign 4
1526
.global far_function

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class FailedPrerequisiteModules : public PrerequisiteModules {
8484

8585
// We shouldn't adjust the compilation commands based on
8686
// FailedPrerequisiteModules.
87-
void adjustHeaderSearchOptions(HeaderSearchOptions &Options) const override {
88-
}
87+
void adjustHeaderSearchOptions(HeaderSearchOptions &Options) const override {}
8988

9089
// FailedPrerequisiteModules can never be reused.
9190
bool
@@ -430,21 +429,21 @@ class CachingProjectModules : public ProjectModules {
430429
/// Collect the directly and indirectly required module names for \param
431430
/// ModuleName in topological order. The \param ModuleName is guaranteed to
432431
/// be the last element in \param ModuleNames.
433-
llvm::SmallVector<StringRef> getAllRequiredModules(PathRef RequiredSource,
434-
CachingProjectModules &MDB,
435-
StringRef ModuleName) {
436-
llvm::SmallVector<llvm::StringRef> ModuleNames;
432+
llvm::SmallVector<std::string> getAllRequiredModules(PathRef RequiredSource,
433+
CachingProjectModules &MDB,
434+
StringRef ModuleName) {
435+
llvm::SmallVector<std::string> ModuleNames;
437436
llvm::StringSet<> ModuleNamesSet;
438437

439438
auto VisitDeps = [&](StringRef ModuleName, auto Visitor) -> void {
440439
ModuleNamesSet.insert(ModuleName);
441440

442-
for (StringRef RequiredModuleName : MDB.getRequiredModules(
441+
for (const std::string &RequiredModuleName : MDB.getRequiredModules(
443442
MDB.getSourceForModuleName(ModuleName, RequiredSource)))
444443
if (ModuleNamesSet.insert(RequiredModuleName).second)
445444
Visitor(RequiredModuleName, Visitor);
446445

447-
ModuleNames.push_back(ModuleName);
446+
ModuleNames.push_back(ModuleName.str());
448447
};
449448
VisitDeps(ModuleName, VisitDeps);
450449

@@ -494,28 +493,30 @@ llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
494493
// Get Required modules in topological order.
495494
auto ReqModuleNames = getAllRequiredModules(RequiredSource, MDB, ModuleName);
496495
for (llvm::StringRef ReqModuleName : ReqModuleNames) {
497-
if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
496+
if (BuiltModuleFiles.isModuleUnitBuilt(ReqModuleName))
498497
continue;
499498

500499
if (auto Cached = Cache.getModule(ReqModuleName)) {
501500
if (IsModuleFileUpToDate(Cached->getModuleFilePath(), BuiltModuleFiles,
502501
TFS.view(std::nullopt))) {
503-
log("Reusing module {0} from {1}", ModuleName,
502+
log("Reusing module {0} from {1}", ReqModuleName,
504503
Cached->getModuleFilePath());
505504
BuiltModuleFiles.addModuleFile(std::move(Cached));
506505
continue;
507506
}
508507
Cache.remove(ReqModuleName);
509508
}
510509

510+
std::string ReqFileName =
511+
MDB.getSourceForModuleName(ReqModuleName, RequiredSource);
511512
llvm::Expected<ModuleFile> MF = buildModuleFile(
512-
ModuleName, ModuleUnitFileName, getCDB(), TFS, BuiltModuleFiles);
513+
ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
513514
if (llvm::Error Err = MF.takeError())
514515
return Err;
515516

516-
log("Built module {0} to {1}", ModuleName, MF->getModuleFilePath());
517+
log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
517518
auto BuiltModuleFile = std::make_shared<const ModuleFile>(std::move(*MF));
518-
Cache.add(ModuleName, BuiltModuleFile);
519+
Cache.add(ReqModuleName, BuiltModuleFile);
519520
BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
520521
}
521522

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# A smoke test to check that a simple dependency chain for modules can work.
2+
#
3+
# RUN: rm -fr %t
4+
# RUN: mkdir -p %t
5+
# RUN: split-file %s %t
6+
#
7+
# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json.tmp
8+
# RUN: sed -e "s|CLANG_CC|%clang|g" %t/compile_commands.json.tmp > %t/compile_commands.json
9+
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc.tmp
10+
#
11+
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
12+
# (with the extra slash in the front), so we add it here.
13+
# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %/t/definition.jsonrpc.tmp > %/t/definition.jsonrpc
14+
#
15+
# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \
16+
# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc
17+
18+
#--- A-frag.cppm
19+
export module A:frag;
20+
export void printA() {}
21+
22+
#--- A.cppm
23+
export module A;
24+
export import :frag;
25+
26+
#--- Use.cpp
27+
import A;
28+
void foo() {
29+
print
30+
}
31+
32+
#--- compile_commands.json.tmpl
33+
[
34+
{
35+
"directory": "DIR",
36+
"command": "CLANG_CC -fprebuilt-module-path=DIR -std=c++20 -o DIR/main.cpp.o -c DIR/Use.cpp",
37+
"file": "DIR/Use.cpp"
38+
},
39+
{
40+
"directory": "DIR",
41+
"command": "CLANG_CC -std=c++20 DIR/A.cppm --precompile -o DIR/A.pcm",
42+
"file": "DIR/A.cppm"
43+
},
44+
{
45+
"directory": "DIR",
46+
"command": "CLANG_CC -std=c++20 DIR/A-frag.cppm --precompile -o DIR/A-frag.pcm",
47+
"file": "DIR/A-frag.cppm"
48+
}
49+
]
50+
51+
#--- definition.jsonrpc.tmpl
52+
{
53+
"jsonrpc": "2.0",
54+
"id": 0,
55+
"method": "initialize",
56+
"params": {
57+
"processId": 123,
58+
"rootPath": "clangd",
59+
"capabilities": {
60+
"textDocument": {
61+
"completion": {
62+
"completionItem": {
63+
"snippetSupport": true
64+
}
65+
}
66+
}
67+
},
68+
"trace": "off"
69+
}
70+
}
71+
---
72+
{
73+
"jsonrpc": "2.0",
74+
"method": "textDocument/didOpen",
75+
"params": {
76+
"textDocument": {
77+
"uri": "file://DIR/Use.cpp",
78+
"languageId": "cpp",
79+
"version": 1,
80+
"text": "import A;\nvoid foo() {\n print\n}\n"
81+
}
82+
}
83+
}
84+
85+
# CHECK: "message"{{.*}}printA{{.*}}(fix available)
86+
87+
---
88+
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}
89+
---
90+
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
91+
---
92+
{"jsonrpc":"2.0","method":"exit"}

clang-tools-extra/clangd/test/modules.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# A smoke test to check the modules can work basically.
22
#
3-
# Windows have different escaping modes.
4-
# FIXME: We should add one for windows.
5-
# UNSUPPORTED: system-windows
6-
#
73
# RUN: rm -fr %t
84
# RUN: mkdir -p %t
95
# RUN: split-file %s %t
106
#
117
# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json.tmp
128
# RUN: sed -e "s|CLANG_CC|%clang|g" %t/compile_commands.json.tmp > %t/compile_commands.json
13-
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc
9+
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc.tmp
10+
#
11+
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
12+
# (with the extra slash in the front), so we add it here.
13+
# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %/t/definition.jsonrpc.tmp > %/t/definition.jsonrpc
1414
#
1515
# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \
1616
# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ Bug Fixes in This Version
669669
base classes. (GH139452)
670670
- Fixed an assertion failure in serialization of constexpr structs containing unions. (#GH140130)
671671
- Fixed duplicate entries in TableGen that caused the wrong attribute to be selected. (GH#140701)
672+
- Fixed type mismatch error when 'builtin-elementwise-math' arguments have different qualifiers, this should be well-formed. (#GH141397)
672673

673674
Bug Fixes to Compiler Builtins
674675
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,21 +811,25 @@ changes to one object won't affect the others, the object's initializer will run
811811
once per copy, etc.
812812

813813
Specifically, this warning fires when it detects an object which:
814-
1. Appears in a header file (so it might get compiled into multiple libaries), and
814+
1. Is defined as ``inline`` in a header file (so it might get compiled into multiple libaries), and
815815
2. Has external linkage (otherwise it's supposed to be duplicated), and
816816
3. Has hidden visibility.
817817

818818
As well as one of the following:
819819
1. The object is mutable, or
820820
2. The object's initializer definitely has side effects.
821821

822-
The warning is best resolved by making the object ``const`` (if possible), or by explicitly
823-
giving the object non-hidden visibility, e.g. using ``__attribute((visibility("default")))``.
824-
Note that all levels of a pointer variable must be constant; ``const int*`` will
825-
trigger the warning because the pointer itself is mutable.
822+
The warning can be resolved by removing one of the conditions above. In rough
823+
order of preference, this may be done by:
824+
1. Marking the object ``const`` (if possible)
825+
2. Moving the object's definition to a source file
826+
3. Giving the object non-hidden visibility, e.g. using ``__attribute((visibility("default")))``.
826827

827-
This warning is currently disabled on Windows since it uses import/export rules
828-
instead of visibility.
828+
Note that for (2), all levels of a pointer variable must be constant;
829+
``const int*`` will trigger the warning because the pointer itself is mutable.
830+
831+
This warning is not yet implemented for Windows, since Windows uses
832+
import/export rules instead of visibility.
829833
}];
830834
}
831835

0 commit comments

Comments
 (0)