[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-03 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

Working on a fix - it should be trivial, just need to check that that it still 
builds and passes. 

[Trying to generate code without the correct target enabled!]

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-03 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-02 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus edited 
https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-02 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

> Yes, thank you!

This is now part of this PR. 

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-02 Thread Mats Petersson via cfe-commits


@@ -21,4 +22,14 @@ CodeGenOptions::CodeGenOptions() {
 #include "flang/Frontend/CodeGenOptions.def"
 }
 
+std::optional getCodeModel(llvm::StringRef string) {
+  return llvm::StringSwitch>(string)
+  .Case("tiny", llvm::CodeModel::Model::Tiny)
+  .Case("small", llvm::CodeModel::Model::Small)
+  .Case("kernel", llvm::CodeModel::Model::Kernel)
+  .Case("medium", llvm::CodeModel::Model::Medium)
+  .Case("large", llvm::CodeModel::Model::Large)
+  .Default(std::nullopt);

Leporacanthicus wrote:

Yes, as do we. Just not in this piece of code, it happens when we're parsing 
arguments. We call this function twice, only checking in the first place. 
Approximately line 400 of flang/lib/Frontend/CompilerInvocation.cpp 
There are tests in flang/test/Driver/mcmodel.f90 for generating an error.

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits


@@ -2823,3 +2823,84 @@ void tools::addOffloadCompressArgs(const 
llvm::opt::ArgList &TCArgs,
 CmdArgs.push_back(
 TCArgs.MakeArgString(Twine("-compression-level=") + Arg->getValue()));
 }
+
+void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,

Leporacanthicus wrote:

Yes, it is a direct copy, aside from not using a "cached" TripleStr and instead 
calling getTriple() on the Triple. [I just compared the two versions].

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus edited 
https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits

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

>From 0ef4b61d0429517b92f7b6de7fa52c516f3a1468 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Thu, 13 Jun 2024 14:01:36 +
Subject: [PATCH 1/5] [flang] Implement -mcmodel flag

This patch implements the -mcmodel flag from clang, allowing the Code Model to
be changed for the LLVM module. The same set of mcmodel flags are accepted as
in clang and the same Code Model attributes are added to the LLVM module for
those flags.
---
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 76 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 81 +++
 clang/lib/Driver/ToolChains/CommonArgs.h  |  4 +
 clang/lib/Driver/ToolChains/Flang.cpp |  5 ++
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 flang/lib/Frontend/CompilerInvocation.cpp | 21 +
 flang/lib/Frontend/FrontendActions.cpp|  3 +
 flang/test/Driver/mcmodel.f90 | 44 ++
 flang/test/Lower/mcmodel.f90  | 16 
 10 files changed, 177 insertions(+), 76 deletions(-)
 create mode 100644 flang/test/Driver/mcmodel.f90
 create mode 100644 flang/test/Lower/mcmodel.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..4087d3b95cc39 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4600,7 +4600,7 @@ def inline_asm_EQ : Joined<["-"], "inline-asm=">, 
Group,
   NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", 
"IAD_Intel"]>,
   MarshallingInfoEnum, "IAD_ATT">;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   MarshallingInfoString, [{"default"}]>;
 def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, 
Group,
   Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1f8591537b6c8..0447581128cd1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5908,81 +5908,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
 
-  if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-StringRef CM = A->getValue();
-bool Ok = false;
-if (Triple.isOSAIX() && CM == "medium")
-  CM = "large";
-if (Triple.isAArch64(64)) {
-  Ok = CM == "tiny" || CM == "small" || CM == "large";
-  if (CM == "large" && !Triple.isOSBinFormatMachO() &&
-  RelocationModel != llvm::Reloc::Static)
-D.Diag(diag::err_drv_argument_only_allowed_with)
-<< A->getAsString(Args) << "-fno-pic";
-} else if (Triple.isLoongArch()) {
-  if (CM == "extreme" &&
-  Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
-D.Diag(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "-fplt";
-  Ok = CM == "normal" || CM == "medium" || CM == "extreme";
-  // Convert to LLVM recognizable names.
-  if (Ok)
-CM = llvm::StringSwitch(CM)
- .Case("normal", "small")
- .Case("extreme", "large")
- .Default(CM);
-} else if (Triple.isPPC64() || Triple.isOSAIX()) {
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-} else if (Triple.isRISCV()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medany")
-CM = "medium";
-  Ok = CM == "small" || CM == "medium";
-} else if (Triple.getArch() == llvm::Triple::x86_64) {
-  Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
-  CM);
-} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
-  // NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
-  // whatever works for the host.
-  Ok = true;
-} else if (Triple.isSPARC64()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medmid")
-CM = "medium";
-  else if (CM == "medany")
-CM = "large";
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-}
-if (Ok) {
-  CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
-} else {
-  D.Diag(diag::err_drv_unsupported_option_argument_for_target)
-  << A->getSpelling() << CM << TripleStr;
-}
-  }
-
-  if (Triple.getArch() == llvm::Triple::x86_64) {
-bool IsMediumCM = false;
-bool IsLargeCM = false;
-if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-  IsMediumCM = StringRef(A->getValue()) == "medium";
-  IsLargeCM = StringRef(A->getValue()) == "large";
-}
-if (Arg *A = Args.getLastArg(options::OPT_ml

[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits

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

>From 0ef4b61d0429517b92f7b6de7fa52c516f3a1468 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Thu, 13 Jun 2024 14:01:36 +
Subject: [PATCH 1/4] [flang] Implement -mcmodel flag

This patch implements the -mcmodel flag from clang, allowing the Code Model to
be changed for the LLVM module. The same set of mcmodel flags are accepted as
in clang and the same Code Model attributes are added to the LLVM module for
those flags.
---
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 76 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 81 +++
 clang/lib/Driver/ToolChains/CommonArgs.h  |  4 +
 clang/lib/Driver/ToolChains/Flang.cpp |  5 ++
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 flang/lib/Frontend/CompilerInvocation.cpp | 21 +
 flang/lib/Frontend/FrontendActions.cpp|  3 +
 flang/test/Driver/mcmodel.f90 | 44 ++
 flang/test/Lower/mcmodel.f90  | 16 
 10 files changed, 177 insertions(+), 76 deletions(-)
 create mode 100644 flang/test/Driver/mcmodel.f90
 create mode 100644 flang/test/Lower/mcmodel.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..4087d3b95cc39 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4600,7 +4600,7 @@ def inline_asm_EQ : Joined<["-"], "inline-asm=">, 
Group,
   NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", 
"IAD_Intel"]>,
   MarshallingInfoEnum, "IAD_ATT">;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   MarshallingInfoString, [{"default"}]>;
 def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, 
Group,
   Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1f8591537b6c8..0447581128cd1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5908,81 +5908,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
 
-  if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-StringRef CM = A->getValue();
-bool Ok = false;
-if (Triple.isOSAIX() && CM == "medium")
-  CM = "large";
-if (Triple.isAArch64(64)) {
-  Ok = CM == "tiny" || CM == "small" || CM == "large";
-  if (CM == "large" && !Triple.isOSBinFormatMachO() &&
-  RelocationModel != llvm::Reloc::Static)
-D.Diag(diag::err_drv_argument_only_allowed_with)
-<< A->getAsString(Args) << "-fno-pic";
-} else if (Triple.isLoongArch()) {
-  if (CM == "extreme" &&
-  Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
-D.Diag(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "-fplt";
-  Ok = CM == "normal" || CM == "medium" || CM == "extreme";
-  // Convert to LLVM recognizable names.
-  if (Ok)
-CM = llvm::StringSwitch(CM)
- .Case("normal", "small")
- .Case("extreme", "large")
- .Default(CM);
-} else if (Triple.isPPC64() || Triple.isOSAIX()) {
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-} else if (Triple.isRISCV()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medany")
-CM = "medium";
-  Ok = CM == "small" || CM == "medium";
-} else if (Triple.getArch() == llvm::Triple::x86_64) {
-  Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
-  CM);
-} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
-  // NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
-  // whatever works for the host.
-  Ok = true;
-} else if (Triple.isSPARC64()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medmid")
-CM = "medium";
-  else if (CM == "medany")
-CM = "large";
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-}
-if (Ok) {
-  CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
-} else {
-  D.Diag(diag::err_drv_unsupported_option_argument_for_target)
-  << A->getSpelling() << CM << TripleStr;
-}
-  }
-
-  if (Triple.getArch() == llvm::Triple::x86_64) {
-bool IsMediumCM = false;
-bool IsLargeCM = false;
-if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-  IsMediumCM = StringRef(A->getValue()) == "medium";
-  IsLargeCM = StringRef(A->getValue()) == "large";
-}
-if (Arg *A = Args.getLastArg(options::OPT_ml

[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits


@@ -39,6 +39,7 @@ ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, 
llvm::Reloc::PIC_) ///<
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
+ENUM_CODEGENOPT(CodeModel, llvm::CodeModel::Model, 5, 
llvm::CodeModel::Model::Small)

Leporacanthicus wrote:

This code is no longer present. 

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-07-01 Thread Mats Petersson via cfe-commits


@@ -39,6 +39,7 @@ ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, 
llvm::Reloc::PIC_) ///<
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
+ENUM_CODEGENOPT(CodeModel, llvm::CodeModel::Model, 5, 
llvm::CodeModel::Model::Small)

Leporacanthicus wrote:

Rightly or wrongly, I've changed it to copy the way that Clang does it, and 
store the string in CodeGenOptions, then parse it (twice, but sharing the code 
to do so, rather than implementing the same-ish code twice in Clang). 

https://github.com/llvm/llvm-project/pull/95411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Implement -mcmodel flag (PR #95411)

2024-06-28 Thread Mats Petersson via cfe-commits

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

>From 0ef4b61d0429517b92f7b6de7fa52c516f3a1468 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Thu, 13 Jun 2024 14:01:36 +
Subject: [PATCH 1/3] [flang] Implement -mcmodel flag

This patch implements the -mcmodel flag from clang, allowing the Code Model to
be changed for the LLVM module. The same set of mcmodel flags are accepted as
in clang and the same Code Model attributes are added to the LLVM module for
those flags.
---
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 76 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 81 +++
 clang/lib/Driver/ToolChains/CommonArgs.h  |  4 +
 clang/lib/Driver/ToolChains/Flang.cpp |  5 ++
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 flang/lib/Frontend/CompilerInvocation.cpp | 21 +
 flang/lib/Frontend/FrontendActions.cpp|  3 +
 flang/test/Driver/mcmodel.f90 | 44 ++
 flang/test/Lower/mcmodel.f90  | 16 
 10 files changed, 177 insertions(+), 76 deletions(-)
 create mode 100644 flang/test/Driver/mcmodel.f90
 create mode 100644 flang/test/Lower/mcmodel.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..4087d3b95cc39 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4600,7 +4600,7 @@ def inline_asm_EQ : Joined<["-"], "inline-asm=">, 
Group,
   NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", 
"IAD_Intel"]>,
   MarshallingInfoEnum, "IAD_ATT">;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   MarshallingInfoString, [{"default"}]>;
 def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, 
Group,
   Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1f8591537b6c8..0447581128cd1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5908,81 +5908,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
 
-  if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-StringRef CM = A->getValue();
-bool Ok = false;
-if (Triple.isOSAIX() && CM == "medium")
-  CM = "large";
-if (Triple.isAArch64(64)) {
-  Ok = CM == "tiny" || CM == "small" || CM == "large";
-  if (CM == "large" && !Triple.isOSBinFormatMachO() &&
-  RelocationModel != llvm::Reloc::Static)
-D.Diag(diag::err_drv_argument_only_allowed_with)
-<< A->getAsString(Args) << "-fno-pic";
-} else if (Triple.isLoongArch()) {
-  if (CM == "extreme" &&
-  Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false))
-D.Diag(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "-fplt";
-  Ok = CM == "normal" || CM == "medium" || CM == "extreme";
-  // Convert to LLVM recognizable names.
-  if (Ok)
-CM = llvm::StringSwitch(CM)
- .Case("normal", "small")
- .Case("extreme", "large")
- .Default(CM);
-} else if (Triple.isPPC64() || Triple.isOSAIX()) {
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-} else if (Triple.isRISCV()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medany")
-CM = "medium";
-  Ok = CM == "small" || CM == "medium";
-} else if (Triple.getArch() == llvm::Triple::x86_64) {
-  Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"},
-  CM);
-} else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) {
-  // NVPTX/AMDGPU/SPIRV does not care about the code model and will accept
-  // whatever works for the host.
-  Ok = true;
-} else if (Triple.isSPARC64()) {
-  if (CM == "medlow")
-CM = "small";
-  else if (CM == "medmid")
-CM = "medium";
-  else if (CM == "medany")
-CM = "large";
-  Ok = CM == "small" || CM == "medium" || CM == "large";
-}
-if (Ok) {
-  CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
-} else {
-  D.Diag(diag::err_drv_unsupported_option_argument_for_target)
-  << A->getSpelling() << CM << TripleStr;
-}
-  }
-
-  if (Triple.getArch() == llvm::Triple::x86_64) {
-bool IsMediumCM = false;
-bool IsLargeCM = false;
-if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
-  IsMediumCM = StringRef(A->getValue()) == "medium";
-  IsLargeCM = StringRef(A->getValue()) == "large";
-}
-if (Arg *A = Args.getLastArg(options::OPT_ml

[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-18 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/92430
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-17 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

> progress?

I'm afraid I'm still waiting for review from some of the key people here. 
Apparently there was some OpenMP conference last week, which kept some people 
very busy, so I'm hoping by the time they've read emails and got over jet-lag, 
etc, they'll get round to this.

https://github.com/llvm/llvm-project/pull/92430
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-12 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-11 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus commented:

Nit-pick, otherwise OK by me.

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-11 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus edited 
https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-11 Thread Mats Petersson via cfe-commits


@@ -0,0 +1,15 @@
+! Test -mlink-builtin-bitcode flag
+! RUN: %flang -emit-llvm -c -o %t.bc %S/Inputs/libfun.f90
+! RUN: %flang_fc1 -emit-llvm -o - -mlink-builtin-bitcode %t.bc %s 2>&1 | 
FileCheck %s
+
+! CHECK: define internal void @libfun_
+
+! RUN: not %flang_fc1 -emit-llvm -triple x86_64-unknown-linux-gnu -o - 
-mlink-builtin-bitcode %no-%t.bc %s 2>&1 | FileCheck %s --check-prefix=ERROR

Leporacanthicus wrote:

My guess is that this doesn't need a triple [and probably never did]? So to 
keep it "architecture independent", perhaps remove that?  It's nit-picky, but I 
think it's useful to avoid having any reference to architecture/OS things in 
the tests when they don't HAVE to.

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-07 Thread Mats Petersson via cfe-commits


@@ -1146,6 +1150,54 @@ void CodeGenAction::embedOffloadObjects() {
   }
 }
 
+void CodeGenAction::linkBuiltinBCLibs() {

Leporacanthicus wrote:

This is a fairly large chunk of code - does it come from Clang in some way - if 
so, is it possible to have one common function shared, rather than two copies?

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-07 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus edited 
https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-07 Thread Mats Petersson via cfe-commits




Leporacanthicus wrote:

Would it be possible to generate this, rather than supply it as a binary - just 
out of safety-concerns with binaries, really.

I expect the contents isn't particularly complex or time-consuming to build.

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)

2024-06-07 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus commented:

Overall looks good. Minor nits on "binary files in repo" and duplication of 
code [although I couldn't find the corresponding bit in Clang - I didn't spend 
much time on searching for it].

https://github.com/llvm/llvm-project/pull/94763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-07 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

@ergawy Could you take a look at this, given that you did something similar 
[even if it was much smaller] recently?

https://github.com/llvm/llvm-project/pull/92430
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-06 Thread Mats Petersson via cfe-commits

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

>From 629f5785738fdc52d4dc8d193aa43b3d011b1039 Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 19 Apr 2024 18:00:58 +0100
Subject: [PATCH 1/6] Fix for changed code at the end of AllocaIP.

Some of the OpenMP code can change the instruction pointed at by
the insertion point. This leads to an assert in the compiler about
BB->getParent() and IP->getParent() not matching or something like
that.

The fix is to rebuild the insertionpoint from the block, rather
than use builder.restoreIP.

Also, move some of the alloca generation, rather than skipping back
and forth between insert points (and ensure all the allocas are done
before their users are created).

A simple test, mainly to ensure the minimal reproducer doesn't fail
to compile in the future is also added.
---
 .../OpenMP/parallel-reduction-allocate.f90| 23 +++
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 11 ++---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 22 +++---
 3 files changed, 45 insertions(+), 11 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/parallel-reduction-allocate.f90

diff --git a/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90 
b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
new file mode 100644
index 0..fddce25ae22cc
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
@@ -0,0 +1,23 @@
+!! The main point of this test is to check that the code compiles at all, so 
the
+!! checking is not very detailed. Not hitting an assert, crashing or otherwise 
failing
+!! to compile is the key point. Also, emitting llvm is required for this to 
happen.
+! RUN: %flang_fc1 -emit-llvm -fopenmp -o - %s 2>&1 | FileCheck %s
+subroutine proc
+  implicit none
+  real(8),allocatable :: F(:)
+  real(8),allocatable :: A(:)
+
+!$omp parallel private(A) reduction(+:F)
+  allocate(A(10))
+!$omp end parallel
+end subroutine proc
+
+!CHECK-LABEL: define void @proc_()
+!CHECK: call void
+!CHECK-SAME: @__kmpc_fork_call(ptr {{.*}}, i32 1, ptr @[[OMP_PAR:.*]], {{.*}})
+
+!CHECK: define internal void @[[OMP_PAR]]
+!CHECK: omp.par.region8:
+!CHECK-NEXT: call ptr @malloc
+!CHECK-SAME: i64 10
+
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 2c4b45255d059..d423b545a1faf 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1391,7 +1391,8 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
 
   // Change the location to the outer alloca insertion point to create and
   // initialize the allocas we pass into the parallel region.
-  Builder.restoreIP(OuterAllocaIP);
+  InsertPointTy NewOuter(OuterAllocaBlock, OuterAllocaBlock->begin());
+  Builder.restoreIP(NewOuter);
   AllocaInst *TIDAddrAlloca = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
   AllocaInst *ZeroAddrAlloca =
   Builder.CreateAlloca(Int32, nullptr, "zero.addr");
@@ -2155,7 +2156,8 @@ OpenMPIRBuilder::createReductions(const 
LocationDescription &Loc,
   // values.
   unsigned NumReductions = ReductionInfos.size();
   Type *RedArrayTy = ArrayType::get(Builder.getPtrTy(), NumReductions);
-  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+  //  Builder.restoreIP(AllocaIP);
   Value *RedArray = Builder.CreateAlloca(RedArrayTy, nullptr, "red.array");
 
   Builder.SetInsertPoint(InsertBlock, InsertBlock->end());
@@ -2556,7 +2558,10 @@ OpenMPIRBuilder::applyStaticWorkshareLoop(DebugLoc DL, 
CanonicalLoopInfo *CLI,
   getOrCreateRuntimeFunction(M, omp::OMPRTL___kmpc_for_static_fini);
 
   // Allocate space for computed loop bounds as expected by the "init" 
function.
-  Builder.restoreIP(AllocaIP);
+
+  //  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+
   Type *I32Type = Type::getInt32Ty(M.getContext());
   Value *PLastIter = Builder.CreateAlloca(I32Type, nullptr, "p.lastiter");
   Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 6ec4c120c11ea..47b07248ba84d 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1154,6 +1154,17 @@ convertOmpParallel(omp::ParallelOp opInst, 
llvm::IRBuilderBase &builder,
 MutableArrayRef reductionArgs =
 opInst.getRegion().getArguments().take_back(
 opInst.getNumReductionVars());
+
+SmallVector byRefVars;
+if (isByRef) {
+  for (unsigned i = 0; i < opInst.getNumReductionVars(); ++i) {
+// Allocate reduction variable (which is a pointer to the real 
reduciton
+// variable allocated in the inlined region)
+byRefVars.p

[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-06 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

> Allocas should be placed at the start of the entry block.

Would it be acceptable to make this change such that the alloca's are at the 
very start of the block? I have tried that, and it seems to work. It will still 
mean changes to the tests, and I can't guarantee ALL alloca's for all Fortran 
(via MLIR) generated code will be at the start of the entry block.

We have a further ticket to clean this up, but it's a bigger task, which we 
will do, but it will take a few weeks at least.

https://github.com/llvm/llvm-project/pull/92430
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-05 Thread Mats Petersson via cfe-commits

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

>From 629f5785738fdc52d4dc8d193aa43b3d011b1039 Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 19 Apr 2024 18:00:58 +0100
Subject: [PATCH 1/6] Fix for changed code at the end of AllocaIP.

Some of the OpenMP code can change the instruction pointed at by
the insertion point. This leads to an assert in the compiler about
BB->getParent() and IP->getParent() not matching or something like
that.

The fix is to rebuild the insertionpoint from the block, rather
than use builder.restoreIP.

Also, move some of the alloca generation, rather than skipping back
and forth between insert points (and ensure all the allocas are done
before their users are created).

A simple test, mainly to ensure the minimal reproducer doesn't fail
to compile in the future is also added.
---
 .../OpenMP/parallel-reduction-allocate.f90| 23 +++
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 11 ++---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 22 +++---
 3 files changed, 45 insertions(+), 11 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/parallel-reduction-allocate.f90

diff --git a/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90 
b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
new file mode 100644
index 00..fddce25ae22ccf
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
@@ -0,0 +1,23 @@
+!! The main point of this test is to check that the code compiles at all, so 
the
+!! checking is not very detailed. Not hitting an assert, crashing or otherwise 
failing
+!! to compile is the key point. Also, emitting llvm is required for this to 
happen.
+! RUN: %flang_fc1 -emit-llvm -fopenmp -o - %s 2>&1 | FileCheck %s
+subroutine proc
+  implicit none
+  real(8),allocatable :: F(:)
+  real(8),allocatable :: A(:)
+
+!$omp parallel private(A) reduction(+:F)
+  allocate(A(10))
+!$omp end parallel
+end subroutine proc
+
+!CHECK-LABEL: define void @proc_()
+!CHECK: call void
+!CHECK-SAME: @__kmpc_fork_call(ptr {{.*}}, i32 1, ptr @[[OMP_PAR:.*]], {{.*}})
+
+!CHECK: define internal void @[[OMP_PAR]]
+!CHECK: omp.par.region8:
+!CHECK-NEXT: call ptr @malloc
+!CHECK-SAME: i64 10
+
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 2c4b45255d059c..d423b545a1faf3 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1391,7 +1391,8 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
 
   // Change the location to the outer alloca insertion point to create and
   // initialize the allocas we pass into the parallel region.
-  Builder.restoreIP(OuterAllocaIP);
+  InsertPointTy NewOuter(OuterAllocaBlock, OuterAllocaBlock->begin());
+  Builder.restoreIP(NewOuter);
   AllocaInst *TIDAddrAlloca = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
   AllocaInst *ZeroAddrAlloca =
   Builder.CreateAlloca(Int32, nullptr, "zero.addr");
@@ -2155,7 +2156,8 @@ OpenMPIRBuilder::createReductions(const 
LocationDescription &Loc,
   // values.
   unsigned NumReductions = ReductionInfos.size();
   Type *RedArrayTy = ArrayType::get(Builder.getPtrTy(), NumReductions);
-  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+  //  Builder.restoreIP(AllocaIP);
   Value *RedArray = Builder.CreateAlloca(RedArrayTy, nullptr, "red.array");
 
   Builder.SetInsertPoint(InsertBlock, InsertBlock->end());
@@ -2556,7 +2558,10 @@ OpenMPIRBuilder::applyStaticWorkshareLoop(DebugLoc DL, 
CanonicalLoopInfo *CLI,
   getOrCreateRuntimeFunction(M, omp::OMPRTL___kmpc_for_static_fini);
 
   // Allocate space for computed loop bounds as expected by the "init" 
function.
-  Builder.restoreIP(AllocaIP);
+
+  //  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+
   Type *I32Type = Type::getInt32Ty(M.getContext());
   Value *PLastIter = Builder.CreateAlloca(I32Type, nullptr, "p.lastiter");
   Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 6ec4c120c11ea5..47b07248ba84d6 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1154,6 +1154,17 @@ convertOmpParallel(omp::ParallelOp opInst, 
llvm::IRBuilderBase &builder,
 MutableArrayRef reductionArgs =
 opInst.getRegion().getArguments().take_back(
 opInst.getNumReductionVars());
+
+SmallVector byRefVars;
+if (isByRef) {
+  for (unsigned i = 0; i < opInst.getNumReductionVars(); ++i) {
+// Allocate reduction variable (which is a pointer to the real 
reduciton
+// variable allocated in the inlined region)
+byRef

[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-05 Thread Mats Petersson via cfe-commits


@@ -0,0 +1,23 @@
+!! The main point of this test is to check that the code compiles at all, so 
the

Leporacanthicus wrote:

I have created an internal ticket to improve the code generation. It's just a 
much bigger task than this one started out as. I then found more problems, so 
this took much longer than I expected.

https://github.com/llvm/llvm-project/pull/92430
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)

2024-06-04 Thread Mats Petersson via cfe-commits

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

>From e08c19ced1b2bcdd4a83ffcd3c5f5656c2021d52 Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 19 Apr 2024 18:00:58 +0100
Subject: [PATCH 1/5] Fix for changed code at the end of AllocaIP.

Some of the OpenMP code can change the instruction pointed at by
the insertion point. This leads to an assert in the compiler about
BB->getParent() and IP->getParent() not matching or something like
that.

The fix is to rebuild the insertionpoint from the block, rather
than use builder.restoreIP.

Also, move some of the alloca generation, rather than skipping back
and forth between insert points (and ensure all the allocas are done
before their users are created).

A simple test, mainly to ensure the minimal reproducer doesn't fail
to compile in the future is also added.
---
 .../OpenMP/parallel-reduction-allocate.f90| 23 +++
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 11 ++---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 22 +++---
 3 files changed, 45 insertions(+), 11 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/parallel-reduction-allocate.f90

diff --git a/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90 
b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
new file mode 100644
index 0..fddce25ae22cc
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-reduction-allocate.f90
@@ -0,0 +1,23 @@
+!! The main point of this test is to check that the code compiles at all, so 
the
+!! checking is not very detailed. Not hitting an assert, crashing or otherwise 
failing
+!! to compile is the key point. Also, emitting llvm is required for this to 
happen.
+! RUN: %flang_fc1 -emit-llvm -fopenmp -o - %s 2>&1 | FileCheck %s
+subroutine proc
+  implicit none
+  real(8),allocatable :: F(:)
+  real(8),allocatable :: A(:)
+
+!$omp parallel private(A) reduction(+:F)
+  allocate(A(10))
+!$omp end parallel
+end subroutine proc
+
+!CHECK-LABEL: define void @proc_()
+!CHECK: call void
+!CHECK-SAME: @__kmpc_fork_call(ptr {{.*}}, i32 1, ptr @[[OMP_PAR:.*]], {{.*}})
+
+!CHECK: define internal void @[[OMP_PAR]]
+!CHECK: omp.par.region8:
+!CHECK-NEXT: call ptr @malloc
+!CHECK-SAME: i64 10
+
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index cb4de9c8876dc..e76197ea6c9c7 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1391,7 +1391,8 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
 
   // Change the location to the outer alloca insertion point to create and
   // initialize the allocas we pass into the parallel region.
-  Builder.restoreIP(OuterAllocaIP);
+  InsertPointTy NewOuter(OuterAllocaBlock, OuterAllocaBlock->begin());
+  Builder.restoreIP(NewOuter);
   AllocaInst *TIDAddrAlloca = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
   AllocaInst *ZeroAddrAlloca =
   Builder.CreateAlloca(Int32, nullptr, "zero.addr");
@@ -2151,7 +2152,8 @@ OpenMPIRBuilder::createReductions(const 
LocationDescription &Loc,
   // values.
   unsigned NumReductions = ReductionInfos.size();
   Type *RedArrayTy = ArrayType::get(Builder.getPtrTy(), NumReductions);
-  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+  //  Builder.restoreIP(AllocaIP);
   Value *RedArray = Builder.CreateAlloca(RedArrayTy, nullptr, "red.array");
 
   Builder.SetInsertPoint(InsertBlock, InsertBlock->end());
@@ -2552,7 +2554,10 @@ OpenMPIRBuilder::applyStaticWorkshareLoop(DebugLoc DL, 
CanonicalLoopInfo *CLI,
   getOrCreateRuntimeFunction(M, omp::OMPRTL___kmpc_for_static_fini);
 
   // Allocate space for computed loop bounds as expected by the "init" 
function.
-  Builder.restoreIP(AllocaIP);
+
+  //  Builder.restoreIP(AllocaIP);
+  Builder.SetInsertPoint(AllocaIP.getBlock()->getTerminator());
+
   Type *I32Type = Type::getInt32Ty(M.getContext());
   Value *PLastIter = Builder.CreateAlloca(I32Type, nullptr, "p.lastiter");
   Value *PLowerBound = Builder.CreateAlloca(IVTy, nullptr, "p.lowerbound");
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 6ec4c120c11ea..47b07248ba84d 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1154,6 +1154,17 @@ convertOmpParallel(omp::ParallelOp opInst, 
llvm::IRBuilderBase &builder,
 MutableArrayRef reductionArgs =
 opInst.getRegion().getArguments().take_back(
 opInst.getNumReductionVars());
+
+SmallVector byRefVars;
+if (isByRef) {
+  for (unsigned i = 0; i < opInst.getNumReductionVars(); ++i) {
+// Allocate reduction variable (which is a pointer to the real 
reduciton
+// variable allocated in the inlined region)
+byRefVars.p

[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-04-05 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/86816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits

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

>From 372995f4e755e3c0bc4a0b5dd09e27c21a3faf2e Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 15 Mar 2024 17:38:52 +
Subject: [PATCH 1/2] [FLANG] allow -fopenmp=

This enables the -fopenmp= option to the set of options
supported by flang.

The generated arguments for the FC1 compilation will appear in a
slightly different order, so one test had to be updated to be less
sensitive to order of the arguments.
---
 clang/include/clang/Driver/Options.td|  3 +-
 clang/lib/Driver/ToolChains/Flang.cpp| 28 ++-
 flang/test/Driver/fopenmp.f90| 60 
 flang/test/Driver/omp-driver-offload.f90 |  9 +++-
 4 files changed, 95 insertions(+), 5 deletions(-)
 create mode 100644 flang/test/Driver/fopenmp.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aca8c9b0d5487a..3e78dada51a1b3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3403,7 +3403,8 @@ defm openmp_extensions: BoolFOption<"openmp-extensions",
   "Enable all Clang extensions for OpenMP directives and clauses">,
   NegFlag>;
-def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
+def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
 def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 6168b42dc78292..97326c2ed13f3c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -38,8 +38,6 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
   Args.addAllArgs(CmdArgs, {options::OPT_ffixed_form,
 options::OPT_ffree_form,
 options::OPT_ffixed_line_length_EQ,
-options::OPT_fopenmp,
-options::OPT_fopenmp_version_EQ,
 options::OPT_fopenacc,
 options::OPT_finput_charset_EQ,
 options::OPT_fimplicit_none,
@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.
+  break;
+default:
+  // By default, if Clang doesn't know how to generate useful OpenMP code
+  // for a specific runtime library, we just don't pass the '-fopenmp' flag
+  // down to the actual compilation.
+  // FIXME: It would be better to have a mode which *only* omits IR
+  // generation based on the OpenMP support so that we get consistent
+  // semantic analysis, etc.
+  break;
+}
+  }
+
   // Offloading related options
   addOffloadOptions(C, Inputs, JA, Args, CmdArgs);
 
diff --git a/flang/test/Driver/fopenmp.f90 b/flang/test/Driver/fopenmp.f90
new file mode 100644
index 00..068134a97a19d0
--- /dev/null
+++ b/flang/test/Driver/fopenmp.f90
@@ -0,0 +1,60 @@
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-NO-OPENMP
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-NO-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-freebsd -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-freebsd -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-NO-OPENMP
+! RUN: %flang -target x86_64-freebsd -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %

[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits


@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.
+  break;
+default:

Leporacanthicus wrote:

So, it definitely is done this way on purpose - see clang/test/Driver/fopenmp.c 
(only "interesting" lines)
``` // RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
...
// CHECK-CC1-OPENMP: "-cc1"
// CHECK-CC1-OPENMP: "-fopenmp"
//
// CHECK-CC1-NO-OPENMP: "-cc1"
// CHECK-CC1-NO-OPENMP-NOT: "-fopenmp"
```
We can certainly add a warning or error, but Clang doesn't... :)


https://github.com/llvm/llvm-project/pull/86816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits


@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.
+  break;
+default:

Leporacanthicus wrote:

Yes, behaving the same way as clang here.

https://github.com/llvm/llvm-project/pull/86816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits


@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.

Leporacanthicus wrote:

Roughly this bunch.

```  // If no option regarding the use of TLS in OpenMP codegeneration is
  // given, decide a default based on the target. Otherwise rely on the
  // options and pass the right information to the frontend.
  if (!Args.hasFlag(options::OPT_fopenmp_use_tls,
options::OPT_fnoopenmp_use_tls, /*Default=*/true))
CmdArgs.push_back("-fnoopenmp-use-tls");
  Args.AddLastArg(CmdArgs, options::OPT_fopenmp_simd,
  options::OPT_fno_openmp_simd);
  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_enable_irbuilder);
  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
  if (!Args.hasFlag(options::OPT_fopenmp_extensions,
options::OPT_fno_openmp_extensions, /*Default=*/true))
CmdArgs.push_back("-fno-openmp-extensions");
  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_cuda_number_of_sm_EQ);
  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_cuda_blocks_per_sm_EQ);
  Args.AddAllArgs(CmdArgs,
  options::OPT_fopenmp_cuda_teams_reduction_recs_num_EQ);
  if (Args.hasFlag(options::OPT_fopenmp_optimistic_collapse,
   options::OPT_fno_openmp_optimistic_collapse,
   /*Default=*/false))
CmdArgs.push_back("-fopenmp-optimistic-collapse");

  // When in OpenMP offloading mode with NVPTX target, forward
  // cuda-mode flag
  if (Args.hasFlag(options::OPT_fopenmp_cuda_mode,
   options::OPT_fno_openmp_cuda_mode, /*Default=*/false))
CmdArgs.push_back("-fopenmp-cuda-mode");

  // When in OpenMP offloading mode, enable debugging on the device.
  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_target_debug_EQ);
  if (Args.hasFlag(options::OPT_fopenmp_target_debug,
   options::OPT_fno_openmp_target_debug, /*Default=*/false))
CmdArgs.push_back("-fopenmp-target-debug");

  // When in OpenMP offloading mode, forward assumptions information about
  // thread and team counts in the device.
  if (Args.hasFlag(options::OPT_fopenmp_assume_teams_oversubscription,
   options::OPT_fno_openmp_assume_teams_oversubscription,
   /*Default=*/false))
CmdArgs.push_back("-fopenmp-assume-teams-oversubscription");
  if (Args.hasFlag(options::OPT_fopenmp_assume_threads_oversubscription,
   options::OPT_fno_openmp_assume_threads_oversubscription,
   /*Default=*/false))
CmdArgs.push_back("-fopenmp-assume-threads-oversubscription");
  if (Args.hasArg(options::OPT_fopenmp_assume_no_thread_state))
CmdArgs.push_back("-fopenmp-assume-no-thread-state");
  if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
  if (Args.hasArg(options::OPT_fopenmp_offload_mandatory))
CmdArgs.push_back("-fopenmp-offload-mandatory");
  if (Args.hasArg(options::OPT_fopenmp_force_usm))
CmdArgs.push_back("-fopenmp-force-usm");
```



https://github.com/llvm/llvm-project/pull/86816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits


@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.
+  break;
+default:

Leporacanthicus wrote:

This is what Clang does in this place. I'm not sure I understand why.

https://github.com/llvm/llvm-project/pull/86816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [FLANG] allow -fopenmp= (PR #86816)

2024-03-27 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus created 
https://github.com/llvm/llvm-project/pull/86816

This enables the -fopenmp= option to the set of options supported by 
flang.

The generated arguments for the FC1 compilation will appear in a slightly 
different order, so one test had to be updated to be less sensitive to order of 
the arguments.

>From 372995f4e755e3c0bc4a0b5dd09e27c21a3faf2e Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 15 Mar 2024 17:38:52 +
Subject: [PATCH] [FLANG] allow -fopenmp=

This enables the -fopenmp= option to the set of options
supported by flang.

The generated arguments for the FC1 compilation will appear in a
slightly different order, so one test had to be updated to be less
sensitive to order of the arguments.
---
 clang/include/clang/Driver/Options.td|  3 +-
 clang/lib/Driver/ToolChains/Flang.cpp| 28 ++-
 flang/test/Driver/fopenmp.f90| 60 
 flang/test/Driver/omp-driver-offload.f90 |  9 +++-
 4 files changed, 95 insertions(+), 5 deletions(-)
 create mode 100644 flang/test/Driver/fopenmp.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aca8c9b0d5487a..3e78dada51a1b3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3403,7 +3403,8 @@ defm openmp_extensions: BoolFOption<"openmp-extensions",
   "Enable all Clang extensions for OpenMP directives and clauses">,
   NegFlag>;
-def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
+def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
 def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 6168b42dc78292..97326c2ed13f3c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -38,8 +38,6 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
   Args.addAllArgs(CmdArgs, {options::OPT_ffixed_form,
 options::OPT_ffree_form,
 options::OPT_ffixed_line_length_EQ,
-options::OPT_fopenmp,
-options::OPT_fopenmp_version_EQ,
 options::OPT_fopenacc,
 options::OPT_finput_charset_EQ,
 options::OPT_fimplicit_none,
@@ -764,6 +762,32 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action other than OpenMP.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false) &&
+  (JA.isDeviceOffloading(Action::OFK_None) ||
+   JA.isDeviceOffloading(Action::OFK_OpenMP))) {
+switch (D.getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+case Driver::OMPRT_IOMP5:
+  // Clang can generate useful OpenMP code for these two runtime libraries.
+  CmdArgs.push_back("-fopenmp");
+  Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
+
+  // FIXME: Clang supports a whole bunch more flags here.
+  break;
+default:
+  // By default, if Clang doesn't know how to generate useful OpenMP code
+  // for a specific runtime library, we just don't pass the '-fopenmp' flag
+  // down to the actual compilation.
+  // FIXME: It would be better to have a mode which *only* omits IR
+  // generation based on the OpenMP support so that we get consistent
+  // semantic analysis, etc.
+  break;
+}
+  }
+
   // Offloading related options
   addOffloadOptions(C, Inputs, JA, Args, CmdArgs);
 
diff --git a/flang/test/Driver/fopenmp.f90 b/flang/test/Driver/fopenmp.f90
new file mode 100644
index 00..068134a97a19d0
--- /dev/null
+++ b/flang/test/Driver/fopenmp.f90
@@ -0,0 +1,60 @@
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-NO-OPENMP
+! RUN: %flang -target x86_64-linux-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-NO-OPENMP
+! RUN: %flang -target x86_64-apple-darwin -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FC1-OPENMP
+! RUN: %flang -target x86_64-freebsd -fopenmp=libomp -c %s -### 2>&1 | 
FileChe

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

2024-02-05 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

Thanks for letting me klnow. I have a fix in 
https://github.com/llvm/llvm-project/pull/80717

I'm not entirely sure why it's broken on Arm but not x86 - the tests run on 
both, and should give identical output [but clearly doesn't].

--
Mats
[https://opengraph.githubassets.com/ce56cc443042f8ad8e40eab60d1e7385e82143e2d8f23e4ebfed483158d90a84/llvm/llvm-project/pull/80717]
Fix broken ARM processor features test by Leporacanthicus ・ Pull Request #80717 
・ llvm/llvm-project
This test failed when I pulled latest changes. I suspect it's my fault...
github.com


From: Valentin Clement (バレンタイン クレメン) ***@***.***>
Sent: 05 February 2024 18:14
To: llvm/llvm-project ***@***.***>
Cc: Mats Petersson ***@***.***>; State change ***@***.***>
Subject: Re: [llvm/llvm-project] [flang]Add support for -moutline-atomics and 
-mno-outline-atomics (PR #78755)


This is breaking couple of arm buildbots.

―
Reply to this email directly, view it on 
GitHub,
 or 
unsubscribe.
You are receiving this because you modified the open/close state.Message ID: 
***@***.***>

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


https://github.com/llvm/llvm-project/pull/78755
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-02-05 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/78755
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-02-02 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/7] [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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-02-02 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/6] [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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-02-02 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/5] [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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-02-02 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-01-31 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/3] [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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-01-31 Thread Mats Petersson via cfe-commits

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 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/2] [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,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-01-31 Thread Mats Petersson via cfe-commits

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

>From 1bf1060607dc8d4fedb227de35271e0b0307f564 Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH 1/2] [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 d2e6c3ff721c2..b8be694bf0bf8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4960,10 +4960,10 @@ def mno_fmv : Flag<["-"], "mno-fmv">, 
Group,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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 03d68c3df7fb3..7394ef6f601c7 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -354,6 +354,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:
@@ -674,7 +695,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
 
   if (isa(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 {
+o

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

2024-01-19 Thread Mats Petersson via cfe-commits

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

This adds the support to add the target-feature.

It will be fully supported once the generic support for adding target-cpu and 
target-features attributes to functions has landed. See #78289. Regression 
tests for that will be added once that PR lands. 



>From 1bf1060607dc8d4fedb227de35271e0b0307f564 Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 19 Jan 2024 16:30:31 +
Subject: [PATCH] [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 d2e6c3ff721c27..b8be694bf0bf80 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4960,10 +4960,10 @@ def mno_fmv : Flag<["-"], "mno-fmv">, 
Group,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable function multiversioning">;
 def moutline_atomics : Flag<["-"], "moutline-atomics">, 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,
-  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,
   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 03d68c3df7fb37..7394ef6f601c7e 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -354,6 +354,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:
@@ -674,7 +695,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
 
   if (isa(JA)) {
-  CmdArgs.push_back("-E");
+CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(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 a3c41fb4611f56..74127327e798e6 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 s

[clang] [clang-tools-extra] [flang] [llvm] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-28 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [flang] Enable alias tags pass by default (PR #73111)

2023-11-22 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/73111
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [flang] Enable alias tags pass by default (PR #73111)

2023-11-22 Thread Mats Petersson via cfe-commits


@@ -242,10 +242,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
clang::driver::options::OPT_fno_loop_versioning, false))
 opts.LoopVersioning = 1;
 
-  opts.AliasAnalysis =
-  args.hasFlag(clang::driver::options::OPT_falias_analysis,
-   clang::driver::options::OPT_fno_alias_analysis,
-   /*default=*/false);
+  bool aliasAnalysis = false;
+  bool noAliasAnalysis = false;
+  if (auto *arg =
+  args.getLastArg(clang::driver::options::OPT_falias_analysis,
+  clang::driver::options::OPT_fno_alias_analysis)) {
+if (arg->getOption().matches(clang::driver::options::OPT_falias_analysis))
+  aliasAnalysis = true;
+else
+  noAliasAnalysis = true;
+  }
+  opts.AliasAnalysis = 0;
+  if (opts.OptimizationLevel > 0) {
+if (!noAliasAnalysis)
+  opts.AliasAnalysis = 1;

Leporacanthicus wrote:

Is there a reason that AliasAnalysis is an integer, rather than a boolean?

https://github.com/llvm/llvm-project/pull/73111
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [flang] Enable alias tags pass by default (PR #73111)

2023-11-22 Thread Mats Petersson via cfe-commits


@@ -311,7 +311,7 @@ inline void createDefaultFIRCodeGenPassPipeline(
   if (config.VScaleMin != 0)
 pm.addPass(fir::createVScaleAttrPass({config.VScaleMin, 
config.VScaleMax}));
 
-  fir::addFIRToLLVMPass(pm, config.OptLevel);
+  fir::addFIRToLLVMPass(pm, config.OptLevel, config.AliasAnalysis);

Leporacanthicus wrote:

Maybe we can just pass (const reference to) `config` into the 
`addFIRToLLVMPass`?

https://github.com/llvm/llvm-project/pull/73111
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] Add flags controlling whether to run the fir alias tags pass (PR #68595)

2023-10-11 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/68595
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] Add flags controlling whether to run the fir alias tags pass (PR #68595)

2023-10-11 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/68595
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e13bed4 - [PATCH] [llvm] [InstCombine] Canonicalise ADD+GEP

2023-10-06 Thread Mats Petersson via cfe-commits

Author: Dmitriy Smirnov
Date: 2023-10-06T12:29:06+01:00
New Revision: e13bed4c5f3544c076ce57e36d9a11eefa5a7815

URL: 
https://github.com/llvm/llvm-project/commit/e13bed4c5f3544c076ce57e36d9a11eefa5a7815
DIFF: 
https://github.com/llvm/llvm-project/commit/e13bed4c5f3544c076ce57e36d9a11eefa5a7815.diff

LOG: [PATCH] [llvm] [InstCombine] Canonicalise ADD+GEP

This patch tries to canonicalise add + gep to gep + gep.

Co-authored-by: Paul Walker 

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D155688

Added: 


Modified: 
clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll
llvm/test/Transforms/InstCombine/align-addr.ll
llvm/test/Transforms/InstCombine/mem-par-metadata-memcpy.ll
llvm/test/Transforms/InstCombine/memrchr-4.ll
llvm/test/Transforms/InstCombine/shift.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-interleaved-accesses.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
llvm/test/Transforms/LoopVectorize/induction.ll
llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll
llvm/test/Transforms/LoopVectorize/invariant-store-vectorization.ll
llvm/test/Transforms/LoopVectorize/runtime-check.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-loops.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp 
b/clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
index 2ec620eb19d223b..5c4b86744287ec3 100644
--- a/clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
+++ b/clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
@@ -94,9 +94,9 @@ void* test9(B* x) { return dynamic_cast(x); }
 // CHECK-NEXT:   [[VBTBL:%.*]] = load ptr, ptr [[VBPTR]], align 4
 // CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32, ptr [[VBTBL]], 
i32 1
 // CHECK-NEXT:   [[VBOFFS:%.*]] = load i32, ptr [[VBOFFP]], align 4
-// CHECK-NEXT:   [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
-// CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8, ptr %x, i32 [[DELTA]]
-// CHECK-NEXT:   [[CALL:%.*]] = tail call ptr @__RTCastToVoid(ptr nonnull 
[[ADJ]])
+// CHECK-NEXT:   [[BASE:%.*]] = getelementptr i8, ptr %x, i32 [[VBOFFS]]
+// CHECK-NEXT:   [[ADJ:%.*]] = getelementptr i8, ptr [[BASE]], i32 4
+// CHECK-NEXT:   [[CALL:%.*]] = tail call ptr @__RTCastToVoid(ptr [[ADJ]])
 // CHECK-NEXT:   br label
 // CHECK:[[RET:%.*]] = phi ptr
 // CHECK-NEXT:   ret ptr [[RET]]

diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 0ee29149a1aeef2..4736df40951af38 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2316,11 +2316,27 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 return CastInst::CreatePointerBitCastOrAddrSpaceCast(Y, GEPType);
 }
   }
-
   // We do not handle pointer-vector geps here.
   if (GEPType->isVectorTy())
 return nullptr;
 
+  if (GEP.getNumIndices() == 1) {
+// Try to replace ADD + GEP with GEP + GEP.
+Value *Idx1, *Idx2;
+if (match(GEP.getOperand(1),
+  m_OneUse(m_Add(m_Value(Idx1), m_Value(Idx2) {
+  //   %idx = add i64 %idx1, %idx2
+  //   %gep = getelementptr i32, i32* %ptr, i64 %idx
+  // as:
+  //   %newptr = getelementptr i32, i32* %ptr, i64 %idx1
+  //   %newgep = getelementptr i32, i32* %newptr, i64 %idx2
+  auto *NewPtr = Builder.CreateGEP(GEP.getResultElementType(),
+   GEP.getPointerOperand(), Idx1);
+  return GetElementPtrInst::Create(GEP.getResultElementType(), NewPtr,
+   Idx2);
+}
+  }
+
   if (!GEP.isInBounds()) {
 unsigned IdxWidth =
 DL.getIndexSizeInBits(PtrOp->getType()->getPointerAddressSpace());

diff  --git a/llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll 
b/llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll
index 333ecc14e473b6b..24c5e1c2f789a57 100644
--- a/llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll
+++ b/llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll
@@ -12,26 +12,26 @@ target triple = "hexagon"
 define <64 x i16> @f0(ptr %a0, i32 %a1) #0 {
 ; CHECK-LABEL: @f0(
 ; CHECK-NEXT:  b0:
-; CHECK-NEXT:[[V0:%.*]] = add i32 [[A1:%.*]], 64
-; CHECK-NEXT:[[V1:%.*]] = getelementptr i16, ptr [[A0:%.*]], i32 [[V0]]
+; CHECK-NEXT:[[TMP0:%.*]] = getelementptr i16, ptr [[A0:%.*]], i32 
[[A1:%.*]]
+; CHECK-NEXT:[[V1:%.*]] = getelementptr i16, ptr [[TMP0]], i32 64
 ; CHECK-NEXT:[[PTI:%.*]] = ptrtoint ptr [[V1]] to i32
-; CHECK-NEXT:[[ADD:%.*]] = and i32 [[PTI]], -128
-; CHECK-NEXT:[[ITP:%.*]] = inttoptr i32 [[ADD]] to ptr
+; CHECK-NEXT:[[AND:%.*]] = and i32 [[PTI]], -1

[clang] [flang]Add vscale argument parsing (PR #67676)

2023-10-02 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus closed 
https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits

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

>From 17e128e808ecb170b71a4713692cff3dee8d50aa Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 15 Sep 2023 18:52:11 +0100
Subject: [PATCH 1/4] [flang]Add vscale argument parsing

Support for vector scale range arguments, for AArch64 scalable vector
extension (SVE) support.

Adds -msve-vector-bits to the flang frontend, and for flang fc1 the
options are -mvscale-min and -mvscale-max (optional). These match the
clang and clang cc1 options for the same purposes.

A further patch will actually USE these arguments.
---
 clang/include/clang/Driver/Options.td|  5 ++-
 clang/lib/Driver/ToolChains/Flang.cpp| 39 +++-
 clang/lib/Driver/ToolChains/Flang.h  |  7 
 flang/include/flang/Frontend/LangOptions.def |  3 ++
 flang/lib/Frontend/CompilerInvocation.cpp| 37 +++
 flang/lib/Frontend/FrontendActions.cpp   |  1 +
 flang/test/Driver/driver-help-hidden.f90 |  2 +
 flang/test/Driver/driver-help.f90|  4 ++
 8 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f573f5a06ceb501..4e491f7d76c8622 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4550,18 +4550,19 @@ foreach i = {8-15,18} in
 HelpText<"Make the x"#i#" register call-saved (AArch64 only)">;
 
 def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, 
Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify the size in bits of an SVE vector register. Defaults to 
the"
" vector length agnostic value of \"scalable\". (AArch64 only)">;
 } // let Flags = [TargetSpecific]
 
 def mvscale_min_EQ : Joined<["-"], "mvscale-min=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64/RISC-V 
only)">,
   MarshallingInfoInt>;
 def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale maximum. Defaults to the"
" vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
   MarshallingInfoInt>;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 10f785ce7ab9075..ef18048f2f3203b 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -170,6 +170,39 @@ void Flang::addPicOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   }
 }
 
+
+void Flang::AddAArch64TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Handle -msve_vector_bits=
+  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
+Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
+Val.equals("2048+")) {
+  unsigned Bits = 0;
+  if (Val.endswith("+"))
+Val = Val.substr(0, Val.size() - 1);
+  else {
+bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+assert(!Invalid && "Failed to parse value");
+CmdArgs.push_back(
+Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128)));
+  }
+
+  bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+  assert(!Invalid && "Failed to parse value");
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128)));
+// Silently drop requests for vector-length agnostic code as it's implied.
+} else if (!Val.equals("scalable"))
+  // Handle the unsupported values passed to msve-vector-bits.
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Val;
+  }
+}
+
 void Flang::addTargetOptions(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   const ToolChain &TC = getToolChain();
@@ -186,9 +219,13 @@ void Flang::addTargetOptions(const ArgList &Args,
   switch (TC.getArch()) {
   default:
 break;
+  case llvm::Triple::aarch64:
+getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
+AddAArch64TargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::r600:
   case llvm::Triple::amdgcn:
-  case llvm::Triple::aarch64:
   case llvm::Triple::riscv64:
   case llvm::Triple::x86_64:
 getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
diff --git a/clang/lib/Driver/ToolChains/Flang.h 
b/clang/lib/Driver/ToolChains/Flang.h
index 962b4ae601726af..0141240b5d3ac90 100644
--- a/clang/lib/D

[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits


@@ -0,0 +1,55 @@
+! -
+! Tests for the -msve-vector-bits flag (taken from the clang test)
+! -
+
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-128 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=256 2>&1 | FileCheck --check-prefix=CHECK-256 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=512 2>&1 | FileCheck --check-prefix=CHECK-512 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=128+ 2>&1 | FileCheck --check-prefix=CHECK-128P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=256+ 2>&1 | FileCheck --check-prefix=CHECK-256P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=512+ 2>&1 | FileCheck --check-prefix=CHECK-512P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=1024+ 2>&1 | FileCheck --check-prefix=CHECK-1024P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=2048+ 2>&1 | FileCheck --check-prefix=CHECK-2048P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=scalable 2>&1 | FileCheck 
--check-prefix=CHECK-SCALABLE %s
+
+! CHECK-128: "-mvscale-max=1" "-mvscale-min=1"

Leporacanthicus wrote:

It is checking the fc1 command. Just like the clang test is checking the cc1 
command generated by the driver.

So you're saying we should check that it's not catching some other - 
preprocessor, linker or something else that may have got hold of the "right" 
command-line argument?

https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits


@@ -0,0 +1,55 @@
+! -
+! Tests for the -msve-vector-bits flag (taken from the clang test)
+! -
+
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-128 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=256 2>&1 | FileCheck --check-prefix=CHECK-256 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=512 2>&1 | FileCheck --check-prefix=CHECK-512 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=128+ 2>&1 | FileCheck --check-prefix=CHECK-128P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=256+ 2>&1 | FileCheck --check-prefix=CHECK-256P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=512+ 2>&1 | FileCheck --check-prefix=CHECK-512P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=1024+ 2>&1 | FileCheck --check-prefix=CHECK-1024P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=2048+ 2>&1 | FileCheck --check-prefix=CHECK-2048P %s
+! RUN: %flang -c %s -### --target=aarch64-none-linux-gnu -march=armv8-a+sve \
+! RUN:  -msve-vector-bits=scalable 2>&1 | FileCheck 
--check-prefix=CHECK-SCALABLE %s
+
+! CHECK-128: "-mvscale-max=1" "-mvscale-min=1"

Leporacanthicus wrote:

It's like that in the original clang/test/Driver/aarch64-sve-vector-bits.c - I 
just changed it to using a flang instead of clang (and removed a bit of testing 
for attributes for vector range - Fotran doesn't have function attributes, as 
far as I'm aware)

https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus resolved 
https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits


@@ -170,6 +169,38 @@ void Flang::addPicOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   }
 }
 
+void Flang::AddAArch64TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Handle -msve_vector_bits=
+  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
+Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
+Val.equals("2048+")) {
+  unsigned Bits = 0;
+  if (Val.endswith("+"))
+Val = Val.substr(0, Val.size() - 1);

Leporacanthicus wrote:

That's copied directly from clang, and I think it's better to keep them 
identical [although I did modify the [[maybe_unused]] from (void) in the check 
if the conversion worked.

[There's about 200 lines AROUND this bit, that does a bunch of other 
target-specific stuff for aarch64, so I can't just call the clang version of 
this code]

https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-29 Thread Mats Petersson via cfe-commits

Leporacanthicus wrote:

> Please could you add testing, like the tests you wrote for the loop 
> versioning flag.

Tests added.

https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-28 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus resolved 
https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-28 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus resolved 
https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-28 Thread Mats Petersson via cfe-commits

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

>From 25b53fa1d6d52e8f22dcdaaf5c7fbf47132e Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 15 Sep 2023 18:52:11 +0100
Subject: [PATCH 1/3] [flang]Add vscale argument parsing

Support for vector scale range arguments, for AArch64 scalable vector
extension (SVE) support.

Adds -msve-vector-bits to the flang frontend, and for flang fc1 the
options are -mvscale-min and -mvscale-max (optional). These match the
clang and clang cc1 options for the same purposes.

A further patch will actually USE these arguments.
---
 clang/include/clang/Driver/Options.td|  5 ++-
 clang/lib/Driver/ToolChains/Flang.cpp| 39 +++-
 clang/lib/Driver/ToolChains/Flang.h  |  7 
 flang/include/flang/Frontend/LangOptions.def |  3 ++
 flang/lib/Frontend/CompilerInvocation.cpp| 37 +++
 flang/lib/Frontend/FrontendActions.cpp   |  1 +
 flang/test/Driver/driver-help-hidden.f90 |  2 +
 flang/test/Driver/driver-help.f90|  4 ++
 8 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f573f5a06ceb501..4e491f7d76c8622 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4550,18 +4550,19 @@ foreach i = {8-15,18} in
 HelpText<"Make the x"#i#" register call-saved (AArch64 only)">;
 
 def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, 
Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify the size in bits of an SVE vector register. Defaults to 
the"
" vector length agnostic value of \"scalable\". (AArch64 only)">;
 } // let Flags = [TargetSpecific]
 
 def mvscale_min_EQ : Joined<["-"], "mvscale-min=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64/RISC-V 
only)">,
   MarshallingInfoInt>;
 def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale maximum. Defaults to the"
" vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
   MarshallingInfoInt>;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 10f785ce7ab9075..ef18048f2f3203b 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -170,6 +170,39 @@ void Flang::addPicOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   }
 }
 
+
+void Flang::AddAArch64TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Handle -msve_vector_bits=
+  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
+Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
+Val.equals("2048+")) {
+  unsigned Bits = 0;
+  if (Val.endswith("+"))
+Val = Val.substr(0, Val.size() - 1);
+  else {
+bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+assert(!Invalid && "Failed to parse value");
+CmdArgs.push_back(
+Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128)));
+  }
+
+  bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+  assert(!Invalid && "Failed to parse value");
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128)));
+// Silently drop requests for vector-length agnostic code as it's implied.
+} else if (!Val.equals("scalable"))
+  // Handle the unsupported values passed to msve-vector-bits.
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Val;
+  }
+}
+
 void Flang::addTargetOptions(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   const ToolChain &TC = getToolChain();
@@ -186,9 +219,13 @@ void Flang::addTargetOptions(const ArgList &Args,
   switch (TC.getArch()) {
   default:
 break;
+  case llvm::Triple::aarch64:
+getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
+AddAArch64TargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::r600:
   case llvm::Triple::amdgcn:
-  case llvm::Triple::aarch64:
   case llvm::Triple::riscv64:
   case llvm::Triple::x86_64:
 getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
diff --git a/clang/lib/Driver/ToolChains/Flang.h 
b/clang/lib/Driver/ToolChains/Flang.h
index 962b4ae601726af..0141240b5d3ac90 100644
--- a/clang/lib/D

[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-28 Thread Mats Petersson via cfe-commits


@@ -170,6 +170,39 @@ void Flang::addPicOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   }
 }
 
+
+void Flang::AddAArch64TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Handle -msve_vector_bits=
+  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
+Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
+Val.equals("2048+")) {
+  unsigned Bits = 0;
+  if (Val.endswith("+"))
+Val = Val.substr(0, Val.size() - 1);
+  else {
+bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+assert(!Invalid && "Failed to parse value");
+CmdArgs.push_back(
+Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128)));
+  }
+
+  bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+  assert(!Invalid && "Failed to parse value");
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128)));
+// Silently drop requests for vector-length agnostic code as it's implied.
+} else if (!Val.equals("scalable"))
+  // Handle the unsupported values passed to msve-vector-bits.
+  D.Diag(diag::err_drv_unsupported_option_argument)

Leporacanthicus wrote:

It's not "unsupported", it just doesn't do anything different from "not 
specifying anything". It's what clang does.

https://github.com/llvm/llvm-project/pull/67676
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang]Add vscale argument parsing (PR #67676)

2023-09-28 Thread Mats Petersson via cfe-commits

https://github.com/Leporacanthicus created 
https://github.com/llvm/llvm-project/pull/67676

Support for vector scale range arguments, for AArch64 scalable vector extension 
(SVE) support.

Adds -msve-vector-bits to the flang frontend, and for flang fc1 the options are 
-mvscale-min and -mvscale-max (optional). These match the clang and clang cc1 
options for the same purposes.

A further patch will actually USE these arguments.

>From 25b53fa1d6d52e8f22dcdaaf5c7fbf47132e Mon Sep 17 00:00:00 2001
From: Mats Petersson 
Date: Fri, 15 Sep 2023 18:52:11 +0100
Subject: [PATCH] [flang]Add vscale argument parsing

Support for vector scale range arguments, for AArch64 scalable vector
extension (SVE) support.

Adds -msve-vector-bits to the flang frontend, and for flang fc1 the
options are -mvscale-min and -mvscale-max (optional). These match the
clang and clang cc1 options for the same purposes.

A further patch will actually USE these arguments.
---
 clang/include/clang/Driver/Options.td|  5 ++-
 clang/lib/Driver/ToolChains/Flang.cpp| 39 +++-
 clang/lib/Driver/ToolChains/Flang.h  |  7 
 flang/include/flang/Frontend/LangOptions.def |  3 ++
 flang/lib/Frontend/CompilerInvocation.cpp| 37 +++
 flang/lib/Frontend/FrontendActions.cpp   |  1 +
 flang/test/Driver/driver-help-hidden.f90 |  2 +
 flang/test/Driver/driver-help.f90|  4 ++
 8 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f573f5a06ceb501..4e491f7d76c8622 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4550,18 +4550,19 @@ foreach i = {8-15,18} in
 HelpText<"Make the x"#i#" register call-saved (AArch64 only)">;
 
 def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, 
Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify the size in bits of an SVE vector register. Defaults to 
the"
" vector length agnostic value of \"scalable\". (AArch64 only)">;
 } // let Flags = [TargetSpecific]
 
 def mvscale_min_EQ : Joined<["-"], "mvscale-min=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64/RISC-V 
only)">,
   MarshallingInfoInt>;
 def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
   Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FC1Option]>,
   HelpText<"Specify the vscale maximum. Defaults to the"
" vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
   MarshallingInfoInt>;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 10f785ce7ab9075..ef18048f2f3203b 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -170,6 +170,39 @@ void Flang::addPicOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   }
 }
 
+
+void Flang::AddAArch64TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Handle -msve_vector_bits=
+  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048") || Val.equals("128+") ||
+Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
+Val.equals("2048+")) {
+  unsigned Bits = 0;
+  if (Val.endswith("+"))
+Val = Val.substr(0, Val.size() - 1);
+  else {
+bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+assert(!Invalid && "Failed to parse value");
+CmdArgs.push_back(
+Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128)));
+  }
+
+  bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
+  assert(!Invalid && "Failed to parse value");
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128)));
+// Silently drop requests for vector-length agnostic code as it's implied.
+} else if (!Val.equals("scalable"))
+  // Handle the unsupported values passed to msve-vector-bits.
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Val;
+  }
+}
+
 void Flang::addTargetOptions(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   const ToolChain &TC = getToolChain();
@@ -186,9 +219,13 @@ void Flang::addTargetOptions(const ArgList &Args,
   switch (TC.getArch()) {
   default:
 break;
+  case llvm::Triple::aarch64:
+getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
+AddAArch64TargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::r600:
   

[clang] efae695 - Add -f[no-]loop-versioning option

2023-04-18 Thread Mats Petersson via cfe-commits

Author: Mats Petersson
Date: 2023-04-18T09:47:54+01:00
New Revision: efae695d52ccc987ddd3eb042eeb11f06cb2383b

URL: 
https://github.com/llvm/llvm-project/commit/efae695d52ccc987ddd3eb042eeb11f06cb2383b
DIFF: 
https://github.com/llvm/llvm-project/commit/efae695d52ccc987ddd3eb042eeb11f06cb2383b.diff

LOG: Add -f[no-]loop-versioning option

Add flags for loop-versioning pass enable/disable

Reviewed By: awarzynski, tblah

Differential Revision: https://reviews.llvm.org/D141307

Added: 
flang/test/Driver/version-loops.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/Flang.h
flang/include/flang/Frontend/CodeGenOptions.def
flang/include/flang/Tools/CLOptions.inc
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/frontend-forwarding.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7fa1d7d636bb..eed0d517a1ad 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5167,7 +5167,9 @@ def fno_automatic : Flag<["-"], "fno-automatic">, 
Group,
 defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
   PosFlag,
   NegFlag>;
-
+defm loop_versioning : BoolOptionWithoutMarshalling<"f", 
"version-loops-for-stride",
+  PosFlag,
+   NegFlag>;
 } // let Flags = [FC1Option, FlangOption, FlangOnlyOption]
 
 def J : JoinedOrSeparate<["-"], "J">,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 57555ed32553..300072db35ed 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -52,6 +52,55 @@ void Flang::addPreprocessingOptions(const ArgList &Args,
options::OPT_I, options::OPT_cpp, options::OPT_nocpp});
 }
 
+/// @C shouldLoopVersion
+///
+/// Check if Loop Versioning should be enabled.
+/// We look for the last of one of the following:
+///   -Ofast, -O4, -O and -f[no-]version-loops-for-stride.
+/// Loop versioning is disabled if the last option is
+///  -fno-version-loops-for-stride.
+/// Loop versioning is enabled if the last option is one of:
+///  -floop-versioning
+///  -Ofast
+///  -O4
+///  -O3
+/// For all other cases, loop versioning is is disabled.
+///
+/// The gfortran compiler automatically enables the option for -O3 or -Ofast.
+///
+/// @return true if loop-versioning should be enabled, otherwise false.
+static bool shouldLoopVersion(const ArgList &Args) {
+  const Arg *LoopVersioningArg = Args.getLastArg(
+  options::OPT_Ofast, options::OPT_O, options::OPT_O4,
+  options::OPT_floop_versioning, options::OPT_fno_loop_versioning);
+  if (!LoopVersioningArg)
+return false;
+
+  if (LoopVersioningArg->getOption().matches(options::OPT_fno_loop_versioning))
+return false;
+
+  if (LoopVersioningArg->getOption().matches(options::OPT_floop_versioning))
+return true;
+
+  if (LoopVersioningArg->getOption().matches(options::OPT_Ofast) ||
+  LoopVersioningArg->getOption().matches(options::OPT_O4))
+return true;
+
+  if (LoopVersioningArg->getOption().matches(options::OPT_O)) {
+StringRef S(LoopVersioningArg->getValue());
+unsigned OptLevel = 0;
+// Note -Os or Oz woould "fail" here, so return false. Which is the
+// desiered behavior.
+if (S.getAsInteger(10, OptLevel))
+  return false;
+
+return OptLevel > 2;
+  }
+
+  llvm_unreachable("We should not end up here");
+  return false;
+}
+
 void Flang::addOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const 
{
   Args.AddAllArgs(CmdArgs,
   {options::OPT_module_dir, options::OPT_fdebug_module_writer,
@@ -60,16 +109,6 @@ void Flang::addOtherOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ,
options::OPT_funderscoring, options::OPT_fno_underscoring});
 
-  Arg *stackArrays =
-  Args.getLastArg(options::OPT_Ofast, options::OPT_fstack_arrays,
-  options::OPT_fno_stack_arrays);
-  if (stackArrays &&
-  !stackArrays->getOption().matches(options::OPT_fno_stack_arrays))
-CmdArgs.push_back("-fstack-arrays");
-
-  if (Args.hasArg(options::OPT_flang_experimental_hlfir))
-CmdArgs.push_back("-flang-experimental-hlfir");
-
   llvm::codegenoptions::DebugInfoKind DebugInfoKind;
   if (Args.hasArg(options::OPT_gN_Group)) {
 Arg *gNArg = Args.getLastArg(options::OPT_gN_Group);
@@ -82,6 +121,21 @@ void Flang::addOtherOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   addDebugInfoKind(CmdArgs, DebugInfoKind);
 }
 
+void Flang::addCodegenOptions(const ArgList &Args,
+  ArgStringList 

[clang] 4d1460c - Revert "[flang] Add -fpass-plugin option to Flang frontend"

2022-10-05 Thread Mats Petersson via cfe-commits

Author: Mats Petersson
Date: 2022-10-05T19:43:02+01:00
New Revision: 4d1460c77d0095fb5eb974b42d96ca4f4567a7cd

URL: 
https://github.com/llvm/llvm-project/commit/4d1460c77d0095fb5eb974b42d96ca4f4567a7cd
DIFF: 
https://github.com/llvm/llvm-project/commit/4d1460c77d0095fb5eb974b42d96ca4f4567a7cd.diff

LOG: Revert "[flang] Add -fpass-plugin option to Flang frontend"

This reverts commit 43fe6f7cc35ded691bbc2fa844086d321e705d46.

Reverting this as CI breaks.

To reproduce, run check-flang, and it will fail with an error saying
.../lib/Bye.so not found in pass-plugin.f90

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/docs/FlangDriver.md
flang/docs/ReleaseNotes.md
flang/include/flang/Frontend/CodeGenOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/frontend-forwarding.f90

Removed: 
flang/test/Driver/pass-plugin-not-found.f90
flang/test/Driver/pass-plugin.f90



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f09025d34346c..0b795184b7bd0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2710,7 +2710,7 @@ def fplugin_arg : Joined<["-"], "fplugin-arg-">,
   MetaVarName<"-">,
   HelpText<"Pass  to plugin ">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
-  Group, Flags<[CC1Option,FlangOption,FC1Option]>, 
MetaVarName<"">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new 
pass manager).">,
   MarshallingInfoStringVector>;
 defm preserve_as_comments : BoolFOption<"preserve-as-comments",

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 9fe83ed0886b4..b279529a33184 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -55,8 +55,7 @@ void Flang::AddOtherOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   Args.AddAllArgs(CmdArgs,
   {options::OPT_module_dir, options::OPT_fdebug_module_writer,
options::OPT_fintrinsic_modules_path, options::OPT_pedantic,
-   options::OPT_std_EQ, options::OPT_W_Joined,
-   options::OPT_fpass_plugin_EQ});
+   options::OPT_std_EQ, options::OPT_W_Joined});
 }
 
 void Flang::AddPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {

diff  --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index b44f44efc93fa..af1fddc8f750a 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -507,28 +507,3 @@ Lastly, if `ParseTree` modifications are performed, then 
it might be necessary
 to re-analyze expressions and modify scope or symbols. You can check
 [Semantics.md](Semantics.md) for more details on how `ParseTree` is edited
 e.g. during the semantic checks.
-
-# LLVM Pass Plugins
-
-Pass plugins are dynamic shared objects that consist of one or more LLVM IR
-passes. The `-fpass-plugin` option enables these passes to be passed to the 
-middle-end where they are added to the optimization pass pipeline and run after
-lowering to LLVM IR.The exact position of the pass in the pipeline will depend 
-on how it has been registered with the `llvm::PassBuilder`. See the 
-documentation for 
-[`llvm::PassBuilder`](https://llvm.org/doxygen/classllvm_1_1PassBuilder.html)
-for details. 
-
-The framework to enable pass plugins in `flang-new` uses the exact same 
-machinery as that used by `clang` and thus has the same capabilities and
-limitations. 
-
-In order to use a pass plugin, the pass(es) must be compiled into a dynamic 
-shared object which is then loaded using the `-fpass-plugin` option. 
-
-```
-flang-new -fpass-plugin=/path/to/plugin.so 
-```
-
-This option is available in both the compiler driver and the frontend driver. 
-Note that LLVM plugins are not officially supported on Windows.

diff  --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index 0cc85db9debc5..fd1db3b00eb83 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -24,10 +24,6 @@ page](https://llvm.org/releases/).
 
 ## Major New Features
 
-* Flang now supports loading LLVM pass plugins with the `-fpass-plugin` option
-  which is also available in clang. The option mimics the behavior of the
-  corresponding option in clang and has the same capabilities and limitations.
-
 ## Bug Fixes
 
 ## Non-comprehensive list of changes in this release

diff  --git a/flang/include/flang/Frontend/CodeGenOptions.h 
b/flang/include/flang/Frontend/CodeGenOptions.h
index 7bb10d4b0f3c8..025f67cd8e177 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.h
+++ b/flang/include/flang/Frontend/Cod

Re: [PATCH] D17955: [OpenCL] Fix piep builtin bug

2016-03-08 Thread Mats Petersson via cfe-commits
MatsPetersson added a subscriber: MatsPetersson.
MatsPetersson added a comment.

Obvious typo in title. Pipe, not piep.


http://reviews.llvm.org/D17955



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-19 Thread Mats Petersson via cfe-commits
MatsPetersson added a comment.

@Anastasia: Yes, I agree, printf should be done as a separate patch.


http://reviews.llvm.org/D16928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-17 Thread Mats Petersson via cfe-commits
MatsPetersson added a comment.

I think adding printf as a builtin function is a good idea.

If not, I feel that the error message should distinguish between (for example):

  int printf(global char* fmt, ...);

and

  void myfunc(int n, ...);

since the former is "incorrect prototype of printf" and the latter is "not a 
valid opencl function".


http://reviews.llvm.org/D16928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-16 Thread Mats Petersson via cfe-commits
MatsPetersson added inline comments.


Comment at: test/SemaOpenCL/invalid-func.cl:6
@@ +5,2 @@
+void foo(int, ...); // expected-error{{OpenCL does not allow variadic 
arguments}}
+int printf(const char *, ...);

pekka.jaaskelainen wrote:
> I wonder should we check for the fingerprint too when letting printf() pass?
> This is not the correct OpenCL printf() as the first argument should be in 
> constant address space.
Good spot, this should be fixed.


http://reviews.llvm.org/D16928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-16 Thread Mats Petersson via cfe-commits
MatsPetersson added a subscriber: MatsPetersson.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7700
@@ -7698,2 +7699,3 @@
+  "OpenCL does not allow variadic arguments">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions

Looks good


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7717
@@ +7716,3 @@
+def err_opencl_block_storage_type : Error<
+  "the __block storage type is not permitted">;
+def err_opencl_invalid_block_declaration : Error<

Looks good now (from my official account this time! :) )


http://reviews.llvm.org/D16928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-05 Thread Mats Petersson via cfe-commits
Leporacanthicus added a subscriber: Leporacanthicus.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7684
@@ +7683,3 @@
+  "the __block storage type is not permitted">;
+
+def err_opencl_variadic_prototype_not_allowed : Error<

Is this blank line there for a reason, as there seem to be none above... 


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7704
@@ +7703,3 @@
+def err_opencl_invalid_block_declaration : Error<
+  "invalid block variable declaration - must be %select{const 
qualified|initialised}0">;
+def err_opencl_extern_block_declaration : Error<

US spelling is initialized - which I believe is standard for Clang?


Comment at: test/SemaOpenCL/invalid-blocks-cl20.cl:5
@@ +4,3 @@
+
+// All blocks declarations must be const qualified and initialised.
+void f1() {

US spelling will need to be fixed here too, if fixed above.


Repository:
  rL LLVM

http://reviews.llvm.org/D16928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread mats petersson via cfe-commits
On 5 October 2015 at 15:51, Aaron Ballman  wrote:

> On Mon, Oct 5, 2015 at 10:49 AM, mats petersson 
> wrote:
> >
> >
> > On 5 October 2015 at 15:41, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Mon Oct  5 09:41:27 2015
> >> New Revision: 249321
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
> >> Log:
> >> Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus
> tests
> >> and documentation.
> >>
> >> Modified:
> >> cfe/trunk/docs/LibASTMatchersReference.html
> >> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
> >>
> >> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> >> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
> >> @@ -2210,6 +2210,18 @@ Usable as: Matcher >>  
> >>
> >>
> >> +Matcher< >> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
> ">FunctionDecl> >> class="name" onclick="toggle('isVariadic0')"> >> name="isVariadic0Anchor">isVariadic
> >> +Matches if a
> >> function declaration is variadic.
> >> +
> >> +Example matches f, but not g or h. The function i will not match, event
> >> when
> >> +compiled in C mode.
> >> +  void f(...);
> >> +  void g(int);
> >> +  template  void h(Ts...);
> >> +  void i();
> >> +
> >> +
> >> +
> >>  Matcher< >> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
> ">FunctionDecl> >> class="name" onclick="toggle('parameterCountIs0')"> >> name="parameterCountIs0Anchor">parameterCountIsunsigned
> >> N
> >>  Matches
> >> FunctionDecls that have a specific parameter count.
> >>
> >>
> >> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> >> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5
> 09:41:27
> >> 2015
> >> @@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
> >>return Node.isThisDeclarationADefinition();
> >>  }
> >>
> >> +/// \brief Matches if a function declaration is variadic.
> >> +///
> >> +/// Example matches f, but not g or h. The function i will not match,
> >> even when
> >> +/// compiled in C mode.
> >> +/// \code
> >> +///   void f(...);
> >> +///   void g(int);
> >> +///   template  void h(Ts...);
> >> +///   void i();
> >> +/// \endcode
> >> +AST_MATCHER(FunctionDecl, isVariadic) {
> >> +  return Node.isVariadic();
> >> +}
> >> +
> >>  /// \brief Matches the class declaration that the given method
> >> declaration
> >>  /// belongs to.
> >>  ///
> >>
> >> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> >> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27
> >> 2015
> >> @@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
> >>REGISTER_MATCHER(isStruct);
> >>REGISTER_MATCHER(isTemplateInstantiation);
> >>REGISTER_MATCHER(isUnion);
> >> +  REGISTER_MATCHER(isVariadic);
> >>REGISTER_MATCHER(isVirtual);
> >>REGISTER_MATCHER(isWritten);
> >>REGISTER_MATCHER(labelStmt);
> >>
> >> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> >> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5
> >> 09:41:27 2015
> >> @@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
> >>notMatches("void f(int);"
> >>   "template  struct S { void g(T t) { f(t);
> }
> >> };",
> >>   CallFunctionF));
> >> +
> >> +  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
> >> +  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
> >
> > Am I missing something - surely this should be EXPECT_FALSE?
>
> EXPECT_TRUE is correct -- the test is using notMat

Re: r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread mats petersson via cfe-commits
On 5 October 2015 at 15:41, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Mon Oct  5 09:41:27 2015
> New Revision: 249321
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
> Log:
> Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests
> and documentation.
>
> Modified:
> cfe/trunk/docs/LibASTMatchersReference.html
> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
>
> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
> @@ -2210,6 +2210,18 @@ Usable as: Matcher  
>
>
> +MatcherFunctionDecl> class="name" onclick="toggle('isVariadic0')"> name="isVariadic0Anchor">isVariadic
> +Matches if a
> function declaration is variadic.
> +
> +Example matches f, but not g or h. The function i will not match, event
> when
> +compiled in C mode.
> +  void f(...);
> +  void g(int);
> +  template  void h(Ts...);
> +  void i();
> +
> +
> +
>  MatcherFunctionDecl> class="name" onclick="toggle('parameterCountIs0')"> name="parameterCountIs0Anchor">parameterCountIsunsigned
> N
>  Matches
> FunctionDecls that have a specific parameter count.
>
>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 09:41:27
> 2015
> @@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
>return Node.isThisDeclarationADefinition();
>  }
>
> +/// \brief Matches if a function declaration is variadic.
> +///
> +/// Example matches f, but not g or h. The function i will not match,
> even when
> +/// compiled in C mode.
> +/// \code
> +///   void f(...);
> +///   void g(int);
> +///   template  void h(Ts...);
> +///   void i();
> +/// \endcode
> +AST_MATCHER(FunctionDecl, isVariadic) {
> +  return Node.isVariadic();
> +}
> +
>  /// \brief Matches the class declaration that the given method declaration
>  /// belongs to.
>  ///
>
> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27 2015
> @@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
>REGISTER_MATCHER(isStruct);
>REGISTER_MATCHER(isTemplateInstantiation);
>REGISTER_MATCHER(isUnion);
> +  REGISTER_MATCHER(isVariadic);
>REGISTER_MATCHER(isVirtual);
>REGISTER_MATCHER(isWritten);
>REGISTER_MATCHER(labelStmt);
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5
> 09:41:27 2015
> @@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
>notMatches("void f(int);"
>   "template  struct S { void g(T t) { f(t); }
> };",
>   CallFunctionF));
> +
> +  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
>
Am I missing something - surely this should be EXPECT_FALSE?

--
Mats

> +  EXPECT_TRUE(notMatches("template  void f(Ts...);",
> + functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatches("void f();", functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatchesC("void f();", functionDecl(isVariadic(;
>  }
>
>  TEST(FunctionTemplate, MatchesFunctionTemplateDeclarations) {
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=249321&r1=249320&r2=249321&view=diff
>
> =

Re: Question about FunctionDecl::isVariadic()

2015-10-02 Thread mats petersson via cfe-commits
On 2 October 2015 at 22:07, Aaron Ballman  wrote:

> On Fri, Oct 2, 2015 at 4:01 PM, mats petersson 
> wrote:
> > Since "varargs" often involve some kind of special passing mechanisms
> [I've
> > seen implementations that build data block and pass a pointer to that,
> > rather than passing on the stack, for example], or additional code in the
> > recipient function, I would say that `f2()` does not mean `f2(...)`.
>
> I kind of wondered if that was the case. If that's reality, perhaps we
> may want to consider naming it FunctionDecl::hasVarArgs() or something
> that specifies the difference is in whether we need to care about
> packaging up the argument list so it can be used with va_start() and
> friends?
>

My understanding of the meaning of `isVariadic` is indeed "needs to use
va_* to get arguments".

I believe it's technically valid to do something like:

void f2();


f2(42);


voif f2(int x)
{
... use x ...
}

and no special code should be required. Of course, the results of changing
`f2(42);` int `f2(4.2);` or `f2("foo");` and retaining the `int x`
parameter will lead to undefined behaviour, and compiler can do anything it
likes with that... :)

--
Mats

>
> ~Aaron
>
> >
> > --
> > Mats
> >
> > On 2 October 2015 at 20:16, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Given the following two function declarations:
> >>
> >> void f1(...);
> >> void f2();
> >>
> >> It makes sense to me that isVariadic() returns true for f1 in both C
> >> and C++. It makes sense to me that isVariadic() returns false for f2
> >> in C++. I am confused as to why it returns false instead of true for
> >> C, however.
> >>
> >> In C11, 6.7.6.3p9 states: If the list terminates with an ellipsis (,
> >> ...), no information about the number or types of the parameters after
> >> the comma is supplied.
> >>
> >> p14 states, in part: "The empty list in a function declarator that is
> >> not part of a definition of that function specifies that no
> >> information about the number or types of the parameters is supplied."
> >>
> >> It seems to me that for function *declarations* (not definitions),
> >> isVariadic() should return true for f2 in C. Is there a reason it
> >> doesn't currently behave that way, or is this a bug?
> >>
> >> I ask because I was writing an AST matcher for isVariadic() for an
> >> in-progress checker, but the checker was failing to catch that f2 was
> >> a variadic function. I am not certain whether
> >> FunctionDecl::isVariadic() should be changed, whether the AST matcher
> >> isVariadic() should be smarter about C code, or whether the checker
> >> itself needs to be smarter about this particular behavior in C code.
> >> My gut reaction is that FunctionDecl::isVariadic() has a bug, but from
> >> looking at code elsewhere, everything seems to assume isVariadic()
> >> implies the ellipsis, which makes me think I just need to make my
> >> checker smarter.
> >>
> >> Thanks!
> >>
> >> ~Aaron
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Question about FunctionDecl::isVariadic()

2015-10-02 Thread mats petersson via cfe-commits
Since "varargs" often involve some kind of special passing mechanisms [I've
seen implementations that build data block and pass a pointer to that,
rather than passing on the stack, for example], or additional code in the
recipient function, I would say that `f2()` does not mean `f2(...)`.

--
Mats

On 2 October 2015 at 20:16, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Given the following two function declarations:
>
> void f1(...);
> void f2();
>
> It makes sense to me that isVariadic() returns true for f1 in both C
> and C++. It makes sense to me that isVariadic() returns false for f2
> in C++. I am confused as to why it returns false instead of true for
> C, however.
>
> In C11, 6.7.6.3p9 states: If the list terminates with an ellipsis (,
> ...), no information about the number or types of the parameters after
> the comma is supplied.
>
> p14 states, in part: "The empty list in a function declarator that is
> not part of a definition of that function specifies that no
> information about the number or types of the parameters is supplied."
>
> It seems to me that for function *declarations* (not definitions),
> isVariadic() should return true for f2 in C. Is there a reason it
> doesn't currently behave that way, or is this a bug?
>
> I ask because I was writing an AST matcher for isVariadic() for an
> in-progress checker, but the checker was failing to catch that f2 was
> a variadic function. I am not certain whether
> FunctionDecl::isVariadic() should be changed, whether the AST matcher
> isVariadic() should be smarter about C code, or whether the checker
> itself needs to be smarter about this particular behavior in C code.
> My gut reaction is that FunctionDecl::isVariadic() has a bug, but from
> looking at code elsewhere, everything seems to assume isVariadic()
> implies the ellipsis, which makes me think I just need to make my
> checker smarter.
>
> Thanks!
>
> ~Aaron
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits