[flang-commits] [clang] [flang] [flang]Add support for -moutline-atomics and -mno-outline-atomics (PR #78755)

Mats Petersson via flang-commits flang-commits at lists.llvm.org
Fri Feb 2 03:28:16 PST 2024


https://github.com/Leporacanthicus updated https://github.com/llvm/llvm-project/pull/78755

>From a0e256f379130a98ba03793f7102c67d02cbdef1 Mon Sep 17 00:00:00 2001
From: Mats Petersson <mats.petersson at arm.com>
Date: Fri, 19 Jan 2024 16:30:31 +0000
Subject: [PATCH 1/4] [flang]Add support for -moutline-atomics and
 -mno-outline-atomics

Clang has support for genarting atomic operations as functions rather
than inline atomic operations, using a target feature.

This is useful for code-size, some cases of debugging, and it also affects
the ability to inline functions from C into Fortran or the other way around
when using LTO - the inliner will check the target features to make sure
functions are compatible, and a difference in outline-atomics would disable
the inlining of an outline-atomics into a non-outline-atomics function.
---
 clang/include/clang/Driver/Options.td         |  4 ++--
 clang/lib/Driver/ToolChains/Flang.cpp         | 23 ++++++++++++++++++-
 flang/lib/Frontend/CompilerInvocation.cpp     | 15 ++++++++++++
 flang/test/Driver/aarch64-outline-atomics.f90 | 11 +++++++++
 flang/test/Driver/driver-help-hidden.f90      |  2 ++
 flang/test/Driver/driver-help.f90             |  4 ++++
 6 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 flang/test/Driver/aarch64-outline-atomics.f90

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index d940665969339..0eb72f5722541 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4982,10 +4982,10 @@ def mno_fmv : Flag<["-"], "mno-fmv">, Group<f_clang_Group>,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, Group<f_clang_Group>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Generate local calls to out-of-line atomic operations">;
 def mno_outline_atomics : Flag<["-"], "mno-outline-atomics">, Group<f_clang_Group>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Don't generate local calls to out-of-line atomic operations">;
 def mno_implicit_float : Flag<["-"], "mno-implicit-float">, Group<m_Group>,
   HelpText<"Don't generate implicit floating point or vector instructions">;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index b659521df88ff..bdd8afde44165 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -352,6 +352,27 @@ void Flang::addTargetOptions(const ArgList &Args,
     CmdArgs.push_back(Args.MakeArgString(CPU));
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
+                               options::OPT_mno_outline_atomics)) {
+    // Option -moutline-atomics supported for AArch64 target only.
+    if (!Triple.isAArch64()) {
+      D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+          << Triple.getArchName() << A->getOption().getName();
+    } else {
+      if (A->getOption().matches(options::OPT_moutline_atomics)) {
+        CmdArgs.push_back("-target-feature");
+        CmdArgs.push_back("+outline-atomics");
+      } else {
+        CmdArgs.push_back("-target-feature");
+        CmdArgs.push_back("-outline-atomics");
+      }
+    }
+  } else if (Triple.isAArch64() &&
+             getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+outline-atomics");
+  }
+
   // Add the target features.
   switch (TC.getArch()) {
   default:
@@ -672,7 +693,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
 
   if (isa<PreprocessJobAction>(JA)) {
-      CmdArgs.push_back("-E");
+    CmdArgs.push_back("-E");
   } else if (isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) {
     if (JA.getType() == types::TY_Nothing) {
       CmdArgs.push_back("-fsyntax-only");
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index a3c41fb4611f5..74127327e798e 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -402,6 +402,21 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
   for (const llvm::opt::Arg *currentArg :
        args.filtered(clang::driver::options::OPT_target_feature))
     opts.featuresAsWritten.emplace_back(currentArg->getValue());
+
+  llvm::Triple targetTriple{llvm::Triple(opts.triple)};
+  if (const llvm::opt::Arg *A =
+          args.getLastArg(clang::driver::options::OPT_moutline_atomics,
+                          clang::driver::options::OPT_mno_outline_atomics)) {
+    // Option -moutline-atomics supported for AArch64 target only.
+    if (!targetTriple.isAArch64()) {
+      if (A->getOption().matches(
+              clang::driver::options::OPT_moutline_atomics)) {
+        opts.featuresAsWritten.push_back("+outline-atomics");
+      } else {
+        opts.featuresAsWritten.push_back("-outline-atomics");
+      }
+    }
+  }
 }
 
 // Tweak the frontend configuration based on the frontend action
diff --git a/flang/test/Driver/aarch64-outline-atomics.f90 b/flang/test/Driver/aarch64-outline-atomics.f90
new file mode 100644
index 0000000000000..f469d50290ef0
--- /dev/null
+++ b/flang/test/Driver/aarch64-outline-atomics.f90
@@ -0,0 +1,11 @@
+! Test that flang-new forwards the -moutline-atomics and -mno-outline-atomics.
+! RUN: %flang -moutline-atomics --target=aarch64-none-none -### %s -o %t 2>&1  | FileCheck %s
+! CHECK: "-target-feature" "+outline-atomics"
+
+! RUN: %flang -mno-outline-atomics --target=aarch64-none-none -### %s -o %t 2>&1  | FileCheck %s --check-prefix=CHECK-NOOUTLINE
+! CHECK-NOOUTLINE: "-target-feature" "-outline-atomics"
+
+! RUN: %flang -mno-outline-atomics --target=x86-none-none -### %s -o %t 2>&1  | FileCheck %s --check-prefix=CHECK-ERRMSG
+! CHECK-ERRMSG: warning: 'x86' does not support '-mno-outline-atomics'
+
+
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index 25dfcf3c70d8e..36b7d207ad36a 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -122,7 +122,9 @@
 ! CHECK-NEXT: -mllvm=<arg>            Alias for -mllvm
 ! CHECK-NEXT: -mllvm <value>          Additional arguments to forward to LLVM's option processing
 ! CHECK-NEXT: -mmlir <value>          Additional arguments to forward to MLIR's option processing
+! CHECK-NEXT: -mno-outline-atomics    Don't generate local calls to out-of-line atomic operations
 ! CHECK-NEXT: -module-dir <dir>       Put MODULE files in <dir>
+! CHECK-NEXT: -moutline-atomics       Generate local calls to out-of-line atomic operations
 ! CHECK-NEXT: -mrvv-vector-bits=<value>
 ! CHECK-NEXT:                         Specify the size in bits of an RVV vector register
 ! CHECK-NEXT: -msve-vector-bits=<value>
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index 9f0aae51c3f5d..b23e34f4d3c0d 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -108,7 +108,9 @@
 ! HELP-NEXT: -mllvm=<arg>            Alias for -mllvm
 ! HELP-NEXT: -mllvm <value>          Additional arguments to forward to LLVM's option processing
 ! HELP-NEXT: -mmlir <value>          Additional arguments to forward to MLIR's option processing
+! HELP-NEXT: -mno-outline-atomics    Don't generate local calls to out-of-line atomic operations
 ! HELP-NEXT: -module-dir <dir>       Put MODULE files in <dir>
+! HELP-NEXT: -moutline-atomics       Generate local calls to out-of-line atomic operations
 ! HELP-NEXT: -mrvv-vector-bits=<value>
 ! HELP-NEXT:                         Specify the size in bits of an RVV vector register
 ! HELP-NEXT: -msve-vector-bits=<value>
@@ -246,8 +248,10 @@
 ! HELP-FC1-NEXT: -mframe-pointer=<value> Specify which frame pointers to retain.
 ! HELP-FC1-NEXT: -mllvm <value>          Additional arguments to forward to LLVM's option processing
 ! HELP-FC1-NEXT: -mmlir <value>          Additional arguments to forward to MLIR's option processing
+! HELP-FC1-NEXT: -mno-outline-atomics    Don't generate local calls to out-of-line atomic operations
 ! HELP-FC1-NEXT: -module-dir <dir>       Put MODULE files in <dir>
 ! HELP-FC1-NEXT: -module-suffix <suffix> Use <suffix> as the suffix for module files (the default value is `.mod`)
+! HELP-FC1-NEXT: -moutline-atomics       Generate local calls to out-of-line atomic operations
 ! HELP-FC1-NEXT: -mreassociate           Allow reassociation transformations for floating-point instructions
 ! HELP-FC1-NEXT: -mrelocation-model <value>
 ! HELP-FC1-NEXT:                         The relocation model to use

>From 26e268baa357c5a10ee2fc54d79f959f1e453e71 Mon Sep 17 00:00:00 2001
From: Mats Petersson <mats.petersson at arm.com>
Date: Wed, 31 Jan 2024 10:20:16 +0000
Subject: [PATCH 2/4] Make common code for setting args

Also invert condition pointed out in review.
---
 clang/lib/Driver/ToolChains/Clang.cpp      | 23 ++-------------------
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 24 ++++++++++++++++++++++
 clang/lib/Driver/ToolChains/CommonArgs.h   |  4 ++++
 clang/lib/Driver/ToolChains/Flang.cpp      | 23 ++-------------------
 flang/lib/Frontend/CompilerInvocation.cpp  |  2 +-
 5 files changed, 33 insertions(+), 43 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d8965fdf76fb..07e44c187839a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7650,27 +7650,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   addMachineOutlinerArgs(D, Args, CmdArgs, Triple, /*IsLTO=*/false);
 
-  if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
-                               options::OPT_mno_outline_atomics)) {
-    // Option -moutline-atomics supported for AArch64 target only.
-    if (!Triple.isAArch64()) {
-      D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-          << Triple.getArchName() << A->getOption().getName();
-    } else {
-      if (A->getOption().matches(options::OPT_moutline_atomics)) {
-        CmdArgs.push_back("-target-feature");
-        CmdArgs.push_back("+outline-atomics");
-      } else {
-        CmdArgs.push_back("-target-feature");
-        CmdArgs.push_back("-outline-atomics");
-      }
-    }
-  } else if (Triple.isAArch64() &&
-             getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
-    CmdArgs.push_back("-target-feature");
-    CmdArgs.push_back("+outline-atomics");
-  }
-
+  addOutlineAtomicsArgs(D, getToolChain(), Args, CmdArgs, Triple);
+  
   if (Triple.isAArch64() &&
       (Args.hasArg(options::OPT_mno_fmv) ||
        (Triple.isAndroid() && Triple.isAndroidVersionLT(23)) ||
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index acc247447b985..ad03bdc7668d9 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2790,3 +2790,27 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C,
     }
   }
 }
+
+void tools::addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList & CmdArgs, const llvm::Triple &Triple)
+{
+    if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
+                               options::OPT_mno_outline_atomics)) {
+    // Option -moutline-atomics supported for AArch64 target only.
+    if (!Triple.isAArch64()) {
+      D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+          << Triple.getArchName() << A->getOption().getName();
+    } else {
+      if (A->getOption().matches(options::OPT_moutline_atomics)) {
+        CmdArgs.push_back("-target-feature");
+        CmdArgs.push_back("+outline-atomics");
+      } else {
+        CmdArgs.push_back("-target-feature");
+        CmdArgs.push_back("-outline-atomics");
+      }
+    }
+  } else if (Triple.isAArch64() &&
+             TC.IsAArch64OutlineAtomicsDefault(Args)) {
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back("+outline-atomics");
+  }
+}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index 807867f13a5c3..e90c3965bcc95 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -215,6 +215,9 @@ void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
                         llvm::opt::ArgStringList &CC1Args,
                         StringRef BitcodeSuffix, const llvm::Triple &Triple);
+
+void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple);
+
 } // end namespace tools
 } // end namespace driver
 } // end namespace clang
@@ -222,4 +225,5 @@ void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
 clang::CodeGenOptions::FramePointerKind
 getFramePointerKind(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
 
+                                  
 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index bdd8afde44165..7a6515d368ec4 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -352,27 +352,8 @@ void Flang::addTargetOptions(const ArgList &Args,
     CmdArgs.push_back(Args.MakeArgString(CPU));
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
-                               options::OPT_mno_outline_atomics)) {
-    // Option -moutline-atomics supported for AArch64 target only.
-    if (!Triple.isAArch64()) {
-      D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-          << Triple.getArchName() << A->getOption().getName();
-    } else {
-      if (A->getOption().matches(options::OPT_moutline_atomics)) {
-        CmdArgs.push_back("-target-feature");
-        CmdArgs.push_back("+outline-atomics");
-      } else {
-        CmdArgs.push_back("-target-feature");
-        CmdArgs.push_back("-outline-atomics");
-      }
-    }
-  } else if (Triple.isAArch64() &&
-             getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
-    CmdArgs.push_back("-target-feature");
-    CmdArgs.push_back("+outline-atomics");
-  }
-
+  addOutlineAtomicsArgs(D, getToolChain(), Args, CmdArgs, Triple);
+  
   // Add the target features.
   switch (TC.getArch()) {
   default:
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 74127327e798e..4d6894e0b5d03 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -408,7 +408,7 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
           args.getLastArg(clang::driver::options::OPT_moutline_atomics,
                           clang::driver::options::OPT_mno_outline_atomics)) {
     // Option -moutline-atomics supported for AArch64 target only.
-    if (!targetTriple.isAArch64()) {
+    if (targetTriple.isAArch64()) {
       if (A->getOption().matches(
               clang::driver::options::OPT_moutline_atomics)) {
         opts.featuresAsWritten.push_back("+outline-atomics");

>From cb62b1eee566efbac629a86ed9f90bbdc957ba9a Mon Sep 17 00:00:00 2001
From: Mats Petersson <mats.petersson at arm.com>
Date: Wed, 31 Jan 2024 17:43:01 +0000
Subject: [PATCH 3/4] Fix formatting and update test

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp    | 8 +++++---
 clang/lib/Driver/ToolChains/CommonArgs.h      | 6 ++++--
 clang/lib/Driver/ToolChains/Flang.cpp         | 2 +-
 flang/test/Driver/aarch64-outline-atomics.f90 | 4 ++++
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ad03bdc7668d9..7bb81eb5d716a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2791,9 +2791,11 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C,
   }
 }
 
-void tools::addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList & CmdArgs, const llvm::Triple &Triple)
-{
-    if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
+void tools::addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC,
+                                  const llvm::opt::ArgList &Args,
+                                  llvm::opt::ArgStringList &CmdArgs,
+                                  const llvm::Triple &Triple) {
+  if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
                                options::OPT_mno_outline_atomics)) {
     // Option -moutline-atomics supported for AArch64 target only.
     if (!Triple.isAArch64()) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index e90c3965bcc95..2db0f889ca820 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -216,7 +216,10 @@ void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
                         llvm::opt::ArgStringList &CC1Args,
                         StringRef BitcodeSuffix, const llvm::Triple &Triple);
 
-void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple);
+void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC,
+                           const llvm::opt::ArgList &Args,
+                           llvm::opt::ArgStringList &CmdArgs,
+                           const llvm::Triple &Triple);
 
 } // end namespace tools
 } // end namespace driver
@@ -225,5 +228,4 @@ void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt
 clang::CodeGenOptions::FramePointerKind
 getFramePointerKind(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
 
-                                  
 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 7a6515d368ec4..2e5ee8e9e66dc 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -674,7 +674,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
 
   if (isa<PreprocessJobAction>(JA)) {
-    CmdArgs.push_back("-E");
+      CmdArgs.push_back("-E");
   } else if (isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) {
     if (JA.getType() == types::TY_Nothing) {
       CmdArgs.push_back("-fsyntax-only");
diff --git a/flang/test/Driver/aarch64-outline-atomics.f90 b/flang/test/Driver/aarch64-outline-atomics.f90
index f469d50290ef0..a1c874c20df5c 100644
--- a/flang/test/Driver/aarch64-outline-atomics.f90
+++ b/flang/test/Driver/aarch64-outline-atomics.f90
@@ -5,6 +5,10 @@
 ! RUN: %flang -mno-outline-atomics --target=aarch64-none-none -### %s -o %t 2>&1  | FileCheck %s --check-prefix=CHECK-NOOUTLINE
 ! CHECK-NOOUTLINE: "-target-feature" "-outline-atomics"
 
+! Use Fuchsia to ensure the outline atomics is enabled.
+! RUN: %flang --target=aarch64-none-fuchsia -### %s -o %t 2>&1  | FileCheck %s --check-prefix=CHECK-DEFAULT
+! CHECK-DEFAULT: "-target-feature" "+outline-atomics"
+
 ! RUN: %flang -mno-outline-atomics --target=x86-none-none -### %s -o %t 2>&1  | FileCheck %s --check-prefix=CHECK-ERRMSG
 ! CHECK-ERRMSG: warning: 'x86' does not support '-mno-outline-atomics'
 

>From f80bd4f2e4f46c94d9b3fc1aa6682da58244c251 Mon Sep 17 00:00:00 2001
From: Mats Petersson <mats.petersson at arm.com>
Date: Fri, 2 Feb 2024 11:26:36 +0000
Subject: [PATCH 4/4] Add lowering test

---
 flang/test/Lower/aarch64-outline-atomics.f90 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 flang/test/Lower/aarch64-outline-atomics.f90

diff --git a/flang/test/Lower/aarch64-outline-atomics.f90 b/flang/test/Lower/aarch64-outline-atomics.f90
new file mode 100644
index 0000000000000..6c0367077f2d4
--- /dev/null
+++ b/flang/test/Lower/aarch64-outline-atomics.f90
@@ -0,0 +1,18 @@
+! RUN: %flang -S -emit-llvm --target=aarch64-none-none -moutline-atomics -o - %s | FileCheck %s --check-prefixes=CHECKON,CHECKALL
+! RUN: %flang -S -emit-llvm --target=aarch64-none-none -mno-outline-atomics -o - %s | FileCheck %s --check-prefixes=CHECKOFF,CHECKALL
+! REQUIRES: aarch64-registered-target
+
+subroutine test()
+  integer :: i
+
+  do i = 1, 10
+  end do
+end subroutine
+
+! CHECKALL-LABEL: define void @test_()
+! CHECKALL-SAME: #[[ATTR:[0-9]*]]
+! CHECKALL: attributes #[[ATTR]] =
+! Use CHECK-SAME to allow arbitrary other attributes to be present.
+! CHECKALL-SAME: target-features
+! CHECKON-SAME: +outline-atomics
+! CHECKOFF-SAME: -outline-atomics



More information about the flang-commits mailing list