Skip to content

Commit

Permalink
bump to llvmorg-19.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
KomiMoe committed Oct 3, 2024
1 parent 4335dba commit a1d84b3
Show file tree
Hide file tree
Showing 88 changed files with 2,388 additions and 348 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,8 @@ jobs:
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
fi
# x86 macOS and x86 Windows have trouble building flang, so disable it.
# Windows: https://github.com/llvm/llvm-project/issues/100202
# macOS: 'rebase opcodes terminated early at offset 1 of 80016' when building __fortran_builtins.mod
build_flang="true"
if [ "$target" = "Windows-X64" ]; then
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS=\"clang;lld;lldb;clang-tools-extra;bolt;polly;mlir\""
build_flang="false"
fi
if [ "${{ runner.os }}" = "Windows" ]; then
# The build times out on Windows, so we need to disable LTO.
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"
Expand Down
5 changes: 3 additions & 2 deletions bolt/test/perf2bolt/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shutil
import subprocess

if shutil.which("perf") is not None:
config.available_features.add("perf")
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:
config.available_features.add("perf")
7 changes: 5 additions & 2 deletions clang/cmake/caches/Release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")

set(STAGE1_PROJECTS "clang")
set(STAGE1_RUNTIMES "")

# Building Flang on Windows requires compiler-rt, so we need to build it in
# stage1. compiler-rt is also required for building the Flang tests on
# macOS.
set(STAGE1_RUNTIMES "compiler-rt")

if (LLVM_RELEASE_ENABLE_PGO)
list(APPEND STAGE1_PROJECTS "lld")
list(APPEND STAGE1_RUNTIMES "compiler-rt")
set(CLANG_BOOTSTRAP_TARGETS
generate-profdata
stage2-package
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/AST/DeclBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ class alignas(8) Decl {
/// Whether this declaration comes from explicit global module.
bool isFromExplicitGlobalModule() const;

/// Whether this declaration comes from global module.
bool isFromGlobalModule() const;

/// Whether this declaration comes from a named module.
bool isInNamedModule() const;

Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Tooling/CompilationDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ std::unique_ptr<CompilationDatabase>
std::unique_ptr<CompilationDatabase>
inferTargetAndDriverMode(std::unique_ptr<CompilationDatabase> Base);

/// Returns a wrapped CompilationDatabase that will transform argv[0] to an
/// absolute path, if it currently is a plain tool name, looking it up in
/// PATH.
std::unique_ptr<CompilationDatabase>
inferToolLocation(std::unique_ptr<CompilationDatabase> Base);

/// Returns a wrapped CompilationDatabase that will expand all rsp(response)
/// files on commandline returned by underlying database.
std::unique_ptr<CompilationDatabase>
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/DeclBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,10 @@ bool Decl::isFromExplicitGlobalModule() const {
return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
}

bool Decl::isFromGlobalModule() const {
return getOwningModule() && getOwningModule()->isGlobalModule();
}

bool Decl::isInNamedModule() const {
return getOwningModule() && getOwningModule()->isNamedModule();
}
Expand Down
26 changes: 15 additions & 11 deletions clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2833,18 +2833,22 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
llvm::AtomicOrdering::SequentiallyConsistent);
return isPre ? Builder.CreateBinOp(op, old, amt) : old;
}
// Special case for atomic increment/decrement on floats
// Special case for atomic increment/decrement on floats.
// Bail out non-power-of-2-sized floating point types (e.g., x86_fp80).
if (type->isFloatingType()) {
llvm::AtomicRMWInst::BinOp aop =
isInc ? llvm::AtomicRMWInst::FAdd : llvm::AtomicRMWInst::FSub;
llvm::Instruction::BinaryOps op =
isInc ? llvm::Instruction::FAdd : llvm::Instruction::FSub;
llvm::Value *amt = llvm::ConstantFP::get(
VMContext, llvm::APFloat(static_cast<float>(1.0)));
llvm::Value *old =
Builder.CreateAtomicRMW(aop, LV.getAddress(), amt,
llvm::AtomicOrdering::SequentiallyConsistent);
return isPre ? Builder.CreateBinOp(op, old, amt) : old;
llvm::Type *Ty = ConvertType(type);
if (llvm::has_single_bit(Ty->getScalarSizeInBits())) {
llvm::AtomicRMWInst::BinOp aop =
isInc ? llvm::AtomicRMWInst::FAdd : llvm::AtomicRMWInst::FSub;
llvm::Instruction::BinaryOps op =
isInc ? llvm::Instruction::FAdd : llvm::Instruction::FSub;
llvm::Value *amt = llvm::ConstantFP::get(Ty, 1.0);
llvm::AtomicRMWInst *old = Builder.CreateAtomicRMW(
aop, LV.getAddress(), amt,
llvm::AtomicOrdering::SequentiallyConsistent);

return isPre ? Builder.CreateBinOp(op, old, amt) : old;
}
}
value = EmitLoadOfLValue(LV, E->getExprLoc());
input = value;
Expand Down
26 changes: 26 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
WantDebug = !A->getOption().matches(options::OPT_g0) &&
!A->getOption().matches(options::OPT_ggdb0);

// If a -gdwarf argument appeared, remember it.
bool EmitDwarf = false;
if (const Arg *A = getDwarfNArg(Args))
EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain());

bool EmitCodeView = false;
if (const Arg *A = Args.getLastArg(options::OPT_gcodeview))
EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain());

// If the user asked for debug info but did not explicitly specify -gcodeview
// or -gdwarf, ask the toolchain for the default format.
if (!EmitCodeView && !EmitDwarf && WantDebug) {
switch (getToolChain().getDefaultDebugFormat()) {
case llvm::codegenoptions::DIF_CodeView:
EmitCodeView = true;
break;
case llvm::codegenoptions::DIF_DWARF:
EmitDwarf = true;
break;
}
}

// If the arguments don't imply DWARF, don't emit any debug info here.
if (!EmitDwarf)
WantDebug = false;

llvm::codegenoptions::DebugInfoKind DebugInfoKind =
llvm::codegenoptions::NoDebugInfo;

Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Format/FormatTokenLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
FirstInLineIndex = Tokens.size() - 1;
} while (Tokens.back()->isNot(tok::eof));
if (Style.InsertNewlineAtEOF) {
auto &TokEOF = *Tokens.back();
if (TokEOF.NewlinesBefore == 0) {
TokEOF.NewlinesBefore = 1;
TokEOF.OriginalColumn = 0;
}
}
return Tokens;
}

Expand Down
5 changes: 0 additions & 5 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3680,11 +3680,6 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
auto *First = Line.First;
First->SpacesRequiredBefore = 1;
First->CanBreakBefore = First->MustBreakBefore;

if (First->is(tok::eof) && First->NewlinesBefore == 0 &&
Style.InsertNewlineAtEOF) {
First->NewlinesBefore = 1;
}
}

// This function heuristically determines whether 'Current' starts the name of a
Expand Down
26 changes: 24 additions & 2 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,30 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
// equivalence.
LocalInstantiationScope ScopeForParameters(S);
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
for (auto *PVD : FD->parameters())
ScopeForParameters.InstantiatedLocal(PVD, PVD);
for (auto *PVD : FD->parameters()) {
if (!PVD->isParameterPack()) {
ScopeForParameters.InstantiatedLocal(PVD, PVD);
continue;
}
// This is hacky: we're mapping the parameter pack to a size-of-1 argument
// to avoid building SubstTemplateTypeParmPackTypes for
// PackExpansionTypes. The SubstTemplateTypeParmPackType node would
// otherwise reference the AssociatedDecl of the template arguments, which
// is, in this case, the template declaration.
//
// However, as we are in the process of comparing potential
// re-declarations, the canonical declaration is the declaration itself at
// this point. So if we didn't expand these packs, we would end up with an
// incorrect profile difference because we will be profiling the
// canonical types!
//
// FIXME: Improve the "no-transform" machinery in FindInstantiatedDecl so
// that we can eliminate the Scope in the cases where the declarations are
// not necessarily instantiated. It would also benefit the noexcept
// specifier comparison.
ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
}

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

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9732,8 +9732,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// the function decl is created above).
// FIXME: We need a better way to separate C++ standard and clang modules.
bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
NewFD->isConstexpr() || NewFD->isConsteval() ||
!NewFD->getOwningModule() ||
NewFD->isFromExplicitGlobalModule() ||
NewFD->isFromGlobalModule() ||
NewFD->getOwningModule()->isHeaderLikeModule();
bool isInline = D.getDeclSpec().isInlineSpecified();
bool isVirtual = D.getDeclSpec().isVirtualSpecified();
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Tooling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_clang_library(clangTooling
GuessTargetAndModeCompilationDatabase.cpp
InterpolatingCompilationDatabase.cpp
JSONCompilationDatabase.cpp
LocateToolCompilationDatabase.cpp
Refactoring.cpp
RefactoringCallbacks.cpp
StandaloneExecution.cpp
Expand Down
71 changes: 71 additions & 0 deletions clang/lib/Tooling/LocateToolCompilationDatabase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===- GuessTargetAndModeCompilationDatabase.cpp --------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include <memory>

namespace clang {
namespace tooling {

namespace {
class LocationAdderDatabase : public CompilationDatabase {
public:
LocationAdderDatabase(std::unique_ptr<CompilationDatabase> Base)
: Base(std::move(Base)) {
assert(this->Base != nullptr);
}

std::vector<std::string> getAllFiles() const override {
return Base->getAllFiles();
}

std::vector<CompileCommand> getAllCompileCommands() const override {
return addLocation(Base->getAllCompileCommands());
}

std::vector<CompileCommand>
getCompileCommands(StringRef FilePath) const override {
return addLocation(Base->getCompileCommands(FilePath));
}

private:
std::vector<CompileCommand>
addLocation(std::vector<CompileCommand> Cmds) const {
for (auto &Cmd : Cmds) {
if (Cmd.CommandLine.empty())
continue;
std::string &Driver = Cmd.CommandLine.front();
// If the driver name already is absolute, we don't need to do anything.
if (llvm::sys::path::is_absolute(Driver))
continue;
// If the name is a relative path, like bin/clang, we assume it's
// possible to resolve it and don't do anything about it either.
if (llvm::any_of(Driver,
[](char C) { return llvm::sys::path::is_separator(C); }))
continue;
auto Absolute = llvm::sys::findProgramByName(Driver);
// If we found it in path, update the entry in Cmd.CommandLine
if (Absolute && llvm::sys::path::is_absolute(*Absolute))
Driver = std::move(*Absolute);
}
return Cmds;
}
std::unique_ptr<CompilationDatabase> Base;
};
} // namespace

std::unique_ptr<CompilationDatabase>
inferToolLocation(std::unique_ptr<CompilationDatabase> Base) {
return std::make_unique<LocationAdderDatabase>(std::move(Base));
}

} // namespace tooling
} // namespace clang
31 changes: 31 additions & 0 deletions clang/test/ClangScanDeps/implicit-target.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Check that we can detect an implicit target when clang is invoked as
// <triple->clang. Using an implicit triple requires that the target actually
// is available, too.
// REQUIRES: x86-registered-target

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json

// Check that we can deduce this both when using a compilation database, and when using
// a literal command line.

// RUN: clang-scan-deps -format experimental-full -compilation-database %t/cdb.json | FileCheck %s

// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang %t/source.c -o %t/source.o | FileCheck %s

// CHECK: "-triple",
// CHECK-NEXT: "x86_64-w64-windows-gnu",


//--- cdb.json.in
[
{
"directory": "DIR"
"command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o"
"file": "DIR/source.c"
},
]

//--- source.c
void func(void) {}
3 changes: 1 addition & 2 deletions clang/test/ClangScanDeps/modules-extern-submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ module third {}
// CHECK: "-fmodule-map-file=[[PREFIX]]/first/first/module.modulemap",
// CHECK: "-fmodule-file=first=[[PREFIX]]/cache/{{.*}}/first-{{.*}}.pcm",
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
Expand Down
6 changes: 2 additions & 4 deletions clang/test/ClangScanDeps/modules-full-output-tu-order.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
// CHECK: "-D"
// CHECK-NEXT: "ONE"
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.c"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
Expand All @@ -52,8 +51,7 @@
// CHECK: "-D"
// CHECK-NEXT: "TWO"
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.c"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ module Dependency { header "dependency.h" }
// CHECK: ],
// CHECK-NEXT: "command-line": [
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.c"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
Expand Down
3 changes: 1 addition & 2 deletions clang/test/ClangScanDeps/modules-header-sharing.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
// CHECK: "-fmodule-name=A",
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m",
// CHECK-NEXT: "[[PREFIX]]/shared/H.h"
// CHECK-NEXT: ],
Expand Down
3 changes: 1 addition & 2 deletions clang/test/ClangScanDeps/modules-implementation-module-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ framework module FWPrivate { header "private.h" }
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
// CHECK: "-fmodule-name=FWPrivate",
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
Expand Down
3 changes: 1 addition & 2 deletions clang/test/ClangScanDeps/modules-implementation-private.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
// CHECK-NEXT: ],
// CHECK-NEXT: "command-line": [
// CHECK: ],
// CHECK-NEXT: "executable": "clang",
// CHECK-NEXT: "file-deps": [
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Missed.h",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
Expand Down
Loading

0 comments on commit a1d84b3

Please sign in to comment.