[Flang][OpenMP] Fix Flang crash and incorrect ordering with OpenMP detached task (#194840) Fixes - [#194563](https://github.com/llvm/llvm-project/issues/194563) This PR fixes the runtime crash and incorrect task ordering reported in the testcase involving: ``` !$omp task if(.false.) depend(out:x) detach(ev) ``` The testcase had two issues: **1. Segmentation fault near omp_fulfill_event(ev)** The detach event handle was not being initialized or preserved correctly before the nested task used it. **2. Incorrect execution order** The task with depend(in:x) was running before the detach event was fulfilled, which violates OpenMP dependency semantics. #### Changes in this PR 1. Treat `parallel master` as a top-level parallel construct in Flang semantics to ensure correct data-sharing behavior. 2. Treat variables used in `detach(...)` as shared so the event handle remains valid across tasks. 3. Fix `OMPIRBuilder` lowering for task `if(.false.)` to use merged-if0 behavior through the normal task runtime path, ensuring correct task allocation, event creation, dependency registration, and proper waiting until `omp_fulfill_event(ev)`. 4. Add an MLIR regression test for `if(false) + depend + detach`. GitOrigin-RevId: 43d13365f875e6eeeb50b77cc1af49543cbece8d
Flang is a ground-up implementation of a Fortran front end written in modern C++. It started off as the f18 project (https://github.com/flang-compiler/f18) with an aim to replace the previous flang project (https://github.com/flang-compiler/flang) and address its various deficiencies. F18 was subsequently accepted into the LLVM project and rechristened as Flang.
Please note that flang is not ready yet for production usage.
Read more about flang in the docs directory. Start with the compiler overview.
To better understand Fortran as a language and the specific grammar accepted by flang, read Fortran For C Programmers and flang's specifications of the Fortran grammar and the OpenMP grammar.
Treatment of language extensions is covered in this document.
To understand the compilers handling of intrinsics, see the discussion of intrinsics.
To understand how a flang program communicates with libraries at runtime, see the discussion of runtime descriptors.
If you're interested in contributing to the compiler, read the style guide and also review how flang uses modern C++ features.
If you are interested in writing new documentation, follow LLVM's Markdown style guide.
Consult the Getting Started with Flang for information on building and running flang.