Skip to content

Commit d6e508f

Browse files
authored
Merge branch 'main' into remove_no_op_bitcast_DXIL_reland
2 parents bb2c58e + fccab5d commit d6e508f

File tree

1,240 files changed

+53369
-24321
lines changed

Some content is hidden

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

1,240 files changed

+53369
-24321
lines changed

bolt/lib/Passes/RetpolineInsertion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ std::string createRetpolineFunctionTag(BinaryContext &BC,
195195

196196
TagOS << "+";
197197
if (MemRef.DispExpr)
198-
MemRef.DispExpr->print(TagOS, BC.AsmInfo.get());
198+
BC.AsmInfo->printExpr(TagOS, *MemRef.DispExpr);
199199
else
200200
TagOS << MemRef.DispImm;
201201

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ FilterMemProfile("filter-mem-profile",
6161
cl::init(true),
6262
cl::cat(AggregatorCategory));
6363

64+
static cl::opt<bool> ParseMemProfile(
65+
"parse-mem-profile",
66+
cl::desc("enable memory profile parsing if it's present in the input data, "
67+
"on by default unless `--itrace` is set."),
68+
cl::init(true), cl::cat(AggregatorCategory));
69+
6470
static cl::opt<unsigned long long>
6571
FilterPID("pid",
6672
cl::desc("only use samples from process with specified PID"),
@@ -181,6 +187,10 @@ void DataAggregator::start() {
181187
"script -F pid,event,ip",
182188
/*Wait = */false);
183189
} else if (!opts::ITraceAggregation.empty()) {
190+
// Disable parsing memory profile from trace data, unless requested by user.
191+
if (!opts::ParseMemProfile.getNumOccurrences())
192+
opts::ParseMemProfile = false;
193+
184194
std::string ItracePerfScriptArgs = llvm::formatv(
185195
"script -F pid,brstack --itrace={0}", opts::ITraceAggregation);
186196
launchPerfProcess("branch events with itrace", MainEventsPPI,
@@ -191,12 +201,9 @@ void DataAggregator::start() {
191201
/*Wait = */ false);
192202
}
193203

194-
// Note: we launch script for mem events regardless of the option, as the
195-
// command fails fairly fast if mem events were not collected.
196-
launchPerfProcess("mem events",
197-
MemEventsPPI,
198-
"script -F pid,event,addr,ip",
199-
/*Wait = */false);
204+
if (opts::ParseMemProfile)
205+
launchPerfProcess("mem events", MemEventsPPI, "script -F pid,event,addr,ip",
206+
/*Wait = */ false);
200207

201208
launchPerfProcess("process events", MMapEventsPPI,
202209
"script --show-mmap-events --no-itrace",
@@ -217,7 +224,8 @@ void DataAggregator::abort() {
217224
sys::Wait(TaskEventsPPI.PI, 1, &Error);
218225
sys::Wait(MMapEventsPPI.PI, 1, &Error);
219226
sys::Wait(MainEventsPPI.PI, 1, &Error);
220-
sys::Wait(MemEventsPPI.PI, 1, &Error);
227+
if (opts::ParseMemProfile)
228+
sys::Wait(MemEventsPPI.PI, 1, &Error);
221229

222230
deleteTempFiles();
223231

@@ -506,7 +514,8 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
506514
errs() << "PERF2BOLT: failed to parse samples\n";
507515

508516
// Special handling for memory events
509-
if (!prepareToParse("mem events", MemEventsPPI, MemEventsErrorCallback))
517+
if (opts::ParseMemProfile &&
518+
!prepareToParse("mem events", MemEventsPPI, MemEventsErrorCallback))
510519
if (const std::error_code EC = parseMemEvents())
511520
errs() << "PERF2BOLT: failed to parse memory events: " << EC.message()
512521
<< '\n';

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "MCTargetDesc/RISCVMCExpr.h"
13+
#include "MCTargetDesc/RISCVMCAsmInfo.h"
1414
#include "MCTargetDesc/RISCVMCTargetDesc.h"
1515
#include "bolt/Core/MCPlusBuilder.h"
1616
#include "llvm/BinaryFormat/ELF.h"
@@ -33,8 +33,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
3333

3434
bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
3535
CompFuncTy Comp) const override {
36-
const auto &RISCVExprA = cast<RISCVMCExpr>(A);
37-
const auto &RISCVExprB = cast<RISCVMCExpr>(B);
36+
const auto &RISCVExprA = cast<MCSpecifierExpr>(A);
37+
const auto &RISCVExprB = cast<MCSpecifierExpr>(B);
3838
if (RISCVExprA.getSpecifier() != RISCVExprB.getSpecifier())
3939
return false;
4040

@@ -245,7 +245,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
245245
MCContext *Ctx) {
246246
Inst.setOpcode(Opcode);
247247
Inst.clear();
248-
Inst.addOperand(MCOperand::createExpr(RISCVMCExpr::create(
248+
Inst.addOperand(MCOperand::createExpr(MCSpecifierExpr::create(
249249
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx),
250250
ELF::R_RISCV_CALL_PLT, *Ctx)));
251251
}
@@ -342,7 +342,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
342342
}
343343

344344
const MCSymbol *getTargetSymbol(const MCExpr *Expr) const override {
345-
auto *RISCVExpr = dyn_cast<RISCVMCExpr>(Expr);
345+
auto *RISCVExpr = dyn_cast<MCSpecifierExpr>(Expr);
346346
if (RISCVExpr && RISCVExpr->getSubExpr())
347347
return getTargetSymbol(RISCVExpr->getSubExpr());
348348

@@ -435,19 +435,19 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
435435
case ELF::R_RISCV_TLS_GD_HI20:
436436
// The GOT is reused so no need to create GOT relocations
437437
case ELF::R_RISCV_PCREL_HI20:
438-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx);
438+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx);
439439
case ELF::R_RISCV_PCREL_LO12_I:
440440
case ELF::R_RISCV_PCREL_LO12_S:
441-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_LO, Ctx);
441+
return MCSpecifierExpr::create(Expr, RISCV::S_PCREL_LO, Ctx);
442442
case ELF::R_RISCV_HI20:
443-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_HI20, Ctx);
443+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_HI20, Ctx);
444444
case ELF::R_RISCV_LO12_I:
445445
case ELF::R_RISCV_LO12_S:
446-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_LO, Ctx);
446+
return MCSpecifierExpr::create(Expr, RISCV::S_LO, Ctx);
447447
case ELF::R_RISCV_CALL:
448-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
448+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
449449
case ELF::R_RISCV_CALL_PLT:
450-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
450+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
451451
}
452452
}
453453

@@ -466,10 +466,10 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
466466
return false;
467467

468468
const auto *ImmExpr = ImmOp.getExpr();
469-
if (!isa<RISCVMCExpr>(ImmExpr))
469+
if (!isa<MCSpecifierExpr>(ImmExpr))
470470
return false;
471471

472-
switch (cast<RISCVMCExpr>(ImmExpr)->getSpecifier()) {
472+
switch (cast<MCSpecifierExpr>(ImmExpr)->getSpecifier()) {
473473
default:
474474
return false;
475475
case ELF::R_RISCV_CALL_PLT:

bolt/lib/Utils/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
66

77
set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
88

9+
if(llvm_vc AND LLVM_APPEND_VC_REV)
10+
set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
11+
endif()
12+
if(LLVM_VC_REPOSITORY AND LLVM_VC_REVISION)
13+
set(llvm_source_dir ${LLVM_SOURCE_DIR})
14+
set(llvm_vc_repository ${LLVM_VC_REPOSITORY})
15+
set(llvm_vc_revision ${LLVM_VC_REVISION})
16+
endif()
17+
if(bolt_vc AND LLVM_APPEND_VC_REV)
18+
set(bolt_source_dir ${BOLT_SOURCE_DIR})
19+
endif()
20+
921
# Create custom target to generate the VC revision include.
1022
add_custom_command(OUTPUT "${version_inc}"
1123
DEPENDS "${llvm_vc}" "${bolt_vc}" "${generate_vcs_version_script}"
1224
COMMAND ${CMAKE_COMMAND} "-DNAMES=BOLT"
25+
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
26+
"-DBOLT_SOURCE_DIR=${bolt_source_dir}"
1327
"-DHEADER_FILE=${version_inc}"
14-
"-DBOLT_SOURCE_DIR=${BOLT_SOURCE_DIR}"
1528
"-DLLVM_VC_REPOSITORY=${llvm_vc_repository}"
1629
"-DLLVM_VC_REVISION=${llvm_vc_revision}"
1730
"-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ static llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
5454
case AS_none:
5555
Field = (AccessSpecifier)R[0];
5656
return llvm::Error::success();
57-
default:
58-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
59-
"invalid value for AccessSpecifier");
6057
}
58+
llvm_unreachable("invalid value for AccessSpecifier");
6159
}
6260

6361
static llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,

clang-tools-extra/clang-doc/BitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {
664664
case InfoType::IT_typedef:
665665
emitBlock(*static_cast<clang::doc::TypedefInfo *>(I));
666666
break;
667-
default:
667+
case InfoType::IT_default:
668668
llvm::errs() << "Unexpected info, unable to write.\n";
669669
return true;
670670
}

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
143143
return reduce<FunctionInfo>(Values);
144144
case InfoType::IT_typedef:
145145
return reduce<TypedefInfo>(Values);
146-
default:
146+
case InfoType::IT_default:
147147
return llvm::createStringError(llvm::inconvertibleErrorCode(),
148148
"unexpected info type");
149149
}
150+
llvm_unreachable("unhandled enumerator");
150151
}
151152

152153
bool CommentInfo::operator==(const CommentInfo &Other) const {

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,11 @@ std::string serialize(std::unique_ptr<Info> &I) {
388388
return serialize(*static_cast<EnumInfo *>(I.get()));
389389
case InfoType::IT_function:
390390
return serialize(*static_cast<FunctionInfo *>(I.get()));
391-
default:
391+
case InfoType::IT_typedef:
392+
case InfoType::IT_default:
392393
return "";
393394
}
395+
llvm_unreachable("unhandled enumerator");
394396
}
395397

396398
static void parseFullComment(const FullComment *C, CommentInfo &CI) {
@@ -525,9 +527,13 @@ static std::unique_ptr<Info> makeAndInsertIntoParent(ChildType Child) {
525527
InsertChild(ParentRec->Children, std::forward<ChildType>(Child));
526528
return ParentRec;
527529
}
528-
default:
529-
llvm_unreachable("Invalid reference type for parent namespace");
530+
case InfoType::IT_default:
531+
case InfoType::IT_enum:
532+
case InfoType::IT_function:
533+
case InfoType::IT_typedef:
534+
break;
530535
}
536+
llvm_unreachable("Invalid reference type for parent namespace");
531537
}
532538

533539
// There are two uses for this function.

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ getNewFieldsOrder(const RecordDecl *Definition,
8686
static void
8787
addReplacement(SourceRange Old, SourceRange New, const ASTContext &Context,
8888
std::map<std::string, tooling::Replacements> &Replacements) {
89+
if (Old.getBegin().isMacroID())
90+
Old = Context.getSourceManager().getExpansionRange(Old).getAsRange();
91+
if (New.getBegin().isMacroID())
92+
New = Context.getSourceManager().getExpansionRange(New).getAsRange();
8993
StringRef NewText =
9094
Lexer::getSourceText(CharSourceRange::getTokenRange(New),
9195
Context.getSourceManager(), Context.getLangOpts());

clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,16 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
702702
return hasArgument(
703703
CC.LengthPos,
704704
allOf(
705-
anyOf(
706-
ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
707-
allOf(unless(hasDefinition(SizeOfCharExpr)),
708-
allOf(CC.WithIncrease
709-
? ignoringImpCasts(hasDefinition(HasIncOp))
710-
: ignoringImpCasts(allOf(
711-
unless(hasDefinition(HasIncOp)),
712-
anyOf(hasDefinition(binaryOperator().bind(
713-
UnknownLengthName)),
714-
hasDefinition(anything())))),
715-
AnyOfWrongLengthInit))),
705+
anyOf(ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
706+
allOf(unless(hasDefinition(SizeOfCharExpr)),
707+
allOf(CC.WithIncrease
708+
? ignoringImpCasts(hasDefinition(HasIncOp))
709+
: ignoringImpCasts(
710+
allOf(unless(hasDefinition(HasIncOp)),
711+
hasDefinition(optionally(
712+
binaryOperator().bind(
713+
UnknownLengthName))))),
714+
AnyOfWrongLengthInit))),
716715
expr().bind(LengthExprName)));
717716
};
718717

0 commit comments

Comments
 (0)