[PATCH] D77792: [analyzer] Extend constraint manager to be able to compare simple SymSymExprs

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal abandoned this revision.
steakhal added a comment.

I no longer think that we should support Symbol to Symbol comparisons.
It would introduce certain anomalies, like //Why could the CM reason about this 
and that comparisons wile could not in others//.

As of now, it's clear that we can not compare Symbols to Symbols - preventing 
such confusing questions to arise in the future.
If we were to implement Symbol to Symbol comparisons, we should cover a lot 
more cases than this patch could.

So I decided to abandon this patch.


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

https://reviews.llvm.org/D77792

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


[PATCH] D85528: [analyzer] Fix cast evaluation on scoped enums in ExprEngine

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 286209.
steakhal marked an inline comment as done.
steakhal added a comment.

Add an extra `RUN` line without //refutation//.
The expected result is the same as with refutation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85528

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/test/Analysis/z3-refute-enum-crash.cpp


Index: clang/test/Analysis/z3-refute-enum-crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/z3-refute-enum-crash.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config crosscheck-with-z3=true -verify %s
+//
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -verify %s
+//
+// REQUIRES: z3
+//
+// Requires z3 only for refutation. Works with both constraint managers.
+
+void clang_analyzer_dump(int);
+
+using sugar_t = unsigned char;
+
+// Enum types
+enum class ScopedSugared : sugar_t {};
+enum class ScopedPrimitive : unsigned char {};
+enum UnscopedSugared : sugar_t {};
+enum UnscopedPrimitive : unsigned char {};
+
+template 
+T conjure();
+
+void test_enum_types() {
+  int sym1 = static_cast(conjure()) & 0x0F;
+  int sym2 = static_cast(conjure()) & 0x0F;
+  int sym3 = static_cast(conjure()) & 0x0F;
+  int sym4 = static_cast(conjure()) & 0x0F;
+
+  if (sym1 && sym2 && sym3 && sym4) {
+// no-crash on these dumps
+clang_analyzer_dump(sym1); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym2); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym3); // expected-warning{{(conj_}}
+clang_analyzer_dump(sym4); // expected-warning{{(conj_}}
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -95,11 +95,15 @@
   }
 
   bool haveSameType(QualType Ty1, QualType Ty2) {
+const bool BothHaveSameCanonicalTypes =
+Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2);
+const bool BothHaveIntegralOrUnscopedEnumerationType =
+Ty1->isIntegralOrUnscopedEnumerationType() &&
+Ty2->isIntegralOrUnscopedEnumerationType();
 // FIXME: Remove the second disjunct when we support symbolic
 // truncation/extension.
-return (Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2) ||
-(Ty1->isIntegralOrEnumerationType() &&
- Ty2->isIntegralOrEnumerationType()));
+return BothHaveSameCanonicalTypes ||
+   BothHaveIntegralOrUnscopedEnumerationType;
   }
 
   SVal evalCast(SVal val, QualType castTy, QualType originalType);


Index: clang/test/Analysis/z3-refute-enum-crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/z3-refute-enum-crash.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config crosscheck-with-z3=true -verify %s
+//
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -verify %s
+//
+// REQUIRES: z3
+//
+// Requires z3 only for refutation. Works with both constraint managers.
+
+void clang_analyzer_dump(int);
+
+using sugar_t = unsigned char;
+
+// Enum types
+enum class ScopedSugared : sugar_t {};
+enum class ScopedPrimitive : unsigned char {};
+enum UnscopedSugared : sugar_t {};
+enum UnscopedPrimitive : unsigned char {};
+
+template 
+T conjure();
+
+void test_enum_types() {
+  int sym1 = static_cast(conjure()) & 0x0F;
+  int sym2 = static_cast(conjure()) & 0x0F;
+  int sym3 = static_cast(conjure()) & 0x0F;
+  int sym4 = static_cast(conjure()) & 0x0F;
+
+  if (sym1 && sym2 && sym3 && sym4) {
+// no-crash on these dumps
+clang_analyzer_dump(sym1); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym2); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym3); // expected-warning{{(conj_}}
+clang_analyzer_dump(sym4); // expected-warning{{(conj_}}
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -95,11 +95,15 @@
   }
 
   bool haveSameType(QualType Ty1, QualType Ty2) {
+const bool BothHaveSameCanonicalTypes =
+Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2);
+const bool BothHaveIntegralOrUnscopedEnumerationType =
+Ty1->isIntegralOrUnscopedEnumerationType() &&
+

[PATCH] D84979: [analyzer][NFC] Refine CStringLength modeling API

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 286212.
steakhal marked 2 inline comments as done.
steakhal edited the summary of this revision.
steakhal added a comment.
Herald added a subscriber: mgorny.

Fixed Artem's inline comments:

- `cstring::getCStringLength` now takes `StateRef` by value
- `cstring::dumpCStringLengths` now takes by `StateRef` by non const value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84979

Files:
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringChecker.h
  clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h
  clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLengthModeling.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLengthModeling.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLengthModeling.cpp
@@ -0,0 +1,306 @@
+//=== CStringLengthModeling.cpp  Implementation of CStringLength API C++ -*--=//
+//
+// 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
+//
+//===--===//
+//
+// Implements the CStringLength API and the CStringChecker bookkeeping parts.
+// Updates the associated cstring lengths of memory regions:
+//  - Infers the cstring length of string literals.
+//  - Removes cstring length associations of dead symbols.
+//  - Handles region invalidation.
+//
+//===--===//
+
+#include "CStringChecker.h"
+#include "CStringLength.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+using namespace ento;
+using namespace cstring;
+
+/// Associates an strlen to a memory region.
+REGISTER_MAP_WITH_PROGRAMSTATE(CStringLengthMap, const MemRegion *, SVal)
+
+//===--===//
+// Implementation of the public CStringLength API.
+//===--===//
+
+ProgramStateRef cstring::setCStringLength(ProgramStateRef State,
+  const MemRegion *MR, SVal StrLength) {
+  assert(!StrLength.isUndef() && "Attempt to set an undefined string length");
+
+  MR = MR->StripCasts();
+
+  switch (MR->getKind()) {
+  case MemRegion::StringRegionKind:
+// FIXME: This can happen if we strcpy() into a string region. This is
+// undefined [C99 6.4.5p6], but we should still warn about it.
+return State;
+
+  case MemRegion::SymbolicRegionKind:
+  case MemRegion::AllocaRegionKind:
+  case MemRegion::NonParamVarRegionKind:
+  case MemRegion::ParamVarRegionKind:
+  case MemRegion::FieldRegionKind:
+  case MemRegion::ObjCIvarRegionKind:
+// These are the types we can currently track string lengths for.
+break;
+
+  case MemRegion::ElementRegionKind:
+// FIXME: Handle element regions by upper-bounding the parent region's
+// string length.
+return State;
+
+  default:
+// Other regions (mostly non-data) can't have a reliable C string length.
+// For now, just ignore the change.
+// FIXME: These are rare but not impossible. We should output some kind of
+// warning for things like strcpy((char[]){'a', 0}, "b");
+return State;
+  }
+
+  if (StrLength.isUnknown())
+return removeCStringLength(State, MR);
+  return State->set(MR, StrLength);
+}
+
+ProgramStateRef cstring::removeCStringLength(ProgramStateRef State,
+ const MemRegion *MR) {
+  return State->remove(MR);
+}
+
+NonLoc cstring::createCStringLength(ProgramStateRef , CheckerContext ,
+const Expr *Ex, const MemRegion *MR) {
+  assert(Ex);
+  assert(MR);
+
+  SValBuilder  = Ctx.getSValBuilder();
+  QualType SizeTy = SVB.getContext().getSizeType();
+  NonLoc CStrLen =
+  SVB.getMetadataSymbolVal(CStringChecker::getTag(), MR, Ex, SizeTy,
+   Ctx.getLocationContext(), Ctx.blockCount())
+  .castAs();
+
+  // Implicitly constrain the range to SIZE_MAX/4
+  BasicValueFactory  = SVB.getBasicValueFactory();
+  const llvm::APSInt  = BVF.getMaxValue(SizeTy);
+  const llvm::APSInt Four = APSIntType(MaxValue).getValue(4);
+  const llvm::APSInt *MaxLength = BVF.evalAPSInt(BO_Div, MaxValue, 

[PATCH] D86047: [clangd] Target member of dependent base made visible via a using-decl

2020-08-18 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe33ec9d90400: [clangd] Target member of dependent base made 
visible via a using-decl (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86047

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1087,66 +1087,78 @@
 
 TEST(LocateSymbol, Alias) {
   const char *Tests[] = {
-R"cpp(
+  R"cpp(
   template  struct function {};
   template  using [[callback]] = function;
 
   c^allback foo;
 )cpp",
 
-// triggered on non-definition of a renaming alias: should not give any
-// underlying decls.
-R"cpp(
+  // triggered on non-definition of a renaming alias: should not give any
+  // underlying decls.
+  R"cpp(
   class Foo {};
   typedef Foo [[Bar]];
 
   B^ar b;
 )cpp",
-R"cpp(
+  R"cpp(
   class Foo {};
   using [[Bar]] = Foo; // definition
   Ba^r b;
 )cpp",
 
-// triggered on the underlying decl of a renaming alias.
-R"cpp(
+  // triggered on the underlying decl of a renaming alias.
+  R"cpp(
   class [[Foo]];
   using Bar = Fo^o;
 )cpp",
 
-// triggered on definition of a non-renaming alias: should give underlying
-// decls.
-R"cpp(
+  // triggered on definition of a non-renaming alias: should give underlying
+  // decls.
+  R"cpp(
   namespace ns { class [[Foo]] {}; }
   using ns::F^oo;
 )cpp",
 
-R"cpp(
+  R"cpp(
   namespace ns { int [[x]](char); int [[x]](double); }
   using ns::^x;
 )cpp",
 
-R"cpp(
+  R"cpp(
   namespace ns { int [[x]](char); int x(double); }
   using ns::x;
   int y = ^x('a');
 )cpp",
 
-R"cpp(
+  R"cpp(
   namespace ns { class [[Foo]] {}; }
   using ns::Foo;
   F^oo f;
 )cpp",
 
-// other cases that don't matter much.
-R"cpp(
+  // other cases that don't matter much.
+  R"cpp(
   class Foo {};
   typedef Foo [[Ba^r]];
 )cpp",
-R"cpp(
+  R"cpp(
   class Foo {};
   using [[B^ar]] = Foo;
 )cpp",
+
+  // Member of dependent base
+  R"cpp(
+  template 
+  struct Base {
+void [[waldo]]() {}
+  };
+  template 
+  struct Derived : Base {
+using Base::w^aldo;
+  };
+)cpp",
   };
 
   for (const auto* Case : Tests) {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -207,6 +207,19 @@
   )cpp";
   EXPECT_DECLS("MemberExpr", {"using X::foo", Rel::Alias},
{"int foo()", Rel::Underlying});
+
+  Code = R"cpp(
+  template 
+  struct Base {
+void waldo() {}
+  };
+  template 
+  struct Derived : Base {
+using Base::[[waldo]];
+  };
+)cpp";
+  EXPECT_DECLS("UnresolvedUsingValueDecl", {"using Base::waldo", Rel::Alias},
+   {"void waldo()", Rel::Underlying});
 }
 
 TEST_F(TargetDeclTest, ConstructorInitList) {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -345,7 +345,7 @@
 
 // Give the underlying decl if navigation is triggered on a non-renaming
 // alias.
-if (llvm::isa(D)) {
+if (llvm::isa(D) || llvm::isa(D)) {
   // FIXME: address more complicated cases. TargetDecl(... Underlying) gives
   // all overload candidates, we only want the targeted one if the cursor is
   // on an using-alias usage, workround it with getDeclAtPosition.
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -100,7 +100,7 @@
 std::vector getMembersReferencedViaDependentName(
 const Type *T,
 llvm::function_ref NameFactory,
-bool IsNonstaticMember) {
+llvm::function_ref Filter) {
   if (!T)
 return {};
   if (auto *ET = T->getAs()) {
@@ -113,17 +113,22 @@
   return {};
 RD = RD->getDefinition();
 DeclarationName Name = NameFactory(RD->getASTContext());
-return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-  return IsNonstaticMember ? D->isCXXInstanceMember()
-   : 

[PATCH] D84979: [analyzer][NFC] Refine CStringLength modeling API

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D84979#2190996 , @balazske wrote:

> Really I am still not totally familiar how the checkers work and if it is 
> good to have these function names.

Yea, naming things is pretty hard. I'm open to have a less verbose one - 
especially since these API functions will live under some namespace.

> [...]  It could get the data from CStringChecker using a "get" function or 
> test if there is data at all. In this case it may happen that this get 
> function modifies state or computes the length at that point?

This patch makes sure that the //get// function will not modify the state 
(takes a `const ProgramStateRef`).
We don't really want to store the length of a `StringLiteral`, since that can 
be computed on demand.

> And how do the //set// operation work, it only stores a value computed by the 
> calling code?

It tries to avoid storing the length information. E.g. if a region refers to a 
string literal - we don't have to store the length. (This was the previous 
behavior, I don't want to change that.)
However, we don't handle ElementRegions (for now, but I'm working on it).

> And the //create// operation then does the computation and //set// together?

CStringChecker needs a way to defer associating the length of the region.
I'm not sure why, but the magic //Hypothetical// parameter was introduced just 
for accomplishing that.
I'm not confident enough to refactor the function which exploits this. [1]

> The functions look not symmetrical, the set and create takes a `MemRegion` 
> but the get takes a `SVal`.

The current implementation checks if the SVal is a GotoLabel (which is not a 
MemRegion). I didn't want to change its behavior in this patch.
`MemRegion` parameter would fit much more nicely, just as you said.

> The create function sets the length for the passed memory region

No, it just creates a symbol, representing a cstring length. That symbol is 
(strictly speaking) not yet associated with the memory region.
Furthermore, it applies implicit constraints like assuming that the cstring 
length is always less than the corresponding extent (It is not yet done, but 
I'm working on this too).

> but makes no tests on it like the set function (can we call the set function 
> from the create?).

We could call, but we need a mechanism to defer associating the length of a 
region.
CStringChecker relies on this behavior. See my paragraph about the 
//Hypothetical// parameter.

---

@balazske Unfortunately, I don't have satisfying answers to you, but any 
further improvements could be done in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84979

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


[PATCH] D86130: [AST] Fix a crash on mangling a binding decl from a DeclRefExpr.

2020-08-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: rsmith.
Herald added a project: clang.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86130

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/mangle.cpp


Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1138,3 +1138,12 @@
   // CHECK-LABEL: @_ZN6test581AC1INS_5StateEEET_MNS_8identityIS3_E4typeEFbvE
   void fn1() { A(a, ::m_fn1); }
 }
+
+namespace test59 {
+  // verify no crash.
+  template
+  void f(T g) {
+auto [e] = g;
+[](decltype(e)) {};
+  }
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -657,6 +657,8 @@
 mangleName(FD);
   else if (const MSGuidDecl *GuidD = dyn_cast(GD.getDecl()))
 mangleName(GuidD);
+  else if (const BindingDecl *BD = dyn_cast(GD.getDecl()))
+mangleName(BD);
   else
 llvm_unreachable("unexpected kind of global decl");
 }


Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1138,3 +1138,12 @@
   // CHECK-LABEL: @_ZN6test581AC1INS_5StateEEET_MNS_8identityIS3_E4typeEFbvE
   void fn1() { A(a, ::m_fn1); }
 }
+
+namespace test59 {
+  // verify no crash.
+  template
+  void f(T g) {
+auto [e] = g;
+[](decltype(e)) {};
+  }
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -657,6 +657,8 @@
 mangleName(FD);
   else if (const MSGuidDecl *GuidD = dyn_cast(GD.getDecl()))
 mangleName(GuidD);
+  else if (const BindingDecl *BD = dyn_cast(GD.getDecl()))
+mangleName(BD);
   else
 llvm_unreachable("unexpected kind of global decl");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-18 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:29-34
+// qNaN / any = qNaN
+if (test__divdf3(makeQNaN64(), 3., UINT64_C(0x7ff8)))
+  return 1;
+// NaN / any = NaN
+if (test__divdf3(makeNaN64(UINT64_C(0x123)), 3., 
UINT64_C(0x7ff8)))
+  return 1;

Expressions `any/nan' also could be checked.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:49-54
+// Inf / Inf = NaN
+if (test__divdf3(makeInf64(), makeInf64(), UINT64_C(0x7ff8)))
+  return 1;
+// 0.0 / 0.0 = NaN
+if (test__divdf3(+0x0.0p+0, +0x0.0p+0, UINT64_C(0x7ff8)))
+  return 1;

Expression `Inf/0' also could be checked.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:80
+// divisor is 1.0 as UQ1.31
+if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;

Is 0x1.0001p+0 equal to 1.0 in UQ1.31?



Comment at: compiler-rt/test/builtins/Unit/divsf3_test.c:27
 {
+// Returned NaNs are assumed to be qNaN by default
+

Similar notes as for double precision checks.



Comment at: compiler-rt/test/builtins/Unit/divtf3_test.c:34
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default

Similar notes as double precision checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

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


[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Ping


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

https://reviews.llvm.org/D84316

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


[clang-tools-extra] e33ec9d - [clangd] Target member of dependent base made visible via a using-decl

2020-08-18 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-08-18T03:03:49-04:00
New Revision: e33ec9d90400a906314ccbd5821dbe05d070108a

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

LOG: [clangd] Target member of dependent base made visible via a using-decl

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

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index f73a6e584972..9db814368a02 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -100,7 +100,7 @@ CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
 std::vector getMembersReferencedViaDependentName(
 const Type *T,
 llvm::function_ref NameFactory,
-bool IsNonstaticMember) {
+llvm::function_ref Filter) {
   if (!T)
 return {};
   if (auto *ET = T->getAs()) {
@@ -113,17 +113,22 @@ std::vector 
getMembersReferencedViaDependentName(
   return {};
 RD = RD->getDefinition();
 DeclarationName Name = NameFactory(RD->getASTContext());
-return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-  return IsNonstaticMember ? D->isCXXInstanceMember()
-   : !D->isCXXInstanceMember();
-});
+return RD->lookupDependentName(Name, Filter);
   }
   return {};
 }
 
-// Given the type T of a dependent expression that appears of the LHS of a 
"->",
-// heuristically find a corresponding pointee type in whose scope we could look
-// up the name appearing on the RHS.
+const auto NonStaticFilter = [](const NamedDecl *D) {
+  return D->isCXXInstanceMember();
+};
+const auto StaticFilter = [](const NamedDecl *D) {
+  return !D->isCXXInstanceMember();
+};
+const auto ValueFilter = [](const NamedDecl *D) { return isa(D); };
+
+// Given the type T of a dependent expression that appears of the LHS of a
+// "->", heuristically find a corresponding pointee type in whose scope we
+// could look up the name appearing on the RHS.
 const Type *getPointeeType(const Type *T) {
   if (!T)
 return nullptr;
@@ -141,7 +146,7 @@ const Type *getPointeeType(const Type *T) {
   [](ASTContext ) {
 return Ctx.DeclarationNames.getCXXOperatorName(OO_Arrow);
   },
-  /*IsNonStaticMember=*/true);
+  NonStaticFilter);
   if (ArrowOps.empty())
 return nullptr;
 
@@ -187,13 +192,12 @@ std::vector resolveExprToDecls(const 
Expr *E) {
 }
 return getMembersReferencedViaDependentName(
 BaseType, [ME](ASTContext &) { return ME->getMember(); },
-/*IsNonstaticMember=*/true);
+NonStaticFilter);
   }
   if (const auto *RE = dyn_cast(E)) {
 return getMembersReferencedViaDependentName(
 RE->getQualifier()->getAsType(),
-[RE](ASTContext &) { return RE->getDeclName(); },
-/*IsNonstaticMember=*/false);
+[RE](ASTContext &) { return RE->getDeclName(); }, StaticFilter);
   }
   if (const auto *CE = dyn_cast(E)) {
 const auto *CalleeType = resolveExprToType(CE->getCallee());
@@ -291,7 +295,6 @@ const NamedDecl *getTemplatePattern(const NamedDecl *D) {
 // CXXDependentScopeMemberExpr, but some other constructs remain to be handled:
 //  - DependentTemplateSpecializationType,
 //  - DependentNameType
-//  - UnresolvedUsingValueDecl
 //  - UnresolvedUsingTypenameDecl
 struct TargetFinder {
   using RelSet = DeclRelationSet;
@@ -345,6 +348,15 @@ struct TargetFinder {
 } else if (const auto *NAD = dyn_cast(D)) {
   add(NAD->getUnderlyingDecl(), Flags | Rel::Underlying);
   Flags |= Rel::Alias; // continue with the alias
+} else if (const UnresolvedUsingValueDecl *UUVD =
+   dyn_cast(D)) {
+  for (const NamedDecl *Target : getMembersReferencedViaDependentName(
+   UUVD->getQualifier()->getAsType(),
+   [UUVD](ASTContext &) { return UUVD->getNameInfo().getName(); },
+   ValueFilter)) {
+add(Target, Flags | Rel::Underlying);
+  }
+  Flags |= Rel::Alias; // continue with the alias
 } else if (const UsingShadowDecl *USD = dyn_cast(D)) {
   // Include the using decl, but don't traverse it. This may end up
   // including *all* shadows, which we don't want.

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 9936c67cb6e5..031a9c7bf5da 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -345,7 +345,7 @@ locateASTReferent(SourceLocation CurLoc, const 
syntax::Token *TouchedIdentifier,
 
 

[PATCH] D86132: [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
CarolineConcatto requested review of this revision.

If a folder's name, where the test fortran.f95 is running, has cc1 the test
fails because of  CHECK-ASM-NOT: cc1.
The solution used in this patch is to add quotation mark around cc1 and cc1as
because the driver returns these flags with quotation marks ("")


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86132

Files:
  clang/test/Driver/fortran.f95


Index: clang/test/Driver/fortran.f95
===
--- clang/test/Driver/fortran.f95
+++ clang/test/Driver/fortran.f95
@@ -6,14 +6,14 @@
 ! CHECK-OBJECT: gcc
 ! CHECK-OBJECT: "-c"
 ! CHECK-OBJECT: "-x" "f95"
-! CHECK-OBJECT-NOT: cc1as
+! CHECK-OBJECT-NOT: "cc1as"
 
 ! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
 ! RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 ! CHECK-ASM: gcc
 ! CHECK-ASM: "-S"
 ! CHECK-ASM: "-x" "f95"
-! CHECK-ASM-NOT: cc1
+! CHECK-ASM-NOT: "cc1"
 
 ! RUN: %clang -Wall -target x86_64-unknown-linux-gnu -integrated-as %s -o %t 
-### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s
 ! CHECK-WARN: gcc


Index: clang/test/Driver/fortran.f95
===
--- clang/test/Driver/fortran.f95
+++ clang/test/Driver/fortran.f95
@@ -6,14 +6,14 @@
 ! CHECK-OBJECT: gcc
 ! CHECK-OBJECT: "-c"
 ! CHECK-OBJECT: "-x" "f95"
-! CHECK-OBJECT-NOT: cc1as
+! CHECK-OBJECT-NOT: "cc1as"
 
 ! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
 ! RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 ! CHECK-ASM: gcc
 ! CHECK-ASM: "-S"
 ! CHECK-ASM: "-x" "f95"
-! CHECK-ASM-NOT: cc1
+! CHECK-ASM-NOT: "cc1"
 
 ! RUN: %clang -Wall -target x86_64-unknown-linux-gnu -integrated-as %s -o %t -### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s
 ! CHECK-WARN: gcc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 286258.
eduucaldas added a comment.

Fail on non-matching number of tree dumps and annotations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -194,21 +194,29 @@
   "log";
   }
 
-  bool failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
-  assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  if (AnnotatedRanges.size() != TreeDumps.size()) {
+return ::testing::AssertionFailure()
+   << "The number of annotated ranges in the source code is different "
+  "to the number of their corresponding tree dumps.";
+  }
+  bool Failed = false;
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
 std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-IdExpression
+| `-UnqualifiedId
+|   |-operator
+|   `-+
+|-(
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+|-,
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X 

[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.cpp:199
+  auto AnnotatedRanges = AnnotatedCode.ranges();
+  assert(AnnotatedRanges.size() == TreeDumps.size());
+  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {

eduucaldas wrote:
> gribozavr2 wrote:
> > ASSERT_EQ I think would be better.
> `ASSERT_EQ` is a macro that returns void, so we cannot use it here.
> 
> However that brings another question.
> Right now we have methods `treeDumpEqual*` that return `AssertionResult`s and 
> we use them in our tests in the following way: 
> `EXPECT_TRUE(treeDumpEqual*...)`.
> It seems to me that we should instead perform any assertion inside 
> `treeDumpEqual*`, and then just call it directly in the test.
> 
> WDYT?  I case you agree we can perform this change in another patch.
We need the `EXPECT_TRUE` at the test site to get information about in which 
line number we failed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

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


[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-08-18 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

For reference, I've been using this + D75960  
in my employer's Clang build for almost two months. We have been using 
`std::bit_cast` in our codebase quite a bit and haven't encountered any issues 
with these two changes. It would be nice too see this merged.


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

https://reviews.llvm.org/D76323

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


[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 286251.
eduucaldas added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -194,21 +194,25 @@
   "log";
   }
 
-  bool failed = false;
+  bool Failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
   assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
 std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-IdExpression
+| `-UnqualifiedId
+|   |-operator
+|   `-+
+|-(
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+|-,
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   operator int();
 };
 void test(X x) {
   // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();
+  [[x.operator int()]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-SimpleDeclaration
-| | |-SimpleDeclarator
-| | | |-operator
-| | 

[PATCH] D86132: [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-18 Thread David Truby via Phabricator via cfe-commits
DavidTruby requested changes to this revision.
DavidTruby added a comment.
This revision now requires changes to proceed.

On my clang line, when compiling a C file, this appears as "-cc1" not "cc1". I 
don't see a cc1as so I can't check that one but I assume it will be the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86132

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


[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 286248.
eduucaldas marked 7 inline comments as done.
eduucaldas added a comment.

Answering comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -194,21 +194,25 @@
   "log";
   }
 
-  bool failed = false;
+  bool Failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
   assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
 std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-IdExpression
+| `-UnqualifiedId
+|   |-operator
+|   `-+
+|-(
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+|-,
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   operator int();
 };
 void test(X x) {
   // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();
+  [[x.operator int()]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| 

[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-18 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

@sepavloff

Thank you for the test cases. Looks like it is worth completely rewriting the 
three tests as table-driven tests, so for example adding four cases for 
`[+-]Inf / [+-]0.0` would be almost as easy as testing only one of them 
(something similar is already implemented for `udivmod?i4_test.c`). The 
differences between adjacent test cases would be more visually obvious, as well.




Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:80
+// divisor is 1.0 as UQ1.31
+if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;

sepavloff wrote:
> Is 0x1.0001p+0 equal to 1.0 in UQ1.31?
Divisor is `1.(31 zeroes)1` after restoring the implicit bit, so it is 
**truncated** to 1.0 as UQ1.31. Instead of counting bits carefully, it would 
probably be better to add several tests with the `1` bit shifted 1-2 places 
left/right as well as if the divisor is round up instead of truncating - //just 
in case//. :) So, with table-driven test it would probably be simpler to not 
make extra assumptions on the implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

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


[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

It doesn't feel like this patch got a very positive reception, but I'd still 
like to try a bit more to get it in.

Even though it's difficult to test this particular change upstream, would it 
still be acceptable to take the patch since it reverts the behavior to what it 
was previously? If there are worries that things may break in the future due to 
other changes, we do catch these things in our downstream testing and are 
fairly diligent about reporting back about them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-08-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: bkramer, djasper, klimek.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
fodinabor requested review of this revision.

Currently newer clang-format options cannot be included in .clang-format files, 
if not all users can be forced to use an updated version.
This patch tries to solve this by adding an option to clang-format, enabling to 
ignore unknown (newer) options.

As this is my first LLVM patch, I'm expecting to get some things wrong and are 
happy to receive any feedback!
E.g.: I haven't found how to update the clang-format help page yet. Is it auto 
generated?
Also if you have any suggestions on whom to ask wrt review, please add them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86137

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp

Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -195,6 +195,8 @@
   MapHNode *MN = dyn_cast_or_null(CurrentNode);
   if (!MN)
 return;
+  if (IgnoreUnkown)
+return;
   for (const auto  : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
   setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
@@ -428,6 +430,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setIgnoreUnknown(bool Value) { IgnoreUnkown = Value; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
@@ -735,6 +739,8 @@
 void Output::setError(const Twine ) {
 }
 
+void Output::setIgnoreUnknown(bool Value) {}
+
 bool Output::canElideEmptySequence() {
   // Normally, with an optional key/value where the value is an empty sequence,
   // the whole key/value can be not written.  But, that produces wrong yaml
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setIgnoreUnknown(bool) = 0;
 
   template 
   void enumCase(T , const char* Str, const T ConstVal) {
@@ -1504,6 +1505,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setIgnoreUnknown(bool) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1517,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   boolScalarMatchFound = false;
+  bool IgnoreUnkown = false;
 };
 
 ///
@@ -1561,6 +1565,7 @@
   void scalarTag(std::string &) override;
   NodeKind getNodeKind() override;
   void setError(const Twine ) override;
+  void setIgnoreUnknown(bool) override;
   bool canElideEmptySequence() override;
 
   // These are only used by operator<<. They could be private
Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,6 +104,11 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt
+IgnoreUnkownOptions("ignore-unknown-options",
+cl::desc("If set, unknown format options are ignored."),
+cl::init(false), cl::cat(ClangFormatCategory));
+
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -378,7 +383,8 @@
   }
 
   llvm::Expected FormatStyle =
-  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
+   nullptr, IgnoreUnkownOptions.getValue());
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1288,7 +1288,8 @@
   return true;
 }
 
-std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
+std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+   bool IgnoreUnknownOptions) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -1302,6 +1303,7 @@
   // Mapping also uses the context to get the language to find the correct
   // base style.
   Input.setContext(Style);
+  Input.setIgnoreUnknown(IgnoreUnknownOptions);
   

[PATCH] D85321: [OPENMP]Do not capture base pointer by reference if it is used as a base for array-like reduction.

2020-08-18 Thread Alexey Bataev 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 rG1b93ebccaa09: [OPENMP]Do not capture base pointer by 
reference if it is used as a base for… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85321

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp

Index: clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
@@ -20,9 +20,9 @@
   }
 }
 
-// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8***)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8*** %{{.+}})
+// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8**)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8** %{{.+}})
 
-// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8*** {{.+}})
+// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8** {{.+}})
 // CHECK: alloca i32,
 // CHECK: [[ARGC_FP_ADDR:%.+]] = alloca i32,
 // CHECK: [[TR:%.+]] = alloca [2 x [[TASKRED_TY:%struct.kmp_taskred_input_t.*]]],
@@ -124,7 +124,6 @@
 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR]],
 // CHECK-DAG: [[ARGV_REF]] = load i8*, i8** [[ARGV_ADDR:%.+]],
 // CHECK-DAG: [[ARGV_ADDR]] = load i8**, i8*** [[ARGV_ADDR_REF:%.+]],
-// CHECK-DAG: [[ARGV_ADDR_REF:%.+]] = load i8***, i8 [[ARGV:%.+]],
-// CHECK-DAG: [[ARGV]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
+// CHECK-DAG: [[ARGV_ADDR_REF]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
 
 #endif
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
@@ -19,9 +19,9 @@
   }
 }
 
-// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8***)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8*** %{{.+}})
+// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8**)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8** %{{.+}})
 
-// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8*** {{.+}})
+// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8** {{.+}})
 // CHECK: alloca i32,
 // CHECK: [[ARGC_FP_ADDR:%.+]] = alloca i32,
 // CHECK: [[TR:%.+]] = alloca [2 x [[TASKRED_TY:%struct.kmp_taskred_input_t.*]]],
@@ -123,7 +123,6 @@
 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR]],
 // CHECK-DAG: [[ARGV_REF]] = load i8*, i8** [[ARGV_ADDR:%.+]],
 // CHECK-DAG: [[ARGV_ADDR]] = load i8**, i8*** [[ARGV_ADDR_REF:%.+]],
-// CHECK-DAG: [[ARGV_ADDR_REF:%.+]] = load i8***, i8 [[ARGV:%.+]],
-// CHECK-DAG: [[ARGV]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
+// CHECK-DAG: [[ARGV_ADDR_REF]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
 
 #endif
Index: clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp

[clang] 1b93ebc - [OPENMP]Do not capture base pointer by reference if it is used as a base for array-like reduction.

2020-08-18 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-08-18T09:05:35-04:00
New Revision: 1b93ebccaa094c079db7ad729e2f7fea7bac2f34

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

LOG: [OPENMP]Do not capture base pointer by reference if it is used as a base 
for array-like reduction.

If the declaration is used in the reduction clause, it is captured by
reference by default. But if the declaration is a pointer and it is a
base for array-like reduction, this declaration can be captured by
value, since the pointee is reduced but not the original declaration.

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
clang/test/OpenMP/sections_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a493f3114dc29..53917ef98acdf 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -70,12 +70,15 @@ class DSAStackTy {
 const Expr *RefExpr = nullptr;
 DeclRefExpr *PrivateCopy = nullptr;
 SourceLocation ImplicitDSALoc;
+bool AppliedToPointee = false;
 DSAVarData() = default;
 DSAVarData(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind,
const Expr *RefExpr, DeclRefExpr *PrivateCopy,
-   SourceLocation ImplicitDSALoc, unsigned Modifier)
+   SourceLocation ImplicitDSALoc, unsigned Modifier,
+   bool AppliedToPointee)
 : DKind(DKind), CKind(CKind), Modifier(Modifier), RefExpr(RefExpr),
-  PrivateCopy(PrivateCopy), ImplicitDSALoc(ImplicitDSALoc) {}
+  PrivateCopy(PrivateCopy), ImplicitDSALoc(ImplicitDSALoc),
+  AppliedToPointee(AppliedToPointee) {}
   };
   using OperatorOffsetTy =
   llvm::SmallVector, 4>;
@@ -99,6 +102,9 @@ class DSAStackTy {
 /// variable is marked as lastprivate(true) or not (false).
 llvm::PointerIntPair RefExpr;
 DeclRefExpr *PrivateCopy = nullptr;
+/// true if the attribute is applied to the pointee, not the variable
+/// itself.
+bool AppliedToPointee = false;
   };
   using DeclSAMapTy = llvm::SmallDenseMap;
   using UsedRefMapTy = llvm::SmallDenseMap;
@@ -511,7 +517,8 @@ class DSAStackTy {
 
   /// Adds explicit data sharing attribute to the specified declaration.
   void addDSA(const ValueDecl *D, const Expr *E, OpenMPClauseKind A,
-  DeclRefExpr *PrivateCopy = nullptr, unsigned Modifier = 0);
+  DeclRefExpr *PrivateCopy = nullptr, unsigned Modifier = 0,
+  bool AppliedToPointee = false);
 
   /// Adds additional information for the reduction items with the reduction id
   /// represented as an operator.
@@ -563,7 +570,8 @@ class DSAStackTy {
   /// match specified \a CPred predicate in any directive which matches \a 
DPred
   /// predicate.
   const DSAVarData
-  hasDSA(ValueDecl *D, const llvm::function_ref CPred,
+  hasDSA(ValueDecl *D,
+ const llvm::function_ref CPred,
  const llvm::function_ref DPred,
  bool FromParent) const;
   /// Checks if the specified variables has data-sharing attributes which
@@ -571,15 +579,16 @@ class DSAStackTy {
   /// matches \a DPred predicate.
   const DSAVarData
   hasInnermostDSA(ValueDecl *D,
-  const llvm::function_ref CPred,
+  const llvm::function_ref CPred,
   const llvm::function_ref DPred,
   bool FromParent) const;
   /// Checks if the specified variables has explicit data-sharing
   /// attributes which match specified \a CPred predicate at the specified
   /// OpenMP region.
-  bool hasExplicitDSA(const ValueDecl *D,
-  const llvm::function_ref CPred,
-  unsigned Level, bool NotLastprivate = false) const;
+  bool
+  hasExplicitDSA(const ValueDecl *D,
+ const llvm::function_ref CPred,
+ unsigned Level, bool NotLastprivate = false) const;
 
   /// Returns true if the directive at level \Level matches in the
   /// specified \a DPred predicate.
@@ -1185,6 +1194,7 @@ DSAStackTy::DSAVarData 

[PATCH] D84887: [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286270.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84887

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp


Index: clang/test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_is_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -285,4 +285,41 @@
   ++arg;
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 
c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x 
c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[SZ:64|32]]] [i{{64|32}} 
{{8|4}}]
+// OMP_MAP_TARGET_PARAM = 0x20 | OMP_MAP_TO = 0x1 = 0x21
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
+void bar() {
+  __attribute__((aligned(64))) double *ptr;
+  // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, 
i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}}, i8** null)
+  // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to double***
+  // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to double***
+  // CK3-DAG: store double** [[PTR:%.+]], double*** [[CBP1]]
+  // CK3-DAG: store double** [[PTR]], double*** [[CP1]]
+
+  // CK3: call void [[KERNEL:@.+]](double** [[PTR]])
+#pragma omp target is_device_ptr(ptr)
+  *ptr = 0;
+}
+#endif
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8436,10 +8436,12 @@
 if (DevPointersMap.count(VD)) {
   CombinedInfo.BasePointers.emplace_back(Arg, VD);
   CombinedInfo.Pointers.push_back(Arg);
-  CombinedInfo.Sizes.push_back(
-  
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
-CGF.Int64Ty, /*isSigned=*/true));
-  CombinedInfo.Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
+  CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
+  CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
+  /*isSigned=*/true));
+  CombinedInfo.Types.push_back(
+  (Cap->capturesVariable() ? OMP_MAP_TO : 

[PATCH] D86069: [clang] When loading preamble from AST file, re-export modules in Sema.

2020-08-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/test/PCH/preamble-modules.cpp:8
+
+#ifndef MAIN_FILE
+#define MAIN_FILE

what are these ifdefs about? you never seem to define this symbol

(Possible you're copying from a test that is doing something tricky like being 
run in two modes or including itself? Or did you mean to give different flags 
for the include vs emit pch?)



Comment at: clang/test/PCH/preamble-modules.cpp:14
+// Main section.
+MyType foo;
+#endif

This seems like currently it's never getting parsed as MAIN_FILE is never 
defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86069

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


[PATCH] D86132: [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 286257.
CarolineConcatto added a comment.

Missing a -


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86132

Files:
  clang/test/Driver/fortran.f95


Index: clang/test/Driver/fortran.f95
===
--- clang/test/Driver/fortran.f95
+++ clang/test/Driver/fortran.f95
@@ -6,14 +6,14 @@
 ! CHECK-OBJECT: gcc
 ! CHECK-OBJECT: "-c"
 ! CHECK-OBJECT: "-x" "f95"
-! CHECK-OBJECT-NOT: cc1as
+! CHECK-OBJECT-NOT: "-cc1as"
 
 ! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
 ! RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 ! CHECK-ASM: gcc
 ! CHECK-ASM: "-S"
 ! CHECK-ASM: "-x" "f95"
-! CHECK-ASM-NOT: cc1
+! CHECK-ASM-NOT: "-cc1"
 
 ! RUN: %clang -Wall -target x86_64-unknown-linux-gnu -integrated-as %s -o %t 
-### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s
 ! CHECK-WARN: gcc


Index: clang/test/Driver/fortran.f95
===
--- clang/test/Driver/fortran.f95
+++ clang/test/Driver/fortran.f95
@@ -6,14 +6,14 @@
 ! CHECK-OBJECT: gcc
 ! CHECK-OBJECT: "-c"
 ! CHECK-OBJECT: "-x" "f95"
-! CHECK-OBJECT-NOT: cc1as
+! CHECK-OBJECT-NOT: "-cc1as"
 
 ! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
 ! RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 ! CHECK-ASM: gcc
 ! CHECK-ASM: "-S"
 ! CHECK-ASM: "-x" "f95"
-! CHECK-ASM-NOT: cc1
+! CHECK-ASM-NOT: "-cc1"
 
 ! RUN: %clang -Wall -target x86_64-unknown-linux-gnu -integrated-as %s -o %t -### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s
 ! CHECK-WARN: gcc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

2020-08-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, xazax.hun, martong, balazske, 
baloghadamsoftware, gamesh411.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, whisperity.
Szelethus requested review of this revision.

In short, macro expansions handled the case where a variadic //parameter// 
mapped to multiple //arguments//, but not the other way around. An internal 
ticket was submitted that demonstrated that we fail an assertion. Macro 
expansion so far worked by lexing the source code token-by-token and using the 
`Preprocessor` to turn these tokens into identifiers or just get their proper 
spelling, but what this counter intuitively doesn't do, is actually expand 
these macros, so we have to do the heavy lifting -- in this case, figure out 
what `__VA_ARGS__` expands into. Since this case can only occur in a nested 
macro, the information we gathered from the containing macro does contain this 
information. If a parameter resolves to `__VA_ARGS__`, we need to temporarily 
stop getting our tokens from the lexer, and get the tokens from what 
`__VA_ARGS__` maps to.

I also found a few more deficiencies I'll have to handle sooner rather then 
later. I also have 3 commits about to land this is based on, some miscellaneous 
renames, clarification in the documentation, prettifying some tests.

An educational rant:

For those that didn't have the displeasure of following my macro expansion 
project, here's why this is so annoying: We really, really suck at 
understanding macros. D74473  is a recent 
example where we attempt to get the definition of the `EOF` macro, but give up 
rather fast if it isn't something trivial. D54349#1294765 
 is also memorable for me. Indeed, 
whenever we hit a macro, we are in deep trouble.

Since CodeChecker isn't an IDE, what we really wanted to achieve is when the 
bug path goes through a macro, show what it would expand into.

The fundamental problem is, we simply can't ask `Preprocessor` what a macro 
expands into without hacking really hard. The HTML output commits about every 
sin under the sun; hiding under `clang/lib/Rewrite/HTMLRewrite.cpp`, it 
`const_cast`s a `Preprocessor` object, stores most of its inner state (you 
can't guarantee you got them all) such as the `DiagnosticsEngine`, some of the 
user configurations in temporary variables, replaces them with new ones, 
practically reruns the entire lexing and preprocessing stage of the compiler, 
and at the end, puts the original inner state back in. This enables it to not 
have to literally reimplement the preprocessor, but creates a large 
preprocessed version of the source code, which it is almost impossible to 
reliably link the two together (answering the question that what a specific 
macro usage expands into).

Pp-trace, a Clang tool, would be great, but unfortunately it still isn't able 
to do macro expansions in a single go, just step by step (think about nested 
macros and variadic arguments).

So, I chose to practically reimplement the entire preprocessor with the goal of 
taking a single source location of a macro usage, and spitting the entire 
expansion out. This has a few advantages, namely that it leaves the 
Preprocessor const, and provides a rather deep understanding of the process of 
the macro expansion. The problem is, its a nightmare due to the extreme 
primitiveness of the available tools, and will have to be updated as time goes 
on.

You can learn a bit more from these patches and discussions:
D52742  (check the patch stack)
http://lists.llvm.org/pipermail/cfe-dev/2018-September/059226.html
http://lists.llvm.org/pipermail/cfe-dev/2017-August/055077.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86135

Files:
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  
clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
  clang/test/Analysis/plist-macros-with-expansion.cpp

Index: clang/test/Analysis/plist-macros-with-expansion.cpp
===
--- clang/test/Analysis/plist-macros-with-expansion.cpp
+++ clang/test/Analysis/plist-macros-with-expansion.cpp
@@ -472,3 +472,62 @@
 
 // CHECK: nameAPPLY_ZERO2
 // CHECK-NEXT: expansionint bar() { return 0; }
+
+void foo(int , const char *str);
+
+#define PARAMS_RESOLVE_TO_VA_ARGS(i, fmt) \
+  foo(i, fmt);\
+  i = 0;
+#define DISPATCH(...) PARAMS_RESOLVE_TO_VA_ARGS(__VA_ARGS__);
+
+void mulitpleParamsResolveToVA_ARGS(void) {
+  int x = 1;
+  DISPATCH(x, "LF1M healer");
+  (void)(10 / x); // expected-warning{{Division by zero}}
+}
+// CHECK: nameDISPATCH
+// CHECK-NEXT: expansionfoo(x, LF1M healer);x = 0;;
+
+void variadicCFunction(int , const char *str, ...);
+

[PATCH] D86069: [clang] When loading preamble from AST file, re-export modules in Sema.

2020-08-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/test/PCH/preamble-modules.cpp:8
+
+#ifndef MAIN_FILE
+#define MAIN_FILE

sammccall wrote:
> what are these ifdefs about? you never seem to define this symbol
> 
> (Possible you're copying from a test that is doing something tricky like 
> being run in two modes or including itself? Or did you mean to give different 
> flags for the include vs emit pch?)
Oh, I stole this trick from Kadir. You compile this file twice. First one is to 
generate a PCH for preamble. MAIN_FILE is not set, so it only reads the 
preamble section. The second one has -include-pch. That means MAIN_FILE is now 
set (from the preamble PCH file), so we only compile the main section.

It's a creative solution to a problem I wish I didn't have ;-)
Is there a better way to do this, without splitting the file in two? 
preamble_bytes seems fragile.



Comment at: clang/test/PCH/preamble-modules.cpp:14
+// Main section.
+MyType foo;
+#endif

sammccall wrote:
> This seems like currently it's never getting parsed as MAIN_FILE is never 
> defined.
It's parsed. Without this fix, there's a warning generated here. See comment 
above for explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86069

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


[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 286259.
eduucaldas added a comment.

Nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -171,7 +171,7 @@
<< "Source file has syntax errors, they were printed to the test "
   "log";
   }
-  std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
   // EXPECT_EQ shows the diff between the two strings if they are different.
   EXPECT_EQ(Tree.trim().str(), Actual);
   if (Actual != Tree.trim().str()) {
@@ -194,21 +194,29 @@
   "log";
   }
 
-  bool failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
-  assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  if (AnnotatedRanges.size() != TreeDumps.size()) {
+return ::testing::AssertionFailure()
+   << "The number of annotated ranges in the source code is different "
+  "to the number of their corresponding tree dumps.";
+  }
+  bool Failed = false;
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
+StringRef(AnnotatedNode->dump(*Arena)).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}

[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:477
 struct X {
   friend X operator+(const X&, const X&);
 };

A test for this part was created below



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.cpp:199
+  auto AnnotatedRanges = AnnotatedCode.ranges();
+  assert(AnnotatedRanges.size() == TreeDumps.size());
+  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {

gribozavr2 wrote:
> ASSERT_EQ I think would be better.
`ASSERT_EQ` is a macro that returns void, so we cannot use it here.

However that brings another question.
Right now we have methods `treeDumpEqual*` that return `AssertionResult`s and 
we use them in our tests in the following way: `EXPECT_TRUE(treeDumpEqual*...)`.
It seems to me that we should instead perform any assertion inside 
`treeDumpEqual*`, and then just call it directly in the test.

WDYT?  I case you agree we can perform this change in another patch.



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.cpp:206
+// EXPECT_EQ shows the diff between the two strings if they are different.
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+if (AnnotatedNodeDump != TreeDumps[i].trim().str())

gribozavr2 wrote:
> Could you dump the annotated source code substring to make debugging failing 
> tests easier?
Very good suggestion :) thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

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


[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-18 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286255.
atrosinenko added a comment.

Address the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

Files:
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c
  compiler-rt/test/builtins/Unit/fp_test.h

Index: compiler-rt/test/builtins/Unit/fp_test.h
===
--- compiler-rt/test/builtins/Unit/fp_test.h
+++ compiler-rt/test/builtins/Unit/fp_test.h
@@ -253,14 +253,29 @@
 return fromRep32(0x7f80U);
 }
 
+static inline float makeNegativeInf32(void)
+{
+return fromRep32(0xff80U);
+}
+
 static inline double makeInf64(void)
 {
 return fromRep64(0x7ff0UL);
 }
 
+static inline double makeNegativeInf64(void)
+{
+return fromRep64(0xfff0UL);
+}
+
 #if __LDBL_MANT_DIG__ == 113
 static inline long double makeInf128(void)
 {
 return fromRep128(0x7fffUL, 0x0UL);
 }
+
+static inline long double makeNegativeInf128(void)
+{
+return fromRep128(0xUL, 0x0UL);
+}
 #endif
Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -32,6 +32,8 @@
 int main()
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default
+
 // qNaN / any = qNaN
 if (test__divtf3(makeQNaN128(),
  0x1.23456789abcdefp+5L,
@@ -39,17 +41,111 @@
  UINT64_C(0x0)))
 return 1;
 // NaN / any = NaN
-if (test__divtf3(makeNaN128(UINT64_C(0x80003000)),
+if (test__divtf3(makeNaN128(UINT64_C(0x3000)),
  0x1.23456789abcdefp+5L,
  UINT64_C(0x7fff8000),
  UINT64_C(0x0)))
 return 1;
-// inf / any = inf
-if (test__divtf3(makeInf128(),
- 0x1.23456789abcdefp+5L,
+// any / qNaN = qNaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeQNaN128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// any / NaN = NaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeNaN128(UINT64_C(0x3000)),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// +Inf / positive = +Inf
+if (test__divtf3(makeInf128(), 3.L,
  UINT64_C(0x7fff),
  UINT64_C(0x0)))
 return 1;
+// +Inf / negative = -Inf
+if (test__divtf3(makeInf128(), -3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / positive = -Inf
+if (test__divtf3(makeNegativeInf128(), 3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / negative = +Inf
+if (test__divtf3(makeNegativeInf128(), -3.L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// Inf / Inf = NaN
+if (test__divtf3(makeInf128(), makeInf128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// 0.0 / 0.0 = NaN
+if (test__divtf3(+0x0.0p+0L, +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// +0.0 / +Inf = +0.0
+if (test__divtf3(+0x0.0p+0L, makeInf128(),
+ UINT64_C(0x0),
+ UINT64_C(0x0)))
+return 1;
+// +Inf / +0.0 = +Inf
+if (test__divtf3(makeInf128(), +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// positive / +0.0 = +Inf
+if (test__divtf3(+1.0L, +0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+// positive / -0.0 = -Inf
+if (test__divtf3(+1.0L, -0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / +0.0 = -Inf
+if (test__divtf3(-1.0L, +0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / -0.0 = +Inf
+if (test__divtf3(-1.0L, -0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// 1/3
+if (test__divtf3(1.L, 3.L,
+ UINT64_C(0x3ffd),
+ UINT64_C(0x)))
+return 1;
+// smallest 

[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas 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 rGc8c92b54d74c: [SyntaxTree] Use Annotations based tests for 
expressions (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -171,7 +171,7 @@
<< "Source file has syntax errors, they were printed to the test "
   "log";
   }
-  std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
   // EXPECT_EQ shows the diff between the two strings if they are different.
   EXPECT_EQ(Tree.trim().str(), Actual);
   if (Actual != Tree.trim().str()) {
@@ -194,21 +194,29 @@
   "log";
   }
 
-  bool failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
-  assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  if (AnnotatedRanges.size() != TreeDumps.size()) {
+return ::testing::AssertionFailure()
+   << "The number of annotated ranges in the source code is different "
+  "to the number of their corresponding tree dumps.";
+  }
+  bool Failed = false;
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
+StringRef(AnnotatedNode->dump(*Arena)).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-

[clang] c8c92b5 - [SyntaxTree] Use Annotations based tests for expressions

2020-08-18 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-18T13:00:56Z
New Revision: c8c92b54d74c1b9256f9aed6ba89d66fbd1d01ae

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

LOG: [SyntaxTree] Use Annotations based tests for expressions

In this process we also create some other tests, in order to not lose
coverage when focusing on the annotated code

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 211e8b1ae901..fd858dfba91f 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@ void test() {
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-IdExpression
+| `-UnqualifiedId
+|   |-operator
+|   `-+
+|-(
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+|-,
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   operator int();
 };
 void test(X x) {
   // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();
+  [[x.operator int()]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-SimpleDeclaration
-| | |-SimpleDeclarator
-| | | |-operator
-| | | |-int
-| | | `-ParametersAndQualifiers
-| | |   |-(
-| | |   `-)
-| | `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-UnknownExpression
-| | | |-IdExpression
-| | | | `-UnqualifiedId
-| | | |   `-x
-| | | |-.
-| | | |-operator
-| | | `-int
-| | |-(
-| | `-)
-| `-;
-`-}
-)txt"));
+  {R"txt(
+UnknownExpression
+|-UnknownExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-x
+| |-.
+| |-operator
+| `-int
+|-(
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_LiteralOperatorId) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 unsigned operator "" _w(char);
 void test() {
-  operator "" _w('1');
+  [[operator "" _w('1')]];
 }
 )cpp",
-  R"txt(

[clang] ab58c9e - [SyntaxTree] Implement annotation-based test infrastructure

2020-08-18 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-18T13:00:56Z
New Revision: ab58c9ee8a6e9ace3a93198496b4d85e8cb2b5a9

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

LOG: [SyntaxTree] Implement annotation-based test infrastructure

We add the method `SyntaxTreeTest::treeDumpEqualOnAnnotations`, which
allows us to compare the treeDump of only annotated code. This will reduce a
lot of noise from our `BuildTreeTest` and make them short and easier to
read.

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTestBase.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.h

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp 
b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index 6d2efeaaa8eb..05fbac4f47e1 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -180,6 +180,35 @@ ::testing::AssertionResult 
SyntaxTreeTest::treeDumpEqual(StringRef Code,
   return ::testing::AssertionSuccess();
 }
 
+::testing::AssertionResult
+SyntaxTreeTest::treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
+   ArrayRef TreeDumps) {
+  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
+
+  auto AnnotatedCode = llvm::Annotations(CodeWithAnnotations);
+  auto *Root = buildTree(AnnotatedCode.code(), GetParam());
+
+  if (Diags->getClient()->getNumErrors() != 0) {
+return ::testing::AssertionFailure()
+   << "Source file has syntax errors, they were printed to the test "
+  "log";
+  }
+
+  bool failed = false;
+  auto AnnotatedRanges = AnnotatedCode.ranges();
+  assert(AnnotatedRanges.size() == TreeDumps.size());
+  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
+assert(AnnotatedNode);
+auto AnnotatedNodeDump =
+std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
+// EXPECT_EQ shows the 
diff  between the two strings if they are 
diff erent.
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+if (AnnotatedNodeDump != TreeDumps[i].trim().str())
+  failed = true;
+  }
+  return failed ? ::testing::AssertionFailure() : 
::testing::AssertionSuccess();
+}
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);

diff  --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h 
b/clang/unittests/Tooling/Syntax/TreeTestBase.h
index bfa6ecd7909f..c282bbf45fd3 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -34,6 +34,9 @@ class SyntaxTreeTest : public ::testing::Test,
 
   ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree);
 
+  ::testing::AssertionResult
+  treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
+ ArrayRef TreeDumps);
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root);



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


[PATCH] D86132: [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-18 Thread David Truby via Phabricator via cfe-commits
DavidTruby accepted this revision.
DavidTruby 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/D86132/new/

https://reviews.llvm.org/D86132

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


[clang] ca77ab4 - Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread via cfe-commits

Author: Mott, Jeffrey T
Date: 2020-08-18T09:17:26-07:00
New Revision: ca77ab494aa29f7521ff797d230cd1b36cbe4e62

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

LOG: Disable use of _ExtInt with '__atomic' builtins

We're (temporarily) disabling ExtInt for the '__atomic' builtins so we can 
better design their behavior later. The idea is until we do an audit/design for 
the way atomic builtins are supposed to work with _ExtInt, we should leave them 
restricted so they don't limit our future options, such as by binding us to a 
sub-optimal implementation via ABI.

Example after this change:

$ cat test.c

void f(_ExtInt(64) *ptr) {
  __atomic_fetch_add(ptr, 1, 0);
}

$ clang -c test.c

test.c:2:22: error: argument to atomic builtin of type '_ExtInt' is not 
supported
  __atomic_fetch_add(ptr, 1, 0);
 ^
1 error generated.

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

Added: 
libcxx/test/libcxx/atomics/ext-int.verify.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/builtins.c
clang/test/SemaCXX/ext-int.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fd21285b1f79..a63fae5b5f72 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6038,9 +6038,8 @@ def err_func_def_incomplete_result : Error<
 def err_atomic_specifier_bad_type
 : Error<"_Atomic cannot be applied to "
 "%select{incomplete |array |function |reference |atomic |qualified 
"
-"|sizeless ||integer |integer }0type "
-"%1 %select{|||which is not trivially copyable|with less than "
-"1 byte of precision|with a non power of 2 precision}0">;
+"|sizeless ||integer }0type "
+"%1 %select{|||which is not trivially copyable|}0">;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
@@ -7967,6 +7966,8 @@ def err_atomic_exclusive_builtin_pointer_size : Error<
   " 1,2,4 or 8 byte type (%0 invalid)">;
 def err_atomic_builtin_ext_int_size : Error<
   "Atomic memory operand must have a power-of-two size">;
+def err_atomic_builtin_ext_int_prohibit : Error<
+  "argument to atomic builtin of type '_ExtInt' is not supported">;
 def err_atomic_op_needs_atomic : Error<
   "address argument to atomic operation must be a pointer to _Atomic "
   "type (%0 invalid)">;

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4efd62f58d2e..70d3a682fc70 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5050,6 +5050,11 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, 
SourceRange ExprRange,
 ? 0
 : 1);
 
+  if (ValType->isExtIntType()) {
+Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit);
+return ExprError();
+  }
+
   return AE;
 }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index b2be31ac0990..4ab5cc5fd8b9 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8963,11 +8963,8 @@ QualType Sema::BuildAtomicType(QualType T, 
SourceLocation Loc) {
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
   DisallowedKind = 7;
-else if (auto *ExtTy = T->getAs()) {
-  if (ExtTy->getNumBits() < 8)
+else if (T->isExtIntType()) {
 DisallowedKind = 8;
-  else if (!llvm::isPowerOf2_32(ExtTy->getNumBits()))
-DisallowedKind = 9;
 }
 
 if (DisallowedKind != -1) {

diff  --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c
index 4b445724f712..e4093edb5f00 100644
--- a/clang/test/Sema/builtins.c
+++ b/clang/test/Sema/builtins.c
@@ -285,12 +285,16 @@ void test_ei_i42i(_ExtInt(42) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand 
must have a power-of-two size}}
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC 
version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand 
must have a power-of-two size}}
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic 
builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_i64i(_ExtInt(64) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expect success
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC 
version 4.4 - the newer semantics are provided here}}
   

[PATCH] D86146: [ARM][BFloat16] Change types of some Arm and AArch64 bf16 intrinsics

2020-08-18 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: dmgreen, simon_tatham, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
miyuki requested review of this revision.

This patch adjusts the following ARM/AArch64 LLVM IR intrinsics:

- neon_bfmmla
- neon_bfmlalb
- neon_bfmlalt

so that they take and return bf16 and float types. Previously these
intrinsics used <8 x i8> and <4 x i8> vectors (a rudiment from
implementation lacking bf16 IR type).

This patch makes the generated IR cleaner (less useless bitcasts are
produced), but it does not affect the final assembly.

This patch does not touch the dot product intrinsics yet because they
require some changes in the shuffle pattern recognition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86146

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
  clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
  llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll

Index: llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
===
--- llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
+++ llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
@@ -89,10 +89,8 @@
 ; CHECK-NEXT:vmmla.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmmla1.i = call <4 x float> @llvm.arm.neon.bfmmla.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmmla1.i
+  %vbfmmlaq_v3.i = call <4 x float> @llvm.arm.neon.bfmmla(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmmlaq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -101,10 +99,8 @@
 ; CHECK-NEXT:vfmab.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlaltq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -113,10 +109,8 @@
 ; CHECK-NEXT:vfmat.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmlalt1.i = call <4 x float> @llvm.arm.neon.bfmlalt.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalt1.i
+  %vbfmlaltq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalt(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmlaltq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
@@ -127,10 +121,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <4 x bfloat> %b, <4 x bfloat> undef, <8 x i32> zeroinitializer
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %vecinit35)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_laneq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -140,10 +132,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <8 x bfloat> %b, <8 x bfloat> undef, <8 x i32> 
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %vecinit35)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlaltq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
@@ -154,10 +144,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <4 x bfloat> %b, <4 x bfloat> undef, <8 x i32> zeroinitializer
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalt1.i = call <4 x float> @llvm.arm.neon.bfmlalt.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalt1.i
+  %vbfmlaltq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalt(<4 x float> 

[PATCH] D84049: Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread Mott, Jeffrey T via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca77ab494aa2: Disable use of _ExtInt with 
__atomic builtins (authored by jtmott-intel).
Herald added projects: clang, libc++.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84049

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/builtins.c
  clang/test/SemaCXX/ext-int.cpp
  libcxx/test/libcxx/atomics/ext-int.verify.cpp

Index: libcxx/test/libcxx/atomics/ext-int.verify.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/atomics/ext-int.verify.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: clang-11
+
+#include 
+
+int main(int, char**)
+{
+  // expected-error@atomic:*1 {{_Atomic cannot be applied to integer type '_ExtInt(32)'}}
+  std::atomic<_ExtInt(32)> x {42};
+
+  return 0;
+}
Index: clang/test/SemaCXX/ext-int.cpp
===
--- clang/test/SemaCXX/ext-int.cpp
+++ clang/test/SemaCXX/ext-int.cpp
@@ -91,10 +91,11 @@
 _Complex _ExtInt(3) Cmplx;
 
 // Reject cases of _Atomic:
-// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)' with less than 1 byte of precision}}
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)'}}
 _Atomic _ExtInt(4) TooSmallAtomic;
-// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)' with a non power of 2 precision}}
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)'}}
 _Atomic _ExtInt(9) NotPow2Atomic;
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(128)'}}
 _Atomic _ExtInt(128) JustRightAtomic;
 
 // Test result types of Unary/Bitwise/Binary Operations:
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -285,12 +285,16 @@
   __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}}
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}}
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_i64i(_ExtInt(64) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expect success
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expect success
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_ii42(int *ptr, _ExtInt(42) value) {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8963,11 +8963,8 @@
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
   DisallowedKind = 7;
-else if (auto *ExtTy = T->getAs()) {
-  if (ExtTy->getNumBits() < 8)
+else if (T->isExtIntType()) {
 DisallowedKind = 8;
-  else if (!llvm::isPowerOf2_32(ExtTy->getNumBits()))
-DisallowedKind = 9;
 }
 
 if (DisallowedKind != -1) {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5050,6 +5050,11 @@
 ? 0
 : 1);
 
+  if (ValType->isExtIntType()) {
+Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit);
+return ExprError();
+  }
+
   return AE;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6038,9 +6038,8 @@
 def err_atomic_specifier_bad_type
 : Error<"_Atomic cannot be applied to "
 "%select{incomplete |array |function |reference |atomic |qualified "
-"|sizeless ||integer |integer }0type "
-"%1 %select{|||which is not trivially copyable|with less than "
-"1 byte of precision|with a non power of 2 precision}0">;
+"|sizeless ||integer }0type "
+"%1 %select{|||which is not trivially copyable|}0">;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
@@ -7967,6 +7966,8 @@
   " 1,2,4 or 8 byte type (%0 

[PATCH] D86139: [SyntaxTree] Split tests related to Namespace

2020-08-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2151
+
+TEST_P(SyntaxTreeTest, Namepace_UsingDirective) {
+  if (!GetParam().isCXX()) {

I think grouping this test under Namespace_ is not the best choice, because 
what's being tested here is the `using`, not the `namespace`.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2171
+
+TEST_P(SyntaxTreeTest, Namespace_UsingDeclaration) {
+  if (!GetParam().isCXX()) {

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86139

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


[PATCH] D86100: [Clang][SVE] NFC: Move info about ACLE types into separate function.

2020-08-18 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes accepted this revision.
c-rhodes added a comment.
This revision is now accepted and ready to land.

LGTM, just one minor nit but seems like a nice improvement




Comment at: clang/include/clang/AST/ASTContext.h:1318
+  BuiltinVectorTypeInfo
+  getElementTypeForBuiltinVector(const BuiltinType *VecTy) const;
+

nit: not sure on the name here since it's returning more than the element type, 
how about `getBuiltinVectorTypeInfo`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86100

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


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-08-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I suppose this is just piling on heuristics, but I guess it fixes the reported 
bug. Krasimir, what do you think?


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

https://reviews.llvm.org/D79293

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


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286272.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

2020-08-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 286274.
hokein added a comment.

update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86048

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/test/Sema/invalid-member.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -26,3 +26,10 @@
 };
 
 void test3() { Crash3(); } // expected-note {{in instantiation of 
template class}}
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class Crash4 : decltype(N) {
+};
+
+static_assert(sizeof(Crash4) == 1, "");
Index: clang/test/Sema/invalid-member.cpp
===
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -19,3 +19,10 @@
 };
 // Should be able to evaluate sizeof without crashing.
 static_assert(sizeof(Z) == 1, "No valid members");
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class T {
+  decltype(N) member;
+};
+static_assert(sizeof(T) == 1, "No valid members");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -466,10 +466,12 @@
  : Var->getType()->isIntegralOrEnumerationType()) &&
 (Var->getType().isConstQualified() ||
  Var->getType()->isReferenceType())) {
-  if (const Expr *Init = Var->getAnyInitializer())
-if (Init->isValueDependent()) {
+  if (const Expr *Init = Var->getAnyInitializer()) {
+if (Init->isValueDependent())
   Deps |= ExprDependence::ValueInstantiation;
-}
+if (Init->containsErrors())
+  Deps |= ExprDependence::Error;
+  }
 }
 
 // (VD) - FIXME: Missing from the standard:


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -26,3 +26,10 @@
 };
 
 void test3() { Crash3(); } // expected-note {{in instantiation of template class}}
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class Crash4 : decltype(N) {
+};
+
+static_assert(sizeof(Crash4) == 1, "");
Index: clang/test/Sema/invalid-member.cpp
===
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -19,3 +19,10 @@
 };
 // Should be able to evaluate sizeof without crashing.
 static_assert(sizeof(Z) == 1, "No valid members");
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class T {
+  decltype(N) member;
+};
+static_assert(sizeof(T) == 1, "No valid members");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -466,10 +466,12 @@
  : Var->getType()->isIntegralOrEnumerationType()) &&
 (Var->getType().isConstQualified() ||
  Var->getType()->isReferenceType())) {
-  if (const Expr *Init = Var->getAnyInitializer())
-if (Init->isValueDependent()) {
+  if (const Expr *Init = Var->getAnyInitializer()) {
+if (Init->isValueDependent())
   Deps |= ExprDependence::ValueInstantiation;
-}
+if (Init->containsErrors())
+  Deps |= ExprDependence::Error;
+  }
 }
 
 // (VD) - FIXME: Missing from the standard:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86139: [SyntaxTree] Split tests related to Namespace

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86139

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2081,7 +2081,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, Namespaces) {
+TEST_P(SyntaxTreeTest, Namespace_Nested) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2089,9 +2089,6 @@
   R"cpp(
 namespace a { namespace b {} }
 namespace a::b {}
-namespace {}
-
-namespace foo = a;
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -2105,82 +2102,91 @@
 | | |-{
 | | `-}
 | `-}
-|-NamespaceDefinition
-| |-namespace
-| |-a
-| |-::
-| |-b
-| |-{
-| `-}
-|-NamespaceDefinition
-| |-namespace
-| |-{
-| `-}
-`-NamespaceAliasDefinition
+`-NamespaceDefinition
   |-namespace
-  |-foo
-  |-=
   |-a
-  `-;
+  |-::
+  |-b
+  |-{
+  `-}
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UsingDirective) {
+TEST_P(SyntaxTreeTest, Namespace_Unnamed) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-namespace ns {}
-using namespace ::ns;
+namespace {}
 )cpp",
   R"txt(
 *: TranslationUnit
-|-NamespaceDefinition
-| |-namespace
-| |-ns
-| |-{
-| `-}
-`-UsingNamespaceDirective
-  |-using
+`-NamespaceDefinition
   |-namespace
-  |-NestedNameSpecifier
-  | `-::
-  |-ns
-  `-;
+  |-{
+  `-}
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UsingDeclaration) {
+TEST_P(SyntaxTreeTest, Namespace_Alias) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+namespace a {}
+[[namespace foo = a;]]
+)cpp",
+  {R"txt(
+NamespaceAliasDefinition
+|-namespace
+|-foo
+|-=
+|-a
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, Namepace_UsingDirective) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+namespace ns {}
+[[using namespace ::ns;]]
+)cpp",
+  {R"txt(
+UsingNamespaceDirective
+|-using
+|-namespace
+|-NestedNameSpecifier
+| `-::
+|-ns
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, Namespace_UsingDeclaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 namespace ns { int a; }
-using ns::a;
+[[using ns::a;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-NamespaceDefinition
-| |-namespace
-| |-ns
-| |-{
-| |-SimpleDeclaration
-| | |-int
-| | |-SimpleDeclarator
-| | | `-a
-| | `-;
-| `-}
-`-UsingDeclaration
-  |-using
-  |-NestedNameSpecifier
-  | |-IdentifierNameSpecifier
-  | | `-ns
-  | `-::
-  |-a
-  `-;
-)txt"));
+  {R"txt(
+UsingDeclaration
+|-using
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-ns
+| `-::
+|-a
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, FreeStandingClasses) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

2020-08-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:1226
+TStream.injextRange(
+const_cast(PrevParamMap)[__VA_ARGS__II]);
+TStream.next(TheTok);

Oh, this has to be fixed as well. `at()` should be fine, we messed something up 
really bad if the information we gathered from containing macro has no mention 
of `__VA_ARGS__`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86135

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


[clang-tools-extra] 8c9ffe3 - [NFC][clang-tidy] Put abseil headers in alphabetical order

2020-08-18 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-08-18T15:52:47+01:00
New Revision: 8c9ffe34d932e2e17cbcf351d6e37783ea5453ae

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

LOG: [NFC][clang-tidy] Put abseil headers in alphabetical order

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h 
b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
index f58ff5bc44b2..335c333573f4 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
@@ -47,14 +47,18 @@ AST_POLYMORPHIC_MATCHER(
   if (PrefixPosition == StringRef::npos)
 return false;
   Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
-  static const char *AbseilLibraries[] = {
-  "algorithm", "base", "container",   "debugging", "flags",
-  "hash",  "iterator", "memory",  "meta",  "numeric",
-  "random","strings",  "synchronization", "status","time",
-  "types", "utility"};
-  return std::any_of(
-  std::begin(AbseilLibraries), std::end(AbseilLibraries),
-  [&](const char *Library) { return Path.startswith(Library); });
+  static const char *AbseilLibraries[] = {"algorithm", "base",
+  "container", "debugging",
+  "flags", "hash",
+  "iterator",  "memory",
+  "meta",  "numeric",
+  "random","status",
+  "strings",   "synchronization",
+  "time",  "types",
+  "utility"};
+  return llvm::any_of(AbseilLibraries, [&](const char *Library) {
+return Path.startswith(Library);
+  });
 }
 
 } // namespace ast_matchers



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


[PATCH] D84049: Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel added a comment.

Committed to master, and created bug to cherry pick into 11.0.

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84049

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


[libunwind] a20f5fe - Default to disabling the libunwind frameheader cache.

2020-08-18 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-08-18T14:37:36-07:00
New Revision: a20f5fe70810e0a768c1814d69d10862965c21e4

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

LOG: Default to disabling the libunwind frameheader cache.

Although it works fine with glibc, as currently implemented the
frameheader cache is incompatible with certain platforms with
slightly different locking semantics inside dl_iterate_phdr.

Therefore only enable it when it is turned on explicitly with
a configure-time option.

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

Added: 


Modified: 
libunwind/CMakeLists.txt
libunwind/src/AddressSpace.hpp
libunwind/test/frameheadercache_test.pass.cpp

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 8419d851ab7f..f4243f3d2791 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -138,6 +138,7 @@ option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to 
refer to pthread funct
 option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
+option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. 
Requires locking dl_iterate_phdr." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
@@ -368,6 +369,10 @@ if(LIBUNWIND_IS_BAREMETAL)
   add_compile_definitions(_LIBUNWIND_IS_BAREMETAL)
 endif()
 
+if(LIBUNWIND_USE_FRAME_HEADER_CACHE)
+  add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)

diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 78d2dd110865..2443bd761cc4 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -411,10 +411,12 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
 #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires 
_LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
   #endif
 
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
 #include "FrameHeaderCache.hpp"
 
 // There should be just one of these per process.
 static FrameHeaderCache ProcessFrameHeaderCache;
+#endif
 
 static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base,
dl_iterate_cb_data *cbdata) {
@@ -435,8 +437,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t pinfo_size,
   auto cbdata = static_cast(data);
   if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr)
 return 0;
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
   if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data))
 return 1;
+#endif
 
   Elf_Addr image_base = calculateImageBase(pinfo);
   bool found_obj = false;
@@ -464,7 +468,9 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t pinfo_size,
   found_obj = checkAddrInSegment(phdr, image_base, cbdata);
 }
 if (found_obj && found_hdr) {
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
   ProcessFrameHeaderCache.add(cbdata->sects);
+#endif
   return 1;
 }
   }

diff  --git a/libunwind/test/frameheadercache_test.pass.cpp 
b/libunwind/test/frameheadercache_test.pass.cpp
index 9397e70d66cb..ebbc00464e07 100644
--- a/libunwind/test/frameheadercache_test.pass.cpp
+++ b/libunwind/test/frameheadercache_test.pass.cpp
@@ -6,7 +6,7 @@
 // The frame header cache should work fine for other architectures,
 // but the #ifdefs end up being even more complicated than this.
 
-#ifdef __x86_64__
+#if defined(__x86_64__) && defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
 
 // This #if chain is ugly, but see the comments in AddressSpace.hpp for
 // the reasoning.



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


[clang] 4cbceb7 - [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-08-18T15:13:19-07:00
New Revision: 4cbceb74bb5676d0181d4d0cab5194d90a42c2ec

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

LOG: [X86] Add basic support for -mtune command line option in clang

Building on the backend support from D85165. This parses the command line 
option in the driver, passes it on to CC1 and adds a function attribute.

-Still need to support tune on the target attribute.
-Need to use "generic" as the tuning by default. But need to change generic in 
the backend first.
-Need to set tune if march is specified and mtune isn't.
-May need to disable getHostCPUName's ability to guess CPU name from features 
when it doesn't have a family/model match for mtune=native. That's what gcc 
appears to do.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Misc/target-invalid-cpu-note.c

Removed: 




diff  --git a/clang/include/clang/Basic/TargetOptions.h 
b/clang/include/clang/Basic/TargetOptions.h
index 4a5d469b8e54..d1cc024957da 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -35,6 +35,9 @@ class TargetOptions {
   /// If given, the name of the target CPU to generate code for.
   std::string CPU;
 
+  /// If given, the name of the target CPU to tune code for.
+  std::string TuneCPU;
+
   /// If given, the unit to use for floating point math.
   std::string FPMath;
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9d36dc6cc393..6827c877acf8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2715,7 +2715,7 @@ def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1O
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
-  HelpText<"Accepted for compatibility with GCC. Currently has no effect.">;
+  HelpText<"Only supported on X86. Otherwise accepted for compatibility with 
GCC.">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
@@ -3490,6 +3490,8 @@ let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
 
 def target_cpu : Separate<["-"], "target-cpu">,
   HelpText<"Target a specific cpu type">;
+def tune_cpu : Separate<["-"], "tune-cpu">,
+  HelpText<"Tune for a specific cpu type">;
 def target_feature : Separate<["-"], "target-feature">,
   HelpText<"Target specific attributes">;
 def triple : Separate<["-"], "triple">,

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index e4456ea7fa0f..c90becd9f012 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -652,6 +652,16 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine ,
 return nullptr;
   }
 
+  // Check the TuneCPU name if specified.
+  if (!Opts->TuneCPU.empty() && !Target->isValidCPUName(Opts->TuneCPU)) {
+Diags.Report(diag::err_target_unknown_cpu) << Opts->TuneCPU;
+SmallVector ValidList;
+Target->fillValidCPUList(ValidList);
+if (!ValidList.empty())
+  Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
+return nullptr;
+  }
+
   // Set the target ABI if specified.
   if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
 Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ff35d94626d1..23d35f68e141 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1749,6 +1749,7 @@ bool 
CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
   // we have a decl for the function and it has a target attribute then
   // parse that and add it to the feature set.
   StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+  StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
   std::vector Features;
   const auto *FD = dyn_cast_or_null(GD.getDecl());
   FD = FD ? FD->getMostRecentDecl() : FD;
@@ -1783,6 +1784,10 @@ bool 
CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
 Attrs.addAttribute("target-cpu", TargetCPU);
 AddedAttr = true;
   }
+  if (TuneCPU != "") {
+Attrs.addAttribute("tune-cpu", TuneCPU);
+AddedAttr = true;
+  }
   if (!Features.empty()) {
 llvm::sort(Features);
 

[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cbceb74bb56: [X86] Add basic support for -mtune command 
line option in clang (authored by craig.topper).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D85384?vs=283456=286409#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85384

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Misc/target-invalid-cpu-note.c

Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -8,6 +8,11 @@
 // AARCH64: note: valid target CPU values are:
 // AARCH64-SAME: cortex-a35,
 
+// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
+// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
+// TUNE_AARCH64: note: valid target CPU values are:
+// TUNE_AARCH64-SAME: cortex-a35,
+
 // RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
 // X86: error: unknown target CPU 'not-a-cpu'
 // X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
@@ -32,6 +37,30 @@
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
 // X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
 
+// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
+// TUNE_X86: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
+// TUNE_X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
+// TUNE_X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
+// TUNE_X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
+// TUNE_X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
+// TUNE_X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
+// TUNE_X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3,
+// TUNE_X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
+// TUNE_X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
+// TUNE_X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
+// TUNE_X86-SAME: x86-64, geode
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
+// TUNE_X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
+// TUNE_X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
+// TUNE_X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
+// TUNE_X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
+// TUNE_X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
+// TUNE_X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
+
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
 // NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35,
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3658,6 +3658,7 @@
   Opts.EABIVersion = EABIVersion;
   }
   Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
+  Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
   Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
   Opts.LinkerVersion =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include 

[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Zixu, thanks for working on improving this.

I agree with @vsapsai on the the `GenModuleActionWrapper` approach. Also, it 
seems to me that even though it would somehow improve the accuracy, it would be 
solving a more general problem, not really specific to this patch. What about 
`CHECK`s for the introduced fix-its? I don't see a `#include` or `#import` 
being matched in the tests.




Comment at: clang/lib/Lex/PPLexerChange.cpp:299
+  ? Twine{"#import \"" + RelativePath + "\"\n"}.str()
+  : Twine{"#include \"" + RelativePath + "\"\n"}.str();
+  unsigned EndOffset = SourceMgr.getDecomposedLoc(EndLoc).second;

Is it possible to incorporate the string selection as part of the diagnostic 
description in the `.td` file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

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


[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 286387.
zequanwu added a comment.

Minor fix on test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/Inputs/comment.h
  clang/test/CoverageMapping/comment.cpp


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 

[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
+  struct EntryKey {
+const FileEntry *Entry;

Can you add a doxygen comment explaining why we compute our own hashing as 
opposed to using the FileEntry pointer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
-  /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  /// All loaded modules, indexed by file name.
+  llvm::StringMap Modules;

CodaFi wrote:
> aprantl wrote:
> > aprantl wrote:
> > > Is it literally the file name, or something like the absolute realpath? 
> > > And just because I'm curious: Is this the name of the .pcm or of the 
> > > module map file?
> > I just realized @vsapsai already asked the same question :-)
> It's the file path the module cache has computed for the PCM. I could try to 
> use the real path to the file, but I'm not sure how portable/stable that 
> interface is relative to this one.
If it's the path to the `.pcm` there's no point in wasting time on realpath — 
there should only be one module cache path and we don't care where exactly it 
is on disk, and the paths inside the module cache ought to be unique anyway, 
because we just computed them. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D86130: [AST] Fix a crash on mangling a binding decl from a DeclRefExpr.

2020-08-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Here's a testcase that produces a name with external linkage:

  struct X { int i, j; };
  auto [a,b] = X{1,2};
  template void f(decltype(a + T())) {}
  template void f(int);

We should make sure that we mangle the reference to `a` as `_Z1aE` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86130

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


[PATCH] D86101: [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:734
+  if (Info.ElementType == CGM.getContext().BoolTy)
+NumElemsPerVG /= 8;
+

I guess NumElemsPerVG of a bool vector is always divisible by 8 because we 
don't expose `` etc.?



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1404
+  ? Subrange->getCount().get()->getSExtValue()
+  : 0;
 

Do we need a test for this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86101

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


[PATCH] D85977: [release][docs] Update contributions to LLVM 11 for SVE.

2020-08-18 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

I merged it in the release branch as 
https://github.com/llvm/llvm-project/commit/7e6bf0bfe6de9e0d0e58764a66f93210f296bbfa


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85977

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Misc/target-invalid-cpu-note.c:49
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'

efriedma wrote:
> Should we have a test for tune-cpu for some non-x86 target?  Or are we happy 
> to just assume this works correctly because we already have coverage for 
> target-cpu?
I copied the AARCH64 test above an added a -tune-cpu version of it. That will 
be included with my commit


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

https://reviews.llvm.org/D85384

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
+  struct EntryKey {
+const FileEntry *Entry;

aprantl wrote:
> Can you add a doxygen comment explaining why we compute our own hashing as 
> opposed to using the FileEntry pointer?
Basically what you wrote in the description of the review...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Perhaps now would be a good time to combine TypeSize and ElementCount into a 
> single Polynomial type? We don't have to implement the whole abstraction of 
> c*x^n (since we currently don't use the exponent, and don't distinguish 
> between X's) but if it's ever needed in the future it will be obvious where 
> to add it, and it will Just Work.

Even if the types are structurally similar, I'd prefer to keep them separate.  
The uses are distinct, the usage in a function signature indicates what kind of 
value we actually expect.  (It's particularly easy to perform incorrect 
conversions with types representing size and alignment.)




Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3522
+  DAG.getNode(ISD::EXTRACT_SUBVECTOR, Dl,
+  MemVT.getHalfNumVectorElementsVT(*DAG.getContext()),
+  StoreNode->getValue(),

ctetreau wrote:
> What is this `>>` thing? Some indicator of whitespace change, or is this a 
> hard tab?
It's an indicator of a whitespace change; I think they started showing up with 
the recent Phabricator upgrade


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86065

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


[clang] b34b1e3 - [Analysis] Bug fix for exploded graph branching in evalCall for constructor

2020-08-18 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-08-19T00:03:31+02:00
New Revision: b34b1e38381fa4d1b1d9751a6b5233b68e734cfe

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

LOG: [Analysis] Bug fix for exploded graph branching in evalCall for constructor

Summary:
Make exactly single NodeBuilder exists at any given time

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ

Subscribers: martong, cfe-commits
Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/test/Analysis/smart-ptr-text-output.cpp
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 38a680eb04c00..802bc934cfb06 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -602,11 +602,11 @@ void ExprEngine::handleConstructor(const Expr *E,
 *Call, *this);
 
   ExplodedNodeSet DstEvaluated;
-  StmtNodeBuilder Bldr(DstPreCall, DstEvaluated, *currBldrCtx);
 
   if (CE && CE->getConstructor()->isTrivial() &&
   CE->getConstructor()->isCopyOrMoveConstructor() &&
   !CallOpts.IsArrayCtorOrDtor) {
+StmtNodeBuilder Bldr(DstPreCall, DstEvaluated, *currBldrCtx);
 // FIXME: Handle other kinds of trivial constructors as well.
 for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = 
DstPreCall.end();
  I != E; ++I)
@@ -626,6 +626,8 @@ void ExprEngine::handleConstructor(const Expr *E,
   // in the CFG, would be called at the end of the full expression or
   // later (for life-time extended temporaries) -- but avoids infeasible
   // paths when no-return temporary destructors are used for assertions.
+  ExplodedNodeSet DstEvaluatedPostProcessed;
+  StmtNodeBuilder Bldr(DstEvaluated, DstEvaluatedPostProcessed, *currBldrCtx);
   const AnalysisDeclContext *ADC = LCtx->getAnalysisDeclContext();
   if (!ADC->getCFGBuildOptions().AddTemporaryDtors) {
 if (llvm::isa_and_nonnull(TargetRegion) &&
@@ -655,7 +657,7 @@ void ExprEngine::handleConstructor(const Expr *E,
   }
 
   ExplodedNodeSet DstPostArgumentCleanup;
-  for (ExplodedNode *I : DstEvaluated)
+  for (ExplodedNode *I : DstEvaluatedPostProcessed)
 finishArgumentConstruction(DstPostArgumentCleanup, I, *Call);
 
   // If there were other constructors called for object-type arguments

diff  --git a/clang/test/Analysis/smart-ptr-text-output.cpp 
b/clang/test/Analysis/smart-ptr-text-output.cpp
index 5280d0021884d..1132a37fa6679 100644
--- a/clang/test/Analysis/smart-ptr-text-output.cpp
+++ b/clang/test/Analysis/smart-ptr-text-output.cpp
@@ -36,14 +36,15 @@ void derefAfterCtrWithNullVariable() {
 }
 
 void derefAfterRelease() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
+  // FIXME: should mark region as uninteresting after release, so above note 
will not be there
   P.release(); // expected-note {{Smart pointer 'P' is released and set to 
null}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
 }
 
 void derefAfterReset() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
@@ -51,7 +52,7 @@ void derefAfterReset() {
 
 void derefAfterResetWithNull() {
   A *NullInnerPtr = nullptr; // expected-note {{'NullInnerPtr' initialized to 
a null pointer value}}
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   P.reset(NullInnerPtr); // expected-note {{Smart pointer 'P' reset using a 
null value}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
@@ -67,7 +68,7 @@ void derefOnReleasedNullRawPtr() {
 }
 
 void derefOnSwappedNullPtr() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   std::unique_ptr PNull; // expected-note {{Default constructed smart 
pointer 'PNull' is null}}
   P.swap(PNull); // expected-note {{Swapped null smart pointer 'PNull' with 
smart pointer 'P'}}
   PNull->foo(); // No warning.
@@ -77,13 +78,11 @@ void derefOnSwappedNullPtr() {
 
 // FIXME: Fix 

[PATCH] D85796: [Analysis] Bug fix for exploded graph branching in evalCall for constructor

2020-08-18 Thread Nithin VR 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 rGb34b1e38381f: [Analysis] Bug fix for exploded graph 
branching in evalCall for constructor (authored by vrnithinkumar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85796

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -41,6 +41,7 @@
 
 void derefAfterValidCtr() {
   std::unique_ptr P(new A());
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // No warning.
 }
 
@@ -50,17 +51,20 @@
 
 void derefAfterDefaultCtr() {
   std::unique_ptr P;
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterCtrWithNull() {
   std::unique_ptr P(nullptr);
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterCtrWithNullVariable() {
   A *InnerPtr = nullptr;
   std::unique_ptr P(InnerPtr);
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
@@ -87,6 +91,7 @@
 void derefAfterResetWithNonNull() {
   std::unique_ptr P;
   P.reset(new A());
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // No warning.
 }
 
@@ -116,37 +121,40 @@
 void pass_smart_ptr_by_ptr(std::unique_ptr *a);
 void pass_smart_ptr_by_const_ptr(const std::unique_ptr *a);
 
-void regioninvalidationTest() {
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_ref(P);
-P->foo(); // no-warning
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_ref(P);
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_rvalue_ref(std::move(P));
-P->foo(); // no-warning
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_rvalue_ref(std::move(P));
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_ptr();
-P->foo();
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_ptr();
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
+void regioninvalidationWithPassByRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_ref(P);
+  P->foo(); // no-warning
+}
+
+void regioninvalidationWithPassByCostRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_ref(P);
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void regioninvalidationWithPassByRValueRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_rvalue_ref(std::move(P));
+  P->foo(); // no-warning
+}
+
+void regioninvalidationWithPassByConstRValueRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_rvalue_ref(std::move(P));
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void regioninvalidationWithPassByPtr() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_ptr();
+  P->foo();
+}
+
+void regioninvalidationWithPassByConstPtr() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_ptr();
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 struct StructWithSmartPtr {
@@ -160,37 +168,40 @@
 void pass_struct_with_smart_ptr_by_ptr(StructWithSmartPtr *a);
 void pass_struct_with_smart_ptr_by_const_ptr(const StructWithSmartPtr *a);
 
-void regioninvalidationTestWithinStruct() {
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_ref(S);
-S.P->foo(); // no-warning
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_ref(S);
-S.P->foo(); // expected-warning {{Dereference of null smart pointer 'S.P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_rvalue_ref(std::move(S));
-S.P->foo(); // no-warning
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_rvalue_ref(std::move(S));
-S.P->foo(); // expected-warning {{Dereference of null smart pointer 'S.P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_ptr();
-S.P->foo();
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_ptr();
-S.P->foo(); // expected-warning {{Dereference of null 

[PATCH] D86176: [clang-tidy] readability-simplify-boolean-expr detects negated literals

2020-08-18 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Adds support for detecting cases like `if (!true) ...`.
Addresses readability-simplify-boolean-expr not detected for negated boolean 
literals. 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86176

Files:
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
@@ -98,6 +98,46 @@
   // CHECK-FIXES-NEXT: {{^  i = 11;$}}
 }
 
+void if_with_negated_bool_condition() {
+  int i = 10;
+  if (!true) {
+i = 11;
+  } else {
+i = 12;
+  }
+  i = 13;
+  // CHECK-MESSAGES: :[[@LINE-6]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  int i = 10;$}}
+  // CHECK-FIXES-NEXT: {{^  {$}}
+  // CHECK-FIXES-NEXT: {{^i = 12;$}}
+  // CHECK-FIXES-NEXT: {{^  }$}}
+  // CHECK-FIXES-NEXT: {{^  i = 13;$}}
+
+  i = 14;
+  if (!false) {
+i = 15;
+  } else {
+i = 16;
+  }
+  i = 17;
+  // CHECK-MESSAGES: :[[@LINE-6]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  i = 14;$}}
+  // CHECK-FIXES-NEXT: {{^  {$}}
+  // CHECK-FIXES-NEXT: {{^i = 15;$}}
+  // CHECK-FIXES-NEXT: {{^  }$}}
+  // CHECK-FIXES-NEXT: {{^  i = 17;$}}
+
+  i = 18;
+  if (!true) {
+i = 19;
+  }
+  i = 20;
+  // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  i = 18;$}}
+  // CHECK-FIXES-NEXT: {{^  $}}
+  // CHECK-FIXES-NEXT: {{^  i = 20;$}}
+}
+
 void operator_equals() {
   int i = 0;
   bool b1 = (i > 2);
Index: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
===
--- clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
+++ clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
@@ -51,11 +51,11 @@
 
   void
   replaceWithThenStatement(const ast_matchers::MatchFinder::MatchResult ,
-   const CXXBoolLiteralExpr *BoolLiteral);
+   const Expr *BoolLiteral);
 
   void
   replaceWithElseStatement(const ast_matchers::MatchFinder::MatchResult ,
-   const CXXBoolLiteralExpr *FalseConditionRemoved);
+   const Expr *FalseConditionRemoved);
 
   void
   replaceWithCondition(const ast_matchers::MatchFinder::MatchResult ,
Index: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -58,16 +58,28 @@
 const char SimplifyConditionalReturnDiagnostic[] =
 "redundant boolean literal in conditional return statement";
 
-const CXXBoolLiteralExpr *getBoolLiteral(const MatchFinder::MatchResult ,
- StringRef Id) {
-  const auto *Literal = Result.Nodes.getNodeAs(Id);
-  return (Literal && Literal->getBeginLoc().isMacroID()) ? nullptr : Literal;
+const Expr *getBoolLiteral(const MatchFinder::MatchResult ,
+   StringRef Id) {
+  if (const Expr *Literal = Result.Nodes.getNodeAs(Id))
+return Literal->getBeginLoc().isMacroID() ? nullptr : Literal;
+  if (const auto *Negated = Result.Nodes.getNodeAs(Id)) {
+if (Negated->getOpcode() == UO_LNot &&
+isa(Negated->getSubExpr()))
+  return Negated->getBeginLoc().isMacroID() ? nullptr : Negated;
+  }
+  return nullptr;
+}
+
+internal::BindableMatcher literalOrNegatedBool(bool Value) {
+  return expr(anyOf(cxxBoolLiteral(equals(Value)),
+unaryOperator(hasUnaryOperand(ignoringParenImpCasts(
+  cxxBoolLiteral(equals(!Value,
+  hasOperatorName("!";
 }
 
 internal::Matcher returnsBool(bool Value, StringRef Id = "ignored") {
-  auto SimpleReturnsBool =
-  returnStmt(has(cxxBoolLiteral(equals(Value)).bind(Id)))
-  .bind("returns-bool");
+  auto SimpleReturnsBool = returnStmt(has(literalOrNegatedBool(Value).bind(Id)))
+   .bind("returns-bool");
   return anyOf(SimpleReturnsBool,
compoundStmt(statementCountIs(1), has(SimpleReturnsBool)));
 }
@@ -269,16 +281,25 @@
   return asBool(getText(Result, *E), 

[clang] 592b899 - Hook up OpenBSD 64-bit RISC-V support

2020-08-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-18T18:59:55-04:00
New Revision: 592b8996bf9b55eec21e1c9e563f51b6108ec2d2

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

LOG: Hook up OpenBSD 64-bit RISC-V support

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index c90becd9f012..50a3b0e83a56 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -391,6 +391,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
 switch (os) {
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
   return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 65928b08be8e..63a96f20de88 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1607,6 +1607,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
 // OPENBSD:#define __INT32_TYPE__ int



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


[PATCH] D85990: [Clang] Fix BZ47169, loader_uninitialized on incomplete types

2020-08-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Were you able to make any progress on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85990

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


[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/pointer-arithmetic.c:88
+  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int((p + 1) - q);  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}

steakhal wrote:
> The suggested expression should be `p+1-q`.
xD more like `(p+1)-q`



Comment at: clang/test/Analysis/pointer-arithmetic.c:100
+  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
+  clang_analyzer_dump_int(q - (p + 1));  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}

steakhal wrote:
> The suggested expression should be `q-p+1`.
`q-(p+1)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi added a comment.

Switched tactics here. Rather than just change the source of the entropy, let's 
increase it from just inodes to (64-bits of inode) plus (file size) plus (mod 
time). It is still possible to defeat this scheme, but it means an attacker 
would have to replace the PCM with one that has been padded out to the same 
size then backdate its modtime to match the one in the cache - or some 
cascading failure of the syscalls providing these data conspires to make this 
happen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 286318.
steakhal marked 4 inline comments as done.
steakhal retitled this revision from "[analyzer][RFC] Handle pointer difference 
of ElementRegion and SymbolicRegion" to "[analyzer] Handle pointer difference 
of ElementRegion and SymbolicRegion".
steakhal edited the summary of this revision.
steakhal added a comment.

- Refined documentation comments as noted.
- Added tests.
- Removed the complicated `ByteOffsetOfElement` lambda.
- Rename revision.

---

Before this patch, only these reported `Unknown` instead of the currently 
expected value.
Besides that all tests passed as-is on master:

  clang_analyzer_dump_int(p - p0);   // expected-warning {{0 S32b}}
  clang_analyzer_dump_int(p - p1);   // expected-warning {{-1 S32b}}
  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}
  
  // Swapped operands:
  clang_analyzer_dump_int(p0 - p);   // expected-warning {{0 S32b}}
  clang_analyzer_dump_int(p1 - p);   // expected-warning {{1 S32b}}
  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}



---

Further notes:
Element{X, n, Ty1} and Element{X, m, Ty2} should compare equal if and only if 
the `n * sizeof(Ty1)` equals to `n * sizeof(Ty2)`.
However, previously it did not take the size of the types into account (there 
is the corresponding FIXIT).
I'm not fixing this either for now.

The analyzer returns `Unknown` for this call:
clang_analyzer_dump_int((p + 1) - q);
However, IMO it should hold the expression 'p+1+q' instead - regardless of `p` 
alias (or not) the same memory region of `p`
There is a FIXME in the testcode for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/pointer-arithmetic.c

Index: clang/test/Analysis/pointer-arithmetic.c
===
--- clang/test/Analysis/pointer-arithmetic.c
+++ clang/test/Analysis/pointer-arithmetic.c
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_dump_ptr(int *);
+void clang_analyzer_dump_int(int);
 
 int test1() {
   int *p = (int *)sizeof(int);
@@ -28,3 +33,88 @@
   p += 1;
   return *p; // expected-warning {{Dereference of null pointer}}
 }
+
+void simplify_symregion_and_elementregion_pointer_arithmetic_and_comparison(int *p, int n, int m, int *q) {
+  // 'q' is SymReg{q}
+  // 'p' is SymReg{p}
+  int *p1 = p + 1;  // Element{p,1}
+  int *p0 = p1 - 1; // Element{p,0}
+  int *pn = p + n;  // Element{p,n}
+  int *pm = p + m;  // Element{p,m}
+
+  clang_analyzer_dump_ptr(q);
+  clang_analyzer_dump_ptr(p);
+  clang_analyzer_dump_ptr(p0);
+  clang_analyzer_dump_ptr(p1);
+  clang_analyzer_dump_ptr(pn);
+  clang_analyzer_dump_ptr(pm);
+  // expected-warning-re@-6 {{{reg_${{[0-9]+}
+  // expected-warning-re@-6 {{{reg_${{[0-9]+}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},0 S64b,int
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},1 S64b,int}}}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},reg_${{[0-9]+}},int}}}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},reg_${{[0-9]+}},int}}}
+
+  // Test the equality operator:
+  clang_analyzer_eval(p == p0);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p == p1);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p1 == pn); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pn == pm); // expected-warning {{UNKNOWN}}
+
+  // Reverse operands:
+  clang_analyzer_eval(p0 == p);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p1 == p);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(pn == p1); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pm == pn); // expected-warning {{UNKNOWN}}
+
+  // Test the inequality operator:
+  clang_analyzer_eval(p != p0);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p != p1);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p1 != pn); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pn != pm); // expected-warning {{UNKNOWN}}
+
+  // Reverse operands:
+  clang_analyzer_eval(p0 != p);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p1 != p);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(pn != p1); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pm != pn); // expected-warning {{UNKNOWN}}
+
+  // Test the subtraction operator:
+  clang_analyzer_dump_int(p - q);// expected-warning-re {{(reg_${{[0-9]+}}) - (reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int(p - p);   

[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

Note that part of my motivation here over D84639 
 is to support more general types on the lane 
intrinsics, since they also express some semantic content which would be 
interesting to be able to express e.g. on descriptors. I wasn't able to bend 
the SelectionDAG type legalization to my will, so that's why I instead 
"legalize" the intrinsics in the AMDGPUCodeGenPrepare pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D84458: [Modules] Improve error message when cannot find parent module for submodule definition.

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM as is, minor suggestion below.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:700
+  "no module named '%0' %select{found|in '%2'}1, "
+  "expected parent module to be defined before the submodule">;
 def err_mmap_top_level_inferred_submodule : Error<

vsapsai wrote:
> Not sure about this second part of the message ("expected..."). Wanted to 
> make it more actionable but not entirely happy with the wording. Any 
> suggestions including removal are welcome.
How about `, parent module must be defined before the submodule`? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84458

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


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo created this revision.
modimo added reviewers: wenlei, asbirlea, vsk.
modimo added a project: LLVM.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya.
Herald added a project: clang.
modimo requested review of this revision.

D65060  uncovered that trying to use BFI in 
loop passes can lead to non-deterministic behavior when blocks are re-used 
while retaining old BFI data.

To make sure BFI is preserved through loop passes a Value Handle (VH) callback 
is registered on blocks themselves. When a block is freed it now also wipes out 
the accompanying BFI entry such that stale BFI data can no longer persist 
resolving the determinism issue.

An optimistic approach would be to incrementally update BFI information 
throughout the loop passes rather than only invalidating them on removed 
blocks. The issues with that are:

1. It is not clear how BFI information should be incrementally updated: If a 
block is duplicated does its BFI information come with? How about if it's 
split/modified/moved around?
2. Assuming we can address these problems the implementation here will be a 
massive undertaking.

There's a known need of BFI in LICM analysis which requires correct but not 
incrementally updated BFI data. Other loop passes can now also use this level 
of information and richer updates can be made as needed.

This diff also moves BFI to be a part of LoopStandardAnalysisResults since the 
previous method using getCachedResults now (correctly!) statically asserts 
(D72893 ) that this data isn't static through 
the loop passes.

Testing
Ninja check


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -10,6 +10,9 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: 

[PATCH] D83088: Introduce CfgTraits abstraction

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

> Not sure that's the best place to be designing this fairly integral and 
> complicated piece of infrastructure from, but hoping we can find some good 
> places/solutions/etc.

I sent an email to llvm-dev several weeks ago, but things seem to have moved 
here. Either way is fine with me.

> But I guess coming back to the original/broader design: What problems is this 
> intended to solve? The inability to write non-template algorithms over 
> graphs? What cost does that come with? Are there algorithms that are a bit 
> too complicated/unwieldy when done as templates? 
> If it's specifically the static/dynamic dispatch issue - I'm not sure the 
> type erasure and runtime overhead may be worth the tradeoff here, though if 
> it is - it'd be good to keep the non-dynamic version common, rather than now 
> having GraphTraits and CfgTraits done a bit differently, etc.

It's not just over graphs, but taking SSA values into account as well -- that 
is the key distinction between GraphTraits and CfgTraits. The most immediate 
problem is divergence analysis, which is extremely complex and difficult to get 
right. If I had tried to fight the accidental complexity that comes with 
attempting to write such an algorithm as C++ templates in addition to the 
inherent complexity of the algorithm at the same time, I'm not sure I would 
have been able to produce anything workable at all.

Frankly, I suspect that our dominator tree implementation also suffer because 
of this, though at least dominator trees are much more well studied in the 
academic literature, so that helps keep the inherent complexity under control.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D80263: [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Nice catch! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80263

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


[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, cchen.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

If the function is not marked exlicitly as declare target and it calls
function(s), marked as declare target device_type(host), these host-only
functions should be dignosed as used in device mode, if the caller
function is not used in device mode too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86164

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/declare_target_messages.cpp


Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -167,7 +167,7 @@
 #pragma omp declare target to(bazzz) device_type(nohost) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
 void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is 
not available on host}}
 void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is 
not available on host}}
-#pragma omp declare target to(host1) device_type(host) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} 
dev5-note 4 {{marked as 'device_type(host)' here}}
+#pragma omp declare target to(host1) device_type(host) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} 
dev5-note 3 {{marked as 'device_type(host)' here}}
 void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is 
not available on host}}
 #pragma omp declare target to(host2)
 void device() {host1();} // dev5-error {{function with 'device_type(host)' is 
not available on device}}
@@ -183,7 +183,7 @@
 #pragma omp end declare target
 
 void any5() {any();}
-void any6() {host1();} // dev5-error {{function with 'device_type(host)' is 
not available on device}}
+void any6() {host1();}
 void any7() {device();} // host5-error {{function with 'device_type(nohost)' 
is not available on host}}
 void any8() {any2();}
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1551,7 +1551,8 @@
 S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
   return;
 // Finalize analysis of OpenMP-specific constructs.
-if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1)
+if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 &&
+(ShouldEmitRootNode || InOMPDeviceContext))
   S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
 if (Caller)
   S.DeviceKnownEmittedFns[FD] = {Caller, Loc};


Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -167,7 +167,7 @@
 #pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
 void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
 void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
-#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 4 {{marked as 'device_type(host)' here}}
+#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}}
 void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}}
 #pragma omp declare target to(host2)
 void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
@@ -183,7 +183,7 @@
 #pragma omp end declare target
 
 void any5() {any();}
-void any6() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
+void any6() {host1();}
 void any7() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
 void any8() {any2();}
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1551,7 +1551,8 @@
 S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
   return;
 // Finalize analysis of OpenMP-specific constructs.
-if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1)
+if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 &&
+(ShouldEmitRootNode || InOMPDeviceContext))
   S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
 if (Caller)
   

[clang] 6b1f9f2 - [X86] Don't call SemaBuiltinConstantArg from CheckX86BuiltinTileDuplicate if Argument is Type or Value Dependent.

2020-08-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-08-18T12:33:40-07:00
New Revision: 6b1f9f2bd4437910804d571284b7c5bb66eac250

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

LOG: [X86] Don't call SemaBuiltinConstantArg from CheckX86BuiltinTileDuplicate 
if Argument is Type or Value Dependent.

SemaBuiltinConstantArg has an early exit for that case that doesn't
produce an error and doesn't update the APInt. We need to detect that
case and not use the APInt value.

While there delete the signature of CheckX86BuiltinTileArgumentsRange
that takes a single Argument index to check. There's another version
that takes an ArrayRef and single value is convertible to an ArrayRef.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1d12551a8ad2..19d58b889ef7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12192,7 +12192,6 @@ class Sema final {
   bool CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
  ArrayRef ArgNums);
-  bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum);
   bool CheckX86BuiltinTileDuplicate(CallExpr *TheCall, ArrayRef ArgNums);
   bool CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall,
 ArrayRef ArgNums);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 70d3a682fc70..deceffdb0ba5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3705,7 +3705,7 @@ bool Sema::CheckX86BuiltinGatherScatterScale(unsigned 
BuiltinID,
 enum { TileRegLow = 0, TileRegHigh = 7 };
 
 bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
-ArrayRef ArgNums) {
+ ArrayRef ArgNums) {
   for (int ArgNum : ArgNums) {
 if (SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh))
   return true;
@@ -3713,19 +3713,20 @@ bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr 
*TheCall,
   return false;
 }
 
-bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum) {
-  return SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh);
-}
-
 bool Sema::CheckX86BuiltinTileDuplicate(CallExpr *TheCall,
 ArrayRef ArgNums) {
   // Because the max number of tile register is TileRegHigh + 1, so here we use
   // each bit to represent the usage of them in bitset.
   std::bitset ArgValues;
   for (int ArgNum : ArgNums) {
-llvm::APSInt Arg;
-SemaBuiltinConstantArg(TheCall, ArgNum, Arg);
-int ArgExtValue = Arg.getExtValue();
+Expr *Arg = TheCall->getArg(ArgNum);
+if (Arg->isTypeDependent() || Arg->isValueDependent())
+  continue;
+
+llvm::APSInt Result;
+if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
+  return true;
+int ArgExtValue = Result.getExtValue();
 assert((ArgExtValue >= TileRegLow || ArgExtValue <= TileRegHigh) &&
"Incorrect tile register num.");
 if (ArgValues.test(ArgExtValue))



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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-08-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp:483
   bool GapRegion = CR.value().Kind == CounterMappingRegion::GapRegion;
 
   if (CR.index() + 1 == Regions.size() ||

zequanwu wrote:
> vsk wrote:
> > Why is this deletion necessary? Do we need to introduce 0-length regions 
> > which alter the count? An example would help.
> Because a single empty line will be a 0 length region. I don't know why is 
> this condition necessary before. Does zero-length region exists before this 
> change?
> 
> example:
> ```
> int main() {
> 
>   return 0;
> }
> ```
> Before, llvm-cov gives the following.
> ```
> Counter in file 0 1:12 -> 4:2, #0
> Counter in file 0 2:1 -> 2:1, 0
> Emitting segments for file: /tmp/a.c
> Combined regions:
>   1:12 -> 4:2 (count=1)
>   2:1 -> 2:1 (count=0)
> Segment at 1:12 (count = 1), RegionEntry
> Segment at 2:1 (count = 0), RegionEntry, Skipped
> Segment at 4:2 (count = 0), Skipped
> 1|  1|int main() {
> 2|   |
> 3|   |return 0;
> 4|   |}
> ```
> After:
> ```
> Counter in file 0 1:12 -> 4:2, #0
> Counter in file 0 2:1 -> 2:1, 0
> Emitting segments for file: /tmp/a.c
> Combined regions:
>   1:12 -> 4:2 (count=1)
>   2:1 -> 2:1 (count=0)
> Segment at 1:12 (count = 1), RegionEntry
> Segment at 2:1 (count = 0), RegionEntry, Skipped
> Segment at 2:1 (count = 1)
> Segment at 4:2 (count = 0), Skipped
> 1|  1|int main() {
> 2|   |
> 3|  1|return 0;
> 4|  1|}
> ```
It looks like we do occasionally see 0-length regions, possibly due to bugs in 
the frontend 
(http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp.html#L485).

I don't expect the reporting tools to be able to handle duplicate segments in a 
robust way. Having duplicate segments was the source of "messed up" coverage 
bugs in the past, due to the contradiction inherent in having two different 
segments begin at the same source location.

Do you see some other way to represent empty lines? Perhaps, if we emit a 
skipped region for an empty line, we can emit a follow-up segment that restores 
the previously-active region starting on the next line? So in this case:

Segment at 1:12 (count = 1), RegionEntry
Segment at 2:1 (count = 0), RegionEntry, Skipped
Segment at 3:1 (count = 1)
Segment at 4:2 (count = 0), Skipped


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

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


[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm still concerned your approach to the computation of getTypeSize() is a 
ticking time bomb, but I'll take the cleanup even if the underlying motivation 
doesn't really make sense.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1847
+IsIncompleteArrayType ? CharUnits::Zero() : TI.first;
+AlignIsRequired = Context.getTypeInfo(D->getType()).AlignIsRequired;
   };

Can we fix getTypeInfoInChars so it returns all the necessary info, so we don't 
look up the typeinfo twice?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191

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


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 286392.
modimo added a comment.

Commit my changes (crazy I know) so that the diff is actually updated for 
linting


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

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -9,7 +9,10 @@
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Starting Loop pass manager run.
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
 ; MSSA-NEXT: Finished Loop pass manager run.
 ; MSSA-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; MSSA-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running pass: ADCEPass on f
 ; MSSA-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; MSSA-NEXT: Finished llvm::Function pass manager run.
Index: llvm/test/Other/pass-pipelines.ll
===
--- llvm/test/Other/pass-pipelines.ll
+++ llvm/test/Other/pass-pipelines.ll
@@ -54,7 +54,7 @@
 ; CHECK-O2-NOT: Manager
 ; CHECK-O2: Loop Pass Manager
 ; CHECK-O2: Loop Pass Manager
-; CHECK-O2-NOT: Manager
+; Requiring block frequency for LICM will place ICM and rotation under separate Loop Pass Manager
 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
 ; causing new loop pass managers.
 ; CHECK-O2: Simplify the CFG
Index: llvm/test/Other/new-pm-thinlto-defaults.ll

[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM with one minor comment




Comment at: clang/test/Misc/target-invalid-cpu-note.c:49
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'

Should we have a test for tune-cpu for some non-x86 target?  Or are we happy to 
just assume this works correctly because we already have coverage for 
target-cpu?


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

https://reviews.llvm.org/D85384

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


[PATCH] D86169: Initial support for letting plugins perform custom parsing of attribute arguments.

2020-08-18 Thread Jonathan Protzenko via Phabricator via cfe-commits
jonathan.protzenko created this revision.
jonathan.protzenko added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jonathan.protzenko requested review of this revision.

This is a preliminary patch that I hope can serve as a basis for discussion. The
design summary below is copy/pasted from 
https://bugs.llvm.org/show_bug.cgi?id=46446#c7

(I'm intentionally posting a work-in-progress so that I can make sure that 
things
are roughly looking good; I'd like to defer details (clang-format'ing my
changes, naming conventions, tests) to later once the design is settled.)

The patch essentially adds the ability for a plugin to handle the parsing of a
CXX11 attribute's arguments. This means that with this patch, plugin-defined
CXX11 attributes are no longer limited to constant attributes that take no
arguments.

The patch intentionally gives the plugin a fair amount of freedom, to enable
interesting use-cases (see below).

The patch does not (yet) tackle the ability for out-of-tree plugins to extend
Attr.td. I'd be happy to work on that once the present patch makes progress.

Design
==

I chose to extend the ParsedAttrInfo class. This allows reusing the logic that
searches for an attribute plugin that has registered a matching spelling, and
reusing the existing registry of plugins. (I contemplated a separate registry,
but thought it would duplicate the spelling-search logic and would also lead to
code duplication in the plugin itself.)

By default, ParsedAttrInfo's (most of which do *not* come from plugins) are
happy to let the built-in clang parsing logic take effect, enforcing tweaking
knobs such as NumArgs and OptArgs. Plugins can, if they are so inclined, elect
to bypass clang's parsing logic (which, as we saw on Bugzilla, ignores CXX11
attribute arguments when they're not known to clang). In that case, plugins are
on their own; they are expected to handle all of the parsing, as well as pushing
the resulting ParsedAttr into the ParsedAttributes. They then report whether the
arguments are syntactically valid or not and the rest of the parsing code
handles error reporting.

(Side-note: this means that it's a three-state return value, and I'm currently
reusing the existing AttrHandling enum, but it could be improved with either
better names or a separate enum.)

The plugin receives, in addition to location information, two key parameters:

- the parser, obviously
- a possibly-null Declarator representing the partially parsed declaration that 
the attribute is attached to, if any.

The second parameter may be the most surprising part of this patch, so let me
try to provide some motivation and context.

My goal is to enable plugins to perform advanced static analysis and code
generation, relying on rich CXX11 attributes capturing deep semantic information
relating, say, a function's parameters, or a struct's fields.

You can easily imagine someone authoring a static analyzer that recognizes:

  typedef struct
  {
size_t len;
uint8_t *chars;
  [[ my_analyzer::invariant(strlen(chars) == len) ]];
  }
  managed_string;

The point here being to leverage a nice CXX11 attribute that benefits from
typo-checking, proper name and macro resolution, etc. rather than using some
unreliable syntax embedded in comments like so many other tools are doing, or
worse, a custom C++ parser.

In our case, we're auto-generating parsers and serializers from a struct type
definition (see https://www.usenix.org/system/files/sec19-ramananandro_0.pdf for
more info), so I'd like to author:

  typedef struct {
uint32_t min_version;
uint32_t max_version
  [[ everparse::constraint (max_version >= min_version && min_version >= 2 
&& max_version <= 4) ]];
  } my_network_format;
  `

Of course, our actual network formats are much more complicated, but this is
just for the sake of example. My point is that allowing plugins a substantial
degree of freedom is likely to enable a flurry of novel and exciting use-cases
based on clang.

Back to the design of the patch, receiving the Declarator allows me to do things
like this (in the plugin):

  Sema  = P->getActions();
  TypeSourceInfo *T = S.GetTypeForDeclarator(*D, P->getCurScope());
  QualType R = T->getType();
  VarDecl *VD = VarDecl::Create(S.getASTContext(), S.CurContext,
  D->getBeginLoc(), D->getIdentifierLoc(), D->getIdentifier(), R,
  T,
  SC_None);
  // Doing this makes sure Sema is aware of the new scope entry, meaning this 
name
  // will be in scope when parsing the expression. (Parsing and scope
  // resolution are intertwined.)
  VD->setImplicit(true);
  S.PushOnScopeChains(VD, P->getCurScope());

This allows my plugin to successfully parse and recognize complex arguments that
refer to the current declarator, in effect letting my plugin define its own
extended syntax and scoping rules.

I hope this helps, I'll keep working on the patch (this is the first version
that seems to do something useful) but 

[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 286390.
modimo added a comment.

Linting


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

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -10,6 +10,9 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Starting Loop pass manager run.
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
 ; MSSA-NEXT: Finished Loop pass manager run.
 ; MSSA-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; MSSA-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running pass: ADCEPass on f
 ; MSSA-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; MSSA-NEXT: Finished llvm::Function pass manager run.
Index: llvm/test/Other/pass-pipelines.ll
===
--- llvm/test/Other/pass-pipelines.ll
+++ llvm/test/Other/pass-pipelines.ll
@@ -54,7 +54,7 @@
 ; CHECK-O2-NOT: Manager
 ; CHECK-O2: Loop Pass Manager
 ; CHECK-O2: Loop Pass Manager
-; CHECK-O2-NOT: Manager
+; Requiring block frequency for LICM will place ICM and rotation under separate Loop Pass Manager
 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
 ; causing new loop pass managers.
 ; CHECK-O2: Simplify the CFG
Index: llvm/test/Other/new-pm-thinlto-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-defaults.ll
+++ 

[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/pointer-arithmetic.c:88
+  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int((p + 1) - q);  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}

The suggested expression should be `p+1-q`.



Comment at: clang/test/Analysis/pointer-arithmetic.c:100
+  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
+  clang_analyzer_dump_int(q - (p + 1));  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}

The suggested expression should be `q-p+1`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

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


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D86154#2224270 , @nhaehnle wrote:

> Note that part of my motivation here over D84639 
>  is to support more general types on the 
> lane intrinsics, since they also express some semantic content which would be 
> interesting to be able to express e.g. on descriptors. I wasn't able to bend 
> the SelectionDAG type legalization to my will, so that's why I instead 
> "legalize" the intrinsics in the AMDGPUCodeGenPrepare pass.

Don't you just need to handle this in ReplaceNodeResults the same way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286361.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,40 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::DenseMapInfo::getHashValue(Val.Entry);
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (LHS.Entry == getEmptyKey().Entry ||
+LHS.Entry == getTombstoneKey().Entry ||
+RHS.Entry == getEmptyKey().Entry ||
+RHS.Entry == getTombstoneKey().Entry) {
+  return LHS.Entry == RHS.Entry;
+}
+if (LHS.Entry == nullptr || RHS.Entry == nullptr) {
+  return LHS.Entry == RHS.Entry;
+}
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +108,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85150: [OpenMP] Ensure testing for versions 4.5 and default - Part 2

2020-08-18 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Please let me know if there are any changes/suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85150

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1752
   StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+  StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
   std::vector Features;

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > Does this lead to a situation in 'attribute-target' where we have a 
> > > 'tune' setting to a processor that is 'before' the 'TargetCPU'?  Should 
> > > this enforce some sort of hierarchy to make sure we only do it if it is 
> > > 'newer' (read, more feature rich) than the target?
> > TuneCPU is only supposed to control microarchitectural things like should i 
> > prefer an "ADD 1" over "INC" instruction. Or should I use more immediate 
> > controlled shuffles over a single variable controlled shuffle. As such that 
> > things we get from tune don't have a straightforward relationship with 
> > architectural features.
> My concern is more.  Say:
> 
> TargetCPU == "nahalem"
> 
> Does it make sense for 
> TuneCPU == "pentium"?
> 
> It would seem to me that is pretty nonsensical.  I've definitely seen the 
> reverse (in within x86_64 at least, where Tune is newer than Target), but 
> tuning for an older CPU seems like nonsense.
From a behavior standpoint, its not any different than what this does today

-march=pentium -msse4.2 -mpopcnt -mfxsr 


I don't think gcc enforces any ordering.  



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

https://reviews.llvm.org/D85384

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


[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

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

LGTM, nit: Is there a "not" missing in the the commit message?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86164

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


[PATCH] D84992: [clang codegen] Use IR "align" attribute for static array arguments.

2020-08-18 Thread Eli Friedman 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 rG673dbe1b5eef: [clang codegen] Use IR align 
attribute for static array arguments. (authored by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84992

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/vla.c


Index: clang/test/CodeGen/vla.c
===
--- clang/test/CodeGen/vla.c
+++ clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   ArrSize) {
@@ -2539,10 +2542,15 @@
 // For C99 VLAs with the static keyword, we don't know the size so
 // we can't use the dereferenceable attribute, but in addrspace(0)
 // we know that it must be nonnull.
-if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
-!getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
-!CGM.getCodeGenOpts().NullPointerIsValid)
-  AI->addAttr(llvm::Attribute::NonNull);
+if (ArrTy->getSizeModifier() == VariableArrayType::Static) {
+  QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+  if (!getContext().getTargetAddressSpace(ETy) &&
+  !CGM.getCodeGenOpts().NullPointerIsValid)
+AI->addAttr(llvm::Attribute::NonNull);
+}
   }
 
   // Set `align` attribute if any.


Index: clang/test/CodeGen/vla.c
===
--- clang/test/CodeGen/vla.c
+++ clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   

[clang] 673dbe1 - [clang codegen] Use IR "align" attribute for static array arguments.

2020-08-18 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-08-18T12:51:16-07:00
New Revision: 673dbe1b5eef09db39783c828a84f1213a47bad0

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

LOG: [clang codegen] Use IR "align" attribute for static array arguments.

Without the "align" attribute, marking the argument dereferenceable is
basically useless.  See also D80166.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46876 .

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/vla.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9d225b23e3c3..98ba1efc20de 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo ,
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   ArrSize) {
@@ -2539,10 +2542,15 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo ,
 // For C99 VLAs with the static keyword, we don't know the size so
 // we can't use the dereferenceable attribute, but in addrspace(0)
 // we know that it must be nonnull.
-if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
-!getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
-!CGM.getCodeGenOpts().NullPointerIsValid)
-  AI->addAttr(llvm::Attribute::NonNull);
+if (ArrTy->getSizeModifier() == VariableArrayType::Static) {
+  QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+  if (!getContext().getTargetAddressSpace(ETy) &&
+  !CGM.getCodeGenOpts().NullPointerIsValid)
+AI->addAttr(llvm::Attribute::NonNull);
+}
   }
 
   // Set `align` attribute if any.

diff  --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
index 16b82f4acc7d..3142050149aa 100644
--- a/clang/test/CodeGen/vla.c
+++ b/clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@ void test7(int a[b(0)]) {
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)



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


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D83261#2224619 , @cchen wrote:

> In PR45212 comment 5 (https://bugs.llvm.org/show_bug.cgi?id=45212#c5), there 
> is a reduced test case that failed after adding this patch. The assertion is 
> from OMPChildren::getInnermostCapturedStmt.
>
> Test case:
>
>   #include 
>   #include 
>   #include 
>   
>   class Myclass
>   {
> public:
> double A[10];
> double B[10];
>   
> void add(int i)
> {
>   for (int k = 0; k < 10; k++) {
>   #pragma omp atomic
> B[k] += A[i];
>   }
> }
>   };
>   
>   int main(int argc, char* argv[]){
> Myclass foo;
>
> for (int i = 0; i < 10; i++) {
> foo.A[i] = i;
> foo.B[i] = 0;
> }
>   
>   #pragma omp target teams distribute parallel for
> for (int i = 0; i < 10; i++) {
> foo.add(i);
> }
>   
> printf("Correctness check: B[2]= %f \n",foo.B[2]);
> return 0;
>   }
>
> Backtrace:
>
>   Assertion failed: (isa(Val) && "cast() argument of incompatible 
> type!"), function cast, file 
> /Users/cchen/workspace/llvm-project/llvm/include/llvm/Support/Casting.h, line 
> 269.
>   PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
> backtrace, preprocessed source, and associated run script.
>   Stack dump:
>   0.  Program arguments: /Users/cchen/llvm/bin/clang-10 -cc1 -triple nvptx64 
> -aux-triple x86_64-apple-darwin18.7.0 -Wundef-prefix=TARGET_OS_ 
> -Werror=undef-prefix -Wdeprecated-objc-isa-usage 
> -Werror=deprecated-objc-isa-usage -emit-llvm -disable-free -main-file-name 
> test.cpp -mrelocation-model static -mframe-pointer=all -fno-rounding-math 
> -fno-verbose-asm -no-integrated-as 
> -fcompatibility-qualified-id-block-type-checking -target-cpu sm_35 
> -fno-split-dwarf-inlining -debugger-tuning=gdb -target-linker-version 512.4 
> -resource-dir /Users/cchen/llvm/lib/clang/12.0.0 -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include/openmp_wrappers -include 
> __clang_openmp_device_functions.h -internal-isystem 
> /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem /usr/include/c++/v1 
> -internal-isystem /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem 
> /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
> /usr/include -internal-isystem /usr/local/include -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
> /usr/include -fdeprecated-macro -fno-dwarf-directory-asm 
> -fdebug-compilation-dir /Users/cchen/workspace/llvm-project/bugfix/45212 
> -ferror-limit 19 -fopenmp -fopenmp-version=50 
> -fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcxx-exceptions 
> -fexceptions -fcolor-diagnostics -fopenmp-is-device 
> -fopenmp-host-ir-file-path 
> /var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-c282ef.bc -o 
> /var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-f0824e.ll -x c++ 
> test.cpp
>   1.  test.cpp:20:1: current parser token 'int'
>   2.  test.cpp:5:7: LLVM IR generation of declaration 'Myclass'
>   0  clang-10 0x000108bead4c 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
>   1  clang-10 0x000108beb309 
> PrintStackTraceSignalHandler(void*) + 25
>   2  clang-10 0x000108be8c46 
> llvm::sys::RunSignalHandlers() + 118
>   3  clang-10 0x000108bed070 SignalHandler(int) + 208
>   4  libsystem_platform.dylib 0x7fff7bd98b5d _sigtramp + 29
>   5  clang-10 0x00010fdc6ae2 
> llvm::DenseMapInfo::Tombstone + 2998754
>   6  libsystem_c.dylib0x7fff7bc526a6 abort + 127
>   7  libsystem_c.dylib0x7fff7bc1b20d basename_r + 0
>   8  clang-10 0x00010e908344 
> llvm::cast_retty::ret_type 
> llvm::cast(clang::Stmt*) + 100
>   9  clang-10 0x00010d4097b3 
> clang::OMPChildren::getInnermostCapturedStmt(llvm::ArrayRef)
>  + 227
>   10 clang-10 0x00010d3f67d5 
> clang::OMPExecutableDirective::getInnermostCapturedStmt() + 197
>   11 clang-10 0x00010959a555 
> clang::OMPExecutableDirective::getInnermostCapturedStmt() const + 21
>   12 clang-10 0x000109599d89 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1305
>   13 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   14 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   15 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   16 

[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286334.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,36 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::hash_combine(Val.Entry, Val.Entry->getSize(),
+  Val.Entry->getModificationTime());
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (RHS.Entry == getEmptyKey().Entry)
+  return LHS.Entry == getEmptyKey().Entry;
+if (RHS.Entry == getTombstoneKey().Entry)
+  return LHS.Entry == getTombstoneKey().Entry;
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +104,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle created this revision.
nhaehnle added a reviewer: arsenm.
Herald added subscribers: cfe-commits, kerbowa, jfb, hiraditya, t-tye, tpr, 
dstuttard, yaxunl, jvesely, kzhuravl.
Herald added projects: clang, LLVM.
nhaehnle requested review of this revision.
Herald added a subscriber: wdng.

These intrinsics should work at least with standard integer and floating
point sizes, pointers, and vectors of those.

This fixes selection for non-s32 types when readfirstlane is inserted
for SGPR return values.

Moving the atomic optimizer pass in the pass pipeline so that it can be
simplified and rely on the more general support of lane intrinsics.

API users should move to these new intrinsics so that we can remove the
old versions.

Change-Id: I1c5e7e7858890e1c30d3b46c8551e74ab7027552
Based-on: https://reviews.llvm.org/D84639


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86154

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUSearchableTables.td
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIInstructions.td
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/lib/Target/AMDGPU/VOP2Instructions.td
  llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-amdgcn.readfirstlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-amdgpu_ps.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-amdgpu_vs.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.readfirstlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.readlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.s.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.writelane.mir
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readfirstlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.writelane.ll
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Index: llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
===
--- llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -2507,8 +2507,8 @@
 
 define amdgpu_kernel void @readfirstlane_constant(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_constant(
-; CHECK-NEXT:[[VAR:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:store volatile i32 [[VAR]], i32* undef, align 4
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:store volatile i32 [[TMP1]], i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 0, i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 123, i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 ptrtoint (i32* @gv to i32), i32* undef, align 4
@@ -2530,8 +2530,8 @@
 
 define i32 @readfirstlane_idempotent(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_idempotent(
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:ret i32 [[READ0]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
   %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
   %read1 = call i32 @llvm.amdgcn.readfirstlane(i32 %read0)
@@ -2541,8 +2541,8 @@
 
 define i32 @readfirstlane_readlane(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_readlane(
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:ret i32 [[READ0]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
   %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
   %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 0)
@@ -2552,11 +2552,11 @@
 define i32 @readfirstlane_readfirstlane_different_block(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_readfirstlane_different_block(
 ; CHECK-NEXT:  bb0:
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
+; CHECK-NEXT:[[TMP0:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
 ; CHECK-NEXT:br label [[BB1:%.*]]
 ; CHECK:   bb1:
-; CHECK-NEXT:[[READ1:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[READ0]])
-; CHECK-NEXT:ret i32 [[READ1]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[TMP0]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
 

[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Do we really have to use worse names here? Keeping the name works even if 
suboptimal for the attributes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-08-18 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Hey Bruno! Thanks for the review.

In D82118#2224423 , @bruno wrote:

> Hi Zixu, thanks for working on improving this.
>
> I agree with @vsapsai on the the `GenModuleActionWrapper` approach. Also, it 
> seems to me that even though it would somehow improve the accuracy, it would 
> be solving a more general problem, not really specific to this patch.

Yes the wrapper is definitely problematic. I'm checking how the diagnostic 
itself is handled correctly and start from there when I have time. For now 
would it be better to separate this into multiple patches and get the 
diagnostic improvement in first?




Comment at: 
clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h:1-3
+// Umbrella.h
+// CHECK: #import "A1.h"
+// CHECK: #import "A2.h"

> What about `CHECK`s for the introduced fix-its? I don't see a `#include` or 
> `#import` being matched in the tests.

Is this the check you're looking for? It is checked in 
`incomplete-umbrella-fixit.m`:
```
RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap 
-fmodules-cache-path=%t -Wno-everything -Wincomplete-umbrella -fixit %s && 
FileCheck %t/Umbrella.h --input-file %t/Umbrella.h --match-full-lines
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

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


[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D86164#2224577 , @jdoerfert wrote:

> LGTM, nit: Is there a "not" missing in the the commit message?

Yes, will add it, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86164

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


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-18 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In PR45212 comment 5 (https://bugs.llvm.org/show_bug.cgi?id=45212#c5), there is 
a reduced test case that failed after adding this patch. The assertion is from 
OMPChildren::getInnermostCapturedStmt.

Test case:

  #include 
  #include 
  #include 
  
  class Myclass
  {
public:
  double A[10];
  double B[10];
  
void add(int i)
{
  for (int k = 0; k < 10; k++) {
  #pragma omp atomic
B[k] += A[i];
  }
}
  };
  
  int main(int argc, char* argv[]){
Myclass foo;
   
for (int i = 0; i < 10; i++) {
foo.A[i] = i;
foo.B[i] = 0;
}
  
  #pragma omp target teams distribute parallel for
for (int i = 0; i < 10; i++) {
foo.add(i);
}
  
printf("Correctness check: B[2]= %f \n",foo.B[2]);
return 0;
  }

Backtrace:

  Assertion failed: (isa(Val) && "cast() argument of incompatible 
type!"), function cast, file 
/Users/cchen/workspace/llvm-project/llvm/include/llvm/Support/Casting.h, line 
269.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: /Users/cchen/llvm/bin/clang-10 -cc1 -triple nvptx64 
-aux-triple x86_64-apple-darwin18.7.0 -Wundef-prefix=TARGET_OS_ 
-Werror=undef-prefix -Wdeprecated-objc-isa-usage 
-Werror=deprecated-objc-isa-usage -emit-llvm -disable-free -main-file-name 
test.cpp -mrelocation-model static -mframe-pointer=all -fno-rounding-math 
-fno-verbose-asm -no-integrated-as 
-fcompatibility-qualified-id-block-type-checking -target-cpu sm_35 
-fno-split-dwarf-inlining -debugger-tuning=gdb -target-linker-version 512.4 
-resource-dir /Users/cchen/llvm/lib/clang/12.0.0 -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include/openmp_wrappers -include 
__clang_openmp_device_functions.h -internal-isystem 
/Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem /usr/include/c++/v1 
-internal-isystem /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem 
/usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
/usr/include -internal-isystem /usr/local/include -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
/usr/include -fdeprecated-macro -fno-dwarf-directory-asm 
-fdebug-compilation-dir /Users/cchen/workspace/llvm-project/bugfix/45212 
-ferror-limit 19 -fopenmp -fopenmp-version=50 
-fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcxx-exceptions 
-fexceptions -fcolor-diagnostics -fopenmp-is-device -fopenmp-host-ir-file-path 
/var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-c282ef.bc -o 
/var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-f0824e.ll -x c++ test.cpp
  1.test.cpp:20:1: current parser token 'int'
  2.test.cpp:5:7: LLVM IR generation of declaration 'Myclass'
  0  clang-10 0x000108bead4c 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
  1  clang-10 0x000108beb309 
PrintStackTraceSignalHandler(void*) + 25
  2  clang-10 0x000108be8c46 llvm::sys::RunSignalHandlers() 
+ 118
  3  clang-10 0x000108bed070 SignalHandler(int) + 208
  4  libsystem_platform.dylib 0x7fff7bd98b5d _sigtramp + 29
  5  clang-10 0x00010fdc6ae2 
llvm::DenseMapInfo::Tombstone + 2998754
  6  libsystem_c.dylib0x7fff7bc526a6 abort + 127
  7  libsystem_c.dylib0x7fff7bc1b20d basename_r + 0
  8  clang-10 0x00010e908344 
llvm::cast_retty::ret_type 
llvm::cast(clang::Stmt*) + 100
  9  clang-10 0x00010d4097b3 
clang::OMPChildren::getInnermostCapturedStmt(llvm::ArrayRef)
 + 227
  10 clang-10 0x00010d3f67d5 
clang::OMPExecutableDirective::getInnermostCapturedStmt() + 197
  11 clang-10 0x00010959a555 
clang::OMPExecutableDirective::getInnermostCapturedStmt() const + 21
  12 clang-10 0x000109599d89 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1305
  13 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  14 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  15 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  16 clang-10 0x00010959a6f0 
clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions(clang::GlobalDecl) + 320
  17 clang-10 0x00010959b97e 
clang::CodeGen::CGOpenMPRuntime::emitTargetGlobal(clang::GlobalDecl) + 142
  18 clang-10 0x00010973c53e 

[PATCH] D85810: [clang] Pass-through remarks options to linker

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Wei, this looks handy! Minor stylish comments below.




Comment at: clang/include/clang/Driver/Driver.h:638
+/// This checks for clang specific R-value ('-Rpass-*') group.
+bool hasRpassOptions(const llvm::opt::ArgList );
+

Nitpicking here, how about `usesRpassOptions`?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:67
+ A->getValue()));
+  }
+

You can also remove curly braces from here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:72
+Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+  }
+

and here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:77
+Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+  }
+}

and here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:99
+  F = llvm::sys::path::stem(Input.getBaseInput());
+}
+  }

and here, hoist the comment above the `if`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85810

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


[clang] 84fffa6 - [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-08-18T13:26:19-07:00
New Revision: 84fffa67283139954b7764328966b5f766db1003

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

LOG: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same 
file as regions' {start, end}Loc

Fix a bug if {Prev, Next}TokLoc is in different file from skipped regions' 
{start, end}Loc

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

Added: 
clang/test/CoverageMapping/Inputs/comment.h
clang/test/CoverageMapping/comment.cpp

Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index e6e1b2111935..8277804d27c0 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@ CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor 
) {
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@ class CoverageMappingBuilder {
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@ class CoverageMappingBuilder {
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&

diff  --git a/clang/test/CoverageMapping/Inputs/comment.h 
b/clang/test/CoverageMapping/Inputs/comment.h
new file mode 100644
index ..eec5833c2bd0
--- /dev/null
+++ b/clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;

diff  --git a/clang/test/CoverageMapping/comment.cpp 
b/clang/test/CoverageMapping/comment.cpp
new file mode 100644
index ..f8e4b4912e18
--- /dev/null
+++ b/clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0



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


[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu 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 rG84fffa672831: [Coverage] Adjust skipped regions only if 
{Prev,Next}TokLoc is in the same file… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/Inputs/comment.h
  clang/test/CoverageMapping/comment.cpp


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- 

[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286460.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,50 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  /// An \c EntryKey is a thin wrapper around a \c FileEntry that implements
+  /// a richer notion of identity.
+  ///
+  /// A plain \c FileEntry has its identity tied to inode numbers. When the
+  /// module cache regenerates a PCM, some filesystem allocators may reuse
+  /// inode numbers for distinct modules, which can cause the cache to return
+  /// mismatched entries. An \c EntryKey ensures that the size and modification
+  /// time are taken into account when determining the identity of a key, which
+  /// significantly decreases - but does not eliminate - the chance of
+  /// a collision.
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::DenseMapInfo::getHashValue(Val.Entry);
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (LHS.Entry == getEmptyKey().Entry ||
+LHS.Entry == getTombstoneKey().Entry ||
+RHS.Entry == getEmptyKey().Entry ||
+RHS.Entry == getTombstoneKey().Entry) {
+  return LHS.Entry == RHS.Entry;
+}
+if (LHS.Entry == nullptr || RHS.Entry == nullptr) {
+  return LHS.Entry == RHS.Entry;
+}
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +118,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi added a comment.

@aprantl Good idea. Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


  1   2   >