Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions clang/include/clang/AST/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
///
/// Precompiled header for clangAST.
///
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CanonicalType.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/OpenMPClause.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Type.h"
#include "llvm/Support/pch.h"
3 changes: 3 additions & 0 deletions clang/lib/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ add_clang_library(clangAST
VTableBuilder.cpp
VTTBuilder.cpp

PRECOMPILE_HEADERS
[["clang/AST/pch.h"]]

LINK_LIBS
clangBasic
clangLex
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/CodeGen/CGLoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
#include <optional>
using namespace clang::CodeGen;
using namespace llvm;

// No using namespace to avoid collision with llvm::LoopInfo.
namespace clang::CodeGen {

MDNode *
LoopInfo::createFollowupMetadata(const char *FollowupName,
ArrayRef<llvm::Metadata *> LoopProperties) {
Expand Down Expand Up @@ -863,3 +865,4 @@ void LoopInfoStack::InsertHelper(Instruction *I) const {
return;
}
}
} // end namespace clang::CodeGen
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ add_clang_library(clangCodeGen
TrapReasonBuilder.cpp
VarBypassDetector.cpp

DISABLE_PCH_REUSE # PCH contains private headers
PRECOMPILE_HEADERS
[["pch.h"]]

DEPENDS
vt_gen
intrinsics_gen
Expand Down
22 changes: 22 additions & 0 deletions clang/lib/CodeGen/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
///
/// Precompiled header for clangCodeGen. Uses private headers.
///
//===----------------------------------------------------------------------===//

#include "ABIInfoImpl.h"
#include "Address.h"
#include "CGBuilder.h"
#include "CGCXXABI.h"
#include "CGValue.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/pch.h"
#include "llvm/IR/pch.h"
#include "llvm/Support/pch.h"
4 changes: 2 additions & 2 deletions clang/lib/Frontend/TextDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static constexpr raw_ostream::Colors SavedColor = raw_ostream::SAVEDCOLOR;
// is already taken for 'note'. Green is already used to underline
// source ranges. White and black are bad because of the usual
// terminal backgrounds. Which leaves us only with TWO options.
static constexpr raw_ostream::Colors CommentColor = raw_ostream::YELLOW;
static constexpr raw_ostream::Colors TCommentColor = raw_ostream::YELLOW;
static constexpr raw_ostream::Colors LiteralColor = raw_ostream::GREEN;
static constexpr raw_ostream::Colors KeywordColor = raw_ostream::BLUE;

Expand Down Expand Up @@ -1269,7 +1269,7 @@ highlightLines(StringRef FileData, unsigned StartLineNumber,
Vec.emplace_back(Start, Start + Length, LiteralColor);
} else {
assert(T.is(tok::comment));
Vec.emplace_back(Start, Start + Length, CommentColor);
Vec.emplace_back(Start, Start + Length, TCommentColor);
}
};

Expand Down
2 changes: 2 additions & 0 deletions clang/tools/c-index-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(LLVM_LINK_COMPONENTS
add_clang_executable(c-index-test
c-index-test.c
core_main.cpp

DISABLE_PCH_REUSE # Prevent CMake error with C source files.
)

if(NOT MSVC)
Expand Down
2 changes: 2 additions & 0 deletions clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
add_clang_executable(clang-fuzzer-dictionary
dictionary.c

DISABLE_PCH_REUSE # no C++ files, prevent CMake error.
)

1 change: 0 additions & 1 deletion clang/unittests/Basic/CharInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "clang/Basic/CharInfo.h"
#include "gtest/gtest.h"

using namespace llvm;
using namespace clang;

// Check that the CharInfo table has been constructed reasonably.
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The interpreter can throw an exception from user input. The test binary needs
# to be compiled with exception support to catch the thrown exception.
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)
set(LLVM_REQUIRES_RTTI OFF)

add_distinct_clang_unittest(ClangReplInterpreterExceptionTests
InterpreterExceptionTest.cpp
Expand Down
10 changes: 0 additions & 10 deletions flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,6 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
if (BUILD_SHARED_LIBS AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-semantic-interposition")
endif()

# GCC requires this flag in order for precompiled headers to work with ccache
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpch-preprocess")
endif()
endif()

# Clang on Darwin enables non-POSIX extensions by default, which allows the
Expand All @@ -456,11 +451,6 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_POSIX_C_SOURCE=200809")
endif()

# Clang requires this flag in order for precompiled headers to work with ccache
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fno-pch-timestamp")
endif()

list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS)

# Determine HOST_LINK_VERSION on Darwin.
Expand Down
18 changes: 9 additions & 9 deletions flang/lib/Evaluate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,8 @@ add_flang_library(FortranEvaluate
${LIBPGMATH}
${QUADMATHLIB}

LINK_COMPONENTS
Support

DEPENDS
acc_gen
omp_gen
)

target_precompile_headers(FortranEvaluate PRIVATE
DISABLE_PCH_REUSE
PRECOMPILE_HEADERS
[["flang/Evaluate/common.h"]]
[["flang/Evaluate/call.h"]]
[["flang/Evaluate/traverse.h"]]
Expand All @@ -86,4 +79,11 @@ target_precompile_headers(FortranEvaluate PRIVATE
[["flang/Evaluate/integer.h"]]
[["flang/Evaluate/expression.h"]]
[["flang/Evaluate/tools.h"]]

LINK_COMPONENTS
Support

DEPENDS
acc_gen
omp_gen
)
16 changes: 8 additions & 8 deletions flang/lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ add_flang_library(flangFrontend
TextDiagnosticBuffer.cpp
TextDiagnostic.cpp

DISABLE_PCH_REUSE
PRECOMPILE_HEADERS
[["flang/Parser/parsing.h"]]
[["flang/Parser/parse-tree.h"]]
[["flang/Parser/dump-parse-tree.h"]]
[["flang/Lower/PFTBuilder.h"]]
[["flang/Lower/Bridge.h"]]

DEPENDS
CUFDialect
FIRDialect
Expand Down Expand Up @@ -78,11 +86,3 @@ add_flang_library(flangFrontend
clangBasic
clangOptions
)

target_precompile_headers(flangFrontend PRIVATE
[["flang/Parser/parsing.h"]]
[["flang/Parser/parse-tree.h"]]
[["flang/Parser/dump-parse-tree.h"]]
[["flang/Lower/PFTBuilder.h"]]
[["flang/Lower/Bridge.h"]]
)
22 changes: 11 additions & 11 deletions flang/lib/Lower/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ add_flang_library(FortranLower
Support/Utils.cpp
SymbolMap.cpp
VectorSubscripts.cpp

DISABLE_PCH_REUSE
PRECOMPILE_HEADERS
[["flang/Lower/ConvertExpr.h"]]
[["flang/Lower/SymbolMap.h"]]
[["flang/Lower/AbstractConverter.h"]]
[["flang/Lower/IterationSpace.h"]]
[["flang/Lower/CallInterface.h"]]
[["flang/Lower/BoxAnalyzer.h"]]
[["flang/Lower/PFTBuilder.h"]]
[["flang/Lower/DirectivesCommon.h"]]

DEPENDS
CUFAttrs
Expand Down Expand Up @@ -79,14 +90,3 @@ add_flang_library(FortranLower
MLIRLLVMDialect
MLIRSCFToControlFlow
)

target_precompile_headers(FortranLower PRIVATE
[["flang/Lower/ConvertExpr.h"]]
[["flang/Lower/SymbolMap.h"]]
[["flang/Lower/AbstractConverter.h"]]
[["flang/Lower/IterationSpace.h"]]
[["flang/Lower/CallInterface.h"]]
[["flang/Lower/BoxAnalyzer.h"]]
[["flang/Lower/PFTBuilder.h"]]
[["flang/Lower/DirectivesCommon.h"]]
)
16 changes: 8 additions & 8 deletions flang/lib/Parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ add_flang_library(FortranParser
unparse.cpp
user-state.cpp

DISABLE_PCH_REUSE
PRECOMPILE_HEADERS
[["flang/Parser/parsing.h"]]
[["flang/Parser/parse-tree.h"]]
[["flang/Parser/provenance.h"]]
[["flang/Parser/message.h"]]
[["flang/Parser/parse-tree-visitor.h"]]

LINK_LIBS
FortranSupport

Expand All @@ -37,11 +45,3 @@ add_flang_library(FortranParser
omp_gen
acc_gen
)

target_precompile_headers(FortranParser PRIVATE
[["flang/Parser/parsing.h"]]
[["flang/Parser/parse-tree.h"]]
[["flang/Parser/provenance.h"]]
[["flang/Parser/message.h"]]
[["flang/Parser/parse-tree-visitor.h"]]
)
18 changes: 9 additions & 9 deletions flang/lib/Semantics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ add_flang_library(FortranSemantics
type.cpp
unparse-with-symbols.cpp

DISABLE_PCH_REUSE
PRECOMPILE_HEADERS
[["flang/Semantics/semantics.h"]]
[["flang/Semantics/type.h"]]
[["flang/Semantics/openmp-modifiers.h"]]
[["flang/Semantics/expression.h"]]
[["flang/Semantics/tools.h"]]
[["flang/Semantics/symbol.h"]]

DEPENDS
acc_gen
omp_gen
Expand All @@ -68,12 +77,3 @@ add_flang_library(FortranSemantics
FrontendOpenACC
TargetParser
)

target_precompile_headers(FortranSemantics PRIVATE
[["flang/Semantics/semantics.h"]]
[["flang/Semantics/type.h"]]
[["flang/Semantics/openmp-modifiers.h"]]
[["flang/Semantics/expression.h"]]
[["flang/Semantics/tools.h"]]
[["flang/Semantics/symbol.h"]]
)
10 changes: 5 additions & 5 deletions lld/MachO/Arch/ARM64Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int64_t ARM64Common::getEmbeddedAddend(MemoryBufferRef mb, uint64_t offset,
}
}

static void writeValue(uint8_t *loc, const Reloc &r, uint64_t value) {
static void writeValue(uint8_t *loc, const Relocation &r, uint64_t value) {
switch (r.length) {
case 2:
checkInt(loc, r, value, 32);
Expand All @@ -57,7 +57,7 @@ static void writeValue(uint8_t *loc, const Reloc &r, uint64_t value) {
// instruction has opcode & register-operand bits set, with immediate
// operands zeroed. We read it from text, OR-in the immediate
// operands, then write-back the completed instruction.
void ARM64Common::relocateOne(uint8_t *loc, const Reloc &r, uint64_t value,
void ARM64Common::relocateOne(uint8_t *loc, const Relocation &r, uint64_t value,
uint64_t pc) const {
auto loc32 = reinterpret_cast<uint32_t *>(loc);
uint32_t base = ((r.length == 2) ? read32le(loc) : 0);
Expand Down Expand Up @@ -110,7 +110,7 @@ void ARM64Common::relaxGotLoad(uint8_t *loc, uint8_t type) const {
write32le(loc, instruction);
}

void ARM64Common::handleDtraceReloc(const Symbol *sym, const Reloc &r,
void ARM64Common::handleDtraceReloc(const Symbol *sym, const Relocation &r,
uint8_t *loc) const {
assert(r.type == ARM64_RELOC_BRANCH26);

Expand Down Expand Up @@ -138,8 +138,8 @@ static void reportUnalignedLdrStr(Twine loc, uint64_t va, int align,
"-byte aligned");
}

void macho::reportUnalignedLdrStr(void *loc, const lld::macho::Reloc &r,
uint64_t va, int align) {
void macho::reportUnalignedLdrStr(void *loc, const Relocation &r, uint64_t va,
int align) {
uint64_t off = reinterpret_cast<const uint8_t *>(loc) - in.bufferStart;
const InputSection *isec = offsetToInputSection(&off);
std::string locStr = isec ? isec->getLocation(off) : "(invalid location)";
Expand Down
11 changes: 6 additions & 5 deletions lld/MachO/Arch/ARM64Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ struct ARM64Common : TargetInfo {

int64_t getEmbeddedAddend(MemoryBufferRef, uint64_t offset,
const llvm::MachO::relocation_info) const override;
void relocateOne(uint8_t *loc, const Reloc &, uint64_t va,
void relocateOne(uint8_t *loc, const Relocation &, uint64_t va,
uint64_t pc) const override;

void relaxGotLoad(uint8_t *loc, uint8_t type) const override;
uint64_t getPageSize() const override { return 16 * 1024; }

void handleDtraceReloc(const Symbol *sym, const Reloc &r,
void handleDtraceReloc(const Symbol *sym, const Relocation &r,
uint8_t *loc) const override;
};

Expand All @@ -42,7 +42,7 @@ inline uint64_t bitField(uint64_t value, int right, int width, int left) {
// | | imm26 |
// +-----------+---------------------------------------------------+

inline void encodeBranch26(uint32_t *loc, const Reloc &r, uint32_t base,
inline void encodeBranch26(uint32_t *loc, const Relocation &r, uint32_t base,
uint64_t va) {
checkInt(loc, r, va, 28);
// Since branch destinations are 4-byte aligned, the 2 least-
Expand All @@ -61,7 +61,7 @@ inline void encodeBranch26(uint32_t *loc, SymbolDiagnostic d, uint32_t base,
// | |ilo| | immhi | |
// +-+---+---------+-------------------------------------+---------+

inline void encodePage21(uint32_t *loc, const Reloc &r, uint32_t base,
inline void encodePage21(uint32_t *loc, const Relocation &r, uint32_t base,
uint64_t va) {
checkInt(loc, r, va, 35);
llvm::support::endian::write32le(loc, base | bitField(va, 12, 2, 29) |
Expand All @@ -75,7 +75,8 @@ inline void encodePage21(uint32_t *loc, SymbolDiagnostic d, uint32_t base,
bitField(va, 14, 19, 5));
}

void reportUnalignedLdrStr(void *loc, const Reloc &, uint64_t va, int align);
void reportUnalignedLdrStr(void *loc, const Relocation &, uint64_t va,
int align);
void reportUnalignedLdrStr(void *loc, SymbolDiagnostic, uint64_t va, int align);

// 21 10
Expand Down
Loading