From a89ed3064119d110da2289e78bb85630342a2b18 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Thu, 25 Apr 2024 16:34:29 +0200 Subject: [PATCH 01/11] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior https://wg21.link/P2809R3 --- clang/docs/ReleaseNotes.rst | 4 +- clang/lib/CodeGen/CGStmt.cpp | 81 ++++++++++++++++++--- clang/lib/CodeGen/CodeGenFunction.cpp | 1 + clang/lib/CodeGen/CodeGenFunction.h | 23 +----- clang/test/CodeGenCXX/attr-mustprogress.cpp | 70 ++++++++---------- clang/www/cxx_status.html | 2 +- 6 files changed, 107 insertions(+), 74 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 64526ed6d06f5..f5906c2dd4eb5 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -122,7 +122,7 @@ C++23 Feature Support materialize temporary object which is a prvalue in discarded-value expression. - Implemented `P1774R8: Portable assumptions `_. -- Implemented `P2448R2: Relaxing some constexpr restrictions `_. +- Implemented `P2809R3: Trivial infinite loops are not Undefined Behavior `_. C++2c Feature Support ^^^^^^^^^^^^^^^^^^^^^ @@ -131,6 +131,8 @@ C++2c Feature Support - Implemented `P2573R2: = delete("should have a reason"); `_ +- Implemented `P2573R2: = delete("should have a reason"); `_ + Resolutions to C++ Defect Reports ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 576fe2f7a2d46..7a0ad8a73b9fc 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -908,6 +908,73 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { incrementProfileCounter(&S); } +bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, + bool IsTrivialCXXLoop) { + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Always) + return true; + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Never) + return false; + + // Now apply rules for plain C (see 6.8.5.6 in C11). + // Loops with constant conditions do not have to make progress in any C + // version. + // As an extension, we consisider loops whose constant expression + // can be constant-folded. + Expr::EvalResult Result; + bool CondIsConstInt = + !ControllingExpression || + (ControllingExpression->EvaluateAsInt(Result, getContext()) && + Result.Val.isInt()); + bool IsTrue = CondIsConstInt && + (!ControllingExpression || Result.Val.getInt().getBoolValue()); + + if (getLangOpts().C99 && CondIsConstInt) + return false; + + // Loops with non-constant conditions must make progress in C11 and later. + if (getLangOpts().C11) + return true; + + // [C++26][intro.progress] (DR) + // The implementation may assume that any thread will eventually do one of the + // following: + // [...] + // - continue execution of a trivial infinite loop ([stmt.iter.general]). + if (getLangOpts().CPlusPlus11) { + if (IsTrivialCXXLoop && IsTrue) { + CurFn->removeFnAttr(llvm::Attribute::MustProgress); + return false; + } + return true; + } + + return false; +} + +// [C++26][stmt.iter.general] (DR) +// A trivially empty iteration statement is an iteration statement matching one +// of the following forms: +// - while ( expression ) ; +// - while ( expression ) { } +// - do ; while ( expression ) ; +// - do { } while ( expression ) ; +// - for ( init-statement expression(opt); ) ; +// - for ( init-statement expression(opt); ) { } +template static bool hasEmptyLoopBody(const LoopStmt &S) { + if constexpr (std::is_same_v) { + if (S.getInc()) + return false; + } + const Stmt *Body = S.getBody(); + if (!Body || isa(Body)) + return true; + if (const CompoundStmt *Compound = dyn_cast(Body)) + return Compound->body_empty(); + return false; +} + void CodeGenFunction::EmitWhileStmt(const WhileStmt &S, ArrayRef WhileAttrs) { // Emit the header for the loop, which will also become @@ -942,13 +1009,12 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S, // while(1) is common, avoid extra exit blocks. Be sure // to correctly handle break/continue though. llvm::ConstantInt *C = dyn_cast(BoolCondVal); - bool CondIsConstInt = C != nullptr; - bool EmitBoolCondBranch = !CondIsConstInt || !C->isOne(); + bool EmitBoolCondBranch = !C || !C->isOne(); const SourceRange &R = S.getSourceRange(); LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), CGM.getCodeGenOpts(), WhileAttrs, SourceLocToDebugLoc(R.getBegin()), SourceLocToDebugLoc(R.getEnd()), - checkIfLoopMustProgress(CondIsConstInt)); + checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S))); // When single byte coverage mode is enabled, add a counter to loop condition. if (llvm::EnableSingleByteCoverage) @@ -1059,14 +1125,13 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S, // "do {} while (0)" is common in macros, avoid extra blocks. Be sure // to correctly handle break/continue though. llvm::ConstantInt *C = dyn_cast(BoolCondVal); - bool CondIsConstInt = C; bool EmitBoolCondBranch = !C || !C->isZero(); const SourceRange &R = S.getSourceRange(); LoopStack.push(LoopBody, CGM.getContext(), CGM.getCodeGenOpts(), DoAttrs, SourceLocToDebugLoc(R.getBegin()), SourceLocToDebugLoc(R.getEnd()), - checkIfLoopMustProgress(CondIsConstInt)); + checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S))); // As long as the condition is true, iterate the loop. if (EmitBoolCondBranch) { @@ -1109,15 +1174,11 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S, llvm::BasicBlock *CondBlock = CondDest.getBlock(); EmitBlock(CondBlock); - Expr::EvalResult Result; - bool CondIsConstInt = - !S.getCond() || S.getCond()->EvaluateAsInt(Result, getContext()); - const SourceRange &R = S.getSourceRange(); LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs, SourceLocToDebugLoc(R.getBegin()), SourceLocToDebugLoc(R.getEnd()), - checkIfLoopMustProgress(CondIsConstInt)); + checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S))); // Create a cleanup scope for the condition variable cleanups. LexicalScope ConditionScope(*this, S.getSourceRange()); diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 86a6ddd80cc11..95c0784ad9760 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1465,6 +1465,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Ensure that the function adheres to the forward progress guarantee, which // is required by certain optimizations. + // The attribute will be removed if the body contains a trivial empty loop. if (checkIfFunctionMustProgress()) CurFn->addFnAttr(llvm::Attribute::MustProgress); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index ff1873325d409..f0e8e47bc0e42 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -635,28 +635,7 @@ class CodeGenFunction : public CodeGenTypeCache { /// Returns true if a loop must make progress, which means the mustprogress /// attribute can be added. \p HasConstantCond indicates whether the branch /// condition is a known constant. - bool checkIfLoopMustProgress(bool HasConstantCond) { - if (CGM.getCodeGenOpts().getFiniteLoops() == - CodeGenOptions::FiniteLoopsKind::Always) - return true; - if (CGM.getCodeGenOpts().getFiniteLoops() == - CodeGenOptions::FiniteLoopsKind::Never) - return false; - - // If the containing function must make progress, loops also must make - // progress (as in C++11 and later). - if (checkIfFunctionMustProgress()) - return true; - - // Now apply rules for plain C (see 6.8.5.6 in C11). - // Loops with constant conditions do not have to make progress in any C - // version. - if (HasConstantCond) - return false; - - // Loops with non-constant conditions must make progress in C11 and later. - return getLangOpts().C11; - } + bool checkIfLoopMustProgress(const Expr *, bool IsTrivialCXXLoop); const CodeGen::CGBlockInfo *BlockInfo = nullptr; llvm::Value *BlockPointer = nullptr; diff --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp b/clang/test/CodeGenCXX/attr-mustprogress.cpp index 843f5460426cc..5a24e9426d130 100644 --- a/clang/test/CodeGenCXX/attr-mustprogress.cpp +++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp @@ -24,21 +24,21 @@ int b = 0; // CHECK: datalayout // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f0v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond // CHECK: for.cond: // CXX98-NOT: br {{.*}} llvm.loop -// CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP1:!.*]] +// CXX11-NOT: br {{.*}} llvm.loop // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP1:!.*]] void f0() { for (; ;) ; } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f1v( // CHECK-NEXT: entry: @@ -46,8 +46,8 @@ void f0() { // CHECK: for.cond: // CHECK-NEXT: br i1 true, label %for.body, label %for.end // CHECK: for.body: -// CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP2:!.*]] +// CXX98-NOT: br {{.*}}, !llvm.loop +// CXX11-NOT: br {{.*}} llvm.loop // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP2:!.*]] // CHECK: for.end: // CHECK-NEXT: ret void @@ -81,7 +81,7 @@ void f2() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Fv( // CHECK-NEXT: entry: @@ -90,7 +90,7 @@ void f2() { // CHECK-NEXT: br i1 true, label %for.body, label %for.end // CHECK: for.body: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP4:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP4:!.*]] // CHECK: for.end: // CHECK-NEXT: br label %for.cond1 @@ -114,7 +114,7 @@ void F() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2F2v( // CHECK-NEXT: entry: @@ -134,7 +134,7 @@ void F() { // CHECK-NEXT: br i1 true, label %for.body2, label %for.end3 // CHECK: for.body2: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %for.cond1, !llvm.loop [[LOOP7:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br label %for.cond1, !llvm.loop [[LOOP7:!.*]] // CHECK: for.end3: // CHECK-NEXT: ret void @@ -147,14 +147,14 @@ void F2() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2w1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body // CHECK: while.body: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %while.body, !llvm.loop [[LOOP8:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP8:!.*]] // void w1() { @@ -186,7 +186,7 @@ void w2() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Wv( // CHECK-NEXT: entry: @@ -204,7 +204,7 @@ void w2() { // CHECK-NEXT: br label %while.body2 // CHECK: while.body2: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %while.body2, !llvm.loop [[LOOP11:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br label %while.body2, !llvm.loop [[LOOP11:!.*]] // void W() { @@ -215,14 +215,14 @@ void W() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2W2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body // CHECK: while.body: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]] +// CXX11-NOT: br label %while.body, !llvm.loop [[LOOP12:!.*]] // FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]] // void W2() { @@ -233,7 +233,7 @@ void W2() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2d1v( // CHECK-NEXT: entry: @@ -242,7 +242,7 @@ void W2() { // CHECK-NEXT: br label %do.cond // CHECK: do.cond: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP13:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP13:!.*]] // CHECK: do.end: // CHECK-NEXT: ret void @@ -278,7 +278,7 @@ void d2() { } // CXX98-NOT: mustprogress -// CXX11: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Dv( // CHECK-NEXT: entry: @@ -287,7 +287,7 @@ void d2() { // CHECK-NEXT: br label %do.cond // CHECK: do.cond: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP15:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP15:!.*]] // CHECK: do.end: // CHECK-NEXT: br label %do.body1 @@ -312,8 +312,8 @@ void D() { while (a == b); } -// CXX98-NOT : mustprogress -// CXX11: mustprogress +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress // FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2D2v( // CHECK-NEXT: entry: @@ -333,7 +333,7 @@ void D() { // CHECK-NEXT: br label %do.cond2 // CHECK: do.cond2: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NEXT: br i1 true, label %do.body1, label %do.end3, !llvm.loop [[LOOP18:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br i1 true, label %do.body1, label %do.end3, !llvm.loop [[LOOP18:!.*]] // CHECK: do.end3: // CHECK-NEXT: ret void @@ -347,22 +347,12 @@ void D2() { while (1); } -// CXX11: [[LOOP1]] = distinct !{[[LOOP1]], [[MP:!.*]]} +// CXX11: [[LOOP1:.*]] = distinct !{[[LOOP1]], [[MP:.*]]} // CXX11: [[MP]] = !{!"llvm.loop.mustprogress"} -// CXX11: [[LOOP2]] = distinct !{[[LOOP2]], [[MP]]} -// CXX11: [[LOOP3]] = distinct !{[[LOOP3]], [[MP]]} -// CXX11: [[LOOP4]] = distinct !{[[LOOP4]], [[MP]]} -// CXX11: [[LOOP5]] = distinct !{[[LOOP5]], [[MP]]} -// CXX11: [[LOOP6]] = distinct !{[[LOOP6]], [[MP]]} -// CXX11: [[LOOP7]] = distinct !{[[LOOP7]], [[MP]]} -// CXX11: [[LOOP8]] = distinct !{[[LOOP8]], [[MP]]} -// CXX11: [[LOOP9]] = distinct !{[[LOOP9]], [[MP]]} -// CXX11: [[LOOP10]] = distinct !{[[LOOP10]], [[MP]]} -// CXX11: [[LOOP11]] = distinct !{[[LOOP11]], [[MP]]} -// CXX11: [[LOOP12]] = distinct !{[[LOOP12]], [[MP]]} -// CXX11: [[LOOP13]] = distinct !{[[LOOP13]], [[MP]]} -// CXX11: [[LOOP14]] = distinct !{[[LOOP14]], [[MP]]} -// CXX11: [[LOOP15]] = distinct !{[[LOOP15]], [[MP]]} -// CXX11: [[LOOP16]] = distinct !{[[LOOP16]], [[MP]]} -// CXX11: [[LOOP17]] = distinct !{[[LOOP17]], [[MP]]} -// CXX11: [[LOOP18]] = distinct !{[[LOOP18]], [[MP]]} +// CXX11: [[LOOP2:.*]] = distinct !{[[LOOP2]], [[MP]]} +// CXX11: [[LOOP3:.*]] = distinct !{[[LOOP3]], [[MP]]} +// CXX11: [[LOOP4:.*]] = distinct !{[[LOOP4]], [[MP]]} +// CXX11: [[LOOP5:.*]] = distinct !{[[LOOP5]], [[MP]]} +// CXX11: [[LOOP6:.*]] = distinct !{[[LOOP6]], [[MP]]} +// CXX11: [[LOOP7:.*]] = distinct !{[[LOOP7]], [[MP]]} +// CXX11: [[LOOP8:.*]] = distinct !{[[LOOP8]], [[MP]]} diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index c233171e63c81..0d796597d05c0 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -187,7 +187,7 @@

C++2c implementation status

Trivial infinite loops are not Undefined Behavior P2809R3 (DR) - No + Clang 19 Erroneous behaviour for uninitialized reads From 5671ea9763730f67d406c389ace104e17234f562 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 09:44:30 +0200 Subject: [PATCH 02/11] Remove the mustprogress attributes on functions. Whether a function make progress is determined exclusively by loops metadata. --- clang/lib/CodeGen/CGStmt.cpp | 9 +-- clang/lib/CodeGen/CodeGenFunction.cpp | 6 -- clang/lib/CodeGen/CodeGenFunction.h | 18 ----- clang/test/CXX/special/class.dtor/p3-0x.cpp | 2 +- .../aarch64-sme-attrs.cpp | 14 ++-- .../CodeGen/address-safety-attr-flavors.cpp | 70 +++++++++---------- clang/test/CodeGen/address-safety-attr.cpp | 4 +- .../debug-names-compound-type-units.ll | 4 +- clang/test/CodeGen/fp-floatcontrol-stack.cpp | 40 +++++------ clang/test/CodeGen/sanitize-thread-attr.cpp | 2 +- clang/test/CodeGenCXX/apple-kext.cpp | 4 +- clang/test/CodeGenCXX/attr-mustprogress.cpp | 47 ++----------- .../CodeGenCXX/attr-target-clones-aarch64.cpp | 10 +-- clang/test/CodeGenCXX/attr-target-version.cpp | 22 +++--- .../test/CodeGenCXX/cxx11-exception-spec.cpp | 2 +- clang/test/CodeGenCXX/cxx11-noreturn.cpp | 2 +- clang/test/CodeGenCXX/derived-to-base.cpp | 2 +- clang/test/CodeGenCXX/main-norecurse.cpp | 2 +- .../microsoft-abi-array-cookies.cpp | 2 +- clang/test/CodeGenCXX/no-exceptions.cpp | 4 +- clang/test/CodeGenCXX/noinline-template.cpp | 2 +- .../CodeGenCXX/optnone-and-attributes.cpp | 4 +- clang/test/CodeGenCXX/optnone-def-decl.cpp | 2 +- clang/test/CodeGenCXX/pr58798.cpp | 20 +++--- clang/test/CodeGenCXX/reference-cast.cpp | 4 +- clang/test/CodeGenCXX/threadsafe-statics.cpp | 4 +- clang/test/CodeGenCXX/thunks-ehspec.cpp | 6 +- clang/test/CodeGenCXX/thunks.cpp | 2 +- clang/test/CodeGenCXX/virtual-base-cast.cpp | 2 +- clang/test/CodeGenHIP/default-attributes.hip | 8 +-- .../test/CodeGenObjCXX/lambda-expressions.mm | 4 +- clang/test/CodeGenSYCL/function-attrs.cpp | 2 +- clang/test/Modules/aarch64-sme-keywords.cppm | 2 +- clang/test/OpenMP/amdgcn-attributes.cpp | 18 ++--- clang/test/OpenMP/irbuilder_safelen.cpp | 3 +- .../irbuilder_safelen_order_concurrent.cpp | 3 +- clang/test/OpenMP/irbuilder_simd_aligned.cpp | 5 +- clang/test/OpenMP/irbuilder_simdlen.cpp | 3 +- .../test/OpenMP/irbuilder_simdlen_safelen.cpp | 3 +- .../OpenMP/parallel_if_codegen_PR51349.cpp | 4 +- .../check-attributes.cpp.funcattrs.expected | 2 +- 41 files changed, 148 insertions(+), 221 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 7a0ad8a73b9fc..f37af32f12072 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -942,13 +942,8 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, // following: // [...] // - continue execution of a trivial infinite loop ([stmt.iter.general]). - if (getLangOpts().CPlusPlus11) { - if (IsTrivialCXXLoop && IsTrue) { - CurFn->removeFnAttr(llvm::Attribute::MustProgress); - return false; - } - return true; - } + if (getLangOpts().CPlusPlus11) + return !(IsTrivialCXXLoop && IsTrue); return false; } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 95c0784ad9760..76262b6e0d2c8 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1463,12 +1463,6 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, if (Body && isa_and_nonnull(Body)) llvm::append_range(FnArgs, FD->parameters()); - // Ensure that the function adheres to the forward progress guarantee, which - // is required by certain optimizations. - // The attribute will be removed if the body contains a trivial empty loop. - if (checkIfFunctionMustProgress()) - CurFn->addFnAttr(llvm::Attribute::MustProgress); - // Generate the body of the function. PGO.assignRegionCounters(GD, CurFn); if (isa(FD)) diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index f0e8e47bc0e42..f8d160c52f594 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -614,24 +614,6 @@ class CodeGenFunction : public CodeGenTypeCache { // applies to. nullptr if there is no 'musttail' on the current statement. const CallExpr *MustTailCall = nullptr; - /// Returns true if a function must make progress, which means the - /// mustprogress attribute can be added. - bool checkIfFunctionMustProgress() { - if (CGM.getCodeGenOpts().getFiniteLoops() == - CodeGenOptions::FiniteLoopsKind::Never) - return false; - - // C++11 and later guarantees that a thread eventually will do one of the - // following (C++11 [intro.multithread]p24 and C++17 [intro.progress]p1): - // - terminate, - // - make a call to a library I/O function, - // - perform an access through a volatile glvalue, or - // - perform a synchronization operation or an atomic operation. - // - // Hence each function is 'mustprogress' in C++11 or later. - return getLangOpts().CPlusPlus11; - } - /// Returns true if a loop must make progress, which means the mustprogress /// attribute can be added. \p HasConstantCond indicates whether the branch /// condition is a known constant. diff --git a/clang/test/CXX/special/class.dtor/p3-0x.cpp b/clang/test/CXX/special/class.dtor/p3-0x.cpp index 857bdca557fdc..f6a64260e0df5 100644 --- a/clang/test/CXX/special/class.dtor/p3-0x.cpp +++ b/clang/test/CXX/special/class.dtor/p3-0x.cpp @@ -176,4 +176,4 @@ struct TVC : VX template TVC::~TVC() {} -// CHECK: attributes [[ATTRGRP]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[ATTRGRP]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp b/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp index fdd2de11365dd..8fb3b0cac7bb4 100644 --- a/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp +++ b/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp @@ -278,18 +278,18 @@ int test_variadic_template() __arm_inout("za") { preserves_za_decl); } -// CHECK: attributes #[[SM_ENABLED]] = { mustprogress noinline nounwind "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_ENABLED]] = { noinline nounwind "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[NORMAL_DECL]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_ENABLED_DECL]] = { "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[SM_COMPATIBLE]] = { mustprogress noinline nounwind "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_COMPATIBLE]] = { noinline nounwind "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_COMPATIBLE_DECL]] = { "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[SM_BODY]] = { mustprogress noinline nounwind "aarch64_pstate_sm_body" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_SHARED]] = { mustprogress noinline nounwind "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_BODY]] = { noinline nounwind "aarch64_pstate_sm_body" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_SHARED]] = { noinline nounwind "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[ZA_SHARED_DECL]] = { "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_PRESERVED]] = { mustprogress noinline nounwind "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_PRESERVED]] = { noinline nounwind "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[ZA_PRESERVED_DECL]] = { "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_NEW]] = { mustprogress noinline nounwind "aarch64_new_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[NORMAL_DEF]] = { mustprogress noinline nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_NEW]] = { noinline nounwind "aarch64_new_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[NORMAL_DEF]] = { noinline nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_ENABLED_CALL]] = { "aarch64_pstate_sm_enabled" } // CHECK: attributes #[[SM_COMPATIBLE_CALL]] = { "aarch64_pstate_sm_compatible" } // CHECK: attributes #[[SM_BODY_CALL]] = { "aarch64_pstate_sm_body" } diff --git a/clang/test/CodeGen/address-safety-attr-flavors.cpp b/clang/test/CodeGen/address-safety-attr-flavors.cpp index ef815555059db..f14257e718c09 100644 --- a/clang/test/CodeGen/address-safety-attr-flavors.cpp +++ b/clang/test/CodeGen/address-safety-attr-flavors.cpp @@ -25,60 +25,60 @@ // RUN: FileCheck -check-prefix=CHECK-KHWASAN %s int HasSanitizeAddress() { return 1; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: Function Attrs: mustprogress noinline nounwind sanitize_address -// CHECK-KASAN: Function Attrs: mustprogress noinline nounwind sanitize_address -// CHECK-HWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress -// CHECK-KHWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address +// CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address +// CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress +// CHECK-KHWASAN: Function Attrs: noinline nounwind sanitize_hwaddress __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} -// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} -// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} +// CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} +// CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} __attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} -// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} -// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} +// CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} +// CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} __attribute__((disable_sanitizer_instrumentation)) int DisableSanitizerInstrumentation() { return 0; } -// CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp index bd899ed2f9a74..7aeda9a80dcd9 100644 --- a/clang/test/CodeGen/address-safety-attr.cpp +++ b/clang/test/CodeGen/address-safety-attr.cpp @@ -148,7 +148,7 @@ int global2 = *(int*)((char*)&global1+1); // BLFILE: attributes [[NOATTR]] = { noinline nounwind{{.*}} } // BLFUNC: attributes [[WITH]] = { noinline nounwind sanitize_address{{.*}} } -// BLFUNC: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } +// BLFUNC: attributes [[NOATTR]] = { noinline nounwind{{.*}} } // ASAN: attributes [[WITH]] = { noinline nounwind sanitize_address{{.*}} } -// ASAN: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } +// ASAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGen/debug-names-compound-type-units.ll b/clang/test/CodeGen/debug-names-compound-type-units.ll index 62cecfdeaf7f9..bb9f41b82f061 100644 --- a/clang/test/CodeGen/debug-names-compound-type-units.ll +++ b/clang/test/CodeGen/debug-names-compound-type-units.ll @@ -29,7 +29,7 @@ target triple = "x86_64-unknown-linux-gnu" %struct.Foo2 = type { i8, %struct.Foo } %struct.Foo = type { i8 } -; Function Attrs: mustprogress noinline nounwind optnone uwtable +; Function Attrs: noinline nounwind optnone uwtable define dso_local void @_Z7fooFuncv() #0 !dbg !10 { entry: %global2 = alloca %struct.Foo2, align 1 @@ -40,7 +40,7 @@ entry: ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 -attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } !llvm.dbg.cu = !{!0} diff --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp b/clang/test/CodeGen/fp-floatcontrol-stack.cpp index 090da25d21207..d8bff72ac1303 100644 --- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp +++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp @@ -6,10 +6,10 @@ #define FUN(n) \ (float z) { return n * z + n; } -// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} -// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} +// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} float fun_default FUN(1) //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}} #if DEFAULT @@ -32,10 +32,10 @@ float fun_default FUN(1) // Rule: precise must be enabled #pragma float_control(except, on) #endif - // CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} - // CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} - // CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} - // CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} + // CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} + // CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone strictfp{{$$}} + // CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} + // CHECK-NOHONOR: Function Attrs: noinline nounwind optnone strictfp{{$$}} float exc_on FUN(2) //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}} #if DEFAULT @@ -54,10 +54,10 @@ float fun_default FUN(1) #endif #pragma float_control(pop) - // CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} - // CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} - // CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} - // CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} + // CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} + // CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} + // CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} + // CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} float exc_pop FUN(5) //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}} #if DEFAULT @@ -223,10 +223,10 @@ float fun_default FUN(1) #pragma float_control(except, on) #endif float y(); -// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} -// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} +// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} class ON { // Settings for top level class initializer use program source setting. float z = 2 + y() * 7; @@ -246,10 +246,10 @@ class ON { }; ON on; #pragma float_control(except, off) -// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} class OFF { float w = 2 + y() * 7; // CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}} diff --git a/clang/test/CodeGen/sanitize-thread-attr.cpp b/clang/test/CodeGen/sanitize-thread-attr.cpp index 15ae3a16df696..ef861dfe8e42b 100644 --- a/clang/test/CodeGen/sanitize-thread-attr.cpp +++ b/clang/test/CodeGen/sanitize-thread-attr.cpp @@ -58,5 +58,5 @@ int global2 = *(int*)((char*)&global1+1); // BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} } -// TSAN: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } +// TSAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} } // TSAN: attributes [[WITH]] = { noinline nounwind sanitize_thread{{.*}} } diff --git a/clang/test/CodeGenCXX/apple-kext.cpp b/clang/test/CodeGenCXX/apple-kext.cpp index 2cba0be7a006a..d49ef2a0ccfa1 100644 --- a/clang/test/CodeGenCXX/apple-kext.cpp +++ b/clang/test/CodeGenCXX/apple-kext.cpp @@ -38,5 +38,5 @@ namespace test0 { // CHECK: call void @_ZN5test01AD1Ev(ptr @_ZN5test01aE) // CHECK-NEXT: ret void -// CHECK: attributes #[[ATTR0]] = { alwaysinline mustprogress nounwind {{.*}} } -// CHECK: attributes #[[ATTR1]] = { mustprogress noinline nounwind {{.*}} } +// CHECK: attributes #[[ATTR0]] = { alwaysinline nounwind {{.*}} } +// CHECK: attributes #[[ATTR1]] = { noinline nounwind {{.*}} } diff --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp b/clang/test/CodeGenCXX/attr-mustprogress.cpp index 5a24e9426d130..6179712f28540 100644 --- a/clang/test/CodeGenCXX/attr-mustprogress.cpp +++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp @@ -6,10 +6,10 @@ // Check -ffinite-loops option in combination with various standard versions. // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s -// RUN: %clang_cc1 -std=c++11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s -// RUN: %clang_cc1 -std=c++14 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s -// RUN: %clang_cc1 -std=c++17 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s -// RUN: %clang_cc1 -std=c++20 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s +// RUN: %clang_cc1 -std=c++11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s +// RUN: %clang_cc1 -std=c++14 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s +// RUN: %clang_cc1 -std=c++17 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s +// RUN: %clang_cc1 -std=c++20 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s // Check -fno-finite-loops option in combination with various standard versions. // RUN: %clang_cc1 -std=c++98 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s @@ -23,9 +23,6 @@ int b = 0; // CHECK: datalayout -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f0v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -37,9 +34,6 @@ void f0() { for (; ;) ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -57,9 +51,6 @@ void f1() { ; } -// CXX98-NOT: mustprogress -// CXX11: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -80,9 +71,6 @@ void f2() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Fv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -113,9 +101,6 @@ void F() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2F2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -146,9 +131,6 @@ void F2() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2w1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body @@ -162,9 +144,6 @@ void w1() { ; } -// CXX98-NOT: mustprogress -// CXX11: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2w2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.cond @@ -185,9 +164,6 @@ void w2() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Wv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.cond @@ -214,9 +190,6 @@ void W() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2W2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body @@ -232,9 +205,6 @@ void W2() { ; } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2d1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -253,9 +223,6 @@ void d1() { while (1); } -// CXX98-NOT: mustprogress -// CXX11: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2d2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -277,9 +244,6 @@ void d2() { while (a == b); } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Dv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -312,9 +276,6 @@ void D() { while (a == b); } -// CXX98-NOT: mustprogress -// CXX11-NOT: mustprogress -// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2D2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body diff --git a/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp b/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp index 7953f902bf09b..c15f46cde54bf 100644 --- a/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp +++ b/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp @@ -230,11 +230,11 @@ void run_foo_tml() { // CHECK-NEXT: ret i32 2 // //. -// CHECK: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } -// CHECK: attributes #[[ATTR1:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ls64" } -// CHECK: attributes #[[ATTR2:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CHECK: attributes #[[ATTR3:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fptoint" } -// CHECK: attributes #[[ATTR4:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } +// CHECK: attributes #[[ATTR0:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } +// CHECK: attributes #[[ATTR1:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ls64" } +// CHECK: attributes #[[ATTR2:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #[[ATTR3:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fptoint" } +// CHECK: attributes #[[ATTR4:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } //. // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} // CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} diff --git a/clang/test/CodeGenCXX/attr-target-version.cpp b/clang/test/CodeGenCXX/attr-target-version.cpp index 8b7273fe3bb51..c9a22372f26f8 100644 --- a/clang/test/CodeGenCXX/attr-target-version.cpp +++ b/clang/test/CodeGenCXX/attr-target-version.cpp @@ -312,17 +312,17 @@ int bar() { // CHECK-NEXT: ret ptr @_ZN7MyClass40unused_with_implicit_forward_default_defEv.default // //. -// CHECK: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } -// CHECK: attributes #[[ATTR1:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CHECK: attributes #[[ATTR2:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fp-armv8,+neon,+sm4" } -// CHECK: attributes #[[ATTR3:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+crc" } -// CHECK: attributes #[[ATTR4:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+dotprod,+fp-armv8,+neon" } -// CHECK: attributes #[[ATTR5:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+mops" } -// CHECK: attributes #[[ATTR6:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon" } -// CHECK: attributes #[[ATTR7:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon,+sve" } -// CHECK: attributes #[[ATTR8:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } -// CHECK: attributes #[[ATTR9:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" } -// CHECK: attributes #[[ATTR10:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm" } +// CHECK: attributes #[[ATTR0:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } +// CHECK: attributes #[[ATTR1:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #[[ATTR2:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fp-armv8,+neon,+sm4" } +// CHECK: attributes #[[ATTR3:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+crc" } +// CHECK: attributes #[[ATTR4:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+dotprod,+fp-armv8,+neon" } +// CHECK: attributes #[[ATTR5:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+mops" } +// CHECK: attributes #[[ATTR6:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon" } +// CHECK: attributes #[[ATTR7:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon,+sve" } +// CHECK: attributes #[[ATTR8:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } +// CHECK: attributes #[[ATTR9:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" } +// CHECK: attributes #[[ATTR10:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm" } // CHECK: attributes #[[ATTR11:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" } //. // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} diff --git a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp index 08de8868b4710..3991c5170d14f 100644 --- a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp +++ b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp @@ -121,7 +121,7 @@ void j() { } // CHECK: attributes [[NONE]] = { {{.*}} } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } // CHECK: attributes [[NUW2]] = { nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/cxx11-noreturn.cpp b/clang/test/CodeGenCXX/cxx11-noreturn.cpp index feea72ef3f450..58a5a377133a5 100644 --- a/clang/test/CodeGenCXX/cxx11-noreturn.cpp +++ b/clang/test/CodeGenCXX/cxx11-noreturn.cpp @@ -7,4 +7,4 @@ int g(); while (g()) {} } -// CHECK: attributes [[NR]] = { mustprogress noinline noreturn nounwind{{.*}} } +// CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/derived-to-base.cpp b/clang/test/CodeGenCXX/derived-to-base.cpp index c8dbd5bf5cb05..8b49d56a68d44 100644 --- a/clang/test/CodeGenCXX/derived-to-base.cpp +++ b/clang/test/CodeGenCXX/derived-to-base.cpp @@ -46,4 +46,4 @@ namespace test3 { } } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/main-norecurse.cpp b/clang/test/CodeGenCXX/main-norecurse.cpp index 3a476e6a119a2..a98677ce6f599 100644 --- a/clang/test/CodeGenCXX/main-norecurse.cpp +++ b/clang/test/CodeGenCXX/main-norecurse.cpp @@ -5,4 +5,4 @@ int main(int argc, char **argv) { return 1; } -// CHECK: attributes #0 = { mustprogress noinline norecurse{{.*}} } +// CHECK: attributes #0 = { noinline norecurse{{.*}} } diff --git a/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp b/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp index 1cc0e9af571c3..d60b4fefbf688 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp @@ -62,4 +62,4 @@ struct S { void delete_s(S *s) { delete[] s; } } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/no-exceptions.cpp b/clang/test/CodeGenCXX/no-exceptions.cpp index 47f491e50e8f1..c951b685a8a1b 100644 --- a/clang/test/CodeGenCXX/no-exceptions.cpp +++ b/clang/test/CodeGenCXX/no-exceptions.cpp @@ -3,7 +3,7 @@ void g(); // CHECK: define{{.*}} void @_Z1fv() [[NUW:#[0-9]+]] -void f() throw (int) { +void f() throw (int) { // CHECK-NOT: invoke void @_Z1gv g(); @@ -11,4 +11,4 @@ void f() throw (int) { // CHECK: ret void } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/noinline-template.cpp b/clang/test/CodeGenCXX/noinline-template.cpp index cb81f72d0714f..507ca3f34af51 100644 --- a/clang/test/CodeGenCXX/noinline-template.cpp +++ b/clang/test/CodeGenCXX/noinline-template.cpp @@ -15,4 +15,4 @@ void foo() { strs.growStorageBy(); } -// CHECK: attributes [[NI]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NI]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/optnone-and-attributes.cpp b/clang/test/CodeGenCXX/optnone-and-attributes.cpp index 68aa0988b18b5..870d5e9496f04 100644 --- a/clang/test/CodeGenCXX/optnone-and-attributes.cpp +++ b/clang/test/CodeGenCXX/optnone-and-attributes.cpp @@ -75,8 +75,8 @@ int exported_optnone_func(int a) { // CHECK: declare dllimport {{.*}} @_Z21imported_optnone_funci({{.*}}) [[DLLIMPORT:#[0-9]+]] -// CHECK: attributes [[OPTNONE]] = { mustprogress noinline {{.*}} optnone -// CHECK: attributes [[NORETURN]] = { mustprogress noinline noreturn {{.*}} optnone +// CHECK: attributes [[OPTNONE]] = { noinline {{.*}} optnone +// CHECK: attributes [[NORETURN]] = { noinline noreturn {{.*}} optnone // CHECK: attributes [[DLLIMPORT]] = // CHECK-NOT: optnone diff --git a/clang/test/CodeGenCXX/optnone-def-decl.cpp b/clang/test/CodeGenCXX/optnone-def-decl.cpp index 9e7d295ea31d4..6e4e510b9bf6e 100644 --- a/clang/test/CodeGenCXX/optnone-def-decl.cpp +++ b/clang/test/CodeGenCXX/optnone-def-decl.cpp @@ -89,7 +89,7 @@ int user_of_forceinline_optnone_function() { // CHECK: @_Z36user_of_forceinline_optnone_functionv() [[NORMAL]] // CHECK: @_Z28forceinline_optnone_functionii({{.*}}) [[OPTNONE]] -// CHECK: attributes [[OPTNONE]] = { mustprogress noinline nounwind optnone {{.*}} } +// CHECK: attributes [[OPTNONE]] = { noinline nounwind optnone {{.*}} } // CHECK: attributes [[NORMAL]] = // CHECK-NOT: noinline // CHECK-NOT: optnone diff --git a/clang/test/CodeGenCXX/pr58798.cpp b/clang/test/CodeGenCXX/pr58798.cpp index 607b36aa7f69a..ced8823e571e7 100644 --- a/clang/test/CodeGenCXX/pr58798.cpp +++ b/clang/test/CodeGenCXX/pr58798.cpp @@ -1,7 +1,7 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions | FileCheck %s -// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z54early_caller_of_callee_with_clang_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: @@ -12,7 +12,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z22callee_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -30,7 +30,7 @@ // CHECK-NEXT: ret i32 24 // -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_clang_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1:[0-9]+]] { // CHECK-NEXT: entry: @@ -41,7 +41,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_cxx_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -52,7 +52,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z20callee_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] personality ptr @__gxx_personality_v0 { // CHECK-NEXT: entry: @@ -78,7 +78,7 @@ // CHECK-NEXT: unreachable // -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z50early_caller_of_callee_with_cxx_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: @@ -129,7 +129,7 @@ int callee_with_cxx_attr(int a) noexcept { // Calls to definitions: -// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z53late_caller_of_callee_with_clang_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -143,7 +143,7 @@ __attribute__((pure)) int late_caller_of_callee_with_clang_attr_with_clang_attr( return callee_with_clang_attr(a); } -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_clang_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: @@ -157,7 +157,7 @@ int late_caller_of_callee_with_clang_attr_with_cxx_attr(int a) noexcept { return callee_with_clang_attr(a); } -// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_cxx_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -171,7 +171,7 @@ __attribute__((pure)) int late_caller_of_callee_with_cxx_attr_with_clang_attr(in return callee_with_cxx_attr(a); } -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z49late_caller_of_callee_with_cxx_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: diff --git a/clang/test/CodeGenCXX/reference-cast.cpp b/clang/test/CodeGenCXX/reference-cast.cpp index e7b07365974d6..5cb0901c4b9cc 100644 --- a/clang/test/CodeGenCXX/reference-cast.cpp +++ b/clang/test/CodeGenCXX/reference-cast.cpp @@ -15,7 +15,7 @@ const int &lvalue_noop_cast() { return 17; } -// CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z20lvalue_integral_castv() +// CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z20lvalue_integral_castv() const short &lvalue_integral_cast() { if (i == 0) // CHECK: store i16 17, ptr @@ -193,4 +193,4 @@ namespace PR10650 { // CHECK: store i64 } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/threadsafe-statics.cpp b/clang/test/CodeGenCXX/threadsafe-statics.cpp index 4c53482d4c4c9..443fbecc3d260 100644 --- a/clang/test/CodeGenCXX/threadsafe-statics.cpp +++ b/clang/test/CodeGenCXX/threadsafe-statics.cpp @@ -22,6 +22,6 @@ void g() { // NO-TSS-NOT: call void @__cxa_guard_release // NO-TSS: ret void -// WITH-TSS: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// WITH-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} } -// NO-TSS: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// NO-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/thunks-ehspec.cpp b/clang/test/CodeGenCXX/thunks-ehspec.cpp index 4c95a47111408..813d9a6272447 100644 --- a/clang/test/CodeGenCXX/thunks-ehspec.cpp +++ b/clang/test/CodeGenCXX/thunks-ehspec.cpp @@ -17,13 +17,13 @@ class C : A, B { }; void C::primary_key() {} -// CHECK-LABEL: define available_externally void @_ZThn8_N1C9secondaryEv(ptr noundef %this) {{.*}} #2 +// CHECK-LABEL: define available_externally void @_ZThn8_N1C9secondaryEv(ptr noundef %this) {{.*}} #0 // CHECK-NOT: invoke // CHECK: tail call void @_ZN1C9secondaryEv(ptr {{[^,]*}} %{{.*}}) // CHECK-NOT: invoke // CHECK: ret void -// CHECK-LABEL: define available_externally void @_ZThn8_N1C16secondary_varargEiz(ptr noundef %this, i32 noundef %0, ...) {{.*}} #2 +// CHECK-LABEL: define available_externally void @_ZThn8_N1C16secondary_varargEiz(ptr noundef %this, i32 noundef %0, ...) {{.*}} #0 // CHECK-NOT: invoke -// CHECK: musttail call void (ptr, i32, ...) @_ZN1C16secondary_varargEiz(ptr {{[^,]*}} %{{.*}}, i32 noundef %{{.*}}, ...) #3 +// CHECK: musttail call void (ptr, i32, ...) @_ZN1C16secondary_varargEiz(ptr {{[^,]*}} %{{.*}}, i32 noundef %{{.*}}, ...) #2 // CHECK-NEXT: ret void diff --git a/clang/test/CodeGenCXX/thunks.cpp b/clang/test/CodeGenCXX/thunks.cpp index f1ceebf24ba18..394dc8d766515 100644 --- a/clang/test/CodeGenCXX/thunks.cpp +++ b/clang/test/CodeGenCXX/thunks.cpp @@ -529,7 +529,7 @@ C c; // CHECK-NONOPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv // Checking with opt -// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(ptr noundef %this) unnamed_addr #1 align 2 +// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(ptr noundef %this) unnamed_addr #0 align 2 // This is from Test5: // CHECK-OPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv diff --git a/clang/test/CodeGenCXX/virtual-base-cast.cpp b/clang/test/CodeGenCXX/virtual-base-cast.cpp index 57388431e9007..a6b4672eddc83 100644 --- a/clang/test/CodeGenCXX/virtual-base-cast.cpp +++ b/clang/test/CodeGenCXX/virtual-base-cast.cpp @@ -75,4 +75,4 @@ BB* d() { return y; } // MSVC: add nsw i32 4, %[[offset]] // MSVC: } -// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenHIP/default-attributes.hip b/clang/test/CodeGenHIP/default-attributes.hip index 63572bfd242b9..e1e1f4417fa43 100644 --- a/clang/test/CodeGenHIP/default-attributes.hip +++ b/clang/test/CodeGenHIP/default-attributes.hip @@ -8,7 +8,7 @@ #define __device__ __attribute__((device)) #define __global__ __attribute__((global)) -// OPTNONE: Function Attrs: convergent mustprogress noinline nounwind optnone +// OPTNONE: Function Attrs: convergent noinline nounwind optnone // OPTNONE-LABEL: define {{[^@]+}}@_Z4funcv // OPTNONE-SAME: () #[[ATTR0:[0-9]+]] { // OPTNONE-NEXT: entry: @@ -24,7 +24,7 @@ __device__ void func() { } -// OPTNONE: Function Attrs: convergent mustprogress noinline norecurse nounwind optnone +// OPTNONE: Function Attrs: convergent noinline norecurse nounwind optnone // OPTNONE-LABEL: define {{[^@]+}}@_Z6kernelv // OPTNONE-SAME: () #[[ATTR1:[0-9]+]] { // OPTNONE-NEXT: entry: @@ -40,8 +40,8 @@ __global__ void kernel() { } //. -// OPTNONE: attributes #0 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// OPTNONE: attributes #1 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// OPTNONE: attributes #0 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// OPTNONE: attributes #1 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } //. // OPT: attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" } // OPT: attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm index e1fb6ec709b72..1afbde04ab0fa 100644 --- a/clang/test/CodeGenObjCXX/lambda-expressions.mm +++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm @@ -163,5 +163,5 @@ void test() { #endif -// ARC: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } -// MRC: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// ARC: attributes [[NUW]] = { noinline nounwind{{.*}} } +// MRC: attributes [[NUW]] = { noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenSYCL/function-attrs.cpp b/clang/test/CodeGenSYCL/function-attrs.cpp index 1606f961f2d39..21bef5b4a961d 100644 --- a/clang/test/CodeGenSYCL/function-attrs.cpp +++ b/clang/test/CodeGenSYCL/function-attrs.cpp @@ -49,7 +49,7 @@ int main() { return 0; } //. -// CHECK: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #0 = { convergent noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } // CHECK: attributes #1 = { convergent nounwind } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} diff --git a/clang/test/Modules/aarch64-sme-keywords.cppm b/clang/test/Modules/aarch64-sme-keywords.cppm index 759701a633ceb..4852d7e10d602 100644 --- a/clang/test/Modules/aarch64-sme-keywords.cppm +++ b/clang/test/Modules/aarch64-sme-keywords.cppm @@ -31,7 +31,7 @@ import A; // // CHECK:declare void @_ZW1A14f_preserves_zav() #[[PRESERVES_ZA_DECL:[0-9]+]] // -// CHECK:; Function Attrs: mustprogress noinline nounwind optnone +// CHECK:; Function Attrs: noinline nounwind optnone // CHECK:define dso_local void @_Z21f_nonstreaming_callerv() #[[NORMAL_DEF:[0-9]+]] { // CHECK:entry: // CHECK: call void @_ZW1A11f_streamingv() #[[STREAMING_USE:[0-9]+]] diff --git a/clang/test/OpenMP/amdgcn-attributes.cpp b/clang/test/OpenMP/amdgcn-attributes.cpp index 5ddc34537d12f..fd6497919e3b7 100644 --- a/clang/test/OpenMP/amdgcn-attributes.cpp +++ b/clang/test/OpenMP/amdgcn-attributes.cpp @@ -32,12 +32,12 @@ int callable(int x) { return x + 1; } -// DEFAULT: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } -// CPU: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" } -// NOIEEE: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } -// UNSAFEATOMIC: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } - -// DEFAULT: attributes #2 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CPU: attributes #2 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" } -// NOIEEE: attributes #2 = { convergent mustprogress noinline nounwind optnone "amdgpu-ieee"="false" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// UNSAFEATOMIC: attributes #2 = { convergent mustprogress noinline nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" } +// NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } + +// DEFAULT: attributes #2 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CPU: attributes #2 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" } +// NOIEEE: attributes #2 = { convergent noinline nounwind optnone "amdgpu-ieee"="false" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// UNSAFEATOMIC: attributes #2 = { convergent noinline nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } diff --git a/clang/test/OpenMP/irbuilder_safelen.cpp b/clang/test/OpenMP/irbuilder_safelen.cpp index 4ce9e3918957a..84a7d9fe2aeed 100644 --- a/clang/test/OpenMP/irbuilder_safelen.cpp +++ b/clang/test/OpenMP/irbuilder_safelen.cpp @@ -244,8 +244,7 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp b/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp index f82a7b229356c..5d3c8f240963d 100644 --- a/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp +++ b/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp @@ -244,8 +244,7 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 50} diff --git a/clang/test/OpenMP/irbuilder_simd_aligned.cpp b/clang/test/OpenMP/irbuilder_simd_aligned.cpp index db8f19cd56b14..fa35946de3b47 100644 --- a/clang/test/OpenMP/irbuilder_simd_aligned.cpp +++ b/clang/test/OpenMP/irbuilder_simd_aligned.cpp @@ -282,9 +282,8 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } +// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 50} diff --git a/clang/test/OpenMP/irbuilder_simdlen.cpp b/clang/test/OpenMP/irbuilder_simdlen.cpp index 99261faff383d..7a081542cda8b 100644 --- a/clang/test/OpenMP/irbuilder_simdlen.cpp +++ b/clang/test/OpenMP/irbuilder_simdlen.cpp @@ -244,8 +244,7 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp b/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp index 13a1db4ced5ab..44796c9f3f20f 100644 --- a/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp +++ b/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp @@ -244,8 +244,7 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp index 1c6a56239204c..120685011f70b 100644 --- a/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp +++ b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp @@ -14,7 +14,7 @@ void foo() { } #endif -// CHECK: Function Attrs: mustprogress nounwind +// CHECK: Function Attrs: nounwind // CHECK-LABEL: define {{[^@]+}}@_Z3foov // CHECK-SAME: () #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: @@ -52,7 +52,7 @@ void foo() { // CHECK-NEXT: ret void // // -// CHECK-NOINLINE: Function Attrs: mustprogress noinline nounwind +// CHECK-NOINLINE: Function Attrs: noinline nounwind // CHECK-NOINLINE-LABEL: define {{[^@]+}}@_Z3foov // CHECK-NOINLINE-SAME: () #[[ATTR0:[0-9]+]] { // CHECK-NOINLINE-NEXT: entry: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected index dd9e33cf8a381..b04e95944d999 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected @@ -11,7 +11,7 @@ struct ST { struct RT Z; }; -// CHECK: Function Attrs: mustprogress noinline nounwind optnone +// CHECK: Function Attrs: noinline nounwind optnone // CHECK-LABEL: @_Z3fooP2ST( // CHECK-NEXT: entry: // CHECK-NEXT: [[S_ADDR:%.*]] = alloca ptr, align 8 From c7293a08e8679def67789029b9834c4c666dd57b Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 14:57:37 +0200 Subject: [PATCH 03/11] Fix release notes --- clang/docs/ReleaseNotes.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f5906c2dd4eb5..2174e20ee09e6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -122,8 +122,6 @@ C++23 Feature Support materialize temporary object which is a prvalue in discarded-value expression. - Implemented `P1774R8: Portable assumptions `_. -- Implemented `P2809R3: Trivial infinite loops are not Undefined Behavior `_. - C++2c Feature Support ^^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +129,7 @@ C++2c Feature Support - Implemented `P2573R2: = delete("should have a reason"); `_ -- Implemented `P2573R2: = delete("should have a reason"); `_ +- Implemented `P2809R3: Trivial infinite loops are not Undefined Behavior `_. Resolutions to C++ Defect Reports From 2d9290bbe6aa2c05dd82e7be09cd39b8dbcbfee7 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 14:59:15 +0200 Subject: [PATCH 04/11] Address Erich's feedback --- clang/lib/CodeGen/CGStmt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index f37af32f12072..98c124deb9ce2 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -927,7 +927,8 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, !ControllingExpression || (ControllingExpression->EvaluateAsInt(Result, getContext()) && Result.Val.isInt()); - bool IsTrue = CondIsConstInt && + + bool CondIsTrue = CondIsConstInt && (!ControllingExpression || Result.Val.getInt().getBoolValue()); if (getLangOpts().C99 && CondIsConstInt) @@ -943,7 +944,7 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, // [...] // - continue execution of a trivial infinite loop ([stmt.iter.general]). if (getLangOpts().CPlusPlus11) - return !(IsTrivialCXXLoop && IsTrue); + return !(IsTrivialCXXLoop && CondIsTrue); return false; } From 03232873d06bf165554124d8cb5183e30b78f2dd Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 15:19:07 +0200 Subject: [PATCH 05/11] Fix release notes (take 2) --- clang/docs/ReleaseNotes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2174e20ee09e6..e5a2f9649be24 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -122,6 +122,8 @@ C++23 Feature Support materialize temporary object which is a prvalue in discarded-value expression. - Implemented `P1774R8: Portable assumptions `_. +- Implemented `P2448R2: Relaxing some constexpr restrictions `_. + C++2c Feature Support ^^^^^^^^^^^^^^^^^^^^^ From 7d8aa185d01d62205302731f4f018c6116c8f7e4 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 19:29:36 +0200 Subject: [PATCH 06/11] Revert "Remove the mustprogress attributes on functions." This reverts commit 5671ea9763730f67d406c389ace104e17234f562. --- clang/lib/CodeGen/CGStmt.cpp | 9 ++- clang/lib/CodeGen/CodeGenFunction.cpp | 6 ++ clang/lib/CodeGen/CodeGenFunction.h | 18 +++++ clang/test/CXX/special/class.dtor/p3-0x.cpp | 2 +- .../aarch64-sme-attrs.cpp | 14 ++-- .../CodeGen/address-safety-attr-flavors.cpp | 70 +++++++++---------- clang/test/CodeGen/address-safety-attr.cpp | 4 +- .../debug-names-compound-type-units.ll | 4 +- clang/test/CodeGen/fp-floatcontrol-stack.cpp | 40 +++++------ clang/test/CodeGen/sanitize-thread-attr.cpp | 2 +- clang/test/CodeGenCXX/apple-kext.cpp | 4 +- clang/test/CodeGenCXX/attr-mustprogress.cpp | 47 +++++++++++-- .../CodeGenCXX/attr-target-clones-aarch64.cpp | 10 +-- clang/test/CodeGenCXX/attr-target-version.cpp | 22 +++--- .../test/CodeGenCXX/cxx11-exception-spec.cpp | 2 +- clang/test/CodeGenCXX/cxx11-noreturn.cpp | 2 +- clang/test/CodeGenCXX/derived-to-base.cpp | 2 +- clang/test/CodeGenCXX/main-norecurse.cpp | 2 +- .../microsoft-abi-array-cookies.cpp | 2 +- clang/test/CodeGenCXX/no-exceptions.cpp | 4 +- clang/test/CodeGenCXX/noinline-template.cpp | 2 +- .../CodeGenCXX/optnone-and-attributes.cpp | 4 +- clang/test/CodeGenCXX/optnone-def-decl.cpp | 2 +- clang/test/CodeGenCXX/pr58798.cpp | 20 +++--- clang/test/CodeGenCXX/reference-cast.cpp | 4 +- clang/test/CodeGenCXX/threadsafe-statics.cpp | 4 +- clang/test/CodeGenCXX/thunks-ehspec.cpp | 6 +- clang/test/CodeGenCXX/thunks.cpp | 2 +- clang/test/CodeGenCXX/virtual-base-cast.cpp | 2 +- clang/test/CodeGenHIP/default-attributes.hip | 8 +-- .../test/CodeGenObjCXX/lambda-expressions.mm | 4 +- clang/test/CodeGenSYCL/function-attrs.cpp | 2 +- clang/test/Modules/aarch64-sme-keywords.cppm | 2 +- clang/test/OpenMP/amdgcn-attributes.cpp | 18 ++--- clang/test/OpenMP/irbuilder_safelen.cpp | 3 +- .../irbuilder_safelen_order_concurrent.cpp | 3 +- clang/test/OpenMP/irbuilder_simd_aligned.cpp | 5 +- clang/test/OpenMP/irbuilder_simdlen.cpp | 3 +- .../test/OpenMP/irbuilder_simdlen_safelen.cpp | 3 +- .../OpenMP/parallel_if_codegen_PR51349.cpp | 4 +- .../check-attributes.cpp.funcattrs.expected | 2 +- 41 files changed, 221 insertions(+), 148 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 98c124deb9ce2..6aa6117c00635 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -943,8 +943,13 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, // following: // [...] // - continue execution of a trivial infinite loop ([stmt.iter.general]). - if (getLangOpts().CPlusPlus11) - return !(IsTrivialCXXLoop && CondIsTrue); + if (getLangOpts().CPlusPlus11) { + if (IsTrivialCXXLoop && CondIsTrue) { + CurFn->removeFnAttr(llvm::Attribute::MustProgress); + return false; + } + return true; + } return false; } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 76262b6e0d2c8..95c0784ad9760 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1463,6 +1463,12 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, if (Body && isa_and_nonnull(Body)) llvm::append_range(FnArgs, FD->parameters()); + // Ensure that the function adheres to the forward progress guarantee, which + // is required by certain optimizations. + // The attribute will be removed if the body contains a trivial empty loop. + if (checkIfFunctionMustProgress()) + CurFn->addFnAttr(llvm::Attribute::MustProgress); + // Generate the body of the function. PGO.assignRegionCounters(GD, CurFn); if (isa(FD)) diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index f8d160c52f594..f0e8e47bc0e42 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -614,6 +614,24 @@ class CodeGenFunction : public CodeGenTypeCache { // applies to. nullptr if there is no 'musttail' on the current statement. const CallExpr *MustTailCall = nullptr; + /// Returns true if a function must make progress, which means the + /// mustprogress attribute can be added. + bool checkIfFunctionMustProgress() { + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Never) + return false; + + // C++11 and later guarantees that a thread eventually will do one of the + // following (C++11 [intro.multithread]p24 and C++17 [intro.progress]p1): + // - terminate, + // - make a call to a library I/O function, + // - perform an access through a volatile glvalue, or + // - perform a synchronization operation or an atomic operation. + // + // Hence each function is 'mustprogress' in C++11 or later. + return getLangOpts().CPlusPlus11; + } + /// Returns true if a loop must make progress, which means the mustprogress /// attribute can be added. \p HasConstantCond indicates whether the branch /// condition is a known constant. diff --git a/clang/test/CXX/special/class.dtor/p3-0x.cpp b/clang/test/CXX/special/class.dtor/p3-0x.cpp index f6a64260e0df5..857bdca557fdc 100644 --- a/clang/test/CXX/special/class.dtor/p3-0x.cpp +++ b/clang/test/CXX/special/class.dtor/p3-0x.cpp @@ -176,4 +176,4 @@ struct TVC : VX template TVC::~TVC() {} -// CHECK: attributes [[ATTRGRP]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[ATTRGRP]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp b/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp index 8fb3b0cac7bb4..fdd2de11365dd 100644 --- a/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp +++ b/clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp @@ -278,18 +278,18 @@ int test_variadic_template() __arm_inout("za") { preserves_za_decl); } -// CHECK: attributes #[[SM_ENABLED]] = { noinline nounwind "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_ENABLED]] = { mustprogress noinline nounwind "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[NORMAL_DECL]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_ENABLED_DECL]] = { "aarch64_pstate_sm_enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[SM_COMPATIBLE]] = { noinline nounwind "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_COMPATIBLE]] = { mustprogress noinline nounwind "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_COMPATIBLE_DECL]] = { "aarch64_pstate_sm_compatible" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[SM_BODY]] = { noinline nounwind "aarch64_pstate_sm_body" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_SHARED]] = { noinline nounwind "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[SM_BODY]] = { mustprogress noinline nounwind "aarch64_pstate_sm_body" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_SHARED]] = { mustprogress noinline nounwind "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[ZA_SHARED_DECL]] = { "aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_PRESERVED]] = { noinline nounwind "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_PRESERVED]] = { mustprogress noinline nounwind "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[ZA_PRESERVED_DECL]] = { "aarch64_preserves_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[ZA_NEW]] = { noinline nounwind "aarch64_new_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } -// CHECK: attributes #[[NORMAL_DEF]] = { noinline nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[ZA_NEW]] = { mustprogress noinline nounwind "aarch64_new_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } +// CHECK: attributes #[[NORMAL_DEF]] = { mustprogress noinline nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" } // CHECK: attributes #[[SM_ENABLED_CALL]] = { "aarch64_pstate_sm_enabled" } // CHECK: attributes #[[SM_COMPATIBLE_CALL]] = { "aarch64_pstate_sm_compatible" } // CHECK: attributes #[[SM_BODY_CALL]] = { "aarch64_pstate_sm_body" } diff --git a/clang/test/CodeGen/address-safety-attr-flavors.cpp b/clang/test/CodeGen/address-safety-attr-flavors.cpp index f14257e718c09..ef815555059db 100644 --- a/clang/test/CodeGen/address-safety-attr-flavors.cpp +++ b/clang/test/CodeGen/address-safety-attr-flavors.cpp @@ -25,60 +25,60 @@ // RUN: FileCheck -check-prefix=CHECK-KHWASAN %s int HasSanitizeAddress() { return 1; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address -// CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address -// CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress -// CHECK-KHWASAN: Function Attrs: noinline nounwind sanitize_hwaddress +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: Function Attrs: mustprogress noinline nounwind sanitize_address +// CHECK-KASAN: Function Attrs: mustprogress noinline nounwind sanitize_address +// CHECK-HWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress +// CHECK-KHWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} -// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} +// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} -// CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} -// CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} +// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} +// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} __attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() { return 0; } -// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} -// CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} -// CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} +// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} +// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} __attribute__((disable_sanitizer_instrumentation)) int DisableSanitizerInstrumentation() { return 0; } -// CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} -// CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} -// CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} -// CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} -// CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation noinline nounwind$}} +// CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} +// CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} +// CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} +// CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} +// CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp index 7aeda9a80dcd9..bd899ed2f9a74 100644 --- a/clang/test/CodeGen/address-safety-attr.cpp +++ b/clang/test/CodeGen/address-safety-attr.cpp @@ -148,7 +148,7 @@ int global2 = *(int*)((char*)&global1+1); // BLFILE: attributes [[NOATTR]] = { noinline nounwind{{.*}} } // BLFUNC: attributes [[WITH]] = { noinline nounwind sanitize_address{{.*}} } -// BLFUNC: attributes [[NOATTR]] = { noinline nounwind{{.*}} } +// BLFUNC: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } // ASAN: attributes [[WITH]] = { noinline nounwind sanitize_address{{.*}} } -// ASAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} } +// ASAN: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGen/debug-names-compound-type-units.ll b/clang/test/CodeGen/debug-names-compound-type-units.ll index bb9f41b82f061..62cecfdeaf7f9 100644 --- a/clang/test/CodeGen/debug-names-compound-type-units.ll +++ b/clang/test/CodeGen/debug-names-compound-type-units.ll @@ -29,7 +29,7 @@ target triple = "x86_64-unknown-linux-gnu" %struct.Foo2 = type { i8, %struct.Foo } %struct.Foo = type { i8 } -; Function Attrs: noinline nounwind optnone uwtable +; Function Attrs: mustprogress noinline nounwind optnone uwtable define dso_local void @_Z7fooFuncv() #0 !dbg !10 { entry: %global2 = alloca %struct.Foo2, align 1 @@ -40,7 +40,7 @@ entry: ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 -attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } !llvm.dbg.cu = !{!0} diff --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp b/clang/test/CodeGen/fp-floatcontrol-stack.cpp index d8bff72ac1303..090da25d21207 100644 --- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp +++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp @@ -6,10 +6,10 @@ #define FUN(n) \ (float z) { return n * z + n; } -// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} -// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} +// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} float fun_default FUN(1) //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}} #if DEFAULT @@ -32,10 +32,10 @@ float fun_default FUN(1) // Rule: precise must be enabled #pragma float_control(except, on) #endif - // CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} - // CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone strictfp{{$$}} - // CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} - // CHECK-NOHONOR: Function Attrs: noinline nounwind optnone strictfp{{$$}} + // CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} + // CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} + // CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} + // CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} float exc_on FUN(2) //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}} #if DEFAULT @@ -54,10 +54,10 @@ float fun_default FUN(1) #endif #pragma float_control(pop) - // CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} - // CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} - // CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} - // CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} + // CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} + // CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} + // CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} + // CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} float exc_pop FUN(5) //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}} #if DEFAULT @@ -223,10 +223,10 @@ float fun_default FUN(1) #pragma float_control(except, on) #endif float y(); -// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}} -// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone strictfp{{$$}} +// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} class ON { // Settings for top level class initializer use program source setting. float z = 2 + y() * 7; @@ -246,10 +246,10 @@ class ON { }; ON on; #pragma float_control(except, off) -// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}} -// CHECK-NOHONOR: Function Attrs: noinline nounwind optnone{{$$}} +// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}} +// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}} class OFF { float w = 2 + y() * 7; // CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}} diff --git a/clang/test/CodeGen/sanitize-thread-attr.cpp b/clang/test/CodeGen/sanitize-thread-attr.cpp index ef861dfe8e42b..15ae3a16df696 100644 --- a/clang/test/CodeGen/sanitize-thread-attr.cpp +++ b/clang/test/CodeGen/sanitize-thread-attr.cpp @@ -58,5 +58,5 @@ int global2 = *(int*)((char*)&global1+1); // BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} } -// TSAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} } +// TSAN: attributes [[NOATTR]] = { mustprogress noinline nounwind{{.*}} } // TSAN: attributes [[WITH]] = { noinline nounwind sanitize_thread{{.*}} } diff --git a/clang/test/CodeGenCXX/apple-kext.cpp b/clang/test/CodeGenCXX/apple-kext.cpp index d49ef2a0ccfa1..2cba0be7a006a 100644 --- a/clang/test/CodeGenCXX/apple-kext.cpp +++ b/clang/test/CodeGenCXX/apple-kext.cpp @@ -38,5 +38,5 @@ namespace test0 { // CHECK: call void @_ZN5test01AD1Ev(ptr @_ZN5test01aE) // CHECK-NEXT: ret void -// CHECK: attributes #[[ATTR0]] = { alwaysinline nounwind {{.*}} } -// CHECK: attributes #[[ATTR1]] = { noinline nounwind {{.*}} } +// CHECK: attributes #[[ATTR0]] = { alwaysinline mustprogress nounwind {{.*}} } +// CHECK: attributes #[[ATTR1]] = { mustprogress noinline nounwind {{.*}} } diff --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp b/clang/test/CodeGenCXX/attr-mustprogress.cpp index 6179712f28540..5a24e9426d130 100644 --- a/clang/test/CodeGenCXX/attr-mustprogress.cpp +++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp @@ -6,10 +6,10 @@ // Check -ffinite-loops option in combination with various standard versions. // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s -// RUN: %clang_cc1 -std=c++11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s -// RUN: %clang_cc1 -std=c++14 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s -// RUN: %clang_cc1 -std=c++17 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s -// RUN: %clang_cc1 -std=c++20 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s +// RUN: %clang_cc1 -std=c++11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s +// RUN: %clang_cc1 -std=c++14 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s +// RUN: %clang_cc1 -std=c++17 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s +// RUN: %clang_cc1 -std=c++20 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s // Check -fno-finite-loops option in combination with various standard versions. // RUN: %clang_cc1 -std=c++98 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s @@ -23,6 +23,9 @@ int b = 0; // CHECK: datalayout +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f0v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -34,6 +37,9 @@ void f0() { for (; ;) ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -51,6 +57,9 @@ void f1() { ; } +// CXX98-NOT: mustprogress +// CXX11: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2f2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -71,6 +80,9 @@ void f2() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Fv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -101,6 +113,9 @@ void F() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2F2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond @@ -131,6 +146,9 @@ void F2() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2w1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body @@ -144,6 +162,9 @@ void w1() { ; } +// CXX98-NOT: mustprogress +// CXX11: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2w2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.cond @@ -164,6 +185,9 @@ void w2() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Wv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.cond @@ -190,6 +214,9 @@ void W() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2W2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %while.body @@ -205,6 +232,9 @@ void W2() { ; } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2d1v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -223,6 +253,9 @@ void d1() { while (1); } +// CXX98-NOT: mustprogress +// CXX11: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2d2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -244,6 +277,9 @@ void d2() { while (a == b); } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z1Dv( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body @@ -276,6 +312,9 @@ void D() { while (a == b); } +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress // CHECK-LABEL: @_Z2D2v( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body diff --git a/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp b/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp index c15f46cde54bf..7953f902bf09b 100644 --- a/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp +++ b/clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp @@ -230,11 +230,11 @@ void run_foo_tml() { // CHECK-NEXT: ret i32 2 // //. -// CHECK: attributes #[[ATTR0:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } -// CHECK: attributes #[[ATTR1:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ls64" } -// CHECK: attributes #[[ATTR2:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CHECK: attributes #[[ATTR3:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fptoint" } -// CHECK: attributes #[[ATTR4:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } +// CHECK: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } +// CHECK: attributes #[[ATTR1:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ls64" } +// CHECK: attributes #[[ATTR2:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #[[ATTR3:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fptoint" } +// CHECK: attributes #[[ATTR4:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } //. // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} // CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} diff --git a/clang/test/CodeGenCXX/attr-target-version.cpp b/clang/test/CodeGenCXX/attr-target-version.cpp index c9a22372f26f8..8b7273fe3bb51 100644 --- a/clang/test/CodeGenCXX/attr-target-version.cpp +++ b/clang/test/CodeGenCXX/attr-target-version.cpp @@ -312,17 +312,17 @@ int bar() { // CHECK-NEXT: ret ptr @_ZN7MyClass40unused_with_implicit_forward_default_defEv.default // //. -// CHECK: attributes #[[ATTR0:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } -// CHECK: attributes #[[ATTR1:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CHECK: attributes #[[ATTR2:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fp-armv8,+neon,+sm4" } -// CHECK: attributes #[[ATTR3:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+crc" } -// CHECK: attributes #[[ATTR4:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+dotprod,+fp-armv8,+neon" } -// CHECK: attributes #[[ATTR5:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+mops" } -// CHECK: attributes #[[ATTR6:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon" } -// CHECK: attributes #[[ATTR7:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon,+sve" } -// CHECK: attributes #[[ATTR8:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } -// CHECK: attributes #[[ATTR9:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" } -// CHECK: attributes #[[ATTR10:[0-9]+]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm" } +// CHECK: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" } +// CHECK: attributes #[[ATTR1:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #[[ATTR2:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fp-armv8,+neon,+sm4" } +// CHECK: attributes #[[ATTR3:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+crc" } +// CHECK: attributes #[[ATTR4:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+dotprod,+fp-armv8,+neon" } +// CHECK: attributes #[[ATTR5:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+mops" } +// CHECK: attributes #[[ATTR6:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon" } +// CHECK: attributes #[[ATTR7:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon,+sve" } +// CHECK: attributes #[[ATTR8:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon" } +// CHECK: attributes #[[ATTR9:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" } +// CHECK: attributes #[[ATTR10:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm" } // CHECK: attributes #[[ATTR11:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" } //. // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} diff --git a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp index 3991c5170d14f..08de8868b4710 100644 --- a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp +++ b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp @@ -121,7 +121,7 @@ void j() { } // CHECK: attributes [[NONE]] = { {{.*}} } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } // CHECK: attributes [[NUW2]] = { nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/cxx11-noreturn.cpp b/clang/test/CodeGenCXX/cxx11-noreturn.cpp index 58a5a377133a5..feea72ef3f450 100644 --- a/clang/test/CodeGenCXX/cxx11-noreturn.cpp +++ b/clang/test/CodeGenCXX/cxx11-noreturn.cpp @@ -7,4 +7,4 @@ int g(); while (g()) {} } -// CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} } +// CHECK: attributes [[NR]] = { mustprogress noinline noreturn nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/derived-to-base.cpp b/clang/test/CodeGenCXX/derived-to-base.cpp index 8b49d56a68d44..c8dbd5bf5cb05 100644 --- a/clang/test/CodeGenCXX/derived-to-base.cpp +++ b/clang/test/CodeGenCXX/derived-to-base.cpp @@ -46,4 +46,4 @@ namespace test3 { } } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/main-norecurse.cpp b/clang/test/CodeGenCXX/main-norecurse.cpp index a98677ce6f599..3a476e6a119a2 100644 --- a/clang/test/CodeGenCXX/main-norecurse.cpp +++ b/clang/test/CodeGenCXX/main-norecurse.cpp @@ -5,4 +5,4 @@ int main(int argc, char **argv) { return 1; } -// CHECK: attributes #0 = { noinline norecurse{{.*}} } +// CHECK: attributes #0 = { mustprogress noinline norecurse{{.*}} } diff --git a/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp b/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp index d60b4fefbf688..1cc0e9af571c3 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp @@ -62,4 +62,4 @@ struct S { void delete_s(S *s) { delete[] s; } } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/no-exceptions.cpp b/clang/test/CodeGenCXX/no-exceptions.cpp index c951b685a8a1b..47f491e50e8f1 100644 --- a/clang/test/CodeGenCXX/no-exceptions.cpp +++ b/clang/test/CodeGenCXX/no-exceptions.cpp @@ -3,7 +3,7 @@ void g(); // CHECK: define{{.*}} void @_Z1fv() [[NUW:#[0-9]+]] -void f() throw (int) { +void f() throw (int) { // CHECK-NOT: invoke void @_Z1gv g(); @@ -11,4 +11,4 @@ void f() throw (int) { // CHECK: ret void } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/noinline-template.cpp b/clang/test/CodeGenCXX/noinline-template.cpp index 507ca3f34af51..cb81f72d0714f 100644 --- a/clang/test/CodeGenCXX/noinline-template.cpp +++ b/clang/test/CodeGenCXX/noinline-template.cpp @@ -15,4 +15,4 @@ void foo() { strs.growStorageBy(); } -// CHECK: attributes [[NI]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NI]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/optnone-and-attributes.cpp b/clang/test/CodeGenCXX/optnone-and-attributes.cpp index 870d5e9496f04..68aa0988b18b5 100644 --- a/clang/test/CodeGenCXX/optnone-and-attributes.cpp +++ b/clang/test/CodeGenCXX/optnone-and-attributes.cpp @@ -75,8 +75,8 @@ int exported_optnone_func(int a) { // CHECK: declare dllimport {{.*}} @_Z21imported_optnone_funci({{.*}}) [[DLLIMPORT:#[0-9]+]] -// CHECK: attributes [[OPTNONE]] = { noinline {{.*}} optnone -// CHECK: attributes [[NORETURN]] = { noinline noreturn {{.*}} optnone +// CHECK: attributes [[OPTNONE]] = { mustprogress noinline {{.*}} optnone +// CHECK: attributes [[NORETURN]] = { mustprogress noinline noreturn {{.*}} optnone // CHECK: attributes [[DLLIMPORT]] = // CHECK-NOT: optnone diff --git a/clang/test/CodeGenCXX/optnone-def-decl.cpp b/clang/test/CodeGenCXX/optnone-def-decl.cpp index 6e4e510b9bf6e..9e7d295ea31d4 100644 --- a/clang/test/CodeGenCXX/optnone-def-decl.cpp +++ b/clang/test/CodeGenCXX/optnone-def-decl.cpp @@ -89,7 +89,7 @@ int user_of_forceinline_optnone_function() { // CHECK: @_Z36user_of_forceinline_optnone_functionv() [[NORMAL]] // CHECK: @_Z28forceinline_optnone_functionii({{.*}}) [[OPTNONE]] -// CHECK: attributes [[OPTNONE]] = { noinline nounwind optnone {{.*}} } +// CHECK: attributes [[OPTNONE]] = { mustprogress noinline nounwind optnone {{.*}} } // CHECK: attributes [[NORMAL]] = // CHECK-NOT: noinline // CHECK-NOT: optnone diff --git a/clang/test/CodeGenCXX/pr58798.cpp b/clang/test/CodeGenCXX/pr58798.cpp index ced8823e571e7..607b36aa7f69a 100644 --- a/clang/test/CodeGenCXX/pr58798.cpp +++ b/clang/test/CodeGenCXX/pr58798.cpp @@ -1,7 +1,7 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions | FileCheck %s -// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z54early_caller_of_callee_with_clang_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: @@ -12,7 +12,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z22callee_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -30,7 +30,7 @@ // CHECK-NEXT: ret i32 24 // -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_clang_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1:[0-9]+]] { // CHECK-NEXT: entry: @@ -41,7 +41,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_cxx_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -52,7 +52,7 @@ // CHECK-NEXT: ret i32 [[CALL]] // -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z20callee_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] personality ptr @__gxx_personality_v0 { // CHECK-NEXT: entry: @@ -78,7 +78,7 @@ // CHECK-NEXT: unreachable // -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z50early_caller_of_callee_with_cxx_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: @@ -129,7 +129,7 @@ int callee_with_cxx_attr(int a) noexcept { // Calls to definitions: -// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z53late_caller_of_callee_with_clang_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -143,7 +143,7 @@ __attribute__((pure)) int late_caller_of_callee_with_clang_attr_with_clang_attr( return callee_with_clang_attr(a); } -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_clang_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: @@ -157,7 +157,7 @@ int late_caller_of_callee_with_clang_attr_with_cxx_attr(int a) noexcept { return callee_with_clang_attr(a); } -// CHECK: Function Attrs: noinline nounwind optnone willreturn memory(read) +// CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read) // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_cxx_attr_with_clang_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] { // CHECK-NEXT: entry: @@ -171,7 +171,7 @@ __attribute__((pure)) int late_caller_of_callee_with_cxx_attr_with_clang_attr(in return callee_with_cxx_attr(a); } -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: define {{[^@]+}}@_Z49late_caller_of_callee_with_cxx_attr_with_cxx_attri // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] { // CHECK-NEXT: entry: diff --git a/clang/test/CodeGenCXX/reference-cast.cpp b/clang/test/CodeGenCXX/reference-cast.cpp index 5cb0901c4b9cc..e7b07365974d6 100644 --- a/clang/test/CodeGenCXX/reference-cast.cpp +++ b/clang/test/CodeGenCXX/reference-cast.cpp @@ -15,7 +15,7 @@ const int &lvalue_noop_cast() { return 17; } -// CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z20lvalue_integral_castv() +// CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z20lvalue_integral_castv() const short &lvalue_integral_cast() { if (i == 0) // CHECK: store i16 17, ptr @@ -193,4 +193,4 @@ namespace PR10650 { // CHECK: store i64 } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/threadsafe-statics.cpp b/clang/test/CodeGenCXX/threadsafe-statics.cpp index 443fbecc3d260..4c53482d4c4c9 100644 --- a/clang/test/CodeGenCXX/threadsafe-statics.cpp +++ b/clang/test/CodeGenCXX/threadsafe-statics.cpp @@ -22,6 +22,6 @@ void g() { // NO-TSS-NOT: call void @__cxa_guard_release // NO-TSS: ret void -// WITH-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} } +// WITH-TSS: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } -// NO-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} } +// NO-TSS: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenCXX/thunks-ehspec.cpp b/clang/test/CodeGenCXX/thunks-ehspec.cpp index 813d9a6272447..4c95a47111408 100644 --- a/clang/test/CodeGenCXX/thunks-ehspec.cpp +++ b/clang/test/CodeGenCXX/thunks-ehspec.cpp @@ -17,13 +17,13 @@ class C : A, B { }; void C::primary_key() {} -// CHECK-LABEL: define available_externally void @_ZThn8_N1C9secondaryEv(ptr noundef %this) {{.*}} #0 +// CHECK-LABEL: define available_externally void @_ZThn8_N1C9secondaryEv(ptr noundef %this) {{.*}} #2 // CHECK-NOT: invoke // CHECK: tail call void @_ZN1C9secondaryEv(ptr {{[^,]*}} %{{.*}}) // CHECK-NOT: invoke // CHECK: ret void -// CHECK-LABEL: define available_externally void @_ZThn8_N1C16secondary_varargEiz(ptr noundef %this, i32 noundef %0, ...) {{.*}} #0 +// CHECK-LABEL: define available_externally void @_ZThn8_N1C16secondary_varargEiz(ptr noundef %this, i32 noundef %0, ...) {{.*}} #2 // CHECK-NOT: invoke -// CHECK: musttail call void (ptr, i32, ...) @_ZN1C16secondary_varargEiz(ptr {{[^,]*}} %{{.*}}, i32 noundef %{{.*}}, ...) #2 +// CHECK: musttail call void (ptr, i32, ...) @_ZN1C16secondary_varargEiz(ptr {{[^,]*}} %{{.*}}, i32 noundef %{{.*}}, ...) #3 // CHECK-NEXT: ret void diff --git a/clang/test/CodeGenCXX/thunks.cpp b/clang/test/CodeGenCXX/thunks.cpp index 394dc8d766515..f1ceebf24ba18 100644 --- a/clang/test/CodeGenCXX/thunks.cpp +++ b/clang/test/CodeGenCXX/thunks.cpp @@ -529,7 +529,7 @@ C c; // CHECK-NONOPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv // Checking with opt -// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(ptr noundef %this) unnamed_addr #0 align 2 +// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(ptr noundef %this) unnamed_addr #1 align 2 // This is from Test5: // CHECK-OPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv diff --git a/clang/test/CodeGenCXX/virtual-base-cast.cpp b/clang/test/CodeGenCXX/virtual-base-cast.cpp index a6b4672eddc83..57388431e9007 100644 --- a/clang/test/CodeGenCXX/virtual-base-cast.cpp +++ b/clang/test/CodeGenCXX/virtual-base-cast.cpp @@ -75,4 +75,4 @@ BB* d() { return y; } // MSVC: add nsw i32 4, %[[offset]] // MSVC: } -// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenHIP/default-attributes.hip b/clang/test/CodeGenHIP/default-attributes.hip index e1e1f4417fa43..63572bfd242b9 100644 --- a/clang/test/CodeGenHIP/default-attributes.hip +++ b/clang/test/CodeGenHIP/default-attributes.hip @@ -8,7 +8,7 @@ #define __device__ __attribute__((device)) #define __global__ __attribute__((global)) -// OPTNONE: Function Attrs: convergent noinline nounwind optnone +// OPTNONE: Function Attrs: convergent mustprogress noinline nounwind optnone // OPTNONE-LABEL: define {{[^@]+}}@_Z4funcv // OPTNONE-SAME: () #[[ATTR0:[0-9]+]] { // OPTNONE-NEXT: entry: @@ -24,7 +24,7 @@ __device__ void func() { } -// OPTNONE: Function Attrs: convergent noinline norecurse nounwind optnone +// OPTNONE: Function Attrs: convergent mustprogress noinline norecurse nounwind optnone // OPTNONE-LABEL: define {{[^@]+}}@_Z6kernelv // OPTNONE-SAME: () #[[ATTR1:[0-9]+]] { // OPTNONE-NEXT: entry: @@ -40,8 +40,8 @@ __global__ void kernel() { } //. -// OPTNONE: attributes #0 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// OPTNONE: attributes #1 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// OPTNONE: attributes #0 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// OPTNONE: attributes #1 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } //. // OPT: attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" } // OPT: attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm index 1afbde04ab0fa..e1fb6ec709b72 100644 --- a/clang/test/CodeGenObjCXX/lambda-expressions.mm +++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm @@ -163,5 +163,5 @@ void test() { #endif -// ARC: attributes [[NUW]] = { noinline nounwind{{.*}} } -// MRC: attributes [[NUW]] = { noinline nounwind{{.*}} } +// ARC: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } +// MRC: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} } diff --git a/clang/test/CodeGenSYCL/function-attrs.cpp b/clang/test/CodeGenSYCL/function-attrs.cpp index 21bef5b4a961d..1606f961f2d39 100644 --- a/clang/test/CodeGenSYCL/function-attrs.cpp +++ b/clang/test/CodeGenSYCL/function-attrs.cpp @@ -49,7 +49,7 @@ int main() { return 0; } //. -// CHECK: attributes #0 = { convergent noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CHECK: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } // CHECK: attributes #1 = { convergent nounwind } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} diff --git a/clang/test/Modules/aarch64-sme-keywords.cppm b/clang/test/Modules/aarch64-sme-keywords.cppm index 4852d7e10d602..759701a633ceb 100644 --- a/clang/test/Modules/aarch64-sme-keywords.cppm +++ b/clang/test/Modules/aarch64-sme-keywords.cppm @@ -31,7 +31,7 @@ import A; // // CHECK:declare void @_ZW1A14f_preserves_zav() #[[PRESERVES_ZA_DECL:[0-9]+]] // -// CHECK:; Function Attrs: noinline nounwind optnone +// CHECK:; Function Attrs: mustprogress noinline nounwind optnone // CHECK:define dso_local void @_Z21f_nonstreaming_callerv() #[[NORMAL_DEF:[0-9]+]] { // CHECK:entry: // CHECK: call void @_ZW1A11f_streamingv() #[[STREAMING_USE:[0-9]+]] diff --git a/clang/test/OpenMP/amdgcn-attributes.cpp b/clang/test/OpenMP/amdgcn-attributes.cpp index fd6497919e3b7..5ddc34537d12f 100644 --- a/clang/test/OpenMP/amdgcn-attributes.cpp +++ b/clang/test/OpenMP/amdgcn-attributes.cpp @@ -32,12 +32,12 @@ int callable(int x) { return x + 1; } -// DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } -// CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" } -// NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } -// UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } - -// DEFAULT: attributes #2 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CPU: attributes #2 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" } -// NOIEEE: attributes #2 = { convergent noinline nounwind optnone "amdgpu-ieee"="false" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// UNSAFEATOMIC: attributes #2 = { convergent noinline nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// DEFAULT: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// CPU: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" } +// NOIEEE: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } +// UNSAFEATOMIC: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,42" "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="42" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" } + +// DEFAULT: attributes #2 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// CPU: attributes #2 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" } +// NOIEEE: attributes #2 = { convergent mustprogress noinline nounwind optnone "amdgpu-ieee"="false" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +// UNSAFEATOMIC: attributes #2 = { convergent mustprogress noinline nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } diff --git a/clang/test/OpenMP/irbuilder_safelen.cpp b/clang/test/OpenMP/irbuilder_safelen.cpp index 84a7d9fe2aeed..4ce9e3918957a 100644 --- a/clang/test/OpenMP/irbuilder_safelen.cpp +++ b/clang/test/OpenMP/irbuilder_safelen.cpp @@ -244,7 +244,8 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp b/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp index 5d3c8f240963d..f82a7b229356c 100644 --- a/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp +++ b/clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp @@ -244,7 +244,8 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 50} diff --git a/clang/test/OpenMP/irbuilder_simd_aligned.cpp b/clang/test/OpenMP/irbuilder_simd_aligned.cpp index fa35946de3b47..db8f19cd56b14 100644 --- a/clang/test/OpenMP/irbuilder_simd_aligned.cpp +++ b/clang/test/OpenMP/irbuilder_simd_aligned.cpp @@ -282,8 +282,9 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } -// CHECK: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } +// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 50} diff --git a/clang/test/OpenMP/irbuilder_simdlen.cpp b/clang/test/OpenMP/irbuilder_simdlen.cpp index 7a081542cda8b..99261faff383d 100644 --- a/clang/test/OpenMP/irbuilder_simdlen.cpp +++ b/clang/test/OpenMP/irbuilder_simdlen.cpp @@ -244,7 +244,8 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp b/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp index 44796c9f3f20f..13a1db4ced5ab 100644 --- a/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp +++ b/clang/test/OpenMP/irbuilder_simdlen_safelen.cpp @@ -244,7 +244,8 @@ void simple(float *a, float *b, int *c) { // CHECK-NEXT: ret void // //. -// CHECK: attributes #0 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } +// CHECK: attributes #1 = { noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } //. // CHECK: !0 = !{i32 1, !"wchar_size", i32 4} // CHECK: !1 = !{i32 7, !"openmp", i32 45} diff --git a/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp index 120685011f70b..1c6a56239204c 100644 --- a/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp +++ b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp @@ -14,7 +14,7 @@ void foo() { } #endif -// CHECK: Function Attrs: nounwind +// CHECK: Function Attrs: mustprogress nounwind // CHECK-LABEL: define {{[^@]+}}@_Z3foov // CHECK-SAME: () #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: @@ -52,7 +52,7 @@ void foo() { // CHECK-NEXT: ret void // // -// CHECK-NOINLINE: Function Attrs: noinline nounwind +// CHECK-NOINLINE: Function Attrs: mustprogress noinline nounwind // CHECK-NOINLINE-LABEL: define {{[^@]+}}@_Z3foov // CHECK-NOINLINE-SAME: () #[[ATTR0:[0-9]+]] { // CHECK-NOINLINE-NEXT: entry: diff --git a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected index b04e95944d999..dd9e33cf8a381 100644 --- a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected @@ -11,7 +11,7 @@ struct ST { struct RT Z; }; -// CHECK: Function Attrs: noinline nounwind optnone +// CHECK: Function Attrs: mustprogress noinline nounwind optnone // CHECK-LABEL: @_Z3fooP2ST( // CHECK-NEXT: entry: // CHECK-NEXT: [[S_ADDR:%.*]] = alloca ptr, align 8 From 9e656a86946ddbbadb09e8e20e2a0b2426bb6db3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 29 Apr 2024 22:12:34 +0200 Subject: [PATCH 07/11] Fix tests and Address Shafik's comments --- clang/lib/CodeGen/CGStmt.cpp | 7 +- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- clang/test/CodeGenCXX/attr-mustprogress.cpp | 81 ++++++++++++++++++--- 3 files changed, 76 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 6aa6117c00635..a3c66e433b37b 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -910,13 +910,13 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, bool IsTrivialCXXLoop) { - if (CGM.getCodeGenOpts().getFiniteLoops() == - CodeGenOptions::FiniteLoopsKind::Always) - return true; if (CGM.getCodeGenOpts().getFiniteLoops() == CodeGenOptions::FiniteLoopsKind::Never) return false; + if(CGM.getCodeGenOpts().getFiniteLoops() == CodeGenOptions::FiniteLoopsKind::Always + && !getLangOpts().CPlusPlus11) + return true; // Now apply rules for plain C (see 6.8.5.6 in C11). // Loops with constant conditions do not have to make progress in any C // version. @@ -950,7 +950,6 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, } return true; } - return false; } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 95c0784ad9760..6e50d37391983 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1465,7 +1465,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Ensure that the function adheres to the forward progress guarantee, which // is required by certain optimizations. - // The attribute will be removed if the body contains a trivial empty loop. + // In C++11 and up, the attribute will be removed if the body contains a trivial empty loop. if (checkIfFunctionMustProgress()) CurFn->addFnAttr(llvm::Attribute::MustProgress); diff --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp b/clang/test/CodeGenCXX/attr-mustprogress.cpp index 5a24e9426d130..3706415fd3a89 100644 --- a/clang/test/CodeGenCXX/attr-mustprogress.cpp +++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp @@ -222,7 +222,7 @@ void W() { // CHECK-NEXT: br label %while.body // CHECK: while.body: // CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NOT: br label %while.body, !llvm.loop [[LOOP12:!.*]] +// CXX11-NOT: br {{.*}}, !llvm.loop // FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]] // void W2() { @@ -347,12 +347,75 @@ void D2() { while (1); } -// CXX11: [[LOOP1:.*]] = distinct !{[[LOOP1]], [[MP:.*]]} +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress +// CHECK-LABEL: @_Z9compound0v( +// CHECK-NEXT: entry: +// CHECK-NEXT: br label %for.cond +// CHECK: for.cond: +// CXX98-NOT: br {{.*}} llvm.loop +// CXX11-NOT: br {{.*}} llvm.loop +// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP19:!.*]] +void compound0() { + for (; ;) {} +} + +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress +// CHECK-LABEL: @_Z9compound1v( +// CHECK-NEXT: entry: +// CHECK-NEXT: br label %for.cond +// CHECK: for.cond: +// CXX98-NOT: br {{.*}} llvm.loop +// CXX11-NOT: br {{.*}} llvm.loop +// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP20:!.*]] +void compound1() { + for (; ;) {/*! */} +} + +// CXX98-NOT: mustprogress +// CXX11-NOT: mustprogress +// FINITE-NOT: mustprogress +// CHECK-LABEL: @_Z9compound2v( +// CHECK-NEXT: entry: +// CHECK-NEXT: br label %do.body +// CHECK: do.body: +// CHECK-NEXT: br label %do.cond +// CHECK: do.cond: +// CXX98-NOT: br {{.*}}, !llvm.loop +// CXX11-NOT: br {{.*}}, !llvm.loop +// FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP21:!.*]] +// CHECK: do.end: +// CHECK-NEXT: ret void +// +void compound2() { + do {} while (1+1); +} + +// CXX98-NOT: mustprogress +// CXX11 : mustprogress +// FINITE-NOT: mustprogress +// CHECK-LABEL: @_Z5Falsev( +// CHECK-NEXT: entry: +// CHECK-NEXT: br label %do.body +// CHECK: do.body: +// CHECK-NEXT: br label %do.end +// CHECK: do.end: +// CHECK-NEXT: ret void +// +void False() { + do {} while (1-1); +} + + +// CXX11: [[LOOP3]] = distinct !{[[LOOP3]], [[MP:.*]]} // CXX11: [[MP]] = !{!"llvm.loop.mustprogress"} -// CXX11: [[LOOP2:.*]] = distinct !{[[LOOP2]], [[MP]]} -// CXX11: [[LOOP3:.*]] = distinct !{[[LOOP3]], [[MP]]} -// CXX11: [[LOOP4:.*]] = distinct !{[[LOOP4]], [[MP]]} -// CXX11: [[LOOP5:.*]] = distinct !{[[LOOP5]], [[MP]]} -// CXX11: [[LOOP6:.*]] = distinct !{[[LOOP6]], [[MP]]} -// CXX11: [[LOOP7:.*]] = distinct !{[[LOOP7]], [[MP]]} -// CXX11: [[LOOP8:.*]] = distinct !{[[LOOP8]], [[MP]]} +// CXX11: [[LOOP5]] = distinct !{[[LOOP5]], [[MP]]} +// CXX11: [[LOOP6]] = distinct !{[[LOOP6]], [[MP]]} +// CXX11: [[LOOP9]] = distinct !{[[LOOP9]], [[MP]]} +// CXX11: [[LOOP10]] = distinct !{[[LOOP10]], [[MP]]} +// CXX11: [[LOOP14]] = distinct !{[[LOOP14]], [[MP]]} +// CXX11: [[LOOP16]] = distinct !{[[LOOP16]], [[MP]]} +// CXX11: [[LOOP17]] = distinct !{[[LOOP17]], [[MP]]} From b99e8b2408241da23f2d4aafb5b600609f4596fc Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Tue, 30 Apr 2024 15:36:08 +0200 Subject: [PATCH 08/11] Format --- clang/lib/CodeGen/CGStmt.cpp | 5 +++-- clang/lib/CodeGen/CodeGenFunction.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index a3c66e433b37b..f06a7e9a91a14 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -914,8 +914,9 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, CodeGenOptions::FiniteLoopsKind::Never) return false; - if(CGM.getCodeGenOpts().getFiniteLoops() == CodeGenOptions::FiniteLoopsKind::Always - && !getLangOpts().CPlusPlus11) + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Always && + !getLangOpts().CPlusPlus11) return true; // Now apply rules for plain C (see 6.8.5.6 in C11). // Loops with constant conditions do not have to make progress in any C diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 3196d059060ea..546beae4af59e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1471,7 +1471,8 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Ensure that the function adheres to the forward progress guarantee, which // is required by certain optimizations. - // In C++11 and up, the attribute will be removed if the body contains a trivial empty loop. + // In C++11 and up, the attribute will be removed if the body contains a + // trivial empty loop. if (checkIfFunctionMustProgress()) CurFn->addFnAttr(llvm::Attribute::MustProgress); From 6b43d8c4ac62fd6ece436b8cb7910eddcffbd301 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Tue, 30 Apr 2024 15:46:49 +0200 Subject: [PATCH 09/11] Format again --- clang/lib/CodeGen/CGStmt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index f06a7e9a91a14..3a86ae0a1f978 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -929,8 +929,8 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, (ControllingExpression->EvaluateAsInt(Result, getContext()) && Result.Val.isInt()); - bool CondIsTrue = CondIsConstInt && - (!ControllingExpression || Result.Val.getInt().getBoolValue()); + bool CondIsTrue = CondIsConstInt && (!ControllingExpression || + Result.Val.getInt().getBoolValue()); if (getLangOpts().C99 && CondIsConstInt) return false; From 2acda986f9bd8943b43914227e30ca3a47eba02c Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 1 May 2024 11:58:54 +0200 Subject: [PATCH 10/11] Trivial infinite loops are considered infinite, even in the presence of -ffinite-loops --- clang/docs/ReleaseNotes.rst | 4 +++ clang/include/clang/Driver/Options.td | 2 +- clang/lib/CodeGen/CGStmt.cpp | 12 +++---- clang/lib/CodeGen/CodeGenFunction.h | 2 +- clang/test/CodeGen/attr-mustprogress.c | 12 +++---- clang/test/CodeGenCXX/attr-mustprogress.cpp | 40 ++++++++++----------- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index dc4ef715b909b..ea1abb71fd4b7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -297,6 +297,10 @@ Modified Compiler Flags - Carved out ``-Wformat`` warning about scoped enums into a subwarning and make it controlled by ``-Wformat-pedantic``. Fixes #GH88595. +- Trivial infinite loops (i.e loops with a constant controlling expresion + evaluating to ``true`` and an empty body such as ``while(1);``) + are considered infinite, even when the ``-ffinite-loop`` flag is set. + Removed Compiler Flags ------------------------- diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 864da4e1157f7..70247b337815b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3971,7 +3971,7 @@ def funroll_loops : Flag<["-"], "funroll-loops">, Group, def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, HelpText<"Turn off loop unroller">, Visibility<[ClangOption, CC1Option]>; def ffinite_loops: Flag<["-"], "ffinite-loops">, Group, - HelpText<"Assume all loops are finite.">, Visibility<[ClangOption, CC1Option]>; + HelpText<"Assume all non-trivial loops are finite.">, Visibility<[ClangOption, CC1Option]>; def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group, HelpText<"Do not assume that any loop is finite.">, Visibility<[ClangOption, CC1Option]>; diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 3a86ae0a1f978..dbedd69ba6bc7 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -909,15 +909,11 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { } bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, - bool IsTrivialCXXLoop) { + bool HasEmptyBody) { if (CGM.getCodeGenOpts().getFiniteLoops() == CodeGenOptions::FiniteLoopsKind::Never) return false; - if (CGM.getCodeGenOpts().getFiniteLoops() == - CodeGenOptions::FiniteLoopsKind::Always && - !getLangOpts().CPlusPlus11) - return true; // Now apply rules for plain C (see 6.8.5.6 in C11). // Loops with constant conditions do not have to make progress in any C // version. @@ -944,8 +940,10 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, // following: // [...] // - continue execution of a trivial infinite loop ([stmt.iter.general]). - if (getLangOpts().CPlusPlus11) { - if (IsTrivialCXXLoop && CondIsTrue) { + if (CGM.getCodeGenOpts().getFiniteLoops() == + CodeGenOptions::FiniteLoopsKind::Always || + getLangOpts().CPlusPlus11) { + if (HasEmptyBody && CondIsTrue) { CurFn->removeFnAttr(llvm::Attribute::MustProgress); return false; } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 6ecf47ffc4428..01ef034e52339 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -636,7 +636,7 @@ class CodeGenFunction : public CodeGenTypeCache { /// Returns true if a loop must make progress, which means the mustprogress /// attribute can be added. \p HasConstantCond indicates whether the branch /// condition is a known constant. - bool checkIfLoopMustProgress(const Expr *, bool IsTrivialCXXLoop); + bool checkIfLoopMustProgress(const Expr *, bool HasEmptyBody); const CodeGen::CGBlockInfo *BlockInfo = nullptr; llvm::Value *BlockPointer = nullptr; diff --git a/clang/test/CodeGen/attr-mustprogress.c b/clang/test/CodeGen/attr-mustprogress.c index b4f8710a9d692..a5e8dc5cd5d5e 100644 --- a/clang/test/CodeGen/attr-mustprogress.c +++ b/clang/test/CodeGen/attr-mustprogress.c @@ -30,7 +30,7 @@ int b = 0; // CHECK: for.cond: // C99-NOT: br {{.*}}!llvm.loop // C11-NOT: br {{.*}}!llvm.loop -// FINITE-NEXT: br {{.*}}!llvm.loop +// FINITE-NOR: br {{.*}}!llvm.loop // void f0(void) { for (; ;) ; @@ -45,7 +45,7 @@ void f0(void) { // CHECK: for.body: // C99-NOT: br {{.*}}, !llvm.loop // C11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: for.end: // CHECK-NEXT: ret void // @@ -84,7 +84,7 @@ void f2(void) { // CHECK: for.body: // C99-NOT: br {{.*}}, !llvm.loop // C11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: for.end: // CHECK-NEXT: br label %for.cond1 // CHECK: for.cond1: @@ -113,7 +113,7 @@ void F(void) { // CHECK: while.body: // C99-NOT: br {{.*}}, !llvm.loop // C11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop // void w1(void) { while (1) { @@ -159,7 +159,7 @@ void w2(void) { // CHECK: while.body2: // C99-NOT: br {{.*}} !llvm.loop // C11-NOT: br {{.*}} !llvm.loop -// FINITE-NEXT: br {{.*}} !llvm.loop +// FINITE-NOT: br {{.*}} !llvm.loop // void W(void) { while (a == b) { @@ -177,7 +177,7 @@ void W(void) { // CHECK: do.cond: // C99-NOT: br {{.*}}, !llvm.loop // C11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: do.end: // CHECK-NEXT: ret void // diff --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp b/clang/test/CodeGenCXX/attr-mustprogress.cpp index 3706415fd3a89..0cb18df25223e 100644 --- a/clang/test/CodeGenCXX/attr-mustprogress.cpp +++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp @@ -32,7 +32,7 @@ int b = 0; // CHECK: for.cond: // CXX98-NOT: br {{.*}} llvm.loop // CXX11-NOT: br {{.*}} llvm.loop -// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP1:!.*]] +// FINITE-NOT: br {{.*}} llvm.loop void f0() { for (; ;) ; } @@ -48,7 +48,7 @@ void f0() { // CHECK: for.body: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}} llvm.loop -// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP2:!.*]] +// FINITE-NOT: br {{.*}} llvm.loop // CHECK: for.end: // CHECK-NEXT: ret void // @@ -91,7 +91,7 @@ void f2() { // CHECK: for.body: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP4:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: for.end: // CHECK-NEXT: br label %for.cond1 // CHECK: for.cond1: @@ -135,7 +135,7 @@ void F() { // CHECK: for.body2: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br label %for.cond1, !llvm.loop [[LOOP7:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: for.end3: // CHECK-NEXT: ret void // @@ -155,7 +155,7 @@ void F2() { // CHECK: while.body: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP8:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // void w1() { while (1) @@ -205,7 +205,7 @@ void w2() { // CHECK: while.body2: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br label %while.body2, !llvm.loop [[LOOP11:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // void W() { while (a == b) @@ -223,7 +223,7 @@ void W() { // CHECK: while.body: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // void W2() { while (1) @@ -243,7 +243,7 @@ void W2() { // CHECK: do.cond: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP13:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: do.end: // CHECK-NEXT: ret void // @@ -288,7 +288,7 @@ void d2() { // CHECK: do.cond: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP15:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: do.end: // CHECK-NEXT: br label %do.body1 // CHECK: do.body1: @@ -334,7 +334,7 @@ void D() { // CHECK: do.cond2: // CXX98-NOT: br {{.*}}, !llvm.loop // CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br i1 true, label %do.body1, label %do.end3, !llvm.loop [[LOOP18:!.*]] +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: do.end3: // CHECK-NEXT: ret void // @@ -354,9 +354,9 @@ void D2() { // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond // CHECK: for.cond: -// CXX98-NOT: br {{.*}} llvm.loop -// CXX11-NOT: br {{.*}} llvm.loop -// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP19:!.*]] +// CXX98-NOT: br {{.*}}, !llvm.loop +// CXX11-NOT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop void compound0() { for (; ;) {} } @@ -368,9 +368,9 @@ void compound0() { // CHECK-NEXT: entry: // CHECK-NEXT: br label %for.cond // CHECK: for.cond: -// CXX98-NOT: br {{.*}} llvm.loop -// CXX11-NOT: br {{.*}} llvm.loop -// FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP20:!.*]] +// CXX98-NOT: br {{.*}}, llvm.loop +// CXX11-NOT: br {{.*}}, llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop void compound1() { for (; ;) {/*! */} } @@ -384,9 +384,9 @@ void compound1() { // CHECK: do.body: // CHECK-NEXT: br label %do.cond // CHECK: do.cond: -// CXX98-NOT: br {{.*}}, !llvm.loop -// CXX11-NOT: br {{.*}}, !llvm.loop -// FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP21:!.*]] +// CXX98-NOT: br {{.*}}, !llvm.loop +// CXX11-NOT: br {{.*}}, !llvm.loop +// FINITE-NOT: br {{.*}}, !llvm.loop // CHECK: do.end: // CHECK-NEXT: ret void // @@ -396,7 +396,7 @@ void compound2() { // CXX98-NOT: mustprogress // CXX11 : mustprogress -// FINITE-NOT: mustprogress +// FINITE : mustprogress // CHECK-LABEL: @_Z5Falsev( // CHECK-NEXT: entry: // CHECK-NEXT: br label %do.body From aa5f785b24219585f955a97de8eafc4876023ba4 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Thu, 2 May 2024 22:07:21 +0200 Subject: [PATCH 11/11] Remove useless C99 check --- clang/lib/CodeGen/CGStmt.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index dbedd69ba6bc7..479945e3b4cb5 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -928,11 +928,8 @@ bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, bool CondIsTrue = CondIsConstInt && (!ControllingExpression || Result.Val.getInt().getBoolValue()); - if (getLangOpts().C99 && CondIsConstInt) - return false; - // Loops with non-constant conditions must make progress in C11 and later. - if (getLangOpts().C11) + if (getLangOpts().C11 && !CondIsConstInt) return true; // [C++26][intro.progress] (DR)