Skip to content

Commit dd46457

Browse files
committed
Merge tag 'llvmorg-19.1.1' into rustc/19.1-2024-09-17
LLVM Release 19.1.1
2 parents 5699773 + d401987 commit dd46457

File tree

88 files changed

+2388
-348
lines changed

Some content is hidden

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

88 files changed

+2388
-348
lines changed

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,8 @@ jobs:
135135
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
136136
fi
137137
138-
# x86 macOS and x86 Windows have trouble building flang, so disable it.
139-
# Windows: https://github.com/llvm/llvm-project/issues/100202
140-
# macOS: 'rebase opcodes terminated early at offset 1 of 80016' when building __fortran_builtins.mod
141138
build_flang="true"
142139
143-
if [ "$target" = "Windows-X64" ]; then
144-
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS=\"clang;lld;lldb;clang-tools-extra;bolt;polly;mlir\""
145-
build_flang="false"
146-
fi
147-
148140
if [ "${{ runner.os }}" = "Windows" ]; then
149141
# The build times out on Windows, so we need to disable LTO.
150142
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"

bolt/test/perf2bolt/lit.local.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import shutil
2+
import subprocess
23

3-
if shutil.which("perf") is not None:
4-
config.available_features.add("perf")
4+
if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=True).returncode == 0:
5+
config.available_features.add("perf")

clang/cmake/caches/Release.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
4747
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
4848

4949
set(STAGE1_PROJECTS "clang")
50-
set(STAGE1_RUNTIMES "")
50+
51+
# Building Flang on Windows requires compiler-rt, so we need to build it in
52+
# stage1. compiler-rt is also required for building the Flang tests on
53+
# macOS.
54+
set(STAGE1_RUNTIMES "compiler-rt")
5155

5256
if (LLVM_RELEASE_ENABLE_PGO)
5357
list(APPEND STAGE1_PROJECTS "lld")
54-
list(APPEND STAGE1_RUNTIMES "compiler-rt")
5558
set(CLANG_BOOTSTRAP_TARGETS
5659
generate-profdata
5760
stage2-package

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ class alignas(8) Decl {
680680
/// Whether this declaration comes from explicit global module.
681681
bool isFromExplicitGlobalModule() const;
682682

683+
/// Whether this declaration comes from global module.
684+
bool isFromGlobalModule() const;
685+
683686
/// Whether this declaration comes from a named module.
684687
bool isInNamedModule() const;
685688

clang/include/clang/Tooling/CompilationDatabase.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ std::unique_ptr<CompilationDatabase>
234234
std::unique_ptr<CompilationDatabase>
235235
inferTargetAndDriverMode(std::unique_ptr<CompilationDatabase> Base);
236236

237+
/// Returns a wrapped CompilationDatabase that will transform argv[0] to an
238+
/// absolute path, if it currently is a plain tool name, looking it up in
239+
/// PATH.
240+
std::unique_ptr<CompilationDatabase>
241+
inferToolLocation(std::unique_ptr<CompilationDatabase> Base);
242+
237243
/// Returns a wrapped CompilationDatabase that will expand all rsp(response)
238244
/// files on commandline returned by underlying database.
239245
std::unique_ptr<CompilationDatabase>

clang/lib/AST/DeclBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,10 @@ bool Decl::isFromExplicitGlobalModule() const {
11611161
return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
11621162
}
11631163

1164+
bool Decl::isFromGlobalModule() const {
1165+
return getOwningModule() && getOwningModule()->isGlobalModule();
1166+
}
1167+
11641168
bool Decl::isInNamedModule() const {
11651169
return getOwningModule() && getOwningModule()->isNamedModule();
11661170
}

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,18 +2833,22 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
28332833
llvm::AtomicOrdering::SequentiallyConsistent);
28342834
return isPre ? Builder.CreateBinOp(op, old, amt) : old;
28352835
}
2836-
// Special case for atomic increment/decrement on floats
2836+
// Special case for atomic increment/decrement on floats.
2837+
// Bail out non-power-of-2-sized floating point types (e.g., x86_fp80).
28372838
if (type->isFloatingType()) {
2838-
llvm::AtomicRMWInst::BinOp aop =
2839-
isInc ? llvm::AtomicRMWInst::FAdd : llvm::AtomicRMWInst::FSub;
2840-
llvm::Instruction::BinaryOps op =
2841-
isInc ? llvm::Instruction::FAdd : llvm::Instruction::FSub;
2842-
llvm::Value *amt = llvm::ConstantFP::get(
2843-
VMContext, llvm::APFloat(static_cast<float>(1.0)));
2844-
llvm::Value *old =
2845-
Builder.CreateAtomicRMW(aop, LV.getAddress(), amt,
2846-
llvm::AtomicOrdering::SequentiallyConsistent);
2847-
return isPre ? Builder.CreateBinOp(op, old, amt) : old;
2839+
llvm::Type *Ty = ConvertType(type);
2840+
if (llvm::has_single_bit(Ty->getScalarSizeInBits())) {
2841+
llvm::AtomicRMWInst::BinOp aop =
2842+
isInc ? llvm::AtomicRMWInst::FAdd : llvm::AtomicRMWInst::FSub;
2843+
llvm::Instruction::BinaryOps op =
2844+
isInc ? llvm::Instruction::FAdd : llvm::Instruction::FSub;
2845+
llvm::Value *amt = llvm::ConstantFP::get(Ty, 1.0);
2846+
llvm::AtomicRMWInst *old = Builder.CreateAtomicRMW(
2847+
aop, LV.getAddress(), amt,
2848+
llvm::AtomicOrdering::SequentiallyConsistent);
2849+
2850+
return isPre ? Builder.CreateBinOp(op, old, amt) : old;
2851+
}
28482852
}
28492853
value = EmitLoadOfLValue(LV, E->getExprLoc());
28502854
input = value;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
85618561
WantDebug = !A->getOption().matches(options::OPT_g0) &&
85628562
!A->getOption().matches(options::OPT_ggdb0);
85638563

8564+
// If a -gdwarf argument appeared, remember it.
8565+
bool EmitDwarf = false;
8566+
if (const Arg *A = getDwarfNArg(Args))
8567+
EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain());
8568+
8569+
bool EmitCodeView = false;
8570+
if (const Arg *A = Args.getLastArg(options::OPT_gcodeview))
8571+
EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain());
8572+
8573+
// If the user asked for debug info but did not explicitly specify -gcodeview
8574+
// or -gdwarf, ask the toolchain for the default format.
8575+
if (!EmitCodeView && !EmitDwarf && WantDebug) {
8576+
switch (getToolChain().getDefaultDebugFormat()) {
8577+
case llvm::codegenoptions::DIF_CodeView:
8578+
EmitCodeView = true;
8579+
break;
8580+
case llvm::codegenoptions::DIF_DWARF:
8581+
EmitDwarf = true;
8582+
break;
8583+
}
8584+
}
8585+
8586+
// If the arguments don't imply DWARF, don't emit any debug info here.
8587+
if (!EmitDwarf)
8588+
WantDebug = false;
8589+
85648590
llvm::codegenoptions::DebugInfoKind DebugInfoKind =
85658591
llvm::codegenoptions::NoDebugInfo;
85668592

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
100100
if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
101101
FirstInLineIndex = Tokens.size() - 1;
102102
} while (Tokens.back()->isNot(tok::eof));
103+
if (Style.InsertNewlineAtEOF) {
104+
auto &TokEOF = *Tokens.back();
105+
if (TokEOF.NewlinesBefore == 0) {
106+
TokEOF.NewlinesBefore = 1;
107+
TokEOF.OriginalColumn = 0;
108+
}
109+
}
103110
return Tokens;
104111
}
105112

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,11 +3680,6 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
36803680
auto *First = Line.First;
36813681
First->SpacesRequiredBefore = 1;
36823682
First->CanBreakBefore = First->MustBreakBefore;
3683-
3684-
if (First->is(tok::eof) && First->NewlinesBefore == 0 &&
3685-
Style.InsertNewlineAtEOF) {
3686-
First->NewlinesBefore = 1;
3687-
}
36883683
}
36893684

36903685
// This function heuristically determines whether 'Current' starts the name of a

clang/lib/Sema/SemaConcept.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,30 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
969969
// equivalence.
970970
LocalInstantiationScope ScopeForParameters(S);
971971
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
972-
for (auto *PVD : FD->parameters())
973-
ScopeForParameters.InstantiatedLocal(PVD, PVD);
972+
for (auto *PVD : FD->parameters()) {
973+
if (!PVD->isParameterPack()) {
974+
ScopeForParameters.InstantiatedLocal(PVD, PVD);
975+
continue;
976+
}
977+
// This is hacky: we're mapping the parameter pack to a size-of-1 argument
978+
// to avoid building SubstTemplateTypeParmPackTypes for
979+
// PackExpansionTypes. The SubstTemplateTypeParmPackType node would
980+
// otherwise reference the AssociatedDecl of the template arguments, which
981+
// is, in this case, the template declaration.
982+
//
983+
// However, as we are in the process of comparing potential
984+
// re-declarations, the canonical declaration is the declaration itself at
985+
// this point. So if we didn't expand these packs, we would end up with an
986+
// incorrect profile difference because we will be profiling the
987+
// canonical types!
988+
//
989+
// FIXME: Improve the "no-transform" machinery in FindInstantiatedDecl so
990+
// that we can eliminate the Scope in the cases where the declarations are
991+
// not necessarily instantiated. It would also benefit the noexcept
992+
// specifier comparison.
993+
ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
994+
ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
995+
}
974996

975997
std::optional<Sema::CXXThisScopeRAII> ThisScope;
976998

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9732,8 +9732,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
97329732
// the function decl is created above).
97339733
// FIXME: We need a better way to separate C++ standard and clang modules.
97349734
bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
9735+
NewFD->isConstexpr() || NewFD->isConsteval() ||
97359736
!NewFD->getOwningModule() ||
9736-
NewFD->isFromExplicitGlobalModule() ||
9737+
NewFD->isFromGlobalModule() ||
97379738
NewFD->getOwningModule()->isHeaderLikeModule();
97389739
bool isInline = D.getDeclSpec().isInlineSpecified();
97399740
bool isVirtual = D.getDeclSpec().isVirtualSpecified();

clang/lib/Tooling/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add_clang_library(clangTooling
2525
GuessTargetAndModeCompilationDatabase.cpp
2626
InterpolatingCompilationDatabase.cpp
2727
JSONCompilationDatabase.cpp
28+
LocateToolCompilationDatabase.cpp
2829
Refactoring.cpp
2930
RefactoringCallbacks.cpp
3031
StandaloneExecution.cpp
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//===- GuessTargetAndModeCompilationDatabase.cpp --------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "clang/Tooling/CompilationDatabase.h"
10+
#include "clang/Tooling/Tooling.h"
11+
#include "llvm/Support/Path.h"
12+
#include "llvm/Support/Program.h"
13+
#include <memory>
14+
15+
namespace clang {
16+
namespace tooling {
17+
18+
namespace {
19+
class LocationAdderDatabase : public CompilationDatabase {
20+
public:
21+
LocationAdderDatabase(std::unique_ptr<CompilationDatabase> Base)
22+
: Base(std::move(Base)) {
23+
assert(this->Base != nullptr);
24+
}
25+
26+
std::vector<std::string> getAllFiles() const override {
27+
return Base->getAllFiles();
28+
}
29+
30+
std::vector<CompileCommand> getAllCompileCommands() const override {
31+
return addLocation(Base->getAllCompileCommands());
32+
}
33+
34+
std::vector<CompileCommand>
35+
getCompileCommands(StringRef FilePath) const override {
36+
return addLocation(Base->getCompileCommands(FilePath));
37+
}
38+
39+
private:
40+
std::vector<CompileCommand>
41+
addLocation(std::vector<CompileCommand> Cmds) const {
42+
for (auto &Cmd : Cmds) {
43+
if (Cmd.CommandLine.empty())
44+
continue;
45+
std::string &Driver = Cmd.CommandLine.front();
46+
// If the driver name already is absolute, we don't need to do anything.
47+
if (llvm::sys::path::is_absolute(Driver))
48+
continue;
49+
// If the name is a relative path, like bin/clang, we assume it's
50+
// possible to resolve it and don't do anything about it either.
51+
if (llvm::any_of(Driver,
52+
[](char C) { return llvm::sys::path::is_separator(C); }))
53+
continue;
54+
auto Absolute = llvm::sys::findProgramByName(Driver);
55+
// If we found it in path, update the entry in Cmd.CommandLine
56+
if (Absolute && llvm::sys::path::is_absolute(*Absolute))
57+
Driver = std::move(*Absolute);
58+
}
59+
return Cmds;
60+
}
61+
std::unique_ptr<CompilationDatabase> Base;
62+
};
63+
} // namespace
64+
65+
std::unique_ptr<CompilationDatabase>
66+
inferToolLocation(std::unique_ptr<CompilationDatabase> Base) {
67+
return std::make_unique<LocationAdderDatabase>(std::move(Base));
68+
}
69+
70+
} // namespace tooling
71+
} // namespace clang
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Check that we can detect an implicit target when clang is invoked as
2+
// <triple->clang. Using an implicit triple requires that the target actually
3+
// is available, too.
4+
// REQUIRES: x86-registered-target
5+
6+
// RUN: rm -rf %t
7+
// RUN: split-file %s %t
8+
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
9+
10+
// Check that we can deduce this both when using a compilation database, and when using
11+
// a literal command line.
12+
13+
// RUN: clang-scan-deps -format experimental-full -compilation-database %t/cdb.json | FileCheck %s
14+
15+
// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang %t/source.c -o %t/source.o | FileCheck %s
16+
17+
// CHECK: "-triple",
18+
// CHECK-NEXT: "x86_64-w64-windows-gnu",
19+
20+
21+
//--- cdb.json.in
22+
[
23+
{
24+
"directory": "DIR"
25+
"command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o"
26+
"file": "DIR/source.c"
27+
},
28+
]
29+
30+
//--- source.c
31+
void func(void) {}

clang/test/ClangScanDeps/modules-extern-submodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ module third {}
112112
// CHECK: "-fmodule-map-file=[[PREFIX]]/first/first/module.modulemap",
113113
// CHECK: "-fmodule-file=first=[[PREFIX]]/cache/{{.*}}/first-{{.*}}.pcm",
114114
// CHECK: ],
115-
// CHECK-NEXT: "executable": "clang",
116-
// CHECK-NEXT: "file-deps": [
115+
// CHECK: "file-deps": [
117116
// CHECK-NEXT: "[[PREFIX]]/tu.m"
118117
// CHECK-NEXT: ],
119118
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"

clang/test/ClangScanDeps/modules-full-output-tu-order.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
// CHECK: "-D"
3636
// CHECK-NEXT: "ONE"
3737
// CHECK: ],
38-
// CHECK-NEXT: "executable": "clang",
39-
// CHECK-NEXT: "file-deps": [
38+
// CHECK: "file-deps": [
4039
// CHECK-NEXT: "[[PREFIX]]/tu.c"
4140
// CHECK-NEXT: ],
4241
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
@@ -52,8 +51,7 @@
5251
// CHECK: "-D"
5352
// CHECK-NEXT: "TWO"
5453
// CHECK: ],
55-
// CHECK-NEXT: "executable": "clang",
56-
// CHECK-NEXT: "file-deps": [
54+
// CHECK: "file-deps": [
5755
// CHECK-NEXT: "[[PREFIX]]/tu.c"
5856
// CHECK-NEXT: ],
5957
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"

clang/test/ClangScanDeps/modules-has-include-umbrella-header.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ module Dependency { header "dependency.h" }
6464
// CHECK: ],
6565
// CHECK-NEXT: "command-line": [
6666
// CHECK: ],
67-
// CHECK-NEXT: "executable": "clang",
68-
// CHECK-NEXT: "file-deps": [
67+
// CHECK: "file-deps": [
6968
// CHECK-NEXT: "[[PREFIX]]/tu.c"
7069
// CHECK-NEXT: ],
7170
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"

clang/test/ClangScanDeps/modules-header-sharing.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
7878
// CHECK: "-fmodule-name=A",
7979
// CHECK: ],
80-
// CHECK-NEXT: "executable": "clang",
81-
// CHECK-NEXT: "file-deps": [
80+
// CHECK: "file-deps": [
8281
// CHECK-NEXT: "[[PREFIX]]/tu.m",
8382
// CHECK-NEXT: "[[PREFIX]]/shared/H.h"
8483
// CHECK-NEXT: ],

clang/test/ClangScanDeps/modules-implementation-module-map.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ framework module FWPrivate { header "private.h" }
2727
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
2828
// CHECK: "-fmodule-name=FWPrivate",
2929
// CHECK: ],
30-
// CHECK-NEXT: "executable": "clang",
31-
// CHECK-NEXT: "file-deps": [
30+
// CHECK: "file-deps": [
3231
// CHECK-NEXT: "[[PREFIX]]/tu.m"
3332
// CHECK-NEXT: ],
3433
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"

clang/test/ClangScanDeps/modules-implementation-private.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
// CHECK-NEXT: ],
6363
// CHECK-NEXT: "command-line": [
6464
// CHECK: ],
65-
// CHECK-NEXT: "executable": "clang",
66-
// CHECK-NEXT: "file-deps": [
65+
// CHECK: "file-deps": [
6766
// CHECK-NEXT: "[[PREFIX]]/tu.m",
6867
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Missed.h",
6968
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"

0 commit comments

Comments
 (0)