Skip to content

Commit ce980fd

Browse files
Merge branch 'llvm:main' into cfi-show
2 parents a0203f3 + b40d233 commit ce980fd

File tree

216 files changed

+105176
-7455
lines changed

Some content is hidden

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

216 files changed

+105176
-7455
lines changed

.github/new-prs-labeler.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,14 @@ clang:openmp:
10901090
- llvm/unittests/Frontend/OpenMP*
10911091
- llvm/test/Transforms/OpenMP/**
10921092

1093+
clang:temporal-safety:
1094+
- clang/include/clang/Analysis/Analyses/LifetimeSafety*
1095+
- clang/lib/Analysis/LifetimeSafety*
1096+
- clang/unittests/Analysis/LifetimeSafety*
1097+
- clang/test/Sema/*lifetime-safety*
1098+
- clang/test/Sema/*lifetime-analysis*
1099+
- clang/test/Analysis/LifetimeSafety/**
1100+
10931101
clang:as-a-library:
10941102
- clang/tools/libclang/**
10951103
- clang/bindings/**

clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace {
3939
// - LoopCounterName: The entire for loop (as ForStmt).
4040
// - LoopParentName: The body of function f (as CompoundStmt).
4141
// - VectorVarDeclName: 'v' (as VarDecl).
42-
// - VectorVarDeclStmatName: The entire 'std::vector<T> v;' statement (as
42+
// - VectorVarDeclStmtName: The entire 'std::vector<T> v;' statement (as
4343
// DeclStmt).
4444
// - PushBackOrEmplaceBackCallName: 'v.push_back(i)' (as cxxMemberCallExpr).
4545
// - LoopInitVarName: 'i' (as VarDecl).

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static StringRef const StyleNames[] = {
186186
m(ptrdiff_t) \
187187
m(void) \
188188

189-
static StringRef const HungarainNotationPrimitiveTypes[] = {
189+
static StringRef const HungarianNotationPrimitiveTypes[] = {
190190
#define STRINGIZE(v) #v,
191191
HUNGARIAN_NOTATION_PRIMITIVE_TYPES(STRINGIZE)
192192
#undef STRINGIZE
@@ -222,7 +222,7 @@ static StringRef const HungarainNotationPrimitiveTypes[] = {
222222
m(UINT64) \
223223
m(PVOID) \
224224

225-
static StringRef const HungarainNotationUserDefinedTypes[] = {
225+
static StringRef const HungarianNotationUserDefinedTypes[] = {
226226
#define STRINGIZE(v) #v,
227227
HUNGARIAN_NOTATION_USER_DEFINED_TYPES(STRINGIZE)
228228
#undef STRINGIZE
@@ -488,7 +488,7 @@ void IdentifierNamingCheck::HungarianNotation::loadFileConfig(
488488

489489
Buffer = {Section, "PrimitiveType."};
490490
DefSize = Buffer.size();
491-
for (const auto &PrimType : HungarainNotationPrimitiveTypes) {
491+
for (const auto &PrimType : HungarianNotationPrimitiveTypes) {
492492
Buffer.truncate(DefSize);
493493
Buffer.append(PrimType);
494494
StringRef Val = Options.get(Buffer, "");
@@ -501,7 +501,7 @@ void IdentifierNamingCheck::HungarianNotation::loadFileConfig(
501501

502502
Buffer = {Section, "UserDefinedType."};
503503
DefSize = Buffer.size();
504-
for (const auto &Type : HungarainNotationUserDefinedTypes) {
504+
for (const auto &Type : HungarianNotationUserDefinedTypes) {
505505
Buffer.truncate(DefSize);
506506
Buffer.append(Type);
507507
StringRef Val = Options.get(Buffer, "");

clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int getPrecedence(const BinaryOperator *BinOp) {
4848
return 0;
4949
}
5050
}
51-
static void addParantheses(const BinaryOperator *BinOp,
51+
static void addParentheses(const BinaryOperator *BinOp,
5252
const BinaryOperator *ParentBinOp,
5353
ClangTidyCheck *Check,
5454
const clang::SourceManager &SM,
@@ -81,9 +81,9 @@ static void addParantheses(const BinaryOperator *BinOp,
8181
}
8282
}
8383

84-
addParantheses(dyn_cast<BinaryOperator>(BinOp->getLHS()->IgnoreImpCasts()),
84+
addParentheses(dyn_cast<BinaryOperator>(BinOp->getLHS()->IgnoreImpCasts()),
8585
BinOp, Check, SM, LangOpts);
86-
addParantheses(dyn_cast<BinaryOperator>(BinOp->getRHS()->IgnoreImpCasts()),
86+
addParentheses(dyn_cast<BinaryOperator>(BinOp->getRHS()->IgnoreImpCasts()),
8787
BinOp, Check, SM, LangOpts);
8888
}
8989

@@ -92,7 +92,7 @@ void MathMissingParenthesesCheck::check(
9292
const auto *BinOp = Result.Nodes.getNodeAs<BinaryOperator>("binOp");
9393
const SourceManager &SM = *Result.SourceManager;
9494
const clang::LangOptions &LO = Result.Context->getLangOpts();
95-
addParantheses(BinOp, nullptr, this, SM, LO);
95+
addParentheses(BinOp, nullptr, this, SM, LO);
9696
}
9797

9898
} // namespace clang::tidy::readability

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ bool LiveVariables::LivenessValues::isLive(const Expr *E) const {
7272

7373
bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const {
7474
if (const auto *DD = dyn_cast<DecompositionDecl>(D)) {
75-
bool alive = false;
76-
for (const BindingDecl *BD : DD->bindings())
77-
alive |= liveBindings.contains(BD);
78-
7975
// Note: the only known case this condition is necessary, is when a bindig
8076
// to a tuple-like structure is created. The HoldingVar initializers have a
8177
// DeclRefExpr to the DecompositionDecl.
82-
alive |= liveDecls.contains(DD);
83-
return alive;
78+
if (liveDecls.contains(DD))
79+
return true;
80+
81+
for (const BindingDecl *BD : DD->bindings()) {
82+
if (liveBindings.contains(BD))
83+
return true;
84+
}
85+
return false;
8486
}
8587
return liveDecls.contains(D);
8688
}

clang/test/CodeGen/allow-ubsan-check.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// TR-NEXT: [[TMP9:%.*]] = and i1 [[TMP5]], [[TMP8]], !nosanitize [[META2]]
5252
// TR-NEXT: br i1 [[TMP9]], label %[[CONT:.*]], label %[[TRAP:.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
5353
// TR: [[TRAP]]:
54-
// TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR5:[0-9]+]], !nosanitize [[META2]]
54+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 3) #[[ATTR7:[0-9]+]], !nosanitize [[META2]]
5555
// TR-NEXT: unreachable, !nosanitize [[META2]]
5656
// TR: [[CONT]]:
5757
// TR-NEXT: [[DIV:%.*]] = sdiv i32 [[X]], [[Y]]
@@ -102,14 +102,14 @@ int div(int x, int y) {
102102
// CHECK-NEXT: ret i32 [[TMP2]]
103103
//
104104
// TR-LABEL: define dso_local i32 @null(
105-
// TR-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
105+
// TR-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
106106
// TR-NEXT: [[ENTRY:.*:]]
107107
// TR-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
108108
// TR-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 29), !nosanitize [[META2]]
109109
// TR-NEXT: [[DOTNOT1:%.*]] = and i1 [[TMP0]], [[TMP1]]
110110
// TR-NEXT: br i1 [[DOTNOT1]], label %[[TRAP:.*]], label %[[CONT:.*]], !prof [[PROF4:![0-9]+]], !nosanitize [[META2]]
111111
// TR: [[TRAP]]:
112-
// TR-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR5]], !nosanitize [[META2]]
112+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 22) #[[ATTR7]], !nosanitize [[META2]]
113113
// TR-NEXT: unreachable, !nosanitize [[META2]]
114114
// TR: [[CONT]]:
115115
// TR-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4, !tbaa [[TBAA5:![0-9]+]]
@@ -161,7 +161,7 @@ int null(int* x) {
161161
// TR-NEXT: [[DOTDEMORGAN:%.*]] = and i1 [[TMP1]], [[TMP2]]
162162
// TR-NEXT: br i1 [[DOTDEMORGAN]], label %[[TRAP:.*]], label %[[CONT:.*]], !prof [[PROF4]], !nosanitize [[META2]]
163163
// TR: [[TRAP]]:
164-
// TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR5]], !nosanitize [[META2]]
164+
// TR-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR7]], !nosanitize [[META2]]
165165
// TR-NEXT: unreachable, !nosanitize [[META2]]
166166
// TR: [[CONT]]:
167167
// TR-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -212,11 +212,11 @@ void use(double*);
212212
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
213213
//
214214
// TR-LABEL: define dso_local double @lbounds(
215-
// TR-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0]] {
215+
// TR-SAME: i32 noundef [[B:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR5:[0-9]+]] {
216216
// TR-NEXT: [[ENTRY:.*:]]
217217
// TR-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
218218
// TR-NEXT: [[VLA:%.*]] = alloca double, i64 [[TMP0]], align 16
219-
// TR-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR6:[0-9]+]]
219+
// TR-NEXT: call void @use(ptr noundef nonnull [[VLA]]) #[[ATTR8:[0-9]+]]
220220
// TR-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
221221
// TR-NEXT: [[TMP1:%.*]] = icmp ule i64 [[TMP0]], [[IDXPROM]]
222222
// TR-NEXT: [[TMP2:%.*]] = call i1 @llvm.allow.ubsan.check(i8 71), !nosanitize [[META2]]
@@ -227,7 +227,7 @@ void use(double*);
227227
// TR-NEXT: [[TMP5:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA9:![0-9]+]]
228228
// TR-NEXT: ret double [[TMP5]]
229229
// TR: [[TRAP]]:
230-
// TR-NEXT: call void @llvm.ubsantrap(i8 71) #[[ATTR5]], !nosanitize [[META2]]
230+
// TR-NEXT: call void @llvm.ubsantrap(i8 71) #[[ATTR7]], !nosanitize [[META2]]
231231
// TR-NEXT: unreachable, !nosanitize [[META2]]
232232
//
233233
// REC-LABEL: define dso_local double @lbounds(

compiler-rt/test/fuzzer/sig-trap.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ UNSUPPORTED: target={{.*windows.*}}
55
RUN: %cpp_compiler %S/SigTrapTest.cpp -o %t
66

77
RUN: not %run %t 2>&1 | FileCheck %s
8-
CHECK: BINGO
9-
CHECK: ERROR: libFuzzer: deadly signal
8+
CHECK-DAG: BINGO
9+
CHECK-DAG: ERROR: libFuzzer: deadly signal
1010

1111
RUN: trap "%run %t -handle_trap=0" TRAP

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ struct IntrinsicLibrary {
246246
template <mlir::arith::CmpIPredicate pred>
247247
fir::ExtendedValue genCPtrCompare(mlir::Type,
248248
llvm::ArrayRef<fir::ExtendedValue>);
249+
void genCoBroadcast(llvm::ArrayRef<fir::ExtendedValue>);
250+
void genCoMax(llvm::ArrayRef<fir::ExtendedValue>);
251+
void genCoMin(llvm::ArrayRef<fir::ExtendedValue>);
252+
void genCoSum(llvm::ArrayRef<fir::ExtendedValue>);
249253
mlir::Value genCosd(mlir::Type, llvm::ArrayRef<mlir::Value>);
250254
mlir::Value genCospi(mlir::Type, llvm::ArrayRef<mlir::Value>);
251255
void genDateAndTime(llvm::ArrayRef<fir::ExtendedValue>);

flang/include/flang/Optimizer/Builder/Runtime/Coarray.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ namespace fir::runtime {
3434
return fir::NameUniquer::doProcedure({"prif"}, {}, oss.str()); \
3535
}()
3636

37+
#define PRIF_STAT_TYPE builder.getRefType(builder.getI32Type())
38+
#define PRIF_ERRMSG_TYPE \
39+
fir::BoxType::get(fir::CharacterType::get(builder.getContext(), 1, \
40+
fir::CharacterType::unknownLen()))
41+
3742
/// Generate Call to runtime prif_init
3843
mlir::Value genInitCoarray(fir::FirOpBuilder &builder, mlir::Location loc);
3944

@@ -49,5 +54,22 @@ mlir::Value getNumImagesWithTeam(fir::FirOpBuilder &builder, mlir::Location loc,
4954
mlir::Value getThisImage(fir::FirOpBuilder &builder, mlir::Location loc,
5055
mlir::Value team = {});
5156

57+
/// Generate call to runtime subroutine prif_co_broadcast
58+
void genCoBroadcast(fir::FirOpBuilder &builder, mlir::Location loc,
59+
mlir::Value A, mlir::Value sourceImage, mlir::Value stat,
60+
mlir::Value errmsg);
61+
62+
/// Generate call to runtime subroutine prif_co_max and prif_co_max_character
63+
void genCoMax(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
64+
mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
65+
66+
/// Generate call to runtime subroutine prif_co_min or prif_co_min_character
67+
void genCoMin(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
68+
mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
69+
70+
/// Generate call to runtime subroutine prif_co_sum
71+
void genCoSum(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
72+
mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
73+
5274
} // namespace fir::runtime
5375
#endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COARRAY_H

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,34 @@ static constexpr IntrinsicHandler handlers[]{
397397
{"cmplx",
398398
&I::genCmplx,
399399
{{{"x", asValue}, {"y", asValue, handleDynamicOptional}}}},
400+
{"co_broadcast",
401+
&I::genCoBroadcast,
402+
{{{"a", asBox},
403+
{"source_image", asAddr},
404+
{"stat", asAddr, handleDynamicOptional},
405+
{"errmsg", asBox, handleDynamicOptional}}},
406+
/*isElemental*/ false},
407+
{"co_max",
408+
&I::genCoMax,
409+
{{{"a", asBox},
410+
{"result_image", asAddr, handleDynamicOptional},
411+
{"stat", asAddr, handleDynamicOptional},
412+
{"errmsg", asBox, handleDynamicOptional}}},
413+
/*isElemental*/ false},
414+
{"co_min",
415+
&I::genCoMin,
416+
{{{"a", asBox},
417+
{"result_image", asAddr, handleDynamicOptional},
418+
{"stat", asAddr, handleDynamicOptional},
419+
{"errmsg", asBox, handleDynamicOptional}}},
420+
/*isElemental*/ false},
421+
{"co_sum",
422+
&I::genCoSum,
423+
{{{"a", asBox},
424+
{"result_image", asAddr, handleDynamicOptional},
425+
{"stat", asAddr, handleDynamicOptional},
426+
{"errmsg", asBox, handleDynamicOptional}}},
427+
/*isElemental*/ false},
400428
{"command_argument_count", &I::genCommandArgumentCount},
401429
{"conjg", &I::genConjg},
402430
{"cosd", &I::genCosd},
@@ -3686,6 +3714,85 @@ mlir::Value IntrinsicLibrary::genCmplx(mlir::Type resultType,
36863714
imag);
36873715
}
36883716

3717+
// CO_BROADCAST
3718+
void IntrinsicLibrary::genCoBroadcast(llvm::ArrayRef<fir::ExtendedValue> args) {
3719+
checkCoarrayEnabled();
3720+
assert(args.size() == 4);
3721+
mlir::Value sourceImage = fir::getBase(args[1]);
3722+
mlir::Value status =
3723+
isStaticallyAbsent(args[2])
3724+
? fir::AbsentOp::create(builder, loc,
3725+
builder.getRefType(builder.getI32Type()))
3726+
.getResult()
3727+
: fir::getBase(args[2]);
3728+
mlir::Value errmsg =
3729+
isStaticallyAbsent(args[3])
3730+
? fir::AbsentOp::create(builder, loc, PRIF_ERRMSG_TYPE).getResult()
3731+
: fir::getBase(args[3]);
3732+
fir::runtime::genCoBroadcast(builder, loc, fir::getBase(args[0]), sourceImage,
3733+
status, errmsg);
3734+
}
3735+
3736+
// CO_MAX
3737+
void IntrinsicLibrary::genCoMax(llvm::ArrayRef<fir::ExtendedValue> args) {
3738+
checkCoarrayEnabled();
3739+
assert(args.size() == 4);
3740+
mlir::Value refNone =
3741+
fir::AbsentOp::create(builder, loc,
3742+
builder.getRefType(builder.getI32Type()))
3743+
.getResult();
3744+
mlir::Value resultImage =
3745+
isStaticallyAbsent(args[1]) ? refNone : fir::getBase(args[1]);
3746+
mlir::Value status =
3747+
isStaticallyAbsent(args[2]) ? refNone : fir::getBase(args[2]);
3748+
mlir::Value errmsg =
3749+
isStaticallyAbsent(args[3])
3750+
? fir::AbsentOp::create(builder, loc, PRIF_ERRMSG_TYPE).getResult()
3751+
: fir::getBase(args[3]);
3752+
fir::runtime::genCoMax(builder, loc, fir::getBase(args[0]), resultImage,
3753+
status, errmsg);
3754+
}
3755+
3756+
// CO_MIN
3757+
void IntrinsicLibrary::genCoMin(llvm::ArrayRef<fir::ExtendedValue> args) {
3758+
checkCoarrayEnabled();
3759+
assert(args.size() == 4);
3760+
mlir::Value refNone =
3761+
fir::AbsentOp::create(builder, loc,
3762+
builder.getRefType(builder.getI32Type()))
3763+
.getResult();
3764+
mlir::Value resultImage =
3765+
isStaticallyAbsent(args[1]) ? refNone : fir::getBase(args[1]);
3766+
mlir::Value status =
3767+
isStaticallyAbsent(args[2]) ? refNone : fir::getBase(args[2]);
3768+
mlir::Value errmsg =
3769+
isStaticallyAbsent(args[3])
3770+
? fir::AbsentOp::create(builder, loc, PRIF_ERRMSG_TYPE).getResult()
3771+
: fir::getBase(args[3]);
3772+
fir::runtime::genCoMin(builder, loc, fir::getBase(args[0]), resultImage,
3773+
status, errmsg);
3774+
}
3775+
3776+
// CO_SUM
3777+
void IntrinsicLibrary::genCoSum(llvm::ArrayRef<fir::ExtendedValue> args) {
3778+
checkCoarrayEnabled();
3779+
assert(args.size() == 4);
3780+
mlir::Value absentInt =
3781+
fir::AbsentOp::create(builder, loc,
3782+
builder.getRefType(builder.getI32Type()))
3783+
.getResult();
3784+
mlir::Value resultImage =
3785+
isStaticallyAbsent(args[1]) ? absentInt : fir::getBase(args[1]);
3786+
mlir::Value status =
3787+
isStaticallyAbsent(args[2]) ? absentInt : fir::getBase(args[2]);
3788+
mlir::Value errmsg =
3789+
isStaticallyAbsent(args[3])
3790+
? fir::AbsentOp::create(builder, loc, PRIF_ERRMSG_TYPE).getResult()
3791+
: fir::getBase(args[3]);
3792+
fir::runtime::genCoSum(builder, loc, fir::getBase(args[0]), resultImage,
3793+
status, errmsg);
3794+
}
3795+
36893796
// COMMAND_ARGUMENT_COUNT
36903797
fir::ExtendedValue IntrinsicLibrary::genCommandArgumentCount(
36913798
mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {

0 commit comments

Comments
 (0)