[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)

2024-07-02 Thread Abid Qadeer via llvm-branch-commits


@@ -216,31 +215,50 @@ bool 
ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
   if (origSymbol && fir::isTypeWithDescriptor(origSymbol.getType()))
 symAddr = origSymbol;
 
+  if (object.sym()->owner().IsDerivedType()) {
+omp::ObjectList objectList = gatherObjects(object, semaCtx);
+parentObj = objectList[0];
+parentMemberIndices.insert({parentObj.value(), {}});
+if (Fortran::semantics::IsAllocatableOrObjectPointer(
+object.sym()) ||
+memberHasAllocatableParent(object, semaCtx)) {
+  llvm::SmallVector indices =
+  generateMemberPlacementIndices(object, semaCtx);
+  symAddr = createParentSymAndGenIntermediateMaps(
+  clauseLocation, converter, objectList, indices,
+  parentMemberIndices[parentObj.value()], asFortran.str(),
+  mapTypeBits);
+}
+  }
+

abidh wrote:

There is almost same code added in ClauseProcessor.cpp above. Just wanted to 
point out in case this was not intentional.

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


[llvm-branch-commits] [llvm] [OMPIRBuilder] Propagate attributes to outlined target regions (PR #117875)

2025-01-09 Thread Abid Qadeer via llvm-branch-commits

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

LGTM

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


[llvm-branch-commits] [clang] 670686a - Add initial support for multilibs in Baremetal toolchain.

2020-12-14 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-14T20:49:45Z
New Revision: 670686ad8ecc80158a6ff87fff55e0ffa6fdff5d

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

LOG: Add initial support for multilibs in Baremetal toolchain.

This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7429c822b7e9..7619dd30da5a 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -12,6 +12,7 @@
 #include "InputInfo.h"
 #include "Gnu.h"
 
+#include "Arch/RISCV.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -27,12 +28,77 @@ using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 
+static Multilib makeMultilib(StringRef commonSuffix) {
+  return Multilib(commonSuffix, commonSuffix, commonSuffix);
+}
+
+static bool findRISCVMultilibs(const Driver &D,
+   const llvm::Triple &TargetTriple,
+   const ArgList &Args, DetectedMultilibs &Result) 
{
+  Multilib::flags_list Flags;
+  StringRef Arch = riscv::getRISCVArch(Args, TargetTriple);
+  StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple);
+
+  if (TargetTriple.getArch() == llvm::Triple::riscv64) {
+Multilib Imac = 
makeMultilib("").flag("+march=rv64imac").flag("+mabi=lp64");
+Multilib Imafdc = makeMultilib("/rv64imafdc/lp64d")
+  .flag("+march=rv64imafdc")
+  .flag("+mabi=lp64d");
+
+// Multilib reuse
+bool UseImafdc =
+(Arch == "rv64imafdc") || (Arch == "rv64gc"); // gc => imafdc
+
+addMultilibFlag((Arch == "rv64imac"), "march=rv64imac", Flags);
+addMultilibFlag(UseImafdc, "march=rv64imafdc", Flags);
+addMultilibFlag(Abi == "lp64", "mabi=lp64", Flags);
+addMultilibFlag(Abi == "lp64d", "mabi=lp64d", Flags);
+
+Result.Multilibs = MultilibSet().Either(Imac, Imafdc);
+return Result.Multilibs.select(Flags, Result.SelectedMultilib);
+  }
+  if (TargetTriple.getArch() == llvm::Triple::riscv32) {
+Multilib Imac =
+makeMultilib("").flag("+march=rv32imac").flag("+mabi=ilp32");
+Multilib I =
+makeMultilib("/rv32i/ilp32").flag("+march=rv32i").flag("+mabi=ilp32");
+Multilib Im =
+
makeMultilib("/rv32im/ilp32").flag("+march=rv32im").flag("+mabi=ilp32");
+Multilib Iac = makeMultilib("/rv32iac/ilp32")
+   .flag("+march=rv32iac")
+   .flag("+mabi=ilp32");
+Multilib Imafc = makeMultilib("/rv32imafc/ilp32f")
+ .flag("+march=rv32imafc")
+ .flag("+mabi=ilp32f");
+
+// Multilib reuse
+bool UseI = (Arch == "rv32i") || (Arch == "rv32ic");// ic => i
+bool UseIm = (Arch == "rv32im") || (Arch == "rv32imc"); // imc => im
+bool UseImafc = (Arch == "rv32imafc") || (Arch == "rv32imafdc") ||
+(Arch == "rv32gc"); // imafdc,gc => imafc
+
+addMultilibFlag(UseI, "march=rv32i", Flags);
+addMultilibFlag(UseIm, "march=rv32im", Flags);
+addMultilibFlag((Arch == "rv32iac"), "march=rv32iac", Flags);
+addMultilibFlag((Arch == "rv32imac"), "march=rv32imac", Flags);
+addMultilibFlag(UseImafc, "march=rv32imafc", Flags);
+addMultilibFlag(Abi == "ilp32", "mabi=ilp32", Flags);
+addMultilibFlag(Abi == "ilp32f", "mabi=ilp32f", Flags);
+
+Result.Multilibs = MultilibSet().Either(I, Im, Iac, Imac, Imafc);
+return Result.Multilibs.select(Flags, Result.SelectedMultilib);
+  }
+  return false;
+}
+
 BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getP

[llvm-branch-commits] [llvm] 43def79 - Update references to 'master' branch.

2020-12-21 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-21T19:10:34Z
New Revision: 43def795aacd6794f93b91fc76e59953fd67e138

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

LOG: Update references to 'master' branch.

This commit replace 'master' with 'main' in llvm/docs.

Reviewed By: sammccall, kristof.beyls

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

Added: 


Modified: 
llvm/docs/CodingStandards.rst
llvm/docs/DeveloperPolicy.rst
llvm/docs/FAQ.rst
llvm/docs/GettingStarted.rst
llvm/docs/GitBisecting.rst
llvm/docs/GlobalISel/IRTranslator.rst
llvm/docs/LibFuzzer.rst
llvm/docs/TestingGuide.rst
llvm/docs/TypeMetadata.rst

Removed: 




diff  --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index a5798bd73cb1..57d148df89f8 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -77,7 +77,7 @@ on the standard library facilities and the LLVM support 
libraries as much as
 possible.
 
 LLVM support libraries (for example, `ADT
-`_)
+`_)
 implement specialized data structures or functionality missing in the standard
 library. Such libraries are usually implemented in the ``llvm`` namespace and
 follow the expected standard interface, when there is one.

diff  --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 3fa629965318..7bcb5664540a 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -80,7 +80,7 @@ Making and Submitting a Patch
 When making a patch for review, the goal is to make it as easy for the reviewer
 to read it as possible.  As such, we recommend that you:
 
-#. Make your patch against git master, not a branch, and not an old version
+#. Make your patch against git main, not a branch, and not an old version
of LLVM.  This makes it easy to apply the patch.  For information on how to
clone from git, please see the :ref:`Getting Started Guide
`.
@@ -146,7 +146,7 @@ problem, we have a notion of an 'owner' for a piece of the 
code.  The sole
 responsibility of a code owner is to ensure that a commit to their area of the
 code is appropriately reviewed, either by themself or by someone else.  The 
list
 of current code owners can be found in the file `CODE_OWNERS.TXT
-`_ in 
the
+`_ in the
 root of the LLVM source tree.
 
 Note that code ownership is completely 
diff erent than reviewers: anyone can

diff  --git a/llvm/docs/FAQ.rst b/llvm/docs/FAQ.rst
index aef15d6dc711..229ac99f703c 100644
--- a/llvm/docs/FAQ.rst
+++ b/llvm/docs/FAQ.rst
@@ -13,7 +13,7 @@ Can I modify LLVM source code and redistribute the modified 
source?
 ---
 Yes.  The modified source distribution must retain the copyright notice and
 follow the conditions listed in the `Apache License v2.0 with LLVM Exceptions
-`_.
+`_.
 
 
 Can I modify the LLVM source code and redistribute binaries or other tools 
based on it, without redistributing the source?

diff  --git a/llvm/docs/GettingStarted.rst b/llvm/docs/GettingStarted.rst
index d4e4a3b03928..a2274f80fc1f 100644
--- a/llvm/docs/GettingStarted.rst
+++ b/llvm/docs/GettingStarted.rst
@@ -457,7 +457,7 @@ either via emailing to llvm-commits, or, preferably, via 
:ref:`Phabricator
 
 You'll generally want to make sure your branch has a single commit,
 corresponding to the review you wish to send, up-to-date with the upstream
-``origin/master`` branch, and doesn't contain merges. Once you have that, you
+``origin/main`` branch, and doesn't contain merges. Once you have that, you
 can start `a Phabricator review `_ (or use ``git show`` or
 ``git format-patch`` to output the 
diff , and attach it to an email message).
 
@@ -501,7 +501,7 @@ For developers to commit changes from Git
 ^
 
 Once a patch is reviewed, you should rebase it, re-test locally, and commit the
-changes to LLVM's master branch. This is done using `git push` if you have the
+changes to LLVM's main branch. This is done using `git push` if you have the
 required access rights. See `committing a change
 `_ for Phabricator based commits or
 `obtaining commit access `_
@@ -515,13 +515,13 @@ accepted commit on the branch named `branch-with-change`.
   # Go to the branch with your accepted commit.
   % git checkout branch-with-change
   # Rebase your change on

[llvm-branch-commits] [clang] 45ba239 - [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-26 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-11-26T11:43:17Z
New Revision: 45ba2392d7e00aedd4d9fb04070dbae8a7fbbeeb

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

LOG: [clang][Driver] Handle risvc in Baremetal.cpp.

I am working on a baremetal riscv toolchain using LLVM runtime and
LLD linker. Baremetal.cpp provides most of the things needed for such
toolchain. So I have modified it to also handle riscv64/32-unknown-elf
 targets alongside arm-none-eabi.

Currently, targets like riscv64-unknown-elf are handled by RISCVToolChain
which mostly expects a gcc toolchain to be present. If you dont
want the dependency on gcc-toolchain/libgloss or want to use LLD, then
RISCVToolChain is not a good fit.

So in the toolchain selection code, I have made this dependency of
RISCVToolChain on gcc toolchain explicit. It is created if gcc-toolchain
option is present. Otherwise Baremetal toolchain is created. I will be
happy to hear if there is a better way to choose between these two
toolchains.

Reviewed By: jroelofs

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/RISCVToolchain.cpp
clang/lib/Driver/ToolChains/RISCVToolchain.h
clang/test/Driver/baremetal.cpp
clang/test/Driver/riscv-gnutools.c
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain-extra.c
clang/test/Driver/riscv64-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index fb258197cfdd..5e4eb8c4e6c5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5213,7 +5213,11 @@ const ToolChain &Driver::getToolChain(const ArgList 
&Args,
 break;
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
-TC = std::make_unique(*this, Target, Args);
+if (toolchains::RISCVToolChain::hasGCCToolchain(*this, Args))
+  TC =
+  std::make_unique(*this, Target, 
Args);
+else
+  TC = std::make_unique(*this, Target, Args);
 break;
   case llvm::Triple::ve:
 TC = std::make_unique(*this, Target, Args);

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 91e2715404fe..e032d07112eb 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -59,8 +59,22 @@ static bool isARMBareMetal(const llvm::Triple &Triple) {
   return true;
 }
 
+static bool isRISCVBareMetal(const llvm::Triple &Triple) {
+  if (Triple.getArch() != llvm::Triple::riscv32 &&
+  Triple.getArch() != llvm::Triple::riscv64)
+return false;
+
+  if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (Triple.getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return Triple.getEnvironmentName() == "elf";
+}
+
 bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
-  return isARMBareMetal(Triple);
+  return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
 }
 
 Tool *BareMetal::buildLinker() const {

diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp 
b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index 312c8b52c5e8..0dc12c7a84b5 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -31,6 +31,21 @@ static void addMultilibsFilePaths(const Driver &D, const 
MultilibSet &Multilibs,
   addPathIfExists(D, InstallPath + Path, Paths);
 }
 
+// This function tests whether a gcc installation is present either
+// through gcc-toolchain argument or in the same prefix where clang
+// is installed. This helps decide whether to instantiate this toolchain
+// or Baremetal toolchain.
+bool RISCVToolChain::hasGCCToolchain(const Driver &D,
+ const llvm::opt::ArgList &Args) {
+  if (Args.getLastArg(options::OPT_gcc_toolchain))
+return true;
+
+  SmallString<128> GCCDir;
+  llvm::sys::path::append(GCCDir, D.Dir, "..", D.getTargetTriple(),
+  "lib/crt0.o");
+  return llvm::sys::fs::exists(GCCDir);
+}
+
 /// RISCV Toolchain
 RISCVToolChain::RISCVToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)

diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.h 
b/clang/lib/Driver/ToolChains/RISCVToolchain.h
index 4734aee5f1ab..62099bee0404 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -21,6 +21,7 @@ class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public 
Generic_ELF {
   RISCVToolChain(const Driver &D, const llvm::Triple &Triple,
 

[llvm-branch-commits] [clang] ca28883 - Don't use sysroot/include when sysroot is empty.

2020-12-04 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-04T18:33:24Z
New Revision: ca2888310b245d0532d989685a090ae373ee3f93

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

LOG: Don't use sysroot/include when sysroot is empty.

Baremetal toolchain add Driver.SysRoot/include to the system include
paths without checking if Driver.SysRoot is empty. This resulted in
"-internal-isystem" "include" in the command. This patch adds check for
empty sysroot.

Reviewed By: jroelofs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index e032d07112eb..20ffd4b2cd57 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
 SmallString<128> Dir(getDriver().SysRoot);
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
+if (!Dir.empty()) {
+  llvm::sys::path::append(Dir, "include");
+  addSystemInclude(DriverArgs, CC1Args, Dir.str());
+}
   }
 }
 

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 7dd213ee56b4..addf09f00e14 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \



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


[llvm-branch-commits] [clang] 275592e - Provide default location of sysroot for Baremetal toolchain.

2020-12-07 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-07T09:19:52Z
New Revision: 275592e714130345a481a5cb889c89b73a98614f

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

LOG: Provide default location of sysroot for Baremetal  toolchain.

Currently, Baremetal toolchain requires user to pass a sysroot location
using a --sysroot flag. This is not very convenient for the user. It also
creates problem for toolchain vendors who don't have a fixed location to
put the sysroot bits.

Clang does provide 'DEFAULT_SYSROOT' which can be used by the toolchain
builder to provide the default location. But it does not work if toolchain
is targeting multiple targets e.g. arm-none-eabi/riscv64-unknown-elf which
clang is capable of doing.

This patch tries to solve this problem by providing a default location of
the toolchain if user does not explicitly provides --sysroot. The exact
location and name can be different but it should fulfill these conditions:

1. The sysroot path should have a target triple element so that multi-target
toolchain problem (as I described above) could be addressed.

2. The location should not be $TOP/$Triple as this is used by gcc generally
and will be a problem for installing both gcc and clang based toolchain at
the same location.

Reviewed By: jroelofs

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

Added: 
clang/test/Driver/baremetal-sysroot.cpp

Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 20ffd4b2cd57..7429c822b7e9 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,7 +33,7 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple 
&Triple,
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
-  SmallString<128> SysRoot(getDriver().SysRoot);
+  SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
@@ -94,6 +94,17 @@ std::string BareMetal::getRuntimesDir() const {
   return std::string(Dir.str());
 }
 
+std::string BareMetal::computeSysRoot() const {
+  if (!getDriver().SysRoot.empty())
+return getDriver().SysRoot;
+
+  SmallString<128> SysRootDir;
+  llvm::sys::path::append(SysRootDir, getDriver().Dir, "../lib/clang-runtimes",
+  getDriver().getTargetTriple());
+
+  return std::string(SysRootDir);
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -106,7 +117,7 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
   }
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
-SmallString<128> Dir(getDriver().SysRoot);
+SmallString<128> Dir(computeSysRoot());
 if (!Dir.empty()) {
   llvm::sys::path::append(Dir, "include");
   addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -127,7 +138,7 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
-  StringRef SysRoot = getDriver().SysRoot;
+  std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 0be9377134ce..3f4fadf8a7c3 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -67,6 +67,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
+  std::string computeSysRoot() const override;
 };
 
 } // namespace toolchains

diff  --git a/clang/test/Driver/baremetal-sysroot.cpp 
b/clang/test/Driver/baremetal-sysroot.cpp
new file mode 100644
index ..ae174e01417e
--- /dev/null
+++ b/clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// Test that when a --sysroot is not provided, driver picks the default
+// location correctly if available.
+
+// RUN: rm -rf %T/baremetal_default_sysroot
+// RUN: mkdir -p %T/baremetal_default_sysroot/bin
+// RUN: mkdir -p 
%T/baremetal_default_sysroot/lib/clang-runtimes/armv6m-none-eabi
+// RUN: ln -s %clang %T/baremetal_default_sysroot/bin/clang
+
+// RUN: %T/baremetal_default_sysroot/bin/clang -no-canonica

[llvm-branch-commits] [compiler-rt] deec343 - [compiler-rt] Allow appending to 'target_cflags' value from lit_config.

2020-12-08 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-08T11:46:36Z
New Revision: deec343bfd85d7c78fb0d8e251e63f372767297d

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

LOG: [compiler-rt] Allow appending to 'target_cflags' value from lit_config.

This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.

This patch will allows to do things like

$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"

In this way, you can run tests on different targets without having to run
cmake again.

Reviewed By: delcypher

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

Added: 


Modified: 
compiler-rt/test/lit.common.cfg.py

Removed: 




diff  --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 889e29341ee2..e2de463f85c0 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -582,5 +582,11 @@ def is_windows_lto_supported():
 elif config.use_lld and (not config.has_lld):
   config.unsupported = True
 
+# Append any extra flags passed in lit_config
+append_target_cflags = lit_config.params.get('append_target_cflags', None)
+if append_target_cflags:
+  lit_config.note('Appending to extra_cflags: 
"{}"'.format(append_target_cflags))
+  extra_cflags += [append_target_cflags]
+
 config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, 
config.clang]) + " "
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "



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


[llvm-branch-commits] [llvm] 1deff40 - [MC][ELF] Accept abbreviated form with sh_flags and sh_entsize

2020-12-11 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Tobias Burnus
Date: 2020-12-11T16:45:45Z
New Revision: 1deff4009e0ae661b03682901bf6932297ce7ea1

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

LOG: [MC][ELF] Accept abbreviated form with sh_flags and sh_entsize

D73999 / commit 75af9da755721123e62b45cd0bc0c5e688a9722a
added for LLVM 11 a check that sh_flags and sh_entsize (and sh_type)
changes are an error, in line with GNU assembler.

However, GNU assembler accepts and GCC generates an abbreviated form:
while the first .section contains the flags and entsize, subsequent
sections simply contain the name without repeating entsize or flags.

Do likewise for better compatibility.

See https://bugs.llvm.org/show_bug.cgi?id=48201

Reviewed By: jhenderson, MaskRay

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

Added: 
llvm/test/MC/ELF/section-omitted-attributes.s

Modified: 
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/MC/ELF/section-flags-changed.s

Removed: 




diff  --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp 
b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 78fee5ad87a3..65ac1d6b5ba0 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -652,10 +652,13 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, 
SMLoc loc) {
   !(SectionName == ".eh_frame" && Type == ELF::SHT_PROGBITS))
 Error(loc, "changed section type for " + SectionName + ", expected: 0x" +
utohexstr(Section->getType()));
-  if (Section->getFlags() != Flags)
+  // Check that flags are used consistently. However, the GNU assembler permits
+  // to leave out in subsequent uses of the same sections; for compatibility,
+  // do likewise.
+  if ((Flags || Size || !TypeName.empty()) && Section->getFlags() != Flags)
 Error(loc, "changed section flags for " + SectionName + ", expected: 0x" +
utohexstr(Section->getFlags()));
-  if (Section->getEntrySize() != Size)
+  if ((Flags || Size || !TypeName.empty()) && Section->getEntrySize() != Size)
 Error(loc, "changed section entsize for " + SectionName +
", expected: " + Twine(Section->getEntrySize()));
 

diff  --git a/llvm/test/MC/ELF/section-flags-changed.s 
b/llvm/test/MC/ELF/section-flags-changed.s
index 65f52cc29a6d..d2964ef046d1 100644
--- a/llvm/test/MC/ELF/section-flags-changed.s
+++ b/llvm/test/MC/ELF/section-flags-changed.s
@@ -9,4 +9,7 @@ foo:
 # CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, 
expected: 0x6
 .pushsection .foo,"a",@progbits
 
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, 
expected: 0x6
+.section .foo,"",@progbits
+
 .pushsection .foo,"ax",@progbits

diff  --git a/llvm/test/MC/ELF/section-omitted-attributes.s 
b/llvm/test/MC/ELF/section-omitted-attributes.s
new file mode 100644
index ..72b7c9121387
--- /dev/null
+++ b/llvm/test/MC/ELF/section-omitted-attributes.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple=x86_64 %s -o - | FileCheck %s
+
+# If section flags and other attributes are omitted, don't error.
+
+# CHECK: .section.foo,"aM",@progbits,1
+
+.section .foo,"aM",@progbits,1
+
+.section .foo
+
+.pushsection .foo



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