From 6c3129549374c0e81e28fd0a21e96f8087b63a78 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 30 Apr 2021 14:13:47 +0100 Subject: [clang] Refactor mustprogress handling, add it to all loops in c++11+. Currently Clang does not add mustprogress to inifinite loops with a known constant condition, matching C11 behavior. The forward progress guarantee in C++11 and later should allow us to add mustprogress to any loop (http://eel.is/c++draft/intro.progress#1). This allows us to simplify the code dealing with adding mustprogress a bit. Reviewed By: aaron.ballman, lebedev.ri Differential Revision: https://reviews.llvm.org/D96418 --- clang/lib/CodeGen/CodeGenFunction.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 09d49c9..d1937fd 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1186,9 +1186,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, void CodeGenFunction::EmitFunctionBody(const Stmt *Body) { incrementProfileCounter(Body); - if (CPlusPlusWithProgress()) - FnIsMustProgress = true; - if (const CompoundStmt *S = dyn_cast(Body)) EmitCompoundStmtWithoutScope(*S); else @@ -1196,7 +1193,7 @@ void CodeGenFunction::EmitFunctionBody(const Stmt *Body) { // This is checked after emitting the function body so we know if there // are any permitted infinite loops. - if (FnIsMustProgress) + if (checkIfFunctionMustProgress()) CurFn->addFnAttr(llvm::Attribute::MustProgress); } -- cgit v1.1