[llvm-branch-commits] [flang] 1a04a5f - [flang] Fix optional assertion in PFTBuilder
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 15 21:34:53 PDT 2023
Author: Valentin Clement
Date: 2023-05-15T21:32:49-07:00
New Revision: 1a04a5f1cf15ccf5e0472d495fc47311d9656410
URL: https://github.com/llvm/llvm-project/commit/1a04a5f1cf15ccf5e0472d495fc47311d9656410
DIFF: https://github.com/llvm/llvm-project/commit/1a04a5f1cf15ccf5e0472d495fc47311d9656410.diff
LOG: [flang] Fix optional assertion in PFTBuilder
D142279 enabled assertion in libstdc++ and one was triggered
in the PFTBuilder because an optional was access even if it was
null.
This patch fix this issue and add a regression test.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D143589
(cherry picked from commit 3f55311a0afff6278571922e1c23bf5c71dd2d0b)
Added:
flang/test/Lower/pre-fir-tree08.f
Modified:
flang/lib/Lower/PFTBuilder.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp
index a5f1ed7fb0fda..cde906f7565f7 100644
--- a/flang/lib/Lower/PFTBuilder.cpp
+++ b/flang/lib/Lower/PFTBuilder.cpp
@@ -508,7 +508,7 @@ class PFTBuilder {
auto branchTargetMatch = [&]() {
if (const parser::Label targetLabel =
ifCandidateStack.back().ifTargetLabel)
- if (targetLabel == *targetEval.label)
+ if (targetEval.label && targetLabel == *targetEval.label)
return true; // goto target match
if (targetEvalIsEndDoStmt && ifCandidateStack.back().isCycleStmt)
return true; // cycle target match
diff --git a/flang/test/Lower/pre-fir-tree08.f b/flang/test/Lower/pre-fir-tree08.f
new file mode 100755
index 0000000000000..a7ee4eb23fc0d
--- /dev/null
+++ b/flang/test/Lower/pre-fir-tree08.f
@@ -0,0 +1,21 @@
+! RUN: %flang_fc1 -fdebug-pre-fir-tree -fopenacc %s | FileCheck %s
+ program rewrite_goto
+ integer b
+
+ b = dummy(10)
+
+ end
+ function dummy(a)
+ integer, a
+
+ do 10 i=1,10
+ 10 if(i .EQ. 1) GOTO 11
+ i=0
+ 11 dummy = a + i
+ return
+ end
+
+! CHECK: <<IfConstruct!>> -> 5
+! CHECK: 2 ^IfStmt -> 5: 10if(i.eq.1)goto11
+! CHECK: 3 ^GotoStmt! -> 7: goto11
+
More information about the llvm-branch-commits
mailing list