[flang] [clang] [flang] add fveclib flag (PR #71734)

2023-11-09 Thread Kiran Chandramohan via cfe-commits


@@ -81,6 +81,17 @@ class CodeGenOptions : public CodeGenOptionsBase {
 RK_WithPattern, // Remark pattern specified via '-Rgroup=regexp'.
   };
 
+  enum class VectorLibrary {
+NoLibrary,  // Don't use any vector library.
+Accelerate, // Use the Accelerate framework.
+LIBMVEC,// GLIBC vector math library.
+MASSV,  // IBM MASS vector library.
+SVML,   // Intel short vector math library.
+SLEEF,  // SLEEF SIMD Library for Evaluating Elementary Functions.
+Darwin_libsystem_m, // Use Darwin's libsystem_m vector functions.
+ArmPL   // Arm Performance Libraries.
+  };

kiranchandramohan wrote:

Can this class be moved to a file in a new directory 
`llvm/include/llvm/Frontend/Driver` and shared with Clang?

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


[flang] [clang] [flang] add fveclib flag (PR #71734)

2023-11-09 Thread Kiran Chandramohan via cfe-commits


@@ -843,6 +843,44 @@ getOutputStream(CompilerInstance &ci, llvm::StringRef 
inFile,
   llvm_unreachable("Invalid action!");
 }
 
+static std::unique_ptr
+createTLII(llvm::Triple &targetTriple, const CodeGenOptions &codeGenOpts) {
+  auto tlii = std::make_unique(targetTriple);
+  assert(tlii && "Failed to create TargetLibraryInfo");
+
+  using VecLib = llvm::TargetLibraryInfoImpl::VectorLibrary;
+  VecLib vecLib = VecLib::NoLibrary;
+  switch (codeGenOpts.getVecLib()) {
+  case CodeGenOptions::VectorLibrary::Accelerate:
+vecLib = VecLib::Accelerate;
+break;
+  case CodeGenOptions::VectorLibrary::LIBMVEC:
+vecLib = VecLib::LIBMVEC_X86;
+break;
+  case CodeGenOptions::VectorLibrary::MASSV:
+vecLib = VecLib::MASSV;
+break;
+  case CodeGenOptions::VectorLibrary::SVML:
+vecLib = VecLib::SVML;
+break;
+  case CodeGenOptions::VectorLibrary::SLEEF:
+vecLib = VecLib::SLEEFGNUABI;
+break;
+  case CodeGenOptions::VectorLibrary::Darwin_libsystem_m:
+vecLib = VecLib::DarwinLibSystemM;
+break;
+  case CodeGenOptions::VectorLibrary::ArmPL:
+vecLib = VecLib::ArmPL;
+break;
+  case CodeGenOptions::VectorLibrary::NoLibrary:
+vecLib = VecLib::NoLibrary;
+break;
+  }
+
+  tlii->addVectorizableFunctionsFromVecLib(vecLib, targetTriple);
+  return tlii;
+}

kiranchandramohan wrote:

Can this code be moved to `llvm/lib/Frontend/Driver` and shared with Clang?

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


[clang] [llvm] [flang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits

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

Nice work. LGTM.

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


[llvm] [flang] [clang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits

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


[clang] [llvm] [flang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits


@@ -111,7 +111,7 @@ int main(int argc, const char **argv) {
 
   auto Files = llvm::makeIntrusiveRefCnt(FileSystemOptions(), 
OFS);
 
-  auto Driver = std::make_unique(
+  auto Driver = std::make_unique(

kiranchandramohan wrote:

Are these clang prefixes required?

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


[llvm] [clang] [flang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits


@@ -851,11 +851,10 @@ getOutputStream(CompilerInstance &ci, llvm::StringRef 
inFile,
 /// \param [in] act Backend act to run (assembly vs machine-code generation)
 /// \param [in] llvmModule LLVM module to lower to assembly/machine-code
 /// \param [out] os Output stream to emit the generated code to

kiranchandramohan wrote:

Nit: Add the new option here. May be good to have the stream as the last option.

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


[llvm] [clang] [flang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,13 @@
+! test that -fveclib= is passed to the backend
+! -target aarch64 so that ArmPL is available
+! RUN: %flang -S -target aarch64-unknown-linux-gnu -mcpu=neoverse-v1 -Ofast 
-fveclib=ArmPL -o - %s | FileCheck %s
+

kiranchandramohan wrote:

Will this work on all targets? Or only on AArch64?

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


[llvm] [flang] [clang] [flang] add fveclib flag (PR #71734)

2023-11-10 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,13 @@
+! test that -fveclib= is passed to the backend
+! -target aarch64 so that ArmPL is available
+! RUN: %flang -S -target aarch64-unknown-linux-gnu -mcpu=neoverse-v1 -Ofast 
-fveclib=ArmPL -o - %s | FileCheck %s
+

kiranchandramohan wrote:

I was asking whether this test needs to be restricted to only work on a system 
where Arm target is enabled.

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


[flang] [clang] [flang][Driver] Support -rpath, -shared, and -static in the frontend (PR #66702)

2023-11-13 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

@banach-space Is this patch OK with you?

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


[clang] [flang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-06 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

I am assuming you have got a go-ahead from the code owner and others involved 
in the discourse discussion. It is probably good to post a link to this patch 
in the relevant discourse post for information and confirmation.

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


[flang] [llvm] [clang] [clang-tools-extra] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Kiran Chandramohan via cfe-commits


@@ -10,10 +10,50 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
+#include "flang/Runtime/character.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+
+#include  // wcstombs_s
+#include  // UNLEN=256
+#include  // wchar_t cast to LPWSTR
+#pragma comment(lib, "Advapi32.lib") // Link Advapi32.lib for GetUserName

kiranchandramohan wrote:

We usually avoid depending on external libraries. Can this be avoided?

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


[clang] 08cb640 - [NFC] Remove an unused decl to avoid warning

2023-12-09 Thread Kiran Chandramohan via cfe-commits

Author: Kiran Chandramohan
Date: 2023-12-09T16:27:42Z
New Revision: 08cb64034f17d50a660ec78ce8ea81a025b0ba71

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

LOG: [NFC] Remove an unused decl to avoid warning

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index f04018179a5da..f131b6cf3baff 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -143,7 +143,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   // When optimizing, if wasm-opt is available, run it.
   std::string WasmOptPath;
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+  if (Args.getLastArg(options::OPT_O_Group)) {
 WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
 if (WasmOptPath == "wasm-opt") {
   WasmOptPath = {};



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


[clang] [llvm] [mlir] [AArch64][SME] Remove immediate argument restriction for svldr and svstr (PR #68565)

2023-11-15 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan updated 
https://github.com/llvm/llvm-project/pull/68565

>From 83e20904c206980285c4ee9d0227706803147654 Mon Sep 17 00:00:00 2001
From: Samuel Tebbs 
Date: Fri, 6 Oct 2023 17:09:36 +0100
Subject: [PATCH 01/13] [AArch64][SME] Remove immediate argument restriction
 for svldr and svstr

The svldr_vnum_za and svstr_vnum_za builtins/intrinsics currently
require that the vnum argument be an immediate, since the instructions
take an immediate vector number. However, we emit 0 as the immediate
for the instruction no matter what, and instead modify the base register.

This patch removes that restriction on the argument, so that the
argument can be a non-immediate. If an appropriate immediate was
passed to the builtin then CGBuiltin passes that directly to the LLVM
intrinsic, otherwise it modifies the base register as is existing
behaviour.
---
 clang/lib/CodeGen/CGBuiltin.cpp   | 45 
 .../aarch64-sme-intrinsics/acle_sme_ldr.c | 71 ---
 .../aarch64-sme-intrinsics/acle_sme_str.c | 51 -
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td| 10 +--
 .../CostModel/ARM/unaligned_double_load.ll| 59 +++
 .../CodeGen/AArch64/sme-intrinsics-loads.ll   | 33 +++--
 7 files changed, 165 insertions(+), 106 deletions(-)
 create mode 100644 llvm/test/Analysis/CostModel/ARM/unaligned_double_load.ll

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 09309a3937fb613..8444aea8c8ac4b6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -9815,6 +9815,11 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const 
CallExpr *E,
   return Store;
 }
 
+Value *CodeGenFunction::EmitTileslice(Value *Offset, Value *Base) {
+  llvm::Value *CastOffset = Builder.CreateIntCast(Offset, Int64Ty, false);
+  return Builder.CreateAdd(Base, CastOffset, "tileslice");
+}
+
 Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
@@ -9870,18 +9875,34 @@ Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags 
&TypeFlags,
 Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
-  if (Ops.size() == 3) {
-Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);
-llvm::Value *CntsbCall = Builder.CreateCall(Cntsb, {}, "svlb");
-
-llvm::Value *VecNum = Ops[2];
-llvm::Value *MulVL = Builder.CreateMul(CntsbCall, VecNum, "mulvl");
-
-Ops[1] = Builder.CreateGEP(Int8Ty, Ops[1], MulVL);
-Ops[0] = Builder.CreateAdd(
-Ops[0], Builder.CreateIntCast(VecNum, Int32Ty, true), "tileslice");
-Ops.erase(&Ops[2]);
-  }
+  if (Ops.size() == 2) {
+// Intrinsics without a vecnum also use this function, so just provide 0
+Ops.push_back(Ops[1]);
+Ops[1] = Builder.getInt32(0);
+  } else {
+int Imm = -1;
+if (ConstantInt* C = dyn_cast(Ops[2]))
+  if (C->getZExtValue() <= 15)
+  Imm = C->getZExtValue();
+
+if (Imm != -1) {
+  Ops[2] = Ops[1];
+  Ops[1] = Builder.getInt32(Imm);
+} else {
+  Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);
+  llvm::Value *CntsbCall = Builder.CreateCall(Cntsb, {}, "svlb");
+
+  llvm::Value *VecNum = Ops[2];
+  llvm::Value *MulVL = Builder.CreateMul(
+  CntsbCall,
+  VecNum,
+  "mulvl");
+
+  Ops[2] = Builder.CreateGEP(Int8Ty, Ops[1], MulVL);
+  Ops[1] = Builder.getInt32(0);
+  Ops[0] = Builder.CreateIntCast(EmitTileslice(Ops[0], VecNum), Int32Ty, 
false);
+}
+   }
   Function *F = CGM.getIntrinsic(IntID, {});
   return Builder.CreateCall(F, Ops);
 }
diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c 
b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
index e85c47072f2df80..8e07cf1d11c19b2 100644
--- a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
+++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
@@ -6,57 +6,46 @@
 
 #include 
 
-// CHECK-C-LABEL: define dso_local void @test_svldr_vnum_za(
-// CHECK-C-SAME: i32 noundef [[SLICE_BASE:%.*]], ptr noundef [[PTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK-C-NEXT:  entry:
-// CHECK-C-NEXT:tail call void @llvm.aarch64.sme.ldr(i32 [[SLICE_BASE]], 
ptr [[PTR]])
-// CHECK-C-NEXT:ret void
-//
-// CHECK-CXX-LABEL: define dso_local void @_Z18test_svldr_vnum_zajPKv(
-// CHECK-CXX-SAME: i32 noundef [[SLICE_BASE:%.*]], ptr noundef [[PTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK-CXX-NEXT:  entry:
-// CHECK-CXX-NEXT:tail call void @llvm.aarch64.sme.ldr(i32 [[SLICE_BASE]], 
ptr [[PTR]])
-// CHECK-CXX-NEXT:ret void
+// CHECK-C-LABEL: @test_svldr_vnum_za(
+// CHECK-CXX-LABEL: @_Z18test_svldr_v

[flang] [clang] [Flang] Add code-object-version option (PR #72638)

2023-11-19 Thread Kiran Chandramohan via cfe-commits


@@ -85,6 +85,19 @@ class CodeGenOptions : public CodeGenOptionsBase {
 RK_WithPattern, // Remark pattern specified via '-Rgroup=regexp'.
   };
 
+  /// \brief Enumeration value for AMDGPU code object version, which is the
+  /// code object version times 100.
+  enum class CodeObjectVersionKind {
+COV_None,
+COV_2 = 200, // Unsupported.
+COV_3 = 300, // Unsupported.
+COV_4 = 400,
+COV_5 = 500,
+  };

kiranchandramohan wrote:

If possible move this to `llvm/include/llvm/Frontend/Driver/TargetOptions.h`.

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


[clang-tools-extra] [flang] [llvm] [clang] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)

2023-11-22 Thread Kiran Chandramohan via cfe-commits


@@ -37,5 +80,17 @@ void FORTRAN_PROCEDURE_NAME(getarg)(
   (void)RTNAME(GetCommandArgument)(
   n, &value, nullptr, nullptr, __FILE__, __LINE__);
 }
+
+void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *arg, std::int64_t length) {
+  std::array str = {};
+
+  int error = getlogin_r(str.data(), str.size());

kiranchandramohan wrote:

```suggestion
  int error{getlogin_r(str.data(), str.size())};
```

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


[llvm] [clang-tools-extra] [flang] [clang] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)

2023-11-22 Thread Kiran Chandramohan via cfe-commits


@@ -10,9 +10,52 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
+#include "terminator.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
+#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad
+#include 
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+
+#include  // wcstombs_s
+#include  // UNLEN=256
+#include  // wchar_t cast to LPWSTR
+#pragma comment(lib, "Advapi32.lib") // Link Advapi32.lib for GetUserName
+#define LOGIN_NAME_MAX UNLEN
+
+inline int getlogin_r(char *buf, size_t bufSize) {
+  wchar_t w_username[UNLEN + 1] = {};
+  DWORD nameLen = UNLEN + 1;

kiranchandramohan wrote:

```suggestion
  DWORD nameLen{UNLEN + 1};
```

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


[clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-22 Thread Kiran Chandramohan via cfe-commits


@@ -1029,7 +1042,7 @@ void tools::addFortranRuntimeLibraryPath(const ToolChain 
&TC,
  ArgStringList &CmdArgs) {
   // Default to the /../lib directory. This works fine on the
   // platforms that we have tested so far. We will probably have to re-fine
-  // this in the future. In particular, on some platforms, we may need to use
+  // this in the future. In particular, on some platforms, we may need to useq

kiranchandramohan wrote:

Nit: accidental change?

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


[llvm] [mlir] [libcxx] [clang] [lldb] [flang] [Flang][OpenMP] Port openmp threadprivate-use-association.f90 test to HLFIR flow (PR #71043)

2023-11-02 Thread Kiran Chandramohan via cfe-commits

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

LG. Thanks.

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


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

2023-12-18 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

> > llc has a --frame-pointer option, so there is likely a way to pass this 
> > option to the llvm codegen as a global option instead of setting it on all 
> > function at the MLIR level if the only goal is to propagate it to llvm 
> > backend.
> 
> I just discussed a bit with @vzakhari and one advantage of setting it per 
> function is to later be able to merge llvm IR files compiled with different 
> options. That would explain why clang does it. I would still add nothing if 
> the option is None since this is the default, but seems OK to me to decorate 
> the functions as you are doing based on this argument.

@jeanPerier just checking whether you are OK with this pass being here or would 
prefer it to be in LLVM dialect?

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


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

2023-12-19 Thread Kiran Chandramohan via cfe-commits


@@ -38,6 +38,7 @@ CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) 
///< Name of the relocation model to use.
 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) ///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


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

2023-12-19 Thread Kiran Chandramohan via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");

kiranchandramohan wrote:

Do we have a test for this?

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


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

2023-12-19 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,62 @@
+//===- FunctionAttr.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+//===--===//
+/// \file
+/// This is a generic pass for adding attributes to functions.
+//===--==

kiranchandramohan wrote:

Nit: The alignments of the lines seem to be off.

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


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

2023-12-19 Thread Kiran Chandramohan via cfe-commits


@@ -349,4 +349,23 @@ def VScaleAttr : Pass<"vscale-attr", "mlir::func::FuncOp"> 
{
   let constructor = "::fir::createVScaleAttrPass()";
 }
 
+def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
+  let summary = "This is a generic pass that adds function attributes that are 
expected at the LLVM IR level";
+  let description = [{ This feature introduces a general attribute aimed at 
customizing function characteristics. 
+ Options include:
+ Add "frame-pointer" attribute to functions: Set an attribute for the 
frame 
+ pointer on functions, to avoid saving the frame pointer in a register in 
+ functions where it is unnecessary. 
+ This eliminates the need for instructions to save, establish, and restore 
+ frame pointers, while also freeing up an additional register in numerous 
functions. 
+ However, this approach can make debugging unfeasible on certain machines.
+  }];
+  let options = [
+Option<"framePointerKind", "frame-pointer",
+   "mlir::LLVM::framePointerKind::FramePointerKind", 
/*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
+   "frame pointer">,
+  ];

kiranchandramohan wrote:

Stick to 80 characters if possible in the summary, description and options.

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


[clang] [flang] [flang][driver] Remove Fortain_main static library from linking stages (PR #75816)

2023-12-20 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Looks reasonable to me.

I guess the environment settings that are there in the EnvironmentDefaults 
apply only when the main program is compiled with some flags. It would be good 
to check the options in EnvironmentDefaults and see that they are all 
applicable only when compiled for the main program.



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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,15 @@
+! UNSUPPORTED: system-windows
+
+! RUN: %clang -o %t.c-object -c %S/Inputs/main_dupes.c

kiranchandramohan wrote:

You can use %cc for the system-compiler and REQUIRE it to be present for this 
test. 
Reference: 
https://github.com/llvm/llvm-project/blob/main/flang/test/Runtime/no-cpp-dep.c

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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Kiran Chandramohan via cfe-commits


@@ -122,6 +122,7 @@
 # the build directory holding that tool.
 tools = [
 ToolSubst("%flang", command=FindTool("flang-new"), unresolved="fatal"),
+ToolSubst("%clang", command=FindTool("clang"), unresolved="fatal"),

kiranchandramohan wrote:

Remove this if using the system compiler works.

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


[flang] [clang] [Flang][Clang] Add support for frame pointers in Flang Driver (PR #72146)

2023-11-24 Thread Kiran Chandramohan via cfe-commits


@@ -49,6 +49,26 @@ class CodeGenOptionsBase {
 class CodeGenOptions : public CodeGenOptionsBase {
 
 public:
+  /// The type of frame pointer used
+  enum class FramePointerKind {
+None,// Omit all frame pointers.
+NonLeaf, // Keep non-leaf frame pointers.
+All, // Keep all frame pointers.
+  };
+
+  static llvm::StringRef getFramePointerKindName(FramePointerKind Kind) {
+switch (Kind) {
+case FramePointerKind::None:
+  return "none";
+case FramePointerKind::NonLeaf:
+  return "non-leaf";
+case FramePointerKind::All:
+  return "all";
+}
+
+llvm_unreachable("invalid FramePointerKind");
+  };
+

kiranchandramohan wrote:

Move this code and the same code in 
`clang/include/clang/Basic/CodeGenOptions.h` to 
llvm/include/llvm/Frontend/Driver.

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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Kiran Chandramohan via cfe-commits

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

LG. Thanks for the patch and the changes.

https://github.com/llvm/llvm-project/pull/73124
___
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-27 Thread Kiran Chandramohan via cfe-commits


@@ -142,6 +142,26 @@ void Flang::addCodegenOptions(const ArgList &Args,
   if (shouldLoopVersion(Args))
 CmdArgs.push_back("-fversion-loops-for-stride");
 
+  Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis,
+   options::OPT_fno_alias_analysis);
+  Arg *optLevel =
+  Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4);

kiranchandramohan wrote:

Some discussion regarding `-Os` is here.
https://discourse.llvm.org/t/code-size-optimization-flags-in-flang/69482

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-27 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan edited 
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] [flang] Enable alias tags pass by default (PR #73111)

2023-11-27 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan 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


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

2023-11-27 Thread Kiran Chandramohan via cfe-commits


@@ -142,6 +142,26 @@ void Flang::addCodegenOptions(const ArgList &Args,
   if (shouldLoopVersion(Args))
 CmdArgs.push_back("-fversion-loops-for-stride");
 
+  Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis,
+   options::OPT_fno_alias_analysis);
+  Arg *optLevel =
+  Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4);

kiranchandramohan wrote:

> That's fine, but then one has to decide whether -f{no}-alias-analysis 
> overrides -O{n} or not? I think that "explicit" request from a user should 
> always take precedence. This leads to (pseudo code):
>
> opts.AliasAnalysis = 0;
> if (opt level requiring alias analysis)
>  opts.AliasAnalysis  = 1;
> 
> / / User request takes precedence when it comes to alias analysis.
> if (-falias-analysis or -fno-alias-analysis) then
>  "do whatever the user requested"
>Separately, could you check what Clang does and make sure that that would be 
>consistent?

@banach-space This is exactly the handling in the front-end driver as given 
below (and in `lib/Frontend/CompilerInvocation`). The flang driver is only 
deciding whether to forward or not.

```
  opts.AliasAnalysis = opts.OptimizationLevel > 0;
  if (auto *arg =
  args.getLastArg(clang::driver::options::OPT_falias_analysis,
  clang::driver::options::OPT_fno_alias_analysis))
opts.AliasAnalysis =
arg->getOption().matches(clang::driver::options::OPT_falias_analysis);
```

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] Revert "[flang] Enable alias tags pass by default (#73111)" (PR #73821)

2023-11-29 Thread Kiran Chandramohan via cfe-commits

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

Thanks @tblah for the quick response. LG.

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


[flang] [libcxx] [clang] [libc] [libcxxabi] [lldb] [clang-tools-extra] [lld] [llvm] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[lldb] [clang-tools-extra] [llvm] [libcxxabi] [libc] [flang] [lld] [clang] [libcxx] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via cfe-commits

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


[clang-tools-extra] [libcxx] [lld] [libcxxabi] [libc] [flang] [lldb] [llvm] [clang] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-11-30 Thread Kiran Chandramohan via cfe-commits


@@ -101,6 +101,8 @@ class CompilerInvocation : public CompilerInvocationBase {
 
   bool warnAsErr = false;
 
+  const char *argv0;

kiranchandramohan wrote:

Nit: This is probably obvious but will be good to add executable name as a 
comment above.

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


[flang] [clang] [flang] (Re-)Enable alias tags pass by default (PR #74250)

2023-12-04 Thread Kiran Chandramohan via cfe-commits

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

LGTM. Thanks.

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


[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-04 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Just a drive-through comment. The CI is failing for the following two tests. 

Clang :: CodeGen/aapcs-align.cpp
Clang :: CodeGen/aapcs64-align.cpp



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


[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-04 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,13 @@
+//===--- arm_vector_types.td - ARM Fixed vector types compiler interface 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the TableGen definitions from which the ARM BF16 header

kiranchandramohan wrote:

Did you mean BF16 here? The name of the file seems to refer to arm_vector_types 
in general.

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


[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-04 Thread Kiran Chandramohan via cfe-commits


@@ -2229,6 +2231,12 @@ void NeonEmitter::runHeader(raw_ostream &OS) {
 static void emitNeonTypeDefs(const std::string& types, raw_ostream &OS) {
   std::string TypedefTypes(types);
   std::vector TDTypeVec = TypeSpec::fromTypeSpecs(TypedefTypes);
+  // arm_sve.h followed by arm_neon.h does not emmit these types

kiranchandramohan wrote:

```suggestion
  // arm_sve.h followed by arm_neon.h does not emit these types
```

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


[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-04 Thread Kiran Chandramohan via cfe-commits


@@ -2546,6 +2555,53 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
   OS << "#endif /* __ARM_FP16_H */\n";
 }
 
+void NeonEmitter::runVectorType(raw_ostream &OS) {
+  OS << "/*=== arm_vector_types - ARM vector type "
+"--===\n"
+" *\n"
+" *\n"
+" * Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+"Exceptions.\n"
+" * See https://llvm.org/LICENSE.txt for license information.\n"
+" * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+" *\n"
+" 
*===-"
+"--===\n"
+" */\n\n";
+  OS << "#ifndef __ARM_NEON_H\n\n";
+  OS << "#ifndef __ARM_NEON_TYPES_H\n";
+  OS << "#define __ARM_NEON_TYPES_H\n";
+  OS << "#ifdef __aarch64__\n";
+  OS << "typedef uint8_t poly8_t;\n";
+  OS << "typedef uint16_t poly16_t;\n";
+  OS << "typedef uint64_t poly64_t;\n";
+  OS << "typedef __uint128_t poly128_t;\n";
+  OS << "#else\n";
+  OS << "typedef int8_t poly8_t;\n";
+  OS << "typedef int16_t poly16_t;\n";
+  OS << "#endif\n";
+
+  // Needs to declare all the types in case there is arm_sve.h followed by
+  // arm_neon.h.
+  // arm_sve defines __ARM_NEON_TYPES_H so it avoids to declare again the
+  // types in arm_neon.h

kiranchandramohan wrote:

Consider revising this to say what is being done here and then provide the 
reason.

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


[clang] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-04 Thread Kiran Chandramohan via cfe-commits


@@ -2229,6 +2231,12 @@ void NeonEmitter::runHeader(raw_ostream &OS) {
 static void emitNeonTypeDefs(const std::string& types, raw_ostream &OS) {
   std::string TypedefTypes(types);
   std::vector TDTypeVec = TypeSpec::fromTypeSpecs(TypedefTypes);
+  // arm_sve.h followed by arm_neon.h does not emmit these types
+  // because only arm_sve.h defines __ARM_NEON_TYPES_H
+  // arm_neon.h followed by arm_sve.h emmit these types

kiranchandramohan wrote:

```suggestion
  // arm_neon.h followed by arm_sve.h emit these types
```

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


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

2023-12-21 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan edited 
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] [llvm] [clang] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-21 Thread Kiran Chandramohan via cfe-commits


@@ -349,4 +349,24 @@ def VScaleAttr : Pass<"vscale-attr", "mlir::func::FuncOp"> 
{
   let constructor = "::fir::createVScaleAttrPass()";
 }
 
+def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
+  let summary = "This is a generic pass that adds function attributes expected 
at LLVM IR level";
+  let description = [{ This feature introduces a general attribute aimed at 
customizing function characteristics. 
+ Options include:
+ Add "frame-pointer" attribute to functions: Set an attribute for the 
frame 
+ pointer on functions, to avoid saving the frame pointer in a register in 
+ functions where it is unnecessary. 
+ This eliminates the need for instructions to save, establish, and restore 
+ frame pointers, while also freeing up an additional register in numerous 
functions. 
+ However, this approach can make debugging unfeasible on certain machines.
+  }];

kiranchandramohan wrote:

```suggestion
  let description = [{ This feature introduces a general attribute aimed at
 customizing function characteristics. 
 Options include:
 Add "frame-pointer" attribute to functions: Set an attribute for the frame 
 pointer on functions, to avoid saving the frame pointer in a register in 
 functions where it is unnecessary. This eliminates the need for
 instructions to save, establish, and restore frame pointers, while also
 freeing up an additional register in numerous functions. However, this
 approach can make debugging unfeasible on certain machines.
  }];
```

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


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

2023-12-21 Thread Kiran Chandramohan via cfe-commits

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

LG. Please wait for @banach-space 

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] [llvm] [clang] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-21 Thread Kiran Chandramohan via cfe-commits


@@ -349,4 +349,24 @@ def VScaleAttr : Pass<"vscale-attr", "mlir::func::FuncOp"> 
{
   let constructor = "::fir::createVScaleAttrPass()";
 }
 
+def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
+  let summary = "This is a generic pass that adds function attributes expected 
at LLVM IR level";

kiranchandramohan wrote:

```suggestion
  let summary = "Pass that adds function attributes expected at LLVM IR level";
```

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, Clang] Enable and test 'rdynamic' flag (PR #75598)

2023-12-21 Thread Kiran Chandramohan via cfe-commits

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


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

2023-12-22 Thread Kiran Chandramohan via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");

kiranchandramohan wrote:

@banach-space the test is in func-attr.f90 
https://github.com/llvm/llvm-project/pull/74598/files#diff-1d4cea32c615e677fc20e34ffd2f5c3e0f84b00f5af6a692d787747e17bd9e3d

```
! RUN: not %flang_fc1 -triple aarch64-none-none -mframe-pointer=wrongval 
-emit-llvm -o - %s 2>&1| FileCheck %s --check-prefix=CHECK-WRONGVALUEFP
```

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


[clang] [flang] Fix fveclib on Darwin (PR #77605)

2024-01-10 Thread Kiran Chandramohan via cfe-commits

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

LG. Please add a test if possible.

Assuming the issue was that the Argument was not `rendered` if it is `veclib`.

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


[clang] [flang] [flang][draft] Improve debug info generation. (PR #84202)

2024-03-06 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Thanks for this patch to improve debug support in Flang. If you are planning to 
work long-time on enabling full debug support then it would be good to write a 
design document (in flang/docs), get it agreed upon by everyone and then 
proceed. I attempted some time ago at https://reviews.llvm.org/D138534. Could 
you go through the discussions there? You could adopt a similar style document. 
@jeanPerier @vzakhari and @tblah might have opinions.

There were some questions on how to generate debug info. This could be 
generated during lowering and carried in Ops. Alternatively, one of the 
motivations for adding `hlfir.declare` was to collect and retain variable 
information suitable for debug info generation. `fir.declare` also probably 
helps but it is probably dropped before we get to AddDebugFoundation.

The AddDebugFoundation pass was added to retain some location information 
generation that was lost due to some core MLIR changes. It is not compulsory to 
retain it if there are better ways to generate debug information.

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


[clang] [flang] [flang] Enable polymorphic lowering by default (PR #83285)

2024-02-28 Thread Kiran Chandramohan via cfe-commits

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

LGTM.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Kiran Chandramohan via cfe-commits

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

> Add members "leafs" and "association" to .td describing OpenMP/ACC 
> directives: "leafs" are the leaf constructs for composite/combined 
> constructs, and "association" is the source language construct to which the 
> directive applies (e.g. loop, block, etc.)

Could you clarify that these are terminology used in the OpenMP standard?

Great work @kparzysz.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Kiran Chandramohan via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Kiran Chandramohan via cfe-commits


@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_parallel_workshare)
+return false;

kiranchandramohan wrote:

Nit: A comment that workshare is not applicable to C/C++ might be helpful.

https://github.com/llvm/llvm-project/pull/83625
___
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-01-31 Thread Kiran Chandramohan via cfe-commits


@@ -672,7 +674,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");

kiranchandramohan wrote:

Nit: accidental change.

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-01-31 Thread Kiran Chandramohan via cfe-commits


@@ -2790,3 +2790,27 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, 
Compilation &C,
 }
   }
 }
+
+void tools::addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const 
llvm::opt::ArgList &Args, llvm::opt::ArgStringList & CmdArgs, const 
llvm::Triple &Triple)

kiranchandramohan wrote:

There is probably a clang-format issue here.

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-01-31 Thread Kiran Chandramohan via cfe-commits


@@ -215,11 +215,15 @@ void addMachineOutlinerArgs(const Driver &D, const 
llvm::opt::ArgList &Args,
 void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args,
 StringRef BitcodeSuffix, const llvm::Triple &Triple);
+
+void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const 
llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple 
&Triple);
+
 } // end namespace tools
 } // end namespace driver
 } // end namespace clang
 
 clang::CodeGenOptions::FramePointerKind
 getFramePointerKind(const llvm::opt::ArgList &Args, const llvm::Triple 
&Triple);
 
+  

kiranchandramohan wrote:

Nit: accidental change?

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-01-31 Thread Kiran Chandramohan via cfe-commits


@@ -402,6 +402,21 @@ static void parseTargetArgs(TargetOptions &opts, 
llvm::opt::ArgList &args) {
   for (const llvm::opt::Arg *currentArg :
args.filtered(clang::driver::options::OPT_target_feature))
 opts.featuresAsWritten.emplace_back(currentArg->getValue());
+
+  llvm::Triple targetTriple{llvm::Triple(opts.triple)};
+  if (const llvm::opt::Arg *A =
+  args.getLastArg(clang::driver::options::OPT_moutline_atomics,
+  clang::driver::options::OPT_mno_outline_atomics)) {
+// Option -moutline-atomics supported for AArch64 target only.
+if (targetTriple.isAArch64()) {
+  if (A->getOption().matches(
+  clang::driver::options::OPT_moutline_atomics)) {
+opts.featuresAsWritten.push_back("+outline-atomics");
+  } else {
+opts.featuresAsWritten.push_back("-outline-atomics");
+  }
+}
+  }

kiranchandramohan wrote:

Is this required? I did not see a corresponding change in Clang frontend driver.

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-01-31 Thread Kiran Chandramohan via cfe-commits


@@ -215,11 +215,15 @@ void addMachineOutlinerArgs(const Driver &D, const 
llvm::opt::ArgList &Args,
 void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args,
 StringRef BitcodeSuffix, const llvm::Triple &Triple);
+
+void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const 
llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple 
&Triple);
+

kiranchandramohan wrote:

Nit: clang-format

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-02 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan edited 
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-02 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,18 @@
+! RUN: %flang -S -emit-llvm --target=aarch64-none-none -moutline-atomics -o - 
%s | FileCheck %s --check-prefixes=CHECKON,CHECKALL

kiranchandramohan wrote:

I think it is better if this is in the integration test directory.

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 Kiran Chandramohan via cfe-commits

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

LG. Please address or reply to comments before submitting.

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-tools-extra] [clang] [llvm] [flang] [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (PR #76258)

2024-01-12 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan updated 
https://github.com/llvm/llvm-project/pull/76258

>From 03e611d413cffa6ff7432a8a88db5d6901449f3c Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan 
Date: Fri, 22 Dec 2023 18:35:00 +
Subject: [PATCH] [Flang][OpenMP] Avoid default none errors for seq loop
 indices in parallel

---
 flang/lib/Semantics/resolve-directives.cpp |  6 +-
 flang/test/Semantics/OpenMP/resolve05.f90  | 13 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Semantics/resolve-directives.cpp 
b/flang/lib/Semantics/resolve-directives.cpp
index da6c865ad56a3b..6e782204e6368c 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1910,7 +1910,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) 
{
   if (Symbol * found{currScope().FindSymbol(name.source)}) {
 if (symbol != found) {
   name.symbol = found; // adjust the symbol within region
-} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone) {
+} else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
+// Exclude indices of sequential loops that are privatised in
+// the scope of the parallel region, and not in this scope.
+// TODO: check whether this should be caught in IsObjectWithDSA
+!symbol->test(Symbol::Flag::OmpPrivate)) {
   context_.Say(name.source,
   "The DEFAULT(NONE) clause requires that '%s' must be listed in "
   "a data-sharing attribute clause"_err_en_US,
diff --git a/flang/test/Semantics/OpenMP/resolve05.f90 
b/flang/test/Semantics/OpenMP/resolve05.f90
index 00f4860302183d..c4cebb48ac5c2b 100644
--- a/flang/test/Semantics/OpenMP/resolve05.f90
+++ b/flang/test/Semantics/OpenMP/resolve05.f90
@@ -17,7 +17,20 @@ subroutine default_none()
   !$omp end parallel
 end subroutine default_none
 
+! Test that indices of sequential loops are privatised and hence do not error
+! for DEFAULT(NONE)
+subroutine default_none_seq_loop
+  integer :: i
+
+  !$omp parallel do default(none)
+  do i = 1, 10
+ do j = 1, 20
+enddo
+  enddo
+end subroutine
+
 program mm
   call default_none()
+  call default_none_seq_loop()
   !TODO: private, firstprivate, shared
 end

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


[clang-tools-extra] [clang] [llvm] [flang] [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (PR #76258)

2024-01-12 Thread Kiran Chandramohan via cfe-commits

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


[clang-tools-extra] [libcxx] [compiler-rt] [libc] [lldb] [libcxxabi] [flang] [lld] [clang] [llvm] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)

2024-01-15 Thread Kiran Chandramohan via cfe-commits

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


[clang-tools-extra] [flang] [libcxx] [lld] [libcxxabi] [llvm] [lldb] [libc] [clang] [compiler-rt] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)

2024-01-15 Thread Kiran Chandramohan via cfe-commits

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

LG.

Please add a pointer to the discussion where it was agreed to pass a reference 
to the localSymbolTable.

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


[compiler-rt] [libcxxabi] [libcxx] [llvm] [libc] [clang-tools-extra] [lldb] [flang] [lld] [clang] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)

2024-01-15 Thread Kiran Chandramohan via cfe-commits


@@ -110,6 +110,34 @@ static void gatherFuncAndVarSyms(
   }
 }
 
+static Fortran::lower::pft::Evaluation *
+getCollapsedEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) {
+  // Return the Evaluation of the innermost collapsed loop, or the current
+  // evaluation, if there is nothing to collapse.
+  if (collapseValue == 0)
+return &eval;

kiranchandramohan wrote:

Nit: Is it better to convert this to an assert (for > 0) and move this code to 
the parent function?

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


[clang] [flang] [flang][driver] Allow explicit specification of -lFortran_main (PR #78152)

2024-01-15 Thread Kiran Chandramohan via cfe-commits


@@ -1200,6 +1200,14 @@ static void addFortranMain(const ToolChain &TC, const 
ArgList &Args,
   // TODO: Find an equivalent of `--whole-archive` for Darwin and AIX.
   if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX() &&
   !TC.getTriple().isOSAIX()) {
+// Adding -lFortran_main with --whole-archive will create an error if the
+// user specifies -lFortran_main explicitly. Remove the user's
+// -lFortran_main arguments to avoid this (making sure -lFortran_main
+// behaves the same as -lFortranRuntime)
+llvm::erase_if(CmdArgs, [](const char *arg) {
+  return strcmp(arg, "-lFortran_main") == 0;

kiranchandramohan wrote:

Nit: I think you should use `strncmp` here.

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


[flang] [clang] [clang-tools-extra] [llvm] [Flang][OpenMP] Avoid default none errors for seq loop indices in par… (PR #76258)

2024-01-15 Thread Kiran Chandramohan via cfe-commits

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


[compiler-rt] [libc] [clang-tools-extra] [libcxx] [libcxxabi] [llvm] [lldb] [clang] [lld] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)

2024-01-15 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

> Introduce createSectionOp

`genSectionOp`?

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


[compiler-rt] [libc] [clang-tools-extra] [libcxx] [libcxxabi] [llvm] [lldb] [clang] [lld] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)

2024-01-15 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[flang] [llvm] [clang] [libcxx] [mlir] [Flang][OpenMP] : Add a temporary lowering for workshare directive (PR #78268)

2024-01-16 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan updated 
https://github.com/llvm/llvm-project/pull/78268

>From 71c3449d872247e3af05de545e907407ac7ac9f9 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan 
Date: Tue, 16 Jan 2024 12:45:23 +
Subject: [PATCH] [Flang][OpenMP] : Add a temporary lowering for workshare
 directive

As a temporary solution, lower workshare to the single directive
---
 flang/lib/Lower/OpenMP.cpp|  6 +-
 flang/test/Lower/OpenMP/workshare.f90 | 16 
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Lower/OpenMP/workshare.f90

diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 4f7c99a6d2b840..24531c9f70685f 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3312,7 +3312,11 @@ genOMP(Fortran::lower::AbstractConverter &converter,
/*outerCombined=*/false);
 break;
   case llvm::omp::Directive::OMPD_workshare:
-TODO(currentLocation, "Workshare construct");
+// FIXME: Workshare is not a commonly used OpenMP construct, an
+// implementation for this feature will come later. For the codes
+// that use this construct, add a single construct for now.
+genSingleOp(converter, eval, currentLocation, beginClauseList,
+endClauseList);
 break;
   default: {
 // Codegen for combined directives
diff --git a/flang/test/Lower/OpenMP/workshare.f90 
b/flang/test/Lower/OpenMP/workshare.f90
new file mode 100644
index 00..7f63c99ab05965
--- /dev/null
+++ b/flang/test/Lower/OpenMP/workshare.f90
@@ -0,0 +1,16 @@
+
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: func @_QPsb
+subroutine sb(arr)
+  integer :: arr(:)
+!CHECK: omp.parallel  {
+  !$omp parallel
+!CHECK: omp.single  {
+  !$omp workshare
+arr = 0
+  !$omp end workshare
+!CHECK: }
+  !$omp end parallel
+!CHECK: }
+end subroutine

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


[flang] [compiler-rt] [clang] [llvm] [clang-tools-extra] [Flang][OpenMP] Push genEval closer to leaf lowering functions (PR #77760)

2024-01-18 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[libc] [flang] [compiler-rt] [clang-tools-extra] [llvm] [clang] [flang] use setsid to assign the child to prevent zombie as it will be clean up by init process (PR #77944)

2024-01-18 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Could you add a test?

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


[flang] [compiler-rt] [clang] [llvm] [clang-tools-extra] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-18 Thread Kiran Chandramohan via cfe-commits


@@ -2186,11 +2178,43 @@ static void createBodyOfOp(
 const llvm::SmallVector &args = {},
 bool outerCombined = false, DataSharingProcessor *dsp = nullptr) {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+
+  auto insertMarker = [](fir::FirOpBuilder &builder) {
+mlir::Value undef = builder.create(builder.getUnknownLoc(),
+ builder.getIndexType());
+return undef.getDefiningOp();
+  };
+
+  // Find the block where the OMP terminator should go. In simple cases
+  // it is the single block in the operation's region. When the region
+  // is more complicated, especially with unstructured control flow, there
+  // may be multiple blocks, and some of them may have non-OMP terminators
+  // resulting from lowering of the code contained within the operation.
+  // By OpenMP rules, there should be a single exit point from the region:
+  // here exit means transfering control to the code following the operation.
+  // STOP statement is allowed and does not count as exit for the purpose of

kiranchandramohan wrote:

Where is the STOP statement accounted for here? The code here looks like find 
the block without a terminator and assert that there is only ONE.

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


[clang] [compiler-rt] [flang] [llvm] [clang-tools-extra] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-18 Thread Kiran Chandramohan via cfe-commits


@@ -2223,37 +2247,64 @@ static void createBodyOfOp(
 mlir::omp::YieldOp>(
 firOpBuilder, eval.getNestedEvaluations());
 
-  // Insert the terminator.
-  Fortran::lower::genOpenMPTerminator(firOpBuilder, op.getOperation(), loc);
-  // Reset the insert point to before the terminator.
-  resetBeforeTerminator(firOpBuilder, storeOp, block);
+  // Start with privatization, so that the lowering of the nested
+  // code will use the right symbols.
+  constexpr bool isLoop = std::is_same_v ||
+  std::is_same_v;
+  bool privatize = clauses && !outerCombined;
 
-  // Handle privatization. Do not privatize if this is the outer operation.
-  if (clauses && !outerCombined) {
-constexpr bool isLoop = std::is_same_v ||
-std::is_same_v;
+  firOpBuilder.setInsertionPoint(marker);
+  std::optional tempDsp;
+  if (privatize) {
 if (!dsp) {
-  DataSharingProcessor proc(converter, *clauses, eval);
-  proc.processStep1();
-  proc.processStep2(op, isLoop);
-} else {
-  if (isLoop && args.size() > 0)
-dsp->setLoopIV(converter.getSymbolAddress(*args[0]));
-  dsp->processStep2(op, isLoop);
+  tempDsp.emplace(converter, *clauses, eval);
+  tempDsp->processStep1();
 }
-
-if (storeOp)
-  firOpBuilder.setInsertionPointAfter(storeOp);
   }
 
   if constexpr (std::is_same_v) {
 threadPrivatizeVars(converter, eval);
-if (clauses)
+if (clauses) {
+  firOpBuilder.setInsertionPoint(marker);
   ClauseProcessor(converter, *clauses).processCopyin();
+}
   }
 
-  if (genNested)
+  if (genNested) {
+// genFIR(Evaluation&) tries to patch up unterminated blocks, causing
+// a lot of trouble if the terminator generation is delayed past this
+// point. Insert a temporary terminator here, then delete it.
+firOpBuilder.setInsertionPointToEnd(&op.getRegion().back());
+auto *temp = Fortran::lower::genOpenMPTerminator(firOpBuilder,
+ op.getOperation(), loc);
+firOpBuilder.setInsertionPointAfter(marker);
 genNestedEvaluations(converter, eval);
+temp->erase();
+  }
+
+  if (auto *exitBlock = findExitBlock(op.getRegion())) {
+firOpBuilder.setInsertionPointToEnd(exitBlock);
+auto *term = Fortran::lower::genOpenMPTerminator(firOpBuilder,
+ op.getOperation(), loc);
+// Only insert lastprivate code when there actually is an exit block.
+// Such a block may not exist if the nested code produced an infinite
+// loop (this may not make sense in production code, but a user could
+// write that and we should handle it).

kiranchandramohan wrote:

Is it guaranteed that it is only when there is an infinite loop that no exit 
block exists?
Also who/what inserts the terminator for this case (when there is infinite 
loop)?

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


[libc] [clang-tools-extra] [compiler-rt] [flang] [llvm] [clang] [flang] use setsid to assign the child to prevent zombie as it will be clean up by init process (PR #77944)

2024-01-19 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[clang-tools-extra] [llvm] [compiler-rt] [clang] [flang] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-19 Thread Kiran Chandramohan via cfe-commits

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

LGTM.

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


[llvm] [clang] [compiler-rt] [flang] [clang-tools-extra] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-19 Thread Kiran Chandramohan via cfe-commits

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


[compiler-rt] [clang] [flang] [clang-tools-extra] [llvm] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-19 Thread Kiran Chandramohan via cfe-commits


@@ -2223,37 +2247,64 @@ static void createBodyOfOp(
 mlir::omp::YieldOp>(
 firOpBuilder, eval.getNestedEvaluations());
 
-  // Insert the terminator.
-  Fortran::lower::genOpenMPTerminator(firOpBuilder, op.getOperation(), loc);
-  // Reset the insert point to before the terminator.
-  resetBeforeTerminator(firOpBuilder, storeOp, block);
+  // Start with privatization, so that the lowering of the nested
+  // code will use the right symbols.
+  constexpr bool isLoop = std::is_same_v ||
+  std::is_same_v;
+  bool privatize = clauses && !outerCombined;
 
-  // Handle privatization. Do not privatize if this is the outer operation.
-  if (clauses && !outerCombined) {
-constexpr bool isLoop = std::is_same_v ||
-std::is_same_v;
+  firOpBuilder.setInsertionPoint(marker);
+  std::optional tempDsp;
+  if (privatize) {
 if (!dsp) {
-  DataSharingProcessor proc(converter, *clauses, eval);
-  proc.processStep1();
-  proc.processStep2(op, isLoop);
-} else {
-  if (isLoop && args.size() > 0)
-dsp->setLoopIV(converter.getSymbolAddress(*args[0]));
-  dsp->processStep2(op, isLoop);
+  tempDsp.emplace(converter, *clauses, eval);
+  tempDsp->processStep1();
 }
-
-if (storeOp)
-  firOpBuilder.setInsertionPointAfter(storeOp);
   }
 
   if constexpr (std::is_same_v) {
 threadPrivatizeVars(converter, eval);
-if (clauses)
+if (clauses) {
+  firOpBuilder.setInsertionPoint(marker);
   ClauseProcessor(converter, *clauses).processCopyin();
+}
   }
 
-  if (genNested)
+  if (genNested) {
+// genFIR(Evaluation&) tries to patch up unterminated blocks, causing
+// a lot of trouble if the terminator generation is delayed past this
+// point. Insert a temporary terminator here, then delete it.
+firOpBuilder.setInsertionPointToEnd(&op.getRegion().back());
+auto *temp = Fortran::lower::genOpenMPTerminator(firOpBuilder,
+ op.getOperation(), loc);
+firOpBuilder.setInsertionPointAfter(marker);
 genNestedEvaluations(converter, eval);
+temp->erase();
+  }
+
+  if (auto *exitBlock = findExitBlock(op.getRegion())) {
+firOpBuilder.setInsertionPointToEnd(exitBlock);
+auto *term = Fortran::lower::genOpenMPTerminator(firOpBuilder,
+ op.getOperation(), loc);
+// Only insert lastprivate code when there actually is an exit block.
+// Such a block may not exist if the nested code produced an infinite
+// loop (this may not make sense in production code, but a user could
+// write that and we should handle it).

kiranchandramohan wrote:

OK. Makes sense.

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


[llvm] [flang] [compiler-rt] [clang] [clang-tools-extra] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-19 Thread Kiran Chandramohan via cfe-commits


@@ -2223,37 +,100 @@ static void createBodyOfOp(
 mlir::omp::YieldOp>(
 firOpBuilder, eval.getNestedEvaluations());
 
-  // Insert the terminator.
-  Fortran::lower::genOpenMPTerminator(firOpBuilder, op.getOperation(), loc);
-  // Reset the insert point to before the terminator.
-  resetBeforeTerminator(firOpBuilder, storeOp, block);
+  // Start with privatization, so that the lowering of the nested
+  // code will use the right symbols.
+  constexpr bool isLoop = std::is_same_v ||
+  std::is_same_v;
+  bool privatize = clauses && !outerCombined;
 
-  // Handle privatization. Do not privatize if this is the outer operation.
-  if (clauses && !outerCombined) {
-constexpr bool isLoop = std::is_same_v ||
-std::is_same_v;
+  firOpBuilder.setInsertionPoint(marker);
+  std::optional tempDsp;
+  if (privatize) {
 if (!dsp) {
-  DataSharingProcessor proc(converter, *clauses, eval);
-  proc.processStep1();
-  proc.processStep2(op, isLoop);
-} else {
-  if (isLoop && args.size() > 0)
-dsp->setLoopIV(converter.getSymbolAddress(*args[0]));
-  dsp->processStep2(op, isLoop);
+  tempDsp.emplace(converter, *clauses, eval);
+  tempDsp->processStep1();
 }
-
-if (storeOp)
-  firOpBuilder.setInsertionPointAfter(storeOp);
   }
 
   if constexpr (std::is_same_v) {
 threadPrivatizeVars(converter, eval);
-if (clauses)
+if (clauses) {
+  firOpBuilder.setInsertionPoint(marker);
   ClauseProcessor(converter, *clauses).processCopyin();
+}
   }
 
-  if (genNested)
+  if (genNested) {
+// genFIR(Evaluation&) tries to patch up unterminated blocks, causing
+// a lot of trouble if the terminator generation is delayed past this
+// point. Insert a temporary terminator here, then delete it.
+firOpBuilder.setInsertionPointToEnd(&op.getRegion().back());
+auto *temp = Fortran::lower::genOpenMPTerminator(firOpBuilder,
+ op.getOperation(), loc);
+firOpBuilder.setInsertionPointAfter(marker);
 genNestedEvaluations(converter, eval);
+temp->erase();
+  }
+
+  // Get or create a unique exiting block from the given region, or
+  // return nullptr if there is no exiting block.
+  auto getUniqueExit = [&](mlir::Region ®ion) -> mlir::Block * {
+// Find the blocks where the OMP terminator should go. In simple cases
+// it is the single block in the operation's region. When the region
+// is more complicated, especially with unstructured control flow, there
+// may be multiple blocks, and some of them may have non-OMP terminators
+// resulting from lowering of the code contained within the operation.
+// All the remaining blocks are potential exit points from the op's region.
+//
+// Explicit control flow cannot exit any OpenMP region (other than via
+// STOP), and that is enforced by semantic checks prior to lowering. STOP
+// statements are lowered to a function call.
+
+// Collect unterminated blocks.
+llvm::SmallVector exits;
+for (mlir::Block &b : region) {
+  if (b.empty() || !b.back().hasTrait())
+exits.push_back(&b);
+}
+
+if (exits.empty())
+  return nullptr;
+// If there already is a unique exiting block, do not create another one.
+// Additionally, some ops (e.g. omp.sections) require onlt 1 block in

kiranchandramohan wrote:

```suggestion
// Additionally, some ops (e.g. omp.sections) require only 1 block in
```

https://github.com/llvm/llvm-project/pull/77761
___
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-01-19 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,11 @@
+! Test that flang-new forwards the -moutline-atomics and -mno-outline-atomics.
+! RUN: %flang -moutline-atomics --target=aarch64-none-none -### %s -o %t 2>&1  
| FileCheck %s
+! CHECK: "-target-feature" "+outline-atomics"
+
+! RUN: %flang -mno-outline-atomics --target=aarch64-none-none -### %s -o %t 
2>&1  | FileCheck %s --check-prefix=CHECK-NOOUTLINE
+! CHECK-NOOUTLINE: "-target-feature" "-outline-atomics"
+
+! RUN: %flang -mno-outline-atomics --target=x86-none-none -### %s -o %t 2>&1  
| FileCheck %s --check-prefix=CHECK-ERRMSG
+! CHECK-ERRMSG: warning: 'x86' does not support '-mno-outline-atomics'

kiranchandramohan wrote:

Should there be a test to check the behaviour when no outline flags are 
specified and the target is `aarch64`?

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-01-19 Thread Kiran Chandramohan via cfe-commits


@@ -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");
+  }

kiranchandramohan wrote:

Can this code be shared with `Clang` ?

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] c551ba0 - Run test only if X86 target is available

2020-10-26 Thread Kiran Chandramohan via cfe-commits

Author: Kiran Chandramohan
Date: 2020-10-26T21:28:59Z
New Revision: c551ba0e90bd2b49ef501d591f8362ba44e5484d

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

LOG: Run test only if X86 target is available

This fixes failures in AArch64 buildbots by running the
clang/test/CodeGen/X86/att-inline-asm-prefix.c only when the X86
target is available.

Added: 


Modified: 
clang/test/CodeGen/X86/att-inline-asm-prefix.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/att-inline-asm-prefix.c 
b/clang/test/CodeGen/X86/att-inline-asm-prefix.c
index 9bd0d937d86e6..789e1f98a2a15 100644
--- a/clang/test/CodeGen/X86/att-inline-asm-prefix.c
+++ b/clang/test/CodeGen/X86/att-inline-asm-prefix.c
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+
 // RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc -target-feature 
+avx512f -target-feature +avx2 -target-feature +avx512vl -S -o -  | FileCheck 
%s -check-prefix CHECK
 
 // This test is to check if the prefix in inline assembly is correctly



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


[clang] a784de7 - [flang] Add -ffp-contract option processing

2022-10-31 Thread Kiran Chandramohan via cfe-commits

Author: Tom Eccles
Date: 2022-10-31T11:32:31Z
New Revision: a784de783af5096e593c5e214c2c78215fe303f5

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

LOG: [flang] Add -ffp-contract option processing

Only add the option processing and store the result. No attributes are
added to FIR yet.

Only the "off" and "fast" options are supported. "fast-honor-pragmas" is not 
applicable because we do not implement `#pragma clang fp contract()` in Fortran 
[1]. "on" is not supported because it is unclear how to fuse only within 
individual statements. gfortran also does not implement "on": treating it as an 
"off".

Currently the default value is "off" to preserve existing behavior. gfortran 
uses "fast" by default and that may be the right thing for flang-new after 
further discussion in the future, but that can be changed separately. 
gfortran's documentation is available [[ 
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html | here ]].

[1] 
https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags

Reviewed By: vzakhari, awarzynski

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

Added: 
flang/include/flang/Frontend/LangOptions.def
flang/include/flang/Frontend/LangOptions.h
flang/lib/Frontend/LangOptions.cpp
flang/test/Driver/flang_fp_opts.f90

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/CompilerInvocation.h
flang/lib/Frontend/CMakeLists.txt
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/flang_f_opts.f90
flang/test/Driver/frontend-forwarding.f90

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e477d93ba067f..44c277b3c3d8b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -110,6 +110,9 @@ def 
warn_drv_unsupported_option_for_offload_arch_req_feature : Warning<
 def warn_drv_unsupported_option_for_target : Warning<
   "ignoring '%0' option as it is not currently supported for target '%1'">,
   InGroup;
+def warn_drv_unsupported_option_for_flang : Warning<
+  "the argument '%0' is not supported for option '%1'. Mapping to '%1%2'">,
+  InGroup;
 
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6d2c999873733..aa199e4608741 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1919,12 +1919,14 @@ def fno_rounding_math : Flag<["-"], 
"fno-rounding-math">, Group, Flags<
 def ftrapping_math : Flag<["-"], "ftrapping-math">, Group;
 def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group;
 def ffp_contract : Joined<["-"], "ffp-contract=">, Group,
-  Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs):"
+  Flags<[CC1Option, FC1Option, FlangOption]>,
+  DocBrief<"Form fused FP ops (e.g. FMAs):"
   " fast (fuses across statements disregarding pragmas)"
   " | on (only fuses in the same statement unless dictated by pragmas)"
   " | off (never fuses)"
   " | fast-honor-pragmas (fuses across statements unless diectated by 
pragmas)."
   " Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' 
otherwise.">,
+  HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
 
 defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow",

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 964f0e2617047..6c6895da61299 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -80,6 +80,31 @@ void Flang::AddPicOptions(const ArgList &Args, ArgStringList 
&CmdArgs) const {
   }
 }
 
+static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  StringRef FPContract;
+
+  if (const Arg *A = Args.getLastArg(options::OPT_ffp_contract)) {
+const StringRef Val = A->getValue();
+if (Val == "fast" || Val == "off") {
+  FPContract = Val;
+} else if (Val == "on") {
+  // Warn instead of error because users might have makefiles written for
+  // gfortran (which accepts -ffp-contract=on)
+  D.Diag(diag::warn_drv_unsupported_option_for_flang)
+  << Val << A->getOption().getName() << "off";
+  FPContract = "off";
+} else
+  // Clang's "fast-honor-pragmas" option is not suppo

[clang] cd86a03 - [clang,flang] Add help text for -fsyntax-only

2022-08-19 Thread Kiran Chandramohan via cfe-commits

Author: Alexander Malkov
Date: 2022-08-19T09:54:29Z
New Revision: cd86a03246a2df350c2f694457f1ce946cf65663

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

LOG: [clang,flang] Add help text for -fsyntax-only

Fix for the problem with displaying options `-fsyntax-only` in clang and 
flang-new in help
Fix https://github.com/llvm/llvm-project/issues/57033

Before:
``` $ clang  -help | grep syntax
  -objcmt-migrate-property-dot-syntax
 Enable migration of setter/getter messages to property-dot syntax
```
After:
```
 $ clang -help | grep syntax
  -fsyntax-only   Run the preprocessor, parser and semantic analysis 
stages
  -objcmt-migrate-property-dot-syntax
 Enable migration of setter/getter messages to property-dot syntax
```

Reviewed By: vzakhari, awarzynski, MaskRay, alexiprof

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/CommandGuide/clang.rst
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 265a6d7beb6e9..7f9ef3783f9da 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -831,6 +831,8 @@ Only run the driver.
 
 .. option:: -fsyntax-only
 
+Run the preprocessor, parser and semantic analysis stages
+
 .. option:: -module-file-info
 
 Provide information about a particular module file

diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index af2b0df98d3dc..5e344ec702777 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -75,7 +75,7 @@ Stage Selection Options
 
 .. option:: -fsyntax-only
 
- Run the preprocessor, parser and type checking stages.
+ Run the preprocessor, parser and semantic analysis stages.
 
 .. option:: -S
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f9ccca65f3889..78ccf4572ffc8 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3999,7 +3999,7 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   /Zl Don't mention any default libraries in the 
object file
   /Zp Set the default maximum struct packing alignment 
to 1
   /Zp  Specify the default maximum struct packing 
alignment
-  /Zs Syntax-check only
+  /Zs Run the preprocessor, parser and semantic 
analysis stages
 
 OPTIONS:
   -###Print (but do not run) the commands to run for 
this compilation
@@ -4130,6 +4130,7 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   behavior. See user manual for available checks
   -fsplit-lto-unitEnables splitting of the LTO unit.
   -fstandalone-debug  Emit full debug info for all types used by the 
program
+  -fsyntax-only   Run the preprocessor, parser and semantic 
analysis stages
   -fwhole-program-vtables Enables whole-program vtable optimization. 
Requires -flto
   -gcodeview-ghashEmit type record hashes in a .debug$H section
   -gcodeview  Generate CodeView debug information

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a5dfeec4fd463..c8178c13e82e9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2800,7 +2800,8 @@ def fstrict_overflow : Flag<["-"], "fstrict-overflow">, 
Group;
 def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
   Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Run the preprocessor, parser and semantic analysis stages">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;
 def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group;
 def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group;
@@ -6618,7 +6619,7 @@ def _SLASH_Zp : CLJoined<"Zp">,
 def _SLASH_Zp_flag : CLFlag<"Zp">,
   HelpText<"Set default maximum struct packing alignment to 1">,
   Alias, AliasArgs<["1"]>;
-def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
+def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Run the preprocessor, parser and 
semantic analysis stages">,
   Alias;
 def _SLASH_openmp_ : CLFlag<"openmp-">,
   HelpText<"Disable OpenMP support">, Alias;

diff  --git

[libunwind] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-03 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,136 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @foo()
+
+// CHECK-LABEL: @omp_teams_simple
+// CHECK: call void {{.*}} @__kmpc_fork_teams(ptr @{{.+}}, i32 0, ptr 
[[wrapperfn:.+]])

kiranchandramohan wrote:

Could you convert the captured variables (eg. wrapperfn) to caps? This is to 
distinguish them easily from code.

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


[clang] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-03 Thread Kiran Chandramohan via cfe-commits

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

LGTM.

Will the wrapper function stay or be removed?

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


[libunwind] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-03 Thread Kiran Chandramohan via cfe-commits

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

LGTM.

Will the wrapper function stay or be removed?

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


[clang] [mlir][OpenMP] Added translation for `omp.teams` to LLVM IR (PR #68042)

2023-10-03 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,136 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @foo()
+
+// CHECK-LABEL: @omp_teams_simple
+// CHECK: call void {{.*}} @__kmpc_fork_teams(ptr @{{.+}}, i32 0, ptr 
[[wrapperfn:.+]])

kiranchandramohan wrote:

Could you convert the captured variables (eg. wrapperfn) to caps? This is to 
distinguish them easily from code.

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


[clang-tools-extra] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits

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


[clang-tools-extra] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -5748,6 +5758,7 @@ OpenMPIRBuilder::createTeams(const LocationDescription 
&Loc,
 BasicBlock *BodyBB = splitBB(Builder, /*CreateBranch=*/true, 
"teams.entry");
 Builder.SetInsertPoint(BodyBB, BodyBB->begin());
   }
+  InsertPointTy OuterAllocaIP(&OuterAllocaBB, OuterAllocaBB.begin());

kiranchandramohan wrote:

Can this be defined close to its use?

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


[clang] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -5748,6 +5758,7 @@ OpenMPIRBuilder::createTeams(const LocationDescription 
&Loc,
 BasicBlock *BodyBB = splitBB(Builder, /*CreateBranch=*/true, 
"teams.entry");
 Builder.SetInsertPoint(BodyBB, BodyBB->begin());
   }
+  InsertPointTy OuterAllocaIP(&OuterAllocaBB, OuterAllocaBB.begin());

kiranchandramohan wrote:

Can this be defined close to its use?

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


[clang-tools-extra] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -340,6 +340,44 @@ BasicBlock *llvm::splitBBWithSuffix(IRBuilderBase 
&Builder, bool CreateBranch,
   return splitBB(Builder, CreateBranch, Old->getName() + Suffix);
 }
 
+// This function creates a fake integer value and a fake use for the integer
+// value. It returns the fake value created. This is useful in modeling the
+// extra arguments to the outlined functions.
+Value *createFakeIntVal(IRBuilder<> &Builder,
+OpenMPIRBuilder::InsertPointTy OuterAllocaIP,
+std::stack &ToBeDeleted,
+OpenMPIRBuilder::InsertPointTy InnerAllocaIP,
+const Twine &Name = "", bool AsPtr = true) {
+  Builder.restoreIP(OuterAllocaIP);
+  Instruction *FakeVal;
+  AllocaInst *FakeValAddr =
+  Builder.CreateAlloca(Builder.getInt32Ty(), nullptr, Name + ".addr");
+  ToBeDeleted.push(FakeValAddr);
+
+  if (AsPtr)
+FakeVal = FakeValAddr;
+  else {
+FakeVal =
+Builder.CreateLoad(Builder.getInt32Ty(), FakeValAddr, Name + ".val");
+ToBeDeleted.push(FakeVal);

kiranchandramohan wrote:

Would this delete twice for the `AsPtr` case?

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


[libunwind] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -340,6 +340,44 @@ BasicBlock *llvm::splitBBWithSuffix(IRBuilderBase 
&Builder, bool CreateBranch,
   return splitBB(Builder, CreateBranch, Old->getName() + Suffix);
 }
 
+// This function creates a fake integer value and a fake use for the integer
+// value. It returns the fake value created. This is useful in modeling the
+// extra arguments to the outlined functions.
+Value *createFakeIntVal(IRBuilder<> &Builder,
+OpenMPIRBuilder::InsertPointTy OuterAllocaIP,
+std::stack &ToBeDeleted,
+OpenMPIRBuilder::InsertPointTy InnerAllocaIP,
+const Twine &Name = "", bool AsPtr = true) {
+  Builder.restoreIP(OuterAllocaIP);
+  Instruction *FakeVal;
+  AllocaInst *FakeValAddr =
+  Builder.CreateAlloca(Builder.getInt32Ty(), nullptr, Name + ".addr");
+  ToBeDeleted.push(FakeValAddr);
+
+  if (AsPtr)
+FakeVal = FakeValAddr;
+  else {

kiranchandramohan wrote:

Nit: braces to match else. Same for tid below.

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


[clang] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits

https://github.com/kiranchandramohan commented:

Could you expand the summary to describe the changes.
What are the changes required to remove the wrapper function (Why was it 
required in the first place?)
Why are the fake vals necessary?


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


[libunwind] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits

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


[clang] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -340,6 +340,44 @@ BasicBlock *llvm::splitBBWithSuffix(IRBuilderBase 
&Builder, bool CreateBranch,
   return splitBB(Builder, CreateBranch, Old->getName() + Suffix);
 }
 
+// This function creates a fake integer value and a fake use for the integer
+// value. It returns the fake value created. This is useful in modeling the
+// extra arguments to the outlined functions.
+Value *createFakeIntVal(IRBuilder<> &Builder,
+OpenMPIRBuilder::InsertPointTy OuterAllocaIP,
+std::stack &ToBeDeleted,
+OpenMPIRBuilder::InsertPointTy InnerAllocaIP,
+const Twine &Name = "", bool AsPtr = true) {
+  Builder.restoreIP(OuterAllocaIP);
+  Instruction *FakeVal;
+  AllocaInst *FakeValAddr =
+  Builder.CreateAlloca(Builder.getInt32Ty(), nullptr, Name + ".addr");
+  ToBeDeleted.push(FakeValAddr);
+
+  if (AsPtr)
+FakeVal = FakeValAddr;
+  else {
+FakeVal =
+Builder.CreateLoad(Builder.getInt32Ty(), FakeValAddr, Name + ".val");
+ToBeDeleted.push(FakeVal);

kiranchandramohan wrote:

Would this delete twice for the `AsPtr` case?

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


[libunwind] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -5748,6 +5758,7 @@ OpenMPIRBuilder::createTeams(const LocationDescription 
&Loc,
 BasicBlock *BodyBB = splitBB(Builder, /*CreateBranch=*/true, 
"teams.entry");
 Builder.SetInsertPoint(BodyBB, BodyBB->begin());
   }
+  InsertPointTy OuterAllocaIP(&OuterAllocaBB, OuterAllocaBB.begin());

kiranchandramohan wrote:

Can this be defined close to its use?

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


[clang-tools-extra] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-05 Thread Kiran Chandramohan via cfe-commits


@@ -340,6 +340,44 @@ BasicBlock *llvm::splitBBWithSuffix(IRBuilderBase 
&Builder, bool CreateBranch,
   return splitBB(Builder, CreateBranch, Old->getName() + Suffix);
 }
 
+// This function creates a fake integer value and a fake use for the integer
+// value. It returns the fake value created. This is useful in modeling the
+// extra arguments to the outlined functions.
+Value *createFakeIntVal(IRBuilder<> &Builder,
+OpenMPIRBuilder::InsertPointTy OuterAllocaIP,
+std::stack &ToBeDeleted,
+OpenMPIRBuilder::InsertPointTy InnerAllocaIP,
+const Twine &Name = "", bool AsPtr = true) {
+  Builder.restoreIP(OuterAllocaIP);
+  Instruction *FakeVal;
+  AllocaInst *FakeValAddr =
+  Builder.CreateAlloca(Builder.getInt32Ty(), nullptr, Name + ".addr");
+  ToBeDeleted.push(FakeValAddr);
+
+  if (AsPtr)
+FakeVal = FakeValAddr;
+  else {

kiranchandramohan wrote:

Nit: braces to match else. Same for tid below.

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


  1   2   3   >