[clang] [flang] [flang][driver] add -flang-deprecated-no-hlfir hidden option (PR #71820)
https://github.com/vzakhari approved this pull request. Thank you, Jean! https://github.com/llvm/llvm-project/pull/71820 ___ 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)
https://github.com/vzakhari 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)
https://github.com/vzakhari commented: Thank you for the changes, Tom! I have one minor comment, but I would like to ask to merge this after US holidays, if possible. Could you please postpone the merging until Monday GMT? 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)
@@ -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); vzakhari wrote: It looks like `clang` generates `tbaa` metadata at all opt levels, except `-O0`. I think this makes sense: the optimization themselves need to decide how to use it, e.g. for improving performance/code-size/etc. 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] [APINotes] Upstream APINotesOptions (PR #70827)
vzakhari wrote: Hello @egorzhdan, this change breaks https://lab.llvm.org/buildbot/#/builders/270/builds/2125. Could you please fix or revert? https://github.com/llvm/llvm-project/pull/70827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] WIP: [flang] Enable fir alias tags pass by default when optimizing for speed (PR #68597)
vzakhari wrote: Hi @tblah, is this ready for a merge? Let me know if you are just waiting for a review. https://github.com/llvm/llvm-project/pull/68597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] (Re-)Enable alias tags pass by default (PR #74250)
https://github.com/vzakhari commented: Thank you, Tom! 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] [flang] [flang][cuda] Add -fcuda option (PR #84944)
https://github.com/vzakhari approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][cuda] Add -fcuda option (PR #84944)
https://github.com/vzakhari edited https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][cuda] Add -fcuda option (PR #84944)
@@ -6488,6 +6488,9 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", PosFlag, NegFlag>; + +def fcuda : Flag<["-"], "fcuda">, Group, vzakhari wrote: I wonder if we also want to wire it to clang's `-x cuda` option. It might be good to use the same flags for clang/flang in makefiles/cmake. Though, I am not sure if the meaning of the two options is exactly the same. Maybe someone else knows. https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/82832 Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. >From 81ea8a2cf3a1cb4b9e99d590f7a80b156fe609b8 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index e5196bd8b5ae9e..6c620a7f247a10 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,13 +1285,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --ta
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From 81ea8a2cf3a1cb4b9e99d590f7a80b156fe609b8 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index e5196bd8b5ae9e..6c620a7f247a10 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,13 +1285,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From fea6f95d3cfaa3ae75e0f8312198a20c36e79ad7 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From 4ad0b005081fe2286970b4c22721fe72ed26cf8b Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From ef2b9e87295688743771f1a64b15aa6fee6499df Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari closed https://github.com/llvm/llvm-project/pull/82832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
vzakhari wrote: I do not think the Windows CI failure has anything to do with my changes. I am going to merge this. https://github.com/llvm/llvm-project/pull/82832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/81971 Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. >From 3aee67fece1cbad69e912baa6cb191d2e5a0205a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From 32a034ada7ba4d5e4c195b5ef36cf671dcc2e06a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting of F
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
@@ -657,10 +657,61 @@ static llvm::cl::opt "instead of libm complex operations"), llvm::cl::init(false)); +/// Return a string containing the given Fortran intrinsic name +/// with the type of its arguments specified in funcType +/// surrounded by the given prefix/suffix. +static std::string +prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc, + llvm::StringRef prefix, llvm::StringRef name, + llvm::StringRef suffix, mlir::FunctionType funcType) { + std::string output = prefix.str(); + llvm::raw_string_ostream sstream(output); + if (name == "pow") { +assert(funcType.getNumInputs() == 2 && "power operator has two arguments"); +std::string displayName{" ** "}; +sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc, +displayName) +<< displayName +<< numericMlirTypeToFortran(builder, funcType.getInput(1), loc, +displayName); + } else { +sstream << name.upper() << "("; +if (funcType.getNumInputs() > 0) + sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc, + name); +for (mlir::Type argType : funcType.getInputs().drop_front()) { + sstream << ", " << numericMlirTypeToFortran(builder, argType, loc, name); +} +sstream << ")"; + } + sstream << suffix; + return output; +} + +// Generate a call to the Fortran runtime library providing +// support for 128-bit float math via a third-party library. +// If the compiler is built without FLANG_RUNTIME_F128_MATH_LIB, +// this function will report an error. +static mlir::Value genLibF128Call(fir::FirOpBuilder &builder, + mlir::Location loc, + const MathOperation &mathOp, + mlir::FunctionType libFuncType, + llvm::ArrayRef args) { +#ifndef FLANG_RUNTIME_F128_MATH_LIB + std::string message = prettyPrintIntrinsicName( + builder, loc, "compiler is built without support for '", mathOp.key, "'", vzakhari wrote: I expect that we hit this code only when there is support for an intrinsic, but the compiler was built without `FLANG_RUNTIME_F128_MATH_LIB` set up. So `not yet implemented` would be confusing a bit. I can change this code to use the regular TODO macro, because it is probably irrelevant to the user whether it is intrinsic implementation gap or the configuration issue of the compiler build. https://github.com/llvm/llvm-project/pull/81971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From 32a034ada7ba4d5e4c195b5ef36cf671dcc2e06a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/2] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From c798a2b74df57a1375882fb13a88ccf946f4bfbf Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/2] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From c798a2b74df57a1375882fb13a88ccf946f4bfbf Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/3] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
vzakhari wrote: I have been doing some renaming and restructuring before uploading this for review, and I did not test the final version with `libquadmath`. The latest commit makes the `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` compiler fully functional (the end-to-end test is working). Thank you all for the reviews! I am going to merge this as soon as CI completes. I decided to keep the `compiler is built without support for` message as is, because emitting NYI might be confusing to the compiler developers. For users it will look like a compiler error, so I guess it does not matter for them if it has the NYI prefix or not. https://github.com/llvm/llvm-project/pull/81971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)
@@ -322,24 +306,20 @@ struct hash_state { } }; - -/// A global, fixed seed-override variable. -/// -/// This variable can be set using the \see llvm::set_fixed_execution_seed -/// function. See that function for details. Do not, under any circumstances, -/// set or read this variable. -extern uint64_t fixed_seed_override; - +/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic +/// (address of a variable) to prevent having users depend on the particular +/// hash values. On platforms without ASLR, this is still likely +/// non-deterministic per build. inline uint64_t get_execution_seed() { - // FIXME: This needs to be a per-execution seed. This is just a placeholder - // implementation. Switching to a per-execution seed is likely to flush out - // instability bugs and so will happen as its own commit. - // - // However, if there is a fixed seed override set the first time this is - // called, return that instead of the per-execution seed. - const uint64_t seed_prime = 0xff51afd7ed558ccdULL; - static uint64_t seed = fixed_seed_override ? fixed_seed_override : seed_prime; - return seed; + // Work around x86-64 negative offset folding for old Clang -fno-pic + // https://reviews.llvm.org/D93931 +#if LLVM_ENABLE_ABI_BREAKING_CHECKS && \ +(!defined(__clang__) || __clang_major__ > 11) vzakhari wrote: It is definitely a problem for LLVM built using GCC and an external project, based on LLVM, built using CLANG 11. Is there a reliable check that we can add (e.g. in `llvm/include/llvm/Config/abi-breaking.h.cmake`) to detect this at the build time rather than failing during the execution? https://github.com/llvm/llvm-project/pull/96282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)
@@ -322,24 +306,20 @@ struct hash_state { } }; - -/// A global, fixed seed-override variable. -/// -/// This variable can be set using the \see llvm::set_fixed_execution_seed -/// function. See that function for details. Do not, under any circumstances, -/// set or read this variable. -extern uint64_t fixed_seed_override; - +/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic +/// (address of a variable) to prevent having users depend on the particular +/// hash values. On platforms without ASLR, this is still likely +/// non-deterministic per build. inline uint64_t get_execution_seed() { - // FIXME: This needs to be a per-execution seed. This is just a placeholder - // implementation. Switching to a per-execution seed is likely to flush out - // instability bugs and so will happen as its own commit. - // - // However, if there is a fixed seed override set the first time this is - // called, return that instead of the per-execution seed. - const uint64_t seed_prime = 0xff51afd7ed558ccdULL; - static uint64_t seed = fixed_seed_override ? fixed_seed_override : seed_prime; - return seed; + // Work around x86-64 negative offset folding for old Clang -fno-pic + // https://reviews.llvm.org/D93931 +#if LLVM_ENABLE_ABI_BREAKING_CHECKS && \ +(!defined(__clang__) || __clang_major__ > 11) vzakhari wrote: In my case it is a `Release` build with GCC and `-DLLVM_ENABLE_ASSERTIONS=ON`. Could you please explain how `__PIC__` check helps? https://github.com/llvm/llvm-project/pull/96282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Allow disabling of types from the command line (PR #107126)
https://github.com/vzakhari approved this pull request. Looks good to me, but maybe we can have just a single option that accepts predefined words like `real2`, `integer4`, etc. I wonder if we can process multiple instances of an option like https://github.com/llvm/llvm-project/blob/0ad6cee926865d7210eed9e67bfb20dce19c6633/clang/include/clang/Driver/Options.td#L5086. This is just a suggestion to make the coverage of types/kinds more complete. https://github.com/llvm/llvm-project/pull/107126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
vzakhari wrote: FYI, it looks like this change broke `compiler-rt` build, e.g. in https://lab.llvm.org/buildbot/#/builders/270/builds/12485 https://github.com/llvm/llvm-project/pull/87684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
@@ -34,5 +34,9 @@ ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0) /// On by default. ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1) +/// If true, add nsw flags to arithmetic operations for integer. +/// Off by default. +ENUM_LOWERINGOPT(NoSignedWrap, unsigned, 1, 0) vzakhari wrote: `NoSignedWrap` sounds too generic for an option that only forces setting `NSW` for the loop variables' increments. Please consider renaming or at least make the scope of `NSW` assignment clear in the comment above. https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
https://github.com/vzakhari edited https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
https://github.com/vzakhari approved this pull request. It looks good to me except maybe for the naming of the lowering option. Thank you for doing this! https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add -f[no-]vectorize flags (PR #119718)
vzakhari wrote: > I have force pushed this to my branch but github doesn't seem to be picking > it up on this review?? I don't really know how to fix this. A rebase to main head and force push helped in another instance of "Processing updates" https://github.com/llvm/llvm-project/pull/119718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Support -f[no-]realloc-lhs. (PR #120165)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/120165 -frealloc-lhs is the default. If -fno-realloc-lhs is specified, then an allocatable on the left side of an intrinsic assignment is not implicitly (re)allocated to conform with the right hand side. Fortran runtime will issue an error if there is a mismatch in shape/type/allocation-status. >From 4067717df5a429221dd0e27752e5d70a0e042865 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Mon, 16 Dec 2024 15:14:38 -0800 Subject: [PATCH] [flang] Support -f[no-]realloc-lhs. -frealloc-lhs is the default. If -fno-realloc-lhs is specified, then an allocatable on the left side of an intrinsic assignment is not implicitly (re)allocated to conform with the right hand side. Fortran runtime will issue an error if there is a mismatch in shape/type/allocation-status. --- clang/include/clang/Driver/Options.td | 7 +++- clang/lib/Driver/ToolChains/Flang.cpp | 4 ++- flang/include/flang/Lower/LoweringOptions.def | 6 flang/lib/Frontend/CompilerInvocation.cpp | 5 +++ flang/lib/Lower/Bridge.cpp| 3 +- flang/test/Driver/frealloc-lhs.f90| 11 +++ flang/test/Lower/reallocate-lhs.f90 | 32 +++ flang/tools/bbc/bbc.cpp | 7 8 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 flang/test/Driver/frealloc-lhs.f90 create mode 100644 flang/test/Lower/reallocate-lhs.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 88862ae9edb29d..5dad9dc120f52c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3463,6 +3463,9 @@ defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers" NegFlag, PosFlag>; +def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group, + HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">, + Visibility<[FlangOption, FC1Option]>; def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group, HelpText<"Disable the use of stack protectors">; def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, @@ -4296,6 +4299,9 @@ defm stack_size_section : BoolFOption<"stack-size-section", PosFlag, NegFlag>; +def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group, + Visibility<[FlangOption, FC1Option]>, + HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">; def fstack_usage : Flag<["-"], "fstack-usage">, Group, HelpText<"Emit .su file containing information on function stack sizes">; def stack_usage_file : Separate<["-"], "stack-usage-file">, @@ -6775,7 +6781,6 @@ defm real_4_real_8 : BooleanFFlag<"real-4-real-8">, Group; defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; -defm realloc_lhs : BooleanFFlag<"realloc-lhs">, Group; defm recursive : BooleanFFlag<"recursive">, Group; defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index c98fdbd157bac8..8cffa20c4a2d36 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -55,7 +55,9 @@ void Flang::addFortranDialectOptions(const ArgList &Args, options::OPT_fdefault_double_8, options::OPT_flarge_sizes, options::OPT_fno_automatic, -options::OPT_fhermetic_module_files}); +options::OPT_fhermetic_module_files, +options::OPT_frealloc_lhs, +options::OPT_fno_realloc_lhs}); } void Flang::addPreprocessingOptions(const ArgList &Args, diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def index 0b22e54b648e94..5a6debfdffe030 100644 --- a/flang/include/flang/Lower/LoweringOptions.def +++ b/flang/include/flang/Lower/LoweringOptions.def @@ -38,5 +38,11 @@ ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1) /// (i.e. wraps around as two's complement). Off by default. ENUM_LOWERINGOPT(IntegerWrapAround, unsigned, 1, 0) +/// If true (default), follow Fortran 2003 rules for (re)allocating +/// the allocatable on the left side of the intrinsic assignment, +/// if LHS and RHS have mismatching shapes/types. +/// If false, assume that the shapes/types/allocation-status match. +ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1) + #undef LOWERINGOPT #undef ENUM_LOWERINGOPT diff --git a/flang/lib/Frontend/CompilerInvo
[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)
vzakhari wrote: Okay, I do not see an easy way to allow this option for `clang` without printing it in the `--help` output, so I guess I will let it behave same way as the other Flang-only options. https://github.com/llvm/llvm-project/pull/120320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)
https://github.com/vzakhari closed https://github.com/llvm/llvm-project/pull/120320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)
vzakhari wrote: > > After #120165 clang started complaining about unknown option > > -f[no-]realloc-lhs. > > Was this on an existing test? I noticed it when trying to compile a Fortran/C mix test where flang/clang were used as compilers and I passed `-fno-realloc-lhs` in flags that were used for both. Maybe it is not the right way to do it, but clang just ignored the option before my previous change. https://github.com/llvm/llvm-project/pull/120320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)
@@ -3465,7 +3465,7 @@ defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers" PosFlag>; def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group, HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">, - Visibility<[FlangOption, FC1Option]>; + Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>; vzakhari wrote: > Would this now show up in `clang --help` and online guide? Is that what we > want? Is CLOption for Windows? Good point! Yes, `clang --help` now shows it, and I think we do not want this. I will check how I can resolve this. Any advices are welcome. Yes, `CLOption` is for Windows driver. https://github.com/llvm/llvm-project/pull/120320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/120320 After #120165 clang started complaining about unknown option -f[no-]realloc-lhs. This change fixes it to ignore the option like it used to be. >From 5d8d3e08eb322b72f4058b98fc7ea0d6321eaa6c Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 17 Dec 2024 14:24:57 -0800 Subject: [PATCH] [flang] Ignore -f[no-]realloc-lhs. After #120165 clang started complaining about unknown option -f[no-]realloc-lhs. This change fixes it to ignore the option like it used to be. --- clang/include/clang/Driver/Options.td | 4 ++-- clang/test/Driver/frealloc-lhs.cpp| 7 +++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/frealloc-lhs.cpp diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7b544d2534d469..bc3c548da8b96c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3465,7 +3465,7 @@ defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers" PosFlag>; def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group, HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">, - Visibility<[FlangOption, FC1Option]>; + Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>; def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group, HelpText<"Disable the use of stack protectors">; def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, @@ -4300,7 +4300,7 @@ defm stack_size_section : BoolFOption<"stack-size-section", "Emit section containing metadata on function stack sizes">, NegFlag>; def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group, - Visibility<[FlangOption, FC1Option]>, + Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>, HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">; def fstack_usage : Flag<["-"], "fstack-usage">, Group, HelpText<"Emit .su file containing information on function stack sizes">; diff --git a/clang/test/Driver/frealloc-lhs.cpp b/clang/test/Driver/frealloc-lhs.cpp new file mode 100644 index 00..792247deaaa2c1 --- /dev/null +++ b/clang/test/Driver/frealloc-lhs.cpp @@ -0,0 +1,7 @@ +// RUN: %clang -Wunused-command-line-argument -frealloc-lhs -### %s 2> %t +// RUN: FileCheck < %t %s --check-prefix=REALLOCLHS +// RUN: %clang -Wunused-command-line-argument -fno-realloc-lhs -### %s 2> %t +// RUN: FileCheck < %t %s --check-prefix=NOREALLOCLHS + +// CHECK: argument unused during compilation: '-frealloc-lhs' +// CHECK: argument unused during compilation: '-fno-realloc-lhs' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Support -f[no-]realloc-lhs. (PR #120165)
vzakhari wrote: > Just a comment, no action required. I see some hits for realloc-lhs in the > gfortran testsuite. Will some of these tests start behaving differently? Thank you for the heads up, Kiran! I did not change `-Wrealloc-lhs`, so they should behave the same way. Those that use `-fno-realloc-lhs` may start failing at higher opt-levels, because Flang may stop generating calls to the runtime. As long as `-fbounds-check` is not supported (https://github.com/orgs/llvm/projects/12?pane=issue&itemId=29048733), I will have to disable them. I will update the suite after merging this PR. https://github.com/llvm/llvm-project/pull/120165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Support -f[no-]realloc-lhs. (PR #120165)
https://github.com/vzakhari closed https://github.com/llvm/llvm-project/pull/120165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Integrate the option -flang-experimental-integer-overflow into -fno-wrapv (PR #110063)
vzakhari wrote: Thank you for the pointers and the information, Tom! It looks like exchange2 is pretty much the same problem as with bwaves. I posted a note into https://github.com/llvm/llvm-project/issues/117318 https://github.com/llvm/llvm-project/pull/110063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [lld] [llvm] [Flang] Remove FLANG_INCLUDE_RUNTIME (PR #124126)
vzakhari wrote: Hi @Meinersbur is this the only patch that is left to be merged? Could you please rebase it so that I can try it on top-of-tree? https://github.com/llvm/llvm-project/pull/124126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [driver] Generalize the code that adds the path of libflang_rt.runtime.a. (PR #134362)
vzakhari wrote: Can you please explain why you want to link the static library by default? For example, Clang has these options https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-static-libgcc that allow users to force the static linking, and, I think, by default it links shared compiler support libraries. Also, how does the full path linking of the shared library works with `-frtlib-add-rpath`? https://github.com/llvm/llvm-project/pull/134362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/134002 >From 5c83d849a7129840ad8d8accd83e72836d1b2697 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 1 Apr 2025 15:55:30 -0700 Subject: [PATCH 1/3] [flang] Added driver options for arrays repacking. Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost --- clang/include/clang/Driver/Options.td | 62 ++- clang/lib/Driver/ToolChains/Flang.cpp | 30 ++--- flang/docs/ArrayRepacking.md | 19 +++--- flang/include/flang/Lower/LoweringOptions.def | 5 ++ flang/lib/Frontend/CompilerInvocation.cpp | 14 + flang/lib/Lower/ConvertVariable.cpp | 2 +- .../test/Driver/frepack-arrays-contiguity.f90 | 27 flang/test/Driver/frepack-arrays.f90 | 24 +++ flang/test/Driver/fstack-repack-arrays.f90| 24 +++ flang/test/Lower/repack-arrays.f90| 8 +-- flang/tools/bbc/bbc.cpp | 12 +++- 11 files changed, 199 insertions(+), 28 deletions(-) create mode 100644 flang/test/Driver/frepack-arrays-contiguity.f90 create mode 100644 flang/test/Driver/frepack-arrays.f90 create mode 100644 flang/test/Driver/fstack-repack-arrays.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e69b804de63b5..43bcdc6df 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6825,7 +6825,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; defm recursive : BooleanFFlag<"recursive">, Group; -defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; defm sign_zero : BooleanFFlag<"sign-zero">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; @@ -6967,6 +6966,51 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; +defm repack_arrays +: BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], +" non-contiguous assumed shape dummy arrays into " +"contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprotram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ +: Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", PosFlag, @@ -6980,6 +7024,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri PosFlag, NegFlag>; +defm stack_repack_arrays +: BoolOptionWithoutMarshalling< + "f", "stack-repack-arrays", +
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari closed https://github.com/llvm/llvm-project/pull/134002 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/134002 >From eada8e73210a92e6274b99ede1ab694e9c57c4de Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 1 Apr 2025 15:55:30 -0700 Subject: [PATCH 1/3] [flang] Added driver options for arrays repacking. Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost --- clang/include/clang/Driver/Options.td | 62 ++- clang/lib/Driver/ToolChains/Flang.cpp | 30 ++--- flang/docs/ArrayRepacking.md | 19 +++--- flang/include/flang/Lower/LoweringOptions.def | 5 ++ flang/lib/Frontend/CompilerInvocation.cpp | 14 + flang/lib/Lower/ConvertVariable.cpp | 2 +- .../test/Driver/frepack-arrays-contiguity.f90 | 27 flang/test/Driver/frepack-arrays.f90 | 24 +++ flang/test/Driver/fstack-repack-arrays.f90| 24 +++ flang/test/Lower/repack-arrays.f90| 8 +-- flang/tools/bbc/bbc.cpp | 12 +++- 11 files changed, 199 insertions(+), 28 deletions(-) create mode 100644 flang/test/Driver/frepack-arrays-contiguity.f90 create mode 100644 flang/test/Driver/frepack-arrays.f90 create mode 100644 flang/test/Driver/fstack-repack-arrays.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e69b804de63b5..43bcdc6df 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6825,7 +6825,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; defm recursive : BooleanFFlag<"recursive">, Group; -defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; defm sign_zero : BooleanFFlag<"sign-zero">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; @@ -6967,6 +6966,51 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; +defm repack_arrays +: BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], +" non-contiguous assumed shape dummy arrays into " +"contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprotram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ +: Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", PosFlag, @@ -6980,6 +7024,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri PosFlag, NegFlag>; +defm stack_repack_arrays +: BoolOptionWithoutMarshalling< + "f", "stack-repack-arrays", +
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/134002 >From b936044f9a77cb717d74248cad5021b5d997d407 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 1 Apr 2025 15:55:30 -0700 Subject: [PATCH 1/3] [flang] Added driver options for arrays repacking. Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost --- clang/include/clang/Driver/Options.td | 62 ++- clang/lib/Driver/ToolChains/Flang.cpp | 28 ++--- flang/docs/ArrayRepacking.md | 19 +++--- flang/include/flang/Lower/LoweringOptions.def | 5 ++ flang/lib/Frontend/CompilerInvocation.cpp | 14 + flang/lib/Lower/ConvertVariable.cpp | 2 +- .../test/Driver/frepack-arrays-contiguity.f90 | 27 flang/test/Driver/frepack-arrays.f90 | 24 +++ flang/test/Driver/fstack-repack-arrays.f90| 24 +++ flang/test/Lower/repack-arrays.f90| 8 +-- flang/tools/bbc/bbc.cpp | 12 +++- 11 files changed, 198 insertions(+), 27 deletions(-) create mode 100644 flang/test/Driver/frepack-arrays-contiguity.f90 create mode 100644 flang/test/Driver/frepack-arrays.f90 create mode 100644 flang/test/Driver/fstack-repack-arrays.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 89cb03cc33b98..49a59c0417455 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6819,7 +6819,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; defm recursive : BooleanFFlag<"recursive">, Group; -defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; defm sign_zero : BooleanFFlag<"sign-zero">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; @@ -6961,6 +6960,51 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; +defm repack_arrays +: BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], +" non-contiguous assumed shape dummy arrays into " +"contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprotram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ +: Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", PosFlag, @@ -6974,6 +7018,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri PosFlag, NegFlag>; +defm stack_repack_arrays +: BoolOptionWithoutMarshalling< + "f", "stack-repack-arrays", +
[clang] [CMAKE][AMDGPU] fix build failure caused by PR #133619 (PR #133776)
vzakhari wrote: > > @farzonl can you please revert the original commit? It seems to break just > > any LLVM build, so I guess the CI testing of all new PRs should be affected. > > I don't see it breaking any build in LLVM, just the amd offload ones. Al the > Premerge tests also passed. I suspect the `AMDGPUBot.cmake` is doing > something unique. Will study it more > > but the PR to revert is here #133795 Thanks! I think, it only affects the `-DBUILD_SHARED_LIBS=ON` builds, so, indeed, not all the builds :) A couple more examples: https://lab.llvm.org/buildbot/#/builders/145/builds/6156 https://lab.llvm.org/buildbot/#/builders/89/builds/19738 https://github.com/llvm/llvm-project/pull/133776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMAKE][AMDGPU] fix build failure caused by PR #133619 (PR #133776)
vzakhari wrote: @farzonl can you please revert the original commit? It seems to break just any LLVM build, so I guess the CI testing of all new PRs should be affected. https://github.com/llvm/llvm-project/pull/133776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/134002 Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost >From b936044f9a77cb717d74248cad5021b5d997d407 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 1 Apr 2025 15:55:30 -0700 Subject: [PATCH] [flang] Added driver options for arrays repacking. Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost --- clang/include/clang/Driver/Options.td | 62 ++- clang/lib/Driver/ToolChains/Flang.cpp | 28 ++--- flang/docs/ArrayRepacking.md | 19 +++--- flang/include/flang/Lower/LoweringOptions.def | 5 ++ flang/lib/Frontend/CompilerInvocation.cpp | 14 + flang/lib/Lower/ConvertVariable.cpp | 2 +- .../test/Driver/frepack-arrays-contiguity.f90 | 27 flang/test/Driver/frepack-arrays.f90 | 24 +++ flang/test/Driver/fstack-repack-arrays.f90| 24 +++ flang/test/Lower/repack-arrays.f90| 8 +-- flang/tools/bbc/bbc.cpp | 12 +++- 11 files changed, 198 insertions(+), 27 deletions(-) create mode 100644 flang/test/Driver/frepack-arrays-contiguity.f90 create mode 100644 flang/test/Driver/frepack-arrays.f90 create mode 100644 flang/test/Driver/fstack-repack-arrays.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 89cb03cc33b98..49a59c0417455 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6819,7 +6819,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; defm recursive : BooleanFFlag<"recursive">, Group; -defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; defm sign_zero : BooleanFFlag<"sign-zero">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; @@ -6961,6 +6960,51 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; +defm repack_arrays +: BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], +" non-contiguous assumed shape dummy arrays into " +"contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprotram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ +: Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", PosFlag, @@ -6974,6 +7018,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri PosFlag, NegF
[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/134002 >From b936044f9a77cb717d74248cad5021b5d997d407 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Tue, 1 Apr 2025 15:55:30 -0700 Subject: [PATCH 1/2] [flang] Added driver options for arrays repacking. Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost --- clang/include/clang/Driver/Options.td | 62 ++- clang/lib/Driver/ToolChains/Flang.cpp | 28 ++--- flang/docs/ArrayRepacking.md | 19 +++--- flang/include/flang/Lower/LoweringOptions.def | 5 ++ flang/lib/Frontend/CompilerInvocation.cpp | 14 + flang/lib/Lower/ConvertVariable.cpp | 2 +- .../test/Driver/frepack-arrays-contiguity.f90 | 27 flang/test/Driver/frepack-arrays.f90 | 24 +++ flang/test/Driver/fstack-repack-arrays.f90| 24 +++ flang/test/Lower/repack-arrays.f90| 8 +-- flang/tools/bbc/bbc.cpp | 12 +++- 11 files changed, 198 insertions(+), 27 deletions(-) create mode 100644 flang/test/Driver/frepack-arrays-contiguity.f90 create mode 100644 flang/test/Driver/frepack-arrays.f90 create mode 100644 flang/test/Driver/fstack-repack-arrays.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 89cb03cc33b98..49a59c0417455 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6819,7 +6819,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; defm recursive : BooleanFFlag<"recursive">, Group; -defm repack_arrays : BooleanFFlag<"repack-arrays">, Group; defm second_underscore : BooleanFFlag<"second-underscore">, Group; defm sign_zero : BooleanFFlag<"sign-zero">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; @@ -6961,6 +6960,51 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; +defm repack_arrays +: BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], +" non-contiguous assumed shape dummy arrays into " +"contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprotram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ +: Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", PosFlag, @@ -6974,6 +7018,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri PosFlag, NegFlag>; +defm stack_repack_arrays +: BoolOptionWithoutMarshalling< + "f", "stack-repack-arrays", +
[clang] [flang] [driver] Generalize the code that adds the path of libflang_rt.runtime.a. (PR #134362)
vzakhari wrote: May I ask not to merge this yet? I have a question above, but I will not be at work until next Thursday to discuss this in a timely manner. https://github.com/llvm/llvm-project/pull/134362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits