Skip to content

Commit b396737

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:25e8105bff4d into amd-gfx:0d570d01ad3e
Local branch amd-gfx 0d570d0 Merged main:c199f7dc62f3 into amd-gfx:124b4cad343b Remote branch main 25e8105 [asan][ubsan] Enable testing with internal symbolizer (llvm#66257)
2 parents 0d570d0 + 25e8105 commit b396737

File tree

164 files changed

+1473
-827
lines changed

Some content is hidden

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

164 files changed

+1473
-827
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
1414
#include "clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h"
1515
#include "clang/Basic/SourceLocation.h"
16+
#include "llvm/ADT/SmallVector.h"
1617
#include "llvm/Support/Error.h"
17-
#include <memory>
18-
#include <optional>
19-
#include <vector>
2018

2119
namespace clang::tidy::bugprone {
2220
using ast_matchers::MatchFinder;
@@ -54,7 +52,7 @@ void UncheckedOptionalAccessCheck::check(
5452
UncheckedOptionalAccessDiagnoser Diagnoser(ModelOptions);
5553
// FIXME: Allow user to set the (defaulted) SAT iterations max for
5654
// `diagnoseFunction` with config options.
57-
if (llvm::Expected<std::vector<SourceLocation>> Locs =
55+
if (llvm::Expected<llvm::SmallVector<SourceLocation>> Locs =
5856
dataflow::diagnoseFunction<UncheckedOptionalAccessModel,
5957
SourceLocation>(*FuncDecl, *Result.Context,
6058
Diagnoser))

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/ADT/Any.h"
3232
#include "llvm/ADT/STLExtras.h"
3333
#include "llvm/ADT/STLFunctionalExtras.h"
34+
#include "llvm/ADT/SmallVector.h"
3435
#include "llvm/Support/Errc.h"
3536
#include "llvm/Support/Error.h"
3637

@@ -246,9 +247,9 @@ runDataflowAnalysis(
246247
/// - This limit is still low enough to keep runtimes acceptable (on typical
247248
/// machines) in cases where we hit the limit.
248249
template <typename AnalysisT, typename Diagnostic>
249-
llvm::Expected<std::vector<Diagnostic>> diagnoseFunction(
250+
llvm::Expected<llvm::SmallVector<Diagnostic>> diagnoseFunction(
250251
const FunctionDecl &FuncDecl, ASTContext &ASTCtx,
251-
llvm::function_ref<std::vector<Diagnostic>(
252+
llvm::function_ref<llvm::SmallVector<Diagnostic>(
252253
const CFGElement &, ASTContext &,
253254
const TransferStateForDiagnostics<typename AnalysisT::Lattice> &)>
254255
Diagnoser,
@@ -263,7 +264,7 @@ llvm::Expected<std::vector<Diagnostic>> diagnoseFunction(
263264
DataflowAnalysisContext AnalysisContext(std::move(OwnedSolver));
264265
Environment Env(AnalysisContext, FuncDecl);
265266
AnalysisT Analysis(ASTCtx);
266-
std::vector<Diagnostic> Diagnostics;
267+
llvm::SmallVector<Diagnostic> Diagnostics;
267268
if (llvm::Error Err =
268269
runTypeErasedDataflowAnalysis(
269270
*Context, Analysis, Env,

clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
2222
#include "clang/Analysis/FlowSensitive/NoopLattice.h"
2323
#include "clang/Basic/SourceLocation.h"
24-
#include <vector>
24+
#include "llvm/ADT/SmallVector.h"
2525

2626
namespace clang {
2727
namespace dataflow {
@@ -74,14 +74,14 @@ class UncheckedOptionalAccessDiagnoser {
7474
UncheckedOptionalAccessDiagnoser(
7575
UncheckedOptionalAccessModelOptions Options = {});
7676

77-
std::vector<SourceLocation>
77+
llvm::SmallVector<SourceLocation>
7878
operator()(const CFGElement &Elt, ASTContext &Ctx,
7979
const TransferStateForDiagnostics<NoopLattice> &State) {
8080
return DiagnoseMatchSwitch(Elt, Ctx, State.Env);
8181
}
8282

8383
private:
84-
CFGMatchSwitch<const Environment, std::vector<SourceLocation>>
84+
CFGMatchSwitch<const Environment, llvm::SmallVector<SourceLocation>>
8585
DiagnoseMatchSwitch;
8686
};
8787

clang/include/clang/Basic/arm_sme.td

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ include "arm_sve_sme_incl.td"
2020

2121
multiclass ZALoad<string n_suffix, string t, string i_prefix, list<ImmCheck> ch> {
2222
let TargetGuard = "sme" in {
23-
def NAME # _H : MInst<"svld1_hor_" # n_suffix, "vimiPQ", t,
23+
def NAME # _H : MInst<"svld1_hor_" # n_suffix, "vimPQ", t,
2424
[IsLoad, IsOverloadNone, IsStreaming, IsSharedZA],
2525
MemEltTyDefault, i_prefix # "_horiz", ch>;
2626

27-
def NAME # _H_VNUM : MInst<"svld1_hor_vnum_" # n_suffix, "vimiPQl", t,
27+
def NAME # _H_VNUM : MInst<"svld1_hor_vnum_" # n_suffix, "vimPQl", t,
2828
[IsLoad, IsOverloadNone, IsStreaming, IsSharedZA],
2929
MemEltTyDefault, i_prefix # "_horiz", ch>;
3030

31-
def NAME # _V : MInst<"svld1_ver_" # n_suffix, "vimiPQ", t,
31+
def NAME # _V : MInst<"svld1_ver_" # n_suffix, "vimPQ", t,
3232
[IsLoad, IsOverloadNone, IsStreaming, IsSharedZA],
3333
MemEltTyDefault, i_prefix # "_vert", ch>;
3434

35-
def NAME # _V_VNUM : MInst<"svld1_ver_vnum_" # n_suffix, "vimiPQl", t,
35+
def NAME # _V_VNUM : MInst<"svld1_ver_vnum_" # n_suffix, "vimPQl", t,
3636
[IsLoad, IsOverloadNone, IsStreaming, IsSharedZA],
3737
MemEltTyDefault, i_prefix # "_vert", ch>;
3838
}
3939
}
4040

41-
defm SVLD1_ZA8 : ZALoad<"za8", "c", "aarch64_sme_ld1b", [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_15>]>;
42-
defm SVLD1_ZA16 : ZALoad<"za16", "s", "aarch64_sme_ld1h", [ImmCheck<0, ImmCheck0_1>, ImmCheck<2, ImmCheck0_7>]>;
43-
defm SVLD1_ZA32 : ZALoad<"za32", "i", "aarch64_sme_ld1w", [ImmCheck<0, ImmCheck0_3>, ImmCheck<2, ImmCheck0_3>]>;
44-
defm SVLD1_ZA64 : ZALoad<"za64", "l", "aarch64_sme_ld1d", [ImmCheck<0, ImmCheck0_7>, ImmCheck<2, ImmCheck0_1>]>;
45-
defm SVLD1_ZA128 : ZALoad<"za128", "q", "aarch64_sme_ld1q", [ImmCheck<0, ImmCheck0_15>, ImmCheck<2, ImmCheck0_0>]>;
41+
defm SVLD1_ZA8 : ZALoad<"za8", "c", "aarch64_sme_ld1b", [ImmCheck<0, ImmCheck0_0>]>;
42+
defm SVLD1_ZA16 : ZALoad<"za16", "s", "aarch64_sme_ld1h", [ImmCheck<0, ImmCheck0_1>]>;
43+
defm SVLD1_ZA32 : ZALoad<"za32", "i", "aarch64_sme_ld1w", [ImmCheck<0, ImmCheck0_3>]>;
44+
defm SVLD1_ZA64 : ZALoad<"za64", "l", "aarch64_sme_ld1d", [ImmCheck<0, ImmCheck0_7>]>;
45+
defm SVLD1_ZA128 : ZALoad<"za128", "q", "aarch64_sme_ld1q", [ImmCheck<0, ImmCheck0_15>]>;
4646

4747
def SVLDR_VNUM_ZA : MInst<"svldr_vnum_za", "vmQi", "",
4848
[IsOverloadNone, IsStreamingCompatible, IsSharedZA],
@@ -58,29 +58,29 @@ def SVLDR_ZA : MInst<"svldr_za", "vmQ", "",
5858

5959
multiclass ZAStore<string n_suffix, string t, string i_prefix, list<ImmCheck> ch> {
6060
let TargetGuard = "sme" in {
61-
def NAME # _H : MInst<"svst1_hor_" # n_suffix, "vimiP%", t,
61+
def NAME # _H : MInst<"svst1_hor_" # n_suffix, "vimP%", t,
6262
[IsStore, IsOverloadNone, IsStreaming, IsSharedZA, IsPreservesZA],
6363
MemEltTyDefault, i_prefix # "_horiz", ch>;
6464

65-
def NAME # _H_VNUM : MInst<"svst1_hor_vnum_" # n_suffix, "vimiP%l", t,
65+
def NAME # _H_VNUM : MInst<"svst1_hor_vnum_" # n_suffix, "vimP%l", t,
6666
[IsStore, IsOverloadNone, IsStreaming, IsSharedZA, IsPreservesZA],
6767
MemEltTyDefault, i_prefix # "_horiz", ch>;
6868

69-
def NAME # _V : MInst<"svst1_ver_" # n_suffix, "vimiP%", t,
69+
def NAME # _V : MInst<"svst1_ver_" # n_suffix, "vimP%", t,
7070
[IsStore, IsOverloadNone, IsStreaming, IsSharedZA, IsPreservesZA],
7171
MemEltTyDefault, i_prefix # "_vert", ch>;
7272

73-
def NAME # _V_VNUM : MInst<"svst1_ver_vnum_" # n_suffix, "vimiP%l", t,
73+
def NAME # _V_VNUM : MInst<"svst1_ver_vnum_" # n_suffix, "vimP%l", t,
7474
[IsStore, IsOverloadNone, IsStreaming, IsSharedZA, IsPreservesZA],
7575
MemEltTyDefault, i_prefix # "_vert", ch>;
7676
}
7777
}
7878

79-
defm SVST1_ZA8 : ZAStore<"za8", "c", "aarch64_sme_st1b", [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_15>]>;
80-
defm SVST1_ZA16 : ZAStore<"za16", "s", "aarch64_sme_st1h", [ImmCheck<0, ImmCheck0_1>, ImmCheck<2, ImmCheck0_7>]>;
81-
defm SVST1_ZA32 : ZAStore<"za32", "i", "aarch64_sme_st1w", [ImmCheck<0, ImmCheck0_3>, ImmCheck<2, ImmCheck0_3>]>;
82-
defm SVST1_ZA64 : ZAStore<"za64", "l", "aarch64_sme_st1d", [ImmCheck<0, ImmCheck0_7>, ImmCheck<2, ImmCheck0_1>]>;
83-
defm SVST1_ZA128 : ZAStore<"za128", "q", "aarch64_sme_st1q", [ImmCheck<0, ImmCheck0_15>, ImmCheck<2, ImmCheck0_0>]>;
79+
defm SVST1_ZA8 : ZAStore<"za8", "c", "aarch64_sme_st1b", [ImmCheck<0, ImmCheck0_0>]>;
80+
defm SVST1_ZA16 : ZAStore<"za16", "s", "aarch64_sme_st1h", [ImmCheck<0, ImmCheck0_1>]>;
81+
defm SVST1_ZA32 : ZAStore<"za32", "i", "aarch64_sme_st1w", [ImmCheck<0, ImmCheck0_3>]>;
82+
defm SVST1_ZA64 : ZAStore<"za64", "l", "aarch64_sme_st1d", [ImmCheck<0, ImmCheck0_7>]>;
83+
defm SVST1_ZA128 : ZAStore<"za128", "q", "aarch64_sme_st1q", [ImmCheck<0, ImmCheck0_15>]>;
8484

8585
def SVSTR_VNUM_ZA : MInst<"svstr_vnum_za", "vm%i", "",
8686
[IsOverloadNone, IsStreamingCompatible, IsSharedZA, IsPreservesZA],

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,9 +2394,7 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
23942394
case UO_Real: // __real x
23952395
case UO_Imag: // __imag x
23962396
case UO_Extension:
2397-
if (DiscardResult)
2398-
return this->discard(SubExpr);
2399-
return this->visit(SubExpr);
2397+
return this->delegate(SubExpr);
24002398
case UO_Coawait:
24012399
assert(false && "Unhandled opcode");
24022400
}

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <memory>
3535
#include <optional>
3636
#include <utility>
37-
#include <vector>
3837

3938
namespace clang {
4039
namespace dataflow {
@@ -913,8 +912,8 @@ auto buildTransferMatchSwitch() {
913912
.Build();
914913
}
915914

916-
std::vector<SourceLocation> diagnoseUnwrapCall(const Expr *ObjectExpr,
917-
const Environment &Env) {
915+
llvm::SmallVector<SourceLocation> diagnoseUnwrapCall(const Expr *ObjectExpr,
916+
const Environment &Env) {
918917
if (auto *OptionalVal = getValueBehindPossiblePointer(*ObjectExpr, Env)) {
919918
auto *Prop = OptionalVal->getProperty("has_value");
920919
if (auto *HasValueVal = cast_or_null<BoolValue>(Prop)) {
@@ -935,7 +934,8 @@ auto buildDiagnoseMatchSwitch(
935934
// lot of duplicated work (e.g. string comparisons), consider providing APIs
936935
// that avoid it through memoization.
937936
auto IgnorableOptional = ignorableOptional(Options);
938-
return CFGMatchSwitchBuilder<const Environment, std::vector<SourceLocation>>()
937+
return CFGMatchSwitchBuilder<const Environment,
938+
llvm::SmallVector<SourceLocation>>()
939939
// optional::value
940940
.CaseOfCFGStmt<CXXMemberCallExpr>(
941941
valueCall(IgnorableOptional),

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ using namespace llvm;
9191

9292
namespace llvm {
9393
extern cl::opt<bool> DebugInfoCorrelate;
94+
extern cl::opt<bool> PrintPipelinePasses;
9495

9596
// Experiment to move sanitizers earlier.
9697
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
@@ -1090,6 +1091,17 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10901091
TheModule->addModuleFlag(Module::Error, "UnifiedLTO", uint32_t(1));
10911092
}
10921093

1094+
// Print a textual, '-passes=' compatible, representation of pipeline if
1095+
// requested.
1096+
if (PrintPipelinePasses) {
1097+
MPM.printPipeline(outs(), [&PIC](StringRef ClassName) {
1098+
auto PassName = PIC.getPassNameForClassName(ClassName);
1099+
return PassName.empty() ? ClassName : PassName;
1100+
});
1101+
outs() << "\n";
1102+
return;
1103+
}
1104+
10931105
// Now that we have all of the passes ready, run them.
10941106
{
10951107
PrettyStackTraceString CrashInfo("Optimizer");
@@ -1127,6 +1139,13 @@ void EmitAssemblyHelper::RunCodegenPipeline(
11271139
return;
11281140
}
11291141

1142+
// If -print-pipeline-passes is requested, don't run the legacy pass manager.
1143+
// FIXME: when codegen is switched to use the new pass manager, it should also
1144+
// emit pass names here.
1145+
if (PrintPipelinePasses) {
1146+
return;
1147+
}
1148+
11301149
{
11311150
PrettyStackTraceString CrashInfo("Code generation");
11321151
llvm::TimeTraceScope TimeScope("CodeGenPasses");

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9585,29 +9585,29 @@ Value *CodeGenFunction::EmitTileslice(Value *Offset, Value *Base) {
95859585
Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
95869586
SmallVectorImpl<Value *> &Ops,
95879587
unsigned IntID) {
9588-
Ops[3] = EmitSVEPredicateCast(
9589-
Ops[3], getSVEVectorForElementType(SVEBuiltinMemEltTy(TypeFlags)));
9588+
Ops[2] = EmitSVEPredicateCast(
9589+
Ops[2], getSVEVectorForElementType(SVEBuiltinMemEltTy(TypeFlags)));
95909590

95919591
SmallVector<Value *> NewOps;
9592-
NewOps.push_back(Ops[3]);
9592+
NewOps.push_back(Ops[2]);
95939593

9594-
llvm::Value *BasePtr = Ops[4];
9594+
llvm::Value *BasePtr = Ops[3];
95959595

95969596
// If the intrinsic contains the vnum parameter, multiply it with the vector
95979597
// size in bytes.
9598-
if (Ops.size() == 6) {
9598+
if (Ops.size() == 5) {
95999599
Function *StreamingVectorLength =
96009600
CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);
96019601
llvm::Value *StreamingVectorLengthCall =
96029602
Builder.CreateCall(StreamingVectorLength);
96039603
llvm::Value *Mulvl =
9604-
Builder.CreateMul(StreamingVectorLengthCall, Ops[5], "mulvl");
9604+
Builder.CreateMul(StreamingVectorLengthCall, Ops[4], "mulvl");
96059605
// The type of the ptr parameter is void *, so use Int8Ty here.
9606-
BasePtr = Builder.CreateGEP(Int8Ty, Ops[4], Mulvl);
9606+
BasePtr = Builder.CreateGEP(Int8Ty, Ops[3], Mulvl);
96079607
}
96089608
NewOps.push_back(BasePtr);
96099609
NewOps.push_back(Ops[0]);
9610-
NewOps.push_back(EmitTileslice(Ops[2], Ops[1]));
9610+
NewOps.push_back(Ops[1]);
96119611
Function *F = CGM.getIntrinsic(IntID);
96129612
return Builder.CreateCall(F, NewOps);
96139613
}

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,12 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current,
22412241
if (Style.isJson() || !Style.BreakStringLiterals || !AllowBreak)
22422242
return nullptr;
22432243

2244+
// Strings in TypeScript types and dictionary keys can not be broken.
2245+
if (Style.isJavaScript() && (Current.is(TT_SelectorName) ||
2246+
State.Line->startsWith(Keywords.kw_type))) {
2247+
return nullptr;
2248+
}
2249+
22442250
// Don't break string literals inside preprocessor directives (except for
22452251
// #define directives, as their contents are stored in separate lines and
22462252
// are not affected by this check).

clang/lib/Headers/llvm_libc_wrappers/stdlib.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323

2424
#pragma omp begin declare target
2525

26-
// The LLVM C library uses this type so we forward declare it.
26+
// The LLVM C library uses these named types so we forward declare them.
2727
typedef void (*__atexithandler_t)(void);
28+
typedef int (*__bsearchcompare_t)(const void *, const void *);
29+
typedef int (*__qsortcompare_t)(const void *, const void *);
30+
typedef int (*__qsortrcompare_t)(const void *, const void *, void *);
2831

2932
// Enforce ABI compatibility with the structs used by the LLVM C library.
3033
_Static_assert(__builtin_offsetof(div_t, quot) == 0, "ABI mismatch!");

0 commit comments

Comments
 (0)