Skip to content

Commit 1224c14

Browse files
committed
Merge remote-tracking branch 'origin/main' into ir2vec
2 parents 768d399 + ba8773b commit 1224c14

File tree

805 files changed

+114781
-50927
lines changed

Some content is hidden

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

805 files changed

+114781
-50927
lines changed

.ci/all_requirements.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ ml-dtypes==0.5.1 ; python_version < "3.13" \
194194
--hash=sha256:d13755f8e8445b3870114e5b6240facaa7cb0c3361e54beba3e07fa912a6e12b \
195195
--hash=sha256:fd918d4e6a4e0c110e2e05be7a7814d10dc1b95872accbf6512b80a109b71ae1
196196
# via -r mlir/python/requirements.txt
197-
nanobind==2.7.0 \
198-
--hash=sha256:73b12d0e751d140d6c1bf4b215e18818a8debfdb374f08dc3776ad208d808e74 \
199-
--hash=sha256:f9f1b160580c50dcf37b6495a0fd5ec61dc0d95dae5f8004f87dd9ad7eb46b34
197+
nanobind==2.9.2 \
198+
--hash=sha256:c37957ffd5eac7eda349cff3622ecd32e5ee1244ecc912c99b5bc8188bafd16e \
199+
--hash=sha256:e7608472de99d375759814cab3e2c94aba3f9ec80e62cfef8ced495ca5c27d6e
200200
# via -r mlir/python/requirements.txt
201201
numpy==2.0.2 \
202202
--hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \
@@ -383,6 +383,10 @@ swig==4.3.1 \
383383
--hash=sha256:efec16327029f682f649a26da726bb0305be8800bd0f1fa3e81bf0769cf5b476 \
384384
--hash=sha256:fc496c0d600cf1bb2d91e28d3d6eae9c4301e5ea7a0dec5a4281b5efed4245a8
385385
# via -r lldb/test/requirements.txt
386+
typing-extensions==4.15.0 \
387+
--hash=sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466 \
388+
--hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
389+
# via -r mlir/python/requirements.txt
386390
urllib3==2.5.0 \
387391
--hash=sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760 \
388392
--hash=sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/runtimes/ @llvm/reviewers-libcxx
1818

1919
/llvm/lib/Analysis/BasicAliasAnalysis.cpp @nikic
20+
/llvm/lib/Analysis/HashRecognize.cpp @artagnon @pfusik
2021
/llvm/lib/Analysis/InstructionSimplify.cpp @nikic
2122
/llvm/lib/Analysis/LazyValueInfo.cpp @nikic
2223
/llvm/lib/Analysis/ScalarEvolution.cpp @nikic

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 105 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ class FailedPrerequisiteModules : public PrerequisiteModules {
103103
}
104104
};
105105

106-
struct ModuleFile {
106+
/// Represents a reference to a module file (*.pcm).
107+
class ModuleFile {
108+
protected:
107109
ModuleFile(StringRef ModuleName, PathRef ModuleFilePath)
108110
: ModuleName(ModuleName.str()), ModuleFilePath(ModuleFilePath.str()) {}
109111

112+
public:
110113
ModuleFile() = delete;
111114

112115
ModuleFile(const ModuleFile &) = delete;
@@ -128,21 +131,58 @@ struct ModuleFile {
128131
new (this) ModuleFile(std::move(Other));
129132
return *this;
130133
}
131-
132-
~ModuleFile() {
133-
if (!ModuleFilePath.empty() && !DebugModulesBuilder)
134-
llvm::sys::fs::remove(ModuleFilePath);
135-
}
134+
virtual ~ModuleFile() = default;
136135

137136
StringRef getModuleName() const { return ModuleName; }
138137

139138
StringRef getModuleFilePath() const { return ModuleFilePath; }
140139

141-
private:
140+
protected:
142141
std::string ModuleName;
143142
std::string ModuleFilePath;
144143
};
145144

145+
/// Represents a prebuilt module file which is not owned by us.
146+
class PrebuiltModuleFile : public ModuleFile {
147+
private:
148+
// private class to make sure the class can only be constructed by member
149+
// functions.
150+
struct CtorTag {};
151+
152+
public:
153+
PrebuiltModuleFile(StringRef ModuleName, PathRef ModuleFilePath, CtorTag)
154+
: ModuleFile(ModuleName, ModuleFilePath) {}
155+
156+
static std::shared_ptr<PrebuiltModuleFile> make(StringRef ModuleName,
157+
PathRef ModuleFilePath) {
158+
return std::make_shared<PrebuiltModuleFile>(ModuleName, ModuleFilePath,
159+
CtorTag{});
160+
}
161+
};
162+
163+
/// Represents a module file built by us. We're responsible to remove it.
164+
class BuiltModuleFile : public ModuleFile {
165+
private:
166+
// private class to make sure the class can only be constructed by member
167+
// functions.
168+
struct CtorTag {};
169+
170+
public:
171+
BuiltModuleFile(StringRef ModuleName, PathRef ModuleFilePath, CtorTag)
172+
: ModuleFile(ModuleName, ModuleFilePath) {}
173+
174+
static std::shared_ptr<BuiltModuleFile> make(StringRef ModuleName,
175+
PathRef ModuleFilePath) {
176+
return std::make_shared<BuiltModuleFile>(ModuleName, ModuleFilePath,
177+
CtorTag{});
178+
}
179+
180+
virtual ~BuiltModuleFile() {
181+
if (!ModuleFilePath.empty() && !DebugModulesBuilder)
182+
llvm::sys::fs::remove(ModuleFilePath);
183+
}
184+
};
185+
146186
// ReusablePrerequisiteModules - stands for PrerequisiteModules for which all
147187
// the required modules are built successfully. All the module files
148188
// are owned by the modules builder.
@@ -171,9 +211,9 @@ class ReusablePrerequisiteModules : public PrerequisiteModules {
171211
std::string getAsString() const {
172212
std::string Result;
173213
llvm::raw_string_ostream OS(Result);
174-
for (const auto &ModuleFile : RequiredModules) {
175-
OS << "-fmodule-file=" << ModuleFile->getModuleName() << "="
176-
<< ModuleFile->getModuleFilePath() << " ";
214+
for (const auto &MF : RequiredModules) {
215+
OS << "-fmodule-file=" << MF->getModuleName() << "="
216+
<< MF->getModuleFilePath() << " ";
177217
}
178218
return Result;
179219
}
@@ -185,9 +225,9 @@ class ReusablePrerequisiteModules : public PrerequisiteModules {
185225
return BuiltModuleNames.contains(ModuleName);
186226
}
187227

188-
void addModuleFile(std::shared_ptr<const ModuleFile> ModuleFile) {
189-
BuiltModuleNames.insert(ModuleFile->getModuleName());
190-
RequiredModules.emplace_back(std::move(ModuleFile));
228+
void addModuleFile(std::shared_ptr<const ModuleFile> MF) {
229+
BuiltModuleNames.insert(MF->getModuleName());
230+
RequiredModules.emplace_back(std::move(MF));
191231
}
192232

193233
private:
@@ -265,7 +305,7 @@ bool IsModuleFilesUpToDate(
265305

266306
/// Build a module file for module with `ModuleName`. The information of built
267307
/// module file are stored in \param BuiltModuleFiles.
268-
llvm::Expected<ModuleFile>
308+
llvm::Expected<std::shared_ptr<BuiltModuleFile>>
269309
buildModuleFile(llvm::StringRef ModuleName, PathRef ModuleUnitFileName,
270310
const GlobalCompilationDatabase &CDB, const ThreadsafeFS &TFS,
271311
const ReusablePrerequisiteModules &BuiltModuleFiles) {
@@ -340,7 +380,7 @@ buildModuleFile(llvm::StringRef ModuleName, PathRef ModuleUnitFileName,
340380
ModuleUnitFileName));
341381
}
342382

343-
return ModuleFile{ModuleName, Inputs.CompileCommand.Output};
383+
return BuiltModuleFile::make(ModuleName, Inputs.CompileCommand.Output);
344384
}
345385

346386
bool ReusablePrerequisiteModules::canReuse(
@@ -509,10 +549,51 @@ class ModulesBuilder::ModulesBuilderImpl {
509549
ReusablePrerequisiteModules &BuiltModuleFiles);
510550

511551
private:
552+
/// Try to get prebuilt module files from the compilation database.
553+
void getPrebuiltModuleFile(StringRef ModuleName, PathRef ModuleUnitFileName,
554+
const ThreadsafeFS &TFS,
555+
ReusablePrerequisiteModules &BuiltModuleFiles);
556+
512557
ModuleFileCache Cache;
513558
ModuleNameToSourceCache ProjectModulesCache;
514559
};
515560

561+
void ModulesBuilder::ModulesBuilderImpl::getPrebuiltModuleFile(
562+
StringRef ModuleName, PathRef ModuleUnitFileName, const ThreadsafeFS &TFS,
563+
ReusablePrerequisiteModules &BuiltModuleFiles) {
564+
auto Cmd = getCDB().getCompileCommand(ModuleUnitFileName);
565+
if (!Cmd)
566+
return;
567+
568+
ParseInputs Inputs;
569+
Inputs.TFS = &TFS;
570+
Inputs.CompileCommand = std::move(*Cmd);
571+
572+
IgnoreDiagnostics IgnoreDiags;
573+
auto CI = buildCompilerInvocation(Inputs, IgnoreDiags);
574+
if (!CI)
575+
return;
576+
577+
// We don't need to check if the module files are in ModuleCache or adding
578+
// them to the module cache. As even if the module files are in the module
579+
// cache, we still need to validate them. And it looks not helpful to add them
580+
// to the module cache, since we may always try to get the prebuilt module
581+
// files before building the module files by ourselves.
582+
for (auto &[ModuleName, ModuleFilePath] :
583+
CI->getHeaderSearchOpts().PrebuiltModuleFiles) {
584+
if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
585+
continue;
586+
587+
if (IsModuleFileUpToDate(ModuleFilePath, BuiltModuleFiles,
588+
TFS.view(std::nullopt))) {
589+
log("Reusing prebuilt module file {0} of module {1} for {2}",
590+
ModuleFilePath, ModuleName, ModuleUnitFileName);
591+
BuiltModuleFiles.addModuleFile(
592+
PrebuiltModuleFile::make(ModuleName, ModuleFilePath));
593+
}
594+
}
595+
}
596+
516597
llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
517598
PathRef RequiredSource, StringRef ModuleName, const ThreadsafeFS &TFS,
518599
CachingProjectModules &MDB, ReusablePrerequisiteModules &BuiltModuleFiles) {
@@ -532,6 +613,11 @@ llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
532613
return llvm::createStringError(
533614
llvm::formatv("Don't get the module unit for module {0}", ModuleName));
534615

616+
/// Try to get prebuilt module files from the compilation database first. This
617+
/// helps to avoid building the module files that are already built by the
618+
/// compiler.
619+
getPrebuiltModuleFile(ModuleName, ModuleUnitFileName, TFS, BuiltModuleFiles);
620+
535621
// Get Required modules in topological order.
536622
auto ReqModuleNames = getAllRequiredModules(RequiredSource, MDB, ModuleName);
537623
for (llvm::StringRef ReqModuleName : ReqModuleNames) {
@@ -551,15 +637,14 @@ llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
551637

552638
std::string ReqFileName =
553639
MDB.getSourceForModuleName(ReqModuleName, RequiredSource);
554-
llvm::Expected<ModuleFile> MF = buildModuleFile(
640+
llvm::Expected<std::shared_ptr<BuiltModuleFile>> MF = buildModuleFile(
555641
ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
556642
if (llvm::Error Err = MF.takeError())
557643
return Err;
558644

559-
log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
560-
auto BuiltModuleFile = std::make_shared<const ModuleFile>(std::move(*MF));
561-
Cache.add(ReqModuleName, BuiltModuleFile);
562-
BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
645+
log("Built module {0} to {1}", ReqModuleName, (*MF)->getModuleFilePath());
646+
Cache.add(ReqModuleName, *MF);
647+
BuiltModuleFiles.addModuleFile(std::move(*MF));
563648
}
564649

565650
return llvm::Error::success();

clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,35 @@ import M;
644644
EXPECT_EQ(CDB.getGlobalScanningCount(), 1u);
645645
}
646646

647+
TEST_F(PrerequisiteModulesTests, PrebuiltModuleFileTest) {
648+
MockDirectoryCompilationDatabase CDB(TestDir, FS);
649+
650+
CDB.addFile("M.cppm", R"cpp(
651+
export module M;
652+
)cpp");
653+
654+
CDB.addFile("U.cpp", R"cpp(
655+
import M;
656+
)cpp");
657+
658+
// Use ModulesBuilder to produce the prebuilt module file.
659+
ModulesBuilder Builder(CDB);
660+
auto ModuleInfo =
661+
Builder.buildPrerequisiteModulesFor(getFullPath("U.cpp"), FS);
662+
HeaderSearchOptions HS(TestDir);
663+
ModuleInfo->adjustHeaderSearchOptions(HS);
664+
665+
CDB.ExtraClangFlags.push_back("-fmodule-file=M=" +
666+
HS.PrebuiltModuleFiles["M"]);
667+
ModulesBuilder Builder2(CDB);
668+
auto ModuleInfo2 =
669+
Builder2.buildPrerequisiteModulesFor(getFullPath("U.cpp"), FS);
670+
HeaderSearchOptions HS2(TestDir);
671+
ModuleInfo2->adjustHeaderSearchOptions(HS2);
672+
673+
EXPECT_EQ(HS.PrebuiltModuleFiles, HS2.PrebuiltModuleFiles);
674+
}
675+
647676
} // namespace
648677
} // namespace clang::clangd
649678

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ Improvements to clang-tidy
126126
- Improved :program:`clang-tidy` option `-quiet` by suppressing diagnostic
127127
count messages.
128128

129+
- Improved :program:`clang-tidy` by not crashing when an empty `directory`
130+
field is used in a compilation database; the current working directory
131+
will be used instead, and an error message will be printed.
132+
129133
New checks
130134
^^^^^^^^^^
131135

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[{
2+
"directory":"/invalid/",
3+
"file":"/tmp/",
4+
"arguments": []
5+
}]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// UNSUPPORTED: system-windows
22

3-
// RUN: not --crash clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s
3+
// RUN: clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s
44

5-
// CHECK: LLVM ERROR: Cannot chdir into ""!
5+
// CHECK: 'directory' field of compilation database is empty; using the current working directory instead.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// UNSUPPORTED: system-windows
2+
3+
// RUN: not --crash clang-tidy -p %S/Inputs/invalid-database %s 2>&1 | FileCheck %s
4+
5+
// CHECK: LLVM ERROR: Cannot chdir into "/invalid/"!

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Non-comprehensive list of changes in this release
206206
Currently, the use of ``__builtin_dedup_pack`` is limited to template arguments and base
207207
specifiers, it also must be used within a template context.
208208

209+
- ``__builtin_assume_dereferenceable`` now accepts non-constant size operands.
209210

210211
New Compiler Flags
211212
------------------
@@ -379,6 +380,10 @@ X86 Support
379380
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
380381
guaranteed to exist in future releases, or match behaviour with previous
381382
releases of clang or other compilers.
383+
- Remove `m[no-]avx10.x-[256,512]` and `m[no-]evex512` options from Clang
384+
driver.
385+
- Remove `[no-]evex512` feature request from intrinsics and builtins.
386+
- Change features `avx10.x-[256,512]` to `avx10.x`.
382387

383388
Arm and AArch64 Support
384389
^^^^^^^^^^^^^^^^^^^^^^^
@@ -391,6 +396,7 @@ Windows Support
391396

392397
LoongArch Support
393398
^^^^^^^^^^^^^^^^^
399+
- Enable linker relaxation by default for loongarch64.
394400

395401
RISC-V Support
396402
^^^^^^^^^^^^^^

clang/docs/UsersManual.rst

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4581,59 +4581,14 @@ implicitly included in later levels.
45814581
- ``-march=x86-64-v3``: (close to Haswell) AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE
45824582
- ``-march=x86-64-v4``: AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL
45834583

4584-
`Intel AVX10 ISA <https://cdrdv2.intel.com/v1/dl/getContent/784267>`_ is
4584+
`Intel AVX10 ISA <https://cdrdv2.intel.com/v1/dl/getContent/784343>`_ is
45854585
a major new vector ISA incorporating the modern vectorization aspects of
45864586
Intel AVX-512. This ISA will be supported on all future Intel processors.
4587-
Users are supposed to use the new options ``-mavx10.N`` and ``-mavx10.N-512``
4588-
on these processors and should not use traditional AVX512 options anymore.
4589-
4590-
The ``N`` in ``-mavx10.N`` represents a continuous integer number starting
4591-
from ``1``. ``-mavx10.N`` is an alias of ``-mavx10.N-256``, which means to
4592-
enable all instructions within AVX10 version N at a maximum vector length of
4593-
256 bits. ``-mavx10.N-512`` enables all instructions at a maximum vector
4594-
length of 512 bits, which is a superset of instructions ``-mavx10.N`` enabled.
4595-
4596-
Current binaries built with AVX512 features can run on Intel AVX10/512 capable
4597-
processors without re-compile, but cannot run on AVX10/256 capable processors.
4598-
Users need to re-compile their code with ``-mavx10.N``, and maybe update some
4599-
code that calling to 512-bit X86 specific intrinsics and passing or returning
4600-
512-bit vector types in function call, if they want to run on AVX10/256 capable
4601-
processors. Binaries built with ``-mavx10.N`` can run on both AVX10/256 and
4602-
AVX10/512 capable processors.
4603-
4604-
Users can add a ``-mno-evex512`` in the command line with AVX512 options if
4605-
they want to run the binary on both legacy AVX512 and new AVX10/256 capable
4606-
processors. The option has the same constraints as ``-mavx10.N``, i.e.,
4607-
cannot call to 512-bit X86 specific intrinsics and pass or return 512-bit vector
4608-
types in function call.
4609-
4610-
Users should avoid using AVX512 features in function target attributes when
4611-
developing code for AVX10. If they have to do so, they need to add an explicit
4612-
``evex512`` or ``no-evex512`` together with AVX512 features for 512-bit or
4613-
non-512-bit functions respectively to avoid unexpected code generation. Both
4614-
command line option and target attribute of EVEX512 feature can only be used
4615-
with AVX512. They don't affect vector size of AVX10.
4616-
4617-
User should not mix the use AVX10 and AVX512 options together at any time,
4618-
because the option combinations are conflicting sometimes. For example, a
4619-
combination of ``-mavx512f -mavx10.1-256`` doesn't show a clear intention to
4620-
compiler, since instructions in AVX512F and AVX10.1/256 intersect but do not
4621-
overlap. In this case, compiler will emit warning for it, but the behavior
4622-
is determined. It will generate the same code as option ``-mavx10.1-512``.
4623-
A similar case is ``-mavx512f -mavx10.2-256``, which equals to
4624-
``-mavx10.1-512 -mavx10.2-256``, because ``avx10.2-256`` implies ``avx10.1-256``
4625-
and ``-mavx512f -mavx10.1-256`` equals to ``-mavx10.1-512``.
4626-
4627-
There are some new macros introduced with AVX10 support. ``-mavx10.1-256`` will
4628-
enable ``__AVX10_1__`` and ``__EVEX256__``, while ``-mavx10.1-512`` enables
4629-
``__AVX10_1__``, ``__EVEX256__``, ``__EVEX512__`` and ``__AVX10_1_512__``.
4630-
Besides, both ``-mavx10.1-256`` and ``-mavx10.1-512`` will enable all AVX512
4631-
feature specific macros. A AVX512 feature will enable both ``__EVEX256__``,
4632-
``__EVEX512__`` and its own macro. So ``__EVEX512__`` can be used to guard code
4633-
that can run on both legacy AVX512 and AVX10/512 capable processors but cannot
4634-
run on AVX10/256, while a AVX512 macro like ``__AVX512F__`` cannot tell the
4635-
difference among the three options. Users need to check additional macros
4636-
``__AVX10_1__`` and ``__EVEX512__`` if they want to make distinction.
4587+
Users are supposed to use the new options ``-mavx10.N`` on these processors
4588+
and should not use traditional AVX512 options anymore. The ``N`` in
4589+
``-mavx10.N`` represents a continuous integer number starting
4590+
from ``1``. Current binaries built with AVX512 features can run on Intel AVX10
4591+
capable processors without re-compile.
46374592

46384593
ARM
46394594
^^^

0 commit comments

Comments
 (0)