Skip to content

Commit 3066d80

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.4 [skip ci]
2 parents fef3b8b + 4b75fcf commit 3066d80

File tree

508 files changed

+200986
-84186
lines changed

Some content is hidden

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

508 files changed

+200986
-84186
lines changed

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,8 @@ class DataAggregator : public DataReader {
198198
/// A trace is region of code executed between two LBR entries supplied in
199199
/// execution order.
200200
///
201-
/// Return true if the trace is valid, false otherwise.
202-
bool
203-
recordTrace(BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204-
uint64_t Count,
205-
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const;
206-
207201
/// Return a vector of offsets corresponding to a trace in a function
208-
/// (see recordTrace() above).
202+
/// if the trace is valid, std::nullopt otherwise.
209203
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
210204
getFallthroughsInTrace(BinaryFunction &BF, const LBREntry &First,
211205
const LBREntry &Second, uint64_t Count = 1) const;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,17 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
861861
return true;
862862
}
863863

864-
bool DataAggregator::recordTrace(
865-
BinaryFunction &BF, const LBREntry &FirstLBR, const LBREntry &SecondLBR,
866-
uint64_t Count,
867-
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const {
864+
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
865+
DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
866+
const LBREntry &FirstLBR,
867+
const LBREntry &SecondLBR,
868+
uint64_t Count) const {
869+
SmallVector<std::pair<uint64_t, uint64_t>, 16> Branches;
870+
868871
BinaryContext &BC = BF.getBinaryContext();
869872

870873
if (!BF.isSimple())
871-
return false;
874+
return std::nullopt;
872875

873876
assert(BF.hasCFG() && "can only record traces in CFG state");
874877

@@ -877,13 +880,13 @@ bool DataAggregator::recordTrace(
877880
const uint64_t To = SecondLBR.From - BF.getAddress();
878881

879882
if (From > To)
880-
return false;
883+
return std::nullopt;
881884

882885
const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(From);
883886
const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset(To);
884887

885888
if (!FromBB || !ToBB)
886-
return false;
889+
return std::nullopt;
887890

888891
// Adjust FromBB if the first LBR is a return from the last instruction in
889892
// the previous block (that instruction should be a call).
@@ -907,7 +910,7 @@ bool DataAggregator::recordTrace(
907910
// within the same basic block, e.g. when two call instructions are in the
908911
// same block. In this case we skip the processing.
909912
if (FromBB == ToBB)
910-
return true;
913+
return Branches;
911914

912915
// Process blocks in the original layout order.
913916
BinaryBasicBlock *BB = BF.getLayout().getBlock(FromBB->getIndex());
@@ -921,7 +924,7 @@ bool DataAggregator::recordTrace(
921924
LLVM_DEBUG(dbgs() << "no fall-through for the trace:\n"
922925
<< " " << FirstLBR << '\n'
923926
<< " " << SecondLBR << '\n');
924-
return false;
927+
return std::nullopt;
925928
}
926929

927930
const MCInst *Instr = BB->getLastNonPseudoInstr();
@@ -945,20 +948,7 @@ bool DataAggregator::recordTrace(
945948
BI.Count += Count;
946949
}
947950

948-
return true;
949-
}
950-
951-
std::optional<SmallVector<std::pair<uint64_t, uint64_t>, 16>>
952-
DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
953-
const LBREntry &FirstLBR,
954-
const LBREntry &SecondLBR,
955-
uint64_t Count) const {
956-
SmallVector<std::pair<uint64_t, uint64_t>, 16> Res;
957-
958-
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, Res))
959-
return std::nullopt;
960-
961-
return Res;
951+
return Branches;
962952
}
963953

964954
bool DataAggregator::recordEntry(BinaryFunction &BF, uint64_t To, bool Mispred,

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
248248
/// Update ORC data in the binary.
249249
Error rewriteORCTables();
250250

251+
/// Validate written ORC tables after binary emission.
252+
Error validateORCTables();
253+
251254
/// Static call table handling.
252255
Error readStaticCalls();
253256
Error rewriteStaticCalls();
@@ -358,6 +361,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
358361
if (Error E = updateStaticKeysJumpTablePostEmit())
359362
return E;
360363

364+
if (Error E = validateORCTables())
365+
return E;
366+
361367
return Error::success();
362368
}
363369
};
@@ -837,6 +843,32 @@ Error LinuxKernelRewriter::rewriteORCTables() {
837843
return Error::success();
838844
}
839845

846+
Error LinuxKernelRewriter::validateORCTables() {
847+
if (!ORCUnwindIPSection)
848+
return Error::success();
849+
850+
const uint64_t IPSectionAddress = ORCUnwindIPSection->getAddress();
851+
DataExtractor IPDE = DataExtractor(ORCUnwindIPSection->getOutputContents(),
852+
BC.AsmInfo->isLittleEndian(),
853+
BC.AsmInfo->getCodePointerSize());
854+
DataExtractor::Cursor IPCursor(0);
855+
uint64_t PrevIP = 0;
856+
for (uint32_t Index = 0; Index < NumORCEntries; ++Index) {
857+
const uint64_t IP =
858+
IPSectionAddress + IPCursor.tell() + (int32_t)IPDE.getU32(IPCursor);
859+
if (!IPCursor)
860+
return createStringError(errc::executable_format_error,
861+
"out of bounds while reading ORC IP table: %s",
862+
toString(IPCursor.takeError()).c_str());
863+
864+
assert(IP >= PrevIP && "Unsorted ORC table detected");
865+
(void)PrevIP;
866+
PrevIP = IP;
867+
}
868+
869+
return Error::success();
870+
}
871+
840872
/// The static call site table is created by objtool and contains entries in the
841873
/// following format:
842874
///

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ Changes in existing checks
261261

262262
- Improved :doc:`misc-const-correctness
263263
<clang-tidy/checks/misc/const-correctness>` check by avoiding infinite recursion
264-
for recursive forwarding reference.
264+
for recursive functions with forwarding reference parameters and reference
265+
variables which refer to themselves.
265266

266267
- Improved :doc:`misc-definitions-in-headers
267268
<clang-tidy/checks/misc/definitions-in-headers>` check by replacing the local

clang-tools-extra/test/CMakeLists.txt

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,30 @@ foreach(dep ${LLVM_UTILS_DEPS})
6767
endif()
6868
endforeach()
6969

70-
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
71-
if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
72-
llvm_add_library(
73-
CTTestTidyModule
74-
MODULE clang-tidy/CTTestTidyModule.cpp
75-
PLUGIN_TOOL clang-tidy
76-
DEPENDS clang-tidy-headers)
77-
endif()
70+
if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
71+
llvm_add_library(
72+
CTTestTidyModule
73+
MODULE clang-tidy/CTTestTidyModule.cpp
74+
PLUGIN_TOOL clang-tidy)
75+
endif()
7876

79-
if(CLANG_BUILT_STANDALONE)
80-
# LLVMHello library is needed below
81-
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
82-
AND NOT TARGET LLVMHello)
83-
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
84-
lib/Transforms/Hello)
85-
endif()
77+
if(CLANG_BUILT_STANDALONE)
78+
# LLVMHello library is needed below
79+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
80+
AND NOT TARGET LLVMHello)
81+
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
82+
lib/Transforms/Hello)
8683
endif()
84+
endif()
8785

88-
if(TARGET CTTestTidyModule)
89-
list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
90-
target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
91-
if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
92-
set(LLVM_LINK_COMPONENTS
93-
Support
94-
)
95-
endif()
96-
endif()
86+
if(TARGET CTTestTidyModule)
87+
list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
88+
target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
89+
if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
90+
set(LLVM_LINK_COMPONENTS
91+
Support
92+
)
93+
endif()
9794
endif()
9895

9996
add_lit_testsuite(check-clang-extra "Running clang-tools-extra/test"

clang-tools-extra/test/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config.python_executable = "@Python3_EXECUTABLE@"
1010
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1111
config.host_triple = "@LLVM_HOST_TRIPLE@"
1212
config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
13-
config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
13+
config.has_plugins = @CLANG_PLUGIN_SUPPORT@
1414
# Support substitution of the tools and libs dirs with user parameters. This is
1515
# used when we can't determine the tool dir at configuration time.
1616
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")

clang/docs/Multilib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ For a more comprehensive example see
188188
- Dir: thumb/v6-m
189189
# List of one or more normalized command line options, as generated by Clang
190190
# from the command line options or from Mappings below.
191-
# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
191+
# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
192192
# then this multilib variant will be considered a match.
193-
Flags: [--target=thumbv6m-none-unknown-eabi]
193+
Flags: [--target=thumbv6m-unknown-none-eabi]
194194
195195
# Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
196196
# point unit).

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ Bug Fixes in This Version
472472
- Clang now correctly generates overloads for bit-precise integer types for
473473
builtin operators in C++. Fixes #GH82998.
474474

475+
- Fix crash when destructor definition is preceded with an equals sign.
476+
Fixes (#GH89544).
477+
475478
- When performing mixed arithmetic between ``_Complex`` floating-point types and integers,
476479
Clang now correctly promotes the integer to its corresponding real floating-point
477480
type only rather than to the complex type (e.g. ``_Complex float / int`` is now evaluated
@@ -739,10 +742,10 @@ AIX Support
739742
WebAssembly Support
740743
^^^^^^^^^^^^^^^^^^^
741744

742-
The -mcpu=generic configuration now enables multivalue and reference-types.These
743-
proposals are standardized and available in all major engines. Enabling
744-
multivalue here only enables the language feature but does not turn on the
745-
multivalue ABI (this enables non-ABI uses of multivalue, like exnref).
745+
The -mcpu=generic configuration now enables multivalue feature, which is
746+
standardized and available in all major engines. Enabling multivalue here only
747+
enables the language feature but does not turn on the multivalue ABI (this
748+
enables non-ABI uses of multivalue, like exnref).
746749

747750
AVR Support
748751
^^^^^^^^^^^

clang/docs/UsersManual.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,6 @@ for more details.
16961696
* ``-fno-associative-math``
16971697
* ``-fno-reciprocal-math``
16981698
* ``-fsigned-zeros``
1699-
* ``-ftrapping-math``
17001699
* ``-ffp-contract=on``
17011700

17021701
There is ambiguity about how ``-ffp-contract``,

clang/include/clang/AST/ExprCXX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,8 @@ class CXXTemporary {
14821482
/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
14831483
/// }
14841484
/// \endcode
1485+
///
1486+
/// Destructor might be null if destructor declaration is not valid.
14851487
class CXXBindTemporaryExpr : public Expr {
14861488
CXXTemporary *Temp = nullptr;
14871489
Stmt *SubExpr = nullptr;

clang/include/clang/Basic/DiagnosticInstallAPIKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant
2424
def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
2525
def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">;
2626
def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
27-
def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
27+
def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">;
2828
} // end of command line category.
2929

3030
let CategoryName = "Verification" in {

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,13 +1438,18 @@ def err_omp_decl_in_declare_simd_variant : Error<
14381438
def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 %select{sink:|source:}1' must be with '%select{omp_cur_iteration - 1|omp_cur_iteration}1'">;
14391439
def err_omp_unknown_map_type : Error<
14401440
"incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">;
1441+
def err_omp_more_one_map_type : Error<"map type is already specified">;
1442+
def note_previous_map_type_specified_here
1443+
: Note<"map type '%0' is previous specified here">;
14411444
def err_omp_unknown_map_type_modifier : Error<
14421445
"incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
14431446
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
14441447
def err_omp_map_type_missing : Error<
14451448
"missing map type">;
14461449
def err_omp_map_type_modifier_missing : Error<
14471450
"missing map type modifier">;
1451+
def err_omp_map_modifier_specification_list : Error<
1452+
"empty modifier-specification-list is not allowed">;
14481453
def err_omp_declare_simd_inbranch_notinbranch : Error<
14491454
"unexpected '%0' clause, '%1' is specified already">;
14501455
def err_omp_expected_clause_argument

clang/include/clang/InstallAPI/FileList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class FileListReader {
2929
///
3030
/// \param InputBuffer JSON input data.
3131
/// \param Destination Container to load headers into.
32+
/// \param FM Optional File Manager to validate input files exist.
3233
static llvm::Error
3334
loadHeaders(std::unique_ptr<llvm::MemoryBuffer> InputBuffer,
34-
HeaderSeq &Destination);
35+
HeaderSeq &Destination, clang::FileManager *FM = nullptr);
3536

3637
FileListReader() = delete;
3738
};

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ class StoredDeclsList;
7676
class SwitchCase;
7777
class Token;
7878

79+
namespace SrcMgr {
80+
class FileInfo;
81+
} // namespace SrcMgr
82+
7983
/// Writes an AST file containing the contents of a translation unit.
8084
///
8185
/// The ASTWriter class produces a bitstream containing the serialized
@@ -490,6 +494,11 @@ class ASTWriter : public ASTDeserializationListener,
490494
/// during \c SourceManager serialization.
491495
void computeNonAffectingInputFiles();
492496

497+
/// Some affecting files can be included from files that are not affecting.
498+
/// This function erases source locations pointing into such files.
499+
SourceLocation getAffectingIncludeLoc(const SourceManager &SourceMgr,
500+
const SrcMgr::FileInfo &File);
501+
493502
/// Returns an adjusted \c FileID, accounting for any non-affecting input
494503
/// files.
495504
FileID getAdjustedFileID(FileID FID) const;

clang/lib/AST/Expr.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,9 +3893,14 @@ namespace {
38933893
}
38943894

38953895
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) {
3896-
if (E->getTemporary()->getDestructor()->isTrivial()) {
3897-
Inherited::VisitStmt(E);
3898-
return;
3896+
// Destructor of the temporary might be null if destructor declaration
3897+
// is not valid.
3898+
if (const CXXDestructorDecl *DtorDecl =
3899+
E->getTemporary()->getDestructor()) {
3900+
if (DtorDecl->isTrivial()) {
3901+
Inherited::VisitStmt(E);
3902+
return;
3903+
}
38993904
}
39003905

39013906
NonTrivial = true;

clang/lib/AST/ExprClassification.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,13 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
216216
return ClassifyInternal(Ctx,
217217
cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement());
218218

219-
case Expr::PackIndexingExprClass:
219+
case Expr::PackIndexingExprClass: {
220+
// A pack-index-expression always expands to an id-expression.
221+
// Consider it as an LValue expression.
222+
if (cast<PackIndexingExpr>(E)->isInstantiationDependent())
223+
return Cl::CL_LValue;
220224
return ClassifyInternal(Ctx, cast<PackIndexingExpr>(E)->getSelectedExpr());
225+
}
221226

222227
// C, C++98 [expr.sub]p1: The result is an lvalue of type "T".
223228
// C++11 (DR1213): in the case of an array operand, the result is an lvalue

clang/lib/Analysis/ExprMutationAnalyzer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,17 @@ const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
235235
if (Memoized != MemoizedResults.end())
236236
return Memoized->second;
237237

238+
// Assume Exp is not mutated before analyzing Exp.
239+
MemoizedResults[Exp] = nullptr;
238240
if (isUnevaluated(Exp))
239-
return MemoizedResults[Exp] = nullptr;
241+
return nullptr;
240242

241243
for (const auto &Finder : Finders) {
242244
if (const Stmt *S = (this->*Finder)(Exp))
243245
return MemoizedResults[Exp] = S;
244246
}
245247

246-
return MemoizedResults[Exp] = nullptr;
248+
return nullptr;
247249
}
248250

249251
const Stmt *

0 commit comments

Comments
 (0)