This patch proposes the way how LLVM IR function attributes should be generated for Fortran code.
- Expected output:
Flang should be able to attach LLVM IR function attributes as Clang does:
; Clang *.ll file: define dso_local i32 @foo() #0 { ; some code } attributes #0 = { list of attributes for example: nounwind, target-cpu="cpu_name", etc}
- Passing MLIR attributes to LLVM IR for Fortran functions:
Flang can attach LLVM IR function attributes to passthrough MLIR attribute. passthrough attribute is lowered to LLVM IR by MLIR (see patch: https://reviews.llvm.org/D77072 ). The attributes which are dependent on the frontend options (like target-cpu, target-features etc.) should be passed directly to lower functions as it is done in this patch. Attributes which are dependent on the content of Fortran function (for example: alwaysinline) should be added to MLIR code during lowering from PFT to MLIR phase.
- Handling LLVM IR attributes for OpenMP related LLVM IR
OpenMP MLIR operations are lowered to LLVM IR by OpenMPIRBuilder. That's why OpenMPIRbuilder should be responsible for attaching LLVM IR attributes. The attributes which are dependent on frontend options (like target-cpu) should be passed to MLIR code as it is done here: https://reviews.llvm.org/D146612. Proposition of lowering these attributes is put here: https://reviews.llvm.org/D147313 and it is dependent on the result of discussion for patch: https://reviews.llvm.org/D147344 . OpenMP functions attributes which are not dependent on the frontend options should be added during LLVM IR generation like it is done for nounwind attribute: https://reviews.llvm.org/D147321
Is there a reason each distinct function in the compilation unit has its own target attribute? (The target attribute is attached to the module, no?)