[flang-commits] [flang] [flang][driver] Mark -fcommon and -mtune as visible in Flang (PR #68657)

Fangcao Wang via flang-commits flang-commits at lists.llvm.org
Mon Oct 9 20:32:26 PDT 2023


https://github.com/LittleMeepo created https://github.com/llvm/llvm-project/pull/68657

None

>From 490145aaa74fc936682344162ba1340b65c2bebc Mon Sep 17 00:00:00 2001
From: wangfc <wangfangcao1 at huawei.com>
Date: Tue, 10 Oct 2023 11:06:11 +0800
Subject: [PATCH] [flang][driver] Mark -fcommon and -mtune as visible in Flang

---
 clang/include/clang/Driver/Options.td |  3 ++-
 flang/test/Driver/misc-flags.f90      |  3 +++
 flang/test/Driver/tune-cpu.f90        | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Driver/tune-cpu.f90

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 5415b18d3f406df..8936df388d2db97 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1786,7 +1786,7 @@ def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
 def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
 def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
-  Visibility<[ClangOption, CLOption, CC1Option]>,
+  Visibility<[ClangOption, CLOption, CC1Option, FlangOption]>,
   HelpText<"Place uninitialized global variables in a common block">,
   MarshallingInfoNegativeFlag<CodeGenOpts<"NoCommon">>,
   DocBrief<[{Place definitions of variables with no storage class and no initializer
@@ -5077,6 +5077,7 @@ def module_file_info : Flag<["-"], "module-file-info">, Flags<[NoXarchOption]>,
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group<m_Group>;
 def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>,
+  Flags<[TargetSpecific]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Only supported on AArch64, PowerPC, RISC-V, SystemZ, and X86">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
diff --git a/flang/test/Driver/misc-flags.f90 b/flang/test/Driver/misc-flags.f90
index 61d763c5b64dd21..9412ccb8347ff89 100644
--- a/flang/test/Driver/misc-flags.f90
+++ b/flang/test/Driver/misc-flags.f90
@@ -10,6 +10,9 @@
 ! Make sure that `-L' is "visible" to Flang's driver
 ! RUN: %flang -L/ -### %s
 
+! Make sure that `-fcommon' is "visible" to Flang's driver
+! RUN: %flang -fcommon -### %s
+
 program hello
   write(*,*), "Hello world!"
 end program hello
diff --git a/flang/test/Driver/tune-cpu.f90 b/flang/test/Driver/tune-cpu.f90
new file mode 100644
index 000000000000000..44af55e30ab4eb7
--- /dev/null
+++ b/flang/test/Driver/tune-cpu.f90
@@ -0,0 +1,22 @@
+! Test that -mtune is used and that the -tune-cpu is also added to the
+! clang command.
+
+! RUN: %flang --target=aarch64-linux-gnu -mtune=cortex-a57 -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-A57
+
+! RUN: %flang --target=aarch64-linux-gnu -mtune=cortex-a76 -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-A76
+
+! RUN: %flang --target=aarch64-linux-gnu -mtune=cortex-armv9 -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-ARMV9
+
+! RUN: %flang --target=x86_64-linux-gnu -mtune=skylake -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-SKYLAKE
+
+! CHECK-A57: "-tune-cpu" "cortex-a57"
+
+! CHECK-A76: "-tune-cpu" "cortex-a76"
+
+! CHECK-ARMV9: "-tune-cpu" "cortex-armv9"
+
+! CHECK-SKYLAKE: "-tune-cpu" "skylake"



More information about the flang-commits mailing list