https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/100162
[4.5:75:19], [5.0:114:3], [5.1:137:21], [5.2:235:30] "No exception can be raised in the **simd** region." >From 8e99d0743c69f3e5981deb24f501ea993567522e Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek <krzysztof.parzys...@amd.com> Date: Tue, 23 Jul 2024 09:56:53 -0500 Subject: [PATCH] [clang][OpenMP] Mark all SIMD regions as non-throwing [4.5:75:19], [5.0:114:3], [5.1:137:21], [5.2:235:30] "No exception can be raised in the simd region." --- clang/lib/Sema/SemaOpenMP.cpp | 39 ++++++++++++------- clang/test/AST/ast-dump-openmp-for-simd.c | 10 ++--- clang/test/AST/ast-dump-openmp-simd.c | 10 ++--- .../test/AST/ast-dump-openmp-taskloop-simd.c | 10 ++--- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7dadb5cd31a69..bb18c558c49a6 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -10242,13 +10242,15 @@ StmtResult SemaOpenMP::ActOnOpenMPSimdDirective( if (!AStmt) return StmtError(); + CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_simd, AStmt); + assert(isa<CapturedStmt>(AStmt) && "Captured statement expected"); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop( OMPD_simd, getCollapseNumberExpr(Clauses), getOrderedNumberExpr(Clauses), - AStmt, SemaRef, *DSAStack, VarsWithImplicitDSA, B); + CS, SemaRef, *DSAStack, VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -10258,7 +10260,6 @@ StmtResult SemaOpenMP::ActOnOpenMPSimdDirective( if (checkSimdlenSafelenSpecified(SemaRef, Clauses)) return StmtError(); - SemaRef.setFunctionHasBranchProtectedScope(); auto *SimdDirective = OMPSimdDirective::Create( getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); return SimdDirective; @@ -10295,13 +10296,15 @@ StmtResult SemaOpenMP::ActOnOpenMPForSimdDirective( if (!AStmt) return StmtError(); + CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_for_simd, AStmt); + assert(isa<CapturedStmt>(AStmt) && "Captured statement expected"); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop(OMPD_for_simd, getCollapseNumberExpr(Clauses), - getOrderedNumberExpr(Clauses), AStmt, SemaRef, *DSAStack, + getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack, VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -10312,7 +10315,6 @@ StmtResult SemaOpenMP::ActOnOpenMPForSimdDirective( if (checkSimdlenSafelenSpecified(SemaRef, Clauses)) return StmtError(); - SemaRef.setFunctionHasBranchProtectedScope(); return OMPForSimdDirective::Create(getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); } @@ -10764,14 +10766,15 @@ StmtResult SemaOpenMP::ActOnOpenMPParallelForSimdDirective( if (!AStmt) return StmtError(); - setBranchProtectedScope(SemaRef, OMPD_parallel_for_simd, AStmt); + CapturedStmt *CS = + setBranchProtectedScope(SemaRef, OMPD_parallel_for_simd, AStmt); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop(OMPD_parallel_for_simd, getCollapseNumberExpr(Clauses), - getOrderedNumberExpr(Clauses), AStmt, SemaRef, *DSAStack, + getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack, VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -13121,14 +13124,17 @@ StmtResult SemaOpenMP::ActOnOpenMPTaskLoopSimdDirective( if (!AStmt) return StmtError(); + CapturedStmt *CS = + setBranchProtectedScope(SemaRef, OMPD_taskloop_simd, AStmt); + assert(isa<CapturedStmt>(AStmt) && "Captured statement expected"); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop(OMPD_taskloop_simd, getCollapseNumberExpr(Clauses), - /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef, - *DSAStack, VarsWithImplicitDSA, B); + /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack, + VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -13149,7 +13155,6 @@ StmtResult SemaOpenMP::ActOnOpenMPTaskLoopSimdDirective( if (checkSimdlenSafelenSpecified(SemaRef, Clauses)) return StmtError(); - SemaRef.setFunctionHasBranchProtectedScope(); return OMPTaskLoopSimdDirective::Create(getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); } @@ -13236,14 +13241,17 @@ StmtResult SemaOpenMP::ActOnOpenMPMasterTaskLoopSimdDirective( if (!AStmt) return StmtError(); + CapturedStmt *CS = + setBranchProtectedScope(SemaRef, OMPD_master_taskloop_simd, AStmt); + assert(isa<CapturedStmt>(AStmt) && "Captured statement expected"); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop(OMPD_master_taskloop_simd, getCollapseNumberExpr(Clauses), - /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef, - *DSAStack, VarsWithImplicitDSA, B); + /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack, + VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -13264,7 +13272,6 @@ StmtResult SemaOpenMP::ActOnOpenMPMasterTaskLoopSimdDirective( if (checkSimdlenSafelenSpecified(SemaRef, Clauses)) return StmtError(); - SemaRef.setFunctionHasBranchProtectedScope(); return OMPMasterTaskLoopSimdDirective::Create( getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); } @@ -13275,14 +13282,17 @@ StmtResult SemaOpenMP::ActOnOpenMPMaskedTaskLoopSimdDirective( if (!AStmt) return StmtError(); + CapturedStmt *CS = + setBranchProtectedScope(SemaRef, OMPD_masked_taskloop_simd, AStmt); + assert(isa<CapturedStmt>(AStmt) && "Captured statement expected"); OMPLoopBasedDirective::HelperExprs B; // In presence of clause 'collapse' or 'ordered' with number of loops, it will // define the nested loops number. unsigned NestedLoopCount = checkOpenMPLoop(OMPD_masked_taskloop_simd, getCollapseNumberExpr(Clauses), - /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef, - *DSAStack, VarsWithImplicitDSA, B); + /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack, + VarsWithImplicitDSA, B); if (NestedLoopCount == 0) return StmtError(); @@ -13303,7 +13313,6 @@ StmtResult SemaOpenMP::ActOnOpenMPMaskedTaskLoopSimdDirective( if (checkSimdlenSafelenSpecified(SemaRef, Clauses)) return StmtError(); - SemaRef.setFunctionHasBranchProtectedScope(); return OMPMaskedTaskLoopSimdDirective::Create( getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B); } diff --git a/clang/test/AST/ast-dump-openmp-for-simd.c b/clang/test/AST/ast-dump-openmp-for-simd.c index 5dcd9175d4998..06ae226ccb17d 100644 --- a/clang/test/AST/ast-dump-openmp-for-simd.c +++ b/clang/test/AST/ast-dump-openmp-for-simd.c @@ -41,7 +41,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:22, line:7:1> // CHECK-NEXT: | `-OMPForSimdDirective {{.*}} <line:4:1, col:21> // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:5:3, line:6:5> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:5:3, line:6:5> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:5:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -65,7 +65,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:29, line:14:1> // CHECK-NEXT: | `-OMPForSimdDirective {{.*}} <line:10:1, col:21> // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:11:3, line:13:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:11:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -108,7 +108,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-value: Int 1 // CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:31> 'int' 1 // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:18:3, line:20:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:18:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -151,7 +151,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-value: Int 2 // CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:31> 'int' 2 // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:25:3, line:27:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:25:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -195,7 +195,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | |-value: Int 2 // CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:31> 'int' 2 // CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9> -// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:32:3, line:35:9> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:32:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit diff --git a/clang/test/AST/ast-dump-openmp-simd.c b/clang/test/AST/ast-dump-openmp-simd.c index 3ccddd426d741..cffbb9065f1d6 100644 --- a/clang/test/AST/ast-dump-openmp-simd.c +++ b/clang/test/AST/ast-dump-openmp-simd.c @@ -41,7 +41,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:22, line:7:1> // CHECK-NEXT: | `-OMPSimdDirective {{.*}} <line:4:1, col:17> // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:5:3, line:6:5> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:5:3, line:6:5> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:5:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -65,7 +65,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:29, line:14:1> // CHECK-NEXT: | `-OMPSimdDirective {{.*}} <line:10:1, col:17> // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:11:3, line:13:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:11:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -108,7 +108,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-value: Int 1 // CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:27> 'int' 1 // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:18:3, line:20:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:18:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -151,7 +151,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-value: Int 2 // CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:27> 'int' 2 // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7> -// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | | |-ForStmt {{.*}} <line:25:3, line:27:7> // CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:25:8, col:17> // CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -195,7 +195,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | |-value: Int 2 // CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:27> 'int' 2 // CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9> -// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:32:3, line:35:9> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:32:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit diff --git a/clang/test/AST/ast-dump-openmp-taskloop-simd.c b/clang/test/AST/ast-dump-openmp-taskloop-simd.c index 25f9cd30ad1c1..de70ecdefd16a 100644 --- a/clang/test/AST/ast-dump-openmp-taskloop-simd.c +++ b/clang/test/AST/ast-dump-openmp-taskloop-simd.c @@ -43,7 +43,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | |-OMPFirstprivateClause {{.*}} <<invalid sloc>> <implicit> // CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:5:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | `-CapturedStmt {{.*}} <col:3, line:6:5> -// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:5:3, line:6:5> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:5:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -80,7 +80,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:11:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:12:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7> -// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:11:3, line:13:7> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:11:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -135,7 +135,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:18:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:19:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7> -// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:18:3, line:20:7> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:18:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -190,7 +190,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:25:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:26:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7> -// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: | |-ForStmt {{.*}} <line:25:3, line:27:7> // CHECK-NEXT: | | |-DeclStmt {{.*}} <line:25:8, col:17> // CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit @@ -247,7 +247,7 @@ void test_five(int x, int y, int z) { // CHECK-NEXT: | |-DeclRefExpr {{.*}} <line:33:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: | `-DeclRefExpr {{.*}} <line:34:27> 'int' lvalue ParmVar {{.*}} 'z' 'int' refers_to_enclosing_variable_or_capture // CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9> -// CHECK-NEXT: `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow // CHECK-NEXT: |-ForStmt {{.*}} <line:32:3, line:35:9> // CHECK-NEXT: | |-DeclStmt {{.*}} <line:32:8, col:17> // CHECK-NEXT: | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits