[PATCH] D79155: [CodeGen] Increase applicability of ffine-grained-bitfield-accesses for targets with limited native integer widths

2020-06-10 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Ping on this. The patch still applies cleanly against current HEAD.

@efriedma: was your comment an LGTM?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79155/new/

https://reviews.llvm.org/D79155



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


[clang] b3d1092 - Restore part of D80450 [CUDA][HIP] Fix implicit HD function resolution

2020-06-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-06-10T22:33:33-07:00
New Revision: b3d10920e13446efaebb201612328cf0644709f8

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

LOG: Restore part of D80450 [CUDA][HIP] Fix implicit HD function resolution

The "if (S.getLangOpts().CUDA && Cand1.Function && Cand2.Function) {"
part is known to be problematic but the root cause isn't clear yet.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e7e6dc4f3adc..6f074fb941af 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11698,6 +11698,8 @@ class Sema final {
 return IdentifyCUDATarget(dyn_cast(CurContext));
   }
 
+  static bool isCUDAImplicitHostDeviceFunction(const FunctionDecl *D);
+
   // CUDA function call preference. Must be ordered numerically from
   // worst to best.
   enum CUDAFunctionPreference {

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 5d6c15196750..f54d97a2a319 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -211,6 +211,20 @@ Sema::IdentifyCUDAPreference(const FunctionDecl *Caller,
   llvm_unreachable("All cases should've been handled by now.");
 }
 
+template  static bool hasImplicitAttr(const FunctionDecl *D) {
+  if (!D)
+return false;
+  if (auto *A = D->getAttr())
+return A->isImplicit();
+  return D->isImplicit();
+}
+
+bool Sema::isCUDAImplicitHostDeviceFunction(const FunctionDecl *D) {
+  bool IsImplicitDevAttr = hasImplicitAttr(D);
+  bool IsImplicitHostAttr = hasImplicitAttr(D);
+  return IsImplicitDevAttr && IsImplicitHostAttr;
+}
+
 void Sema::EraseUnwantedCUDAMatches(
 const FunctionDecl *Caller,
 SmallVectorImpl> &Matches) {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 319a4b534eba..e57264dec9a0 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9397,16 +9397,22 @@ static Comparison compareEnableIfAttrs(const Sema &S, 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
-  const OverloadCandidate &Cand2) {
+static Comparison
+isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
+  const OverloadCandidate &Cand2) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return false;
+return Comparison::Equal;
 
-  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
-  // is obviously better.
-  if (Cand1.Function->isInvalidDecl()) return false;
-  if (Cand2.Function->isInvalidDecl()) return true;
+  // If both are invalid, they are equal. If one of them is invalid, the other
+  // is better.
+  if (Cand1.Function->isInvalidDecl()) {
+if (Cand2.Function->isInvalidDecl())
+  return Comparison::Equal;
+return Comparison::Worse;
+  }
+  if (Cand2.Function->isInvalidDecl())
+return Comparison::Better;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9416,16 +9422,18 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate &Cand1,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return false;
+return Comparison::Equal;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return true;
+return Comparison::Better;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return false;
+return Comparison::Worse;
 
   if (Cand1CPUSpec && Cand2CPUSpec) {
 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
-  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
+  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
+ ? Comparison::Better
+ : Comparison::Worse;
 
 std::pair
 FirstDiff = std::mismatch(
@@ -9438,7 +9446,9 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate &Cand1,
 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
"Two 
diff erent cpu-specific versions should not have the same "
"identifier list, otherwise they'd be the same decl!");
-return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName();
+return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
+   ? Comparison::Better
+   : Comparison::Worse;
   }
   llvm_unreachable("No way to get here unless both had c

[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 270030.
rprichard added a comment.

Remove unnecessary `virtual` keyword.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81622/new/

https://reviews.llvm.org/D81622

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h

Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -39,7 +39,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/MSP430.h
===
--- clang/lib/Driver/ToolChains/MSP430.h
+++ clang/lib/Driver/ToolChains/MSP430.h
@@ -44,7 +44,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -42,7 +42,7 @@
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const override;
-  virtual std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
Index: clang/lib/Driver/ToolChains/Hurd.h
===
--- clang/lib/Driver/ToolChains/Hurd.h
+++ clang/lib/Driver/ToolChains/Hurd.h
@@ -27,8 +27,6 @@
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
 
-  std::string computeSysRoot() const;
-
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -125,13 +125,6 @@
   return new tools::gnutools::Assembler(*this);
 }
 
-std::string Hurd::computeSysRoot() const {
-  if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
-
-  return std::string();
-}
-
 std::string Hurd::getDynamicLinker(const ArgList &Args) const {
   if (getArch() == llvm::Triple::x86)
 return "/lib/ld.so";
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2846,7 +2846,6 @@
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
-  const std::string& SysRoot = getDriver().SysRoot;
   auto AddIncludePath = [&](std::string Path) {
 std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
@@ -2862,6 +2861,7 @@
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
+  std::string SysRoot = computeSysRoot();
   if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
 return;
   if (AddIncludePath(SysRoot + "/usr/include/c++"))
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -750,6 +750,10 @@
   return ComputeLLVMTriple(Args, InputType);
 }
 
+std::string ToolChain::computeSysRoot() const {
+  return D.SysRoot;
+}
+
 void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   // Each toolchain should provide the appropriate include flags.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -536,6 +536,10 @@
   /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
   virtual bool hasBlocksRuntime() const { return true; }
 
+  /// Return the sysroot, possibly searching for a default sysroot using
+  /// targ

[clang] ed34140 - [X86] Move X86 stuff out of TargetParser.h and into the recently created X86TargetParser.h. NFC

2020-06-10 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-10T22:06:34-07:00
New Revision: ed34140e1146e188686f479bd954dea11a2d26d8

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

LOG: [X86] Move X86 stuff out of TargetParser.h and into the recently created 
X86TargetParser.h. NFC

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/Support/TargetParser.h
llvm/include/llvm/Support/X86TargetParser.h
llvm/lib/Support/Host.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 05c6ec22af3a..0092c52b2b23 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -17,7 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/TargetParser.h"
+#include "llvm/Support/X86TargetParser.h"
 
 namespace clang {
 namespace targets {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 010b77e9ace6..a2e6050ae1f3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -47,7 +47,7 @@
 #include "llvm/IR/MatrixBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/ScopedPrinter.h"
-#include "llvm/Support/TargetParser.h"
+#include "llvm/Support/X86TargetParser.h"
 #include 
 
 using namespace clang;

diff  --git a/llvm/include/llvm/Support/TargetParser.h 
b/llvm/include/llvm/Support/TargetParser.h
index ef7c86122dcd..b60c1aff80d4 100644
--- a/llvm/include/llvm/Support/TargetParser.h
+++ b/llvm/include/llvm/Support/TargetParser.h
@@ -25,55 +25,12 @@ namespace llvm {
 class StringRef;
 
 // Target specific information in their own namespaces.
-// (ARM/AArch64 are declared in ARM/AArch64TargetParser.h)
+// (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
 // These should be generated from TableGen because the information is already
 // there, and there is where new information about targets will be added.
 // FIXME: To TableGen this we need to make some table generated files available
 // even if the back-end is not compiled with LLVM, plus we need to create a new
 // back-end to TableGen to create these clean tables.
-namespace X86 {
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorVendors : unsigned {
-  VENDOR_DUMMY,
-#define X86_VENDOR(ENUM, STRING) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  VENDOR_OTHER
-};
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorTypes : unsigned {
-  CPU_TYPE_DUMMY,
-#define X86_CPU_TYPE(ARCHNAME, ENUM) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  CPU_TYPE_MAX
-};
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorSubtypes : unsigned {
-  CPU_SUBTYPE_DUMMY,
-#define X86_CPU_SUBTYPE(ARCHNAME, ENUM) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  CPU_SUBTYPE_MAX
-};
-
-// This should be kept in sync with libcc/compiler-rt as it should be used
-// by clang as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorFeatures {
-#define X86_FEATURE(VAL, ENUM) \
-  ENUM = VAL,
-#include "llvm/Support/X86TargetParser.def"
-
-};
-
-} // namespace X86
-
 namespace AMDGPU {
 
 /// GPU kinds supported by the AMDGPU target.

diff  --git a/llvm/include/llvm/Support/X86TargetParser.h 
b/llvm/include/llvm/Support/X86TargetParser.h
index 1c9ad03cde81..7cdf1c532814 100644
--- a/llvm/include/llvm/Support/X86TargetParser.h
+++ b/llvm/include/llvm/Support/X86TargetParser.h
@@ -20,6 +20,45 @@ class StringRef;
 
 namespace X86 {
 
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorVendors : unsigned {
+  VENDOR_DUMMY,
+#define X86_VENDOR(ENUM, STRING) \
+  ENUM,
+#include "llvm/Support/X86TargetParser.def"
+  VENDOR_OTHER
+};
+
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorTypes : unsigned {
+  CPU_TYPE_DUMMY,
+#define X86_CPU_TYPE(ARCHNAME, ENUM) \
+  ENUM,
+#include "llvm/Support/X86TargetParser.def"
+  CPU_TYPE_MAX
+};
+
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorSubtypes : unsigned {
+  CPU_SUBTYPE_DUMMY,
+#define X86_CPU_SUBTYPE(ARCHNAME, ENUM) \
+  ENUM,
+#include "llvm/Support/X86TargetParser.def"
+  CPU_SUBTYPE_MAX
+};
+
+// This should be kept in sync with libcc/compiler-rt as 

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:178
 
+  virtual void mangleDynamicDestructor(const VarDecl *D, raw_ostream &Out) = 0;
+

I am not sure "destructor" is the right term here. This seems to be an analogue 
to the functions named using `mangleDynamicAtExitDestructor`, except that those 
rather directly perform destruction and are registered with `atexit` during 
initialization whereas these perform finalization and are "registered" by being 
called from an "sterm" function. What are the thoughts on 
`mangleDynamicStermFinalizer`?



Comment at: clang/lib/AST/ItaniumMangle.cpp:5217
+  else
+Mangler.getStream() << D->getName();
+}

Xiangling_L wrote:
> jasonliu wrote:
> > If I understand correctly, this function will come in pair with 
> > `__cxx_global_var_init`.
> > `__cxx_global_var_init` use number as suffix in the end to avoid 
> > duplication when there is more than one of those, but we are using the 
> > variable name as suffix here instead.
> > Do we want to use number as suffix here to match what 
> > `__cxx_global_var_init` does? It would help people to recognize the pairs 
> > and make them more symmetric. 
> This is somewhere I am kinda on the fence. Personally, I think embed decl 
> name in the __cxx_global_var_destruct_ / __cxx_global_vat_init_ as 
> `mangleDynamicAtExitDestructor` does is more helpful for the user to debug 
> the static init.
> I am not sure if we want to give up that benefit and be consistent with 
> current `__cxx_global_vat_init_ ` using number suffix or do we want to 
> replace number suffix by decl name for `__cxx_global_vat_init_ ` as well.
Not every dynamically initialized non-local variable of static storage duration 
requires non-trivial destruction. These don't actually pair with 
`__cxx_global_var_init`; rather, they pair with the calls to `atexit` and the 
functions whose addresses are passed to `atexit`.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166



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


[PATCH] D81624: [CodeGen] Simplify the way lifetime of block captures is extended

2020-06-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

This is a great improvement, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81624/new/

https://reviews.llvm.org/D81624



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:562
 
+static std::string getTransformedFileName(llvm::Module &M) {
+  SmallString<128> FileName = llvm::sys::path::filename(M.getName());

Consider having the `SmallString<128>` buffer passed in and returning a 
`StringRef` backed by that buffer.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1056
 
+  /// Add a destructor to the C++ global destructor function.
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {

What is "the C++ global destructor function"? Based on the comment on 
`CXXGlobalDtors` it has something to do with termination of the program. The 
existing usage is limited and consistent: This is a facility used when even 
`atexit` is not available.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1058
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {
+CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(),
+nullptr);

The description of `CXXGlobalDtors` is
> Global destructor functions and arguments that need to run on termination.




Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4501
+
+  CGM.AddCXXDtorEntry(StermFn);
 }

The purpose of the specific interface does not appear to match its usage here 
(see my other comment). This function is meant to be called on unloading a 
shared library. The usual termination path calls destructors via `atexit`.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166



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


[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

Thanks, Ryan, for diagnosing and addressing this bug.




Comment at: clang/lib/Driver/ToolChains/Linux.h:45
 llvm::opt::ArgStringList &CmdArgs) const override;
-  virtual std::string computeSysRoot() const;
+  virtual std::string computeSysRoot() const override;
 

Can drop `virtual` here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81622/new/

https://reviews.llvm.org/D81622



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


[clang] af00eb2 - Fix __clang_cuda_math_forward_declares.h

2020-06-10 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-10T23:47:13-04:00
New Revision: af00eb25f890ecbf02818f1466da8f30d93e6298

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

LOG: Fix __clang_cuda_math_forward_declares.h

Recent change from `#if !defined(__CUDA__)` to `#if !__CUDA__` caused
regression on ROCm 3.5 since there is `#define __CUDA__`
before inclusion of the header file, which causes `#if !__CUDA__`
to be invalid.

Change `#if !__CUDA__` back to `#if !defined(__CUDA__)` for backward
compatibility.

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_math_forward_declares.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_math_forward_declares.h 
b/clang/lib/Headers/__clang_cuda_math_forward_declares.h
index 7c0b3575b25a..8a270859e4a5 100644
--- a/clang/lib/Headers/__clang_cuda_math_forward_declares.h
+++ b/clang/lib/Headers/__clang_cuda_math_forward_declares.h
@@ -8,7 +8,7 @@
  */
 #ifndef __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
 #define __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
-#if !__CUDA__ && !__HIP__
+#if !defined(__CUDA__) && !__HIP__
 #error "This file is for CUDA/HIP compilation only."
 #endif
 



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/test/Sema/builtins-overflow.c:39
+_ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expected-error 
{{signed _ExtInt of bit sizes greater than 128 not supported}}
+  }

jtmott-intel wrote:
> erichkeane wrote:
> > As @rjmccall said, I'd suggest the new message anyway that mentions the 
> > builtin, otherwise this would be confusing for me.  Something like:
> > 
> > signed argument to __builtin_mul_overflow must have a bitwidth of less than 
> > or equal to 128.
> Updated message to something halfway between your and John's suggestions. 
> Current result:
> 
> test.c:5:43: error: __builtin_mul_overflow does not support signed 
> _ExtInt operands of more than 128 bits
> _Bool status = __builtin_mul_overflow(x, y, &result);
>   ^
> 1 error generated.
> 
> 
That looks great to me, thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81420/new/

https://reviews.llvm.org/D81420



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4447
+
+  // Create __dtor function for the var decl.
+  llvm::Function *dtorStub = CGF.createAtExitStub(D, dtor, addr);

We should probably report_fatal_error if `CXAAtExit` (the option) is true 
before this line. This would imply driver changes to default AIX to using 
`-fno-use-cxa-atexit`. An associated test file is 
https://github.com/llvm/llvm-project/blame/master/clang/test/Driver/cxa-atexit.cpp.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:524
+  CallConv))
+return;
   EVT ValueVT = Val.getValueType();

pratlucas wrote:
> efriedma wrote:
> > I'm not sure I understand why the standard getCopyFromParts/getCopyToParts 
> > codepath doesn't work. Is the issue that it uses FP_ROUND/FP_EXTEND to 
> > promote from f16 to f32?
> Yes, the issue is the usage of FP_ROUND/FP_EXTEND indeed. Those cause the 
> argument to be converted from f16 into f32 - with a `vcvtb.f16.f32` for 
> instance - instead of simply being placed the value in the LSBs as required 
> by the AAPCS.
That makes sense.

It feels a little weird to have a TLI method to do the splitting, as opposed to 
adding an extra check to the shared codepath, but I guess this way is more 
flexible if someone else needs a similar change in the future.

One other thing to consider is that we could make f16 a "legal" type for all 
ARM subtargets with floating-point registers, regardless of whether the target 
actually has native f16 arithmetic instructions. We do this on AArch64.  That 
would reduce the number of different ways to handle f16 values, and I think 
this change would be unnecessary.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:916
   ExtendKind = ISD::ZERO_EXTEND;
-
 getCopyToParts(DAG, dl, Val.getValue(Val.getResNo() + Value), &Parts[Part],

(Accidental change?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75169/new/

https://reviews.llvm.org/D75169



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/CodeGen/CGCXXABI.h:113
+
+  virtual bool isCXXGlobalInitAndDtorFuncInternal() const { return true; }
+

Xiangling_L wrote:
> jasonliu wrote:
> > Do we need this isCXXGlobalInitAndDtorFuncInternal? Looks like it's always 
> > going to return ! useSinitAndSterm() result.
> AFAIK, not all platforms which use sinit and sterm have external linkage 
> sinit/sterm functions. And also since for 7.2 AIX we are considering change 
> sinit/sterm to internal linkage symbols, I seperate this query out.
I would prefer to create the query in the patch when we actually need it. With 
what we have right now, it seems redundant. 



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:650
+  FTy,
+  (UseSinitAndSterm ? "__sinit8000_clang_" : "_GLOBAL__sub_I_") +
+  FuncSuffix,

It looks like one of the UseSinitAndSterm is redundant. We could have something 
like: 
```
UseSinitAndSterm ? llvm::twine("__sinit8000_clang_") + GlobalUniqueModuleId 
: llvm::twine("_GLOBAL__sub_I_") + getTransformedFileName(getModule())
```
which minimize the use of std::string?
If this is too long, then we could separate them into if statement just like 
what we have in EmitCXXGlobalDtorFunc, or use a lambda.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:692
+  if (UseSinitAndSterm) {
+Fn = CreateGlobalInitOrDestructFunction(
+FTy, llvm::Twine("__sterm8000_clang_") + GlobalUniqueModuleId, FI,

Could we assert !GlobalUniqueModuleId.empty() here?
Right now, it solely relies on `EmitCXXGlobalInitFunc` to run before 
`EmitCXXGlobalDtorFunc` to get `GlobalUniqueModuleId` initialized properly. I 
think it makes sense to put an assert here to make sure it stays in that case 
in the future.  



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:699
+
+  if (!getCXXABI().isCXXGlobalInitAndDtorFuncInternal())
+Fn->setLinkage(llvm::Function::ExternalLinkage);

This could go inside of the `if (UseSinitAndSterm)`.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4479
+
+  llvm::Value *NeedsDestruct = CGF.Builder.CreateIsNull(V, "guard.hasSrterm");
+

jasonliu wrote:
> Srterm is not used in this implementation.
> Suggestion:
> guard.hasDtorCalled
"guard.hasDtor" does not reflect what the meaning. Maybe matching with the 
variable name would make sense: "guard.needsDestruct" or just "needsDestruct"?



Comment at: clang/test/CodeGen/static-init.cpp:15
+
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry:

#0 could be removed.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a subscriber: tpr.

Currently HIP toolchain calls clang to emit bitcode then calls opt/llc for 
device compilation for the default -fno-gpu-rdc
case, which is unnecessary since clang is able to compile a single source file 
to ISA.

This patch fixes the HIP action builder and toolchain so that the default 
-fno-gpu-rdc can be done like a canonical
toolchain, i.e. one clang -cc1 invocation to compile source code to ISA.

This can avoid unnecessary processes to speed up the compilation, and avoid 
redundant LLVM passes which are
performed in clang -cc1 and opt.

This patch does not remove opt/llc in -fgpu-rdc case since device linking is 
still needed whereas
amdgpu backend does not support ISA linking for now.


https://reviews.llvm.org/D81627

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/cuda-phases.cu
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip

Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -68,27 +68,9 @@
 // Oz-SAME: "-Oz"
 // Og-SAME: "-Og"
 
-// ALL: "{{.*}}opt"
-// DEFAULT-NOT: "-O{{.}}"
-// O0-SAME: "-O0"
-// O1-SAME: "-O1"
-// O2-SAME: "-O2"
-// O3-SAME: "-O3"
-// Os-SAME: "-Os"
-// Oz-SAME: "-Oz"
-// Og-SAME: "-O1"
-// ALL-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// ALL-NOT: "{{.*}}opt"
 
-// ALL: "{{.*}}llc"
-// DEFAULT-NOT: "-O{{.}}"
-// O0-SAME: "-O0"
-// O1-SAME: "-O1"
-// O2-SAME: "-O2"
-// O3-SAME: "-O3"
-// Os-SAME: "-O2"
-// Oz-SAME: "-O2"
-// Og-SAME: "-O1"
-// ALL-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// ALL-NOT: "{{.*}}llc"
 
 // ALL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // DEFAULT-NOT: "-O{{.}}"
Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -18,25 +18,17 @@
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
-// CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_803:".*o"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
-// CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_803]]
-// CHECK-SAME: "-o" [[LINKED_BC_DEV_A_803:".*-gfx803-linked-.*bc"]]
-
-// CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx803"
-// CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]]
-
-// CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx803"
-// CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
+// CHECK-NOT: {{".*llvm-link"}}
+// CHECK-NOT: {{".*opt"}}
+// CHECK-NOT: {{".*llc"}}
 
 // CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
@@ -47,25 +39,17 @@
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
-// CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_900:".*o"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_900]]
-// CHECK-SAME: "-o" [[LINKED_BC_DEV_A_900:".*-gfx900-linked-.*bc"]]
-
-// CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx900"
-// CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]]
-
-// CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx900"
-// CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
+// CHECK-NOT: {{".*llvm-link"}}
+// CHECK-NOT: {{".*opt"}}
+// CHECK-NOT: {{".*llc"}}
 
 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_

[PATCH] D81045: [LLVM] Change isa<> to a variadic function template

2020-06-10 Thread Rahul Joshi via Phabricator via cfe-commits
jurahul updated this revision to Diff 270015.
jurahul edited the summary of this revision.
jurahul added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81045/new/

https://reviews.llvm.org/D81045

Files:
  clang/include/clang/AST/DeclBase.h
  llvm/include/llvm/Support/Casting.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp


Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
===
--- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
+++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
@@ -220,7 +220,7 @@
 auto Defs = findAllDefs(U);
 
 // If the values are all Constants or Arguments, don't bother
-if (llvm::none_of(Defs, isa))
+if (llvm::none_of(Defs, [](Value *V) { return isa(V); }))
   return false;
 
 // Presently, we only know how to handle PHINode, Constant, Arguments and
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3860,7 +3860,8 @@
   if (I != HasRecMap.end())
 return I->second;
 
-  bool FoundAddRec = SCEVExprContains(S, isa);
+  bool FoundAddRec =
+  SCEVExprContains(S, [](const SCEV *S) { return isa(S); 
});
   HasRecMap.insert({S, FoundAddRec});
   return FoundAddRec;
 }
@@ -11201,8 +11202,9 @@
 // Returns true when one of the SCEVs of Terms contains a SCEVUnknown 
parameter.
 static inline bool containsParameters(SmallVectorImpl &Terms) {
   for (const SCEV *T : Terms)
-if (SCEVExprContains(T, isa))
+if (SCEVExprContains(T, [](const SCEV *S) { return isa(S); }))
   return true;
+
   return false;
 }
 
Index: llvm/include/llvm/Support/Casting.h
===
--- llvm/include/llvm/Support/Casting.h
+++ llvm/include/llvm/Support/Casting.h
@@ -132,24 +132,30 @@
   }
 };
 
-// isa - Return true if the parameter to the template is an instance of the
-// template type argument.  Used like this:
+// isa - Return true if the parameter to the template is an instance of one
+// of the template type arguments.  Used like this:
 //
 //  if (isa(myVal)) { ... }
+//  if (isa(myVal)) { ... }
 //
 template  LLVM_NODISCARD inline bool isa(const Y &Val) {
   return isa_impl_wrap::SimpleType>::doit(Val);
 }
 
+template 
+LLVM_NODISCARD inline bool isa(const Y &Val) {
+  return isa(Val) || isa(Val);
+}
+
 // isa_and_nonnull - Functionally identical to isa, except that a null value
 // is accepted.
 //
-template 
+template 
 LLVM_NODISCARD inline bool isa_and_nonnull(const Y &Val) {
   if (!Val)
 return false;
-  return isa(Val);
+  return isa(Val);
 }
 
 
//===--===//
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -518,7 +518,7 @@
 if (!HasAttrs) return;
 
 AttrVec &Vec = getAttrs();
-Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa), 
Vec.end());
+llvm::erase_if(Vec, [](Attr *A) { return isa(A); });
 
 if (Vec.empty())
   HasAttrs = false;


Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
===
--- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
+++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
@@ -220,7 +220,7 @@
 auto Defs = findAllDefs(U);
 
 // If the values are all Constants or Arguments, don't bother
-if (llvm::none_of(Defs, isa))
+if (llvm::none_of(Defs, [](Value *V) { return isa(V); }))
   return false;
 
 // Presently, we only know how to handle PHINode, Constant, Arguments and
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3860,7 +3860,8 @@
   if (I != HasRecMap.end())
 return I->second;
 
-  bool FoundAddRec = SCEVExprContains(S, isa);
+  bool FoundAddRec =
+  SCEVExprContains(S, [](const SCEV *S) { return isa(S); });
   HasRecMap.insert({S, FoundAddRec});
   return FoundAddRec;
 }
@@ -11201,8 +11202,9 @@
 // Returns true when one of the SCEVs of Terms contains a SCEVUnknown parameter.
 static inline bool containsParameters(SmallVectorImpl &Terms) {
   for (const SCEV *T : Terms)
-if (SCEVExprContains(T, isa))
+if (SCEVExprContains(T, [](const SCEV *S) { return isa(S); }))
   return true;
+
   return false;
 }
 
Index: llvm/include/llvm/Support/Casting.h
===
--- llvm/include/llvm/Support/Casting.h
+++ llvm/include/llvm/Support/Casting.h
@@ -132,24 +132,30 @@
   }
 };
 
-// isa - Return true if the parameter to the template is a

[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added reviewers: srhines, danalbert, libc++, kristina.
rprichard added a comment.

FWIW, `computeSysRoot` is overridden by these toolchains:

- Linux
- MSP430ToolChain
- MipsLLVMToolChain
- RISCVToolChain

I think this change restores the pre D69758  
behavior for Linux and MipsLLVMToolChain. It might be nice to have a review 
from someone familiar with the MSP430 and RISC-V toolchains.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81622/new/

https://reviews.llvm.org/D81622



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


[PATCH] D81624: [CodeGen] Simplify the way lifetime of block captures is extended

2020-06-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

To clarify my comment, the lifetime of the block capture in `test22` gets 
extended to the end of the enclosing scope, but of course not beyond the end of 
the return statement.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81624/new/

https://reviews.llvm.org/D81624



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


[PATCH] D81624: [CodeGen] Simplify the way lifetime of block captures is extended

2020-06-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added subscribers: ributzka, jfb, dexonsmith, jkorous.

Rather than pushing inactive cleanups for the block captures at the entry of a 
full expression and activating them during the creation of the block literal, 
just call `pushLifetimeExtendedDestroy` to ensure the cleanups are popped at 
the end of the scope enclosing the block expression.

I've made sure that the lifetime of block captures in a return statement 
doesn't get extended beyond the end of the return statement except when the 
`BlockDecl` isn't in the cleanup object list of the return statement's 
`ExprWithCleanups` (see `test22` I added to arc-blocks.m).

This addresses the feedback I got in the following review: 
https://reviews.llvm.org/D64464#inline-690623

rdar://problem/63996471


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81624

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBlocks.h
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/test/CodeGenCXX/blocks-cxx11.cpp
  clang/test/CodeGenCXX/blocks.cpp
  clang/test/CodeGenObjC/arc-blocks.m
  clang/test/CodeGenObjC/arc-foreach.m
  clang/test/CodeGenObjC/noescape.m
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -95,7 +95,7 @@
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVL2:@__device_side_enqueue_block_invoke[^ ]*]] to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to %struct.__opencl_block_literal_generic*
+  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block4 to %struct.__opencl_block_literal_generic*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast %struct.__opencl_block_literal_generic* [[BL]] to i8 addrspace(4)*
   // COMMON-LABEL: call i32 @__enqueue_kernel_basic_events
   // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]],  %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]],
Index: clang/test/CodeGenObjC/noescape.m
===
--- clang/test/CodeGenObjC/noescape.m
+++ clang/test/CodeGenObjC/noescape.m
@@ -95,7 +95,6 @@
 // CHECK-NOARC: store i8* %[[B]], i8** %[[B_ADDR]], align 8
 // CHECK-ARC: store i8* null, i8** %[[B_ADDR]], align 8
 // CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[B_ADDR]], i8* %[[B]])
-// CHECK-ARC: %[[V0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 5
 // CHECK: %[[BLOCK_ISA:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 0
 // CHECK: store i8* bitcast (i8** @_NSConcreteGlobalBlock to i8*), i8** %[[BLOCK_ISA]], align 8
 // CHECK: %[[BLOCK_FLAGS:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 1
@@ -109,7 +108,7 @@
 // CHECK-ARC: %[[V3:.*]] = call i8* @llvm.objc.retain(i8* %[[V2]])
 // CHECK-ARC: store i8* %[[V3]], i8** %[[BLOCK_CAPTURED]], align 8
 // CHECK: call void @noescapeFunc0(
-// CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null)
+// CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[BLOCK_CAPTURED]], i8* null)
 // CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[B_ADDR]], i8* null)
 
 // Non-escaping blocks don't need copy/dispose helper functions.
Index: clang/test/CodeGenObjC/arc-foreach.m
===
--- clang/test/CodeGenObjC/arc-foreach.m
+++ clang/test/CodeGenObjC/arc-foreach.m
@@ -65,14 +65,13 @@
 // CHECK-LP64-NEXT: [[T3:%.*]] = load i8*, i

[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 270009.
rprichard added a comment.

Reverse clang-format's change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81622/new/

https://reviews.llvm.org/D81622

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h

Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -39,7 +39,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/MSP430.h
===
--- clang/lib/Driver/ToolChains/MSP430.h
+++ clang/lib/Driver/ToolChains/MSP430.h
@@ -44,7 +44,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -42,7 +42,7 @@
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const override;
-  virtual std::string computeSysRoot() const;
+  virtual std::string computeSysRoot() const override;
 
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
Index: clang/lib/Driver/ToolChains/Hurd.h
===
--- clang/lib/Driver/ToolChains/Hurd.h
+++ clang/lib/Driver/ToolChains/Hurd.h
@@ -27,8 +27,6 @@
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
 
-  std::string computeSysRoot() const;
-
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -125,13 +125,6 @@
   return new tools::gnutools::Assembler(*this);
 }
 
-std::string Hurd::computeSysRoot() const {
-  if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
-
-  return std::string();
-}
-
 std::string Hurd::getDynamicLinker(const ArgList &Args) const {
   if (getArch() == llvm::Triple::x86)
 return "/lib/ld.so";
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2846,7 +2846,6 @@
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
-  const std::string& SysRoot = getDriver().SysRoot;
   auto AddIncludePath = [&](std::string Path) {
 std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
@@ -2862,6 +2861,7 @@
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
+  std::string SysRoot = computeSysRoot();
   if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
 return;
   if (AddIncludePath(SysRoot + "/usr/include/c++"))
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -750,6 +750,10 @@
   return ComputeLLVMTriple(Args, InputType);
 }
 
+std::string ToolChain::computeSysRoot() const {
+  return D.SysRoot;
+}
+
 void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   // Each toolchain should provide the appropriate include flags.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -536,6 +536,10 @@
   /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
   virtual bool hasBlocksRuntime() const { return true; }
 
+  /// Return the sysroot, possibly searching for a default sysroot using
+  /// tar

[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 270005.
rprichard added a comment.

Rerun after installing clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81622/new/

https://reviews.llvm.org/D81622

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h

Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -39,7 +39,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/MSP430.h
===
--- clang/lib/Driver/ToolChains/MSP430.h
+++ clang/lib/Driver/ToolChains/MSP430.h
@@ -44,7 +44,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -42,7 +42,7 @@
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const override;
-  virtual std::string computeSysRoot() const;
+  virtual std::string computeSysRoot() const override;
 
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
Index: clang/lib/Driver/ToolChains/Hurd.h
===
--- clang/lib/Driver/ToolChains/Hurd.h
+++ clang/lib/Driver/ToolChains/Hurd.h
@@ -27,8 +27,6 @@
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
 
-  std::string computeSysRoot() const;
-
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -125,13 +125,6 @@
   return new tools::gnutools::Assembler(*this);
 }
 
-std::string Hurd::computeSysRoot() const {
-  if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
-
-  return std::string();
-}
-
 std::string Hurd::getDynamicLinker(const ArgList &Args) const {
   if (getArch() == llvm::Triple::x86)
 return "/lib/ld.so";
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2846,7 +2846,6 @@
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
-  const std::string& SysRoot = getDriver().SysRoot;
   auto AddIncludePath = [&](std::string Path) {
 std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
@@ -2862,6 +2861,7 @@
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
+  std::string SysRoot = computeSysRoot();
   if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
 return;
   if (AddIncludePath(SysRoot + "/usr/include/c++"))
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -750,6 +750,8 @@
   return ComputeLLVMTriple(Args, InputType);
 }
 
+std::string ToolChain::computeSysRoot() const { return D.SysRoot; }
+
 void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   // Each toolchain should provide the appropriate include flags.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -536,6 +536,10 @@
   /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
   virtual bool hasBlocksRuntime() const { return true; }
 
+  /// Return the sysroot, possibly searching for a default sysroot using
+  /// tar

[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard created this revision.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, lenary, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: clang.
rprichard updated this revision to Diff 270005.
rprichard added a comment.

Rerun after installing clang-format


The Android NDK's clang driver is used with an Android -target setting,
and the driver automatically finds the Android sysroot at a path
relative to the driver. The sysroot has the libc++ headers in it.

Remove Hurd::computeSysRoot as it is equivalent to the new
ToolChain::computeSysRoot method.

Fixes PR46213.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81622

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h

Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -39,7 +39,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/MSP430.h
===
--- clang/lib/Driver/ToolChains/MSP430.h
+++ clang/lib/Driver/ToolChains/MSP430.h
@@ -44,7 +44,7 @@
   Tool *buildLinker() const override;
 
 private:
-  std::string computeSysRoot() const;
+  std::string computeSysRoot() const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -42,7 +42,7 @@
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const override;
-  virtual std::string computeSysRoot() const;
+  virtual std::string computeSysRoot() const override;
 
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
Index: clang/lib/Driver/ToolChains/Hurd.h
===
--- clang/lib/Driver/ToolChains/Hurd.h
+++ clang/lib/Driver/ToolChains/Hurd.h
@@ -27,8 +27,6 @@
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
 
-  std::string computeSysRoot() const;
-
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -125,13 +125,6 @@
   return new tools::gnutools::Assembler(*this);
 }
 
-std::string Hurd::computeSysRoot() const {
-  if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
-
-  return std::string();
-}
-
 std::string Hurd::getDynamicLinker(const ArgList &Args) const {
   if (getArch() == llvm::Triple::x86)
 return "/lib/ld.so";
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2846,7 +2846,6 @@
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
-  const std::string& SysRoot = getDriver().SysRoot;
   auto AddIncludePath = [&](std::string Path) {
 std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
@@ -2862,6 +2861,7 @@
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
+  std::string SysRoot = computeSysRoot();
   if (AddIncludePath(SysRoot + "/usr/local/include/c++"))
 return;
   if (AddIncludePath(SysRoot + "/usr/include/c++"))
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -750,6 +750,8 @@
   return ComputeLLVMTriple(Args, InputType);
 }
 
+std::string ToolChain::computeSysRoot() const { return D.SysRoot; }
+
 void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
 

[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp:8
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f4(int x, int y = x + 0);
+  // expected-error@-1 {{default argument references parameter 'x'}}

I'd like to see an example like:
```
void f5(int x, int y = ((void)x, 0));
```
to demonstrate that we're checking for potentially-evaluated mentions, not 
odr-uses, here. (`(void)x` is not an odr-use, but is potentially-evaluated.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81615/new/

https://reviews.llvm.org/D81615



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


[clang] dfc0d94 - Revert D80450 "[CUDA][HIP] Fix implicit HD function resolution"

2020-06-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-06-10T17:42:28-07:00
New Revision: dfc0d9475556cb04f443f728e68cf8c7afa904eb

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

LOG: Revert D80450 "[CUDA][HIP] Fix implicit HD function resolution"

This reverts commit 263390d4f5f23967a31af09eb6e0c12e633d6104.

This can still cause bogus errors:

eigen3/Eigen/src/Core/CoreEvaluators.h:94:38: error: call to implicitly-deleted 
copy constructor of 'unary_evaluator>>'

thrust/system/detail/generic/for_each.h:49:3: error: implicit instantiation of 
undefined template
'thrust::detail::STATIC_ASSERTION_FAILURE'

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 33be6c68b11a..e7e6dc4f3adc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11698,8 +11698,6 @@ class Sema final {
 return IdentifyCUDATarget(dyn_cast(CurContext));
   }
 
-  static bool IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D);
-
   // CUDA function call preference. Must be ordered numerically from
   // worst to best.
   enum CUDAFunctionPreference {

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 1106cef0eca2..5d6c15196750 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -211,20 +211,6 @@ Sema::IdentifyCUDAPreference(const FunctionDecl *Caller,
   llvm_unreachable("All cases should've been handled by now.");
 }
 
-template  static bool hasImplicitAttr(const FunctionDecl *D) {
-  if (!D)
-return false;
-  if (auto *A = D->getAttr())
-return A->isImplicit();
-  return D->isImplicit();
-}
-
-bool Sema::IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D) {
-  bool IsImplicitDevAttr = hasImplicitAttr(D);
-  bool IsImplicitHostAttr = hasImplicitAttr(D);
-  return IsImplicitDevAttr && IsImplicitHostAttr;
-}
-
 void Sema::EraseUnwantedCUDAMatches(
 const FunctionDecl *Caller,
 SmallVectorImpl> &Matches) {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5e5f53991a68..319a4b534eba 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9397,22 +9397,16 @@ static Comparison compareEnableIfAttrs(const Sema &S, 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static Comparison
-isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
-  const OverloadCandidate &Cand2) {
+static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
+  const OverloadCandidate &Cand2) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return Comparison::Equal;
+return false;
 
-  // If both are invalid, they are equal. If one of them is invalid, the other
-  // is better.
-  if (Cand1.Function->isInvalidDecl()) {
-if (Cand2.Function->isInvalidDecl())
-  return Comparison::Equal;
-return Comparison::Worse;
-  }
-  if (Cand2.Function->isInvalidDecl())
-return Comparison::Better;
+  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
+  // is obviously better.
+  if (Cand1.Function->isInvalidDecl()) return false;
+  if (Cand2.Function->isInvalidDecl()) return true;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9422,18 +9416,16 @@ isBetterMultiversionCandidate(const OverloadCandidate 
&Cand1,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return Comparison::Equal;
+return false;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return Comparison::Better;
+return true;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return Comparison::Worse;
+return false;
 
   if (Cand1CPUSpec && Cand2CPUSpec) {
 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
-  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
- ? Comparison::Better
- : Comparison::Worse;
+  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
 
 std::pair
 FirstDiff = std::mismatch(
@@ -9446,9 +9438,7 @@ isBetterMultiversionCandidate(const OverloadCandidate 
&Cand1,
 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
"Two 
diff erent cpu-specific versions should not have the same "
"identifier list, otherwise they'd be the same decl!");
-return (*FirstDiff.first)->getName() < (*Fi

[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-10 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added a comment.

In D81552#2086420 , @jkorous wrote:

> @njames93 `hasDirectBase` seems like a useful matcher to me! OTOH I am not 
> totally convinced about `hasType` -> `hasClass`. Anyway, don't you want to 
> land `hasDirectBase` as a separate patch first and then discuss the rest?


There more I add to this, the more splitting it up sounds like a good idea.

> One more thing - I'm just thinking if there isn't some corner case where a 
> base class could be interpreted as both direct and indirect. The most ugly 
> case I came up with is virtual inheritance. I admit I don't know what the 
> standard says about this so it might be a non-issue. Also, it'd still 
> probably make sense to match on such base. WDYT?
> 
>   struct Base {};
>   struct Proxy : virtual Base {};
>   struct Derived : Base, Proxy {};

In that case it would probably register as a direct and indirect base. However 
there is no matcher(nor much need for one) that will solely match indirect 
bases so its mostly a non issue.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3537
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType,
-AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 1) {

jkorous wrote:
> aaron.ballman wrote:
> > njames93 wrote:
> > > aaron.ballman wrote:
> > > > This is undoing a change that was just added less than two weeks ago, 
> > > > so I think the potential for breaking code is small. That said, can you 
> > > > explain why you think `hasClass` is a better approach than `hasType`?
> > > Yeah, as that change hasn't reached landed onto a release branch breaking 
> > > code shouldn't be an issue, If it was I'd leave it in.
> > > 
> > > - `hasType` is very generic, whereas `hasClass` is specific to what a 
> > > `CXXBaseSpecifier` supports.
> > > - It makes the matchers marginally simpler.
> > >   `hasDirectBase(hasType(cxxRecordDecl(hasName("Base"` vs 
> > > `hasDirectBase(hasClass(hasName("Base")))`
> > > - In the documentation it also specifies that `hasClass` takes a 
> > > `Matcher, making it more user friendly.
> > FWIW, I prefer `hasType` to `hasClass`. You can inherit from things which 
> > are not a class, such as a struct (so the name is a bit of a misnomer, but 
> > not too awful), a class template (which you can't match with this 
> > interface), or a template type (which you also can't match with this 
> > interface).
> I don't feel super strongly about this but I also slightly prefer `hasType`.
> 
> To be fair - I didn't really have things like inheritance from template 
> parameters on my mind when working on `hasAnyBase` (it's definitely not 
> tested) so I'd rather not assume it works.
I have decided to put `hasType` back in there as it does have some general 
uses. However I have added more class and class template specific matchers as I 
feel these are slightly more user friendly. 

LMK what you think of this approach.

Side note what is the correct collective term for classes and structs. I'd be 
tempted to refer to them how clang does, records, but `hasRecord` seems wrong.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:3158
+class Base {};
+class Derived : BAse {};
+  )cc",

jkorous wrote:
> Is this (`Base` != `BAse`) a typo or a way how to tease the asserts?
It was to tease the assers, but I removed it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-10 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel updated this revision to Diff 269995.
jtmott-intel added a comment.

This updated patch prepared before John's latest comments.

- Changed diagnostic message to something halfway between John and Erich's 
suggestions.
- Removed superfluous calls to Arg.get.
- Combined call to Diag and return of error status.
- Simplified but kept ternary (for now).
- Updated comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81420/new/

https://reviews.llvm.org/D81420

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-overflow.c
  clang/test/Sema/builtins-overflow.c

Index: clang/test/Sema/builtins-overflow.c
===
--- clang/test/Sema/builtins-overflow.c
+++ clang/test/Sema/builtins-overflow.c
@@ -19,4 +19,23 @@
   __builtin_add_overflow(1, 1, 3);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('int' invalid)}}
   __builtin_add_overflow(1, 1, &f);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('float *' invalid)}}
   __builtin_add_overflow(1, 1, &q);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}}
+
+  {
+_ExtInt(128) x = 1;
+_ExtInt(128) y = 1;
+_ExtInt(128) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expect ok
+  }
+  {
+unsigned _ExtInt(129) x = 1;
+unsigned _ExtInt(129) y = 1;
+unsigned _ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expect ok
+  }
+  {
+_ExtInt(129) x = 1;
+_ExtInt(129) y = 1;
+_ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support signed _ExtInt operands of more than 128 bits}}
+  }
 }
Index: clang/test/CodeGen/builtins-overflow.c
===
--- clang/test/CodeGen/builtins-overflow.c
+++ clang/test/CodeGen/builtins-overflow.c
@@ -41,6 +41,20 @@
   return r;
 }
 
+int test_add_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_add_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.sadd.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_add_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
 unsigned test_sub_overflow_uint_uint_uint(unsigned x, unsigned y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_uint_uint_uint
   // CHECK-NOT: ext
@@ -69,6 +83,20 @@
   return r;
 }
 
+int test_sub_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.ssub.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_sub_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
 unsigned test_mul_overflow_uint_uint_uint(unsigned x, unsigned y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_uint
   // CHECK-NOT: ext
@@ -97,6 +125,48 @@
   return r;
 }
 
+int test_mul_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.smul.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
+int test_mul_overflow_xint127_xint127_xint127(_ExtInt(127) x, _ExtInt(127) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint127_xint127_xint127({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i127, i1 } @llvm.smul.with.overflow.i127(i127 %{{.+}}, i127 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i127, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i127, i1 } [[S]], 0
+  // CHECK: store i127 [[Q]], i127*
+  // CHECK: br i1 [[C]]
+  _ExtInt(127) r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
+int test_mul_overflow_xint128_xint128_xint128(_ExtInt(128) x, 

[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 27.
njames93 added a comment.

- Added back `hasType` overload for `CXXBaseSpecifier`
- Added `hasClassTemplate` and `hasClassOrClassTemplate` matcher for 
`CXXBaseSpecifier`
- Added `hasTemplatedDecl` for `ClassTemplateDecl`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2997,26 +2997,24 @@
 }
 
 TEST(HasAnyBase, DirectBase) {
-  EXPECT_TRUE(matches(
-  "struct Base {};"
-  "struct ExpectedMatch : Base {};",
-  cxxRecordDecl(hasName("ExpectedMatch"),
-hasAnyBase(hasType(cxxRecordDecl(hasName("Base")));
+  EXPECT_TRUE(matches("struct Base {};"
+  "struct ExpectedMatch : Base {};",
+  cxxRecordDecl(hasName("ExpectedMatch"),
+hasAnyBase(hasClass(hasName("Base"));
 }
 
 TEST(HasAnyBase, IndirectBase) {
-  EXPECT_TRUE(matches(
-  "struct Base {};"
-  "struct Intermediate : Base {};"
-  "struct ExpectedMatch : Intermediate {};",
-  cxxRecordDecl(hasName("ExpectedMatch"),
-hasAnyBase(hasType(cxxRecordDecl(hasName("Base")));
+  EXPECT_TRUE(matches("struct Base {};"
+  "struct Intermediate : Base {};"
+  "struct ExpectedMatch : Intermediate {};",
+  cxxRecordDecl(hasName("ExpectedMatch"),
+hasAnyBase(hasClass(hasName("Base"));
 }
 
 TEST(HasAnyBase, NoBase) {
   EXPECT_TRUE(notMatches("struct Foo {};"
  "struct Bar {};",
- cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl());
+ cxxRecordDecl(hasAnyBase(hasClass(cxxRecordDecl());
 }
 
 TEST(IsPublicBase, Public) {
@@ -3117,5 +3115,94 @@
  cxxRecordDecl(hasAnyBase(isVirtual();
 }
 
+TEST(BaseSpecifier, hasDirectBase) {
+  EXPECT_TRUE(matches(
+  R"cc(
+class Base {};
+class Derived : Base{};
+)cc",
+  cxxRecordDecl(hasName("Derived"),
+hasDirectBase(hasClass(hasName("Base"));
+
+  StringRef MultiDerived = R"cc(
+class Base {};
+class Base2 {};
+class Derived : Base, Base2{};
+)cc";
+
+  EXPECT_TRUE(matches(MultiDerived,
+  cxxRecordDecl(hasName("Derived"),
+hasDirectBase(hasClass(hasName("Base"));
+  EXPECT_TRUE(matches(
+  MultiDerived, cxxRecordDecl(hasName("Derived"),
+  hasDirectBase(hasClass(hasName("Base2"));
+
+  StringRef Indirect = R"cc(
+class Base {};
+class Intermediate : Base {};
+class Derived : Intermediate{};
+)cc";
+
+  EXPECT_TRUE(
+  matches(Indirect,
+  cxxRecordDecl(hasName("Derived"),
+hasDirectBase(hasClass(hasName("Intermediate"));
+  EXPECT_TRUE(notMatches(
+  Indirect, cxxRecordDecl(hasName("Derived"),
+  hasDirectBase(hasClass(hasName("Base"));
+}
+
+TEST(BaseSpecifier, HasClassTemplate) {
+  DeclarationMatcher Matcher = cxxRecordDecl(
+  hasDirectBase(hasClassTemplate(hasTemplatedDecl(hasName("Base");
+  EXPECT_TRUE(matches(R"cc(
+template class Base {};
+template class Derived : Base {};
+  )cc",
+  Matcher));
+  EXPECT_FALSE(matches(R"cc(
+template class Base {};
+template class Derived : Base {};
+  )cc",
+   Matcher));
+}
+
+TEST(BaseSpecifier, HasClassOrClassTemplate) {
+  DeclarationMatcher Matcher =
+  cxxRecordDecl(hasDirectBase(hasClassOrClassTemplate(hasName("Base";
+  EXPECT_TRUE(matches(R"cc(
+template class Base {};
+template class Derived : Base {};
+  )cc",
+  Matcher));
+  EXPECT_TRUE(matches(R"cc(
+template class Base {};
+template class Derived : Base {};
+  )cc",
+  Matcher));
+  EXPECT_TRUE(matches(R"cc(
+template class Base {};
+class Derived : Base {};
+  )cc",
+  Matcher));
+  EXPECT_TRUE(matches(R"cc(
+class Base {};
+template class Derived : Base {};
+  )cc",
+  Matcher));
+  EXPECT_TRUE(matches(R"cc(
+class Base {};
+class Derived : Base {};
+  )cc",
+  Matcher));
+}
+
+TEST(ClassTemplateDecl, HasTemplatedDecl) {
+  DeclarationMatcher Matcher =
+  classTemplateDecl(hasTemplatedDecl(hasName("A")));
+  EXPECT_

[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the PCH

2020-06-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D77194#2086245 , @sammccall wrote:

> @rsmith are you OK with merging this into the release branch for 10.0.1?
>  cc @tstellar


Yes, please do.

(I would like for us to eventually maintain AST file format compatibility 
between patch releases, which this change would break, but as far as I'm aware 
the status quo is still that we include the version number and revision as part 
of the signature of the AST file and will reject the file if it differs even by 
clang patch release, so the compatibility there is only a future-facing 
concern, not one that affects this change.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77194/new/

https://reviews.llvm.org/D77194



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

@njames93 `hasDirectBase` seems like a useful matcher to me! OTOH I am not 
totally convinced about `hasType` -> `hasClass`. Anyway, don't you want to land 
`hasDirectBase` as a separate patch first and then discuss the rest?

One more thing - I'm just thinking if there isn't some corner case where a base 
class could be interpreted as both direct and indirect. The most ugly case I 
came up with is virtual inheritance. I admit I don't know what the standard 
says about this so it might be a non-issue. Also, it'd still probably make 
sense to match on such base. WDYT?

  struct Base {};
  struct Proxy : virtual Base {};
  struct Derived : Base, Proxy {};




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3537
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType,
-AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 1) {

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > This is undoing a change that was just added less than two weeks ago, so 
> > > I think the potential for breaking code is small. That said, can you 
> > > explain why you think `hasClass` is a better approach than `hasType`?
> > Yeah, as that change hasn't reached landed onto a release branch breaking 
> > code shouldn't be an issue, If it was I'd leave it in.
> > 
> > - `hasType` is very generic, whereas `hasClass` is specific to what a 
> > `CXXBaseSpecifier` supports.
> > - It makes the matchers marginally simpler.
> >   `hasDirectBase(hasType(cxxRecordDecl(hasName("Base"` vs 
> > `hasDirectBase(hasClass(hasName("Base")))`
> > - In the documentation it also specifies that `hasClass` takes a 
> > `Matcher, making it more user friendly.
> FWIW, I prefer `hasType` to `hasClass`. You can inherit from things which are 
> not a class, such as a struct (so the name is a bit of a misnomer, but not 
> too awful), a class template (which you can't match with this interface), or 
> a template type (which you also can't match with this interface).
I don't feel super strongly about this but I also slightly prefer `hasType`.

To be fair - I didn't really have things like inheritance from template 
parameters on my mind when working on `hasAnyBase` (it's definitely not tested) 
so I'd rather not assume it works.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

Nit: while "[base specifier] `hasType`" sounds natural to me for some reason 
`hasClass` doesn't. English is not my first language though.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:3158
+class Base {};
+class Derived : BAse {};
+  )cc",

Is this (`Base` != `BAse`) a typo or a way how to tease the asserts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-10 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel marked 6 inline comments as done.
jtmott-intel added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7939
   "to a non-const integer (%0 invalid)">;
+def err_overflow_builtin_extint_size : Error<
+  "_ExtInt argument larger than 64-bits to overflow builtin requires runtime "

rjmccall wrote:
> jtmott-intel wrote:
> > rjmccall wrote:
> > > erichkeane wrote:
> > > > Mentioning target-specific support here seems incorrect. @rjmccall I 
> > > > cannot think of a better wording, can you?
> > > "overflow builtins do not support _ExtInt operands of more than %0 bits 
> > > on this target"?  I don't think it's unreasonable to mention the 
> > > target-specificness of it.   Hard-coding the number 64 in the diagnostic 
> > > seems excessively targeted, though.
> > I discovered there's a good existing message I could use that already takes 
> > the bitwidth as a parameter. I decided not to add a new one. 
> > Thoughts/preferences? Here's how the message would come out.
> > 
> > test.c:5:43: error: signed _ExtInt of bit sizes greater than 128 not 
> > supported
> > _Bool status = __builtin_mul_overflow(x, y, &result);
> >   ^
> > 1 error generated.
> > 
> It'd be much clearer to say something about the fact that it's just this 
> builtin that's not supported.
Updated message to something halfway between John and Erich's suggestions. 
Current result:

test.c:5:43: error: __builtin_mul_overflow does not support signed _ExtInt 
operands of more than 128 bits
_Bool status = __builtin_mul_overflow(x, y, &result);
  ^
1 error generated.





Comment at: clang/test/Sema/builtins-overflow.c:39
+_ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expected-error 
{{signed _ExtInt of bit sizes greater than 128 not supported}}
+  }

erichkeane wrote:
> As @rjmccall said, I'd suggest the new message anyway that mentions the 
> builtin, otherwise this would be confusing for me.  Something like:
> 
> signed argument to __builtin_mul_overflow must have a bitwidth of less than 
> or equal to 128.
Updated message to something halfway between your and John's suggestions. 
Current result:

test.c:5:43: error: __builtin_mul_overflow does not support signed _ExtInt 
operands of more than 128 bits
_Bool status = __builtin_mul_overflow(x, y, &result);
  ^
1 error generated.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81420/new/

https://reviews.llvm.org/D81420



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


[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

This looks like the right interpretation of the standard/implementation to me.  
But please do not commit on this accept for another day or two to give the rest 
a chance to look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81615/new/

https://reviews.llvm.org/D81615



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


[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith marked 2 inline comments as done.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:98
+//
+if (DRE->isNonOdrUse() != NOUR_Unevaluated)
+  return S.Diag(DRE->getBeginLoc(),

I think this is an oversight, and we should probably allow all non-odr-use 
mentions here. I'll take this to the committee to check. But let's go with the 
rule as written for now.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:114
+//
+if (VDecl->isLocalVarDecl() && !DRE->isNonOdrUse())
   return S.Diag(DRE->getBeginLoc(),

Do we perform this check after finishing the full-expression and properly 
setting the 'non-odr-use' bits? Oh, I see, that's what the follow-up change is 
about :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81615/new/

https://reviews.llvm.org/D81615



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-10 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/include/clang/AST/RecordLayout.h:75
+  // can be different than Alignment in cases where it is beneficial for
+  // performance.
+  CharUnits PreferredAlignment;

nit for comment: I don't think it's related to performance nowadays, and it's 
more for ABI-compat reason. 



Comment at: clang/lib/AST/ASTContext.cpp:2409
+return std::max(
+ABIAlign, (unsigned)toBits(getASTRecordLayout(RD).PreferredAlignment));
+  }

static_cast instead of c cast?



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:826
+static bool isAIXLayout(const ASTContext &Context) {
+  return Context.getTargetInfo().getTriple().getOS() == llvm::Triple::AIX;
+}

We added supportsAIXPowerAlignment, so let's make use of that.
We could replace every call to isAIXLayout with supportsAIXPowerAlignment. This 
name is more expressive as well. 



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1225
+  CharUnits PreferredAlign =
+  (Packed && ((Context.getLangOpts().getClangABICompat() <=
+   LangOptions::ClangABI::Ver6) ||

Use a lambda for this query would be more preferable if same logic get used 
twice.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1881
+  if (isAIXLayout(Context) && FieldOffset == CharUnits::Zero() &&
+  (IsUnion || NonOverlappingEmptyFieldFound)) {
+FirstNonOverlappingEmptyFieldHandled = true;

Maybe it's a naive thought, but is it possible to replace 
`NonOverlappingEmptyFieldFound` with `IsOverlappingEmptyField && 
FieldOffsets.size() == 0`?



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1943
 getDataSize() != CharUnits::Zero())
   FieldOffset = getDataSize().alignTo(FieldAlign);
 else

hmm... Are we sure we should use FieldAlign instead of PreferredAlign here?
Same for the else below.



Comment at: clang/lib/Basic/Targets/PPC.h:377
 
+if (Triple.isOSAIX()) {
+  LongDoubleWidth = 64;

nit: use "else if" with the above if statement?
If it enters one of the Triples above, it's not necessary to check if it is AIX 
any more. 



Comment at: clang/lib/Basic/Targets/PPC.h:411
 
 if (Triple.getOS() == llvm::Triple::AIX)
   SuitableAlign = 64;

This could get combined with the new if for AIX below. 



Comment at: clang/lib/Basic/Targets/PPC.h:419
 
+if (Triple.isOSAIX()) {
+  LongDoubleWidth = 64;

nit: use "else if" with the above if statement?



Comment at: clang/test/Layout/aix-no-unique-address-with-double.cpp:62
+
+  [[no_unique_address]] Empty emp;
+  A a;

Not an action item, but just an interesting note that, in some cases(like this 
one) power alignment rule could reverse the benefit of having 
[[no_unique_address]] at the first place. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D81311#2086227 , @jdoerfert wrote:

> Do we allow `inmem` to be used for other purposes? I would assume the answer 
> is yes, as we do not forbid it.


I don't know what else we might use it for off-hand, but yes, I think the 
frontend could put this down on all value arguments that are actually passed 
indirectly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81311/new/

https://reviews.llvm.org/D81311



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:327
   return true;
 TheCall->setArg(2, Arg.get());
   }

I know this is existing code, but this is a broken mess.  Please change this to:

```
  ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(2));
  if (Arg.isInvalid()) return true;
  TheCall->setArg(2, Arg.get());

  QualType Ty = Arg.get()->getType();
  const auto *PtrTy = Ty->getAs();
  if (!PtrTy ||
  !PtrTy->getPointeeType()->isIntegerType() ||
  PtrTy->getPointeeType().isConstQualified()) {
S.Diag(Arg.get()->getBeginLoc(),
   diag::err_overflow_builtin_must_be_ptr_int)
  << Ty << Arg.get()->getSourceRange();
return true;
  }
```

Test case would be something like (in ObjC):

```
@interface HasPointer
@property int *pointer;
@end

void test(HasPointer *hp) {
  __builtin_add_overflow(x, y, hp.pointer);
}
```

And the earlier block needs essentially the same change (but obviously checking 
for a different type).  You can't check types before doing placeholder 
conversions, and once you do l-value conversions and a type-check, you really 
don't need the full parameter-initialization logic.



Comment at: clang/lib/Sema/SemaChecking.cpp:337
+  QualType Ty =
+  I < 2 ? Arg.get()->getType()
+: Arg.get()->getType()->getAs()->getPointeeType();

jtmott-intel wrote:
> erichkeane wrote:
> > Try:
> > 
> > Type *Ty = ArgExpr->getType()->getPointeeOrArrayElementType();
> > 
> > instead of the ternary.
> A complication I'm seeing is that `getPointeeOrArrayElementType` returns a 
> `Type` but getIntWidth wants a `QualType`. Some options that occurred to me:
> 
> - Is it acceptable to just wrap a `Type` in a `QualType`?
> - I might be able to add a `getIntWidth(const Type*)` overload.
> - Looks like I can skip the `getAs()` and just call 
> `getPointeeType` directly. The line would be shorter but I would still need 
> the ternary.
* Is it acceptable to just wrap a Type in a QualType?

In general, no, this can lose qualifiers on the array element.  But 
`getIntWidth` shouldn't ever care about that, so in the abstract, adding the 
overload should be fine.  However, in this case I think the ternary is actually 
better code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81420/new/

https://reviews.llvm.org/D81420



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


[PATCH] D81530: [clangd] Log rather than assert on bad UTF-8.

2020-06-10 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

Thanks for the detailed analysis! I have filed 
https://github.com/boostorg/spirit/issues/612


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81530/new/

https://reviews.llvm.org/D81530



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


[PATCH] D81616: [clang] Convert a default argument expression to the parameter type before checking that the default argument is valid with CheckDefaultArgumentVisitor.

2020-06-10 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: bkramer, rjmccall, rsmith, erichkeane.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
riccibruno added a parent revision: D81615: [clang] CWG 2082 and 2346: loosen 
the restrictions on parameters and local variables in default arguments..

Currently the restrictions on a default argument are checked with the visitor
`CheckDefaultArgumentVisitor` in `ActOnParamDefaultArgument` before
performing the conversion to the parameter type in `SetParamDefaultArgument`.

This was fine before the previous patch but now some valid code post-CWG 2346
is rejected:

  void test() {
const int i2 = 0;
extern void h2a(int x = i2); // FIXME: ok, not odr-use
extern void h2b(int x = i2 + 0); // ok, not odr-use
  }

This is because the reference to `i2` in `h2a` has not been marked yet with 
`NOUR_Constant`.
`i2` is marked `NOUR_Constant` when the conversion to the parameter type is 
done, which is
done just after.

The solution is to do the conversion to the parameter type before checking the 
restrictions on
default arguments with `CheckDefaultArgumentVisitor`. This has the side-benefit 
of improving
some diagnostics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81616

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
  clang/test/SemaCXX/vartemplate-lambda.cpp
  clang/test/SemaTemplate/instantiate-local-class.cpp

Index: clang/test/SemaTemplate/instantiate-local-class.cpp
===
--- clang/test/SemaTemplate/instantiate-local-class.cpp
+++ clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -462,18 +462,15 @@
 struct Inner { // expected-note {{in instantiation}}
   void operator()(T a = "") {} // expected-error {{conversion function from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
   // expected-note@-1 {{passing argument to parameter 'a' here}}
-  // expected-note@-2 {{candidate function not viable}}
 };
-Inner()(); // expected-error {{no matching function}}
+Inner()(); // expected-error {{type 'Inner' does not provide a call operator}}
   }
   template void foo(); // expected-note 2 {{in instantiation}}
 
   template  void bar() {
 auto lambda = [](T a = "") {}; // expected-error {{conversion function from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
   // expected-note@-1 {{passing argument to parameter 'a' here}}
-  // expected-note@-2 {{candidate function not viable}}
-  // expected-note@-3 {{conversion candidate of type}}
-lambda(); // expected-error {{no matching function}}
+lambda();
   }
   template void bar(); // expected-note {{in instantiation}}
 }
@@ -494,9 +491,6 @@
   void f(int x = [](T x = nullptr) -> int { return x; }());
   // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}}
   // expected-note@-2 {{passing argument to parameter 'x' here}}
-  // expected-error@-3 {{no matching function for call}}
-  // expected-note@-4 {{candidate function not viable: requires single argument 'x', but no arguments were provided}}
-  // expected-note@-5 {{conversion candidate of type 'auto (*)(int) -> int'}}
 
   void g() { f(); }
   // expected-note@-1 {{in instantiation of default function argument expression for 'f' required here}}
Index: clang/test/SemaCXX/vartemplate-lambda.cpp
===
--- clang/test/SemaCXX/vartemplate-lambda.cpp
+++ clang/test/SemaCXX/vartemplate-lambda.cpp
@@ -6,10 +6,7 @@
 template auto fn1 = [](auto a) { return a + T(1); };
 template auto v1 = [](int a = T()) { return a; }();
 // expected-error@-1{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}}
-// expected-error@-2{{no matching function for call}}
-// expected-note@-3{{passing argument to parameter 'a' here}}
-// expected-note@-4{{candidate function not viable}}
-// expected-note@-5{{conversion candidate of type 'int (*)(int)'}}
+// expected-note@-2{{passing argument to parameter 'a' here}}
 
 struct S {
   template
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -6,5 +6,10 @@
 };
 
 void A::test() {
-  void g(int = this); // expected-error {{default argument references 'this'}}
+  void g(int = this);
+  // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'A *'}}
+  // expected-note@-2 {{passing argument to parameter here}}
+
+  void h(int = ((void)this,42));
+  // expected-error@-1 {{defaul

[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-06-10 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

you are responding to a comment from 2 weeks ago, so let's just move on.

I uploaded a new patch yesterday. You have any comments on this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79675/new/

https://reviews.llvm.org/D79675



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 269981.
nickdesaulniers added a comment.

- update comment to CODEGENOPT
- avoid BooleanFFlag group


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80242/new/

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,7 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-fno-eliminate-unused-debug-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz", file: !4, line: 7, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "_ZTS3baz")
+// CHECK: !7 = !DIEnumerator(name: "BAZ", value: 0)
+// CHECK: !8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z", scope: !9, file: !4, line: 12, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !13)
+// CHECK: !14 = !DIEnumerator(name: "Z", value: 0)
+// CHECK: !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !4, line: 5, baseType: !5)
+// CHECK: !17 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !4, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: "_ZTS3bar")
+// CHECK: !18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y", scope: !9, file: !4, line: 11, size: 8, flags: DIFlagTypePassByValue, elements: !12)
+
+// NODBG-NOT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz", file: !4, line: 7, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "_ZTS3baz")
+// NODBG-NOT: !7 = !DIEnumerator(name: "BAZ", value: 0)
+// NODBG-NOT: !8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z", scope: !9, file: !4, line: 12, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !13)
+// NODBG-NOT: !14 = !DIEnumerator(name: "Z", value: 0)
+// NODBG-NOT: !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !4, line: 5, baseType: !5)
+// NODBG-NOT: !17 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !4, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: "_ZTS3bar")
+// NODBG-NOT: !18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y", scope: !9, file: !4, line: 11, size: 8, flags: DIFlagTypePassByValue, elements: !12)
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,44 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// CHECK: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: true)
+// CHECK: !8 = !DICompositeType(tag: DW

[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the PCH

2020-06-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added subscribers: tstellar, rsmith, sammccall.
sammccall added a comment.

@rsmith are you OK with merging this into the release branch for 10.0.1?
cc @tstellar


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77194/new/

https://reviews.llvm.org/D77194



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Do we allow `inmem` to be used for other purposes? I would assume the answer is 
yes, as we do not forbid it.
I ask because front-ends might use this as a way to add type information to a 
pointer (especially after we strip them).
Or am I confusing something here?

> `byref`

Would be fine with me too.

> I guess the verifier could require you to specify align if you use this, but 
> that's another inconsistency

This would be in line with our efforts to *always* require an alignment. Should 
write it down, make the verifier aware and apply it to `byval` as well, maybe 
others too. The entire "target specific alignment" stuff should be resolved as 
early as possible to not cause confusion and subtle bugs.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81311/new/

https://reviews.llvm.org/D81311



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-10 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel marked an inline comment as done.
jtmott-intel added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:337
+  QualType Ty =
+  I < 2 ? Arg.get()->getType()
+: Arg.get()->getType()->getAs()->getPointeeType();

erichkeane wrote:
> Try:
> 
> Type *Ty = ArgExpr->getType()->getPointeeOrArrayElementType();
> 
> instead of the ternary.
A complication I'm seeing is that `getPointeeOrArrayElementType` returns a 
`Type` but getIntWidth wants a `QualType`. Some options that occurred to me:

- Is it acceptable to just wrap a `Type` in a `QualType`?
- I might be able to add a `getIntWidth(const Type*)` overload.
- Looks like I can skip the `getAs()` and just call 
`getPointeeType` directly. The line would be shorter but I would still need the 
ternary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81420/new/

https://reviews.llvm.org/D81420



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6451
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<

pestctrl wrote:
> efriedma wrote:
> > `InGroup`
> Sorry, I'm not sure I understand. Isn't this a C99 warning? Why is it being 
> put in the C11 group?
Because `C11` really means `C11Extensions`, and this is a C11 extension (ie, 
it's code that's valid in C11 but not valid in C99):
```
// A warning group for warnings about using C11 features as extensions.
def C11 : DiagGroup<"c11-extensions">;
```



Comment at: clang/lib/Sema/SemaExpr.cpp:11571
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers

pestctrl wrote:
> rsmith wrote:
> > efriedma wrote:
> > > pestctrl wrote:
> > > > efriedma wrote:
> > > > > rsmith wrote:
> > > > > > pestctrl wrote:
> > > > > > > efriedma wrote:
> > > > > > > > I think this condition is backwards?  Should be 
> > > > > > > > `!getLangOpts().C11`.  You want the warning with `-std=c99 
> > > > > > > > -pedantic`, you don't want the warning with `std=c11 -pedantic`.
> > > > > > > I don't think it's backwards. If getLangOpts().C11, then it is an 
> > > > > > > extension. Otherwise, it is the warning. I can switch the 
> > > > > > > conditions if it is confusing though.
> > > > > > "Extension" means "this is invalid code that we're accepting 
> > > > > > anyway" -- that's what this is in C99. In C11, I think we shouldn't 
> > > > > > be diagnosing at all.
> > > > > > 
> > > > > > Has anyone checked whether WG14 removed this restriction in C11 as 
> > > > > > a DR resolution? If so, we shouldn't be diagnosing it at all, in 
> > > > > > any language mode.
> > > > > I tracked down the proposal for the change; it's 
> > > > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1439.pdf .  Beyond 
> > > > > the reference to 
> > > > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_314.htm , I can't 
> > > > > find any relevant defect report.
> > > > I have updated the diff to diagnose only for C99. Does the existence of 
> > > > the proposal mean we shouldn't be diagnosing in any language mode?
> > > > 
> > > > Also, how did you track down the proposal that quickly? Even after 
> > > > skimming through it, I still can't find it through searching. 
> > > > Also, how did you track down the proposal that quickly? 
> > > 
> > > It wasn't really that quick, but the thing that eventually worked was 
> > > that I googled for `site:open-std.org "At various points within a 
> > > translation unit"`.
> > I tried to get some clarity from WG14 as to whether they intended N1439 to 
> > be interpreted as applying retroactively, but it seems like their stance is 
> > that they do not do maintenance work on past standards, and have no 
> > mechanism for identifying whether papers should be encouraged for 
> > retroactive application or only for implementations intending to conform to 
> > later standards.
> > 
> > In the absence of guidance either way from WG14, I think our best bet is to 
> > follow GCC and the literal standards text as this patch does.
> GCC has left this warning on by default in any language mode, FWIW. Should we 
> still restrict this warning to only C99 mode? 
Yes, I think so. I assume the GCC folks haven't noticed that this rule was 
relaxed in C11. I've filed a bug against GCC for this: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95630


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79945/new/

https://reviews.llvm.org/D79945



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 269977.
nickdesaulniers added a comment.

- rebase
- fix docs (use declare consistently, avoid define)
- add driver test
- fix command line check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80242/new/

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,7 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-fno-eliminate-unused-debug-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz", file: !4, line: 7, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "_ZTS3baz")
+// CHECK: !7 = !DIEnumerator(name: "BAZ", value: 0)
+// CHECK: !8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z", scope: !9, file: !4, line: 12, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !13)
+// CHECK: !14 = !DIEnumerator(name: "Z", value: 0)
+// CHECK: !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !4, line: 5, baseType: !5)
+// CHECK: !17 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !4, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: "_ZTS3bar")
+// CHECK: !18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y", scope: !9, file: !4, line: 11, size: 8, flags: DIFlagTypePassByValue, elements: !12)
+
+// NODBG-NOT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz", file: !4, line: 7, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "_ZTS3baz")
+// NODBG-NOT: !7 = !DIEnumerator(name: "BAZ", value: 0)
+// NODBG-NOT: !8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z", scope: !9, file: !4, line: 12, baseType: !5, size: 32, flags: DIFlagEnumClass, elements: !13)
+// NODBG-NOT: !14 = !DIEnumerator(name: "Z", value: 0)
+// NODBG-NOT: !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !4, line: 5, baseType: !5)
+// NODBG-NOT: !17 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !4, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: "_ZTS3bar")
+// NODBG-NOT: !18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y", scope: !9, file: !4, line: 11, size: 8, flags: DIFlagTypePassByValue, elements: !12)
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,44 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// CHECK: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: 

[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-10 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: bkramer, rjmccall, rsmith, erichkeane.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements the resolution of  CWG 2082 and CWG 2346.

The resolution of CWG 2082 changed [dcl.fct.default]p7 and p9 to allow a 
parameter
or local variable to appear in a default argument if not in a 
potentially-evaluated expression.

The resolution of CWG 2346 changed [dcl.fct.default]p7 to allow a local variable
to appear in a default argument if not odr-used.

An issue remains after this patch (see the FIXME in 
`test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp`).
This is addressed by the next patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81615

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr23xx.cpp

Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -4,6 +4,13 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 
+namespace dr2346 { // dr2346: 11
+  void test() {
+const int i2 = 0;
+extern void h2b(int x = i2 + 0); // ok, not odr-use
+  }
+}
+
 namespace dr2352 { // dr2352: 10
   int **p;
   const int *const *const &f1() { return p; }
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -49,6 +49,13 @@
   }
 }
 
+namespace dr2082 { // dr2082: 11
+  void test1(int x, int = sizeof(x)); // ok
+#if __cplusplus >= 201103L
+  void test2(int x, int = decltype(x){}); // ok
+#endif
+}
+
 namespace dr2083 { // dr2083: partial
 #if __cplusplus >= 201103L
   void non_const_mem_ptr() {
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void h() {
+  void f1(int x, int y = sizeof(x));  // ok
+  void f2(int x, int y = decltype(x)());  // ok
+  void f3(int x, int y = x);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f4(int x, int y = x + 0);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 class A { 
   void f(A* p = this) { }	// expected-error{{invalid use of 'this'}}
+
+  void test();
 };
+
+void A::test() {
+  void g(int = this); // expected-error {{default argument references 'this'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,7 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-void h()
-{
-  int i;
-  extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+void h() {
+  int i1 = 0;
+  extern void h1(int x = i1);
+  // expected-error@-1 {{default argument references local variable 'i1' of enclosing function}}
+
+  const int i2 = 0;
+  extern void h2a(int x = i2); // FIXME: ok, not odr-use
+  // expected-error@-1 {{default argument references local variable 'i2' of enclosing function}}
+  extern void h2b(int x = i2 + 0); // ok, not odr-use
+
+  const int i3 = 0;
+  extern void h3(const int *x = &i3);
+  // expected-error@-1 {{default argument references local variable 'i3' of enclosing function}}
+
+  const int i4 = 0;
+  extern void h4(int x = sizeof(i4)); // ok, not odr-use
+  extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use
 }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -87,22 +87,31 @@
 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   const NamedDecl *Decl = DRE->getDecl();
   if (const auto *Param = dyn_cast(Decl)) {
-// C++ [dcl.fct.default]p9
-//   Default arguments are evaluated each time the function is
-//   called. The order of evaluation of function ar

[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-06-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added subscribers: raghavendhra, jhuber6, anchu-rajendran, kiranktp, 
DavidTruby, ronlieb, kiranchandramohan.
jdoerfert added a comment.

In D79675#2058657 , @fghanim wrote:

> I am moving on because we are not getting anywhere. However, There are few 
> things I need to point out very quickly.
>
> > I fail to see the point in committing for example your target type solution 
> > if we found a more generic version in the meantime.
> >  We can for sure commit them and then replace them subsequently, but is 
> > that really helping anyone? It would not be a question if
> >  they were in, since they are not it seems to me there is no benefit in 
> > blocking the other patch on them. I mean, the time you worked
> >  on that part is not "less wasted" if we commit it. TBH, I don't thin it is 
> > wasted at all but that is a different conversation.
>
> At one point, you said I was delaying D80222 
>  moments after it was uploaded. Now, D79675 
>  and D79676 
>  , cannot be committed because of the 
> artificial dependency on that patch.


That is not the reason these patches cannot be committed. The reason is that 
*parts of them* needed changes and another round of review.

>> I'm sorry you **feel** I waste your time. I really would not do so on 
>> purpose.
> 
> It is not a feeling. It is a matter of record, and never said you did so on 
> purpose. Freudian slip? :p

Wouldn't that logic imply that any code replacement causes the original work to 
be "wasted time"? I assume that is not the case, hence I do not assume you 
wasted yours (wrt. the code).

>> While more reviewers would obviously help, it is known that smaller patches 
>> do too.
> 
> D79739  has been merged with D80222 
> . I kinda feel bad for the reviewer ;)
>  You are the code owner of the `OMPBuilder`, who do you suggest as reviewers 
> that I can add, in the future?

As of now, I don't really see anyone else doing reviews. I was hoping you would 
start reviewing patches. Same for @jhuber6 
at some point. Other likely candidates are: @kiranchandramohan, @DavidTruby 
@kiranktp @anchu-rajendran @raghavendhra @ronlieb

>> If you have ideas on other improvements of the process, I'm happy to try 
>> them out.
> 
> Let people know that you changed your mind before they put in the time and 
> effort. I am sure that is not a big ask.

I believe I did let everyone know as early as I knew. I'm unsure how I should 
improve on this.
I mention my thoughts in reviews and I usually include a ping to relevant 
@people.
I also assume (or hope) that interested parties watch phabricator (or the 
mailing list), e.g., for OpenMP patches, so they stay informed about what is 
happening.

>  ---
> 
> Anyways, I suggested something that you didn't reply to, which you may have 
> missed. To resolve this, would you be willing to go for:
> 
> 1. You handle any typing problems with this patch when you commit it and 
> D79676  after D80222 
> 
> 2. I bring back all my runtime def.s that I need, and use macros per your 
> original suggestion, and you commit this and D79676 
>  today or tomorrow and that patch can merge 
> based on head commit which it will do anyway?

I'm not even sure I follow. D80222  landed, as 
far as I can tell. Can you elaborate on these suggestions so I do not 
misinterpret them?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79675/new/

https://reviews.llvm.org/D79675



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


[PATCH] D57626: Disallow trivial_abi on a class if all copy and move constructors are deleted

2020-06-10 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf466f0beda59: Disallow trivial_abi on a class if all copy 
and move constructors are deleted (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57626/new/

https://reviews.llvm.org/D57626

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -10,23 +10,23 @@
   int a;
 };
 
-struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}}
+struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}} expected-note {{has a __weak field}}
   __weak id a;
 };
 
-struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}}
+struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}} expected-note {{is polymorphic}}
   virtual void m();
 };
 
 struct S3_2 {
   virtual void m();
-} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}}
+} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}} expected-note {{is polymorphic}}
 
 struct S4 {
   int a;
 };
 
-struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}}
+struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note {{has a virtual base}}
 };
 
 struct __attribute__((trivial_abi)) S9 : public S4 {
@@ -36,19 +36,19 @@
   __weak id a;
 };
 
-struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}}
+struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}} expected-note {{has a __weak field}}
   __weak id a;
 };
 
-struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}}
+struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}} expected-note {{has a __weak field}}
   __weak id a[2];
 };
 
-struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}}
+struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}} expected-note {{has a field of a non-trivial class type}}
   S6 a;
 };
 
-struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}}
+struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}} expected-note {{has a field of a non-trivial class type}}
   S6 a[2];
 };
 
@@ -66,7 +66,7 @@
 S10<__weak id> p2;
 
 template<>
-struct __attribute__((trivial_abi)) S10 { // expected-warning {{'trivial_abi' cannot be applied to 'S10'}}
+struct __attribute__((trivial_abi)) S10 { // expected-warning {{'trivial_abi' cannot be applied to 'S10'}} expected-note {{has a __weak field}}
   __weak id a;
 };
 
@@ -90,8 +90,39 @@
 S16 s16;
 
 template
-struct __attribute__((trivial_abi)) S17 { // expected-warning {{'trivial_abi' cannot be applied to 'S17'}}
+struct __attribute__((trivial_abi)) S17 { // expected-warning {{'trivial_abi' cannot be applied to 'S17'}} expected-note {{has a __weak field}}
   __weak id a;
 };
 
 S17 s17;
+
+namespace deletedCopyMoveConstructor {
+  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
+CopyMoveDeleted(const CopyMoveDeleted &) = delete;
+CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+  };
+
+  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
+CopyMoveDeleted a;
+  };
+
+  struct __attribute__((trivial_abi)) CopyDeleted {
+CopyDeleted(const CopyDeleted &) = delete;
+CopyDeleted(CopyDeleted &&) = default;
+  };
+
+  struct __attribute__((trivial_abi)) MoveDeleted {
+MoveDeleted(const MoveDeleted &) = default;
+MoveDeleted(MoveDeleted &&) = delete;
+  };
+
+  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
+CopyDeleted a;
+MoveDeleted b;
+  };
+
+  // This i

[PATCH] D81530: [clangd] Log rather than assert on bad UTF-8.

2020-06-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D81530#2085725 , @jaafar wrote:

> I can confirm that this commit works equally well for the UTF-8 assertion 
> failure. Thank you!
>
> Is there some way to easily modify the source to produce a diagnostic 
> pointing to the issue's source location? I would like to file an appropriate 
> bug in Boost.


In 
https://www.boost.org/doc/libs/1_73_0/boost/spirit/home/support/char_encoding/iso8859_1.hpp
The line labeled `161  a1`, whose bytes are `"/*  \xa1  161  a1 */   
BOOST_CC_PUNCT,"` triggers it because of the `"\xa1"`.

It's not a cut and dried bug, but I do think removing the high bytes from these 
comments is a good idea, so it's probably worth filing the bug.

The C++ standard doesn't say anything about the encoding of characters on disk 
(the "input encoding" of bytes -> source character set) - it starts with the 
source character set, I think. So what do implementations do?

- clang: from reading the code, clang only supports UTF-8. It supports gcc's 
-finput-charset flag, but setting it to anything other than UTF-8 is an error!
- GCC: supports a variety of input encodings, configured with `-finput-charset` 
or locale. As such it's not really reasonable for a header designed to be 
included to require any particular value, as you can't pass a flag for just 
that header.

In practice this doesn't actually affect compilation because the bad UTF-8 
sequence in the comment is never parsed: clang just skips over it looking for 
`*/`. It probably mostly affects tools that use line/column coordinates (like 
clangd by virtue of LSP, and clang diagnostics), and tools that extract comment 
contents (doxygen et al).
But it still seems that it would be clearer to remove the literal characters 
from the source file, or write them in UTF-8.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81530/new/

https://reviews.llvm.org/D81530



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-10 Thread Benson Chu via Phabricator via cfe-commits
pestctrl marked 2 inline comments as done.
pestctrl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6451
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<

efriedma wrote:
> `InGroup`
Sorry, I'm not sure I understand. Isn't this a C99 warning? Why is it being put 
in the C11 group?



Comment at: clang/lib/Sema/SemaExpr.cpp:11571
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers

rsmith wrote:
> efriedma wrote:
> > pestctrl wrote:
> > > efriedma wrote:
> > > > rsmith wrote:
> > > > > pestctrl wrote:
> > > > > > efriedma wrote:
> > > > > > > I think this condition is backwards?  Should be 
> > > > > > > `!getLangOpts().C11`.  You want the warning with `-std=c99 
> > > > > > > -pedantic`, you don't want the warning with `std=c11 -pedantic`.
> > > > > > I don't think it's backwards. If getLangOpts().C11, then it is an 
> > > > > > extension. Otherwise, it is the warning. I can switch the 
> > > > > > conditions if it is confusing though.
> > > > > "Extension" means "this is invalid code that we're accepting anyway" 
> > > > > -- that's what this is in C99. In C11, I think we shouldn't be 
> > > > > diagnosing at all.
> > > > > 
> > > > > Has anyone checked whether WG14 removed this restriction in C11 as a 
> > > > > DR resolution? If so, we shouldn't be diagnosing it at all, in any 
> > > > > language mode.
> > > > I tracked down the proposal for the change; it's 
> > > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1439.pdf .  Beyond the 
> > > > reference to http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_314.htm 
> > > > , I can't find any relevant defect report.
> > > I have updated the diff to diagnose only for C99. Does the existence of 
> > > the proposal mean we shouldn't be diagnosing in any language mode?
> > > 
> > > Also, how did you track down the proposal that quickly? Even after 
> > > skimming through it, I still can't find it through searching. 
> > > Also, how did you track down the proposal that quickly? 
> > 
> > It wasn't really that quick, but the thing that eventually worked was that 
> > I googled for `site:open-std.org "At various points within a translation 
> > unit"`.
> I tried to get some clarity from WG14 as to whether they intended N1439 to be 
> interpreted as applying retroactively, but it seems like their stance is that 
> they do not do maintenance work on past standards, and have no mechanism for 
> identifying whether papers should be encouraged for retroactive application 
> or only for implementations intending to conform to later standards.
> 
> In the absence of guidance either way from WG14, I think our best bet is to 
> follow GCC and the literal standards text as this patch does.
GCC has left this warning on by default in any language mode, FWIW. Should we 
still restrict this warning to only C99 mode? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79945/new/

https://reviews.llvm.org/D79945



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18508
+  // Component = CreateBuiltinUnaryOp(ELoc, UO_Deref, Component).get();
+  // Component = DefaultFunctionArrayLvalueConversion(Component).get();
+}

jdoerfert wrote:
> Leftover?
Yes, forgot to remove


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80730/new/

https://reviews.llvm.org/D80730



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


[clang] f466f0b - Disallow trivial_abi on a class if all copy and move constructors are

2020-06-10 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-06-10T14:12:13-07:00
New Revision: f466f0beda59af1af182deb3cc8c006093d5a169

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

LOG: Disallow trivial_abi on a class if all copy and move constructors are
deleted

Instead of forcing the class to be passed in registers, which was what
r350920 did, issue a warning and inform the user that the attribute
cannot be used.

For more background, see this discussion:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190128/259907.html

This fixes PR39683.

rdar://problem/47308221

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

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaObjCXX/attr-trivial-abi.mm

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 32ea9fcbf44e..3cba3a3d96f9 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2810,6 +2810,7 @@ destroy the object before returning.
 Attribute ``trivial_abi`` has no effect in the following cases:
 
 - The class directly declares a virtual base or virtual methods.
+- Copy constructors and move constructors of the class are all deleted.
 - The class has a base class that is non-trivial for the purposes of calls.
 - The class has a non-static data member whose type is non-trivial for the 
purposes of calls, which includes:
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ffe9513f8208..1f68ef0d8dae 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3301,6 +3301,12 @@ def err_attribute_output_parameter : Error<
 
 def ext_cannot_use_trivial_abi : ExtWarn<
   "'trivial_abi' cannot be applied to %0">, InGroup;
+def note_cannot_use_trivial_abi_reason : Note<
+  "'trivial_abi' is disallowed on %0 because %select{"
+  "its copy constructors and move constructors are all deleted|"
+  "it is polymorphic|"
+  "it has a base of a non-trivial class type|it has a virtual base|"
+  "it has a __weak field|it has a field of a non-trivial class type}1">;
 
 // Availability attribute
 def warn_availability_unknown_platform : Warning<

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 09d381a5a1ba..26a5e129efdf 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9686,27 +9686,53 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXMethodDecl 
*MD) {
 }
 
 void Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl &RD) {
-  auto PrintDiagAndRemoveAttr = [&]() {
+  auto PrintDiagAndRemoveAttr = [&](unsigned N) {
 // No diagnostics if this is a template instantiation.
-if (!isTemplateInstantiation(RD.getTemplateSpecializationKind()))
+if (!isTemplateInstantiation(RD.getTemplateSpecializationKind())) {
   Diag(RD.getAttr()->getLocation(),
diag::ext_cannot_use_trivial_abi) << &RD;
+  Diag(RD.getAttr()->getLocation(),
+   diag::note_cannot_use_trivial_abi_reason) << &RD << N;
+}
 RD.dropAttr();
   };
 
+  // Ill-formed if the copy and move constructors are deleted.
+  auto HasNonDeletedCopyOrMoveConstructor = [&]() {
+if (RD.needsImplicitCopyConstructor() &&
+!RD.defaultedCopyConstructorIsDeleted())
+  return true;
+if (RD.needsImplicitMoveConstructor() &&
+!RD.defaultedMoveConstructorIsDeleted())
+  return true;
+for (const CXXConstructorDecl *CD : RD.ctors())
+  if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
+return true;
+return false;
+  };
+
+  if (!HasNonDeletedCopyOrMoveConstructor()) {
+PrintDiagAndRemoveAttr(0);
+return;
+  }
+
   // Ill-formed if the struct has virtual functions.
   if (RD.isPolymorphic()) {
-PrintDiagAndRemoveAttr();
+PrintDiagAndRemoveAttr(1);
 return;
   }
 
   for (const auto &B : RD.bases()) {
 // Ill-formed if the base class is non-trivial for the purpose of calls or 
a
 // virtual base.
-if ((!B.getType()->isDependentType() &&
- !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
-B.isVirtual()) {
-  PrintDiagAndRemoveAttr();
+if (!B.getType()->isDependentType() &&
+!B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
+  PrintDiagAndRemoveAttr(2);
+  return;
+}
+
+if (B.isVirtual()) {
+  PrintDiagAndRemoveAttr(3);
   return;
 }
   }
@@ -9716,14 +9742,14 @@ void Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl 
&RD) {
 // non-trivial for the purpose of calls.
 QualType FT = FD->getType();

[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

One nit below, the others seem silent. LGTM.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:18508
+  // Component = CreateBuiltinUnaryOp(ELoc, UO_Deref, Component).get();
+  // Component = DefaultFunctionArrayLvalueConversion(Component).get();
+}

Leftover?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80730/new/

https://reviews.llvm.org/D80730



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-10 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 269961.
cchen added a comment.

Fix based on feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,283 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 --check-

[clang] 1727c6a - [clang] Use IsVolatile=true and RequiresNullTerminator=false for PCMs

2020-06-10 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2020-06-10T14:37:30-06:00
New Revision: 1727c6aab34012f0cefc8a3f29ede5f1f718c832

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

LOG: [clang] Use IsVolatile=true and RequiresNullTerminator=false for PCMs

This change got missed while upstreaming
https://reviews.llvm.org/D2. This is the part of that change that
actually passes the correct arguments when opening a PCM.

The test didn't catch this because it starts at the
`MemoryBuffer::getOpenFile` level. It's not really possible to test
`ModuleManager::addModule` itself to verify how the file was opened.

Added: 


Modified: 
clang/lib/Serialization/ModuleManager.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index 2656220f306d..a42ed2f3c179 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -185,7 +185,14 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
   Buf = llvm::MemoryBuffer::getSTDIN();
 } else {
   // Get a buffer of the file and close the file descriptor when done.
-  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false);
+  // The file is volatile because in a parallel build we expect multiple
+  // compiler processes to use the same module file rebuilding it if 
needed.
+  //
+  // RequiresNullTerminator is false because module files don't need it, 
and
+  // this allows the file to still be mmapped.
+  Buf = FileMgr.getBufferForFile(NewModule->File,
+ /*IsVolatile=*/true,
+ /*RequiresNullTerminator=*/false);
 }
 
 if (!Buf) {



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


[PATCH] D81285: [builtins] Change si_int to int in some helper declarations

2020-06-10 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

I need to recompile LLVM to test this patch so it might take a while.

In D81285#2082517 , @atrosinenko wrote:

> In D81285#2082394 , @aykevl wrote:
>
> > Also note that the libgcc documentation does not always reflect the real 
> > world. For example, `__divmodsi4` on AVR libgcc has a very different 
> > signature: it returns both the division result and the remainder in 
> > registers.
>
>
> Do you mean some special calling convention not used outside the 
> `libgcc`/`clang_rt`? MSP430 has one as well. And I still have to decide how 
> to express for //some of// generic C implementations that they should use 
> that special calling convention on MSP430 without cluttering the sources with 
> `O(target count)` complexity. :) Meanwhile, some hacks do exist for ARM 
> target already.


I don't mean a separate calling convention, although AVR has that as well. 
Rather, that the builtin has a different function signature. This signature is 
a bit hard to express in C so you might consider it a different ABI I guess. I 
implemented it in C by packing the two return values in a single `uint64_t`.




Comment at: compiler-rt/lib/builtins/int_lib.h:112
 
-uint32_t __inline __builtin_ctz(uint32_t value) {
+int __inline __builtin_ctz(uint32_t value) {
   unsigned long trailing_zero = 0;

atrosinenko wrote:
> aykevl wrote:
> > Why `int` and not `native_int` here?
> Just to use more "textually identical" prototype as for an actual 
> `__builtin_ctz` from GCC. On the other hand, such dilemma could be one of 
> arguments against `native_int`.
Yes, that makes sense. It is actually defined with `int` in [the official 
documentation](https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html), and 
because this is at the C language level and not at the ABI/target level, it's 
not one of the "int but really int32_t" types.

That said, I think the parameter should also be `unsigned int` instead of 
`uint32_t`. And the same goes for the other types below. Although, in practice, 
it doesn't really matter as it's all MSVC with 32-bit int everywhere.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81285/new/

https://reviews.llvm.org/D81285



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


[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

2020-06-10 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 2 inline comments as done.
riccibruno added a comment.

Thanks for the review Aaron! I have added some comments inline.




Comment at: clang/lib/Basic/ExpressionTraits.cpp:29-34
+  assert(T <= ET_Last && "invalid enum value!");
+  return ExpressionTraitNames[T];
+}
+
+const char *clang::getTraitSpelling(ExpressionTrait T) {
+  assert(T <= ET_Last && "invalid enum value!");

aaron.ballman wrote:
> Isn't `ET_Last` -1?
Nope :) It's `-1` plus 1 per element in the enumeration. I have added the 
enumerators `ET_Last`, `ATT_Last` and `UETT_Last` for consistency with 
`UTT_Last`, `BTT_Last` and `TT_Last` which are needed.

In this patch `ET_Last`, `ATT_Last` and `UETT_Last` are only used here in this 
assertion and could be replaced by the equivalent `T < XX_Last` where `XX_Last` 
is just added as the last element in the enumeration. However mixing `XX_Last = 
XX_LastElement` and `XX_Last = LastElement + 1` would be very error-prone.



Comment at: clang/lib/Sema/SemaExpr.cpp:3974
 S.Diag(Loc, diag::ext_sizeof_alignof_function_type)
-  << TraitKind << ArgRange;
+<< getTraitSpelling(TraitKind) << ArgRange;
 return false;

aaron.ballman wrote:
> I think the original code was a bit more clear; would it make sense to make 
> the diagnostic engine aware of trait kinds so that it does this dance for 
> you? (It may be overkill given that we don't pass `UnaryExprOrTypeTrait` 
> objects to the diagnostic engine THAT often, but I'm curious what you think.)
I don't think it is worthwhile since as you say `UnaryExprOrTypeTrait` objects 
are not frequently passed to the diagnostic engine.

Moreover I personally finds the explicit `getTraitSpelling(TraitKind)` clearer 
for two reasons:
1. Frequently a non-class enumerator is used as an index to a `select` in a 
diagnostic, relying on the implicit integer conversion.  Special casing 
`UnaryExprOrTypeTrait` would be surprising.

2. (weaker) `<< TraitKind` could mean something else than the trait's spelling; 
for example this could print the trait's name or some user-visible version 
thereof.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81455/new/

https://reviews.llvm.org/D81455



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:11571
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers

efriedma wrote:
> pestctrl wrote:
> > efriedma wrote:
> > > rsmith wrote:
> > > > pestctrl wrote:
> > > > > efriedma wrote:
> > > > > > I think this condition is backwards?  Should be 
> > > > > > `!getLangOpts().C11`.  You want the warning with `-std=c99 
> > > > > > -pedantic`, you don't want the warning with `std=c11 -pedantic`.
> > > > > I don't think it's backwards. If getLangOpts().C11, then it is an 
> > > > > extension. Otherwise, it is the warning. I can switch the conditions 
> > > > > if it is confusing though.
> > > > "Extension" means "this is invalid code that we're accepting anyway" -- 
> > > > that's what this is in C99. In C11, I think we shouldn't be diagnosing 
> > > > at all.
> > > > 
> > > > Has anyone checked whether WG14 removed this restriction in C11 as a DR 
> > > > resolution? If so, we shouldn't be diagnosing it at all, in any 
> > > > language mode.
> > > I tracked down the proposal for the change; it's 
> > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1439.pdf .  Beyond the 
> > > reference to http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_314.htm , 
> > > I can't find any relevant defect report.
> > I have updated the diff to diagnose only for C99. Does the existence of the 
> > proposal mean we shouldn't be diagnosing in any language mode?
> > 
> > Also, how did you track down the proposal that quickly? Even after skimming 
> > through it, I still can't find it through searching. 
> > Also, how did you track down the proposal that quickly? 
> 
> It wasn't really that quick, but the thing that eventually worked was that I 
> googled for `site:open-std.org "At various points within a translation unit"`.
I tried to get some clarity from WG14 as to whether they intended N1439 to be 
interpreted as applying retroactively, but it seems like their stance is that 
they do not do maintenance work on past standards, and have no mechanism for 
identifying whether papers should be encouraged for retroactive application or 
only for implementations intending to conform to later standards.

In the absence of guidance either way from WG14, I think our best bet is to 
follow GCC and the literal standards text as this patch does.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79945/new/

https://reviews.llvm.org/D79945



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


[PATCH] D78232: [OPENMP50]Codegen for scan directive in simd loops.

2020-06-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM. Thx!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78232/new/

https://reviews.llvm.org/D78232



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


[PATCH] D77836: [Attribute] Fix noderef attribute false-negatives

2020-06-10 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f6bb2a69215: [clang][Attribute] Fix noderef attribute 
false-negatives (authored by leonardchan).

Changed prior to commit:
  https://reviews.llvm.org/D77836?vs=267684&id=269951#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77836/new/

https://reviews.llvm.org/D77836

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Frontend/noderef.cpp

Index: clang/test/Frontend/noderef.cpp
===
--- clang/test/Frontend/noderef.cpp
+++ clang/test/Frontend/noderef.cpp
@@ -80,12 +80,28 @@
   int member;
   int NODEREF *member2;
   int NODEREF member3; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *member4;
+
+  int func() { return member; }
+  virtual int func_virt() { return member; }
+
+  A(NODEREF int *x) : member4(x) {} // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
 };
 
+class Child : public A {};
+
 void MemberPointer() {
   int NODEREF A::*var = &A::member; // expected-warning{{'noderef' can only be used on an array or pointer type}}
 }
 
+int MethodCall(NODEREF A *a) { // expected-note{{a declared here}}
+  return a->func();// expected-warning{{dereferencing a; was declared with a 'noderef' type}}
+}
+
+int ChildCall(NODEREF Child *child) { // expected-note{{child declared here}}
+  return child->func();   // expected-warning{{dereferencing child; was declared with a 'noderef' type}}
+}
+
 template 
 class B {
   Ty NODEREF *member;
@@ -100,3 +116,53 @@
 
 int NODEREF *glob_ptr;  // expected-note{{glob_ptr declared here}}
 int glob_int = *glob_ptr;  // expected-warning{{dereferencing glob_ptr; was declared with a 'noderef' type}}
+
+void cast_from_void_ptr(NODEREF void *x) {
+  int *a = static_cast(x);  // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+
+  // Allow regular C-style casts and C-style through reinterpret_casts to be holes
+  int *b = reinterpret_cast(x);
+  int *c = (int *)x;
+}
+
+void conversion_sequences() {
+  NODEREF int *x;
+  int *x2 = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *x3 = static_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *x4 = reinterpret_cast(x);
+
+  // Functional cast - This is exactly equivalent to a C-style cast.
+  typedef int *INT_PTR;
+  int *x5 = INT_PTR(x);
+
+  NODEREF Child *child;
+  Child *child2 = dynamic_cast(child); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+int *static_cast_from_same_ptr_type(NODEREF int *x) {
+  return static_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+A *dynamic_cast_up(NODEREF Child *child) {
+  return dynamic_cast(child); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+Child *dynamic_cast_down(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+A *dynamic_cast_side(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+void *dynamic_cast_to_void_ptr(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+int *const_cast_check(NODEREF const int *x) {
+  return const_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+const int *const_cast_check(NODEREF int *x) {
+  return const_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8200,9 +8200,13 @@
 if (const auto *ToPtrType = Step->Type->getAs()) {
   if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
   !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
-S.Diag(CurInit.get()->getExprLoc(),
-   diag::warn_noderef_to_dereferenceable_pointer)
-<< CurInit.get()->getSourceRange();
+// Do not check static casts here because they are checked earlier
+// in Sema::ActOnCXXNamedCast()
+if (!Kind.isStaticCast()) {
+  S.Diag(CurInit.get()->getExprLoc(),
+ diag::warn_noderef_to_dereferenceable_pointer)
+  << CurInit.get()->getSourceRange();
+}
   }
 }
   }
Index: clang/lib/Sema/SemaCast.cpp

[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, with one more comment inline.




Comment at: clang/lib/Serialization/ASTWriter.cpp:2345
FirstMacroID - NUM_PREDEF_MACRO_IDS,
-   MacroOffsetsBase};
+   MacroOffsetsBase - ASTBlockStartOffset};
 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));

It looks to me like this field is ignored in the reader. If so we should just 
strip it. Can you confirm?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80383/new/

https://reviews.llvm.org/D80383



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


[PATCH] D81608: Fix incorrect call to ExprResult::get()

2020-06-10 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: Anastasia, pekka.jaaskelainen.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Res is already a ExprResult, so if we call .get() we convert an
ExprError() result into an unset result. I discovered this in our
downstream CHERI target where this resulted in a crash due to a
NULL-dereference.
It appears that this was introduced in SVN revision 201788 
(8690a6860a45ba36e39b4ff0dbe434195e125d11)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81608

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@
   // to function type.
   if (Ty->isFunctionType()) {
 Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-CK_FunctionToPointerDecay).get();
+CK_FunctionToPointerDecay);
 if (Res.isInvalid())
   return ExprError();
   }


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@
   // to function type.
   if (Ty->isFunctionType()) {
 Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-CK_FunctionToPointerDecay).get();
+CK_FunctionToPointerDecay);
 if (Res.isInvalid())
   return ExprError();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

2020-06-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Basic/ExpressionTraits.cpp:29-34
+  assert(T <= ET_Last && "invalid enum value!");
+  return ExpressionTraitNames[T];
+}
+
+const char *clang::getTraitSpelling(ExpressionTrait T) {
+  assert(T <= ET_Last && "invalid enum value!");

Isn't `ET_Last` -1?



Comment at: clang/lib/Basic/TypeTraits.cpp:64
+const char *clang::getTraitName(ArrayTypeTrait T) {
+  assert(T <= ATT_Last && "invalid enum value!");
+  return ArrayTypeTraitNames[T];

`ATT_Last` is also -1.



Comment at: clang/lib/Basic/TypeTraits.cpp:69
+const char *clang::getTraitName(UnaryExprOrTypeTrait T) {
+  assert(T <= UETT_Last && "invalid enum value!");
+  return UnaryExprOrTypeTraitNames[T];

`UETT_Last` is also -1.



Comment at: clang/lib/Sema/SemaExpr.cpp:3974
 S.Diag(Loc, diag::ext_sizeof_alignof_function_type)
-  << TraitKind << ArgRange;
+<< getTraitSpelling(TraitKind) << ArgRange;
 return false;

I think the original code was a bit more clear; would it make sense to make the 
diagnostic engine aware of trait kinds so that it does this dance for you? (It 
may be overkill given that we don't pass `UnaryExprOrTypeTrait` objects to the 
diagnostic engine THAT often, but I'm curious what you think.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81455/new/

https://reviews.llvm.org/D81455



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


[clang] 2f6bb2a - [clang][Attribute] Fix noderef attribute false-negatives

2020-06-10 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-06-10T12:20:54-07:00
New Revision: 2f6bb2a69215f9cae883da12f8f596d3f80f8d71

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

LOG: [clang][Attribute] Fix noderef attribute false-negatives

`noderef` was failing to trigger warnings in some cases related to c++ style
casting. This patch addresses them.

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

Added: 


Modified: 
clang/include/clang/Sema/Initialization.h
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/Frontend/noderef.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index d50ec2addc8f..ca9e0a198cb9 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -689,6 +689,9 @@ class InitializationKind {
 return Context >= IC_StaticCast;
   }
 
+  /// Determine whether this initialization is a static cast.
+  bool isStaticCast() const { return Context == IC_StaticCast; }
+
   /// Determine whether this initialization is a C-style cast.
   bool isCStyleOrFunctionalCast() const {
 return Context >= IC_CStyleCast;

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index f483f7315aec..2efe26052c78 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -161,6 +161,30 @@ namespace {
   PlaceholderKind = (BuiltinType::Kind) 0;
 }
   };
+
+  void CheckNoDeref(Sema &S, const QualType FromType, const QualType ToType,
+SourceLocation OpLoc) {
+if (const auto *PtrType = dyn_cast(FromType)) {
+  if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
+if (const auto *DestType = dyn_cast(ToType)) {
+  if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) {
+S.Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer);
+  }
+}
+  }
+}
+  }
+
+  struct CheckNoDerefRAII {
+CheckNoDerefRAII(CastOperation &Op) : Op(Op) {}
+~CheckNoDerefRAII() {
+  if (!Op.SrcExpr.isInvalid())
+CheckNoDeref(Op.Self, Op.SrcExpr.get()->getType(), Op.ResultType,
+ Op.OpRange.getBegin());
+}
+
+CastOperation &Op;
+  };
 }
 
 static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr,
@@ -723,6 +747,8 @@ static TryCastResult 
getCastAwayConstnessCastKind(CastAwayConstnessKind CACK,
 /// Refer to C++ 5.2.7 for details. Dynamic casts are used mostly for runtime-
 /// checked downcasts in class hierarchies.
 void CastOperation::CheckDynamicCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (ValueKind == VK_RValue)
 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
   else if (isPlaceholder())
@@ -876,6 +902,8 @@ void CastOperation::CheckDynamicCast() {
 /// const char *str = "literal";
 /// legacy_function(const_cast\(str));
 void CastOperation::CheckConstCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (ValueKind == VK_RValue)
 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
   else if (isPlaceholder())
@@ -1045,6 +1073,8 @@ void CastOperation::CheckReinterpretCast() {
 /// Refer to C++ 5.2.9 for details. Static casts are mostly used for making
 /// implicit conversions explicit and getting rid of data loss warnings.
 void CastOperation::CheckStaticCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (isPlaceholder()) {
 checkNonOverloadPlaceholders();
 if (SrcExpr.isInvalid())

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 0a98cb2a5ce0..d46e7f86d6b3 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8200,9 +8200,13 @@ ExprResult InitializationSequence::Perform(Sema &S,
 if (const auto *ToPtrType = Step->Type->getAs()) {
   if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
   !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
-S.Diag(CurInit.get()->getExprLoc(),
-   diag::warn_noderef_to_dereferenceable_pointer)
-<< CurInit.get()->getSourceRange();
+// Do not check static casts here because they are checked earlier
+// in Sema::ActOnCXXNamedCast()
+if (!Kind.isStaticCast()) {
+  S.Diag(CurInit.get()->getExprLoc(),
+ diag::warn_noderef_to_dereferenceable_pointer)
+  << CurInit.get()->getSourceRange();
+}
   }
 }
   }

diff  --git a/clang/test/Frontend/noderef.cpp b/clang/test/Frontend/noderef.cpp
index 15eb4e457c20..32d5ca34d1b1 100644
--- a/clang/test/Frontend/noderef.cpp
+++ b/clang/test/Frontend/noderef.cpp
@@ -80,12 +80,28 @@ class A {
   int member;
 

[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6451
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<

`InGroup`



Comment at: clang/lib/Sema/SemaExpr.cpp:11571
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers

pestctrl wrote:
> efriedma wrote:
> > rsmith wrote:
> > > pestctrl wrote:
> > > > efriedma wrote:
> > > > > I think this condition is backwards?  Should be `!getLangOpts().C11`. 
> > > > >  You want the warning with `-std=c99 -pedantic`, you don't want the 
> > > > > warning with `std=c11 -pedantic`.
> > > > I don't think it's backwards. If getLangOpts().C11, then it is an 
> > > > extension. Otherwise, it is the warning. I can switch the conditions if 
> > > > it is confusing though.
> > > "Extension" means "this is invalid code that we're accepting anyway" -- 
> > > that's what this is in C99. In C11, I think we shouldn't be diagnosing at 
> > > all.
> > > 
> > > Has anyone checked whether WG14 removed this restriction in C11 as a DR 
> > > resolution? If so, we shouldn't be diagnosing it at all, in any language 
> > > mode.
> > I tracked down the proposal for the change; it's 
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1439.pdf .  Beyond the 
> > reference to http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_314.htm , I 
> > can't find any relevant defect report.
> I have updated the diff to diagnose only for C99. Does the existence of the 
> proposal mean we shouldn't be diagnosing in any language mode?
> 
> Also, how did you track down the proposal that quickly? Even after skimming 
> through it, I still can't find it through searching. 
> Also, how did you track down the proposal that quickly? 

It wasn't really that quick, but the thing that eventually worked was that I 
googled for `site:open-std.org "At various points within a translation unit"`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79945/new/

https://reviews.llvm.org/D79945



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Driver/CC1Options.td:216-221
 def mrelocation_model : Separate<["-"], "mrelocation-model">,
-  HelpText<"The relocation model to use">, 
Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">;
+  HelpText<"The relocation model to use">, 
Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">,
+  MarshallingInfoString<"CodeGenOpts.RelocationModel", "llvm::Reloc::PIC_">,
+  Normalizer<"normalizeRelocationModel">, 
Denormalizer<"denormalizeRelocationModel">,
+  ValuesAssociatedDefinitions<["llvm::Reloc::Static", "llvm::Reloc::PIC_", 
"llvm::Reloc::ROPI",
+  "llvm::Reloc::RWPI", "llvm::Reloc::ROPI_RWPI", "llvm::Reloc::DynamicNoPIC"]>;

Maybe you can avoid boilerplate with something like this:
```
ValuesAssociatedDefinitionsScope<"llvm::Reloc">,
ValuesAssociatedDefinitions<["Static", "PIC_", "RPOI", "RWPI", "ROPI_RWPI", 
"DynamicNoPIC"]>,
MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_">,
```
Note that I shortened the second argument to `MarshallingInfoString` as well.

@Bigcheese, WDYT?

Also wondering if `ValuesAssociatedDefinitions` could be shorter. Maybe 
`NormalizedValues` (and then `NormalizedValuesScope`)?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:125-127
+static std::string normalizeTriple(const Arg *Arg, const ArgList &ArgList,
+   DiagnosticsEngine &Diags,
+   StringRef DefaultTriple) {

Should we drop parameter names for `ArgList`, `Diags`, and `DefaultTriple`?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:150-158
+static const char *denormalizeRelocationModel(llvm::Reloc::Model RM) {
+  switch (RM) {
+#define HANDLE_MRELOCATION_MODEL_VALUES(V, D)  
\
+  case D:  
\
+return V;
+#include "clang/Driver/Options.inc"
+#undef HANDLE_MRELOCATION_MODEL_VALUES

This looks like boilerplate that's going to be repeated a lot. I'm curious how 
many of the enum options will end up like this.

If more than a few, maybe we can add a `.inc` file that includes these function 
definitions? Triggered by adding:
```
AutoNormalizeEnum<"llvm::Reloc::Model", "RelocationModel">,
```
or something (instead of `Normalizer<>` and `Denormalizer<>`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79796/new/

https://reviews.llvm.org/D79796



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


[PATCH] D81427: [hip] Fix device-only relocatable code compilation.

2020-06-10 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D81427#2085739 , @thakis wrote:

> This doesn't pass tests: http://45.33.8.238/linux/19977/step_7.txt
>
> Please take a look, and please revert for now if fixing takes a while.


Fixed in 
https://github.com/llvm/llvm-project/commit/6dd058083208d58c6a7005bfb092cee085fd9a48


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81427/new/

https://reviews.llvm.org/D81427



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


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: rjmccall.
Anastasia added a comment.

In D80932#2083185 , @bader wrote:

> In D80932#2080631 , @Anastasia wrote:
>
> > > @Anastasia, if we make this change specific to SYCL mode, will it address 
> > > your concerns?
> >
> > I can't answer this question for the reasons I have explained above.
>
>
> Sorry, I'm not sure that I get your concern correctly, so let me clarify: is 
> it allowing conversion between pointers w/ and w/o address space annotation 
> in non-SYCL mode or using OpenCL address space attributes in SYCL mode?
>
> Just to help you to understand the proposed design, I created the full patch 
> for address space handling in SYCL: https://github.com/bader/llvm/pull/18. 
> There are few CodeGen tests validating LLVM IR for SPIR target. Fee free to 
> ask any questions on this PR.


Thanks! This is good but it is only an implementation of the design. Deducing 
the design from an implementation is time-consuming and not sure it is even 
feasible. I don't want to waste our time to provide you detailed feedback based 
on my interpretation of your design and invalid assumptions. I don't want to 
bind you to any particular format and we don't have any strict requirement for 
this in LLVM either, but I would encourage you to take a look at some of RFC 
threads sent to cfe-dev that explain new design concepts. Perhaps, they can 
help you to understand what information can be provided as a starting point to 
new design discussions.

Particularly I would suggest covering these two points:

- SYCL specifies address spaces as classes and it is not very obvious how did 
you come from libraries classes to modifications in Clang? I believe there are 
a number of design choices that you could make. One might think that you can 
just implement address space classes using existing Clang functionality. But if 
it is not sufficient it is important to understand what modifications are 
required and why.

- Other aspects that are important to highlight whether your design has any 
limitations. For example, I don't quite understand your need for 
`SPIR*SYCLDeviceTargetInfo`. Is there anything in your design that limits 
compilation to one particular target?

Overall, I see that there are a lot of changes in CodeGen that are related to 
the language semantic. I believe that CodeGen is supposed to be dialing 
primarily with target-specific logic and I don't know if you should change them 
to query target specific details instead. Also most of your CodeGen changes are 
not related to OpenCL so I would make sure to loop @rjmccall in this thread.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80932/new/

https://reviews.llvm.org/D80932



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a subscriber: debug-info.
probinson added a comment.

+debug-info tag

Needs a Driver test to show that the Right Thing gets passed to cc1.




Comment at: clang/docs/CommandGuide/clang.rst:438
+
+  By default, Clang does not emit type information for types that are declared
+  but not used in a program. To retain the debug info for these unused types,

The change to the command-line reference says "defined" not "declared", these 
should be consistent.



Comment at: clang/docs/UsersManual.rst:2319
+
+  By default, Clang does not emit type information for types that are declared
+  but not used in a program. To retain the debug info for these unused types,

"declared" vs "defined" again.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5149
+  Args.AddLastArg(CmdArgs, options::OPT_feliminate_unused_debug_types);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_eliminate_unused_debug_types);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);

Looks like this makes the "no" option take precedence, even if it comes before 
"yes" option.  Should check for both in one call, so you really do take the 
last one:
```
Args.AddLastArg(CmdArgs, options::OPT_feliminate_unused_debug_types, 
options::OPT_fno_eliminate_unused_debug_types);
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80242/new/

https://reviews.llvm.org/D80242



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


[clang] 6dd0580 - [hip] Fix the failed test case due to the additional backend phase.

2020-06-10 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-10T15:06:06-04:00
New Revision: 6dd058083208d58c6a7005bfb092cee085fd9a48

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

LOG: [hip] Fix the failed test case due to the additional backend phase.

Added: 


Modified: 
clang/test/Driver/cuda-phases.cu

Removed: 




diff  --git a/clang/test/Driver/cuda-phases.cu 
b/clang/test/Driver/cuda-phases.cu
index 58be50ae2e12..acbf345f85c6 100644
--- a/clang/test/Driver/cuda-phases.cu
+++ b/clang/test/Driver/cuda-phases.cu
@@ -49,9 +49,10 @@
 // BIN_AMD_NRDC-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, 
(host-[[T]])
 // BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
 // BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
-// BIN_AMD_RDC-DAG: [[P15:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], 
[[ARCH]])
-// BIN_AMD_RDC-DAG: [[P16:[0-9]+]]: offload, "host-[[T]] 
(powerpc64le-ibm-linux-gnu)" {[[P14]]},
-// BIN_AMD_RDC-DAG-SAME:  "device-[[T]] 
([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P15]]}, object
+// BIN_AMD_RDC-DAG: [[P15:[0-9]+]]: backend, {[[P5]]}, ir, (device-[[T]], 
[[ARCH]])
+// BIN_AMD_RDC-DAG: [[P16:[0-9]+]]: linker, {[[P15]]}, image, (device-[[T]], 
[[ARCH]])
+// BIN_AMD_RDC-DAG: [[P17:[0-9]+]]: offload, "host-[[T]] 
(powerpc64le-ibm-linux-gnu)" {[[P14]]},
+// BIN_AMD_RDC-DAG-SAME:  "device-[[T]] 
([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P16]]}, object
 
 //
 // Test single gpu architecture up to the assemble phase.
@@ -109,11 +110,13 @@
 // BIN2_AMD-DAG: [[P19:[0-9]+]]: backend, {[[P2]]}, assembler, (host-[[T]])
 // BIN2-DAG: [[P20:[0-9]+]]: assembler, {[[P19]]}, object, (host-[[T]])
 // BIN2-DAG: [[P21:[0-9]+]]: linker, {[[P20]]}, image, (host-[[T]])
-// BIN2_AMD-DAG: [[P22:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], 
[[ARCH1]])
-// BIN2_AMD-DAG: [[P23:[0-9]+]]: linker, {[[P12]]}, image, (device-[[T]], 
[[ARCH2]])
-// BIN2_AMD-DAG: [[P24:[0-9]+]]: offload, "host-[[T]] 
(powerpc64le-ibm-linux-gnu)" {[[P21]]},
-// BIN2_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH1]])" 
{[[P22]]},
-// BIN2_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH2]])" 
{[[P23]]}, object
+// BIN2_AMD-DAG: [[P22:[0-9]+]]: backend, {[[P5]]}, ir, (device-[[T]], 
[[ARCH1]])
+// BIN2_AMD-DAG: [[P23:[0-9]+]]: backend, {[[P12]]}, ir, (device-[[T]], 
[[ARCH2]])
+// BIN2_AMD-DAG: [[P24:[0-9]+]]: linker, {[[P22]]}, image, (device-[[T]], 
[[ARCH1]])
+// BIN2_AMD-DAG: [[P25:[0-9]+]]: linker, {[[P23]]}, image, (device-[[T]], 
[[ARCH2]])
+// BIN2_AMD-DAG: [[P26:[0-9]+]]: offload, "host-[[T]] 
(powerpc64le-ibm-linux-gnu)" {[[P21]]},
+// BIN2_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH1]])" 
{[[P24]]},
+// BIN2_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH2]])" 
{[[P25]]}, object
 
 //
 // Test two gpu architecturess up to the assemble phase.



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


[PATCH] D81098: [OpenMP] Upgrade default version of OpenMP to 5.0

2020-06-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D81098#2085786 , @saiislam wrote:

> [Work in progress] Requesting early comments. 28 tests are still failing.


Looks good in general


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81098/new/

https://reviews.llvm.org/D81098



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


[PATCH] D81427: [hip] Fix device-only relocatable code compilation.

2020-06-10 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D81427#2085739 , @thakis wrote:

> This doesn't pass tests: http://45.33.8.238/linux/19977/step_7.txt
>
> Please take a look, and please revert for now if fixing takes a while.


Thanks. I am building with PowerPC enabled to reproduce this issue. There 
should be a minor fix on that test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81427/new/

https://reviews.llvm.org/D81427



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-10 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 269926.
dang added a comment.

This address a bunch of existing feedback and makes the TableGen definitions of 
the additional information significantly nicer to write.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79796/new/

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -9,6 +9,7 @@
 #include "OptEmitter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
@@ -33,6 +34,40 @@
   return OS;
 }
 
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsBit("IsPositive");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsString("Normalizer");
+  OS << ", ";
+  OS << R.getValueAsString("Denormalizer");
+}
+
+static void emitValueTable(raw_ostream &OS, StringRef OptionID,
+   StringRef Values,
+   std::vector AssociatedDefinitions) {
+  SmallVector SplitValues;
+  Values.split(SplitValues, ',');
+  assert(SplitValues.size() == AssociatedDefinitions.size() &&
+ "The number of associated definitions doesn't match the number of "
+ "values");
+
+  SmallString<64> MacroName("HANDLE_");
+  MacroName += OptionID.upper();
+  MacroName += "_VALUES";
+  OS << "#ifdef " << MacroName << "\n";
+  for (unsigned I = 0, E = SplitValues.size(); I != E; ++I)
+OS << MacroName << "(\"" << SplitValues[I] << "\","
+   << AssociatedDefinitions[I] << ")\n";
+  OS << "#endif\n";
+}
+
+struct MarshallingKindInfo {
+  const char *MacroName;
+  void (*Emit)(raw_ostream &OS, const Record &R);
+};
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +170,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -223,11 +254,56 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
 
+  std::vector OptsWithMarshalling;
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
+
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
+if (!isa(R.getValueInit("MarshallingKind")))
+  OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
 
+  for (unsigned I = 0, E = OptsWithMarshalling.size(); I != E; ++I) {
+const Record &R = *OptsWithMarshalling[I];
+assert(!isa(R.getValueInit("KeyPath")) &&
+   !isa(R.getValueInit("DefaultValue")) &&
+   "Must provide at least a key-path and a default value for emitting "
+   "marshalling information");
+StringRef KindStr = R.getValueAsString("MarshallingKind");
+auto KindInfo = StringSwitch(KindStr)
+.Case("flag", {"OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag})
+.Case("string", {"OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString})
+.Default({"", nullptr});
+OS << "#ifdef " << KindInfo.MacroName << "\n";
+OS << KindInfo.MacroName << "(";
+WriteOptRecordFields(OS, R);
+OS << ", ";
+OS << R.getValueAsBit("ShouldAlwaysEmit");
+OS << ", ";
+OS << R.getValueAsString("KeyPath");
+OS << ", ";
+OS << R.getValueAsString("DefaultValue");
+OS << ",";
+KindInfo.Emit(OS, R);
+OS << ")\n";
+OS << "#endif\n";
+
+if (!isa(R.getValueInit("ValuesAssociatedDefinitions"))) {
+  assert(!isa(R.getValueInit("Values")) &&
+ "Cannot provide associated definitions for value-less options");
+  emitValueTable(OS, getOptionName(R), R.getValueAsString("Values"),
+ R.getValueAsListOfStrings("ValuesAssociatedDefinitions"));
+ 

[PATCH] D81427: [hip] Fix device-only relocatable code compilation.

2020-06-10 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b6821a5843b: [hip] Fix device-only relocatable code 
compilation. (authored by hliao).

Changed prior to commit:
  https://reviews.llvm.org/D81427?vs=269555&id=269928#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81427/new/

https://reviews.llvm.org/D81427

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-rdc-device-only.hip

Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- /dev/null
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -0,0 +1,144 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
+// With `-emit-llvm`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-emit-llvm`.
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
+
+// With `-emit-llvm`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-emit-llvm`.
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -S -emit-llvm -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITLL %s
+
+// With `-save-temps`, commane lines for each steps are dumped. For assembly
+// output, there should 3 steps (preprocessor, compile, and backend) per source
+// and per target, totally 12 steps.
+
+// RUN: %clang -### -save-temps -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefix=SAVETEMP %s
+
+// COMMON: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// EMITBC-SAME: "-emit-llvm-bc"
+// EMITLL-SAME: "-emit-llvm"
+// COMMON-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
+// COMMON-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// COMMON-SAME: "-fapply-global-visibility-to-externs"
+// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// CHECK-SAME: {{.*}} {{".*a.cu"}}
+
+// COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// EMITBC-SAME: "-emit-llvm-bc"
+// EMITLL-SAME: "-emit-llvm"
+// COMMON-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
+// COMMON-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// COMMON-SAME: "-fapply-global-visibility-to-externs"
+// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// COMMON-SAME: {{.*}} {{".*a.cu"}}
+
+// COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// EMITBC-SAME: "-emit-llvm-bc"
+// EMITLL-SAME: "-emit-llvm"
+// COMMON-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
+// COMMON-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// COMMON-SAME: "-fapply-global-visibility-to-externs"
+// EMITBC-SAME: {{.*}} "-o" {{"b.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{"b.*ll"}} "-x" "hip"
+// COMMON-SAME: {{.*}} {{".*b.hip"}}
+
+// COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// EMITBC-SAME: "-emit-llvm-bc"
+// EMITLL-SAME: "-emit-llvm"
+// COMMON-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
+// COMMON-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functio

[PATCH] D80917: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-10 Thread Saiyedul Islam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4022bc2a6c5e: [OpenMP][AMDGCN] Support OpenMP offloading for 
AMDGCN architecture - Part 2 (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80917/new/

https://reviews.llvm.org/D80917

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- /dev/null
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -0,0 +1,131 @@
+//--- OMPGridValues.h - Language-specific address spaces --*- C++ -*-//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief Provides definitions for Target specific Grid Values
+///
+//===--===//
+
+#ifndef LLVM_OPENMP_GRIDVALUES_H
+#define LLVM_OPENMP_GRIDVALUES_H
+
+namespace llvm {
+
+namespace omp {
+
+/// \brief Defines various target-specific GPU grid values that must be
+///consistent between host RTL (plugin), device RTL, and clang.
+///We can change grid values for a "fat" binary so that different
+///passes get the correct values when generating code for a
+///multi-target binary. Both amdgcn and nvptx values are stored in
+///this file. In the future, should there be differences between GPUs
+///of the same architecture, then simply make a different array and
+///use the new array name.
+///
+/// Example usage in clang:
+///   const unsigned slot_size = ctx.GetTargetInfo().getGridValue(GV_Warp_Size);
+///
+/// Example usage in libomptarget/deviceRTLs:
+///   #include "OMPGridValues.h"
+///   #ifdef __AMDGPU__
+/// #define GRIDVAL AMDGPUGpuGridValues
+///   #else
+/// #define GRIDVAL NVPTXGpuGridValues
+///   #endif
+///   ... Then use this reference for GV_Warp_Size in the deviceRTL source.
+///   GRIDVAL[GV_Warp_Size]
+///
+/// Example usage in libomptarget hsa plugin:
+///   #include "OMPGridValues.h"
+///   #define GRIDVAL AMDGPUGpuGridValues
+///   ... Then use this reference to access GV_Warp_Size in the hsa plugin.
+///   GRIDVAL[GV_Warp_Size]
+///
+/// Example usage in libomptarget cuda plugin:
+///#include "OMPGridValues.h"
+///#define GRIDVAL NVPTXGpuGridValues
+///   ... Then use this reference to access GV_Warp_Size in the cuda plugin.
+///GRIDVAL[GV_Warp_Size]
+///
+enum GVIDX {
+  /// The maximum number of workers in a kernel.
+  /// (THREAD_ABSOLUTE_LIMIT) - (GV_Warp_Size), might be issue for blockDim.z
+  GV_Threads,
+  /// The size reserved for data in a shared memory slot.
+  GV_Slot_Size,
+  /// The default value of maximum number of threads in a worker warp.
+  GV_Warp_Size,
+  /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
+  /// for NVPTX.
+  GV_Warp_Size_32,
+  /// The number of bits required to represent the max number of threads in warp
+  GV_Warp_Size_Log2,
+  /// GV_Warp_Size * GV_Slot_Size,
+  GV_Warp_Slot_Size,
+  /// the maximum number of teams.
+  GV_Max_Teams,
+  /// Global Memory Alignment
+  GV_Mem_Align,
+  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
+  GV_Warp_Size_Log2_Mask,
+  // An alternative to the heavy data sharing infrastructure that uses global
+  // memory is one that uses device __shared__ memory.  The amount of such space
+  // (in bytes) reserved by the OpenMP runtime is noted here.
+  GV_SimpleBufferSize,
+  // The absolute maximum team size for a working group
+  GV_Max_WG_Size,
+  // The default maximum team size for a working group
+  GV_Default_WG_Size,
+  // This is GV_Max_WG_Size / GV_WarpSize. 32 for NVPTX and 16 for AMDGCN.
+  GV_Max_Warp_Number,
+  /// The slot size that should be reserved for a working warp.
+  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
+  GV_Warp_Size_Log2_MaskL
+};
+
+/// For AMDGPU GPUs
+static constexpr unsigned AMDGPUGpuGridValues[] = {
+448,   // GV_Threads
+256,   // GV_Slot_Size
+64,// GV_Warp_Size
+32,// GV_Warp_Size_32
+6, // GV_Warp_Size_Log2
+64 * 256,  // GV_Warp_Slot_Size
+128,   // GV_Max_Teams
+256,   // GV_Mem_Align
+63,// GV_Warp_Size_Log2_Mask
+896,   // GV_SimpleBufferSize
+1024,  // GV_Max_WG_Size,
+256,   // GV_Defaut_WG_Size
+1024 / 64, // GV_Max_WG_Size / GV_WarpSize
+63 // GV_Warp_Size_Log2_MaskL
+};
+
+/// For Nvidia GPUs
+static constexpr unsigned NVPTXGpuGridValues[] = {
+992,   // GV_Threads
+256,   

[PATCH] D63852: [Clang] Move assembler into a separate file

2020-06-10 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

@echristo any chance you could take a look at this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63852/new/

https://reviews.llvm.org/D63852



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


[PATCH] D81567: [analyzer] SATest: Introduce a single entrypoint for regression scripts

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D81567#2085622 , @Szelethus wrote:

> I failed to follow much of this project so my question may be dumb -- but 
> have you considered other run comparing tools such as csa-testbench 
> (https://github.com/Xazax-hun/csa-testbench) and CodeChecker?


Hi, no you didn't miss anything.  I am getting ready ("Eye of the Tiger" starts 
playing) to address this topic in the mailing list, so I kept you all under 
informed.  These commits is my attempt in making existing scripts that already 
live in the repo more usable and prettier.

In short, this whole so-to-speak //project// is about creating a testing system 
that will for sure produce exactly the same results on any machine.  The trick 
is in using `docker` to run the analyzer and have all the dependencies 
pre-installed there.
On `csa-testbench` and `CodeChecker`, unfortunately not all of the CSA 
developers use `CodeChecker`, and shouldn't be forced to do that for testing.

I will send an email tomorrow and I hope it would make sense :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81567/new/

https://reviews.llvm.org/D81567



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


[PATCH] D81427: [hip] Fix device-only relocatable code compilation.

2020-06-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This doesn't pass tests: http://45.33.8.238/linux/19977/step_7.txt

Please take a look, and please revert for now if fixing takes a while.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81427/new/

https://reviews.llvm.org/D81427



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


[PATCH] D81530: [clangd] Log rather than assert on bad UTF-8.

2020-06-10 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

I can confirm that this commit works equally well for the UTF-8 assertion 
failure. Thank you!

Is there some way to easily modify the source to produce a diagnostic pointing 
to the issue's source location? I would like to file an appropriate bug in 
Boost.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81530/new/

https://reviews.llvm.org/D81530



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


[PATCH] D81045: [LLVM] Change isa<> to a variadic function template

2020-06-10 Thread River Riddle via Phabricator via cfe-commits
rriddle accepted this revision.
rriddle marked an inline comment as done.
rriddle added a comment.
This revision is now accepted and ready to land.

I have run into the desire to have this on many occasions, so LGTM for me.




Comment at: clang/include/clang/AST/DeclBase.h:521
 AttrVec &Vec = getAttrs();
-Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa), 
Vec.end());
+Vec.erase(std::remove_if(Vec.begin(), Vec.end(),
+ [](Attr *A) { return isa(A); }),

nit: We could also update this to use `llvm::erase_if`, but fine to leave as is.



Comment at: llvm/include/llvm/Support/Casting.h:147
+template 
+LLVM_NODISCARD inline typename std::enable_if::type
+isa(const Y &Val) {

nit: I would remove the enable_if and just add an additional type to the 
template.

```
template
... isa(const Y &val) {
  return isa(Val) || isa(Val);
}
```



Comment at: llvm/include/llvm/Support/Casting.h:136
+// isa - Return true if the parameter to the template is an instance of one
+// of the template type argument.  Used like this:
 //

nit: arguments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81045/new/

https://reviews.llvm.org/D81045



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked an inline comment as done.
pratlucas added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:524
+  CallConv))
+return;
   EVT ValueVT = Val.getValueType();

efriedma wrote:
> I'm not sure I understand why the standard getCopyFromParts/getCopyToParts 
> codepath doesn't work. Is the issue that it uses FP_ROUND/FP_EXTEND to 
> promote from f16 to f32?
Yes, the issue is the usage of FP_ROUND/FP_EXTEND indeed. Those cause the 
argument to be converted from f16 into f32 - with a `vcvtb.f16.f32` for 
instance - instead of simply being placed the value in the LSBs as required by 
the AAPCS.



Comment at: llvm/lib/Target/ARM/ARMCallingConv.cpp:296
+
+static bool CC_ARM_AAPCS_Custom_f16(unsigned ValNo, MVT ValVT, MVT LocVT,
+CCValAssign::LocInfo LocInfo,

efriedma wrote:
> It isn't obvious to me why you need this; can you not use 
> CCBitConvertToType/CCAssignToReg?
For hard floats, using CCAssingToReg would indeed work well in the majority of 
the scenarios, but would get in the way of the CMSE handling from D81428. Using 
the f16 loc type causes the clearing of the top 16 bits to be optimized out in 
the DAG.
Also, the AAPCS expects the argument sized to be extended to 4 bytes, so using 
the f32 loc type attends to that rule.

For soft floats, on the other hand, simply convering it to i32 causes the code 
on ARMISel lowering to be quite cumbersome. The loc info becomes either 
`CCValAssign::BCvt` (f16 -> f32 - >i32) or `CCValAssign::AExt` ( f16 -> i16 -> 
i32), so checking for when we need to handle things differently for f16 becomes 
less clear.
Using this flow we have the `isCustom` flag assigned and can have a more 
explicit handling of this.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75169/new/

https://reviews.llvm.org/D75169



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 269915.
pratlucas marked 2 inline comments as done.
pratlucas added a comment.

Clean-ups + fixing failure in CodeGen/ARM/half.ll test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75169/new/

https://reviews.llvm.org/D75169

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/ARM/ARMCallingConv.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/test/CodeGen/ARM/fp16-args.ll
  llvm/test/CodeGen/ARM/fp16-bitcast.ll
  llvm/test/CodeGen/ARM/fp16-promote.ll
  llvm/test/CodeGen/ARM/fp16-vminmaxnm-safe.ll
  llvm/test/CodeGen/ARM/vecreduce-fadd-legalization-strict.ll
  llvm/test/CodeGen/ARM/vecreduce-fmul-legalization-strict.ll
  llvm/test/CodeGen/Thumb2/mve-shuffle.ll
  llvm/test/CodeGen/Thumb2/mve-vdup.ll
  llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll

Index: llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
===
--- llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
+++ llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
@@ -78,7 +78,6 @@
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 ; CHECK-NEXT:.p2align 1
 ; CHECK-NEXT:  @ %bb.1:
@@ -103,7 +102,6 @@
 ; CHECK-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -125,7 +123,6 @@
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-FP-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v16f16:
@@ -169,7 +166,6 @@
 ; CHECK-NOFP-NEXT:vminnm.f16 s8, s8, s10
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s4
 ; CHECK-NOFP-NEXT:vminnm.f16 s0, s8, s0
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v16f16(<16 x half> %x)
@@ -309,20 +305,20 @@
 define arm_aapcs_vfpcc half @fmin_v4f16_nofast(<4 x half> %x) {
 ; CHECK-FP-LABEL: fmin_v4f16_nofast:
 ; CHECK-FP:   @ %bb.0: @ %entry
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v4f16_nofast:
 ; CHECK-NOFP:   @ %bb.0: @ %entry
-; CHECK-NOFP-NEXT:vmov r1, s1
+; CHECK-NOFP-NEXT:vmov r0, s1
 ; CHECK-NOFP-NEXT:vmovx.f16 s10, s0
-; CHECK-NOFP-NEXT:vdup.32 q1, r1
+; CHECK-NOFP-NEXT:vdup.32 q1, r0
 ; CHECK-NOFP-NEXT:vmovx.f16 s8, s4
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s10
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
@@ -333,7 +329,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v4f16(<4 x half> %x)
@@ -346,13 +341,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v8f16_nofast:
@@ -384,7 +379,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -398,13 +392,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.

[clang] 52cae05 - [ASan][Test] Fix expected strings for globals test

2020-06-10 Thread Marco Elver via cfe-commits

Author: Marco Elver
Date: 2020-06-10T20:26:24+02:00
New Revision: 52cae05e087b3d4fd02849fc37c387c720055ffb

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

LOG: [ASan][Test] Fix expected strings for globals test

The expected strings would previously not catch bugs when redzones were
added when they were not actually expected. Fix by adding "global "
before the type.

Added: 


Modified: 
clang/test/CodeGen/asan-globals-alias.cpp
clang/test/CodeGen/asan-globals.cpp

Removed: 




diff  --git a/clang/test/CodeGen/asan-globals-alias.cpp 
b/clang/test/CodeGen/asan-globals-alias.cpp
index 1b6d4183261c..faf160ac79c9 100644
--- a/clang/test/CodeGen/asan-globals-alias.cpp
+++ b/clang/test/CodeGen/asan-globals-alias.cpp
@@ -7,8 +7,8 @@ int global; 
// to genera
 int aliased_global; // KASAN - 
ignore globals prefixed by aliases with __-prefix (below)
 extern int __attribute__((alias("aliased_global"))) __global_alias; // KASAN - 
aliased_global ignored
 
-// ASAN: @aliased_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
-// KASAN: @aliased_global{{.*}}i32
+// ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// KASAN: @aliased_global{{.*}} global i32
 
 // CHECK-LABEL: define internal void @asan.module_ctor
 // ASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 2)

diff  --git a/clang/test/CodeGen/asan-globals.cpp 
b/clang/test/CodeGen/asan-globals.cpp
index 76373f59e424..cb6f2174c6a5 100644
--- a/clang/test/CodeGen/asan-globals.cpp
+++ b/clang/test/CodeGen/asan-globals.cpp
@@ -22,10 +22,10 @@ void func() {
   const char *literal = "Hello, world!";
 }
 
-// ASAN: sectioned_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
-// KASAN: sectioned_global{{.*}}i32
-// ASAN: @__special_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
-// KASAN: @__special_global{{.*}}i32
+// ASAN: sectioned_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// KASAN: sectioned_global{{.*}} global i32
+// ASAN: @__special_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// KASAN: @__special_global{{.*}} global i32
 
 // CHECK-LABEL: define internal void @asan.module_ctor
 // ASAN-NEXT: call void @__asan_init



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


[clang] 8b6821a - [hip] Fix device-only relocatable code compilation.

2020-06-10 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-10T14:10:41-04:00
New Revision: 8b6821a5843bb321b3738e2519beae7142e62928

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

LOG: [hip] Fix device-only relocatable code compilation.

Summary:
- In HIP, just as the regular device-only compilation, the device-only
  relocatable code compilation should not involve offload bundle.
- In addition, that device-only relocatable code compilation should have
  the similar 3 steps, namely preprocessor, compile, and backend, to the
  regular code generation with `-emit-llvm`.

Reviewers: yaxunl, tra

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/hip-rdc-device-only.hip

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8cc5eceaa512..19faf0968e08 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2705,9 +2705,7 @@ class OffloadingActionBuilder final {
   // backend and assemble phases to output LLVM IR. Except for generating
   // non-relocatable device coee, where we generate fat binary for device
   // code and pass to host in Backend phase.
-  if (CudaDeviceActions.empty() ||
-  (CurPhase == phases::Backend && Relocatable) ||
-  CurPhase == phases::Assemble)
+  if (CudaDeviceActions.empty())
 return ABRT_Success;
 
   assert(((CurPhase == phases::Link && Relocatable) ||
@@ -2781,9 +2779,11 @@ class OffloadingActionBuilder final {
   }
 
   // By default, we produce an action for each device arch.
-  for (Action *&A : CudaDeviceActions)
-A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
-   AssociatedOffloadKind);
+  if (!Relocatable || CurPhase <= phases::Backend) {
+for (Action *&A : CudaDeviceActions)
+  A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
+ AssociatedOffloadKind);
+  }
 
   return (CompileDeviceOnly && CurPhase == FinalPhase) ? ABRT_Ignore_Host
: ABRT_Success;
@@ -3668,7 +3668,10 @@ Action *Driver::ConstructPhaseAction(
   Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
   return C.MakeAction(Input, Output);
 }
-if (Args.hasArg(options::OPT_emit_llvm)) {
+if (Args.hasArg(options::OPT_emit_llvm) ||
+(TargetDeviceOffloadKind == Action::OFK_HIP &&
+ Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
+  false))) {
   types::ID Output =
   Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
   return C.MakeAction(Input, Output);
@@ -4588,8 +4591,19 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
 // When using both -save-temps and -emit-llvm, use a ".tmp.bc" suffix for
 // the unoptimized bitcode so that it does not get overwritten by the ".bc"
 // optimized bitcode output.
-if (!AtTopLevel && C.getArgs().hasArg(options::OPT_emit_llvm) &&
-JA.getType() == types::TY_LLVM_BC)
+auto IsHIPRDCInCompilePhase = [](const JobAction &JA,
+ const llvm::opt::DerivedArgList &Args) {
+  // The relocatable compilation in HIP implies -emit-llvm. Similarly, use 
a
+  // ".tmp.bc" suffix for the unoptimized bitcode (generated in the compile
+  // phase.)
+  return isa(JA) &&
+ JA.getOffloadingDeviceKind() == Action::OFK_HIP &&
+ Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
+  false);
+};
+if (!AtTopLevel && JA.getType() == types::TY_LLVM_BC &&
+(C.getArgs().hasArg(options::OPT_emit_llvm) ||
+ IsHIPRDCInCompilePhase(JA, C.getArgs(
   Suffixed += ".tmp";
 Suffixed += '.';
 Suffixed += Suffix;

diff  --git a/clang/test/Driver/hip-rdc-device-only.hip 
b/clang/test/Driver/hip-rdc-device-only.hip
new file mode 100644
index ..4bdff628466a
--- /dev/null
+++ b/clang/test/Driver/hip-rdc-device-only.hip
@@ -0,0 +1,144 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
+// With `-emit-llvm`, the output should be the same as the aforementioned li

[clang] 4022bc2 - [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-10 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2020-06-10T18:09:59Z
New Revision: 4022bc2a6c5e585d99a76b1b2f14c2986b823ce9

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

LOG: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

Summary:
New file include to support platform dependent grid constants. It will be
used by clang, libomptarget plugins, and deviceRTLs to access constant
values consistently and with fast access in the deviceRTLs.

Originally authored by Greg Rodgers (@gregrodgers).

Reviewers: arsenm, sameerds, jdoerfert, yaxunl, b-sumner, scchan, 
JonChesterfield

Reviewed By: arsenm

Subscribers: llvm-commits, pdhaliwal, jholewinski, jvesely, wdng, nhaehnle, 
guansong, kerbowa, sstefan1, cfe-commits, ronlieb, gregrodgers

Tags: #clang, #llvm

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

Added: 
llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 4a7257d1b426..b1a4017b4c76 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Specifiers.h"
@@ -29,6 +30,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/VersionTuple.h"
 #include 
@@ -198,6 +200,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   unsigned char RegParmMax, SSERegParmMax;
   TargetCXXABI TheCXXABI;
   const LangASMap *AddrSpaceMap;
+  const unsigned *GridValues =
+  nullptr; // Array of target-specific GPU grid values that must be
+   // consistent between host RTL (plugin), device RTL, and clang.
 
   mutable StringRef PlatformName;
   mutable VersionTuple PlatformMinVersion;
@@ -1321,6 +1326,12 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 return LangAS::Default;
   }
 
+  /// Return a target-specific GPU grid value based on the GVIDX enum \param gv
+  unsigned getGridValue(llvm::omp::GVIDX gv) const {
+assert(GridValues != nullptr && "GridValues not initialized");
+return GridValues[gv];
+  }
+
   /// Retrieve the name of the platform as it is used in the
   /// availability attribute.
   StringRef getPlatformName() const { return PlatformName; }

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index b9d7640a10b8..8017b9ee402f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/DataLayout.h"
 
 using namespace clang;
@@ -286,6 +287,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
 : DataLayoutStringR600);
   assert(DataLayout->getAllocaAddrSpace() == Private);
+  GridValues = llvm::omp::AMDGPUGpuGridValues;
 
   setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
  !isAMDGCN(Triple));

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 39b07872b142..fda9fad777d4 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -62,6 +63,7 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
   TLSSupported = false;
   VLASupported = false;
   AddrSpaceMap = &NVPTXAddrSpaceMap;
+  GridValues = llvm::omp::NVPTXGpuGridValues;
   UseAddrSpaceMapMangling = true;
 
   // Define available target features

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
new file mode 100644
index ..3ae4a2edbf96
--- /dev/null
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -0,0 +1,131 @@
+//--- OMPGridValues.h - Language-specific address spaces --*- C++ -*-//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed 

[PATCH] D81564: [analyzer] SATest: Add posibility to download source from git and zip

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/utils/analyzer/ProjectMap.py:14
 
+class DownloadType(str, Enum):
+GIT = "git"

xazax.hun wrote:
> I was wondering what is the point of inheriting from `str`. I am not 
> well-versed in Python so it is more of a curiosity.
It helps with direct assignments from strings, cross-comparisons between `Enum` 
values and strings, and most importantly - serialization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81564/new/

https://reviews.llvm.org/D81564



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


cfe-commits@lists.llvm.org

2020-06-10 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: llvm/test/CodeGen/AArch64/aarch64-bf16-ldst-intrinsics.ll:264
+; Function Attrs: argmemonly nounwind readonly
+declare { <8 x bfloat>, <8 x bfloat> } 
@llvm.aarch64.neon.ld2lane.v8bf16.p0i8(<8 x bfloat>, <8 x bfloat>, i64, i8*) #3
+

SjoerdMeijer wrote:
> chill wrote:
> > SjoerdMeijer wrote:
> > > chill wrote:
> > > > LukeGeeson wrote:
> > > > > SjoerdMeijer wrote:
> > > > > > LukeGeeson wrote:
> > > > > > > arsenm wrote:
> > > > > > > > Why is the IR type name bfloat and not bfloat16?
> > > > > > > The naming for the IR type was agreed upon here after quite a big 
> > > > > > > discussion. 
> > > > > > > https://reviews.llvm.org/D78190
> > > > > > I regret very much that I didn't notice this earlier... I.e., I 
> > > > > > noticed this in D76077 and wrote that I am relatively unhappy about 
> > > > > > this (I think I mentioned this on another ticket too).
> > > > > > Because like @arsenm , I would expect the IR type name to be 
> > > > > > bfloat16.
> > > > > > 
> > > > > > Correct me if I am wrong, but I don't see a big discussion about 
> > > > > > this in D78190. I only see 1 or 2 comments about `BFloat` vs 
> > > > > > `Bfloat`.
> > > > > I cannot see a discussion about the IR type name per-se but I can see 
> > > > > you were both involved in the discussion more generally.
> > > > > 
> > > > > I am concerned that this patch is the wrong place to discuss such 
> > > > > issues, and that we should bring this up in a more appropriate place 
> > > > > as you mention so that this patch isn't held back.
> > > > I don't see a compelling reason for the name to be `bfloat16` or 
> > > > `bfloat3`, etc. Like other floating-point types (`float`, `double`, and 
> > > > `half`), the name denotes a specific externally defined format, unlike 
> > > > `iN`.
> > > > Like other floating-point types (float, double, and half), the name 
> > > > denotes a specific externally defined format, 
> > > 
> > > Is the defined format not called bfloat16?
> > Indeed, people use the name "bfloat16". But then the `half`, `float`, and 
> > `double` also differ from the official `binary16`, `binarty32`, and 
> > `binary64`.
> > IMHO `bfloat` fits better in the LLVM IR naming convention.
> yeah, so that's exactly why I don't follow your logic. If there's any logic 
> in the names here, the mapping from source-language type to IR type seems the 
> most plausible one. And I just don't see the benefit of dropping the 16, and 
> how that would fit better in some naming scheme or how that makes things 
> clearer here.
What source language?

That said, I'm resigning from the bikeshedding here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80716/new/

https://reviews.llvm.org/D80716



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


[PATCH] D81591: [ASan][Test] Split out global alias test

2020-06-10 Thread Marco Elver via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f04f104537b: [ASan][Test] Split out global alias test 
(authored by melver).

Changed prior to commit:
  https://reviews.llvm.org/D81591?vs=269898&id=269911#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81591/new/

https://reviews.llvm.org/D81591

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals.cpp


Index: clang/test/CodeGen/asan-globals.cpp
===
--- clang/test/CodeGen/asan-globals.cpp
+++ clang/test/CodeGen/asan-globals.cpp
@@ -12,11 +12,9 @@
 int __attribute__((no_sanitize("address"))) attributed_global;
 int blacklisted_global;
 
-int __attribute__((section("__DATA, __common"))) sectioned_global; // [KASAN] 
ignore globals in a section
+int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - 
ignore globals in a section
 extern "C" {
-int aliased_global; // [KASAN] 
ignore globals prefixed by aliases with __-prefix [below]
-extern int __attribute__((alias("aliased_global"))) __global_alias; // [KASAN] 
aliased_global ignored
-int __special_global;   // [KASAN] 
ignore globals with __-prefix
+int __special_global; // KASAN - ignore globals with __-prefix
 }
 
 void func() {
@@ -26,8 +24,6 @@
 
 // ASAN: sectioned_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
 // KASAN: sectioned_global{{.*}}i32
-// ASAN: @aliased_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
-// KASAN: @aliased_global{{.*}}i32
 // ASAN: @__special_global{{.*}}{ i32, [60 x i8] }{{.*}}align 32
 // KASAN: @__special_global{{.*}}i32
 
@@ -36,7 +32,7 @@
 // ASAN-NEXT: call void @__asan_version_mismatch_check
 // KASAN-NOT: call void @__asan_init
 // KASAN-NOT: call void @__asan_version_mismatch_check
-// ASAN-NEXT: call void @__asan_register_globals({{.*}}, i{{32|64}} 8)
+// ASAN-NEXT: call void @__asan_register_globals({{.*}}, i{{32|64}} 7)
 // KASAN-NEXT: call void @__asan_register_globals({{.*}}, i{{32|64}} 5)
 // CHECK-NEXT: ret void
 
@@ -44,7 +40,7 @@
 // CHECK-NEXT: call void @__asan_unregister_globals
 // CHECK-NEXT: ret void
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], 
![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], 
![[ALIASED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], 
![[LITERAL:[0-9]+]]}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], 
![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], 
![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], 
!"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, 
i1 false}
@@ -55,16 +51,14 @@
 // CHECK: ![[BLACKLISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[SECTIONED_GLOBAL]] = !{{{.*}} ![[SECTIONED_GLOBAL_LOC:[0-9]+]], 
!"sectioned_global", i1 false, i1 false}
 // CHECK: ![[SECTIONED_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 15, i32 
50}
-// CHECK: ![[ALIASED_GLOBAL]] = !{{{.*}} ![[ALIASED_GLOBAL_LOC:[0-9]+]], 
!"aliased_global", i1 false, i1 false}
-// CHECK: ![[ALIASED_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 17, i32 5}
 // CHECK: ![[SPECIAL_GLOBAL]] = !{{{.*}} ![[SPECIAL_GLOBAL_LOC:[0-9]+]], 
!"__special_global", i1 false, i1 false}
-// CHECK: ![[SPECIAL_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 19, i32 5}
+// CHECK: ![[SPECIAL_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 17, i32 5}
 // CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 
false, i1 false}
-// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 23, i32 14}
+// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 21, i32 14}
 // CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"", i1 false, i1 false}
-// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 24, i32 25}
+// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 22, i32 25}
 
-// BLACKLIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], 
![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], 
![[ALIASED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], 
![[LITERAL:[0-9]+]]}
+// BLACKLIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], 
![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], 
![[BLACKLISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], 
![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // BLACKL

[PATCH] D81567: [analyzer] SATest: Introduce a single entrypoint for regression scripts

2020-06-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I failed to follow much of this project so my question may be dumb -- but have 
you considered other run comparing tools such as csa-testbench 
(https://github.com/Xazax-hun/csa-testbench) and CodeChecker?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81567/new/

https://reviews.llvm.org/D81567



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


[PATCH] D81601: [analyzer] SATest: Use logger in single-threaded mode as well

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

It generalizes the way the output looks across any -jN.
Additionally it solves the buffering problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81601

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###
 
+class StreamToLogger:
+def __init__(self, logger: logging.Logger,
+ log_level: int = logging.INFO):
+self.logger = logger
+self.log_level = log_level
+
+def write(self, message: str):
+# Rstrip in order not to write an extra newline.
+self.logger.log(self.log_level, message.rstrip())
+
+def flush(self):
+pass
+
+def fileno(self) -> int:
+return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-def __init__(self, logger: logging.Logger,
- log_level: int = logging.INFO):
-self.logger = logger
-self.log_level = log_level
-
-def write(self, message: str):
-# Rstrip in order not to write an extra newline.
-self.logger.log(self.log_level, message.rstrip())
-
-def flush(self):
-pass
-
-def fileno(self) -> int:
-return 0
-
-
 ###
 # Test harness logic.
 ###


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###
 
+class StreamToLogger:
+def __init__(self, logger: logging.Logger,
+ log_level: int = logging.INFO):
+self.logger = logger
+self.log_level = log_level
+
+def write(self, message: str):
+# Rstrip in order not to write an extra newline.
+self.logger.log(self.log_level, message.rstrip())
+
+def flush(self):
+pass
+
+def fileno(self) -> int:
+return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-def __init__(self, logger: logging.Logger,
- log_level: int = logging.INFO):
-self.logger = logger
-self.log_level = log_level
-
-def write(self, message: str):
-# Rstrip in order not to write an extra newline.
-self.logger.log(self.log_level, message.rstrip())
-
-def flush(self):
-pass
-
-def fileno(self) -> int:
-return 0
-
-
 ###
 # Test harness logic.
 ###
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81600: [analyzer] SATest: Fix package versions for test dependencies

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Another possible difference between various users of the
testing system might be a change in dependencies installed on the
container.  This commit tries to prevent any problem related to
different versions of the libraries/headers used and fixes them to
currently installed versions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81600

Files:
  clang/utils/analyzer/Dockerfile


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -13,34 +13,34 @@
 
 # test system dependencies
 RUN apt-get update && apt-get install -y \
-git \
-gettext \
-python3 \
-python3-pip \
-cmake \
-ninja-build
+git=1:2.17.1-1ubuntu0.7 \
+gettext=0.19.8.1-6ubuntu0.3 \
+python3=3.6.7-1~18.04 \
+python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
+cmake=3.17.3-0kitware1 \
+ninja-build=1.8.2-1
 
 # box2d dependencies
 RUN apt-get install -y \
-libx11-dev \
-libxrandr-dev \
-libxinerama-dev \
-libxcursor-dev \
-libxi-dev
+libx11-dev=2:1.6.4-3ubuntu0.2 \
+libxrandr-dev=2:1.5.1-1 \
+libxinerama-dev=2:1.1.3-1 \
+libxcursor-dev=1:1.1.15-1 \
+libxi-dev=2:1.7.9-1
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10 \
-libgmp-dev
+libgmp10=2:6.1.2+dfsg-2 \
+libgmp-dev=2:6.1.2+dfsg-2
 
 # simbody dependencies
 RUN apt-get install -y \
-liblapack-dev
+liblapack-dev=3.7.1-4ubuntu1
 
 # drogon dependencies
 RUN apt-get install -y \
-libjsonrpccpp-dev \
-uuid-dev
+libjsonrpccpp-dev=0.7.0-1build2 \
+uuid-dev=2.31.1-0.4ubuntu3.6
 
 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
 


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -13,34 +13,34 @@
 
 # test system dependencies
 RUN apt-get update && apt-get install -y \
-git \
-gettext \
-python3 \
-python3-pip \
-cmake \
-ninja-build
+git=1:2.17.1-1ubuntu0.7 \
+gettext=0.19.8.1-6ubuntu0.3 \
+python3=3.6.7-1~18.04 \
+python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
+cmake=3.17.3-0kitware1 \
+ninja-build=1.8.2-1
 
 # box2d dependencies
 RUN apt-get install -y \
-libx11-dev \
-libxrandr-dev \
-libxinerama-dev \
-libxcursor-dev \
-libxi-dev
+libx11-dev=2:1.6.4-3ubuntu0.2 \
+libxrandr-dev=2:1.5.1-1 \
+libxinerama-dev=2:1.1.3-1 \
+libxcursor-dev=1:1.1.15-1 \
+libxi-dev=2:1.7.9-1
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10 \
-libgmp-dev
+libgmp10=2:6.1.2+dfsg-2 \
+libgmp-dev=2:6.1.2+dfsg-2
 
 # simbody dependencies
 RUN apt-get install -y \
-liblapack-dev
+liblapack-dev=3.7.1-4ubuntu1
 
 # drogon dependencies
 RUN apt-get install -y \
-libjsonrpccpp-dev \
-uuid-dev
+libjsonrpccpp-dev=0.7.0-1build2 \
+uuid-dev=2.31.1-0.4ubuntu3.6
 
 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81595: [analyzer] SATest: Make main script Python2 compatible

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

If the user has only python2 installed and wants to use
the dockerized testing system, it is now totally OK.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81595

Files:
  clang/utils/analyzer/SATest.py


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -1,12 +1,5 @@
 #!/usr/bin/env python
 
-import SATestAdd
-import SATestBuild
-import SATestUpdateDiffs
-import CmpRuns
-
-from ProjectMap import ProjectInfo, ProjectMap
-
 import argparse
 import sys
 import os
@@ -22,6 +15,9 @@
 
 
 def add(parser, args):
+import SATestAdd
+from ProjectMap import ProjectInfo
+
 if args.source == "git" and (args.origin == "" or args.commit == ""):
 parser.error(
 "Please provide both --origin and --commit if source is 'git'")
@@ -37,6 +33,9 @@
 
 
 def build(parser, args):
+import SATestBuild
+from ProjectMap import ProjectMap
+
 SATestBuild.VERBOSE = args.verbose
 
 project_map = ProjectMap()
@@ -72,6 +71,16 @@
 
 
 def compare(parser, args):
+import CmpRuns
+
+choices = [CmpRuns.HistogramType.RELATIVE.value,
+   CmpRuns.HistogramType.LOG_RELATIVE.value,
+   CmpRuns.HistogramType.ABSOLUTE.value]
+
+if args.histogram is not None and args.histogram not in choices:
+parser.error("Incorrect histogram type, available choices are {}"
+ .format(choices))
+
 dir_old = CmpRuns.ResultsDirectory(args.old[0], args.root_old)
 dir_new = CmpRuns.ResultsDirectory(args.new[0], args.root_new)
 
@@ -83,6 +92,9 @@
 
 
 def update(parser, args):
+import SATestUpdateDiffs
+from ProjectMap import ProjectMap
+
 project_map = ProjectMap()
 for project in project_map.projects:
 SATestUpdateDiffs.update_reference_results(project)
@@ -145,8 +157,7 @@
 "(please provide --origin and --commit), "
 "'zip' for unpacking source from a zip file, "
 "'script' for downloading source by running "
-"a custom script {}"
-.format(SATestBuild.DOWNLOAD_SCRIPT))
+"a custom script")
 add_parser.add_argument("--origin", action="store", default="",
 help="Origin link for a git repository")
 add_parser.add_argument("--commit", action="store", default="",
@@ -207,9 +218,6 @@
 dest="show_stats", default=False,
 help="Show change in statistics")
 cmp_parser.add_argument("--histogram", action="store", default=None,
-choices=[CmpRuns.HistogramType.RELATIVE.value,
- CmpRuns.HistogramType.LOG_RELATIVE.value,
- CmpRuns.HistogramType.ABSOLUTE.value],
 help="Show histogram of paths differences. "
 "Requires matplotlib")
 cmp_parser.add_argument("old", nargs=1, help="Directory with old results")
@@ -231,6 +239,8 @@
 
 dock_parser.add_argument("--build-image", action="store_true",
  help="Build docker image for running tests.")
+dock_parser.add_argument("--shell", action="store_true",
+ help="Start a shell on docker.")
 dock_parser.add_argument("--llvm-project-dir", action="store",
  default=DEFAULT_LLVM_DIR,
  help="Path to LLVM source code. Defaults "


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -1,12 +1,5 @@
 #!/usr/bin/env python
 
-import SATestAdd
-import SATestBuild
-import SATestUpdateDiffs
-import CmpRuns
-
-from ProjectMap import ProjectInfo, ProjectMap
-
 import argparse
 import sys
 import os
@@ -22,6 +15,9 @@
 
 
 def add(parser, args):
+import SATestAdd
+from ProjectMap import ProjectInfo
+
 if args.source == "git" and (args.origin == "" or args.commit == ""):
 parser.error(
 "Please provide both --origin and --commit if source is 'git'")
@@ -37,6 +33,9 @@
 
 
 def build(parser, args):
+import SATestBuild
+from ProjectMap import ProjectMap
+
 SATestBuild.VERBOSE = args.verbose
 
 project_map = ProjectMap()
@@ -72,6 +71,16 @@
 
 
 def compare(parser, args):
+import CmpRuns
+
+choices = [CmpRuns.HistogramType.RELATIVE.value,
+   CmpRuns.HistogramType.LOG_RELATIVE.value,
+   CmpRuns.HistogramType.ABSOLUTE.va

[PATCH] D81596: [analyzer] SATest: Do not re-run CMake in Docker if not needed

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81596

Files:
  clang/utils/analyzer/entrypoint.py


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -23,16 +23,21 @@
 return parser.parse_known_args()
 
 
-def build_llvm() -> None:
+def build_llvm():
 os.chdir('/build')
 try:
-cmake()
+if is_cmake_needed():
+cmake()
 ninja()
 except CalledProcessError:
 print("Build failed!")
 sys.exit(1)
 
 
+def is_cmake_needed():
+return "build.ninja" not in os.listdir()
+
+
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
 "-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -23,16 +23,21 @@
 return parser.parse_known_args()
 
 
-def build_llvm() -> None:
+def build_llvm():
 os.chdir('/build')
 try:
-cmake()
+if is_cmake_needed():
+cmake()
 ninja()
 except CalledProcessError:
 print("Build failed!")
 sys.exit(1)
 
 
+def is_cmake_needed():
+return "build.ninja" not in os.listdir()
+
+
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
 "-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


cfe-commits@lists.llvm.org

2020-06-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/test/CodeGen/AArch64/aarch64-bf16-ldst-intrinsics.ll:264
+; Function Attrs: argmemonly nounwind readonly
+declare { <8 x bfloat>, <8 x bfloat> } 
@llvm.aarch64.neon.ld2lane.v8bf16.p0i8(<8 x bfloat>, <8 x bfloat>, i64, i8*) #3
+

chill wrote:
> SjoerdMeijer wrote:
> > chill wrote:
> > > LukeGeeson wrote:
> > > > SjoerdMeijer wrote:
> > > > > LukeGeeson wrote:
> > > > > > arsenm wrote:
> > > > > > > Why is the IR type name bfloat and not bfloat16?
> > > > > > The naming for the IR type was agreed upon here after quite a big 
> > > > > > discussion. 
> > > > > > https://reviews.llvm.org/D78190
> > > > > I regret very much that I didn't notice this earlier... I.e., I 
> > > > > noticed this in D76077 and wrote that I am relatively unhappy about 
> > > > > this (I think I mentioned this on another ticket too).
> > > > > Because like @arsenm , I would expect the IR type name to be bfloat16.
> > > > > 
> > > > > Correct me if I am wrong, but I don't see a big discussion about this 
> > > > > in D78190. I only see 1 or 2 comments about `BFloat` vs `Bfloat`.
> > > > I cannot see a discussion about the IR type name per-se but I can see 
> > > > you were both involved in the discussion more generally.
> > > > 
> > > > I am concerned that this patch is the wrong place to discuss such 
> > > > issues, and that we should bring this up in a more appropriate place as 
> > > > you mention so that this patch isn't held back.
> > > I don't see a compelling reason for the name to be `bfloat16` or 
> > > `bfloat3`, etc. Like other floating-point types (`float`, `double`, and 
> > > `half`), the name denotes a specific externally defined format, unlike 
> > > `iN`.
> > > Like other floating-point types (float, double, and half), the name 
> > > denotes a specific externally defined format, 
> > 
> > Is the defined format not called bfloat16?
> Indeed, people use the name "bfloat16". But then the `half`, `float`, and 
> `double` also differ from the official `binary16`, `binarty32`, and 
> `binary64`.
> IMHO `bfloat` fits better in the LLVM IR naming convention.
yeah, so that's exactly why I don't follow your logic. If there's any logic in 
the names here, the mapping from source-language type to IR type seems the most 
plausible one. And I just don't see the benefit of dropping the 16, and how 
that would fit better in some naming scheme or how that makes things clearer 
here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80716/new/

https://reviews.llvm.org/D80716



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


[PATCH] D81598: [analyzer] SATest: Add an easy option to connect to docker for debugging

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Docker on its own has a pretty convenient way to run shell.
This method, however, requires target container to be currently running,
which is not a usual scenario for the test system.  For this purpose,
it is better to have a simple way to run the container, shell it, and
clean up at the end of it all.  New option `--shell` does exactly this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81598

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/entrypoint.py

Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -2,13 +2,15 @@
 import os
 import sys
 
-from typing import List, Tuple
-
 from subprocess import call, check_call, CalledProcessError
+from time import sleep
+from typing import List, Tuple
 
 
 def main():
 settings, rest = parse_arguments()
+if settings.wait:
+wait()
 if settings.build_llvm or settings.build_llvm_only:
 build_llvm()
 if settings.build_llvm_only:
@@ -16,8 +18,14 @@
 sys.exit(test(rest))
 
 
+def wait():
+while True:
+sleep(3600)
+
+
 def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
 parser = argparse.ArgumentParser()
+parser.add_argument('--wait', action='store_true')
 parser.add_argument('--build-llvm', action='store_true')
 parser.add_argument('--build-llvm-only', action='store_true')
 return parser.parse_known_args()
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -108,8 +108,10 @@
 
 if args.build_image:
 docker_build_image()
+elif args.shell:
+docker_shell(args)
 else:
-docker_run(args)
+sys.exit(docker_run(args, ' '.join(args.rest)))
 
 
 def docker_build_image():
@@ -117,21 +119,36 @@
   shell=True))
 
 
-def docker_run(args):
-sys.exit(call("docker run --rm --name satest "
-  "-v {llvm}:/llvm-project "
-  "-v {build}:/build "
-  "-v {clang}:/analyzer "
-  "-v {scripts}:/scripts "
-  "-v {projects}:/projects "
-  "satest-image:latest {args}"
-  .format(llvm=args.llvm_project_dir,
-  build=args.build_dir,
-  clang=args.clang_dir,
-  scripts=SCRIPTS_DIR,
-  projects=PROJECTS_DIR,
-  args=' '.join(args.rest)),
-  shell=True))
+def docker_shell(args):
+try:
+docker_run(args, "--wait", "--detach")
+call("docker exec -it satest bash", shell=True)
+
+except KeyboardInterrupt:
+pass
+
+finally:
+print("Please wait for docker to clean up")
+call("docker stop satest", shell=True)
+
+
+def docker_run(args, command, docker_args=""):
+return call("docker run --rm --name satest "
+"-v {llvm}:/llvm-project "
+"-v {build}:/build "
+"-v {clang}:/analyzer "
+"-v {scripts}:/scripts "
+"-v {projects}:/projects "
+"{docker_args} "
+"satest-image:latest {command}"
+.format(llvm=args.llvm_project_dir,
+build=args.build_dir,
+clang=args.clang_dir,
+scripts=SCRIPTS_DIR,
+projects=PROJECTS_DIR,
+docker_args=docker_args,
+command=command),
+shell=True)
 
 
 def main():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81311#2084066 , @rjmccall wrote:

> In D81311#2083295 , @arsenm wrote:
>
> > In D81311#2078235 , @rjmccall 
> > wrote:
> >
> > > I wonder if `byref` would be a better name for this, as a way to say that 
> > > the object is semantically a direct argument that's being passed by 
> > > implicit reference.
> >
> >
> > This is probably a better name, but potentially more easily confused with 
> > byval.
>
>
> That seems like an unlikely confusion.
>
> > As far as switching to just the raw number, I think there's value in being 
> > consistent with the other growing family of type-carrying parameter 
> > attributes but I don't really care about the type itself. I don't 
> > understand inalloca/preallocated well enough to know if those should also 
> > really only carry a size.
>
> I think carrying a type is probably an attempt to insulate them against the 
> future removal of pointer element types.  I don't think it's actually 
> necessary in either case and could certainly just be a size and alignment.  
> But if you want to use a type, I agree it's not inconsistent, and as long as 
> you honor an explicit alignment it's fine.


The alignment is also technically a separate attribute and we generally don't 
require attributes to always be paired. I guess the verifier could require you 
to specify align if you use this, but that's another inconsistency


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81311/new/

https://reviews.llvm.org/D81311



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


[PATCH] D81599: [analyzer] SATest: Add 5 more projects for testing

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81599

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
  clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
  clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
  clang/utils/analyzer/projects/projects.json
  clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
  clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd

Index: clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/projects.json
===
--- clang/utils/analyzer/projects/projects.json
+++ clang/utils/analyzer/projects/projects.json
@@ -68,5 +68,40 @@
 "source": "git",
 "origin": "https://github.com/facebook/zstd.git";,
 "commit": "2af4e073"
+  },
+  {
+"name": "simbody",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/simbody/simbody.git";,
+"commit": "5cf513d"
+  },
+  {
+"name": "duckdb",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/cwida/duckdb.git";,
+"commit": "d098c9f"
+  },
+  {
+"name": "drogon",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/an-tao/drogon.git";,
+"commit": "fd2a612"
+  },
+  {
+"name": "fmt",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/fmtlib/fmt.git";,
+"commit": "5e7c70e"
+  },
+  {
+"name": "re2",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/google/re2.git";,
+"commit": "2b25567"
   }
 ]
Index: clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
@@ -0,

[PATCH] D81564: [analyzer] SATest: Add posibility to download source from git and zip

2020-06-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/utils/analyzer/ProjectMap.py:14
 
+class DownloadType(str, Enum):
+GIT = "git"

I was wondering what is the point of inheriting from `str`. I am not 
well-versed in Python so it is more of a curiosity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81564/new/

https://reviews.llvm.org/D81564



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


[PATCH] D81593: [analyzer] SATest: Make docker interfaces transparent

2020-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Forward results of every command executed in docker.  The actual commands
and their error codes are more informative than python stacktraces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81593

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/entrypoint.py

Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -1,9 +1,10 @@
 import argparse
 import os
+import sys
 
 from typing import List, Tuple
 
-from subprocess import check_call
+from subprocess import call, check_call, CalledProcessError
 
 
 def main():
@@ -12,7 +13,7 @@
 build_llvm()
 if settings.build_llvm_only:
 return
-test(rest)
+sys.exit(test(rest))
 
 
 def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
@@ -24,8 +25,12 @@
 
 def build_llvm() -> None:
 os.chdir('/build')
-cmake()
-ninja()
+try:
+cmake()
+ninja()
+except CalledProcessError:
+print("Build failed!")
+sys.exit(1)
 
 
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
@@ -43,9 +48,9 @@
 check_call("ninja install", shell=True)
 
 
-def test(args: List[str]):
+def test(args: List[str]) -> int:
 os.chdir("/projects")
-check_call("/scripts/SATest.py " + " ".join(args), shell=True)
+return call("/scripts/SATest.py " + " ".join(args), shell=True)
 
 
 if __name__ == '__main__':
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -11,7 +11,7 @@
 import sys
 import os
 
-from subprocess import check_call
+from subprocess import call
 
 SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
 PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
@@ -101,22 +101,25 @@
 
 
 def docker_build_image():
-check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
-   shell=True)
+sys.exit(call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+  shell=True))
 
 
 def docker_run(args):
-check_call("docker run --rm --name satest "
-   "-v {llvm}:/llvm-project "
-   "-v {build}:/build "
-   "-v {clang}:/analyzer "
-   "-v {scripts}:/scripts "
-   "-v {projects}:/projects "
-   "satest-image:latest {args}"
-   .format(llvm=args.llvm_project_dir, build=args.build_dir,
-   clang=args.clang_dir, scripts=SCRIPTS_DIR,
-   projects=PROJECTS_DIR, args=' '.join(args.rest)),
-   shell=True)
+sys.exit(call("docker run --rm --name satest "
+  "-v {llvm}:/llvm-project "
+  "-v {build}:/build "
+  "-v {clang}:/analyzer "
+  "-v {scripts}:/scripts "
+  "-v {projects}:/projects "
+  "satest-image:latest {args}"
+  .format(llvm=args.llvm_project_dir,
+  build=args.build_dir,
+  clang=args.clang_dir,
+  scripts=SCRIPTS_DIR,
+  projects=PROJECTS_DIR,
+  args=' '.join(args.rest)),
+  shell=True))
 
 
 def main():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:5217
+  else
+Mangler.getStream() << D->getName();
+}

jasonliu wrote:
> If I understand correctly, this function will come in pair with 
> `__cxx_global_var_init`.
> `__cxx_global_var_init` use number as suffix in the end to avoid duplication 
> when there is more than one of those, but we are using the variable name as 
> suffix here instead.
> Do we want to use number as suffix here to match what `__cxx_global_var_init` 
> does? It would help people to recognize the pairs and make them more 
> symmetric. 
This is somewhere I am kinda on the fence. Personally, I think embed decl name 
in the __cxx_global_var_destruct_ / __cxx_global_vat_init_ as 
`mangleDynamicAtExitDestructor` does is more helpful for the user to debug the 
static init.
I am not sure if we want to give up that benefit and be consistent with current 
`__cxx_global_vat_init_ ` using number suffix or do we want to replace number 
suffix by decl name for `__cxx_global_vat_init_ ` as well.



Comment at: clang/lib/CodeGen/CGCXXABI.h:113
+
+  virtual bool isCXXGlobalInitAndDtorFuncInternal() const { return true; }
+

jasonliu wrote:
> Do we need this isCXXGlobalInitAndDtorFuncInternal? Looks like it's always 
> going to return ! useSinitAndSterm() result.
AFAIK, not all platforms which use sinit and sterm have external linkage 
sinit/sterm functions. And also since for 7.2 AIX we are considering change 
sinit/sterm to internal linkage symbols, I seperate this query out.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:305
+  if (llvm::Function *unatexitFn =
+  dyn_cast(unatexit.getCallee()))
+unatexitFn->setDoesNotThrow();

jasonliu wrote:
> Is there a valid case that unatexit.getCallee() returns a type which could 
> not be cast to llvm::Function?
> i.e. Could we use cast instead of dyn_cast?
I used `cast` instead of `dyn_cast` before Diff 9 actually, and then I noticed 
that `clang-tidy` gave error and asked me to use `dyn_cast` instead. Cannot 
recall what the error says though...



Comment at: clang/lib/CodeGen/CodeGenModule.h:20
 #include "SanitizerMetadata.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/DeclCXX.h"

jasonliu wrote:
> Is this Attr.h needed somewhere in this file?
Oops..this is something I forgot to remove. Good catch!



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4481
+
+  llvm::BasicBlock *DestructCheckBlock = 
CGF.createBasicBlock("destruct.check");
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("destruct.end");

jasonliu wrote:
> I think we need a better naming for this and make it consistent with the end 
> block below.
> As it is for now, `destruct.check` is confusing, as we are not checking 
> anything here and we are just going to call destructor directly in this 
> block. 
Thanks, I will try `destruct.call` instead.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-10 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 269900.
Xiangling_L marked 17 inline comments as done.
Xiangling_L added a comment.

Address the comments


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74166/new/

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,85 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
-} t;
+} t1, t2;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_66d40ba2f9a26b497582a82a8a262181, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_66d40ba2f9a26b497582a82a8a262181, i8* null }]
+
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t1)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t1)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor_t1() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t1)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_destruct_t1() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t1)
+// CHECK:   %guard.hasDtor = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasDtor, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor_t1()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #3
+
+// CHECK: define internal void @__cxx_global_var_init.1() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t2)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t2)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor_t2() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t2)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_destruct_t2() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t2)
+// CHECK:   %guard.hasDtor = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasDtor, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor_t2()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:  ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sinit8000_clang_66d40ba2f9a26b497582a82a8a262181() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   call void @__cxx_global_var_init.1()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_66d40ba2f9a26b497582a82a8a262181() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t2()
+// CHECK:   call void @__cxx_global_var_destruct_t1()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-init-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-init-priority-attribute.cpp
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+class test {
+  int a;
+
+public:
+  test(int c) { a = c; }
+  ~test() { a = 0; }
+};
+
+__attribute__((init_priority(2000)))
+test t(1);
+
+// CHECK: fatal error: error in backend: 'init_priority' attribute unsupported on AIX yet
Index: clang/test/CodeGen/aix-destructor-attribute.cpp
===
--- /dev/null
+

[PATCH] D80917: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-10 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

In D80917#2085377 , @jdoerfert wrote:

> I am fine with this. @arsenm feel free to accept.
>
>  ---
>
> In D80917#2085138 , @saiislam wrote:
>
> > Ping.
>
>
> Afaik, pings should be reserved to ~1 week of inactivity. I know this can be 
> frustrating, but we also need to consider noise for reviewers.


Ok. I will keep in mind next time. Thanks :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80917/new/

https://reviews.llvm.org/D80917



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


  1   2   3   >