[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

As mentioned in the reverting commit - these tests fail in non-asserts builds, 
because they assume named IR instructions (like the named entry BB label), 
which aren't provided on a non-asserts build (there's a flag to turn them on - 
but that's probably not the right fix - making the test resilient to 
non-asserts IR is probably the right fix).

Leaving non-asserts builds broken for 12 hours (maybe I'm the first one to come 
across/report it - but I'd expect there are some buildbots that would fail, 
etc) is quite a while - best to be avoided when possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[clang] e1b8fde - Revert "[Clang] Add option to handle behaviour of vector bool/vector pixel."

2021-06-28 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-06-28T22:57:21-07:00
New Revision: e1b8fde1cbfc031d67d9b316f1b4ac3ab9c8801f

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

LOG: Revert "[Clang] Add option to handle behaviour of vector bool/vector 
pixel."

This reverts commit c3fe847f9d90de5a6a76fd1d5f5823ab4719accc.

Tests fail in non-asserts builds because they assume named IR, by the
looks of it (testing for the "entry" label, for instance). I don't know
enough about the update_cc_test_checks.py stuff to know how to manually
fix these tests, so reverting for now.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 
clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
clang/test/CodeGen/vector-compat-pixel-bool.c
clang/test/CodeGen/vector-compat-ternary.c
clang/test/CodeGen/vector-compat.c



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a22fd2506a..b5b8bc6aa3c5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,12 +7441,6 @@ def warn_deprecated_volatile_structured_binding : 
Warning<
   "volatile qualifier in structured binding declaration is deprecated">,
   InGroup;
 
-def warn_deprecated_altivec_src_compat : Warning<
-  "Current handling of vector bool and vector pixel types in this context are "
-  "deprecated. The default behaviour will soon change to that implied by the "
-  "'-altivec-compat=xl' option">,
-  InGroup>;
-
 def err_catch_incomplete_ptr : Error<
   "cannot catch pointer to incomplete type %0">;
 def err_catch_incomplete_ref : Error<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 465bad8d7d11..b6d9160f89a0 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -126,8 +126,6 @@ LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
  LaxVectorConversionKind::All, "lax vector conversions")
-ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,
- AltivecSrcCompatKind::Default, "Altivec source compatibility")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d04ce52a550e..d618daf3d23c 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -244,18 +244,6 @@ class LangOptions : public LangOptionsBase {
 All,
   };
 
-  enum class AltivecSrcCompatKind {
-// All vector compares produce scalars except vector pixel and vector bool.
-// The types vector pixel and vector bool return vector results.
-Mixed,
-// All vector compares produce vector results as in GCC.
-GCC,
-// All vector compares produce scalars as in XL.
-XL,
-// Default clang behaviour.
-Default = Mixed,
-  };
-
   enum class SignReturnAddressScopeKind {
 /// No signing for any function.
 None,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f1455f546199..0122afd2eead 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3823,18 +3823,6 @@ def u : JoinedOrSeparate<["-"], "u">, Group;
 def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Show commands to run and use verbose output">,
   MarshallingInfoFlag>;
-def altivec_src_compat : Joined<["-"], "faltivec-src-compat=">,
-  Flags<[CC1Option]>, Group,
-  HelpText<"Source-level compatibility for Altivec vectors (for PowerPC "
-   "targets). This includes results of vector comparison (scalar for "
-   "'xl', vector for 'gcc') as well as behavior when initializing with 
"
-   "a scalar (splatting for 'xl', element zero only for 'gcc'). For "
-   "'mixed', the compatibility is as 'gcc' for 'vector bool/vector "
-   "pixel' and as 'xl' for other types. Current default is 'mixed'.">,
-  Values<"mixed,gcc,xl">,
-  NormalizedValuesScope<"LangOptions::AltivecSrcCompatKind">,
-  NormalizedValues<["Mixed", "GCC", "XL"]>,
-  MarshallingInfoEnum, "Mixed">;
 def verify_debug_info : Flag<["--"], "verify-debug-info">, 

[PATCH] D105083: [clangd] Ensure Ref::Container refers to an indexed symbol

2021-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes https://github.com/clangd/clangd/issues/806


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105083

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -810,8 +810,7 @@
   };
   EXPECT_EQ(Container("ref1a"),
 findSymbol(Symbols, "f2").ID); // function body (call)
-  // FIXME: This is wrongly contained by fptr and not f2.
-  EXPECT_NE(Container("ref1b"),
+  EXPECT_EQ(Container("ref1b"),
 findSymbol(Symbols, "f2").ID); // function body (address-of)
   EXPECT_EQ(Container("ref2"),
 findSymbol(Symbols, "v1").ID); // variable initializer
Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -26,6 +26,22 @@
 
 namespace clang {
 namespace clangd {
+
+llvm::raw_ostream <<(llvm::raw_ostream ,
+  const CallHierarchyItem ) {
+  return Stream << Item.name << "@" << Item.selectionRange;
+}
+
+llvm::raw_ostream <<(llvm::raw_ostream ,
+  const CallHierarchyIncomingCall ) {
+  Stream << "{ from: " << Call.from << ", ranges: [";
+  for (const auto  : Call.fromRanges) {
+Stream << R;
+Stream << ", ";
+  }
+  return Stream << "] }";
+}
+
 namespace {
 
 using ::testing::AllOf;
@@ -252,6 +268,40 @@
   CheckCallHierarchy(*AST, CalleeC.point(), testPath("callee.cc"));
 }
 
+TEST(CallHierarchy, CallInLocalVarDecl) {
+  // Tests that local variable declarations are not treated as callers
+  // (they're not indexed, so they can't be represented as call hierarchy
+  // items); instead, the caller should be the containing function.
+  // However, namespace-scope variable declarations should be treated as
+  // callers because those are indexed and there is no enclosing entity
+  // that would be a useful caller.
+  Annotations Source(R"cpp(
+int call^ee();
+void caller1() {
+  $call1[[callee]]();
+}
+void caller2() {
+  int localVar = $call2[[callee]]();
+}
+int caller3 = $call3[[callee]]();
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+
+  std::vector Items =
+  prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
+
+  auto Incoming = incomingCalls(Items[0], Index.get());
+  ASSERT_THAT(
+  Incoming,
+  ElementsAre(
+  AllOf(From(WithName("caller1")), FromRanges(Source.range("call1"))),
+  AllOf(From(WithName("caller2")), FromRanges(Source.range("call2"))),
+  AllOf(From(WithName("caller3")), FromRanges(Source.range("call3");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -97,6 +97,13 @@
   static bool shouldCollectSymbol(const NamedDecl , const ASTContext ,
   const Options , bool IsMainFileSymbol);
 
+  /// Given a ref contained in enclosing declaration \p Enclosing, return
+  /// the decl that should be used as that ref's Ref::Container. This is
+  /// usually \p Enclosing itself, but in cases where \p Enclosing is not
+  /// indexed, we walk further up because Ref::Container should always be
+  /// an indexed symbol.
+  const Decl *getRefContainer(const Decl *Enclosing);
+
   void initialize(ASTContext ) override;
 
   void setPreprocessor(std::shared_ptr PP) override {
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -331,6 +331,14 @@
   std::make_unique(CompletionAllocator);
 }
 
+const Decl *SymbolCollector::getRefContainer(const Decl *Enclosing) {
+  const NamedDecl *ND = dyn_cast_or_null(Enclosing);
+  while (ND && !shouldCollectSymbol(*ND, *ASTCtx, Opts, true)) {
+ND = dyn_cast_or_null(ND->getDeclContext());
+  }
+  return 

[PATCH] D99237: [AVR][clang] Fix wrong calling convention in functions return struct type

2021-06-28 Thread Ben Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc94c8d8b5d99: [AVR][clang] Fix wrong calling convention in 
functions return struct type (authored by benshi001).

Changed prior to commit:
  https://reviews.llvm.org/D99237?vs=335368=355111#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99237

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/struct.c


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+  struct s10 a0;
+  return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+  struct s06 a0;
+  return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8154,14 +8154,39 @@
 }
 
 
//===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 
//===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less than or equal to 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+};
+
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes )
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   LangAS getGlobalVarAddressSpace(CodeGenModule ,
   const VarDecl *D) const override {


Index: clang/test/CodeGen/avr/struct.c
===
--- /dev/null
+++ clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+  struct s10 a0;
+  return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+  struct s06 a0;
+  return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8154,14 +8154,39 @@
 }
 
 //===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 //===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less than or equal to 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of 

[clang] c94c8d8 - [AVR][clang] Fix wrong calling convention in functions return struct type

2021-06-28 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2021-06-29T11:32:39+08:00
New Revision: c94c8d8b5d999c97ea424b35a1cb540d2a1d3bc6

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

LOG: [AVR][clang] Fix wrong calling convention in functions return struct type

According to AVR ABI (https://gcc.gnu.org/wiki/avr-gcc), returned struct value
within size 1-8 bytes should be returned directly (via register r18-r25), while
larger ones should be returned via an implicit struct pointer argument.

Reviewed By: dylanmckay

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

Added: 
clang/test/CodeGen/avr/struct.c

Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index e9565a5aef63..035c131dacb7 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8154,14 +8154,39 @@ void M68kTargetCodeGenInfo::setTargetAttributes(
 }
 
 
//===--===//
-// AVR ABI Implementation.
+// AVR ABI Implementation. Documented at
+// https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention
+// https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny
 
//===--===//
 
 namespace {
+class AVRABIInfo : public DefaultABIInfo {
+public:
+  AVRABIInfo(CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType Ty) const {
+// A return struct with size less than or equal to 8 bytes is returned
+// directly via registers R18-R25.
+if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) <= 64)
+  return ABIArgInfo::getDirect();
+else
+  return DefaultABIInfo::classifyReturnType(Ty);
+  }
+
+  // Just copy the original implementation of DefaultABIInfo::computeInfo(),
+  // since DefaultABIInfo::classify{Return,Argument}Type() are not virtual.
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+};
+
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes )
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   LangAS getGlobalVarAddressSpace(CodeGenModule ,
   const VarDecl *D) const override {

diff  --git a/clang/test/CodeGen/avr/struct.c b/clang/test/CodeGen/avr/struct.c
new file mode 100644
index ..cb4e84522df6
--- /dev/null
+++ b/clang/test/CodeGen/avr/struct.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm %s -o - | FileCheck %s
+
+// Structure that is more than 8 bytes.
+struct s10 {
+  int a, b, c, d, e;
+};
+
+// Structure that is less than 8 bytes.
+struct s06 {
+  int a, b, c;
+};
+
+struct s10 foo10(int a, int b, int c) {
+  struct s10 a0;
+  return a0;
+}
+
+struct s06 foo06(int a, int b, int c) {
+  struct s06 a0;
+  return a0;
+}
+
+// CHECK: %struct.s10 = type { i16, i16, i16, i16, i16 }
+// CHECK: %struct.s06 = type { i16, i16, i16 }
+// CHECK: define{{.*}} void @foo10(%struct.s10* {{.*}}, i16 %a, i16 %b, i16 %c)
+// CHECK: define{{.*}} %struct.s06 @foo06(i16 %a, i16 %b, i16 %c)



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


[PATCH] D97824: [ObjC][ARC] Don't add operand bundle `clang.arc.attachedcall` to a call if the call already has the operand bundle

2021-06-28 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97824

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


[PATCH] D95807: [RFC][Coroutines] Add the newly generated SCCs back to the CGSCC work queue after CoroSplit actually happened

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 355110.
lxfind added a comment.
Herald added subscribers: cfe-commits, qcolombet.
Herald added a project: clang.

After removing the legacy test command, I was finally able to update this 
patch. It's now ready for review. I will update the decription to reflect to 
the latest changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95807

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
  llvm/test/Transforms/Coroutines/coro-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-alloca-06.ll
  llvm/test/Transforms/Coroutines/coro-alloca-07.ll
  llvm/test/Transforms/Coroutines/coro-alloca-08.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-byval-param.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
  llvm/test/Transforms/Coroutines/coro-catchswitch.ll
  llvm/test/Transforms/Coroutines/coro-debug.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
  llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll
  llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll
  llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-materialize.ll
  llvm/test/Transforms/Coroutines/coro-padding.ll
  llvm/test/Transforms/Coroutines/coro-param-copy.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
  llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll
  llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
  llvm/test/Transforms/Coroutines/coro-spill-promise.ll
  llvm/test/Transforms/Coroutines/coro-split-00.ll
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-alloc.ll
  llvm/test/Transforms/Coroutines/coro-split-dbg.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
  llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
  llvm/test/Transforms/Coroutines/coro-split-hidden.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail1.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail2.ll
  llvm/test/Transforms/Coroutines/coro-split-musttail3.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-01.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-04.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/Coroutines/coro-zero-alloca.ll
  llvm/test/Transforms/Coroutines/no-suspend.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll

Index: llvm/test/Transforms/Coroutines/restart-trigger.ll
===
--- llvm/test/Transforms/Coroutines/restart-trigger.ll
+++ llvm/test/Transforms/Coroutines/restart-trigger.ll
@@ -1,11 +1,14 @@
 ; REQUIRES: asserts
 ; The following tests use the new pass manager, and verify that the coroutine
 ; passes re-run the CGSCC pipeline.
-; RUN: opt < %s -S -passes='default' -enable-coroutines -debug-only=coro-split 2>&1 | FileCheck %s
-; RUN: opt < %s -S -passes='default' -enable-coroutines -debug-only=coro-split 2>&1 | FileCheck %s
+; RUN: opt < %s -S -passes='default' -enable-coroutines -debug-only=coro-split 2>&1 | FileCheck --check-prefix=CHECK-NEWPM %s
+; RUN: opt < %s -S 

[PATCH] D104619: [clang] Respect PrintingPolicy::FullyQualifiedName when printing a template-id

2021-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 355104.
nridge added a comment.

fix comment at top of file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104619

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -0,0 +1,119 @@
+//===- unittests/AST/TypePrinterTest.cpp --- Type printer tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for QualType::print() and related methods.
+//
+//===--===//
+
+#include "ASTPrint.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ast_matchers;
+using namespace tooling;
+
+namespace {
+
+using PolicyAdjusterType =
+Optional>;
+
+static void PrintType(raw_ostream , const ASTContext *Context, QualType T,
+  PolicyAdjusterType PolicyAdjuster) {
+  assert(!T.isNull() && "Expected non-null Type");
+  PrintingPolicy Policy = Context->getPrintingPolicy();
+  if (PolicyAdjuster)
+(*PolicyAdjuster)(Policy);
+  T.print(Out, Policy);
+}
+
+class PrintMatch : public MatchFinder::MatchCallback {
+  SmallString<1024> Printed;
+  unsigned NumFoundTypes;
+  PolicyAdjusterType PolicyAdjuster;
+
+public:
+  explicit PrintMatch(PolicyAdjusterType PolicyAdjuster)
+  : NumFoundTypes(0), PolicyAdjuster(PolicyAdjuster) {}
+
+  void run(const MatchFinder::MatchResult ) override {
+const QualType *T = Result.Nodes.getNodeAs("id");
+if (!T)
+  return;
+NumFoundTypes++;
+if (NumFoundTypes > 1)
+  return;
+
+llvm::raw_svector_ostream Out(Printed);
+PrintType(Out, Result.Context, *T, PolicyAdjuster);
+  }
+
+  StringRef getPrinted() const { return Printed; }
+
+  unsigned getNumFoundTypes() const { return NumFoundTypes; }
+};
+
+::testing::AssertionResult
+PrintedTypeMatches(StringRef Code, const std::vector ,
+   const DeclarationMatcher ,
+   StringRef ExpectedPrinted,
+   PolicyAdjusterType PolicyAdjuster) {
+  PrintMatch Printer(PolicyAdjuster);
+  MatchFinder Finder;
+  Finder.addMatcher(NodeMatch, );
+  std::unique_ptr Factory =
+  newFrontendActionFactory();
+
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args))
+return testing::AssertionFailure()
+   << "Parsing error in \"" << Code.str() << "\"";
+
+  if (Printer.getNumFoundTypes() == 0)
+return testing::AssertionFailure() << "Matcher didn't find any types";
+
+  if (Printer.getNumFoundTypes() > 1)
+return testing::AssertionFailure() << "Matcher should match only one type "
+  "(found "
+   << Printer.getNumFoundTypes() << ")";
+
+  if (Printer.getPrinted() != ExpectedPrinted)
+return ::testing::AssertionFailure()
+   << "Expected \"" << ExpectedPrinted.str()
+   << "\", "
+  "got \""
+   << Printer.getPrinted().str() << "\"";
+
+  return ::testing::AssertionSuccess();
+}
+
+} // unnamed namespace
+
+TEST(TypePrinter, TemplateId) {
+  std::string Code = R"cpp(
+namespace N {
+  template  struct Type {};
+  
+  template 
+  void Foo(const Type );
+}
+  )cpp";
+  auto Matcher = parmVarDecl(hasType(qualType().bind("id")));
+
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher, "const Type &",
+ PolicyAdjusterType([](PrintingPolicy ) {
+   Policy.FullyQualifiedName = false;
+ })));
+
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher, "const N::Type &",
+ PolicyAdjusterType([](PrintingPolicy ) {
+   Policy.FullyQualifiedName = true;
+ })));
+}
\ No newline at end of file
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -29,6 +29,7 @@
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   StructuralEquivalenceTest.cpp
+  TypePrinterTest.cpp
   )
 
 clang_target_link_libraries(ASTTests
Index: clang/lib/AST/TypePrinter.cpp
===
--- 

[PATCH] D104619: [clang] Respect PrintingPolicy::FullyQualifiedName when printing a template-id

2021-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D104619#2831966 , @dblaikie wrote:

> So likely what you'd need would be a unit test of some kind (check around in 
> clang/unittests to see if there are other AST pretty printer tests, for 
> instance).

Thanks for the suggestion! I did find existing pretty printer tests and was 
able to write a test for this fix by doing something similar.

I added you as reviewer for the patch, hope that's ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104619

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


[PATCH] D104619: [clang] [WIP] Respect PrintingPolicy::FullyQualifiedName when printing a template-id

2021-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 355103.
nridge added a comment.
Herald added a subscriber: mgorny.

add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104619

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -0,0 +1,127 @@
+//===- unittests/AST/StmtPrinterTest.cpp --- Statement printer tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for Stmt::printPretty() and related methods.
+//
+// Search this file for WRONG to see test cases that are producing something
+// completely wrong, invalid C++ or just misleading.
+//
+// These tests have a coding convention:
+// * statements to be printed should be contained within a function named 'A'
+//   unless it should have some special name (e.g., 'operator+');
+// * additional helper declarations are 'Z', 'Y', 'X' and so on.
+//
+//===--===//
+
+#include "ASTPrint.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ast_matchers;
+using namespace tooling;
+
+namespace {
+
+using PolicyAdjusterType =
+Optional>;
+
+static void PrintType(raw_ostream , const ASTContext *Context, QualType T,
+  PolicyAdjusterType PolicyAdjuster) {
+  assert(!T.isNull() && "Expected non-null Type");
+  PrintingPolicy Policy = Context->getPrintingPolicy();
+  if (PolicyAdjuster)
+(*PolicyAdjuster)(Policy);
+  T.print(Out, Policy);
+}
+
+class PrintMatch : public MatchFinder::MatchCallback {
+  SmallString<1024> Printed;
+  unsigned NumFoundTypes;
+  PolicyAdjusterType PolicyAdjuster;
+
+public:
+  explicit PrintMatch(PolicyAdjusterType PolicyAdjuster)
+  : NumFoundTypes(0), PolicyAdjuster(PolicyAdjuster) {}
+
+  void run(const MatchFinder::MatchResult ) override {
+const QualType *T = Result.Nodes.getNodeAs("id");
+if (!T)
+  return;
+NumFoundTypes++;
+if (NumFoundTypes > 1)
+  return;
+
+llvm::raw_svector_ostream Out(Printed);
+PrintType(Out, Result.Context, *T, PolicyAdjuster);
+  }
+
+  StringRef getPrinted() const { return Printed; }
+
+  unsigned getNumFoundTypes() const { return NumFoundTypes; }
+};
+
+::testing::AssertionResult
+PrintedTypeMatches(StringRef Code, const std::vector ,
+   const DeclarationMatcher ,
+   StringRef ExpectedPrinted,
+   PolicyAdjusterType PolicyAdjuster) {
+  PrintMatch Printer(PolicyAdjuster);
+  MatchFinder Finder;
+  Finder.addMatcher(NodeMatch, );
+  std::unique_ptr Factory =
+  newFrontendActionFactory();
+
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args))
+return testing::AssertionFailure()
+   << "Parsing error in \"" << Code.str() << "\"";
+
+  if (Printer.getNumFoundTypes() == 0)
+return testing::AssertionFailure() << "Matcher didn't find any types";
+
+  if (Printer.getNumFoundTypes() > 1)
+return testing::AssertionFailure() << "Matcher should match only one type "
+  "(found "
+   << Printer.getNumFoundTypes() << ")";
+
+  if (Printer.getPrinted() != ExpectedPrinted)
+return ::testing::AssertionFailure()
+   << "Expected \"" << ExpectedPrinted.str()
+   << "\", "
+  "got \""
+   << Printer.getPrinted().str() << "\"";
+
+  return ::testing::AssertionSuccess();
+}
+
+} // unnamed namespace
+
+TEST(TypePrinter, TemplateId) {
+  std::string Code = R"cpp(
+namespace N {
+  template  struct Type {};
+  
+  template 
+  void Foo(const Type );
+}
+  )cpp";
+  auto Matcher = parmVarDecl(hasType(qualType().bind("id")));
+
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher, "const Type &",
+ PolicyAdjusterType([](PrintingPolicy ) {
+   Policy.FullyQualifiedName = false;
+ })));
+
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher, "const N::Type &",
+ PolicyAdjusterType([](PrintingPolicy ) {
+   Policy.FullyQualifiedName = true;
+ })));
+}
\ No newline at end of file
Index: clang/unittests/AST/CMakeLists.txt

[clang] 948308e - Fix `-Wunused-variable` warning. NFC.

2021-06-28 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2021-06-28T22:50:36-04:00
New Revision: 948308ef34dc7da8bb741a85eb9941cc2b05d227

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

LOG: Fix `-Wunused-variable` warning. NFC.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 35b34179cc23..4ff6c632b61d 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2173,7 +2173,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
   // Add "sample-profile-suffix-elision-policy" attribute for internal linkage
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
-if (auto *Fn = dyn_cast(TargetDecl)) {
+if (isa(TargetDecl)) {
   if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
   llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",



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


[PATCH] D104344: [modules] Track how headers are included by different modules.

2021-06-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping. It would be useful to know if this approach makes sense. If so, I can 
test it on a bigger codebase and see if there are any problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104344

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


[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-28 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

In D104261#2844636 , @aaronpuchert 
wrote:

> In D104261#2841356 , @delesley 
> wrote:
>
>> since it's restricted to relockable managed locks, I'm not too worried...
>
> Not quite, it affects scoped locks with explicit unlock, which was supported 
> before D49885 .
>
> @rupprecht, can you still test patches on Google's code? Would be good to 
> know if this breaks anything.

Thanks for the heads up. I ran this on the same targets that broke in D84604 
 (in case that's what you're looking for), and 
those continue to pass. I can try further testing of other targets, but that 
may take a little longer, so I have no problem with you landing this as-is and 
I can follow up if there are problems elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104261

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31eb696fc4cd: [Coroutines] Remove CoroElide from O0 pipeline 
(authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Transforms/Coroutines/smoketest.ll


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,21 +2,21 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
 ; RUN: 
-passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)'
 2>&1 \
-; RUN: | FileCheck %s
+; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
-; CHECK: CoroEarlyPass
-; CHECK: CoroSplitPass
-; CHECK: CoroElidePass
-; CHECK: CoroCleanupPass
+; CHECK-ALL: CoroEarlyPass
+; CHECK-ALL: CoroSplitPass
+; CHECK-OPT: CoroElidePass
+; CHECK-ALL: CoroCleanupPass
 
 define void @foo() {
   ret void
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1986,7 +1986,6 @@
 
 CGSCCPassManager CGPM;
 CGPM.addPass(CoroSplitPass());
-CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
 
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -3,23 +3,23 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN:   -O0 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O1 %s 2>&1 | FileCheck %s
+// RUN:   -O1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 //
-// CHECK: Running pass:{{.*}}CoroEarlyPass
+// CHECK-ALL: Running pass:{{.*}}CoroEarlyPass
 //
 // The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
 // The second coro-split pass splits coroutine 'foo' into funclets
 // 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
-// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK-ALL: Running pass:{{.*}}CoroCleanupPass
 
 namespace std {
 namespace experimental {


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,21 +2,21 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: 

[clang] 31eb696 - [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2021-06-28T19:28:27-07:00
New Revision: 31eb696fc4cd3b1ed8054d88af54f214c0f92989

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

LOG: [Coroutines] Remove CoroElide from O0 pipeline

CoroElide pass works only when a post-split coroutine is inlined into another 
post-split coroutine.
In O0, there is no inlining after CoroSplit, and hence no CoroElide can happen.
It's useless to put CoroElide pass in the O0 pipeline and it will never be 
triggered (unless I miss anything).

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

Added: 


Modified: 
clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Transforms/Coroutines/smoketest.ll

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp 
b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
index 83f8121296690..91e0fb3042b9d 100644
--- a/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
+++ b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -3,23 +3,23 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN:   -O0 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O1 %s 2>&1 | FileCheck %s
+// RUN:   -O1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 //
-// CHECK: Running pass:{{.*}}CoroEarlyPass
+// CHECK-ALL: Running pass:{{.*}}CoroEarlyPass
 //
 // The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
 // The second coro-split pass splits coroutine 'foo' into funclets
 // 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
-// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK-ALL: Running pass:{{.*}}CoroCleanupPass
 
 namespace std {
 namespace experimental {

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 49f6c1049625f..2db8b451bf16d 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1986,7 +1986,6 @@ ModulePassManager 
PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
 
 CGSCCPassManager CGPM;
 CGPM.addPass(CoroSplitPass());
-CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
 
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));

diff  --git a/llvm/test/Transforms/Coroutines/smoketest.ll 
b/llvm/test/Transforms/Coroutines/smoketest.ll
index bb8d26783ca9d..bd122ff00180c 100644
--- a/llvm/test/Transforms/Coroutines/smoketest.ll
+++ b/llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,21 +2,21 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
 ; RUN: 
-passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)'
 2>&1 \
-; RUN: | FileCheck %s
+; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
-; CHECK: CoroEarlyPass
-; CHECK: CoroSplitPass
-; CHECK: CoroElidePass
-; CHECK: CoroCleanupPass
+; CHECK-ALL: CoroEarlyPass
+; CHECK-ALL: CoroSplitPass
+; CHECK-OPT: CoroElidePass
+; 

[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

> That's a separate topic though. Let's agree on this diff first and then I can 
> explain more about the always_inline issue.

Yeah, maybe we should discuss it on the llvm-dev thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

> Yeah, but it may be inlined  after splitting, which could trigger coro elide.

In O0, there is no inliner pass (after CoroSplit), so inlining should never 
happen.

>> in fact, we should make it illegal to mark a coroutine "always_inline", 
>> because there is no guarantee that a coroutine can be fully inlined, GCC 
>> does that
>
> To my understanding, it looks like that we shouldn't inline it since we 
> couldn't inline all parts of the function. Is this what you want to say?
> I think it may be a problem that we can't inline the full coroutine. But it's 
> not the reason to forbid it.

That's a separate topic though. Let's agree on this diff first and then I can 
explain more about the always_inline issue.

> ---
>
> Coro Elide is not defined in the standard (although it comes up in the 
> proposal). So it should be a compiler optimization. In this way, it should be 
> OK to remove it in O0.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D105066#2845978 , @lxfind wrote:

> Coroutine functions cannot be inlined before splitting, even if it's marked 
> "always_inline"

Yeah, but it may be inlined  after splitting, which could trigger coro elide.

> in fact, we should make it illegal to mark a coroutine "always_inline", 
> because there is no guarantee that a coroutine can be fully inlined, GCC does 
> that

To my understanding, it looks like that we shouldn't inline it since we 
couldn't inline all parts of the function. Is this what you want to say?
I think it may be a problem that we can't inline the full coroutine. But it's 
not the reason to forbid it.

---

Coro Elide is not defined in the standard (although it comes up in the 
proposal). So it should be a compiler optimization. In this way, it should be 
OK to remove it in O0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D105066#2845958 , @ChuanqiXu wrote:

> On O0, it is possible to inline if the user marked the function with 
> `always_inline`.
> Since CoroElide is kind of optimization, it should be OK to skip in O0.
> Out of curiosity, what's the reason that you want to remove it?

Coroutine functions cannot be inlined before splitting, even if it's marked 
"always_inline" (in fact, we should make it illegal to mark a coroutine 
"always_inline", because there is no guarantee that a coroutine can be fully 
inlined, GCC does that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

On O0, it is possible to inline if the user marked the function with 
`always_inline`.
Since CoroElide is kind of optimization, it should be OK to skip in O0.
Out of curiosity, what's the reason that you want to remove it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

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


[PATCH] D97824: [ObjC][ARC] Don't add operand bundle `clang.arc.attachedcall` to a call if the call already has the operand bundle

2021-06-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 355080.
ahatanak added a comment.

Check the presence of the operand bundle earlier in `emitARCOperationAfterCall`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97824

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjCXX/arc-rv-attr.mm


Index: clang/test/CodeGenObjCXX/arc-rv-attr.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/arc-rv-attr.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc 
-std=c++11 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK
+
+id foo(void);
+
+// CHECK-LABEL: define{{.*}} void @_Z14test_list_initv(
+// CHECK: %[[CALL1:.*]] = call i8* @_Z3foov() [ "clang.arc.attachedcall"(i64 
0) ]
+// CHECK: call i8* @llvm.objc.retain(i8* %[[CALL1]])
+
+void test_list_init() {
+  auto t = id{foo()};
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2939,8 +2939,12 @@
   ValueTransform doAfterCall,
   ValueTransform doFallback) {
   CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
+  auto *callBase = dyn_cast(value);
 
-  if (llvm::CallInst *call = dyn_cast(value)) {
+  if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) {
+// Fall back if the call base has operand bundle "clang.arc.attachedcall".
+value = doFallback(CGF, value);
+  } else if (llvm::CallInst *call = dyn_cast(value)) {
 // Place the retain immediately following the call.
 CGF.Builder.SetInsertPoint(call->getParent(),
++llvm::BasicBlock::iterator(call));


Index: clang/test/CodeGenObjCXX/arc-rv-attr.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/arc-rv-attr.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -std=c++11 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+
+id foo(void);
+
+// CHECK-LABEL: define{{.*}} void @_Z14test_list_initv(
+// CHECK: %[[CALL1:.*]] = call i8* @_Z3foov() [ "clang.arc.attachedcall"(i64 0) ]
+// CHECK: call i8* @llvm.objc.retain(i8* %[[CALL1]])
+
+void test_list_init() {
+  auto t = id{foo()};
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2939,8 +2939,12 @@
   ValueTransform doAfterCall,
   ValueTransform doFallback) {
   CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
+  auto *callBase = dyn_cast(value);
 
-  if (llvm::CallInst *call = dyn_cast(value)) {
+  if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) {
+// Fall back if the call base has operand bundle "clang.arc.attachedcall".
+value = doFallback(CGF, value);
+  } else if (llvm::CallInst *call = dyn_cast(value)) {
 // Place the retain immediately following the call.
 CGF.Builder.SetInsertPoint(call->getParent(),
++llvm::BasicBlock::iterator(call));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105001: [Clang][RISCV] Support half-precision floating point for RVV intrinsics.

2021-06-28 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

This all looks good to me except adding back the asm check. 
BTW, do we need to attach the half-precision floating point spec link?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105001

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


[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 355073.
lxfind added a comment.

update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105066

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Transforms/Coroutines/smoketest.ll


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,21 +2,21 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
 ; RUN: 
-passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)'
 2>&1 \
-; RUN: | FileCheck %s
+; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
-; CHECK: CoroEarlyPass
-; CHECK: CoroSplitPass
-; CHECK: CoroElidePass
-; CHECK: CoroCleanupPass
+; CHECK-ALL: CoroEarlyPass
+; CHECK-ALL: CoroSplitPass
+; CHECK-OPT: CoroElidePass
+; CHECK-ALL: CoroCleanupPass
 
 define void @foo() {
   ret void
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1986,7 +1986,6 @@
 
 CGSCCPassManager CGPM;
 CGPM.addPass(CoroSplitPass());
-CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
 
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -3,23 +3,23 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN:   -O0 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O1 %s 2>&1 | FileCheck %s
+// RUN:   -O1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 //
-// CHECK: Running pass:{{.*}}CoroEarlyPass
+// CHECK-ALL: Running pass:{{.*}}CoroEarlyPass
 //
 // The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
 // The second coro-split pass splits coroutine 'foo' into funclets
 // 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
-// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK-ALL: Running pass:{{.*}}CoroCleanupPass
 
 namespace std {
 namespace experimental {


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,21 +2,21 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 

[PATCH] D104088: Add clang frontend flags for MIP

2021-06-28 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 355066.
ellis added a comment.

Add min instruction count frontend flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104088

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/clang-mip-flags.c

Index: clang/test/Driver/clang-mip-flags.c
===
--- /dev/null
+++ clang/test/Driver/clang-mip-flags.c
@@ -0,0 +1,49 @@
+// REQUIRES: clang-driver
+// UNSUPPORTED: windows-msvc
+
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip %s 2>&1 | FileCheck %s --check-prefix USE
+// USE: "-cc1"
+// USE-SAME: "-mllvm" "-machine-profile-use=/path/to/profile.mip"
+// USE-SAME: "-mllvm" "-link-unit-name=a.out"
+
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip -o my-executable %s 2>&1 | FileCheck %s --check-prefix USE-OUTPUT
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip -fmachine-profile-link-unit-name=my-executable %s 2>&1 | FileCheck %s --check-prefix USE-OUTPUT
+// USE-OUTPUT: "-cc1"
+// USE-OUTPUT-SAME: "-mllvm" "-link-unit-name=my-executable"
+
+// RUN: %clang -### -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix GEN
+// RUN: %clang -### -fno-machine-profile-generate -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix GEN
+// GEN: "-cc1"
+// GEN-SAME: "-mllvm" "-enable-machine-instrumentation"
+// GEN-SAME: "-mllvm" "-link-unit-name=a.out"
+
+// RUN: %clang -### %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// RUN: %clang -### -fno-machine-profile-generate %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// RUN: %clang -### -fmachine-profile-generate -fno-machine-profile-generate %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// NOGEN-NOT: "-enable-machine-instrumentation"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-function-coverage %s 2>&1 | FileCheck %s --check-prefix FUNCCOV
+// FUNCCOV: "-cc1"
+// FUNCCOV-SAME: "-mllvm" "-enable-machine-function-coverage"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-block-coverage %s 2>&1 | FileCheck %s --check-prefix BLOCKCOV
+// BLOCKCOV: "-cc1"
+// BLOCKCOV-SAME: "-mllvm" "-enable-machine-block-coverage"
+
+// RUN: %clang -### -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix FULL
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-call-graph %s 2>&1 | FileCheck %s --check-prefix FULL
+// FULL: "-cc1"
+// FULL-SAME: "-mllvm" "-enable-machine-call-graph"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-runtime-buffer=1024 %s 2>&1 | FileCheck %s --check-prefix RUNTIMEBUF
+// RUNTIMEBUF: "-cc1"
+// RUNTIMEBUF-SAME: "-mllvm" "-machine-profile-runtime-buffer=1024"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-function-group-count=22 -fmachine-profile-selected-function-group=11 %s 2>&1 | FileCheck %s --check-prefix GEN-GROUPS
+// GEN-GROUPS: "-cc1"
+// GEN-GROUPS-SAME: "-mllvm" "-machine-profile-function-group-count=22"
+// GEN-GROUPS-SAME: "-mllvm" "-machine-profile-selected-function-group=11"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-min-instruction-count=50 %s 2>&1 | FileCheck %s --check-prefix MIN-INSTR
+// MIN-INSTR: "-cc1"
+// MIN-INSTR-SAME: "-mllvm" "-machine-profile-min-instruction-count=50"
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -118,6 +118,7 @@
 llvm-lto2
 llvm-modextract
 llvm-nm
+llvm-mipdata
 llvm-objcopy
 llvm-objdump
 llvm-profdata
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -149,6 +149,7 @@
   CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
+  getToolChain().addMachineProfileRTLibs(Args, CmdArgs);
 
   const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
Index: clang/lib/Driver/ToolChains/NetBSD.cpp
===

[PATCH] D105066: [Coroutines] Remove CoroElide from O0 pipeline

2021-06-28 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added reviewers: ChuanqiXu, rjmccall.
Herald added subscribers: hoy, modimo, wenlei, hiraditya.
lxfind requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

CoroElide pass works only when a post-split coroutine is inlined into another 
post-split coroutine.
In O0, there is no inlining after CoroSplit, and hence no CoroElide can happen.
It's useless to put CoroElide pass in the O0 pipeline and it will never be 
triggered (unless I miss anything).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105066

Files:
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Transforms/Coroutines/smoketest.ll


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,20 +2,20 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: -debug-pass-manager 2>&1 | FileCheck %s
+; RUN: -debug-pass-manager 2>&1 | FileCheck %s 
--check-prefixes=CHECK-ALL,CHECK-OPT
 ; RUN: opt < %s -disable-output -debug-pass-manager \
 ; RUN: 
-passes='function(coro-early),cgscc(coro-split),function(coro-elide,coro-cleanup)'
 2>&1 \
-; RUN: | FileCheck %s
+; RUN: | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 
 ; CHECK: CoroEarlyPass
 ; CHECK: CoroSplitPass
-; CHECK: CoroElidePass
+; CHECK-OPT: CoroElidePass
 ; CHECK: CoroCleanupPass
 
 define void @foo() {
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1986,7 +1986,6 @@
 
 CGSCCPassManager CGPM;
 CGPM.addPass(CoroSplitPass());
-CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
 
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -3,23 +3,23 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN:   -O0 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
 // RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
-// RUN:   -O1 %s 2>&1 | FileCheck %s
+// RUN:   -O1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
 //
-// CHECK: Running pass:{{.*}}CoroEarlyPass
+// CHECK-ALL: Running pass:{{.*}}CoroEarlyPass
 //
 // The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
 // The second coro-split pass splits coroutine 'foo' into funclets
 // 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
-// CHECK: Running pass: CoroSplitPass on (_Z3foov)
-// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
 //
-// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK-ALL: Running pass:{{.*}}CoroCleanupPass
 
 namespace std {
 namespace experimental {


Index: llvm/test/Transforms/Coroutines/smoketest.ll
===
--- llvm/test/Transforms/Coroutines/smoketest.ll
+++ llvm/test/Transforms/Coroutines/smoketest.ll
@@ -2,20 +2,20 @@
 ; levels and -enable-coroutines adds coroutine passes to the pipeline.
 ;
 ; RUN: opt < %s -disable-output -passes='default' -enable-coroutines \
-; RUN: 

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D103938#2836470 , @rsmith wrote:

> I've given this some more thought, and I think it's only the "constant 
> evaluated" check that we want to bypass in this case. It's common to use 
> `sizeof` or `decltype` with a comma operator in order to put an expression in 
> a SFINAE context, and I don't think we should warn on those cases. So I think 
> we should still do the context check for `DiagIfReachable`, but only bail out 
> for unevaluated contexts, not for constant-evaluated contexts. Does that seem 
> reasonable?

Yeah, it is reasonable and seems already in place 
(https://reviews.llvm.org/rG78ecb8737d97a038770af9f6a1ad1d7925c87eb7).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 355054.
ychen added a comment.

- Add test case for 'constexpr if'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/CodeCompletion/pragma-macro-token-caching.c
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/Parser/cxx-ambig-decl-expr.cpp
  clang/test/Parser/cxx0x-ambig.cpp
  clang/test/Sema/const-eval.c
  clang/test/Sema/exprs.c
  clang/test/Sema/i-c-e.c
  clang/test/Sema/vla-2.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaCXX/builtin-constant-p.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/constant-expression.cpp
  clang/test/SemaCXX/expression-traits.cpp
  clang/test/SemaCXX/warn-comma-operator.cpp
  clang/test/SemaCXX/warn-unused-value.cpp

Index: clang/test/SemaCXX/warn-unused-value.cpp
===
--- clang/test/SemaCXX/warn-unused-value.cpp
+++ clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++17 %s
 
 // PR4806
 namespace test0 {
@@ -138,3 +139,26 @@
   (void)arr3;
   (void)arr4;
 }
+
+#if __cplusplus >= 201103L // C++11 or later
+namespace test5 {
+int v[(5, 6)]; // expected-warning {{expression result unused}}
+void foo() {
+  new double[false ? (1, 2) : 3]
+// FIXME: We shouldn't diagnose the unreachable constant expression
+// here.
+[false ? (1, 2) : 3]; // expected-warning {{expression result unused}}
+}
+} // namespace test5
+#endif
+
+#if __cplusplus >= 201703L // C++11 or later
+namespace test6 {
+auto b() {
+  if constexpr (false)
+return (1,0);
+  else
+return (1.0,0.0); // expected-warning {{expression result unused}}
+}
+} // namespace test6
+#endif
Index: clang/test/SemaCXX/warn-comma-operator.cpp
===
--- clang/test/SemaCXX/warn-comma-operator.cpp
+++ clang/test/SemaCXX/warn-comma-operator.cpp
@@ -242,8 +242,8 @@
 
 template 
 class Foo {
-  typedef bool_seq<(xs::value, true)...> all_true;
-  typedef bool_seq<(xs::value, false)...> all_false;
+  typedef bool_seq<((void)xs::value, true)...> all_true;
+  typedef bool_seq<((void)xs::value, false)...> all_false;
   typedef bool_seq seq;
 };
 
Index: clang/test/SemaCXX/expression-traits.cpp
===
--- clang/test/SemaCXX/expression-traits.cpp
+++ clang/test/SemaCXX/expression-traits.cpp
@@ -583,10 +583,10 @@
 
 // Can't use the ASSERT_ macros without adding parens around
 // the comma expression.
-static_assert(__is_lvalue_expr(x,x), "expected an lvalue");
-static_assert(__is_rvalue_expr(x,1), "expected an rvalue");
-static_assert(__is_lvalue_expr(1,x), "expected an lvalue");
-static_assert(__is_rvalue_expr(1,1), "expected an rvalue");
+static_assert(__is_lvalue_expr((void)x,x), "expected an lvalue");
+static_assert(__is_rvalue_expr((void)x,1), "expected an rvalue");
+static_assert(__is_lvalue_expr((void)1,x), "expected an lvalue");
+static_assert(__is_rvalue_expr((void)1,1), "expected an rvalue");
 }
 
 #if 0
Index: clang/test/SemaCXX/constant-expression.cpp
===
--- clang/test/SemaCXX/constant-expression.cpp
+++ clang/test/SemaCXX/constant-expression.cpp
@@ -88,8 +88,8 @@
 
 void diags(int n) {
   switch (n) {
-case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
-case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} expected-warning {{expression result unused}}
+case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} expected-warning {{expression result unused}}
 case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
 case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
   ;
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -745,7 

Maintenance works in llvm lab tomorrow June 29

2021-06-28 Thread Galina Kistanova via cfe-commits
Hello,

LLVM lab and build master will be unavailable tomorrow June 29 for about an
hour starting 2PM PST due maintenance works in the lab.
Thank you for understanding.

Thanks

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


[PATCH] D102356: [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.

2021-06-28 Thread Hongtao Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG633ca3ff2f8f: [UniqueLinkageName] Use exsiting GlobalDecl 
object instead of reconstructing… (authored by hoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102356

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp


Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@
   return mver();
 }
 
+namespace {
+class A {
+public:
+  A() {}
+  ~A() {}
+};
+}
+
+void test() {
+  A a;
+}
+
 // PLAIN: @_ZL4glob = internal global
 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
 // PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() 
#[[#ATTR:]] {
 // UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
 // UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { 
{{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
 if (auto *Fn = dyn_cast(TargetDecl)) {
-  if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+  if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+  llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
 }


Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@
   return mver();
 }
 
+namespace {
+class A {
+public:
+  A() {}
+  ~A() {}
+};
+}
+
+void test() {
+  A a;
+}
+
 // PLAIN: @_ZL4glob = internal global
 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
 // PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() #[[#ATTR:]] {
 // UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
 // UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { {{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
 if (auto *Fn = dyn_cast(TargetDecl)) {
-  if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+  if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+  llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
 }

[clang] 633ca3f - [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.

2021-06-28 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2021-06-28T14:50:41-07:00
New Revision: 633ca3ff2f8fc2e2b69001d17abc43f302578fc1

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

LOG: [UniqueLinkageName] Use exsiting GlobalDecl object instead of 
reconstructing one.

C++ constructors/destructors need to go through a different constructor to 
construct a GlobalDecl object in order to retrieve their linkage type. This 
causes an assert failure in the default constructor of GlobalDecl. I'm chaning 
it to using the exsiting GlobalDecl object.

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/unique-internal-linkage-names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1cd972f32f3ff..35b34179cc231 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
 if (auto *Fn = dyn_cast(TargetDecl)) {
-  if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+  if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+  llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
 }

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names.cpp 
b/clang/test/CodeGen/unique-internal-linkage-names.cpp
index c567bcde45a84..95591de308d37 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ b/clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@ int mver_call() {
   return mver();
 }
 
+namespace {
+class A {
+public:
+  A() {}
+  ~A() {}
+};
+}
+
+void test() {
+  A a;
+}
+
 // PLAIN: @_ZL4glob = internal global
 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
 // PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@ int mver_call() {
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() 
#[[#ATTR:]] {
 // UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
 // UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { 
{{.*}}"sample-profile-suffix-elision-policy"{{.*}} }



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


[PATCH] D104975: Implement P1949

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 355036.
cor3ntin added a comment.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.

Optimize character lookup for ascii


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/UnicodeCharSets.h
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/FixIt/fixit-unicode.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Preprocessor/utf8-allowed-chars.c
  clang/www/cxx_status.html
  llvm/include/llvm/Support/UnicodeCharRanges.h

Index: llvm/include/llvm/Support/UnicodeCharRanges.h
===
--- llvm/include/llvm/Support/UnicodeCharRanges.h
+++ llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -62,6 +62,14 @@
   /// Returns true if the character set contains the Unicode code point
   /// \p C.
   bool contains(uint32_t C) const {
+if (C < 127) {
+  for (const auto  : Ranges) {
+if (R.Lower <= C && R.Upper >= C)
+  return true;
+if (R.Lower > C)
+  return false;
+  }
+}
 return std::binary_search(Ranges.begin(), Ranges.end(), C);
   }
 
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1311,7 +1311,7 @@
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7;>P1949R7
-  No
+  Clang 13
 
 
   Mixed string literal concatenation
Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -23,46 +23,30 @@
 
 
 
-
-
-
-
 #if __cplusplus
-# if __cplusplus >= 201103L
-// C++11
-// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
+// expected-error@11 {{not allowed in identifiers}}
+// expected-error@13 {{not allowed in identifiers}}
+// expected-error@20 {{expected unqualified-id}}
 // expected-error@21 {{expected unqualified-id}}
 
-# else
-// C++03
-// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@10 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
-
-# endif
 #else
 # if __STDC_VERSION__ >= 201112L
 // C11
 // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
 // expected-warning@11 {{using this character in an identifier is incompatible with C99}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@13 {{not allowed in identifiers}}
 // expected-warning@14 {{using this character in an identifier is incompatible with C99}}
 // expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
 // expected-error@21 {{expected identifier}}
 
 # else
 // C99
-// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@11 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@9 {{not allowed in identifiers}}
+// expected-error@11 {{not allowed in identifiers}}
+// expected-error@13 {{allowed in identifiers}}
+// expected-error@14 {{not allowed in identifiers}}
 // expected-error@20 {{expected identifier}}
-// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
+// expected-error@21 {{not allowed in identifiers}} expected-warning@21 {{declaration does not declare anything}}
 
 # endif
 #endif
Index: clang/test/Preprocessor/ucn-allowed-chars.c
===
--- 

[PATCH] D104117: [clangd] Fix highlighting for implicit ObjC property refs

2021-06-28 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 355035.
dgoldman added a comment.

Fix clang-tidy warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104117

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -696,11 +696,16 @@
   int $Field_decl[[_someProperty]];
 }
 @property(nonatomic, assign) int $Field_decl[[someProperty]];
+@property(readonly, class) $Class[[Foo]] 
*$Field_decl_readonly_static[[sharedInstance]];
 @end
 @implementation $Class_decl[[Foo]]
 @synthesize someProperty = _someProperty;
+- (int)$Method_decl[[otherMethod]] {
+  return 0;
+}
 - (int)$Method_decl[[doSomething]] {
-  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  $Class[[Foo]].$Field_static[[sharedInstance]].$Field[[someProperty]] 
= 1;
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 
self.$Field[[otherMethod]] + 1;
   self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
 }
 @end
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -556,6 +556,42 @@
 return true;
   }
 
+  // Objective-C allows you to use property syntax `self.prop` as sugar for
+  // `[self prop]` and `[self setProp:]` when there's no explicit `@property`
+  // for `prop` as well as for class properties. We treat this like a property
+  // even though semantically it's equivalent to a method expression.
+  void highlightObjCImplicitPropertyRef(const ObjCMethodDecl *OMD,
+SourceLocation Loc) {
+auto  = H.addToken(Loc, HighlightingKind::Field)
+.addModifier(HighlightingModifier::ClassScope);
+if (OMD->isClassMethod())
+  Tok.addModifier(HighlightingModifier::Static);
+if (isDefaultLibrary(OMD))
+  Tok.addModifier(HighlightingModifier::DefaultLibrary);
+  }
+
+  bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *OPRE) {
+// We need to handle implicit properties here since they will appear to
+// reference `ObjCMethodDecl` via an implicit `ObjCMessageExpr`, so normal
+// highlighting will not work.
+if (!OPRE->isImplicitProperty())
+  return true;
+// A single property expr can reference both a getter and setter, but we 
can
+// only provide a single semantic token, so prefer the getter. In most 
cases
+// the end result should be the same, although it's technically possible
+// that the user defines a setter for a system SDK.
+if (OPRE->isMessagingGetter()) {
+  highlightObjCImplicitPropertyRef(OPRE->getImplicitPropertyGetter(),
+   OPRE->getLocation());
+  return true;
+}
+if (OPRE->isMessagingSetter()) {
+  highlightObjCImplicitPropertyRef(OPRE->getImplicitPropertySetter(),
+   OPRE->getLocation());
+}
+return true;
+  }
+
   bool VisitOverloadExpr(OverloadExpr *E) {
 if (!E->decls().empty())
   return true; // handled by findExplicitReferences.


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -696,11 +696,16 @@
   int $Field_decl[[_someProperty]];
 }
 @property(nonatomic, assign) int $Field_decl[[someProperty]];
+@property(readonly, class) $Class[[Foo]] *$Field_decl_readonly_static[[sharedInstance]];
 @end
 @implementation $Class_decl[[Foo]]
 @synthesize someProperty = _someProperty;
+- (int)$Method_decl[[otherMethod]] {
+  return 0;
+}
 - (int)$Method_decl[[doSomething]] {
-  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  $Class[[Foo]].$Field_static[[sharedInstance]].$Field[[someProperty]] = 1;
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + self.$Field[[otherMethod]] + 1;
   self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
 }
 @end
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ 

[PATCH] D103461: [clang][deps] NFC: Preserve the original frontend action

2021-06-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D103461#2841918 , @bmahjour wrote:

> @jansvoboda11 This change is causing the following LIT tests to fail on AIX:

I think @jansvoboda11 is out this week (IIRC, back next week). A possible 
interim workaround would be to add an `XFAIL: aix` (or whatever the lit feature 
is for AIX triples)... are you able to land something like that to unblock you? 
(Seems like the correct fix for `-fno-integrated-as` could be a bit more 
complicated...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103461

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


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-28 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, but since this hasn't been up for long maybe leave it open for a bit in 
case someone else has a comment.


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

https://reviews.llvm.org/D105052

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


[PATCH] D102356: [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.

2021-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks alright, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102356

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:130
 TT.isArch64Bit()
-? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
-: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
+? (hasReferenceTypes(FS)
+   ? 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"

pmatos wrote:
> tlively wrote:
> > `hasReferenceTypes` should also be taking the CPU into account, not just 
> > the feature string. Normally this would be done via `getSubtargetImpl`, but 
> > I guess we probably can't call that this early in the construction of the 
> > `WebAssemblyTargetMachine`. Would anything break if we just unconditionally 
> > added the reference types address spaces to the data layout string?
> Regarding this change, I don't quite understand why referencetypes should 
> take the CPU into account. Are there CPU variants for the wasm backend? I 
> haven't touched the conditional because that would mean touching the several 
> tests that don't enable reference types and use the old data layout string. 
> However, I would think that if that's the path we want to follow here, we 
> could do it and change all wasm tests to use the layout string with reference 
> types.
> 
Yes, there are CPU variants defined here: 
https://github.com/llvm/llvm-project/blob/7ac0442fe59dbe0f9127e79e8786a7dd6345c537/llvm/lib/Target/WebAssembly/WebAssembly.td#L89-L100.
 Note that the CPU may enable reference types even if the feature string does 
not. If it doesn't break anything, then unconditionally updating the layout 
string sounds like the best option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[PATCH] D102356: [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.

2021-06-28 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 355012.
hoy added a comment.
Herald added a subscriber: modimo.

Added tests for static ctor/dtor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102356

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp


Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@
   return mver();
 }
 
+namespace {
+class A {
+public:
+  A() {}
+  ~A() {}
+};
+}
+
+void test() {
+  A a;
+}
+
 // PLAIN: @_ZL4glob = internal global
 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
 // PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() 
#[[#ATTR:]] {
 // UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
 // UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void 
@_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { 
{{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
 if (auto *Fn = dyn_cast(TargetDecl)) {
-  if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+  if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+  llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
 }


Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@
   return mver();
 }
 
+namespace {
+class A {
+public:
+  A() {}
+  ~A() {}
+};
+}
+
+void test() {
+  A a;
+}
+
 // PLAIN: @_ZL4glob = internal global
 // PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
 // PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@
 // UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() #[[#ATTR:]] {
 // UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
 // UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
 // UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { {{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@
   // functions with -funique-internal-linkage-names.
   if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
 if (auto *Fn = dyn_cast(TargetDecl)) {
-  if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+  if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+  llvm::GlobalValue::InternalLinkage)
 FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
 }
___
cfe-commits mailing list

[PATCH] D102728: [clang][Sema] removes -Wfree-nonheap-object reference param false positive

2021-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:10466
 if (isa(D))
-  return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+  if (!isa(D) ||
+  !dyn_cast(D)->getType()->isReferenceType())

cjdb wrote:
> dblaikie wrote:
> > It doesn't look like the parameter case is tested, is it? And is it 
> > necessary? I think it'd be reasonable to warn on `void f1(int i) { 
> > free(); }` - so I think it's only the "is it a reference type" that's the 
> > important property.
> Right, but it's also reasonable to warn on this, which isn't a parameter.
> ```
> int i = 0;
> int& r = i;
> std::free();
> ```
> However, I will take you up on making sure that parameters are tested.
Catching this case seems unlikely to be feasible in a compiler diagnostic - 
because differentiating the false positives and true positives would require 
more complicated analysis than is usually done.

eg: We shouldn't warn on this:
```
int *i = (int*)std::malloc(sizeof(int));
int  = *i;
std::free();
```



Comment at: clang/test/Sema/warn-free-nonheap-object.cpp:13-16
+void free_reference(char ) { ::free(); }
+void free_reference(char &) { ::free(); }
+void std_free_reference(char ) { std::free(); }
+void std_free_reference(char &) { std::free(); }

I probably wouldn't bother testing the combinatorial expansion of all options 
(std versus global, rvalue versus lvalue) - if the features are treated 
orthogonally in the code (there's little chance that some particular 
combination would have a problem if each separately didn't have a problem).

& generally I don't think there's any need to have callers of these functions 
in any context (member function or otherwise - as mentioned further down) - 
clang warnings generally aren't interprocedural, so there's no real risk that 
checking the function alone would result in different results than checking it 
with a caller as well.



Comment at: clang/test/Sema/warn-free-nonheap-object.cpp:69-70
+  {
+char* P = (char *)std::malloc(2);
+free_reference(*P);
+  }

dblaikie wrote:
> I don't think this code is necessary - since clang warnings aren't 
> interprocedural, there's no need to flesh out the example this far - you can 
> have the function standalone elsewhere, that takes a reference parameter and 
> tries to free it after taking its address. Without any caller.
^ ping on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102728

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


[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Vincent LE GARREC via Phabricator via cfe-commits
bansan added a comment.

@kbobyrev Thanks, it's probably that. I thought I could send a patch/commit 
with my Phabricator account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


Re: [clang] e5c7c17 - [clang] Rename StringRef _lower() method calls to _insensitive()

2021-06-28 Thread David Blaikie via cfe-commits
Ah, found it in https://reviews.llvm.org/D104819 - good to leave that in in
the "Differential Revision: " part of the commit message (or if you end up
splitting patches off from a review, such that it doesn't necessarily make
sense for it to close the review (preparatory patches, etc) then linking to
the review without the "Differential Revision: " prefix and/or linking to a
design discussion, etc).

All good - thanks for the renaming!

On Mon, Jun 28, 2021 at 11:38 AM David Blaikie  wrote:

> Was this design/code reviewed (there's no mention in the commit message of
> a link to a phab review, for instance)? Probably worth some discussion - if
> there was a review, could you link it here in a reply?
>
> On Thu, Jun 24, 2021 at 2:23 PM Martin Storsjö via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Martin Storsjö
>> Date: 2021-06-25T00:22:01+03:00
>> New Revision: e5c7c171e5db6af1e3dca1059df4287b0d147eaf
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf.diff
>>
>> LOG: [clang] Rename StringRef _lower() method calls to _insensitive()
>>
>> This is mostly a mechanical change, but a testcase that contains
>> parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp)
>> isn't touched.
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
>> clang/lib/Analysis/CalledOnceCheck.cpp
>> clang/lib/Analysis/RetainSummaryManager.cpp
>> clang/lib/Basic/FileManager.cpp
>> clang/lib/CodeGen/TargetInfo.cpp
>> clang/lib/Driver/Driver.cpp
>> clang/lib/Driver/ToolChains/Arch/RISCV.cpp
>> clang/lib/Driver/ToolChains/Clang.cpp
>> clang/lib/Driver/ToolChains/Fuchsia.cpp
>> clang/lib/Driver/ToolChains/Gnu.cpp
>> clang/lib/Driver/ToolChains/Hexagon.cpp
>> clang/lib/Driver/ToolChains/MSVC.cpp
>> clang/lib/Driver/ToolChains/MinGW.cpp
>> clang/lib/Format/Format.cpp
>> clang/lib/Format/SortJavaScriptImports.cpp
>> clang/lib/Format/UsingDeclarationsSorter.cpp
>> clang/lib/Frontend/CompilerInvocation.cpp
>> clang/lib/Lex/HeaderMap.cpp
>> clang/lib/Lex/PPDirectives.cpp
>> clang/lib/Lex/PPMacroExpansion.cpp
>> clang/lib/Sema/CodeCompleteConsumer.cpp
>> clang/lib/Sema/SemaChecking.cpp
>> clang/lib/Sema/SemaCodeComplete.cpp
>> clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
>> clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
>> clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
>> clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
>> clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
>> clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
>> clang/tools/clang-refactor/TestSupport.cpp
>> clang/tools/clang-scan-deps/ClangScanDeps.cpp
>> clang/tools/driver/driver.cpp
>> clang/tools/libclang/CIndexCodeCompletion.cpp
>> clang/unittests/Tooling/CompilationDatabaseTest.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
>> b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
>> index f6fdbe868e2df..40db70e6f4a51 100644
>> --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
>> +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
>> @@ -20,7 +20,7 @@ getBestGuess(llvm::StringRef Search,
>> llvm::ArrayRef Allowed,
>>  ++MaxEditDistance;
>>llvm::StringRef Res;
>>for (const llvm::StringRef  : Allowed) {
>> -if (Item.equals_lower(Search)) {
>> +if (Item.equals_insensitive(Search)) {
>>assert(!Item.equals(Search) && "This should be handled earlier
>> on.");
>>MaxEditDistance = 1;
>>Res = Item;
>> @@ -40,7 +40,7 @@ getBestGuess(llvm::StringRef Search,
>> llvm::ArrayRef Allowed,
>>auto NoPrefix = Item;
>>if (!NoPrefix.consume_front(DropPrefix))
>>  continue;
>> -  if (NoPrefix.equals_lower(Search)) {
>> +  if (NoPrefix.equals_insensitive(Search)) {
>>  if (NoPrefix.equals(Search))
>>return Item.str();
>>  MaxEditDistance = 1;
>>
>> diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp
>> b/clang/lib/Analysis/CalledOnceCheck.cpp
>> index db094129a9608..661f7b999f2b9 100644
>> --- a/clang/lib/Analysis/CalledOnceCheck.cpp
>> +++ b/clang/lib/Analysis/CalledOnceCheck.cpp
>> @@ -478,7 +478,7 @@ bool mentionsAnyOfConventionalNames(const Expr *E) {
>>  return llvm::any_of(
>>  CONVENTIONAL_CONDITIONS,
>>  [ConditionName](const llvm::StringLiteral ) {
>> -  return ConditionName.contains_lower(Conventional);
>> +  return ConditionName.contains_insensitive(Conventional);
>>  });
>>});
>>  }
>>
>> diff  --git a/clang/lib/Analysis/RetainSummaryManager.cpp
>> 

[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-28 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1138
+
+Ops[0] = TableSet; // The new chain is the TableSet itself
+  }

I was expecting to see a TABLE_SET back to a null after the call here to avoid 
the GC root being leaked in table slot 0 (as above).   I must be missing 
something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes

2021-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> We have a few in `test/Analysis/exploded-graph-rewriter/` where we test parts 
> of the emitted html.

And they're now failing on the pre-merge buildbots. So i guess updating 
existing tests would already be nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104917

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


[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

More buildbot failures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

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


[clang] 1d85d08 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T15:47:21-04:00
New Revision: 1d85d0879a75b9556b10f55739437af8233c0b64

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

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0.
More buildbot failures

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 20f6afa76cbb3..d59bad30e7428 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine , LangOptions );
+  virtual void adjust(LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 4c2859e5eda7f..e73b4a3a40c74 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void TargetInfo::adjust(LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e2..595132e2e70ba 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions ) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e0446905..fe5c61c6ba2bb 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda970222..6860b5e5d02fa 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void PPCTargetInfo::adjust(LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759d..554f2174fee00 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the 

[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2021-06-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Function-wise the patch looks good, but I'm somewhat concerned about silently 
breaking users. At the very least there should be a relevant entry in the 
release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49864

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


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: dexonsmith, dcoughlin, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a reviewer: aaron.ballman.
arphaman requested review of this revision.

This patch adds support for Mac Catalyst availability attribute, as supported 
by the Apple clang compiler. A follow-up patch will provide additional support 
for inferring Mac Catalyst availability from macOS availability using the 
mapping in the SDKSettings.json.


https://reviews.llvm.org/D105052

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenObjC/availability-check-maccatalyst.m
  clang/test/FixIt/fixit-availability-maccatalyst.m
  clang/test/Sema/attr-availability-maccatalyst.c
  clang/test/SemaObjC/unguarded-availability-maccatalyst.m

Index: clang/test/SemaObjC/unguarded-availability-maccatalyst.m
===
--- /dev/null
+++ clang/test/SemaObjC/unguarded-availability-maccatalyst.m
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-ios14.1-macabi -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+#ifdef NO_WARNING
+  // expected-no-diagnostics
+#endif
+
+#define AVAILABLE_PREV __attribute__((availability(macCatalyst, introduced = 13.1)))
+#define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
+#define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+
+typedef struct {
+
+} Record AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+AVAILABLE_PREV
+Record var;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var' with an availability attribute to silence this warnin}}
+#endif
+
+AVAILABLE_NEXT
+Record var2;
+
+void test() {
+  previouslyAvailable();
+  currentlyAvailable();
+  willBeAvailabile();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabile' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
+#endif
+  if (@available(maccatalyst 14.1, *))
+willBeAvailabile(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabile(); // OK
+}
+
+void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
+void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
+void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+void testIOSAvailabilityAlsoWorks() {
+  previouslyAvailableIOS();
+  currentlyAvailableIOS();
+  willBeAvailabileIOS();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabileIOS' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabileIOS' in an @available check to silence this warning}}
+#endif
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabileIOS(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+}
+
+typedef struct {
+
+} Record2 __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+__attribute__((availability(ios, introduced = 10)))
+Record2 var11;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record2' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var11' with an availability attribute to silence this warnin}}
+#endif
+
+__attribute__((availability(ios, introduced = 14.1)))
+Record2 var12;
Index: clang/test/Sema/attr-availability-maccatalyst.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-maccatalyst.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fapplication-extension -D APPEXT 

[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-28 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:130
 TT.isArch64Bit()
-? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
-: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
+? (hasReferenceTypes(FS)
+   ? 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"

tlively wrote:
> `hasReferenceTypes` should also be taking the CPU into account, not just the 
> feature string. Normally this would be done via `getSubtargetImpl`, but I 
> guess we probably can't call that this early in the construction of the 
> `WebAssemblyTargetMachine`. Would anything break if we just unconditionally 
> added the reference types address spaces to the data layout string?
Regarding this change, I don't quite understand why referencetypes should take 
the CPU into account. Are there CPU variants for the wasm backend? I haven't 
touched the conditional because that would mean touching the several tests that 
don't enable reference types and use the old data layout string. However, I 
would think that if that's the path we want to follow here, we could do it and 
change all wasm tests to use the layout string with reference types.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-06-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I thought I sent this batch of comments loong ago =\

Better late than never.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:113-120
+#define FB(Name, K) MIX_##Name = (1ull << (K##ull - 1ull))
+
+  FB(None, 1),  //< Mix between the two parameters is not possible.
+  FB(Trivial, 2),   //< The two mix trivially, and are the exact same type.
+  FB(Canonical, 3), //< The two mix because the types refer to the same
+// CanonicalType, but we do not elaborate as to how.
+

whisperity wrote:
> alexfh wrote:
> > I'd switch to scoped enums (`enum class`), remove the macro, and use 
> > simpler code like `None = 0x1, Trivial = 0x2, Canonical = 0x4`, etc.
> `enum class` is a good idea!
> 
> Unfortunately, I'm not really sold on the hexa literals... It makes the code 
> confusing the read, because you have to keep in mind which range the hexa 
> literals mean, and when there is a shift in position, e.g. if you read `0x20` 
> you have to count out that okay, that's 2nd position, so at least 16, so at 
> least the 4th bit, but it is two, so you shift it again to the right, so in 
> the bit pattern it turns on the 5th bit actually.
> It makes it very easy to misread or misinterpret things, especially when 
> trying to work on the source code.
> (In the last extension patch, the number of elements in the bit mask go up to 
> the 8th or the 9th bit, I don't remember exactly at the top of my head.)
> 
> Compared to this, the current text when read immediately tells you which 
> "decimal" position you should expect the appropriate bit to be toggled on, if 
> the flag is there.
> 
> Binary literals, on the other hand, would be amazing to use here, sadly we're 
> only in C++14.
First of all, do we ever need to know the position of the set bit in these flag 
enumerators? Isn't it enough that each enumerator has a distinct bit set? If 
so, there's not much complexity in reading and expanding sequences like 
`0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 
0x0200, ...`.
However, if that's not to your taste, there's another frequently used style of 
defining flag enumerations in LLVM: `1 << 0, 1 << 1, 1 << 2, 1 << 3, ...`.

Either of these is fine, but using macros for this purpose is not necessary and 
doesn't make the code any easier to read or to modify.

> Compared to this, the current text when read immediately tells you which 
> "decimal" position you should expect the appropriate bit to be toggled on, if 
> the flag is there.
Do I understand correctly that you need this exclusively for the purpose of 
reading debug logs? If so, it seems to be better to decode the bits before 
logging them. See the comment on line 87 above.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:133
+
+  void sanitize() {
+assert(Flags != MIX_Invalid && "sanitize() called on invalid bitvec");

whisperity wrote:
> alexfh wrote:
> > What should this method do and how it should be used? Same for 
> > Mix::sanitize()
> Once there are more flags in the bitmask (not just "None" and "Trivial"), 
> this method deals with sanitising the flags that are toggled on and off by 
> the recursive descent on the type tree.
> 
> For example, if there is a typedef involved (see D95736), it will toggle on 
> the typedef flag, and start investigating the aliased type. This subsequent 
> investigation might figure out that the aliased type is trivial, or it is 
> distinct. In case it is distinct, that level of the recursion will turn on 
> the "Not mixable" flag. In this case, when the investigation returns 
> completely, we will have "Typedef" and "None" both turned on. This method 
> will throw away everything but the "None" bit, so when the data is returned 
> to the diagnostic-generating part of the check, it will know what to do.
Thanks for the explanation! But it would be very helpful to have this 
information in the code, not only in a code review comment.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp:129
+
+void qualified1(int I, const int CI) {} // NO-WARN: Not the same type.
+

whisperity wrote:
> alexfh wrote:
> > Does the top-level const change anything with regard to the "mixability"? 
> > It's a purely implementation-side difference, callers could still swap 
> > parameters.
> Unfortunately, coding styles differ whether people mark local variables const 
> or not, across projects. Even with pointers: in some cases, a swapped call to 
> `memcpy` might be caught if the user made one of the pointers passed already 
> `const void*` instead of just `void*`.
> 
> D95736 deals with implementing the logic for this, it is exposed as a 
> user-configurable option whether they want to consider const stuff the same 
> as non-const stuff.
The `const` in 

[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D104981#2845005 , @bansan wrote:

> @kbobyrev Yes please. I downloaded arc. I created a commit where last line is 
> "Differential Revision: https://reviews.llvm.org/D104981;.
>
> I linked my github account to llvm's phabricator.
>
> But when I `arc land`, I can't logon with my github username.
>
>STRATEGY  Merging with "squash" strategy, the default strategy.
>SOURCE  Landing the current branch, "main".
>ONTO REMOTE  Remote "origin" was selected by following tracking branches 
> upstream to the closest remote.
>ONTO TARGET  Refs were selected by reading "arc.land.onto" configuration: 
> main.
>INTO REMOTE  Will merge into remote "origin" by default, because this is 
> the remote the change is landing onto.
>INTO TARGET  Will merge into target "main" by default, because this is the 
> "onto" target.
>FETCH  Fetching "main" from remote "origin"...
>   
> $   git fetch --no-tags --quiet -- origin main
>   
>   
>INTO COMMIT  Preparing merge into "main" from remote "origin", at commit 
> "614b46e4dcab".
>LANDING  These changes will land:
>   
> *   D104981 [clang-tidy] Add -line-filter to run-clang-tidy.py
> 0610f15fab16  [clang-tidy] Add -line-filter to run-clang-tidy.py
>   
>>>>  Land these changes? [y/N/?] y
>MERGING  0610f15fab16 [clang-tidy] Add -line-filter to run-clang-tidy.py
>MERGE  Attempting to rebase changes.
>DONE  Merge succeeded.
>PUSHING  Pushing changes to "origin".
>   
> $   git push -- origin 6adf32fecc25:refs/heads/main
>   
>   Username for 'https://github.com': bansan85
>   Password for 'https://bansa...@github.com':
>   remote: Permission to llvm/llvm-project.git denied to bansan85.
>   fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The 
> requested URL returned error: 403
>   
>LOAD STATE  Restoring local state (to ref "main" at commit "0610f15fab16").
>USAGE EXCEPTION  Push failed! Fix the error and run "arc land" again.
>
> I try to follow 
> https://github.com/llvm/llvm-project/blob/main/llvm/docs/Phabricator.rst but 
> I don't know what I missed.
>
> Thanks,

Landed the patch!

I think the problem is that you do not have the commit access yet. Here's how 
to get it: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe837ce2a3236: [clang-tidy] Add -line-filter to 
run-clang-tidy.py (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,13 +81,16 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config):
+extra_arg, extra_arg_before, quiet, config,
+line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
+  if line_filter is not None:
+start.append('-line-filter=' + line_filter)
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:
@@ -165,7 +168,7 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config)
+ args.quiet, args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -209,6 +212,9 @@
   'headers to output diagnostics from. Diagnostics from '
   'the main file of each translation unit are always '
   'displayed.')
+  parser.add_argument('-line-filter', default=None,
+  help='List of files with line ranges to filter the'
+  'warnings.')
   if yaml:
 parser.add_argument('-export-fixes', metavar='filename', 
dest='export_fixes',
 help='Create a yaml file to store suggested fixes in, '


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,13 +81,16 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config):
+extra_arg, extra_arg_before, quiet, config,
+line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
+  if line_filter is not None:
+start.append('-line-filter=' + line_filter)
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:
@@ -165,7 +168,7 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config)
+ args.quiet, args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -209,6 +212,9 @@
   'headers to output diagnostics from. Diagnostics from '
   'the main file of each translation unit are always '
   'displayed.')
+  parser.add_argument('-line-filter', default=None,
+  help='List of files with line ranges to filter the'
+  'warnings.')
   if yaml:
 parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes',
 help='Create a yaml file to store suggested fixes in, '
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e837ce2 - [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-06-28T21:17:36+02:00
New Revision: e837ce2a32369b2e9e8e5d60270c072c7dd63827

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

LOG: [clang-tidy] Add -line-filter to run-clang-tidy.py

This patch allows the use of --line-filter in clang-tidy.py from
run-clang-tidy.py

Author: [bansan (Vincent LE GARREC)](https://reviews.llvm.org/p/bansan/)

Reviewed By: kbobyrev

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 313ecd2f95716..de810230b2852 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,13 +81,16 @@ def make_absolute(f, directory):
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config):
+extra_arg, extra_arg_before, quiet, config,
+line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
+  if line_filter is not None:
+start.append('-line-filter=' + line_filter)
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:
@@ -165,7 +168,7 @@ def run_tidy(args, tmpdir, build_path, queue, lock, 
failed_files):
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config)
+ args.quiet, args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -209,6 +212,9 @@ def main():
   'headers to output diagnostics from. Diagnostics from '
   'the main file of each translation unit are always '
   'displayed.')
+  parser.add_argument('-line-filter', default=None,
+  help='List of files with line ranges to filter the'
+  'warnings.')
   if yaml:
 parser.add_argument('-export-fixes', metavar='filename', 
dest='export_fixes',
 help='Create a yaml file to store suggested fixes in, '



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


[PATCH] D105049: [NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h

2021-06-28 Thread Evan Wilde via Phabricator via cfe-commits
etcwilde created this revision.
etcwilde added a reviewer: compnerd.
etcwilde added a project: clang.
etcwilde requested review of this revision.
Herald added a subscriber: cfe-commits.

There are some trailing semicolons on namespaces in 
clang/lib/APINotes/APINotesFormat.h.
These result in warnings while building and don't need to be there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105049

Files:
  clang/lib/APINotes/APINotesFormat.h


Index: clang/lib/APINotes/APINotesFormat.h
===
--- clang/lib/APINotes/APINotesFormat.h
+++ clang/lib/APINotes/APINotesFormat.h
@@ -220,7 +220,7 @@
   // below)
  llvm::BCBlob // map from name to tag information
  >;
-}; // namespace tag_block
+} // namespace tag_block
 
 namespace typedef_block {
 enum { TYPEDEF_DATA = 1 };
@@ -231,7 +231,7 @@
   // below)
  llvm::BCBlob // map from name to typedef information
  >;
-}; // namespace typedef_block
+} // namespace typedef_block
 
 namespace enum_constant_block {
 enum { ENUM_CONSTANT_DATA = 1 };


Index: clang/lib/APINotes/APINotesFormat.h
===
--- clang/lib/APINotes/APINotesFormat.h
+++ clang/lib/APINotes/APINotesFormat.h
@@ -220,7 +220,7 @@
   // below)
  llvm::BCBlob // map from name to tag information
  >;
-}; // namespace tag_block
+} // namespace tag_block
 
 namespace typedef_block {
 enum { TYPEDEF_DATA = 1 };
@@ -231,7 +231,7 @@
   // below)
  llvm::BCBlob // map from name to typedef information
  >;
-}; // namespace typedef_block
+} // namespace typedef_block
 
 namespace enum_constant_block {
 enum { ENUM_CONSTANT_DATA = 1 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2dbe1c675fe9: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D104729?vs=354932=354981#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -704,7 +704,7 @@
   if (!instance->hasTarget())
 return nullptr;
 
-  instance->getTarget().adjust(instance->getLangOpts());
+  instance->getTarget().adjust(*diagnostics_engine, instance->getLangOpts());
 
   if (!action->BeginSourceFile(*instance,
instance->getFrontendOpts().Inputs[0]))
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -658,7 +658,8 @@
   //
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  m_compiler->getTarget().adjust(m_compiler->getLangOpts());
+  m_compiler->getTarget().adjust(m_compiler->getDiagnostics(),
+		 m_compiler->getLangOpts());
 
   // 6. Set up the diagnostic buffer for reporting errors
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.

[clang] 2dbe1c6 - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T15:09:53-04:00
New Revision: 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0

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

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e7428..20f6afa76cbb3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c74..4c2859e5eda7f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70ba..fac786dbcf9e2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2bb..244a6e0446905 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02fa..d431dda970222 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee00..18ee1194c759d 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option 

[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

buildbot fails in lldb, will submit updates


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

buildbot fails on lldb need to update this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

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


[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

2021-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-28 Thread Vincent LE GARREC via Phabricator via cfe-commits
bansan added a comment.

@kbobyrev Yes please. I downloaded arc. I created a commit where last line is 
"Differential Revision: https://reviews.llvm.org/D104981;.

I linked my github account to llvm's phabricator.

But when I `arc land`, I can't logon with my github username.

   STRATEGY  Merging with "squash" strategy, the default strategy.
   SOURCE  Landing the current branch, "main".
   ONTO REMOTE  Remote "origin" was selected by following tracking branches 
upstream to the closest remote.
   ONTO TARGET  Refs were selected by reading "arc.land.onto" configuration: 
main.
   INTO REMOTE  Will merge into remote "origin" by default, because this is the 
remote the change is landing onto.
   INTO TARGET  Will merge into target "main" by default, because this is the 
"onto" target.
   FETCH  Fetching "main" from remote "origin"...
  
$   git fetch --no-tags --quiet -- origin main
  
  
   INTO COMMIT  Preparing merge into "main" from remote "origin", at commit 
"614b46e4dcab".
   LANDING  These changes will land:
  
*   D104981 [clang-tidy] Add -line-filter to run-clang-tidy.py
0610f15fab16  [clang-tidy] Add -line-filter to run-clang-tidy.py
  
   >>>  Land these changes? [y/N/?] y
   MERGING  0610f15fab16 [clang-tidy] Add -line-filter to run-clang-tidy.py
   MERGE  Attempting to rebase changes.
   DONE  Merge succeeded.
   PUSHING  Pushing changes to "origin".
  
$   git push -- origin 6adf32fecc25:refs/heads/main
  
  Username for 'https://github.com': bansan85
  Password for 'https://bansa...@github.com':
  remote: Permission to llvm/llvm-project.git denied to bansan85.
  fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The 
requested URL returned error: 403
  
   LOAD STATE  Restoring local state (to ref "main" at commit "0610f15fab16").
   USAGE EXCEPTION  Push failed! Fix the error and run "arc land" again.

I try to follow 
https://github.com/llvm/llvm-project/blob/main/llvm/docs/Phabricator.rst but I 
don't know what I missed.

Thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


[PATCH] D104975: Implement P1949

2021-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 354973.
cor3ntin added a comment.

Fix clang tidy check, update cxx_status


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/UnicodeCharSets.h
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/FixIt/fixit-unicode.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Preprocessor/utf8-allowed-chars.c
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1311,7 +1311,7 @@
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7;>P1949R7
-  No
+  Clang 13
 
 
   Mixed string literal concatenation
Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -23,46 +23,30 @@
 
 
 
-
-
-
-
 #if __cplusplus
-# if __cplusplus >= 201103L
-// C++11
-// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
+// expected-error@11 {{not allowed in identifiers}}
+// expected-error@13 {{not allowed in identifiers}}
+// expected-error@20 {{expected unqualified-id}}
 // expected-error@21 {{expected unqualified-id}}
 
-# else
-// C++03
-// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@10 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
-
-# endif
 #else
 # if __STDC_VERSION__ >= 201112L
 // C11
 // expected-warning@9 {{using this character in an identifier is incompatible with C99}}
 // expected-warning@11 {{using this character in an identifier is incompatible with C99}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@13 {{not allowed in identifiers}}
 // expected-warning@14 {{using this character in an identifier is incompatible with C99}}
 // expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
 // expected-error@21 {{expected identifier}}
 
 # else
 // C99
-// expected-error@9 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@11 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-error@14 {{non-ASCII characters are not allowed outside of literals and identifiers}}
+// expected-error@9 {{not allowed in identifiers}}
+// expected-error@11 {{not allowed in identifiers}}
+// expected-error@13 {{allowed in identifiers}}
+// expected-error@14 {{not allowed in identifiers}}
 // expected-error@20 {{expected identifier}}
-// expected-error@21 {{non-ASCII characters are not allowed outside of literals and identifiers}} expected-warning@21 {{declaration does not declare anything}}
+// expected-error@21 {{not allowed in identifiers}} expected-warning@21 {{declaration does not declare anything}}
 
 # endif
 #endif
Index: clang/test/Preprocessor/ucn-allowed-chars.c
===
--- clang/test/Preprocessor/ucn-allowed-chars.c
+++ clang/test/Preprocessor/ucn-allowed-chars.c
@@ -16,7 +16,7 @@
 
 // Identifier initial characters
 extern char \u0E50; // C++03, C11, C++11
-extern char \u0300; // disallowed initially in C11/C++11, always in C99/C++03
+extern char \u0300; // disallowed in C99/C++03
 extern char \u0D61; // C99, C11, C++03, C++11
 
 
@@ -38,19 +38,16 @@
 
 
 #if __cplusplus
+// expected-error@9 {{expected ';'}}
+// expected-error@11 {{expected ';'}}
+// expected-error@18 {{expected unqualified-id}}
 # if __cplusplus >= 201103L
 // C++11
-// expected-warning@7 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@8 {{using this character in an identifier is incompatible with C++98}}
-// 

[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG614b46e4dcab: [clangd] Add a flag to disable formatting of 
tweak edits (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105039

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -18,12 +18,14 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "URI.h"
+#include "refactor/Tweak.h"
 #include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -31,6 +33,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -1259,6 +1262,60 @@
   ASSERT_TRUE(MT.children().count("tuscheduler"));
   EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
 }
+
+TEST(ClangdServer, RespectsTweakFormatting) {
+  static constexpr const char *TweakID = "ModuleTweak";
+  static constexpr const char *NewContents = "{not;\nformatted;}";
+
+  // Contributes a tweak that generates a non-formatted insertion and disables
+  // formatting.
+  struct TweakContributingModule final : public FeatureModule {
+struct ModuleTweak final : public Tweak {
+  const char *id() const override { return TweakID; }
+  bool prepare(const Selection ) override { return true; }
+  Expected apply(const Selection ) override {
+auto  = Sel.AST->getSourceManager();
+llvm::StringRef FilePath = SM.getFilename(Sel.Cursor);
+tooling::Replacements Reps;
+llvm::cantFail(
+Reps.add(tooling::Replacement(FilePath, 0, 0, NewContents)));
+auto E = llvm::cantFail(Effect::mainFileEdit(SM, std::move(Reps)));
+E.FormatEdits = false;
+return E;
+  }
+  std::string title() const override { return id(); }
+  llvm::StringLiteral kind() const override {
+return llvm::StringLiteral("");
+  };
+};
+
+void contributeTweaks(std::vector> ) override {
+  Out.emplace_back(new ModuleTweak);
+}
+  };
+
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  auto Opts = ClangdServer::optsForTest();
+  FeatureModuleSet Set;
+  Set.add(std::make_unique());
+  Opts.FeatureModules = 
+  ClangdServer Server(CDB, FS, Opts);
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  // Ensure that disabled formatting is respected.
+  Notification N;
+  Server.applyTweak(FooCpp, {}, TweakID, [&](llvm::Expected E) {
+ASSERT_TRUE(static_cast(E));
+EXPECT_THAT(llvm::cantFail(E->ApplyEdits.lookup(FooCpp).apply()),
+NewContents);
+N.notify();
+  });
+  N.wait();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto  : (*Effect)->ApplyEdits) {
 Edit  = It.second;
 format::FormatStyle Style =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 614b46e - [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-06-28T20:52:47+02:00
New Revision: 614b46e4dcab0d095e05f8b4da45ef935b7b86b4

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

LOG: [clangd] Add a flag to disable formatting of tweak edits

Some tweaks might edit file types not supported by clang-format. This
patch gives them a way to signal that they do not require formatting.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 0f525f3b9a0a4..1e722086e2e04 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, 
StringRef TweakID,
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto  : (*Effect)->ApplyEdits) {
 Edit  = It.second;
 format::FormatStyle Style =

diff  --git a/clang-tools-extra/clangd/refactor/Tweak.h 
b/clang-tools-extra/clangd/refactor/Tweak.h
index 60ee34d138d6b..5b2d9cc80d9fd 100644
--- a/clang-tools-extra/clangd/refactor/Tweak.h
+++ b/clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@ class Tweak {
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;

diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index 49e1f7aa93b67..07f5da1fbc52f 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -18,12 +18,14 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "URI.h"
+#include "refactor/Tweak.h"
 #include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -31,6 +33,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -1259,6 +1262,60 @@ TEST(ClangdServer, MemoryUsageTest) {
   ASSERT_TRUE(MT.children().count("tuscheduler"));
   EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
 }
+
+TEST(ClangdServer, RespectsTweakFormatting) {
+  static constexpr const char *TweakID = "ModuleTweak";
+  static constexpr const char *NewContents = "{not;\nformatted;}";
+
+  // Contributes a tweak that generates a non-formatted insertion and disables
+  // formatting.
+  struct TweakContributingModule final : public FeatureModule {
+struct ModuleTweak final : public Tweak {
+  const char *id() const override { return TweakID; }
+  bool prepare(const Selection ) override { return true; }
+  Expected apply(const Selection ) override {
+auto  = Sel.AST->getSourceManager();
+llvm::StringRef FilePath = SM.getFilename(Sel.Cursor);
+tooling::Replacements Reps;
+llvm::cantFail(
+Reps.add(tooling::Replacement(FilePath, 0, 0, NewContents)));
+auto E = llvm::cantFail(Effect::mainFileEdit(SM, std::move(Reps)));
+E.FormatEdits = false;
+return E;
+  }
+  std::string title() const override { return id(); }
+  llvm::StringLiteral kind() const override {
+return llvm::StringLiteral("");
+  };
+};
+
+void contributeTweaks(std::vector> ) override {
+  Out.emplace_back(new ModuleTweak);
+}
+  };
+
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  auto Opts = ClangdServer::optsForTest();
+  FeatureModuleSet Set;
+  Set.add(std::make_unique());
+  Opts.FeatureModules = 
+  ClangdServer Server(CDB, FS, Opts);
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  // Ensure that disabled formatting is respected.
+  Notification 

[clang] 280593b - [Clang] [NFC] fix CHECK lines for convergent attribute tests

2021-06-28 Thread Sameer Sahasrabuddhe via cfe-commits

Author: Sameer Sahasrabuddhe
Date: 2021-06-29T00:21:07+05:30
New Revision: 280593bd3ff1db6d19ccb8182698dd9c816734e2

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

LOG: [Clang] [NFC] fix CHECK lines for convergent attribute tests

Added: 


Modified: 
clang/test/CodeGen/convergent-functions.cpp
clang/test/CodeGenCUDA/convergent.cu
clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip

Removed: 




diff  --git a/clang/test/CodeGen/convergent-functions.cpp 
b/clang/test/CodeGen/convergent-functions.cpp
index 7ddb8d3f94501..cb8682474f931 100644
--- a/clang/test/CodeGen/convergent-functions.cpp
+++ b/clang/test/CodeGen/convergent-functions.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -fconvergent-functions -o 
- < %s | FileCheck -check-prefix=CONVFUNC %s
-// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -o - < %s | FileCheck 
-check-prefix=NOCONVFUNC %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -fconvergent-functions -o 
- < %s | FileCheck -check-prefixes=CHECK,CONVFUNC %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -o - < %s | FileCheck 
-check-prefixes=CHECK,NOCONVFUNC %s
 
 // Test that the -fconvergent-functions flag works
 
-// CONVFUNC: attributes #0 = { convergent {{.*}} }
+// CHECK: attributes #0 = {
 // NOCONVFUNC-NOT: convergent
+// CONVFUNC-SAME: convergent
+// CHECK-SAME: }
 void func() { }

diff  --git a/clang/test/CodeGenCUDA/convergent.cu 
b/clang/test/CodeGenCUDA/convergent.cu
index ff18f92ef1eae..5d98d4ba69262 100644
--- a/clang/test/CodeGenCUDA/convergent.cu
+++ b/clang/test/CodeGenCUDA/convergent.cu
@@ -42,4 +42,4 @@ __host__ __device__ void bar() {
 // HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
 // HOST: attributes [[BAZ_ATTR]] = {
 // HOST-NOT: convergent
-// NOST-SAME: }
+// HOST-SAME: }

diff  --git a/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip 
b/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
index 9e3e436200fc3..ee4c585cb5d7c 100644
--- a/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
+++ b/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
@@ -15,4 +15,4 @@ __device__ float foo(float x) {
 // CHECK: attributes [[ATTR1]] = { convergent
 // CHECK: attributes [[ATTR2]] = {
 // CHECK-NOT: convergent
-// CHECK: }
+// CHECK-SAME: }



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


[PATCH] D102728: [clang][Sema] removes -Wfree-nonheap-object reference param false positive

2021-06-28 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Oops, looks like I never submitted my replies!




Comment at: clang/lib/Sema/SemaChecking.cpp:10466
 if (isa(D))
-  return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+  if (!isa(D) ||
+  !dyn_cast(D)->getType()->isReferenceType())

dblaikie wrote:
> It doesn't look like the parameter case is tested, is it? And is it 
> necessary? I think it'd be reasonable to warn on `void f1(int i) { free(); 
> }` - so I think it's only the "is it a reference type" that's the important 
> property.
Right, but it's also reasonable to warn on this, which isn't a parameter.
```
int i = 0;
int& r = i;
std::free();
```
However, I will take you up on making sure that parameters are tested.



Comment at: clang/test/Sema/warn-free-nonheap-object.cpp:38-40
+  char *ptr1 = (char *)std::malloc(10);
+  char *ptr2 = (char *)std::malloc(10);
+  char *ptr3 = (char *)std::malloc(10);

dblaikie wrote:
> Is it relevant that these are members? Or could they be globals just as well? 
> Might be simpler/more obvious if they were globals, I think.
This tests that members aren't overlooked, which has a distinct code path to 
normal variables IIRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102728

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


Re: [clang] e5c7c17 - [clang] Rename StringRef _lower() method calls to _insensitive()

2021-06-28 Thread David Blaikie via cfe-commits
Was this design/code reviewed (there's no mention in the commit message of
a link to a phab review, for instance)? Probably worth some discussion - if
there was a review, could you link it here in a reply?

On Thu, Jun 24, 2021 at 2:23 PM Martin Storsjö via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Martin Storsjö
> Date: 2021-06-25T00:22:01+03:00
> New Revision: e5c7c171e5db6af1e3dca1059df4287b0d147eaf
>
> URL:
> https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf
> DIFF:
> https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf.diff
>
> LOG: [clang] Rename StringRef _lower() method calls to _insensitive()
>
> This is mostly a mechanical change, but a testcase that contains
> parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp)
> isn't touched.
>
> Added:
>
>
> Modified:
> clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
> clang/lib/Analysis/CalledOnceCheck.cpp
> clang/lib/Analysis/RetainSummaryManager.cpp
> clang/lib/Basic/FileManager.cpp
> clang/lib/CodeGen/TargetInfo.cpp
> clang/lib/Driver/Driver.cpp
> clang/lib/Driver/ToolChains/Arch/RISCV.cpp
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/lib/Driver/ToolChains/Fuchsia.cpp
> clang/lib/Driver/ToolChains/Gnu.cpp
> clang/lib/Driver/ToolChains/Hexagon.cpp
> clang/lib/Driver/ToolChains/MSVC.cpp
> clang/lib/Driver/ToolChains/MinGW.cpp
> clang/lib/Format/Format.cpp
> clang/lib/Format/SortJavaScriptImports.cpp
> clang/lib/Format/UsingDeclarationsSorter.cpp
> clang/lib/Frontend/CompilerInvocation.cpp
> clang/lib/Lex/HeaderMap.cpp
> clang/lib/Lex/PPDirectives.cpp
> clang/lib/Lex/PPMacroExpansion.cpp
> clang/lib/Sema/CodeCompleteConsumer.cpp
> clang/lib/Sema/SemaChecking.cpp
> clang/lib/Sema/SemaCodeComplete.cpp
> clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
> clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
> clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
> clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
> clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
> clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
> clang/tools/clang-refactor/TestSupport.cpp
> clang/tools/clang-scan-deps/ClangScanDeps.cpp
> clang/tools/driver/driver.cpp
> clang/tools/libclang/CIndexCodeCompletion.cpp
> clang/unittests/Tooling/CompilationDatabaseTest.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
> b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
> index f6fdbe868e2df..40db70e6f4a51 100644
> --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
> +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
> @@ -20,7 +20,7 @@ getBestGuess(llvm::StringRef Search,
> llvm::ArrayRef Allowed,
>  ++MaxEditDistance;
>llvm::StringRef Res;
>for (const llvm::StringRef  : Allowed) {
> -if (Item.equals_lower(Search)) {
> +if (Item.equals_insensitive(Search)) {
>assert(!Item.equals(Search) && "This should be handled earlier
> on.");
>MaxEditDistance = 1;
>Res = Item;
> @@ -40,7 +40,7 @@ getBestGuess(llvm::StringRef Search,
> llvm::ArrayRef Allowed,
>auto NoPrefix = Item;
>if (!NoPrefix.consume_front(DropPrefix))
>  continue;
> -  if (NoPrefix.equals_lower(Search)) {
> +  if (NoPrefix.equals_insensitive(Search)) {
>  if (NoPrefix.equals(Search))
>return Item.str();
>  MaxEditDistance = 1;
>
> diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp
> b/clang/lib/Analysis/CalledOnceCheck.cpp
> index db094129a9608..661f7b999f2b9 100644
> --- a/clang/lib/Analysis/CalledOnceCheck.cpp
> +++ b/clang/lib/Analysis/CalledOnceCheck.cpp
> @@ -478,7 +478,7 @@ bool mentionsAnyOfConventionalNames(const Expr *E) {
>  return llvm::any_of(
>  CONVENTIONAL_CONDITIONS,
>  [ConditionName](const llvm::StringLiteral ) {
> -  return ConditionName.contains_lower(Conventional);
> +  return ConditionName.contains_insensitive(Conventional);
>  });
>});
>  }
>
> diff  --git a/clang/lib/Analysis/RetainSummaryManager.cpp
> b/clang/lib/Analysis/RetainSummaryManager.cpp
> index 58ead1dfe3522..7ed1e40333f43 100644
> --- a/clang/lib/Analysis/RetainSummaryManager.cpp
> +++ b/clang/lib/Analysis/RetainSummaryManager.cpp
> @@ -189,20 +189,22 @@ static bool hasRCAnnotation(const Decl *D, StringRef
> rcAnnotation) {
>  }
>
>  static bool isRetain(const FunctionDecl *FD, StringRef FName) {
> -  return FName.startswith_lower("retain") ||
> FName.endswith_lower("retain");
> +  return FName.startswith_insensitive("retain") ||
> + FName.endswith_insensitive("retain");
>  }
>
>  static bool isRelease(const FunctionDecl *FD, StringRef FName) {
> -  return 

[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes

2021-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yay, great, thanks!

Can you add a test as well? We have a few in 
`test/Analysis/exploded-graph-rewriter/` where we test parts of the emitted 
html.

Do you happen to have a screenshot of how it looks?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104917

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


[PATCH] D104550: [analyzer] Implement getType for SVal

2021-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Amazing, thanks!!




Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:213
+  /// bound expression AST node as well, since AST always has exact types.
+  QualType getType(const ASTContext &) const;
 };

I'm also in favor of a note that says "Loc values are interpreted as pointer 
rvalues for the purposes of this method" or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104550

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


[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

2021-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks! Why isn't this a `NoteTag`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

@cor3ntin do you have any interest in making a similar patch for the LWG 
issues? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[PATCH] D105017: [analyzer] LValueToRValueBitCasts should evaluate to an r-value

2021-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks, nice! More stuff to support.




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:307
 
   if (CastE->getCastKind() == CK_LValueToRValue) {
 for (ExplodedNodeSet::iterator I = dstPreStmt.begin(), E = 
dstPreStmt.end();

How difficult would it be to handle the cast properly by adding it to this 
branch, except eventually passing the right type to `getSVal(R, ...)` inside 
`evalLoad()`?



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:543
   case CK_VectorSplat: {
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;

You didn't start it but that's, ugh, not a great name for the function to 
handle the new cast.

I wouldn't mind eliminating the function entirely and inlining the 
implementation as it actually makes the code easier to read, for once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105017

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


[PATCH] D104883: [CodeGen] Add ParmVarDecls to FunctionDecls that are created to generate ObjC property getter/setter functions

2021-06-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I'll wait a day or two in case someone else has feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104883

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


[PATCH] D105024: Add papers adopted by the C++ committee in the June 2021 plenary.

2021-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in 18c3c7784975700ae463bb461487d46e74324a66 
, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105024

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


[clang] 18c3c77 - Add papers adopted by the C++ committee in the June 2021 plenary

2021-06-28 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-06-28T13:45:12-04:00
New Revision: 18c3c7784975700ae463bb461487d46e74324a66

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

LOG: Add papers adopted by the C++ committee in the June 2021 plenary

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index b7f2501cbc534..8de688189e297 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1283,6 +1283,41 @@ C++2b implementation status
   https://wg21.link/p2266r1;>P2266R1
   Clang 13
 
+
+  if consteval
+  https://wg21.link/P1938R3;>P1938R3
+  No
+
+
+  Allow duplicate attributes
+  https://wg21.link/P2156R1;>P2156R1
+  Clang 13
+
+
+  Narrowing contextual conversions to bool
+  https://wg21.link/P1401R5;>P1401R5
+  No
+
+
+  Trimming whitespaces before line splicing
+  https://wg21.link/P2223R2;>P2223R2
+  Yes
+
+
+  Make declaration order layout mandated
+  https://wg21.link/p1847r4;>P1874R4
+  Yes
+
+
+  C++ identifier syntax using UAX 31
+  https://wg21.link/P1949R7;>P1949R7
+  No
+
+
+  Mixed string literal concatenation
+  https://wg21.link/p2201r1;>P2201R1
+  Yes
+
 
 
 



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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2021-06-28 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D86049#2844766 , @dmaclach wrote:

> Has anything happened with this at all or did it get dropped?

I can work with you and @rjmccall to land a version of this. We can chat 
offline if you'd like too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2021-06-28 Thread Dave MacLachlan via Phabricator via cfe-commits
dmaclach added a comment.

Has anything happened with this at all or did it get dropped?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-06-28 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 354945.
pmatos added a comment.

Checks for inttoptr and ptrtoint insts in wasm backend and bails out if 
necessary.

Also addresses @tlively's comments to the original patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+%extern = type opaque
+%externref = type %extern addrspace(10)*
+
+define 

[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 354941.
kadircet added a comment.

Add a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105039

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -18,12 +18,14 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "URI.h"
+#include "refactor/Tweak.h"
 #include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -31,6 +33,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -1259,6 +1262,60 @@
   ASSERT_TRUE(MT.children().count("tuscheduler"));
   EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
 }
+
+TEST(ClangdServer, RespectsTweakFormatting) {
+  static constexpr const char *TweakID = "ModuleTweak";
+  static constexpr const char *NewContents = "{not;\nformatted;}";
+
+  // Contributes a tweak that generates a non-formatted insertion and disables
+  // formatting.
+  struct TweakContributingModule final : public FeatureModule {
+struct ModuleTweak final : public Tweak {
+  const char *id() const override { return TweakID; }
+  bool prepare(const Selection ) override { return true; }
+  Expected apply(const Selection ) override {
+auto  = Sel.AST->getSourceManager();
+llvm::StringRef FilePath = SM.getFilename(Sel.Cursor);
+tooling::Replacements Reps;
+llvm::cantFail(
+Reps.add(tooling::Replacement(FilePath, 0, 0, NewContents)));
+auto E = llvm::cantFail(Effect::mainFileEdit(SM, std::move(Reps)));
+E.FormatEdits = false;
+return E;
+  }
+  std::string title() const override { return id(); }
+  llvm::StringLiteral kind() const override {
+return llvm::StringLiteral("");
+  };
+};
+
+void contributeTweaks(std::vector> ) override {
+  Out.emplace_back(new ModuleTweak);
+}
+  };
+
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  auto Opts = ClangdServer::optsForTest();
+  FeatureModuleSet Set;
+  Set.add(std::make_unique());
+  Opts.FeatureModules = 
+  ClangdServer Server(CDB, FS, Opts);
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  // Ensure that disabled formatting is respected.
+  Notification N;
+  Server.applyTweak(FooCpp, {}, TweakID, [&](llvm::Expected E) {
+ASSERT_TRUE(static_cast(E));
+EXPECT_THAT(llvm::cantFail(E->ApplyEdits.lookup(FooCpp).apply()),
+NewContents);
+N.notify();
+  });
+  N.wait();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto  : (*Effect)->ApplyEdits) {
 Edit  = It.second;
 format::FormatStyle Style =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104946: [AMDGPU] Add builtin functions image_bvh_intersect_ray

2021-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:221-224
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, 
"V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, 
"V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, 
"V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
+TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, 
"V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")

arsenm wrote:
> The intrinsic signature suggests the 1st and 4th/5th arguments are 
> overloadable. How does this handle the various supported types?
By convention, we do not define overloaded target specific clang builtins. In 
stead we use postfixes to indicate the types. In this case, we use the 
following naming convention:

h - 4/5-th args are half
d - 4/5-th args are double
l - first arg is i64

by default - 1st arg is i32, 4/5-th args are float.

Currently we are missing functions for 4/5-th args are double. I will add them.



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

https://reviews.llvm.org/D104946

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


[clang] c27e5a2 - Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70

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

LOG: Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option 
fprotect-parens"

This reverts commit 4f1238e44d803b145997fa984677a6c5cdf1f417.
Buildbot fails on predecessor patch

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Driver/clang_f_opts.c

Removed: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 9e8bac635337..244212a1336d 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,26 +1478,6 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
-.. option:: -f[no-]protect-parens:
-
-   This option pertains to floating-point types, complex types with
-   floating-point components, and vectors of these types. Some arithmetic
-   expression transformations that are mathematically correct and permissible
-   according to the C and C++ language standards may be incorrect when dealing
-   with floating-point types, such as reassociation and distribution. Further,
-   the optimizer may ignore parentheses when computing arithmetic expressions
-   in circumstances where the parenthesized and unparenthesized expression
-   express the same mathematical value. For example (a+b)+c is the same
-   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
-   additions in any order regardless of the parentheses. When enabled, this
-   option forces the optimizer to honor the order of operations with respect
-   to parentheses in all circumstances.
-
-   Note that floating-point contraction (option `-ffp-contract=`) is disabled
-   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
-   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
-   has no effect because the optimizer is prohibited from making unsafe
-   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 33d3e6dc4e7d..5a9d0a001829 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,9 +1657,6 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
 
-// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
-LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
-
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 22c2a1a39ea1..70a22fd2506a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,9 +8530,6 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
-def err_typecheck_expect_flt_or_vector : Error<
-  "invalid operand of type %0 where floating, complex or "
-  "a vector of such types is required">;
 def err_cast_selector_expr : Error<
   "cannot type cast @selector expression">;
 def ext_typecheck_cond_incompatible_pointers : ExtWarn<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b18e957a58f4..465bad8d7d11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -199,8 +199,6 @@ COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED 

[clang] 8815ef8 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: 8815ef823c803e98f328068d1abde255296de9c3

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

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2c02b0c3f45414ac6c64583e006a26113c028304.
buildbot fails

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 4f0cbf986b31..0e984eb29b81 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine , LangOptions );
+  virtual void adjust(LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 88086fa2fed7..ffd88dc75dba 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void TargetInfo::adjust(LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e..595132e2e70b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions ) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e044690..fe5c61c6ba2b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda97022..6860b5e5d02f 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void PPCTargetInfo::adjust(LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759..554f2174fee0 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   // Note: GCC 

[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a subscriber: rupprecht.
aaronpuchert added a comment.

In D104261#2841356 , @delesley wrote:

> since it's restricted to relockable managed locks, I'm not too worried...

Not quite, it affects scoped locks with explicit unlock, which was supported 
before D49885 .

@rupprecht, can you still test patches on Google's code? Would be good to know 
if this breaks anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104261

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f1238e44d80: [clang][patch][fpenv] Add builtin 
__arithmetic_fence and option fprotect-parens (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence();
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// 

[PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c02b0c3f454: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104729

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -138,7 +138,7 @@
 
   bool hasProtectedVisibility() const override { return false; }
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -234,7 +234,8 @@
  Builtin::FirstTSBuiltin);
 }
 
-void WebAssemblyTargetInfo::adjust(LangOptions ) {
+void WebAssemblyTargetInfo::adjust(DiagnosticsEngine ,
+   LangOptions ) {
   // If the Atomics feature isn't available, turn off POSIXThreads and
   // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
   if (!HasAtomics) {
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -135,8 +135,8 @@
 AddrSpaceMap = DefaultIsGeneric ?  : 
   }
 
-  void adjust(LangOptions ) override {
-TargetInfo::adjust(Opts);
+  void adjust(DiagnosticsEngine , LangOptions ) override {
+  

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG931e95687d6d: [llvm][clang][fpenv] Create new intrinsic 
llvm.arith.fence to control FP… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0

[clang] 4f1238e - [clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 4f1238e44d803b145997fa984677a6c5cdf1f417

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

LOG: [clang][patch][fpenv] Add builtin __arithmetic_fence and option 
fprotect-parens

This patch adds a new clang builtin, __arithmetic_fence. The purpose of the
builtin is to provide the user fine control, at the expression level, over
floating point optimization when -ffast-math (-ffp-model=fast) is enabled.
The builtin prevents the optimizer from rearranging floating point expression
evaluation. The new option fprotect-parens has the same effect on
parenthesized expressions, forcing the optimizer to respect the parentheses.

Reviewed By: aaron.ballman, kpn

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

Added: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336d..9e8bac635337 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,6 +1478,26 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -f[no-]protect-parens:
+
+   This option pertains to floating-point types, complex types with
+   floating-point components, and vectors of these types. Some arithmetic
+   expression transformations that are mathematically correct and permissible
+   according to the C and C++ language standards may be incorrect when dealing
+   with floating-point types, such as reassociation and distribution. Further,
+   the optimizer may ignore parentheses when computing arithmetic expressions
+   in circumstances where the parenthesized and unparenthesized expression
+   express the same mathematical value. For example (a+b)+c is the same
+   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
+   additions in any order regardless of the parentheses. When enabled, this
+   option forces the optimizer to honor the order of operations with respect
+   to parentheses in all circumstances.
+
+   Note that floating-point contraction (option `-ffp-contract=`) is disabled
+   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
+   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
+   has no effect because the optimizer is prohibited from making unsafe
+   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 5a9d0a001829..33d3e6dc4e7d 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,6 +1657,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
 
+// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
+LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a22fd2506a..22c2a1a39ea1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,6 +8530,9 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
+def err_typecheck_expect_flt_or_vector : Error<
+  "invalid operand of type %0 where floating, complex or "
+  "a vector of such types is required">;
 def err_cast_selector_expr : 

[clang] 2c02b0c - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 2c02b0c3f45414ac6c64583e006a26113c028304

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

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e742..20f6afa76cbb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c7..4c2859e5eda7 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70b..fac786dbcf9e 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2b..244a6e044690 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02f..d431dda97022 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee0..18ee1194c759 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   // Note: GCC recognizes 

[PATCH] D105001: [Clang][RISCV] Support half-precision floating point for RVV intrinsics.

2021-06-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:27
 //  i -> int
-//  h -> half
+//  h -> half (__fp16)
+//  x -> half (_Float16)

This also includes OpenCL half



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c:13
 
+// ASM-NOT: warning
 #include 

Do you plan to bring back the ASM check for all tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105001

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


[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG - I do think a config knob for this would be nice one day.
As discussed offline it would also cover rename, code complete insertion...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105039

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


[PATCH] D103615: [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-28 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3fe847f9d90: [Clang] Add option to handle behaviour of 
vector bool/vector pixel. (authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
  clang/test/CodeGen/vector-compat-pixel-bool.c
  clang/test/CodeGen/vector-compat-ternary.c
  clang/test/CodeGen/vector-compat.c

Index: clang/test/CodeGen/vector-compat.c
===
--- /dev/null
+++ clang/test/CodeGen/vector-compat.c
@@ -0,0 +1,162 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=mixed -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=xl -triple powerpc-unknown-unknown -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+// RUN: %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @ui8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned char ui8(vector unsigned char a, vector unsigned char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-NEXT:store <16 x i8> [[A:%.*]], <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <16 x i8> [[B:%.*]], <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <16 x i8>, <16 x i8>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <16 x i1> [[CMP]] to <16 x i8>
+// CHECK-NEXT:ret <16 x i8> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector signed char si8(vector signed char a, vector signed char b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @ui16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[SEXT]]
+//
+// ERROR: returning 'int' from a function with incompatible result type
+vector unsigned short ui16(vector unsigned short a, vector unsigned short b) {
+  return a == b;
+}
+
+// CHECK-LABEL: @si16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:store <8 x i16> [[A:%.*]], <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:store <8 x i16> [[B:%.*]], <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x i16>, <8 x i16>* [[A_ADDR]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <8 x i16>, <8 x i16>* [[B_ADDR]], align 16
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq <8 x i16> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:  

[clang] c3fe847 - [Clang] Add option to handle behaviour of vector bool/vector pixel.

2021-06-28 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-06-28T11:16:37-05:00
New Revision: c3fe847f9d90de5a6a76fd1d5f5823ab4719accc

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

LOG: [Clang] Add option to handle behaviour of vector bool/vector pixel.

Added the option `-altivec-src-compat=[mixed,gcc,xl]`. The default at this time 
is `mixed`.

The default behavior for clang is for all vector compares to return a scalar 
unless the vectors being
compared are vector bool or vector pixel. In that case the compare returns a
vector. With the gcc case all vector compares return vectors and in the xl case
all vector compares return scalars.

This patch does not change the default behavior of clang.

This option will be used in future patches to implement behaviour compatibility 
for the vector bool/pixel types.

Reviewed By: bmahjour

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

Added: 
clang/test/CodeGen/vector-compat-pixel-bool-ternary.c
clang/test/CodeGen/vector-compat-pixel-bool.c
clang/test/CodeGen/vector-compat-ternary.c
clang/test/CodeGen/vector-compat.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b5b8bc6aa3c5..70a22fd2506a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,6 +7441,12 @@ def warn_deprecated_volatile_structured_binding : 
Warning<
   "volatile qualifier in structured binding declaration is deprecated">,
   InGroup;
 
+def warn_deprecated_altivec_src_compat : Warning<
+  "Current handling of vector bool and vector pixel types in this context are "
+  "deprecated. The default behaviour will soon change to that implied by the "
+  "'-altivec-compat=xl' option">,
+  InGroup>;
+
 def err_catch_incomplete_ptr : Error<
   "cannot catch pointer to incomplete type %0">;
 def err_catch_incomplete_ref : Error<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b6d9160f89a0..465bad8d7d11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -126,6 +126,8 @@ LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
  LaxVectorConversionKind::All, "lax vector conversions")
+ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,
+ AltivecSrcCompatKind::Default, "Altivec source compatibility")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d618daf3d23c..d04ce52a550e 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -244,6 +244,18 @@ class LangOptions : public LangOptionsBase {
 All,
   };
 
+  enum class AltivecSrcCompatKind {
+// All vector compares produce scalars except vector pixel and vector bool.
+// The types vector pixel and vector bool return vector results.
+Mixed,
+// All vector compares produce vector results as in GCC.
+GCC,
+// All vector compares produce scalars as in XL.
+XL,
+// Default clang behaviour.
+Default = Mixed,
+  };
+
   enum class SignReturnAddressScopeKind {
 /// No signing for any function.
 None,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0122afd2eead..f1455f546199 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3823,6 +3823,18 @@ def u : JoinedOrSeparate<["-"], "u">, Group;
 def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Show commands to run and use verbose output">,
   MarshallingInfoFlag>;
+def altivec_src_compat : Joined<["-"], "faltivec-src-compat=">,
+  Flags<[CC1Option]>, Group,
+  HelpText<"Source-level compatibility for Altivec vectors (for PowerPC "
+   "targets). This includes results of vector comparison (scalar for "
+   "'xl', vector for 'gcc') as well as behavior when initializing with 
"
+   "a scalar (splatting for 'xl', element zero only for 'gcc'). For "
+   "'mixed', the compatibility is as 'gcc' for 'vector 

[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

2021-06-28 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 354924.
mizvekov added a comment.

- Fix missing period as pointed by rsmith.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr15xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/SemaCXX/compare-function-pointer.cpp
  clang/test/SemaTemplate/resolve-single-template-id.cpp

Index: clang/test/SemaTemplate/resolve-single-template-id.cpp
===
--- clang/test/SemaTemplate/resolve-single-template-id.cpp
+++ clang/test/SemaTemplate/resolve-single-template-id.cpp
@@ -68,11 +68,11 @@
 
   one < one; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   oneT < oneT; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}}
   twoT < twoT; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
Index: clang/test/SemaCXX/compare-function-pointer.cpp
===
--- clang/test/SemaCXX/compare-function-pointer.cpp
+++ clang/test/SemaCXX/compare-function-pointer.cpp
@@ -3,25 +3,48 @@
 using fp0_t = void (*)();
 using fp1_t = int (*)();
 
+namespace test_builtin {
+
 extern fp0_t a, b;
 extern fp1_t c;
 
 bool eq0 = a == b;
 bool ne0 = a != b;
-bool lt0 = a < b;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
-bool le0 = a <= b;  // expected-warning {{ordered comparison of function pointers}}
-bool gt0 = a > b;   // expected-warning {{ordered comparison of function pointers}}
-bool ge0 = a >= b;  // expected-warning {{ordered comparison of function pointers}}
-auto tw0 = a <=> b; // expected-error {{ordered comparison of function pointers}}
+bool lt0 = a < b;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
+bool le0 = a <= b;  // expected-error {{ordered comparison of function pointers}}
+bool gt0 = a > b;   // expected-error {{ordered comparison of function pointers}}
+bool ge0 = a >= b;  // expected-error {{ordered comparison of function pointers}}
 
 bool eq1 = a == c;  // expected-error {{comparison of distinct pointer types}}
 bool ne1 = a != c;  // expected-error {{comparison of distinct pointer types}}
-bool lt1 = a < c;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool le1 = a <= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool gt1 = a > c;   // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool ge1 = a >= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
+bool lt1 = a < c;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
+bool le1 = a <= c;  // expected-error {{ordered comparison of function pointers}}
+bool gt1 = a > c;   // expected-error {{ordered comparison of function pointers}}
+bool ge1 = a >= c;  // expected-error {{ordered comparison of function pointers}}
 auto tw1 = a <=> c; // expected-error {{ordered comparison of function pointers}}
+
+} // namespace test_builtin
+
+namespace test_overload {
+
+template struct wrapper { operator T(); };
+
+extern wrapper a, b;
+extern wrapper c;
+
+bool eq0 = a == b;
+bool ne0 = a != b;
+bool lt0 = a < b;   // expected-error {{invalid operands to binary expression}}
+bool le0 = a <= b;  // expected-error {{invalid operands to binary expression}}
+bool gt0 = a > b;   // expected-error {{invalid operands to binary expression}}
+bool ge0 = a >= 

[PATCH] D105039: [clangd] Add a flag to disable formatting of tweak edits

2021-06-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Some tweaks might edit file types not supported by clang-format. This
patch gives them a way to signal that they do not require formatting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105039

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.h


Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto  : (*Effect)->ApplyEdits) {
 Edit  = It.second;
 format::FormatStyle Style =


Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -78,6 +78,9 @@
 /// A message to be displayed to the user.
 llvm::Optional ShowMessage;
 FileEdits ApplyEdits;
+/// Whether the edits should be formatted before presenting to the client.
+/// Note that it applies to all files.
+bool FormatEdits = true;
 
 static Effect showMessage(StringRef S) {
   Effect E;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -637,8 +637,8 @@
   Effect = T.takeError();
 }
 assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
+if (*Effect && (*Effect)->FormatEdits) {
+  // Format tweaks that require it centrally here.
   for (auto  : (*Effect)->ApplyEdits) {
 Edit  = It.second;
 format::FormatStyle Style =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-28 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodefraine updated this revision to Diff 354922.
brunodefraine added a comment.

Slightly improved test case (both C and C++).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/attr-nodebug2.c


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb 
-dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.


Index: clang/test/CodeGen/attr-nodebug2.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nodebug2.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -debug-info-kind=limited -debugger-tuning=gdb -dwarf-version=4 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void t1();
+
+void use() { t1(); }
+
+__attribute__((nodebug)) void t1() {
+  int a = 10;
+  a++;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// CHECK-LABEL: define{{.*}} void @use()
+// CHECK-SAME:  !dbg
+// CHECK-SAME:  {
+// CHECK:   !dbg
+// CHECK:   }
+
+// PR50767 Function __attribute__((nodebug)) inconsistency causes crash
+// illegal (non-distinct) !dbg metadata was being added to _Z2t1v definition
+
+// CHECK-LABEL: define{{.*}} void @t1()
+// CHECK-NOT:   !dbg
+// CHECK-SAME:  {
+// CHECK-NOT:   !dbg
+// CHECK:   }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@
   QualType ResTy = BuildFunctionArgList(GD, Args);
 
   // Check if we should generate debug info for this function.
-  if (FD->hasAttr())
-DebugInfo = nullptr; // disable debug info indefinitely for this function
+  if (FD->hasAttr()) {
+// Clear non-distinct debug info that was possibly attached to the function
+// due to an earlier declaration without the nodebug attribute
+if (Fn)
+  Fn->setSubprogram(nullptr);
+// Disable debug info indefinitely for this function
+DebugInfo = nullptr;
+  }
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

2021-06-28 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 354920.
mizvekov added a comment.

- Rebase after split.
- Add tests which I had forgotten, covering the builtin candidates for the 
relational operators other than spaceship.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr15xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/SemaCXX/compare-function-pointer.cpp
  clang/test/SemaTemplate/resolve-single-template-id.cpp

Index: clang/test/SemaTemplate/resolve-single-template-id.cpp
===
--- clang/test/SemaTemplate/resolve-single-template-id.cpp
+++ clang/test/SemaTemplate/resolve-single-template-id.cpp
@@ -68,11 +68,11 @@
 
   one < one; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   oneT < oneT; // expected-warning {{self-comparison always evaluates to false}} \
  // expected-warning {{relational comparison result unused}}   \
- // expected-warning {{ordered comparison of function pointers}}
+ // expected-error   {{ordered comparison of function pointers}}
 
   two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}}
   twoT < twoT; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
Index: clang/test/SemaCXX/compare-function-pointer.cpp
===
--- clang/test/SemaCXX/compare-function-pointer.cpp
+++ clang/test/SemaCXX/compare-function-pointer.cpp
@@ -3,25 +3,48 @@
 using fp0_t = void (*)();
 using fp1_t = int (*)();
 
+namespace test_builtin {
+
 extern fp0_t a, b;
 extern fp1_t c;
 
 bool eq0 = a == b;
 bool ne0 = a != b;
-bool lt0 = a < b;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
-bool le0 = a <= b;  // expected-warning {{ordered comparison of function pointers}}
-bool gt0 = a > b;   // expected-warning {{ordered comparison of function pointers}}
-bool ge0 = a >= b;  // expected-warning {{ordered comparison of function pointers}}
-auto tw0 = a <=> b; // expected-error {{ordered comparison of function pointers}}
+bool lt0 = a < b;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}
+bool le0 = a <= b;  // expected-error {{ordered comparison of function pointers}}
+bool gt0 = a > b;   // expected-error {{ordered comparison of function pointers}}
+bool ge0 = a >= b;  // expected-error {{ordered comparison of function pointers}}
 
 bool eq1 = a == c;  // expected-error {{comparison of distinct pointer types}}
 bool ne1 = a != c;  // expected-error {{comparison of distinct pointer types}}
-bool lt1 = a < c;   // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool le1 = a <= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool gt1 = a > c;   // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
-bool ge1 = a >= c;  // expected-warning {{ordered comparison of function pointers}}
-// expected-error@-1 {{comparison of distinct pointer types}}
+bool lt1 = a < c;   // expected-error {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}
+bool le1 = a <= c;  // expected-error {{ordered comparison of function pointers}}
+bool gt1 = a > c;   // expected-error {{ordered comparison of function pointers}}
+bool ge1 = a >= c;  // expected-error {{ordered comparison of function pointers}}
 auto tw1 = a <=> c; // expected-error {{ordered comparison of function pointers}}
+
+} // namespace test_builtin
+
+namespace test_overload {
+
+template struct wrapper { operator T(); };
+
+extern wrapper a, b;
+extern wrapper c;
+
+bool eq0 = a == b;
+bool ne0 = a != b;
+bool lt0 = a < b;   // expected-error {{invalid operands to binary expression}}
+bool le0 = a <= b;  // expected-error {{invalid operands to binary expression}}

[PATCH] D104777: PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration

2021-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

In D104777#2844077 , @brunodefraine 
wrote:

> That I already encounter this in builtin headers is probably an indication 
> that the new error will break some code in the wild.

Fair point, breaking backwards compatibility isn't great.

> A pragmatic solution would be to only raise the error in 
> `Sema::mergeDeclAttributes` if `Old->isUsed()`, i.e. an earlier declaration 
> without `nodebug` can be forgiven if not yet used. I think that would still 
> make it impossible to trigger the crash?

I'm not too fussed about the original patch - just figured it might be 
nicer/cleaner to require a consistent view of the attribute value. I'm not sure 
it's worth splitting hairs on "it can be inconsistent but only in this narrow 
way".

I can appreciate that only invalidating the cases that were crashes before 
avoids increasing the feature surface area more than necessary - but I'm not 
sure it makes for a more ergonomic feature. (though, equally - the idea that 
adding a definition to a translation unit would modify the DWARF produced for 
calls to the function that were previously fine is weird too - but I guess we 
already had that property if you added the definition at the start of the 
translation unit)

Let's just go with the original patch then - thanks for your patience/working 
through the alternatives!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104777

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added inline comments.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:30
+#ifdef __OPENMP_AMDGCN__
+#define __DEVICE__ static __attribute__((always_inline, nothrow))
+#define __CONSTEXPR__ constexpr

ashi1 wrote:
> Does OpenMP not require `__device__` attribute here? I know constexpr defines 
> `__device__` on HIP, does OMP do the same?
It does not as these methods are inside declare variant.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:32
+#define __CONSTEXPR__ constexpr
+#define __constant__ __attribute__((constant))
+#else

ashi1 wrote:
> I don't think this is the right place to define `__constant__`? It's unused 
> in this header, and may get forgotten. Would it be better to define it in the 
> openmp wrapper or does cmath define it in OpenMP?
It is being used. However, I have moved it to openmp_wrappers/cmath.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-06-28 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 354913.
pdhaliwal marked 2 inline comments as done.
pdhaliwal added a comment.

- Move __constant__ to openmp_wrappers/cmath
- Using push/pop_macro to avoid redefinition


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -23,9 +23,13 @@
 inline long long
 abs(long long __x) { return __builtin_llabs (__x); }
 
+// amdgcn already provides 

Re: [clang] 4a47da2 - [Sema] turns -Wfree-nonheap-object on by default

2021-06-28 Thread David Blaikie via cfe-commits
(ping on this)

On Mon, May 10, 2021 at 8:37 AM David Blaikie  wrote:

> Christopher - had a chance to look into this any further?
>
> Roman - I'm OK either way on that. I don't think it's the most costly
> false positive - not too much code is probably freeing via a reference
> (rather than a pointer) to allocated memory.
>
>
> On Fri, Apr 30, 2021 at 10:08 AM Roman Lebedev 
> wrote:
> >
> > Should the diagnostic be backed out until then?
> >
> > Roman
> >
> > On Fri, Apr 30, 2021 at 7:52 PM Christopher Di Bella via cfe-commits
> >  wrote:
> > >
> > > Sorry, not yet. I'll talk with my TL to see if I can get some time
> allotted for this in the next few weeks.
> > >
> > > On Thu, 29 Apr 2021 at 16:13, David Blaikie 
> wrote:
> > >>
> > >> Ping on this - have you had a chance to look at this false positive?
> > >>
> > >> On Sat, Apr 3, 2021 at 4:29 PM David Blaikie 
> wrote:
> > >> >
> > >> > Looks like this has a false positive (that's firing on some mlir
> code,
> > >> > committed a workaround in  499571ea835daf786626a0db1e12f890b6cd8f8d
> )
> > >> > like this:
> > >> >
> > >> > $ cat test.cpp
> > >> > #include 
> > >> > void f1(int & x) { free(); }
> > >> > int main() { f1(*(int*)malloc(sizeof(int))); }
> > >> >
> > >> > Could you fix that? (& then revert the workaround)
> > >> >
> > >> > On Fri, Jan 15, 2021 at 1:44 PM Christopher Di Bella via cfe-commits
> > >> >  wrote:
> > >> > >
> > >> > >
> > >> > > Author: Christopher Di Bella
> > >> > > Date: 2021-01-15T21:38:47Z
> > >> > > New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263
> > >> > >
> > >> > > URL:
> https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263
> > >> > > DIFF:
> https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263.diff
> > >> > >
> > >> > > LOG: [Sema] turns -Wfree-nonheap-object on by default
> > >> > >
> > >> > > We'd discussed adding the warning to -Wall in D89988. This patch
> honours that.
> > >> > >
> > >> > > Added:
> > >> > >
> > >> > >
> > >> > > Modified:
> > >> > > clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > clang/test/Analysis/NewDelete-intersections.mm
> > >> > > clang/test/Analysis/free.c
> > >> > >
> > >> > > Removed:
> > >> > >
> > >> > >
> > >> > >
> > >> > >
> 
> > >> > > diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
> b/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > index d500ab321058..04ba89aa457e 100644
> > >> > > --- a/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > +++ b/clang/include/clang/Basic/DiagnosticGroups.td
> > >> > > @@ -110,6 +110,7 @@ def FloatConversion :
> > >> > >   FloatZeroConversion]>;
> > >> > >
> > >> > >  def FrameAddress : DiagGroup<"frame-address">;
> > >> > > +def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;
> > >> > >  def DoublePromotion : DiagGroup<"double-promotion">;
> > >> > >  def EnumTooLarge : DiagGroup<"enum-too-large">;
> > >> > >  def UnsupportedNan : DiagGroup<"unsupported-nan">;
> > >> > >
> > >> > > diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > index 7d36397a7993..e93657898f58 100644
> > >> > > --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> > >> > > @@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<
> > >> > >  def err_no_dynamic_cast_with_fno_rtti : Error<
> > >> > >"use of dynamic_cast requires -frtti">;
> > >> > >  def warn_no_dynamic_cast_with_rtti_disabled: Warning<
> > >> > > -  "dynamic_cast will not work since RTTI data is disabled by "
> > >> > > +  "dynamic_cast will not work since RTTI data is disabled by "
> > >> > >"%select{-fno-rtti-data|/GR-}0">, InGroup;
> > >> > >  def warn_no_typeid_with_rtti_disabled: Warning<
> > >> > >"typeid will not work since RTTI data is disabled by "
> > >> > > @@ -7625,8 +7625,7 @@ def warn_condition_is_assignment :
> Warning<"using the result of an "
> > >> > >InGroup;
> > >> > >  def warn_free_nonheap_object
> > >> > >: Warning<"attempt to call %0 on non-heap object %1">,
> > >> > > -InGroup>,
> > >> > > -DefaultIgnore; // FIXME: add to -Wall after sufficient
> testing
> > >> > > +InGroup;
> > >> > >
> > >> > >  // Completely identical except off by default.
> > >> > >  def warn_condition_is_idiomatic_assignment : Warning<"using the
> result "
> > >> > >
> > >> > > diff  --git a/clang/test/Analysis/NewDelete-intersections.mm
> b/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > index f01d62f8d365..6f81034ee349 100644
> > >> > > --- a/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > +++ b/clang/test/Analysis/NewDelete-intersections.mm
> > >> > > @@ -24,9 +24,6 @@
> > >> > >  extern "C" void free(void *);
> > >> 

[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-06-28 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added a comment.

@kiranchandramohan The tests passed now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93373

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(here's another flaky failure that was due to this: 
http://45.33.8.238/mac/33008/step_7.txt )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted for now in d5402a2fee5d860e20378f819e200865af3a6113 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


  1   2   >