[flang-commits] [flang] [flang] GETPID runtime and lower intrinsic implementation (PR #70442)

Yi Wu via flang-commits flang-commits at lists.llvm.org
Fri Oct 27 07:19:23 PDT 2023


================
@@ -23,6 +24,10 @@ extern "C" {
 // integer kind.
 std::int32_t RTNAME(ArgumentCount)();
 
+// ??.?.??
----------------
PAX-12-WU wrote:

I have tried to implement it in `flang/runtime/extension`
```c++
// RESULT = GETPID()
pid_t FORTRAN_PROCEDURE_NAME(getpid)() { return RTNAME(GetPID)(); }
```
However, when testing getpid in a file, getpid would return a `float` rather than an `i32`, the same applies even if I change the return type from `pid_t` -> `std::int32`.
There is a workaround, by renaming the function from `getpid` -> `igetpid`
|...| Before  |  After |
|---|---|---|
| fuc name  | getpid  | igetpid  |  
| -S -emit-llvm  | ` %3 = call contract float @getpid_()`  | `%3 = call i32 @iargc_()` | 


https://github.com/llvm/llvm-project/pull/70442


More information about the flang-commits mailing list