flang
flang copied to clipboard
[LLVM 15] Support opaque pointers in Classic Flang
Hello, everyone!
We noticed that there are some efforts to make classic-flang use LLVM15: [LLVM 15][runtime] Define overloaded function types and improve type checking #1289 [LLVM 15][runtime] Stop using K&R function declarations #1290 [LLVM 15][runtime] Remove extern function declarations #1291 [LLVM 15][runtime] Add C prototypes for external Fortran matmul functions #1292 [LLVM 15][test] Rename lit.site.cfg variable to support LLVM 15 #1293 [LLVM 15][libpgmath] Decouple from libflangrti by using errno directly; NFCI #1294
As we know, Opaque pointers are enabled by default in LLVM 15, aiming to replace all pointer types in LLVM with opaque pointer types. The new pointer type is represented textually as ptr. For more details, see Opaque Pointers — LLVM 16.0.0 git documentation.
In order to make classic-flang support LLVM15 and later we plan to implement Opaque pointers in classic-flang. Our proposal will be presented here later. Once the work on porting classic-flang to LLVM15 is complete, we will start supporting Opaque pointers in classic-flang.
CC: @pawosm-arm @mgabka @paulwalker-arm
@xinliu-hnc Please note that there are a couple more LLVM 15 patches I intend to submit. Currently flang/master will fail to build with LLVM 15 even with the listed patches applied.
In order to support opaque pointers in Classic Flang, we have to modify the following parts.
- For the typed pointers generated by functions, we are going to modify functions in ll_structrue.cpp to uniformly use 'ptr' as the IR output string, and to modify functions in cgmain.cpp to reduce the redundant cast_ops between pointers.
- There are some hard-coded typed pointers needed to be modified in cgmain.cpp/ll_write.cpp/llassem.cpp/llassem_common.cpp/lldebug.cpp. Some of them are used to declare the llvm intrinsic functions. We are rewriting them with 'ptr'.
- Lots of test cases using typed pointer IR are also needed to be modified.
The work is complete.