[clang] [flang] [flang][Driver] Add support for -f[no]keep-inline-functions option (PR #230007)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 18:46:41 PDT 2026


================
@@ -0,0 +1,50 @@
+! RUN: %flang -### -fkeep-inline-functions %s 2>&1 | FileCheck %s --check-prefix=DRIVER-KEEP
+! RUN: %flang -### -fno-keep-inline-functions %s 2>&1 | FileCheck %s --check-prefix=DRIVER-NOKEEP
+! RUN: %flang -### -fkeep-inline-functions -fno-keep-inline-functions %s 2>&1 | FileCheck %s --check-prefix=DRIVER-NOKEEP
+! RUN: %flang -### -fno-keep-inline-functions -fkeep-inline-functions %s 2>&1 | FileCheck %s --check-prefix=DRIVER-KEEP
+
+! DRIVER-KEEP: "-fc1"
+! DRIVER-KEEP-SAME: "-fkeep-inline-functions"
+! DRIVER-NOKEEP: "-fc1"
+! DRIVER-NOKEEP-NOT: "-fkeep-inline-functions"
+! DRIVER-NOKEEP-NOT: "-fno-keep-inline-functions"
+
+! Without the flag, an alwaysinline contained procedure is inlined and deleted.
+! RUN: %flang_fc1 -emit-llvm -O2 -o - %s | FileCheck %s --check-prefix=DEFAULT
----------------
shivaramaarao wrote:

The self-reference is the smaller change, and it uses the symbol-use rule the inliner already has. An explicit retain attribute would be clearer, but the inliner does not consult one today. Teaching it to do so means changing the generic MLIR inliner, not just Flang.

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


More information about the cfe-commits mailing list