Skip to content

Commit 7f8dee3

Browse files
authored
merge main into amd-staging (llvm#3932)
2 parents c57397b + 0ca6d85 commit 7f8dee3

File tree

103 files changed

+903
-454
lines changed

Some content is hidden

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

103 files changed

+903
-454
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ Expected<std::unique_ptr<BinaryContext>> BinaryContext::createBinaryContext(
207207
Twine("BOLT-ERROR: ", Error));
208208

209209
std::unique_ptr<const MCRegisterInfo> MRI(
210-
TheTarget->createMCRegInfo(TripleName));
210+
TheTarget->createMCRegInfo(TheTriple));
211211
if (!MRI)
212212
return createStringError(
213213
make_error_code(std::errc::not_supported),
214214
Twine("BOLT-ERROR: no register info for target ", TripleName));
215215

216216
// Set up disassembler.
217217
std::unique_ptr<MCAsmInfo> AsmInfo(
218-
TheTarget->createMCAsmInfo(*MRI, TripleName, MCTargetOptions()));
218+
TheTarget->createMCAsmInfo(*MRI, TheTriple, MCTargetOptions()));
219219
if (!AsmInfo)
220220
return createStringError(
221221
make_error_code(std::errc::not_supported),
@@ -227,7 +227,7 @@ Expected<std::unique_ptr<BinaryContext>> BinaryContext::createBinaryContext(
227227
AsmInfo->setAllowAtInName(true);
228228

229229
std::unique_ptr<const MCSubtargetInfo> STI(
230-
TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr));
230+
TheTarget->createMCSubtargetInfo(TheTriple, "", FeaturesStr));
231231
if (!STI)
232232
return createStringError(
233233
make_error_code(std::errc::not_supported),

clang-tools-extra/docs/clang-tidy/checks/performance/noexcept-move-constructor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ marked with ``noexcept`` or marked with ``noexcept(expr)`` where ``expr``
99
evaluates to ``false`` (but is not a ``false`` literal itself).
1010

1111
Move constructors of all the types used with STL containers, for example,
12-
need to be declared ``noexcept``. Otherwise STL will choose copy constructors
12+
should be declared ``noexcept``. Otherwise STL may choose copy constructors
1313
instead. The same is valid for move assignment operations.

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,8 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
29122912
OptPrimType SubExprT = classify(SubExpr);
29132913
bool IsStatic = E->getStorageDuration() == SD_Static;
29142914
if (IsStatic) {
2915-
std::optional<unsigned> GlobalIndex = P.createGlobal(E);
2915+
2916+
UnsignedOrNone GlobalIndex = P.createGlobal(E);
29162917
if (!GlobalIndex)
29172918
return false;
29182919

@@ -3001,7 +3002,7 @@ bool Compiler<Emitter>::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
30013002
if (T && !E->isLValue())
30023003
return this->delegate(Init);
30033004

3004-
std::optional<unsigned> GlobalIndex = P.createGlobal(E);
3005+
UnsignedOrNone GlobalIndex = P.createGlobal(E);
30053006
if (!GlobalIndex)
30063007
return false;
30073008

@@ -3345,7 +3346,7 @@ bool Compiler<Emitter>::VisitSourceLocExpr(const SourceLocExpr *E) {
33453346

33463347
auto *UGCD = cast<UnnamedGlobalConstantDecl>(BaseDecl);
33473348

3348-
std::optional<unsigned> GlobalIndex = P.getOrCreateGlobal(UGCD);
3349+
UnsignedOrNone GlobalIndex = P.getOrCreateGlobal(UGCD);
33493350
if (!GlobalIndex)
33503351
return false;
33513352

@@ -3868,7 +3869,7 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
38683869
if (!RD->isCompleteDefinition())
38693870
return this->emitDummyPtr(GuidDecl, E);
38703871

3871-
std::optional<unsigned> GlobalIndex = P.getOrCreateGlobal(GuidDecl);
3872+
UnsignedOrNone GlobalIndex = P.getOrCreateGlobal(GuidDecl);
38723873
if (!GlobalIndex)
38733874
return false;
38743875
if (!this->emitGetPtrGlobal(*GlobalIndex, E))
@@ -4860,7 +4861,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
48604861
DeclScope<Emitter> LocalScope(this, VD);
48614862

48624863
// We've already seen and initialized this global.
4863-
if (std::optional<unsigned> GlobalIndex = P.getGlobal(VD)) {
4864+
if (UnsignedOrNone GlobalIndex = P.getGlobal(VD)) {
48644865
if (P.getPtrGlobal(*GlobalIndex).isInitialized())
48654866
return checkDecl();
48664867

@@ -4869,7 +4870,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
48694870
return Init && checkDecl() && initGlobal(*GlobalIndex);
48704871
}
48714872

4872-
std::optional<unsigned> GlobalIndex = P.createGlobal(VD, Init);
4873+
UnsignedOrNone GlobalIndex = P.createGlobal(VD, Init);
48734874

48744875
if (!GlobalIndex)
48754876
return false;
@@ -6802,7 +6803,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
68026803
return F && this->emitGetFnPtr(F, E);
68036804
}
68046805
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(D)) {
6805-
if (std::optional<unsigned> Index = P.getOrCreateGlobal(D)) {
6806+
if (UnsignedOrNone Index = P.getOrCreateGlobal(D)) {
68066807
if (!this->emitGetPtrGlobal(*Index, E))
68076808
return false;
68086809
if (OptPrimType T = classify(E->getType())) {

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ bool EvalEmitter::emitDestroy(uint32_t I, const SourceInfo &Info) {
331331
/// This is what we do here.
332332
void EvalEmitter::updateGlobalTemporaries() {
333333
for (const auto &[E, Temp] : S.SeenGlobalTemporaries) {
334-
if (std::optional<unsigned> GlobalIndex = P.getGlobal(E)) {
334+
if (UnsignedOrNone GlobalIndex = P.getGlobal(E)) {
335335
const Pointer &Ptr = P.getPtrGlobal(*GlobalIndex);
336336
APValue *Cached = Temp->getOrCreateValue(true);
337337

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Pointer Program::getPtrGlobal(unsigned Idx) const {
111111
return Pointer(Globals[Idx]->block());
112112
}
113113

114-
std::optional<unsigned> Program::getGlobal(const ValueDecl *VD) {
114+
UnsignedOrNone Program::getGlobal(const ValueDecl *VD) {
115115
if (auto It = GlobalIndices.find(VD); It != GlobalIndices.end())
116116
return It->second;
117117

@@ -131,14 +131,14 @@ std::optional<unsigned> Program::getGlobal(const ValueDecl *VD) {
131131
return std::nullopt;
132132
}
133133

134-
std::optional<unsigned> Program::getGlobal(const Expr *E) {
134+
UnsignedOrNone Program::getGlobal(const Expr *E) {
135135
if (auto It = GlobalIndices.find(E); It != GlobalIndices.end())
136136
return It->second;
137137
return std::nullopt;
138138
}
139139

140-
std::optional<unsigned> Program::getOrCreateGlobal(const ValueDecl *VD,
141-
const Expr *Init) {
140+
UnsignedOrNone Program::getOrCreateGlobal(const ValueDecl *VD,
141+
const Expr *Init) {
142142
if (auto Idx = getGlobal(VD))
143143
return Idx;
144144

@@ -195,8 +195,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
195195
return I;
196196
}
197197

198-
std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
199-
const Expr *Init) {
198+
UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
200199
bool IsStatic, IsExtern;
201200
bool IsWeak = VD->isWeak();
202201
if (const auto *Var = dyn_cast<VarDecl>(VD)) {
@@ -213,7 +212,7 @@ std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
213212

214213
// Register all previous declarations as well. For extern blocks, just replace
215214
// the index with the new variable.
216-
std::optional<unsigned> Idx =
215+
UnsignedOrNone Idx =
217216
createGlobal(VD, VD->getType(), IsStatic, IsExtern, IsWeak, Init);
218217
if (!Idx)
219218
return std::nullopt;
@@ -240,7 +239,7 @@ std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
240239
return *Idx;
241240
}
242241

243-
std::optional<unsigned> Program::createGlobal(const Expr *E) {
242+
UnsignedOrNone Program::createGlobal(const Expr *E) {
244243
if (auto Idx = getGlobal(E))
245244
return Idx;
246245
if (auto Idx = createGlobal(E, E->getType(), /*isStatic=*/true,
@@ -251,9 +250,9 @@ std::optional<unsigned> Program::createGlobal(const Expr *E) {
251250
return std::nullopt;
252251
}
253252

254-
std::optional<unsigned> Program::createGlobal(const DeclTy &D, QualType Ty,
255-
bool IsStatic, bool IsExtern,
256-
bool IsWeak, const Expr *Init) {
253+
UnsignedOrNone Program::createGlobal(const DeclTy &D, QualType Ty,
254+
bool IsStatic, bool IsExtern, bool IsWeak,
255+
const Expr *Init) {
257256
// Create a descriptor for the global.
258257
Descriptor *Desc;
259258
const bool IsConst = Ty.isConstQualified();

clang/lib/AST/ByteCode/Program.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ class Program final {
7878
}
7979

8080
/// Finds a global's index.
81-
std::optional<unsigned> getGlobal(const ValueDecl *VD);
82-
std::optional<unsigned> getGlobal(const Expr *E);
81+
UnsignedOrNone getGlobal(const ValueDecl *VD);
82+
UnsignedOrNone getGlobal(const Expr *E);
8383

8484
/// Returns or creates a global an creates an index to it.
85-
std::optional<unsigned> getOrCreateGlobal(const ValueDecl *VD,
86-
const Expr *Init = nullptr);
85+
UnsignedOrNone getOrCreateGlobal(const ValueDecl *VD,
86+
const Expr *Init = nullptr);
8787

8888
/// Returns or creates a dummy value for unknown declarations.
8989
unsigned getOrCreateDummy(const DeclTy &D);
9090

9191
/// Creates a global and returns its index.
92-
std::optional<unsigned> createGlobal(const ValueDecl *VD, const Expr *Init);
92+
UnsignedOrNone createGlobal(const ValueDecl *VD, const Expr *Init);
9393

9494
/// Creates a global from a lifetime-extended temporary.
95-
std::optional<unsigned> createGlobal(const Expr *E);
95+
UnsignedOrNone createGlobal(const Expr *E);
9696

9797
/// Creates a new function from a code range.
9898
template <typename... Ts>
@@ -165,9 +165,9 @@ class Program final {
165165
private:
166166
friend class DeclScope;
167167

168-
std::optional<unsigned> createGlobal(const DeclTy &D, QualType Ty,
169-
bool IsStatic, bool IsExtern,
170-
bool IsWeak, const Expr *Init = nullptr);
168+
UnsignedOrNone createGlobal(const DeclTy &D, QualType Ty, bool IsStatic,
169+
bool IsExtern, bool IsWeak,
170+
const Expr *Init = nullptr);
171171

172172
/// Reference to the VM context.
173173
Context &Ctx;

clang/lib/Parse/ParseStmtAsm.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
543543
std::string FeaturesStr =
544544
llvm::join(TO.Features.begin(), TO.Features.end(), ",");
545545

546-
std::unique_ptr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
546+
std::unique_ptr<llvm::MCRegisterInfo> MRI(
547+
TheTarget->createMCRegInfo(TheTriple));
547548
if (!MRI) {
548549
Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
549550
<< "target MC unavailable";
@@ -552,11 +553,11 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
552553
// FIXME: init MCOptions from sanitizer flags here.
553554
llvm::MCTargetOptions MCOptions;
554555
std::unique_ptr<llvm::MCAsmInfo> MAI(
555-
TheTarget->createMCAsmInfo(*MRI, TT, MCOptions));
556+
TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions));
556557
// Get the instruction descriptor.
557558
std::unique_ptr<llvm::MCInstrInfo> MII(TheTarget->createMCInstrInfo());
558559
std::unique_ptr<llvm::MCSubtargetInfo> STI(
559-
TheTarget->createMCSubtargetInfo(TT, TO.CPU, FeaturesStr));
560+
TheTarget->createMCSubtargetInfo(TheTriple, TO.CPU, FeaturesStr));
560561
// Target MCTargetDesc may not be linked in clang-based tools.
561562

562563
if (!MAI || !MII || !STI) {
@@ -591,7 +592,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
591592
}
592593

593594
std::unique_ptr<llvm::MCInstPrinter> IP(
594-
TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
595+
TheTarget->createMCInstPrinter(TheTriple, 1, *MAI, *MII, *MRI));
595596

596597
// Change to the Intel dialect.
597598
Parser->setAssemblerDialect(1);

clang/tools/driver/cc1as_main.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ struct AssemblerInvocation {
7171
/// @name Target Options
7272
/// @{
7373

74-
/// The name of the target triple to assemble for.
75-
std::string Triple;
74+
/// The target triple to assemble for.
75+
llvm::Triple Triple;
7676

7777
/// If given, the name of the target CPU to determine which instructions
7878
/// are legal.
@@ -192,9 +192,12 @@ struct AssemblerInvocation {
192192
std::string AsSecureLogFile;
193193
/// @}
194194

195+
void setTriple(llvm::StringRef Str) {
196+
Triple = llvm::Triple(llvm::Triple::normalize(Str));
197+
}
198+
195199
public:
196200
AssemblerInvocation() {
197-
Triple = "";
198201
NoInitialTextSection = 0;
199202
InputFile = "-";
200203
OutputPath = "-";
@@ -261,7 +264,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
261264
// Construct the invocation.
262265

263266
// Target Options
264-
Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
267+
Opts.setTriple(Args.getLastArgValue(OPT_triple));
265268
if (Arg *A = Args.getLastArg(options::OPT_darwin_target_variant_triple))
266269
Opts.DarwinTargetVariantTriple = llvm::Triple(A->getValue());
267270
if (Arg *A = Args.getLastArg(OPT_darwin_target_variant_sdk_version_EQ)) {
@@ -278,7 +281,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
278281

279282
// Use the default target triple if unspecified.
280283
if (Opts.Triple.empty())
281-
Opts.Triple = llvm::sys::getDefaultTargetTriple();
284+
Opts.setTriple(llvm::sys::getDefaultTargetTriple());
282285

283286
// Language Options
284287
Opts.IncludePaths = Args.getAllArgValues(OPT_I);
@@ -419,7 +422,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
419422
std::string Error;
420423
const Target *TheTarget = TargetRegistry::lookupTarget(Opts.Triple, Error);
421424
if (!TheTarget)
422-
return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
425+
return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple.str();
423426

424427
ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
425428
MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
@@ -604,7 +607,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
604607
std::unique_ptr<MCTargetAsmParser> TAP(
605608
TheTarget->createMCAsmParser(*STI, *Parser, *MCII, MCOptions));
606609
if (!TAP)
607-
Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
610+
Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple.str();
608611

609612
// Set values for symbols, if any.
610613
for (auto &S : Opts.SymbolDefs) {

compiler-rt/test/asan/TestCases/Linux/coverage-missing.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
// Test for "sancov.py missing ...".
22

33
// First case: coverage from executable. main() is called on every code path.
4-
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
54
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t -DFOOBAR -DMAIN
6-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t
5+
// RUN: rm -rf %t-dir
6+
// RUN: mkdir -p %t-dir
7+
// RUN: cd %t-dir
8+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t
79
// RUN: %sancov print *.sancov > main.txt
810
// RUN: rm *.sancov
911
// RUN: count 1 < main.txt
10-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x
12+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x
1113
// RUN: %sancov print *.sancov > foo.txt
1214
// RUN: rm *.sancov
1315
// RUN: count 3 < foo.txt
14-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x x
16+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x x
1517
// RUN: %sancov print *.sancov > bar.txt
1618
// RUN: rm *.sancov
1719
// RUN: count 4 < bar.txt
@@ -24,15 +26,18 @@
2426
// RUN: not grep "^<" %t.log
2527

2628
// Second case: coverage from DSO.
27-
// RUN: cd ..
28-
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
29+
// cd %t-dir
2930
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %dynamiclib -DFOOBAR -shared -fPIC
3031
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %dynamiclib -o %t -DMAIN
31-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x
32+
// RUN: cd ..
33+
// RUN: rm -rf %t-dir
34+
// RUN: mkdir -p %t-dir
35+
// RUN: cd %t-dir
36+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x
3237
// RUN: %sancov print %xdynamiclib_filename.*.sancov > foo.txt
3338
// RUN: rm *.sancov
3439
// RUN: count 2 < foo.txt
35-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x x
40+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x x
3641
// RUN: %sancov print %xdynamiclib_filename.*.sancov > bar.txt
3742
// RUN: rm *.sancov
3843
// RUN: count 3 < bar.txt

compiler-rt/test/asan/TestCases/Linux/local_alias.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
// false positive global-buffer-overflow due to sanitized library poisons
55
// globals from non-sanitized one.
66
//
7-
// RUN: mkdir -p %t.dir && cd %t.dir
87
// RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib1
98
// RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %dynamiclib2
109
// RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o
11-
// RUN: %clangxx_asan %t.o %ld_flags_rpath_exe2 %ld_flags_rpath_exe1 -o %t.dir/EXE
12-
// RUN: %run %t.dir/EXE
10+
// RUN: %clangxx_asan %t.o %ld_flags_rpath_exe2 %ld_flags_rpath_exe1 -o %t-EXE
11+
// RUN: %run %t-EXE
1312

1413
#if defined (BUILD_INSTRUMENTED_DSO)
1514
long h = 15;

0 commit comments

Comments
 (0)