[flang-commits] [flang] [flang] Fix seg fault `CodeGenAction::executeAction()` (PR #78269)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 16 05:00:12 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-driver
Author: Kareem Ergawy (ergawy)
<details>
<summary>Changes</summary>
If `generateLLVMIR()` fails, we still continue using the module we failed to generate which causes a seg fault if LLVM code-gen failed for some reason or another. This commit fixes this issue.
---
Full diff: https://github.com/llvm/llvm-project/pull/78269.diff
1 Files Affected:
- (modified) flang/lib/Frontend/FrontendActions.cpp (+5)
``````````diff
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 74e3992d5ab62ba..65c4df7388f97b2 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -1202,6 +1202,11 @@ void CodeGenAction::executeAction() {
if (!llvmModule)
generateLLVMIR();
+ // If generating the LLVM module failed, abort! No need for further error
+ // reporting since generateLLVMIR() does this already.
+ if (!llvmModule)
+ return;
+
// Set the triple based on the targetmachine (this comes compiler invocation
// and the command-line target option if specified, or the default if not
// given on the command-line).
``````````
</details>
https://github.com/llvm/llvm-project/pull/78269
More information about the flang-commits
mailing list