Skip to content

Commit b316798

Browse files
committed
Bug fixes for rebase onto LLVM 19.
1 parent 4093f20 commit b316798

File tree

120 files changed

+621
-459
lines changed

Some content is hidden

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

120 files changed

+621
-459
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,19 +1385,22 @@ def is_unexposed(self):
13851385
OPEN_ACC_COMPUTE_DIRECTIVE = 320
13861386

13871387
# Cilk cilk_spawn statement.
1388-
CILK_SPAWN_STMT = 321
1388+
CILK_SPAWN_STMT = 322
13891389

13901390
# Cilk wrapper for an expression preceded by cilk_spawn.
1391-
CILK_SPAWN_EXPR = 322
1391+
CILK_SPAWN_EXPR = 323
13921392

13931393
# Cilk cilk_sync statement.
1394-
CILK_SYNC_STMT = 323
1394+
CILK_SYNC_STMT = 324
13951395

13961396
# Cilk cilk_for statement.
1397-
CILK_FOR_STMT = 324
1397+
CILK_FOR_STMT = 325
13981398

13991399
# Cilk cilk_scope statement.
1400-
CILK_SCOPE_STMT = 325
1400+
CILK_SCOPE_STMT = 326
1401+
1402+
# Cilk cilk_for range statement.
1403+
CILK_FOR_RANGE_STMT = 327
14011404

14021405
###
14031406
# Other Kinds

clang/include/clang-c/Index.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,11 +2180,11 @@ enum CXCursorKind {
21802180

21812181
/** A _Cilk_scope statement.
21822182
*/
2183-
CXCursor_CilkScopeStmt = 311,
2183+
CXCursor_CilkScopeStmt = 326,
21842184

21852185
/** A _Cilk_for range statement.
21862186
*/
2187-
CXCursor_CilkForRangeStmt = 312,
2187+
CXCursor_CilkForRangeStmt = 327,
21882188

21892189
CXCursor_LastStmt = CXCursor_CilkForRangeStmt,
21902190

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,17 @@ def err_drv_invalid_cf_runtime_abi
340340
def err_drv_gnustep_objc_runtime_incompatible_binary : Error<
341341
"GNUstep Objective-C runtime version %0 incompatible with target binary format">;
342342
def err_drv_double_cilk : Error<
343-
"Conflicting Cilk versions">;
343+
"conflicting Cilk versions">;
344344
def err_drv_cilk_objc : Error<
345345
"Cilk does not support Objective-C">;
346346
def err_drv_cilk_unsupported: Error<
347347
"Cilk not yet supported for this target">;
348348
def err_drv_opencilk_missing_abi_bitcode: Error<
349-
"Cannot find OpenCilk runtime ABI bitcode file: %0">;
349+
"cannot find OpenCilk runtime ABI bitcode file: %0">;
350350
def err_drv_opencilk_resource_dir_missing_include: Error<
351-
"No include directory in OpenCilk resource directory: %0">;
351+
"no include directory in OpenCilk resource directory: %0">;
352352
def err_drv_opencilk_resource_dir_missing_lib: Error<
353-
"No lib directory in OpenCilk resource directory: %0">;
353+
"no lib directory in OpenCilk resource directory: %0">;
354354
def err_drv_emit_llvm_link : Error<
355355
"-emit-llvm cannot be used when linking">;
356356
def err_drv_optimization_remark_pattern : Error<

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace clang {
3939
DIAG_SIZE_AST = 300,
4040
DIAG_SIZE_COMMENT = 100,
4141
DIAG_SIZE_CROSSTU = 100,
42-
DIAG_SIZE_SEMA = 4500,
42+
DIAG_SIZE_SEMA = 4600,
4343
DIAG_SIZE_ANALYSIS = 100,
4444
DIAG_SIZE_REFACTORING = 1000,
4545
DIAG_SIZE_INSTALLAPI = 100,

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ def warn_pragma_cilk_grainsize_equals: Warning<
14321432
"'#pragma cilk grainsize' no longer requires '='">,
14331433
InGroup<SourceUsesCilkPlus>;
14341434
def warn_cilk_for_forrange_loop_experimental: Warning<
1435-
"'cilk_for' support for for-range loops is currently EXPERIMENTAL only!">,
1435+
"'cilk_for' support for for-range loops is currently experimental">,
14361436
InGroup<SourceUsesCilkPlus>;
14371437
def error_hyperobject_arguments: Error<
14381438
"hyperobject must have 0 or 2 callbacks">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11054,11 +11054,11 @@ def err_cilk_for_increment_inconsistent : Error<
1105411054
def err_cilk_for_increment_zero : Error<
1105511055
"loop increment must be non-zero in 'cilk_for'">;
1105611056
def err_cilk_for_loop_modifies_control_var : Error<
11057-
"Modifying the loop control variable inside a 'cilk_for' has undefined behavior">;
11057+
"modifying the loop control variable inside a 'cilk_for' has undefined behavior">;
1105811058
def warn_cilk_for_loop_control_var_func : Warning<
11059-
"Modifying the loop control variable inside a 'cilk_for' using a function call has undefined behavior">, InGroup<CilkPlusLoopControlVarModification>, DefaultIgnore;
11059+
"modifying the loop control variable inside a 'cilk_for' using a function call has undefined behavior">, InGroup<CilkPlusLoopControlVarModification>, DefaultIgnore;
1106011060
def warn_cilk_for_loop_control_var_aliased: Warning<
11061-
"Modifying the loop control variable '%0' through an alias in 'cilk_for' has undefined behavior">, InGroup<CilkPlusLoopControlVarModification>, DefaultIgnore;
11061+
"modifying the loop control variable '%0' through an alias in 'cilk_for' has undefined behavior">, InGroup<CilkPlusLoopControlVarModification>, DefaultIgnore;
1106211062
def note_cilk_for_loop_control_var_declared_here: Note<
1106311063
"'cilk_for' loop control variable declared here">;
1106411064
def warn_empty_cilk_for_body : Warning<
@@ -11140,7 +11140,7 @@ def no_reducer_array : Warning<
1114011140

1114111141
// cilk for_range
1114211142
def err_cilk_for_range_end_minus_begin : Error<
11143-
"Cannot determine length with '__end - __begin'. Please use a random access iterator.">;
11143+
"cannot determine length with '__end - __begin'; please use a random access iterator">;
1114411144
}
1114511145
// end of Cilk category
1114611146

clang/lib/AST/ASTContext.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,19 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
31943194
OS << "P";
31953195
return;
31963196

3197+
case Type::Hyperobject: {
3198+
const auto *HT = cast<HyperobjectType>(T);
3199+
OS << "<hyperobject>";
3200+
encodeTypeForFunctionPointerAuth(Ctx, OS, HT->getElementType());
3201+
if (HT->hasCallbacks()) {
3202+
OS << "<identity>";
3203+
encodeTypeForFunctionPointerAuth(Ctx, OS, HT->getIdentity()->getType());
3204+
OS << "<reduce>";
3205+
encodeTypeForFunctionPointerAuth(Ctx, OS, HT->getReduce()->getType());
3206+
}
3207+
return;
3208+
}
3209+
31973210
case Type::ObjCObjectPointer:
31983211
case Type::BlockPointer:
31993212
OS << "P";

clang/lib/CodeGen/CGCilk.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void CodeGenFunction::DetachScope::FinishDetach() {
323323
}
324324
}
325325

326-
Address CodeGenFunction::DetachScope::CreateDetachedMemTemp(
326+
RawAddress CodeGenFunction::DetachScope::CreateDetachedMemTemp(
327327
QualType Ty, StorageDuration SD, const Twine &Name) {
328328
// There shouldn't be multiple reference temporaries needed.
329329
assert(!RefTmp.isValid() &&
@@ -425,7 +425,7 @@ llvm::Instruction *CodeGenFunction::EmitSyncRegionStart() {
425425
auto NL = ApplyDebugLocation::CreateArtificial(*this);
426426
llvm::Instruction *SRStart = llvm::CallInst::Create(
427427
CGM.getIntrinsic(llvm::Intrinsic::syncregion_start),
428-
"syncreg", AllocaInsertPt);
428+
"syncreg", &*AllocaInsertPt);
429429
SRStart->setDebugLoc(Builder.getCurrentDebugLocation());
430430
return SRStart;
431431
}
@@ -858,6 +858,30 @@ LValue CodeGenFunction::EmitCilkSpawnExprLValue(const CilkSpawnExpr *E) {
858858
return LV;
859859
}
860860

861+
// Copied from CGStmt.cpp
862+
// [C++26][stmt.iter.general] (DR)
863+
// A trivially empty iteration statement is an iteration statement matching one
864+
// of the following forms:
865+
// - while ( expression ) ;
866+
// - while ( expression ) { }
867+
// - do ; while ( expression ) ;
868+
// - do { } while ( expression ) ;
869+
// - for ( init-statement expression(opt); ) ;
870+
// - for ( init-statement expression(opt); ) { }
871+
template <typename LoopStmt> static bool hasEmptyLoopBody(const LoopStmt &S) {
872+
if constexpr (std::is_same_v<LoopStmt, ForStmt> ||
873+
std::is_same_v<LoopStmt, CilkForStmt>) {
874+
if (S.getInc())
875+
return false;
876+
}
877+
const Stmt *Body = S.getBody();
878+
if (!Body || isa<NullStmt>(Body))
879+
return true;
880+
if (const CompoundStmt *Compound = dyn_cast<CompoundStmt>(Body))
881+
return Compound->body_empty();
882+
return false;
883+
}
884+
861885
void CodeGenFunction::EmitCilkForStmt(const CilkForStmt &S,
862886
ArrayRef<const Attr *> ForAttrs) {
863887
JumpDest LoopExit = getJumpDestInCurrentScope("pfor.end");
@@ -918,14 +942,12 @@ void CodeGenFunction::EmitCilkForStmt(const CilkForStmt &S,
918942
EmitBlock(CondBlock);
919943

920944
Expr::EvalResult Result;
921-
bool CondIsConstInt = S.getCond()->EvaluateAsInt(Result, getContext());
922-
923945
LoopStack.setSpawnStrategy(LoopAttributes::DAC);
924946
const SourceRange &R = S.getSourceRange();
925947
LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs,
926948
SourceLocToDebugLoc(R.getBegin()),
927949
SourceLocToDebugLoc(R.getEnd()),
928-
checkIfLoopMustProgress(CondIsConstInt));
950+
checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S)));
929951

930952
const Expr *Inc = S.getInc();
931953
assert(Inc && "_Cilk_for loop has no increment");

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ void CodeGenFunction::destroyHyperobject(CodeGenFunction &CGF, Address Addr,
18991899
QualType Type) {
19001900
llvm::Function *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::reducer_unregister);
19011901
llvm::Value *Arg =
1902-
CGF.Builder.CreateBitCast(Addr.getPointer(), CGF.CGM.VoidPtrTy);
1902+
CGF.Builder.CreateBitCast(Addr.emitRawPointer(CGF), CGF.CGM.VoidPtrTy);
19031903
CGF.Builder.CreateCall(F, {Arg});
19041904
QualType Inner = Type.stripHyperobject();
19051905
if (const RecordType *rtype = Inner->getAs<RecordType>()) {
@@ -2015,7 +2015,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
20152015
initializeWhatIsTechnicallyUninitialized(Loc);
20162016
if (Reducer)
20172017
EmitReducerInit(&D, RCB,
2018-
Builder.CreateBitCast(emission.Addr.getPointer(),
2018+
Builder.CreateBitCast(emission.Addr.emitRawPointer(*this),
20192019
CGM.VoidPtrTy));
20202020
return;
20212021
}
@@ -2075,7 +2075,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
20752075
EmitExprAsInit(Init, &D, lv, capturedByInit);
20762076
if (Reducer)
20772077
EmitReducerInit(&D, RCB,
2078-
Builder.CreateBitCast(emission.Addr.getPointer(),
2078+
Builder.CreateBitCast(emission.Addr.emitRawPointer(*this),
20792079
CGM.VoidPtrTy));
20802080
return;
20812081
}
@@ -2087,7 +2087,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
20872087
EmitStoreThroughLValue(RValue::get(constant), lv, true);
20882088
if (Reducer)
20892089
EmitReducerInit(&D, RCB,
2090-
Builder.CreateBitCast(emission.Addr.getPointer(),
2090+
Builder.CreateBitCast(emission.Addr.emitRawPointer(*this),
20912091
CGM.VoidPtrTy));
20922092
return;
20932093
}
@@ -2098,7 +2098,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
20982098

20992099
if (Reducer)
21002100
EmitReducerInit(&D, RCB,
2101-
Builder.CreateBitCast(emission.Addr.getPointer(),
2101+
Builder.CreateBitCast(emission.Addr.emitRawPointer(*this),
21022102
CGM.VoidPtrTy));
21032103
}
21042104

@@ -2325,9 +2325,6 @@ void CodeGenFunction::pushDestroy(QualType::DestructionKind dtorKind,
23252325
void CodeGenFunction::pushDestroy(CleanupKind cleanupKind, Address addr,
23262326
QualType type, Destroyer *destroyer,
23272327
bool useEHCleanupForArray) {
2328-
if (SpawnedCleanup)
2329-
return pushLifetimeExtendedDestroy(cleanupKind, addr, type, destroyer,
2330-
useEHCleanupForArray);
23312328
pushFullExprCleanup<DestroyObject>(cleanupKind, addr, type,
23322329
destroyer, useEHCleanupForArray);
23332330
}

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,9 +1210,9 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
12101210

12111211
if (IsReducer) {
12121212
llvm::Function *Unregister =
1213-
CGM.getIntrinsic(llvm::Intrinsic::reducer_unregister);
1213+
CGM.getIntrinsic(llvm::Intrinsic::reducer_unregister);
12141214
llvm::Value *AddrVoid =
1215-
Builder.CreateBitCast(addr.getPointer(), CGM.VoidPtrTy);
1215+
Builder.CreateBitCast(addr.emitRawPointer(*this), CGM.VoidPtrTy);
12161216
Builder.CreateCall(Unregister, {AddrVoid});
12171217
}
12181218

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ class CodeGenFunction : public CodeGenTypeCache {
15861586

15871587
// Information about a reference temporary created early in the detached
15881588
// block.
1589-
Address RefTmp = Address::invalid();
1589+
RawAddress RefTmp = RawAddress::invalid();
15901590
StorageDuration RefTmpSD;
15911591

15921592
// Optional taskframe created separately from detach.
@@ -1661,8 +1661,8 @@ class CodeGenFunction : public CodeGenTypeCache {
16611661

16621662
// Create a temporary for the spawned task, specifically, before the spawned
16631663
// task has started.
1664-
Address CreateDetachedMemTemp(QualType Ty, StorageDuration SD,
1665-
const Twine &Name = "det.tmp");
1664+
RawAddress CreateDetachedMemTemp(QualType Ty, StorageDuration SD,
1665+
const Twine &Name = "det.tmp");
16661666
};
16671667

16681668
/// The current detach scope.

clang/lib/Parse/ParseCilk.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ StmtResult Parser::ParseCilkForStatement(SourceLocation *TrailingElseLoc) {
209209

210210
if (Tok.is(tok::code_completion)) {
211211
cutOffParsing();
212-
Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_ForInit);
212+
Actions.CodeCompletion().CodeCompleteOrdinaryName(
213+
getCurScope(), SemaCodeCompletion::PCC_ForInit);
213214
return StmtError();
214215
}
215216

@@ -281,7 +282,8 @@ StmtResult Parser::ParseCilkForStatement(SourceLocation *TrailingElseLoc) {
281282

282283
if (Tok.is(tok::code_completion)) {
283284
cutOffParsing();
284-
Actions.CodeCompleteObjCForCollection(getCurScope(), DG);
285+
Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(),
286+
DG);
285287
return StmtError();
286288
}
287289
Collection = ParseExpression();
@@ -318,7 +320,8 @@ StmtResult Parser::ParseCilkForStatement(SourceLocation *TrailingElseLoc) {
318320

319321
if (Tok.is(tok::code_completion)) {
320322
cutOffParsing();
321-
Actions.CodeCompleteObjCForCollection(getCurScope(), nullptr);
323+
Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(),
324+
nullptr);
322325
return StmtError();
323326
}
324327
Collection = ParseExpression();

clang/lib/Sema/SemaExpr.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,9 +2290,10 @@ Expr *Sema::BuildHyperobjectLookup(Expr *E, bool Pointer) {
22902290
InputType.getLocalFastQualifiers());
22912291
QualType Ptr = Context.getPointerType(ResultType);
22922292

2293+
SourceLocation Loc = E->getExprLoc();
22932294
ExprResult SizeExpr;
22942295
if (ResultType.getTypePtr()->isDependentType()) {
2295-
SizeExpr = CreateUnaryExprOrTypeTraitExpr(E, E->getExprLoc(), UETT_SizeOf);
2296+
SizeExpr = CreateUnaryExprOrTypeTraitExpr(E, Loc, UETT_SizeOf);
22962297
} else {
22972298
QualType SizeType = Context.getSizeType();
22982299
llvm::APInt Size(Context.getTypeSize(SizeType),
@@ -2305,7 +2306,7 @@ Expr *Sema::BuildHyperobjectLookup(Expr *E, bool Pointer) {
23052306
VarAddr = E;
23062307
} else if (Difficult) {
23072308
ExprResult Address =
2308-
BuildBuiltinCallExpr(E->getExprLoc(), Builtin::BI__builtin_addressof, E);
2309+
BuildBuiltinCallExpr(Loc, Builtin::BI__builtin_addressof, E);
23092310
assert(Address.isUsable());
23102311
VarAddr = Address.get();
23112312
} else {
@@ -2316,16 +2317,18 @@ Expr *Sema::BuildHyperobjectLookup(Expr *E, bool Pointer) {
23162317
Expr *CallArgs[] = {VarAddr, SizeExpr.get(), HT->getIdentity(),
23172318
HT->getReduce()};
23182319
ExprResult Call =
2319-
BuildBuiltinCallExpr(E->getExprLoc(), Builtin::BI__hyper_lookup, CallArgs);
2320+
BuildBuiltinCallExpr(Loc, Builtin::BI__hyper_lookup, CallArgs);
23202321

23212322
// Template expansion normally strips out implicit casts, so make this
23222323
// explicit in C++.
2323-
CastExpr *Casted = nullptr;
2324+
Expr *Casted = nullptr;
23242325
if (Difficult)
2325-
Casted = CXXStaticCastExpr::Create(
2326-
Context, Ptr, VK_PRValue, CK_BitCast, Call.get(), nullptr,
2327-
Context.CreateTypeSourceInfo(Ptr), FPOptionsOverride(),
2328-
SourceLocation(), SourceLocation(), SourceRange());
2326+
// Based on logic in CoroutineStmtBuilder::makeNewAndDeleteExpr()
2327+
Casted =
2328+
BuildCXXNamedCast(Loc, tok::kw_static_cast,
2329+
Context.getTrivialTypeSourceInfo(Ptr), Call.get(),
2330+
SourceRange(Loc, Loc), SourceRange(Loc, Loc))
2331+
.get();
23292332
else
23302333
Casted =
23312334
ImplicitCastExpr::Create(Context, Ptr, CK_BitCast, Call.get(), nullptr,

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
144144
.Default(LoopHintAttr::TapirGrainsize);
145145
if (Option == LoopHintAttr::TapirGrainsize) {
146146
assert(ValueExpr && "Attribute must have a valid value expression.");
147-
if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
147+
if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc(), /*AllowZero=*/true))
148148
return nullptr;
149149
State = LoopHintAttr::Numeric;
150150
} else

0 commit comments

Comments
 (0)