[flang-commits] [flang] [flang] Pass to add frame pointer attribute (PR #74598)

Radu Salavat via flang-commits flang-commits at lists.llvm.org
Mon Dec 11 04:20:15 PST 2023


================
@@ -310,10 +311,17 @@ inline void createDefaultFIRCodeGenPassPipeline(
 
   if (config.VScaleMin != 0)
     pm.addPass(fir::createVScaleAttrPass({config.VScaleMin, config.VScaleMax}));
-
+  
+  // Add function attributes 
   fir::FunctionAttrTypes functionAttrs;
-  functionAttrs.framePointerKind = config.FramePointerKind;
-  pm.addPass(fir::createFunctionAttrPass(functionAttrs));
+  
+  if (config.FramePointerKind != llvm::FramePointerKind::None) {  
+    if (config.FramePointerKind == llvm::FramePointerKind::NonLeaf) 
+        functionAttrs.framePointerKind = mlir::LLVM::framePointerKind::FramePointerKind::NonLeaf;
+    else functionAttrs.framePointerKind = mlir::LLVM::framePointerKind::FramePointerKind::All;
----------------
Radu2k wrote:

To optimise the code I have removed any invocation from the FrontendActions.cpp. The parameter is declared in `CodeGedOptions.def`, set in the `CompilerInvocation.cpp` based on the user requirements and called `FramePointerKind = opts.getFramePointer();` when `MLIRToLLVMPassPipelineConfig` is initialised.

In both `CodeGedOptions.def` and `CompilerInvocation.cpp` I saw that llvm namespace is predominantly used, and did not used the mlir FramePointerKind. 

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


More information about the flang-commits mailing list