[PATCH] D85692: python bindings: fix DeprecationWarning

2020-08-19 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Does this mean we officially no longer support python 2, which this change 
breaks?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85692

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-19 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Thank you preparing this i1 patch and doing it on clang side only.  We were 
testing this patch and sending problem reports.  Now, we can use this patch 
without modifying llvm code.  We can define vector mask types like below.  
Then, we can define intrinsic functions using this type.  Those are converted 
to mask type, e.g v256i1, in the back end without adding bitcasts in 
ISelLowering.cpp.  It helps developers very much.  I hope this extension is 
accepted.

  typedef double __vr __attribute__((__vector_size__(2048)));
  #if __STDC_VERSION__ >= 199901L
  // For C99
  typedef _Bool __vm__attribute__((__vector_size__(32)));
  typedef _Bool __vm256 __attribute__((__vector_size__(32)));
  typedef _Bool __vm512 __attribute__((__vector_size__(64)));
  #else
  #ifdef __cplusplus
  // For C++
  typedef bool __vm__attribute__((__vector_size__(32)));
  typedef bool __vm256 __attribute__((__vector_size__(32)));
  typedef bool __vm512 __attribute__((__vector_size__(64)));
  #else
  #error need C++ or C99 to use vector intrinsics for VE
  #endif
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing

2020-08-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D83298/new/

https://reviews.llvm.org/D83298

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


[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-08-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3938
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\

Will this ever have an issue with lifetime? I can see various values for 
`EXTRACTOR` causing issues here. https://abseil.io/tips/107


It would be good to at least document somewhere the restrictions on `EXTRACTOR`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

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


[PATCH] D85981: [clang][Modules] Increase the Entropy of ModuleManager Map Keys

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

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,67 @@
   // 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;
+off_t Size;
+time_t ModTime;
+
+EntryKey(const FileEntry *Entry) : Entry(Entry), Size(0), ModTime(0) {
+  if (Entry) {
+Size = Entry->getSize();
+ModTime = Entry->getModificationTime();
+  }
+}
+
+EntryKey(const FileEntry *Entry, off_t Size, time_t ModTime)
+: Entry(Entry), Size(Size), ModTime(ModTime) {}
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{
+llvm::DenseMapInfo::getEmptyKey(),
+llvm::DenseMapInfo::getEmptyKey(),
+llvm::DenseMapInfo::getEmptyKey(),
+};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey(),
+llvm::DenseMapInfo::getTombstoneKey(),
+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.Size == RHS.Size &&
+   LHS.ModTime == RHS.ModTime;
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating 

[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-08-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D82860/new/

https://reviews.llvm.org/D82860

___
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-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 286688.
zequanwu added a comment.

minor fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

Files:
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  compiler-rt/test/profile/coverage_emptylines.cpp
  compiler-rt/test/profile/instrprof-set-file-object-merging.c
  compiler-rt/test/profile/instrprof-set-file-object.c
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Index: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -488,8 +488,12 @@
 const bool Skipped = (CR.index() + 1) == Regions.size();
 startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
  CurStartLoc, !GapRegion, Skipped);
+// Create a segment with last pushed regions's count at CurStartLoc.
+startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
+ CurStartLoc, false);
 continue;
   }
+
   if (CR.index() + 1 == Regions.size() ||
   CurStartLoc != Regions[CR.index() + 1].startLoc()) {
 // Emit a segment if the next region doesn't start at the same location
@@ -586,7 +590,7 @@
 for (unsigned I = 1, E = Segments.size(); I < E; ++I) {
   const auto  = Segments[I - 1];
   const auto  = Segments[I];
-  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
+  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col <= R.Col)) {
 LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
   << " followed by " << R.Line << ":" << R.Col << "\n");
 assert(false && "Coverage segments not unique or sorted");
Index: compiler-rt/test/profile/instrprof-set-file-object.c
===
--- compiler-rt/test/profile/instrprof-set-file-object.c
+++ compiler-rt/test/profile/instrprof-set-file-object.c
@@ -24,7 +24,7 @@
 // CHECK:   12|  1|int main(int argc, const char *argv[]) {
 // CHECK:   13|  1|  if (argc < 2)
 // CHECK:   14|  0|return 1;
-// CHECK:   15|  1|
+// CHECK:   15|   |
 // CHECK:   16|  1|  FILE *F = fopen(argv[1], "w+b");
 // CHECK:   17|  1|  __llvm_profile_set_file_object(F, 0);
 // CHECK:   18|  1|  return 0;
Index: compiler-rt/test/profile/instrprof-set-file-object-merging.c
===
--- compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -31,13 +31,13 @@
 // CHECK:   14|  2|int main(int argc, const char *argv[]) {
 // CHECK:   15|  2|  if (argc < 2)
 // CHECK:   16|  0|return 1;
-// CHECK:   17|  2|
+// CHECK:   17|   |
 // CHECK:   18|  2|  FILE *F = fopen(argv[1], "r+b");
 // CHECK:   19|  2|  if (!F) {
 // CHECK:   20|   |// File might not exist, try opening with truncation
 // CHECK:   21|  1|F = fopen(argv[1], "w+b");
 // CHECK:   22|  1|  }
 // CHECK:   23|  2|  __llvm_profile_set_file_object(F, 1);
-// CHECK:   24|  2|
+// CHECK:   24|   |
 // CHECK:   25|  2|  return 0;
 // CHECK:   26|  2|}
Index: compiler-rt/test/profile/coverage_emptylines.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_emptylines.cpp
@@ -0,0 +1,61 @@
+// Remove comments first.
+// RUN: sed 's/[ \t]*\/\/.*//' %s > %t.stripped.cpp
+// RUN: %clangxx_profgen -fcoverage-mapping -o %t %t.stripped.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+
+int main() {// CHECK:   [[# @LINE]]| 1|int main() {
+int x = 0;  // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+x = 1;  // CHECK-NEXT:  [[# @LINE]]| 1|
+if (x)  // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+x   // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+=   // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+// CHECK-NEXT:  [[# @LINE]]|  |
+0;

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

2020-08-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

This looks OK to me.

I think we'll also need updates for `_ExtInt` now too -- we have more 
fundamental types with padding than only `long double` and `bool` now. (I 
continue to be displeased that we assume 8-bit `char` in `__builtin_bit_cast`, 
but that's not new in this patch.)


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] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG724f570ad255: [X86] Add support tune in target 
attribute (authored by craig.topper).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86187

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Sema/attr-target.c

Index: clang/test/Sema/attr-target.c
===
--- clang/test/Sema/attr-target.c
+++ clang/test/Sema/attr-target.c
@@ -1,22 +1,34 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu  -fsyntax-only -verify %s
+
+#ifdef __x86_64__
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
 //expected-error@+1 {{'target' attribute takes one argument}}
 int __attribute__((target())) bar() { return 4; }
-//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+// no warning, tune is supported for x86
 int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("fpmath=387"))) walrus() { return 4; }
-//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() {  return 4; }
 //expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("woof"))) bark() {  return 4; }
 // no warning, same as saying 'nothing'.
 int __attribute__((target("arch="))) turtle() { return 4; }
-//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("branch-protection=none"))) birch_tree() { return 5; }
+//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+
+#else
+
+// tune is not supported by other targets.
+//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss"))) baz() { return 4; }
 
+#endif
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 4; }
 
-int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
 
 int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
@@ -31,12 +30,11 @@
   return 5;
 }
 
+int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
-// We ignore the tune attribute so walrus should be identical to baz and bar.
-// CHECK: walrus{{.*}} #0
 // We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
@@ -48,11 +46,16 @@
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87"
+// CHECK: walrus{{.*}} #8
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" "tune-cpu"="i686"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 

[clang] 724f570 - [X86] Add support 'tune' in target attribute

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

Author: Craig Topper
Date: 2020-08-19T15:58:19-07:00
New Revision: 724f570ad25568acc3a33dcdce9cadd776de2382

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

LOG: [X86] Add support 'tune' in target attribute

This adds parsing and codegen support for tune in target attribute.

I've implemented this so that arch in the target attribute implicitly disables 
tune from the command line. I'm not sure what gcc does here. But since -march 
implies -mtune. I assume 'arch' in the target attribute implies tune in the 
target attribute.

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

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attr-target-x86.c
clang/test/Sema/attr-target.c

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 1b457337d658..b3729b2e0d99 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -334,11 +334,17 @@ static_assert(sizeof(ParamIdx) == 
sizeof(ParamIdx::SerialType),
 struct ParsedTargetAttr {
   std::vector Features;
   StringRef Architecture;
+  StringRef Tune;
   StringRef BranchProtection;
   bool DuplicateArchitecture = false;
+  bool DuplicateTune = false;
   bool operator ==(const ParsedTargetAttr ) const {
 return DuplicateArchitecture == Other.DuplicateArchitecture &&
-   Architecture == Other.Architecture && Features == Other.Features;
+   DuplicateTune == Other.DuplicateTune &&
+   Architecture == Other.Architecture &&
+   Tune == Other.Tune &&
+   BranchProtection == Other.BranchProtection &&
+   Features == Other.Features;
   }
 };
 

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index f525d3566dbb..45244c67efe0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2346,11 +2346,10 @@ def Target : InheritableAttr {
 // accepting it weirdly.
 Feature = Feature.trim();
 
-// We don't support cpu tuning this way currently.
 // TODO: Support the fpmath option. It will require checking
 // overall feature validity for the function with the rest of the
 // attributes on the function.
-if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
+if (Feature.startswith("fpmath="))
   continue;
 
 if (Feature.startswith("branch-protection=")) {
@@ -2364,6 +2363,11 @@ def Target : InheritableAttr {
 Ret.DuplicateArchitecture = true;
   else
 Ret.Architecture = Feature.split("=").second.trim();
+} else if (Feature.startswith("tune=")) {
+  if (!Ret.Tune.empty())
+Ret.DuplicateTune = true;
+  else
+Ret.Tune = Feature.split("=").second.trim();
 } else if (Feature.startswith("no-"))
   Ret.Features.push_back("-" + Feature.split("-").second.str());
 else

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 29ad179e46e9..3a28cf245656 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1898,6 +1898,9 @@ the target with or without a "-mno-" in front 
corresponding to the absence
 of the feature, as well as ``arch="CPU"`` which will change the default "CPU"
 for the function.
 
+For X86, the attribute also allows ``tune="CPU"`` to optimize the generated
+code for the given CPU without changing the available instructions.
+
 For AArch64, the attribute also allows the "branch-protection=" option,
 where the permissible arguments and their effect on code generation are the 
same
 as for the command-line option ``-mbranch-protection``.

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 25e6e317304f..79cee9d75905 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2829,8 +2829,9 @@ def err_attribute_requires_opencl_version : Error<
 def err_invalid_branch_protection_spec : Error<
   "invalid or misplaced branch protection specification '%0'">;
 def warn_unsupported_target_attribute
-: Warning<"%select{unsupported|duplicate}0%select{| architecture}1 '%2' in"
-  " the 'target' attribute string; 'target' attribute ignored">,
+: Warning<"%select{unsupported|duplicate|unknown}0%select{| architecture|"
+  " tune 

[clang] 4a36711 - [X86] Add mtune command line test cases that should have gone with 4cbceb74bb5676d0181d4d0cab5194d90a42c2ec

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

Author: Craig Topper
Date: 2020-08-19T15:58:06-07:00
New Revision: 4a367114397ab5d175cb8b74ee6144978e7fdeba

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

LOG: [X86] Add mtune command line test cases that should have gone with 
4cbceb74bb5676d0181d4d0cab5194d90a42c2ec

Added: 
clang/test/CodeGen/tune-cpu.c
clang/test/Driver/x86-mtune.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/tune-cpu.c b/clang/test/CodeGen/tune-cpu.c
new file mode 100644
index ..60c2c3048623
--- /dev/null
+++ b/clang/test/CodeGen/tune-cpu.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu nehalem 
-emit-llvm %s -o - | FileCheck %s
+
+int baz(int a) { return 4; }
+
+// CHECK: baz{{.*}} #0
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" 
"tune-cpu"="nehalem"

diff  --git a/clang/test/Driver/x86-mtune.c b/clang/test/Driver/x86-mtune.c
new file mode 100644
index ..65ac1a510eec
--- /dev/null
+++ b/clang/test/Driver/x86-mtune.c
@@ -0,0 +1,5 @@
+// Ensure we support the -mtune flag.
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -mtune=nocona 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=nocona
+// nocona: "-tune-cpu" "nocona"



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


[PATCH] D86223: [analyzer][z3] Use more elaborate z3 variable names in debug build

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

In D86223#2226876 , @xazax.hun wrote:

> Exactly, but you could return a StringRef to static storage.
>
> I am fine with both approach. Whichever you find cleaner.

Eh, I'm not sure if it worth it to put these into virtual functions - as 
conditionally overriding functions is not really a good idea.
So we would not win much.

I still think that this way is the cleanest AFAIK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86223

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


[clang] c1c1bed - [c++14] Implement missed piece of N3323: use "converted constant" rules

2020-08-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-08-19T15:45:51-07:00
New Revision: c1c1bed5d0828f1905f1e9a09a32c02f05de9b41

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

LOG: [c++14] Implement missed piece of N3323: use "converted constant" rules
for array bounds, not "integer constant" rules.

For an array bound of class type, this causes us to perform an implicit
conversion to size_t, instead of looking for a unique conversion to
integral or unscoped enumeration type. This affects which cases are
valid when a class has multiple implicit conversion functions to
different types.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index fb9f442bc5bc..49ab94f9df14 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3213,7 +3213,7 @@ class Sema final {
 CCEK_CaseValue,   ///< Expression in a case label.
 CCEK_Enumerator,  ///< Enumerator value with fixed underlying type.
 CCEK_TemplateArg, ///< Value of a non-type template parameter.
-CCEK_NewExpr, ///< Constant expression in a noptr-new-declarator.
+CCEK_ArrayBound,  ///< Array bound in array declarator or new-expression.
 CCEK_ConstexprIf, ///< Condition in a constexpr if statement.
 CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier.
   };

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 335ee95715d0..132f5b0f1721 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1760,12 +1760,10 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool 
UseGlobal,
 // C++1y [expr.new]p6: Every constant-expression in a 
noptr-new-declarator
 //   shall be a converted constant expression (5.19) of type 
std::size_t
 //   and shall evaluate to a strictly positive value.
-unsigned IntWidth = Context.getTargetInfo().getIntWidth();
-assert(IntWidth && "Builtin type of size 0?");
-llvm::APSInt Value(IntWidth);
+llvm::APSInt Value(Context.getIntWidth(Context.getSizeType()));
 Array.NumElts
  = CheckConvertedConstantExpression(NumElts, 
Context.getSizeType(), Value,
-CCEK_NewExpr)
+CCEK_ArrayBound)
  .get();
   } else {
 Array.NumElts

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index bcf6aa7a310e..dc0098964be4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -5628,6 +5628,7 @@ static ExprResult CheckConvertedConstantExpression(Sema 
, Expr *From,
 return Result;
 
   // Check for a narrowing implicit conversion.
+  bool ReturnPreNarrowingValue = false;
   APValue PreNarrowingValue;
   QualType PreNarrowingType;
   switch (SCS->getNarrowingKind(S.Context, Result.get(), PreNarrowingValue,
@@ -5642,12 +5643,22 @@ static ExprResult CheckConvertedConstantExpression(Sema 
, Expr *From,
 break;
 
   case NK_Constant_Narrowing:
+if (CCE == Sema::CCEK_ArrayBound &&
+PreNarrowingType->isIntegralOrEnumerationType() &&
+PreNarrowingValue.isInt()) {
+  // Don't diagnose array bound narrowing here; we produce more precise
+  // errors by allowing the un-narrowed value through.
+  ReturnPreNarrowingValue = true;
+  break;
+}
 S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing)
 << CCE << /*Constant*/ 1
 << PreNarrowingValue.getAsString(S.Context, PreNarrowingType) << T;
 break;
 
   case NK_Type_Narrowing:
+// FIXME: It would be better to diagnose that the expression is not a
+// constant expression.
 S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing)
 << CCE << /*Constant*/ 0 << From->getType() << T;
 break;
@@ -5676,7 +5687,10 @@ static ExprResult CheckConvertedConstantExpression(Sema 
, Expr *From,
 
 if (Notes.empty()) {
   // It's a constant expression.
-  return ConstantExpr::Create(S.Context, Result.get(), Value);
+  Expr *E = ConstantExpr::Create(S.Context, Result.get(), Value);
+  if (ReturnPreNarrowingValue)
+Value = std::move(PreNarrowingValue);
+  return E;
 }
   }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fb62250564b5..c08d4426e5b8 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2229,6 +2229,21 @@ QualType Sema::BuildExtIntType(bool IsUnsigned, Expr 

[PATCH] D85981: [clang][Modules] Increase the Entropy of ModuleManager Map Keys

2020-08-19 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286679.
CodaFi retitled this revision from "[clang][Modules] Use File Names Instead of 
inodes As Loaded Module Keys" to "[clang][Modules] Increase the Entropy of 
ModuleManager Map Keys".

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,67 @@
   // 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;
+off_t Size;
+time_t ModTime;
+
+EntryKey(const FileEntry *Entry) : Entry(Entry), Size(0), ModTime(0) {
+  if (Entry) {
+Size = Entry->getSize();
+ModTime = Entry->getModificationTime();
+  }
+}
+
+EntryKey(const FileEntry *Entry, off_t Size, time_t ModTime)
+: Entry(Entry), Size(Size), ModTime(ModTime) {}
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{
+  llvm::DenseMapInfo::getEmptyKey(),
+  llvm::DenseMapInfo::getEmptyKey(),
+  llvm::DenseMapInfo::getEmptyKey(),
+};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+  llvm::DenseMapInfo::getTombstoneKey(),
+  llvm::DenseMapInfo::getTombstoneKey(),
+  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.Size == RHS.Size &&
+   LHS.ModTime == RHS.ModTime;
+

[PATCH] D86029: [analyzer] Add modeling for unque_ptr::get()

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar marked 2 inline comments as done.
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:362-363
+  const auto *InnerPointVal = State->get(ThisRegion);
+  if (!InnerPointVal)
+return;
+

xazax.hun wrote:
> NoQ wrote:
> > You'll have to actively handle this case, sooner or later. Consider the 
> > following test cases that won't work until you do:
> > ```lang=c++
> > void foo(std::unique_ptr p) {
> >   A *x = p.get();
> >   A *y = p.get();
> >   clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
> >   if (!x) {
> > y->foo(); // expected-warning{{Called C++ object pointer is null}}
> >   }
> > }
> > 
> > ```
> You mean the case where we do not have an inner pointer registered in the 
> state yet, right?
> 
> I believe we might also have to handle similar cases for `operator bool()` as 
> well. 
Added the above test case. 
Using conjureSymbolVal in case of missing inner pointer value



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:362-363
+  const auto *InnerPointVal = State->get(ThisRegion);
+  if (!InnerPointVal)
+return;
+

vrnithinkumar wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > You'll have to actively handle this case, sooner or later. Consider the 
> > > following test cases that won't work until you do:
> > > ```lang=c++
> > > void foo(std::unique_ptr p) {
> > >   A *x = p.get();
> > >   A *y = p.get();
> > >   clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
> > >   if (!x) {
> > > y->foo(); // expected-warning{{Called C++ object pointer is null}}
> > >   }
> > > }
> > > 
> > > ```
> > You mean the case where we do not have an inner pointer registered in the 
> > state yet, right?
> > 
> > I believe we might also have to handle similar cases for `operator bool()` 
> > as well. 
> Added the above test case. 
> Using conjureSymbolVal in case of missing inner pointer value
```
void foo(std::unique_ptr P) {
  A *X = P.get();
  if (!X) {
P->foo(); // expected-warning {{Dereference of null smart pointer 'Pl' 
[alpha.cplusplus.SmartPtr]}}
  }
}
```
I was trying to add the above use case. Since we are using conjureSymbolVal in 
case of missing inner pointer value.

But still the inner pointer value is constrained to [0, 0] in false branch, 
`InnerPointVal->isZeroConstant()` returning false. 
Also I tried `State->isNull(*InnerPointVal).isConstrainedTrue();` This is also 
not working.
How should we check whether the conjureSymbolVal for inner pointer value is 
constrained to [0, 0]?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86029

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


[PATCH] D86029: [analyzer] Add modeling for unque_ptr::get()

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 286675.
vrnithinkumar edited the summary of this revision.
vrnithinkumar added a comment.

- Using conjureSymbolVal in case of missing inner pointer value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86029

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.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
@@ -7,6 +7,7 @@
 
 void clang_analyzer_warnIfReached();
 void clang_analyzer_numTimesReached();
+void clang_analyzer_eval(bool);
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
@@ -252,3 +253,26 @@
   P->foo(); // No warning.
   PValid->foo(); // No warning.
 }
+
+void derefOnRawPtrFromGetOnNullPtr() {
+  std::unique_ptr P;
+  P.get()->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+}
+
+void derefOnRawPtrFromGetOnValidPtr() {
+  std::unique_ptr P(new A());
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromGetOnUnknownPtr(std::unique_ptr P) {
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromMultipleGetOnUnknownPtr(std::unique_ptr P) {
+  A *X = P.get();
+  A *Y = P.get();
+  clang_analyzer_eval(X == Y); // expected-warning{{TRUE}}
+  if (!X) {
+Y->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  }
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -116,3 +116,18 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' of type 'std::unique_ptr' [cplusplus.Move]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P' of type 'std::unique_ptr'}}
 }
+
+void derefOnRawPtrFromGetOnNullPtr() {
+  std::unique_ptr P; // FIXME: add note "Default constructed smart pointer 'P' is null"
+  P.get()->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+}
+
+void derefOnRawPtrFromGetOnValidPtr() {
+  std::unique_ptr P(new A());
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromGetOnUnknownPtr(std::unique_ptr P) {
+  P.get()->foo(); // No warning.
+}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -56,13 +56,15 @@
   void handleReset(const CallEvent , CheckerContext ) const;
   void handleRelease(const CallEvent , CheckerContext ) const;
   void handleSwap(const CallEvent , CheckerContext ) const;
+  void handleGet(const CallEvent , CheckerContext ) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent , CheckerContext &) const;
   CallDescriptionMap SmartPtrMethodHandlers{
   {{"reset"}, ::handleReset},
   {{"release"}, ::handleRelease},
-  {{"swap", 1}, ::handleSwap}};
+  {{"swap", 1}, ::handleSwap},
+  {{"get"}, ::handleGet}};
 };
 } // end of anonymous namespace
 
@@ -345,6 +347,33 @@
   }));
 }
 
+void SmartPtrModeling::handleGet(const CallEvent ,
+ CheckerContext ) const {
+  ProgramStateRef State = C.getState();
+  const auto *IC = dyn_cast();
+  if (!IC)
+return;
+
+  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisRegion)
+return;
+
+  SVal InnerPointerVal;
+  if (const auto *InnerValPtr = State->get(ThisRegion)) {
+InnerPointerVal = *InnerValPtr;
+  } else {
+const auto *CallExpr = Call.getOriginExpr();
+InnerPointerVal = C.getSValBuilder().conjureSymbolVal(
+CallExpr, C.getLocationContext(), Call.getResultType(), C.blockCount());
+State = State->set(ThisRegion, InnerPointerVal);
+  }
+
+  State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
+  InnerPointerVal);
+  // TODO: Add NoteTag, for how the raw pointer got using 'get' method.
+  C.addTransition(State);
+}
+
 void ento::registerSmartPtrModeling(CheckerManager ) {
   auto *Checker = Mgr.registerChecker();
   Checker->ModelSmartPtrDereference =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


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

https://reviews.llvm.org/D86187

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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-08-19 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added a comment.

Hi Nicoali,

In D83088#2227151 , @nhaehnle wrote:

> ...
> Take a look here for example: 
> https://github.com/nhaehnle/llvm-project/blob/715450fa7f968ceefaf9c3b04b47066866c97206/llvm/lib/Analysis/GenericConvergenceUtils.cpp#L499
>  -- this is obviously still fairly simple, but it's an example of printing 
> out the results of an analysis in a way that's generic over the underlying 
> CFG and SSA form. A statically polymorphic wrapper is here: 
> https://github.com/nhaehnle/llvm-project/blob/715450fa7f968ceefaf9c3b04b47066866c97206/llvm/include/llvm/Analysis/GenericConvergenceUtils.h#L569
>
> The simple example might be bearable writing as a template, precisely because 
> it's simple -- so only looking at simple examples is unlikely to really 
> capture the motivation. Really what the motivation boils down to is stuff 
> like this: 
> https://github.com/nhaehnle/llvm-project/blob/controlflow-wip-v7/llvm/lib/Analysis/GenericUniformAnalysis.cpp
>  -- I don't fancy writing all this as a template.
>
> Thid motivation would essentially go away if C++ could type-check against 
> traits in the way that Rust and other languages like it can -- but it can't, 
> so here we are.

Based on your description and the DomTree patches, if I understand correctly, 
the primary motivation is to facilitate writing CFG-representation-agnostic 
algorithms/analyses (e.g., dominators, divergence, convergence analyses), such 
that you can later lift the results back to the representation-aware types? If 
that's correct, I support the overall goal. Having spent probably ~weeks 
wrangling with domtree templates, this sounds like something that could 
simplify life a lot and potentially cut down on compilation times & sizes of 
llvm binaries.


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] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks.

2020-08-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

In D86193#2227129 , @davidxl wrote:

> A heads up -- I won't be able to review patch until mid Sept. Hope this is 
> fine.

Thanks for the heads-up. That's fine. We can wait for your input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

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


[PATCH] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks.

2020-08-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 286664.
hoy edited the summary of this revision.
hoy added a comment.

Updating D86193 : [CSSPGO] Pseudo probe 
instrumentation for basic blocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/emit-pseudo-probe.c
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/Analysis/AliasSetTracker.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/CodeGen/Analysis.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll

Index: llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
@@ -0,0 +1,29 @@
+; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t
+; RUN: FileCheck %s < %t --check-prefix=CHECK-IL
+; RUN: llc %t -stop-after=instruction-select -o - | FileCheck %s --check-prefix=CHECK-MIR
+;
+;; Check the generation of pseudoprobe intrinsic call.
+
+define void @foo(i32 %x) {
+bb0:
+  %cmp = icmp eq i32 %x, 0
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID:]], 1, 0
+  br i1 %cmp, label %bb1, label %bb2
+
+bb1:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 3, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb2:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 2, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb3:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4)
+  ret void
+}
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5122,7 +5122,9 @@
 
 if (I->mayReadOrWriteMemory() &&
 (!isa(I) ||
- cast(I)->getIntrinsicID() != Intrinsic::sideeffect)) {
+ (cast(I)->getIntrinsicID() != Intrinsic::sideeffect &&
+  cast(I)->getIntrinsicID() !=
+  Intrinsic::pseudoprobe))) {
   // Update the linked list of memory accessing instructions.
   if (CurrentLoadStore) {
 CurrentLoadStore->NextLoadStore = SD;
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7167,7 +7167,8 @@
 
   Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
   if (ID && (ID == Intrinsic::assume || ID == Intrinsic::lifetime_end ||
- ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect))
+ ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect ||
+ ID == Intrinsic::pseudoprobe))
 return nullptr;
 
   auto willWiden = [&](unsigned VF) -> bool {
Index: llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ 

[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 286661.
craig.topper added a comment.

Refine the diagnostic message


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

https://reviews.llvm.org/D86187

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Sema/attr-target.c

Index: clang/test/Sema/attr-target.c
===
--- clang/test/Sema/attr-target.c
+++ clang/test/Sema/attr-target.c
@@ -1,22 +1,34 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu  -fsyntax-only -verify %s
+
+#ifdef __x86_64__
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
 //expected-error@+1 {{'target' attribute takes one argument}}
 int __attribute__((target())) bar() { return 4; }
-//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+// no warning, tune is supported for x86
 int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("fpmath=387"))) walrus() { return 4; }
-//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() {  return 4; }
 //expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("woof"))) bark() {  return 4; }
 // no warning, same as saying 'nothing'.
 int __attribute__((target("arch="))) turtle() { return 4; }
-//expected-warning@+1 {{unsupported architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+//expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("branch-protection=none"))) birch_tree() { return 5; }
+//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+
+#else
+
+// tune is not supported by other targets.
+//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss"))) baz() { return 4; }
 
+#endif
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 4; }
 
-int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
 
 int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
@@ -31,12 +30,11 @@
   return 5;
 }
 
+int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
-// We ignore the tune attribute so walrus should be identical to baz and bar.
-// CHECK: walrus{{.*}} #0
 // We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
@@ -48,11 +46,16 @@
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87"
+// CHECK: walrus{{.*}} #8
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" "tune-cpu"="i686"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 

[PATCH] D83088: Introduce CfgTraits abstraction

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

In D83088#2225415 , @dblaikie wrote:

>>> 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.
>
> Not sure I follow - could you give an example of a graph where the 
> GraphTraits concept of the Graph and the CfgTraits concept of the graph (or, 
> perhaps more importantly - features of the graph/API surface area/properties 
> you can expose through the CFG API/concept/thing but not through GraphTraits?

See below.

>> 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.
>
> I'm totally open to discussing making APIs more usable, for sure - though I'm 
> thinking it's likely a concept (like containers in the C++ standard library) 
> might be the better direction.
>
> Perhaps some code samples showing how one would interact (probably not whole 
> algorithms - maybe something simple like generating a dot diagram for a 
> graph) with these things given different APIs (traits, concepts, and runtime 
> polymorphism) - and implementations of each kind too.

Take a look here for example: 
https://github.com/nhaehnle/llvm-project/blob/715450fa7f968ceefaf9c3b04b47066866c97206/llvm/lib/Analysis/GenericConvergenceUtils.cpp#L499
 -- this is obviously still fairly simple, but it's an example of printing out 
the results of an analysis in a way that's generic over the underlying CFG and 
SSA form. A statically polymorphic wrapper is here: 
https://github.com/nhaehnle/llvm-project/blob/715450fa7f968ceefaf9c3b04b47066866c97206/llvm/include/llvm/Analysis/GenericConvergenceUtils.h#L569

The simple example might be bearable writing as a template, precisely because 
it's simple -- so only looking at simple examples is unlikely to really capture 
the motivation. Really what the motivation boils down to is stuff like this: 
https://github.com/nhaehnle/llvm-project/blob/controlflow-wip-v7/llvm/lib/Analysis/GenericUniformAnalysis.cpp
 -- I don't fancy writing all this as a template.

Thid motivation would essentially go away if C++ could type-check against 
traits in the way that Rust and other languages like it can -- but it can't, so 
here we are.


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] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks.

2020-08-19 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

A heads up -- I won't be able to review patch until mid Sept. Hope this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

___
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-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286658.
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] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Attr.h:346
+   Tune == Other.Tune &&
+   BranchProtection == Other.BranchProtection &&
+   Features == Other.Features;

craig.topper wrote:
> Was it a bug that BranchProtection wasn't in the original code?
I just dug out the original review which added it 
(https://reviews.llvm.org/D68711) and there's no mention of why 
`BranchProtection` was missed here, so I think it was just a bug.


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

https://reviews.llvm.org/D86187

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


[clang] 7cffaf5 - [X89] Ignore -mtune=generic to fix failures some users are seeing after D85384

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

Author: Craig Topper
Date: 2020-08-19T13:17:57-07:00
New Revision: 7cffaf510f97eabef89b0d45aeb939df40e8e9d3

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

LOG: [X89] Ignore -mtune=generic to fix failures some users are seeing after 
D85384

Some code bases out there pass -mtune=generic to clang. This would have
been ignored prior to D85384. Now it results in an error
because "generic" isn't recognized by isValidCPUName.

And if we let it go through to the backend as a tune
setting it would get the tune flags closer to i386 rather
than a modern CPU.

I plan to change what tune=generic does in the backend in
a future patch. And allow this in the frontend.
But this should be a quick fix for the error some users
are seeing.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4f37590ffbfb..2054069daa5b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2081,8 +2081,13 @@ void Clang::AddX86TargetArgs(const ArgList ,
 if (Name == "native")
   Name = llvm::sys::getHostCPUName();
 
-CmdArgs.push_back("-tune-cpu");
-CmdArgs.push_back(Args.MakeArgString(Name));
+// Ignore generic either from getHostCPUName or from command line.
+// FIXME: We need to support this eventually but isValidCPUName and the
+// backend aren't ready for it yet.
+if (Name != "generic") {
+  CmdArgs.push_back("-tune-cpu");
+  CmdArgs.push_back(Args.MakeArgString(Name));
+}
   }
 }
 



___
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-19 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb4acd37fe60: [OPENMP]Fix PR47158, case 2: do not report 
host-only functions in unused… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

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)
   S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Author: Alexey Bataev
Date: 2020-08-19T16:14:33-04:00
New Revision: fb4acd37fe60a08a0077560d2814053d76ea1c41

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

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

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 not be dignosed as used in device mode, if the caller
function is not used in device mode too.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index b9d655bab1b0..47484c5be9c9 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1551,7 +1551,8 @@ class DeferredDiagnosticsEmitter
 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};

diff  --git a/clang/test/OpenMP/declare_target_messages.cpp 
b/clang/test/OpenMP/declare_target_messages.cpp
index 3a78e492af58..7287a6682f0b 100644
--- a/clang/test/OpenMP/declare_target_messages.cpp
+++ b/clang/test/OpenMP/declare_target_messages.cpp
@@ -167,7 +167,7 @@ void bazzz() {bazz();}
 #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 @@ void any4() {any2();}
 #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();}
 



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


[PATCH] D86239: [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target region.

2020-08-19 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 reviewer: aaron.ballman.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

OpenMP 5.0 supports nested declare target regions. So, in general,it is
allow to mark a declarationas declare target with different device_type
or link type. Patch adds support for such kind of nesting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86239

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/dump.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp

Index: clang/test/OpenMP/declare_target_ast_print.cpp
===
--- clang/test/OpenMP/declare_target_ast_print.cpp
+++ clang/test/OpenMP/declare_target_ast_print.cpp
@@ -241,6 +241,28 @@
 // CHECK: void cba();
 // CHECK: #pragma omp end declare target
 
+#pragma omp declare target
+int abc1() { return 1; }
+#pragma omp declare target to(abc1) device_type(nohost)
+#pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: #pragma omp declare target device_type(nohost)
+// CHECK-NEXT: int abc1() {
+// CHECK-NEXT: return 1;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp end declare target
+
+#pragma omp declare target
+int inner_link;
+#pragma omp declare target link(inner_link)
+#pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: #pragma omp declare target link
+// CHECK-NEXT: int inner_link;
+// CHECK-NEXT: #pragma omp end declare target
+
 int main (int argc, char **argv) {
   foo();
   foo_c();
@@ -254,4 +276,5 @@
 // CHECK: #pragma omp declare target
 // CHECK-NEXT: int ts = 1;
 // CHECK-NEXT: #pragma omp end declare target
+
 #endif
Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -86,4 +86,4 @@
 // CHECK-NEXT:  | `-ReturnStmt {{.+}} 
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}} <> Implicit MT_To
+// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4644,12 +4644,11 @@
 }
 
 case UPD_DECL_MARKED_OPENMP_DECLARETARGET: {
-  OMPDeclareTargetDeclAttr::MapTypeTy MapType =
-  static_cast(Record.readInt());
-  OMPDeclareTargetDeclAttr::DevTypeTy DevType =
-  static_cast(Record.readInt());
+  auto MapType = Record.readEnum();
+  auto DevType = Record.readEnum();
+  unsigned Level = Record.readInt();
   D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
-  Reader.getContext(), MapType, DevType, readSourceRange(),
+  Reader.getContext(), MapType, DevType, Level, readSourceRange(),
   AttributeCommonInfo::AS_Pragma));
   break;
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2473,7 +2473,7 @@
 StringRef HostDevTy =
 getOpenMPSimpleClauseTypeName(OMPC_device_type, OMPC_DEVICE_TYPE_host);
 Diag(Loc, diag::err_omp_wrong_device_function_call) << HostDevTy << 0;
-Diag(FD->getAttr()->getLocation(),
+Diag(*OMPDeclareTargetDeclAttr::getLocation(FD),
  diag::note_omp_marked_device_type_here)
 << HostDevTy;
 return;
@@ -2484,7 +2484,7 @@
 StringRef NoHostDevTy = getOpenMPSimpleClauseTypeName(
 OMPC_device_type, OMPC_DEVICE_TYPE_nohost);
 Diag(Loc, diag::err_omp_wrong_device_function_call) << NoHostDevTy << 1;
-Diag(FD->getAttr()->getLocation(),
+Diag(*OMPDeclareTargetDeclAttr::getLocation(FD),
  diag::note_omp_marked_device_type_here)
 << NoHostDevTy;
   }
@@ -18483,14 +18483,14 @@
 Diag(Loc, diag::err_omp_region_not_file_context);
 return false;
   }
-  ++DeclareTargetNestingLevel;
+  DeclareTargetNesting.push_back(Loc);
   return true;
 }
 
 void Sema::ActOnFinishOpenMPDeclareTargetDirective() {
-  assert(DeclareTargetNestingLevel > 0 &&
+  assert(!DeclareTargetNesting.empty() &&
  "Unexpected ActOnFinishOpenMPDeclareTargetDirective");
-  --DeclareTargetNestingLevel;
+  DeclareTargetNesting.pop_back();
 }
 
 NamedDecl *
@@ -18543,19 +18543,25 @@
   (ND->isUsed(/*CheckUsedAttr=*/false) || ND->isReferenced()))
 Diag(Loc, diag::warn_omp_declare_target_after_first_use);
 
+  auto *VD = 

[PATCH] D86187: [X86] Add support 'tune' in target attribute

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



Comment at: clang/test/Sema/attr-target.c:26
+//expected-warning@+1 {{unsupported tune 'hiss' in the 'target' attribute 
string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+

"unsupported tune" seems a little weird. For the command-line flag, we print 
something like "unknown target CPU 'hiss'"; can we use similar wording here, so 
it's clear why it's not supported?


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

https://reviews.llvm.org/D86187

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 286634.
RKSimon edited the summary of this revision.
RKSimon added a comment.

Added -x c++ RUN lines to the existing popcnt-builtins.c file - thanks 
@erichkeane


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

Files:
  clang/lib/Headers/popcntintrin.h
  clang/test/CodeGen/popcnt-builtins.c


Index: clang/test/CodeGen/popcnt-builtins.c
===
--- clang/test/CodeGen/popcnt-builtins.c
+++ clang/test/CodeGen/popcnt-builtins.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o 
- | FileCheck %s
-
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///
 /// \headerfile 
@@ -23,7 +29,7 @@
 ///An unsigned 32-bit integer operand.
 /// \returns A 32-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -40,7 +46,7 @@
 ///An unsigned 64-bit integer operand.
 /// \returns A 64-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -48,5 +54,6 @@
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 
 #endif /* __POPCNTINTRIN_H */


Index: clang/test/CodeGen/popcnt-builtins.c
===
--- clang/test/CodeGen/popcnt-builtins.c
+++ clang/test/CodeGen/popcnt-builtins.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
-
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///
 /// \headerfile 
@@ -23,7 +29,7 @@
 ///An unsigned 32-bit integer operand.
 /// \returns A 32-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ 

[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:130
+// Returns empty type if not found valid inner pointer type.
+static QualType getInnerPointerType(const CallEvent , CheckerContext ) {
+  QualType InnerType{};

It seems like a long shot to me.
I am not sure is there any direct or easy way to get inner pointer type from a 
smart pointer  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 286632.
vrnithinkumar marked 5 inline comments as done.
vrnithinkumar added a comment.

Changes to use conjureSymbolVal if the inner pointer value is missing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.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
@@ -252,3 +252,46 @@
   P->foo(); // No warning.
   PValid->foo(); // No warning.
 }
+
+void derefConditionOnNullPtr() {
+  std::unique_ptr P;
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotNullPtr() {
+  std::unique_ptr P;
+  if (!P)
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (P)
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (!P)
+PNull->foo(); // No warning.
+}
+
+void derefConditionOnUnKnownPtr(std::unique_ptr P) {
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefOnValidPtrAfterReset(std::unique_ptr P) {
+  P.reset(new A());
+  if (!P)
+P->foo(); // No warning.
+  else
+P->foo(); // No warning.
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -116,3 +116,80 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' of type 'std::unique_ptr' [cplusplus.Move]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P' of type 'std::unique_ptr'}}
 }
+
+void derefConditionOnNullPtrFalseBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (P) { // expected-note {{Taking false branch}}
+// expected-note@-1{{Smart pointer 'P' is nul}}
+P->foo(); // No warning.
+  } else {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnNullPtrTrueBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (!P) { // expected-note {{Taking true branch}}
+// expected-note@-1{{Smart pointer 'P' is nul}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnValidPtrTrueBranch() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull; // expected-note {{Default constructed smart pointer 'PNull' is null}}
+  if (P) { // expected-note {{Taking true branch}}
+// expected-note@-1{{Smart pointer 'P' is non-nul}}
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'PNull'}}
+  } else {
+PNull->foo(); // No warning
+  }
+}
+
+void derefConditionOnValidPtrFalseBranch() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull; // expected-note {{Default constructed smart pointer 'PNull' is null}}
+  if (!P) { // expected-note {{Taking false branch}}
+// expected-note@-1{{Smart pointer 'P' is non-nul}}
+PNull->foo(); // No warning
+  } else {
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'PNull'}}
+  }
+}
+
+void derefConditionOnNotValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (!P)
+PNull->foo(); // No warning.
+}
+
+void derefConditionOnUnKnownPtrAssumeNull(std::unique_ptr P) {
+  std::unique_ptr PNull; // expected-note {{Default constructed smart pointer 'PNull' is null}}
+  if (!P) { // expected-note {{Taking true branch}}
+// expected-note@-1{{Assuming smart pointer 'P' is null}}
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'PNull'}}
+  }
+}
+
+void derefConditionOnUnKnownPtrAssumeNonNull(std::unique_ptr P) {
+  std::unique_ptr PNull; // expected-note {{Default 

[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:147
 
-if (!move::isMovedFrom(State, ThisR)) {
-  // TODO: Model this case as well. At least, avoid invalidation of
-  // globals.
-  return false;
+if (ModelSmartPtrDereference) {
+  handleBoolOperation(Call, C);

xazax.hun wrote:
> vrnithinkumar wrote:
> > This seems little messy here.
> > I guess once we model the `std::move` for smart ptr it will be less messy 
> I agree. `isNullAfterMoveMethod` is especially confusing as it does not do 
> what the name of the function says. It checks if the `Call` is a boolean 
> conversion operator. I'd suggest renaming that method to make this code a bit 
> more sensible. 
> 
> Moreover, when `ModelSmartPtrDereference` is true, we no longer model moves 
> below right? I think a comment that this logic is duplicated 
> `handleBoolOperation` might make the code cleaner. 
> 
> But yeah, this needs to be cleaned up, hopefully really soon.
- Renamed the method to `isBooleanOpMethod`
- Added comments and FIXME
Hopefully we can clean up once `std::move` is modeled.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:389
+}
+C.addTransition(State);
+  } else if (move::isMovedFrom(State, ThisRegion)) {

xazax.hun wrote:
> This looks fine for now, but we often prefer adding a return after each case 
> to avoid executing multiple `addTransition`s accidentally after refactoring.
Added return



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:411
+  if (NotNullState) {
+auto NonNullVal = C.getSValBuilder().makeTruthVal(true);
+NotNullState =

NoQ wrote:
> vrnithinkumar wrote:
> > Since the inner pointer value can be any non-null value, I am not sure what 
> > should be the value to be added to the map for tracking.
> > 
> Don't add values, constrain existing values.
Made changes to create the conjured symbol and use that to constrain. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


[PATCH] D86223: [analyzer][z3] Use more elaborate z3 variable names in debug build

2020-08-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Exactly, but you could return a StringRef to static storage.

I am fine with both approach. Whichever you find cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86223

___
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-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D85384#2226866 , @craig.topper 
wrote:

> In D85384#2226842 , @aeubanks wrote:
>
>> This doesn't work with -mtune=generic 
>> (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility 
>> be added?
>>
>> (https://crbug.com/1119448)
>>
>>   $ cat /tmp/a.c
>>   int main(){}
>>   $ ./build/bin/clang /tmp/a.c -o /dev/null -mtune=generic
>>   error: unknown target CPU 'generic'
>>   note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, 
>> silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, 
>> westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, 
>> core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, 
>> cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, 
>> athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, 
>> amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, 
>> znver2, x86-64
>
> I was planning to do work supporting that as one of my next patches. But 
> didn't think about the fact that people would already doing it since the 
> option was being ignored. I'll put in a quick fix.

Thanks!
There may be codebases trying to compile under both gcc and clang. Or remnants 
from gcc days?


Repository:
  rG LLVM Github Monorepo

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] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D85384#2226842 , @aeubanks wrote:

> This doesn't work with -mtune=generic 
> (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility 
> be added?
>
> (https://crbug.com/1119448)
>
>   $ cat /tmp/a.c
>   int main(){}
>   $ ./build/bin/clang /tmp/a.c -o /dev/null -mtune=generic
>   error: unknown target CPU 'generic'
>   note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, 
> silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, 
> sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, 
> broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, 
> icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, 
> opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, 
> btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64

I was planning to do work supporting that as one of my next patches. But didn't 
think about the fact that people would already doing it since the option was 
being ignored. I'll put in a quick fix.


Repository:
  rG LLVM Github Monorepo

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] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

RKSimon wrote:
> arsenm wrote:
> > RKSimon wrote:
> > > craig.topper wrote:
> > > > RKSimon wrote:
> > > > > arsenm wrote:
> > > > > > Missing required register target?
> > > > > sure, oddly we don't appear to do this for most of the x86 builtins 
> > > > > codegen tests - I'll see if I can cleanup those soon
> > > > Do we need a registered target if we're stopping at IR generation?
> > > Not really - I'm not sure if its good practice or not, some targets seem 
> > > to do this but x86 not so much.
> > There's a vague desire to be able to omit the target intrinsics if the 
> > target isn't built, which would imply eventually making the clang parts 
> > conditionally compiled
> I'm blanking on this (loong week) - but isn't there a way to tell the 
> driver to treat this as a c program? Then we can either add run lines that 
> test it as 'c' in the (renamed) cpp file or 'c++11' in the original c file - 
> I don't mind which.
`-x c` does it.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

arsenm wrote:
> RKSimon wrote:
> > craig.topper wrote:
> > > RKSimon wrote:
> > > > arsenm wrote:
> > > > > Missing required register target?
> > > > sure, oddly we don't appear to do this for most of the x86 builtins 
> > > > codegen tests - I'll see if I can cleanup those soon
> > > Do we need a registered target if we're stopping at IR generation?
> > Not really - I'm not sure if its good practice or not, some targets seem to 
> > do this but x86 not so much.
> There's a vague desire to be able to omit the target intrinsics if the target 
> isn't built, which would imply eventually making the clang parts 
> conditionally compiled
I'm blanking on this (loong week) - but isn't there a way to tell the 
driver to treat this as a c program? Then we can either add run lines that test 
it as 'c' in the (renamed) cpp file or 'c++11' in the original c file - I don't 
mind which.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

___
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-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

This doesn't work with -mtune=generic 
(https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be 
added?

(https://crbug.com/1119448)


Repository:
  rG LLVM Github Monorepo

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] D86223: [analyzer][z3] Use more elaborate z3 variable names in debug build

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

In D86223#2226630 , @xazax.hun wrote:

> I wonder whether having a virtual method for symbols to get the prefix would 
> be cleaner (something like getKindCStr), but I do not insist.

Are you implying to have something like:

  virtual SmallString<8> clang::ento::SymbolData::getKindStr() const;

BTW probably we could make use of this in the `SymbolData` dump method family.

Or do you want to lift this function to the `SymExpr` class?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86223

___
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-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu 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() ||

vsk wrote:
> 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
I think we should have the following, because the wrapped segment's count will 
be used in next line (e.g. line 3). 
```
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
```


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] D86187: [X86] Add support 'tune' in target attribute

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



Comment at: clang/include/clang/AST/Attr.h:346
+   Tune == Other.Tune &&
+   BranchProtection == Other.BranchProtection &&
+   Features == Other.Features;

Was it a bug that BranchProtection wasn't in the original code?


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

https://reviews.llvm.org/D86187

___
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-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 286622.
zequanwu added a comment.

Add a wrapped segment at location of zero-length segment with last pushed 
region count.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

Files:
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  compiler-rt/test/profile/coverage_emptylines.cpp
  compiler-rt/test/profile/instrprof-set-file-object-merging.c
  compiler-rt/test/profile/instrprof-set-file-object.c
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Index: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -488,8 +488,11 @@
 const bool Skipped = (CR.index() + 1) == Regions.size();
 startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
  CurStartLoc, !GapRegion, Skipped);
+// Create a segment with last pushed regions's count after CurStartLoc.
+startSegment(*ActiveRegions.back(), CurStartLoc, false);
 continue;
   }
+
   if (CR.index() + 1 == Regions.size() ||
   CurStartLoc != Regions[CR.index() + 1].startLoc()) {
 // Emit a segment if the next region doesn't start at the same location
@@ -586,7 +589,7 @@
 for (unsigned I = 1, E = Segments.size(); I < E; ++I) {
   const auto  = Segments[I - 1];
   const auto  = Segments[I];
-  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
+  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col <= R.Col)) {
 LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
   << " followed by " << R.Line << ":" << R.Col << "\n");
 assert(false && "Coverage segments not unique or sorted");
Index: compiler-rt/test/profile/instrprof-set-file-object.c
===
--- compiler-rt/test/profile/instrprof-set-file-object.c
+++ compiler-rt/test/profile/instrprof-set-file-object.c
@@ -24,7 +24,7 @@
 // CHECK:   12|  1|int main(int argc, const char *argv[]) {
 // CHECK:   13|  1|  if (argc < 2)
 // CHECK:   14|  0|return 1;
-// CHECK:   15|  1|
+// CHECK:   15|   |
 // CHECK:   16|  1|  FILE *F = fopen(argv[1], "w+b");
 // CHECK:   17|  1|  __llvm_profile_set_file_object(F, 0);
 // CHECK:   18|  1|  return 0;
Index: compiler-rt/test/profile/instrprof-set-file-object-merging.c
===
--- compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -31,13 +31,13 @@
 // CHECK:   14|  2|int main(int argc, const char *argv[]) {
 // CHECK:   15|  2|  if (argc < 2)
 // CHECK:   16|  0|return 1;
-// CHECK:   17|  2|
+// CHECK:   17|   |
 // CHECK:   18|  2|  FILE *F = fopen(argv[1], "r+b");
 // CHECK:   19|  2|  if (!F) {
 // CHECK:   20|   |// File might not exist, try opening with truncation
 // CHECK:   21|  1|F = fopen(argv[1], "w+b");
 // CHECK:   22|  1|  }
 // CHECK:   23|  2|  __llvm_profile_set_file_object(F, 1);
-// CHECK:   24|  2|
+// CHECK:   24|   |
 // CHECK:   25|  2|  return 0;
 // CHECK:   26|  2|}
Index: compiler-rt/test/profile/coverage_emptylines.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_emptylines.cpp
@@ -0,0 +1,61 @@
+// Remove comments first.
+// RUN: sed 's/[ \t]*\/\/.*//' %s > %t.stripped.cpp
+// RUN: %clangxx_profgen -fcoverage-mapping -o %t %t.stripped.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+
+int main() {// CHECK:   [[# @LINE]]| 1|int main() {
+int x = 0;  // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+x = 1;  // CHECK-NEXT:  [[# @LINE]]| 1|
+if (x)  // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+x   // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+=   // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+// CHECK-NEXT:  [[# @LINE]]|  |
+

[PATCH] D66854: [index-while-building] PathIndexer

2020-08-19 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4da126c3748f: [index-while-building] PathIndexer (authored 
by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66854?vs=283111=286619#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66854

Files:
  clang/include/clang/IndexSerialization/SerializablePathCollection.h
  clang/lib/CMakeLists.txt
  clang/lib/IndexSerialization/CMakeLists.txt
  clang/lib/IndexSerialization/SerializablePathCollection.cpp

Index: clang/lib/IndexSerialization/SerializablePathCollection.cpp
===
--- /dev/null
+++ clang/lib/IndexSerialization/SerializablePathCollection.cpp
@@ -0,0 +1,91 @@
+//===--- SerializablePathCollection.cpp -- Index of paths ---*- 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
+//
+//===--===//
+
+#include "clang/IndexSerialization/SerializablePathCollection.h"
+#include "llvm/Support/Path.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::index;
+
+StringPool::StringOffsetSize StringPool::add(StringRef Str) {
+  const std::size_t Offset = Buffer.size();
+  Buffer += Str;
+  return StringPool::StringOffsetSize(Offset, Str.size());
+}
+
+size_t PathPool::addFilePath(RootDirKind Root,
+ const StringPool::StringOffsetSize ,
+ StringRef Filename) {
+  FilePaths.emplace_back(DirPath(Root, Dir), Paths.add(Filename));
+  return FilePaths.size() - 1;
+}
+
+StringPool::StringOffsetSize PathPool::addDirPath(StringRef Dir) {
+  return Paths.add(Dir);
+}
+
+llvm::ArrayRef PathPool::getFilePaths() const {
+  return FilePaths;
+}
+
+StringRef PathPool::getPaths() const { return Paths.getBuffer(); }
+
+SerializablePathCollection::SerializablePathCollection(
+StringRef CurrentWorkDir, StringRef SysRoot, llvm::StringRef OutputFile)
+: WorkDir(CurrentWorkDir),
+  SysRoot(llvm::sys::path::parent_path(SysRoot).empty() ? StringRef()
+: SysRoot),
+  WorkDirPath(Paths.addDirPath(WorkDir)),
+  SysRootPath(Paths.addDirPath(SysRoot)),
+  OutputFilePath(Paths.addDirPath(OutputFile)) {}
+
+size_t SerializablePathCollection::tryStoreFilePath(const FileEntry ) {
+  auto FileIt = UniqueFiles.find();
+  if (FileIt != UniqueFiles.end())
+return FileIt->second;
+
+  const auto Dir = tryStoreDirPath(sys::path::parent_path(FE.getName()));
+  const auto FileIdx =
+  Paths.addFilePath(Dir.Root, Dir.Path, sys::path::filename(FE.getName()));
+
+  UniqueFiles.try_emplace(, FileIdx);
+  return FileIdx;
+}
+
+PathPool::DirPath SerializablePathCollection::tryStoreDirPath(StringRef Dir) {
+  // We don't want to strip separator if Dir is "/" - so we check size > 1.
+  while (Dir.size() > 1 && llvm::sys::path::is_separator(Dir.back()))
+Dir = Dir.drop_back();
+
+  auto DirIt = UniqueDirs.find(Dir);
+  if (DirIt != UniqueDirs.end())
+return DirIt->second;
+
+  const std::string OrigDir = Dir.str();
+
+  PathPool::RootDirKind Root = PathPool::RootDirKind::Regular;
+  if (!SysRoot.empty() && Dir.startswith(SysRoot) &&
+  llvm::sys::path::is_separator(Dir[SysRoot.size()])) {
+Root = PathPool::RootDirKind::SysRoot;
+Dir = Dir.drop_front(SysRoot.size());
+  } else if (!WorkDir.empty() && Dir.startswith(WorkDir) &&
+ llvm::sys::path::is_separator(Dir[WorkDir.size()])) {
+Root = PathPool::RootDirKind::CurrentWorkDir;
+Dir = Dir.drop_front(WorkDir.size());
+  }
+
+  if (Root != PathPool::RootDirKind::Regular) {
+while (!Dir.empty() && llvm::sys::path::is_separator(Dir.front()))
+  Dir = Dir.drop_front();
+  }
+
+  PathPool::DirPath Result(Root, Paths.addDirPath(Dir));
+  UniqueDirs.try_emplace(OrigDir, Result);
+  return Result;
+}
Index: clang/lib/IndexSerialization/CMakeLists.txt
===
--- /dev/null
+++ clang/lib/IndexSerialization/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_clang_library(clangIndexSerialization
+  SerializablePathCollection.cpp
+
+  LINK_LIBS
+  clangBasic
+  )
Index: clang/lib/CMakeLists.txt
===
--- clang/lib/CMakeLists.txt
+++ clang/lib/CMakeLists.txt
@@ -20,6 +20,7 @@
 add_subdirectory(Tooling)
 add_subdirectory(DirectoryWatcher)
 add_subdirectory(Index)
+add_subdirectory(IndexSerialization)
 if(CLANG_ENABLE_STATIC_ANALYZER)
   add_subdirectory(StaticAnalyzer)
 endif()
Index: clang/include/clang/IndexSerialization/SerializablePathCollection.h

[clang] 4da126c - [index-while-building] PathIndexer

2020-08-19 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-08-19T11:25:21-07:00
New Revision: 4da126c3748f3b6c6251e45614b12d3aa118d047

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

LOG: [index-while-building] PathIndexer

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

Added: 
clang/include/clang/IndexSerialization/SerializablePathCollection.h
clang/lib/IndexSerialization/CMakeLists.txt
clang/lib/IndexSerialization/SerializablePathCollection.cpp

Modified: 
clang/lib/CMakeLists.txt

Removed: 




diff  --git 
a/clang/include/clang/IndexSerialization/SerializablePathCollection.h 
b/clang/include/clang/IndexSerialization/SerializablePathCollection.h
new file mode 100644
index ..20cf8fbdad96
--- /dev/null
+++ b/clang/include/clang/IndexSerialization/SerializablePathCollection.h
@@ -0,0 +1,129 @@
+//===--- SerializablePathCollection.h -- Index of paths -*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_INDEX_SerializablePathCollection_H
+#define LLVM_CLANG_INDEX_SerializablePathCollection_H
+
+#include "clang/Basic/FileManager.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
+
+#include 
+#include 
+
+namespace clang {
+namespace index {
+
+/// Pool of strings
+class StringPool {
+  llvm::SmallString<512> Buffer;
+
+public:
+  struct StringOffsetSize {
+std::size_t Offset;
+std::size_t Size;
+
+StringOffsetSize(size_t Offset, size_t Size) : Offset(Offset), Size(Size) 
{}
+  };
+
+  StringOffsetSize add(StringRef Str);
+  StringRef getBuffer() const { return Buffer; }
+};
+
+/// Pool of filesystem paths backed by a StringPool
+class PathPool {
+public:
+  /// Special root directory of a filesystem path.
+  enum class RootDirKind {
+Regular = 0,
+CurrentWorkDir = 1,
+SysRoot = 2,
+  };
+
+  struct DirPath {
+RootDirKind Root;
+StringPool::StringOffsetSize Path;
+
+DirPath(RootDirKind Root, const StringPool::StringOffsetSize )
+: Root(Root), Path(Path) {}
+  };
+
+  struct FilePath {
+DirPath Dir;
+StringPool::StringOffsetSize Filename;
+
+FilePath(const DirPath , const StringPool::StringOffsetSize )
+: Dir(Dir), Filename(Filename) {}
+  };
+
+  /// \returns index of the newly added file in FilePaths.
+  size_t addFilePath(RootDirKind Root, const StringPool::StringOffsetSize ,
+ StringRef Filename);
+
+  /// \returns offset in Paths and size of newly added directory.
+  StringPool::StringOffsetSize addDirPath(StringRef Dir);
+
+  llvm::ArrayRef getFilePaths() const;
+
+  StringRef getPaths() const;
+
+private:
+  StringPool Paths;
+  std::vector FilePaths;
+};
+
+/// Stores file paths and produces serialization-friendly representation.
+class SerializablePathCollection {
+  std::string WorkDir;
+  std::string SysRoot;
+
+  PathPool Paths;
+  llvm::DenseMap UniqueFiles;
+  llvm::StringMap UniqueDirs;
+
+public:
+  const StringPool::StringOffsetSize WorkDirPath;
+  const StringPool::StringOffsetSize SysRootPath;
+  const StringPool::StringOffsetSize OutputFilePath;
+
+  SerializablePathCollection(llvm::StringRef CurrentWorkDir,
+ llvm::StringRef SysRoot,
+ llvm::StringRef OutputFile);
+
+  /// \returns buffer containing all the paths.
+  llvm::StringRef getPathsBuffer() const { return Paths.getPaths(); }
+
+  /// \returns file paths (no directories) backed by buffer exposed in
+  /// getPathsBuffer.
+  ArrayRef getFilePaths() const {
+return Paths.getFilePaths();
+  }
+
+  /// Stores path to \p FE if it hasn't been stored yet.
+  /// \returns index to array exposed by getPathsBuffer().
+  size_t tryStoreFilePath(const clang::FileEntry );
+
+private:
+  /// Stores \p Path if it is non-empty.
+  /// Warning: this method doesn't check for uniqueness.
+  /// \returns offset of \p Path value begin in buffer with stored paths.
+  StringPool::StringOffsetSize storePath(llvm::StringRef Path);
+
+  /// Stores \p dirStr path if it hasn't been stored yet.
+  PathPool::DirPath tryStoreDirPath(llvm::StringRef dirStr);
+};
+
+} // namespace index
+} // namespace clang
+
+#endif // LLVM_CLANG_INDEX_SerializablePathCollection_H

diff  --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index c2b6a5a4d5d4..23082789ff9a 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt

[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

RKSimon wrote:
> craig.topper wrote:
> > RKSimon wrote:
> > > arsenm wrote:
> > > > Missing required register target?
> > > sure, oddly we don't appear to do this for most of the x86 builtins 
> > > codegen tests - I'll see if I can cleanup those soon
> > Do we need a registered target if we're stopping at IR generation?
> Not really - I'm not sure if its good practice or not, some targets seem to 
> do this but x86 not so much.
There's a vague desire to be able to omit the target intrinsics if the target 
isn't built, which would imply eventually making the clang parts conditionally 
compiled


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


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

2020-08-19 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Do we need to upgrade the old bfmmla to the new signatures?




Comment at: llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll:176
-
-define <4 x float> @test_vbfmlaltq_laneq_f32_v2(<4 x float> %r, <8 x bfloat> 
%a, <8 x bfloat> %b) {
-; CHECK-LABEL: test_vbfmlaltq_laneq_f32_v2:

It seems like it's probably worth keeping this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86146

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


[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In D86187#2226621 , @craig.topper 
wrote:

> Add a note to AttrDocs.td

Thanks for the docs update, continues to LGTM!


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

https://reviews.llvm.org/D86187

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


[PATCH] D86221: [compiler-rt][builtins] Do not assume int to be at least 32 bit wide

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a subscriber: scanon.
atrosinenko added a comment.

On one hand, this `clzdi()` implementation should be completely harmless when 
fallback is implemented via `clzsi()`. On the other hand, it may possibly be 
completely removed. This code snippet mimics one already existing for `clzsi` 
in int_types.h and for currently supported targets it can probably be even as 
simple as this (provided we can use C99):

  #if ULLONG_MAX == 0x
  #define clzdi __builtin_clzll
  #define ctzdi __builtin_ctzll
  #else
  #error could not determine appropriate clzdi macro for this system
  #endif




Comment at: compiler-rt/lib/builtins/int_lib.h:149
 
+static int __inline clzdi(di_int a) {
+#if defined __LP64__

@scanon

This function was copied from fp_lib.h almost unchanged, so it can be used from 
fp_extend.h (the version from that file is almost identical except it does not 
use the properly-sized `clzsi()` macro). But is this manual fallback 
implementation useful nowadays? As I can see, the implementation in fp_lib.h 
remained almost untouched since 2010 when this file was uploaded via 
{rGb1fdde1d01}. Now, `__builtin_clzll` is used in many places of 
compiler-rt/builtins library for seemingly the same purpose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86221

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

craig.topper wrote:
> RKSimon wrote:
> > arsenm wrote:
> > > Missing required register target?
> > sure, oddly we don't appear to do this for most of the x86 builtins codegen 
> > tests - I'll see if I can cleanup those soon
> Do we need a registered target if we're stopping at IR generation?
Not really - I'm not sure if its good practice or not, some targets seem to do 
this but x86 not so much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[clang] a407ec9 - Revert "Revert "[NFC][llvm] Make the contructors of `ElementCount` private.""

2020-08-19 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2020-08-19T17:26:36Z
New Revision: a407ec9b6db1e29e9aa361819f499ad11038d2dd

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

LOG: Revert "Revert "[NFC][llvm] Make the contructors of `ElementCount` 
private.""

Was reverted because MLIR/Flang builds were broken, these APIs have been
fixed in the meantime.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
llvm/include/llvm/Analysis/VectorUtils.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/Support/MachineValueType.h
llvm/include/llvm/Support/TypeSize.h
llvm/lib/Analysis/VFABIDemangling.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/Type.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/unittests/Analysis/VectorUtilsTest.cpp
llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
llvm/unittests/FuzzMutate/OperationsTest.cpp
llvm/unittests/IR/ConstantsTest.cpp
llvm/unittests/IR/PatternMatch.cpp
llvm/unittests/IR/VectorTypesTest.cpp
llvm/unittests/IR/VerifierTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c51629ecfd53..a9cab40247df 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3714,11 +3714,11 @@ QualType ASTContext::getIncompleteArrayType(QualType 
elementType,
 ASTContext::BuiltinVectorTypeInfo
 ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
 #define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS)  
\
-  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true),
\
+  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), 
\
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\
-  {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
+  {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
 
   switch (Ty->getKind()) {
   default:

diff  --git a/llvm/include/llvm/Analysis/VectorUtils.h 
b/llvm/include/llvm/Analysis/VectorUtils.h
index a860652b2332..f77048d45d01 100644
--- a/llvm/include/llvm/Analysis/VectorUtils.h
+++ b/llvm/include/llvm/Analysis/VectorUtils.h
@@ -99,7 +99,8 @@ struct VFShape {
   // Retrieve the VFShape that can be used to map a (scalar) function to 
itself,
   // with VF = 1.
   static VFShape getScalarShape(const CallInst ) {
-return VFShape::get(CI, /*EC*/ {1, false}, /*HasGlobalPredicate*/ false);
+return VFShape::get(CI, ElementCount::getFixed(1),
+/*HasGlobalPredicate*/ false);
   }
 
   // Retrieve the basic vectorization shape of the function, where all
@@ -305,7 +306,7 @@ typedef unsigned ID;
 inline Type *ToVectorTy(Type *Scalar, unsigned VF, bool isScalable = false) {
   if (Scalar->isVoidTy() || VF == 1)
 return Scalar;
-  return VectorType::get(Scalar, {VF, isScalable});
+  return VectorType::get(Scalar, ElementCount::get(VF, isScalable));
 }
 
 /// Identify if the intrinsic is trivially vectorizable.

diff  --git a/llvm/include/llvm/IR/DerivedTypes.h 
b/llvm/include/llvm/IR/DerivedTypes.h
index 843809909d7c..1837f6808f24 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -446,7 +446,8 @@ class VectorType : public Type {
 
   static VectorType *get(Type *ElementType, unsigned NumElements,
  bool Scalable) {
-return VectorType::get(ElementType, {NumElements, Scalable});
+return VectorType::get(ElementType,
+   ElementCount::get(NumElements, Scalable));
   }
 
   static VectorType *get(Type *ElementType, const VectorType *Other) {
@@ -640,7 +641,7 @@ class ScalableVectorType : public VectorType {
 };
 
 inline ElementCount VectorType::getElementCount() const {
-  return ElementCount(ElementQuantity, isa(this));
+  return ElementCount::get(ElementQuantity, isa(this));
 }
 
 /// Class to represent pointers.

diff  --git a/llvm/include/llvm/IR/Intrinsics.h 
b/llvm/include/llvm/IR/Intrinsics.h
index a9e6525e2f3d..3fc7c5a2ceb4 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -134,7 +134,9 @@ namespace Intrinsic {
   unsigned Pointer_AddressSpace;
   unsigned Struct_NumElements;
   unsigned Argument_Info;
-  ElementCount Vector_Width;
+  // There is no default constructor in `ElementCount`, so we 

[PATCH] D86223: [analyzer][z3] Use more elaborate z3 variable names in debug build

2020-08-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!

I wonder whether having a virtual method for symbols to get the prefix would be 
cleaner (something like getKindCStr), but I do not insist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86223

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 286605.
RKSimon added a comment.

Require x86-registered-target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

Files:
  clang/lib/Headers/popcntintrin.h
  clang/test/CodeGen/popcnt-builtins.cpp


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,42 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///
 /// \headerfile 
@@ -23,7 +29,7 @@
 ///An unsigned 32-bit integer operand.
 /// \returns A 32-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -40,7 +46,7 @@
 ///An unsigned 64-bit integer operand.
 /// \returns A 64-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -48,5 +54,6 @@
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 
 #endif /* __POPCNTINTRIN_H */


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,42 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS

[clang] 4fc56d7 - Revert "[NFC][llvm] Make the contructors of `ElementCount` private."

2020-08-19 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2020-08-19T17:21:37Z
New Revision: 4fc56d70aadea9df88e7bf408e2e203dc79ff8e6

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

LOG: Revert "[NFC][llvm] Make the contructors of `ElementCount` private."

This reverts commit 264afb9e6aebc98c353644dd0700bec808501cab.
(and dependent 6b742cc48 and fc53bd610f)

MLIR/Flang are broken.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
llvm/include/llvm/Analysis/VectorUtils.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/Support/MachineValueType.h
llvm/include/llvm/Support/TypeSize.h
llvm/lib/Analysis/VFABIDemangling.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/Type.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/unittests/Analysis/VectorUtilsTest.cpp
llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
llvm/unittests/FuzzMutate/OperationsTest.cpp
llvm/unittests/IR/ConstantsTest.cpp
llvm/unittests/IR/PatternMatch.cpp
llvm/unittests/IR/VectorTypesTest.cpp
llvm/unittests/IR/VerifierTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a9cab40247df..c51629ecfd53 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3714,11 +3714,11 @@ QualType ASTContext::getIncompleteArrayType(QualType 
elementType,
 ASTContext::BuiltinVectorTypeInfo
 ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
 #define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS)  
\
-  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), 
\
+  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true),
\
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\
-  {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
+  {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
 
   switch (Ty->getKind()) {
   default:

diff  --git a/llvm/include/llvm/Analysis/VectorUtils.h 
b/llvm/include/llvm/Analysis/VectorUtils.h
index f77048d45d01..a860652b2332 100644
--- a/llvm/include/llvm/Analysis/VectorUtils.h
+++ b/llvm/include/llvm/Analysis/VectorUtils.h
@@ -99,8 +99,7 @@ struct VFShape {
   // Retrieve the VFShape that can be used to map a (scalar) function to 
itself,
   // with VF = 1.
   static VFShape getScalarShape(const CallInst ) {
-return VFShape::get(CI, ElementCount::getFixed(1),
-/*HasGlobalPredicate*/ false);
+return VFShape::get(CI, /*EC*/ {1, false}, /*HasGlobalPredicate*/ false);
   }
 
   // Retrieve the basic vectorization shape of the function, where all
@@ -306,7 +305,7 @@ typedef unsigned ID;
 inline Type *ToVectorTy(Type *Scalar, unsigned VF, bool isScalable = false) {
   if (Scalar->isVoidTy() || VF == 1)
 return Scalar;
-  return VectorType::get(Scalar, ElementCount::get(VF, isScalable));
+  return VectorType::get(Scalar, {VF, isScalable});
 }
 
 /// Identify if the intrinsic is trivially vectorizable.

diff  --git a/llvm/include/llvm/IR/DerivedTypes.h 
b/llvm/include/llvm/IR/DerivedTypes.h
index 1837f6808f24..843809909d7c 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -446,8 +446,7 @@ class VectorType : public Type {
 
   static VectorType *get(Type *ElementType, unsigned NumElements,
  bool Scalable) {
-return VectorType::get(ElementType,
-   ElementCount::get(NumElements, Scalable));
+return VectorType::get(ElementType, {NumElements, Scalable});
   }
 
   static VectorType *get(Type *ElementType, const VectorType *Other) {
@@ -641,7 +640,7 @@ class ScalableVectorType : public VectorType {
 };
 
 inline ElementCount VectorType::getElementCount() const {
-  return ElementCount::get(ElementQuantity, isa(this));
+  return ElementCount(ElementQuantity, isa(this));
 }
 
 /// Class to represent pointers.

diff  --git a/llvm/include/llvm/IR/Intrinsics.h 
b/llvm/include/llvm/IR/Intrinsics.h
index 3fc7c5a2ceb4..a9e6525e2f3d 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -134,9 +134,7 @@ namespace Intrinsic {
   unsigned Pointer_AddressSpace;
   unsigned Struct_NumElements;
   unsigned Argument_Info;
-  // There is no default constructor in `ElementCount`, so we need
-  

[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 286602.
craig.topper added a comment.

Add a note to AttrDocs.td


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

https://reviews.llvm.org/D86187

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Sema/attr-target.c

Index: clang/test/Sema/attr-target.c
===
--- clang/test/Sema/attr-target.c
+++ clang/test/Sema/attr-target.c
@@ -1,9 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu  -fsyntax-only -verify %s
+
+#ifdef __x86_64__
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
 //expected-error@+1 {{'target' attribute takes one argument}}
 int __attribute__((target())) bar() { return 4; }
-//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+// no warning, tune is supported for x86
 int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("fpmath=387"))) walrus() { return 4; }
@@ -19,4 +22,13 @@
 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("branch-protection=none"))) birch_tree() { return 5; }
+//expected-warning@+1 {{unsupported tune 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+
+#else
+
+// tune is not supported by other targets.
+//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss"))) baz() { return 4; }
 
+#endif
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 4; }
 
-int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
 
 int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
@@ -31,12 +30,11 @@
   return 5;
 }
 
+int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
-// We ignore the tune attribute so walrus should be identical to baz and bar.
-// CHECK: walrus{{.*}} #0
 // We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
@@ -48,11 +46,16 @@
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87"
+// CHECK: walrus{{.*}} #8
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" "tune-cpu"="i686"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-f16c,-fma,-fma4,-gfni,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
-// CHECK: #4 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
+// CHECK-NOT: tune-cpu
+// CHECK: #2 = {{.*}}"target-cpu"="i686" 

[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

arsenm wrote:
> Missing required register target?
sure, oddly we don't appear to do this for most of the x86 builtins codegen 
tests - I'll see if I can cleanup those soon


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

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



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

arsenm wrote:
> Missing required register target?
Do we need a registered target if we're stopping at IR generation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 286601.
RKSimon added a comment.

add c++11 limiter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

Files:
  clang/lib/Headers/popcntintrin.h
  clang/test/CodeGen/popcnt-builtins.cpp


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///
 /// \headerfile 
@@ -23,7 +29,7 @@
 ///An unsigned 32-bit integer operand.
 /// \returns A 32-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -40,7 +46,7 @@
 ///An unsigned 64-bit integer operand.
 /// \returns A 64-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -48,5 +54,6 @@
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 
 #endif /* __POPCNTINTRIN_H */


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///

[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/popcnt-builtins.cpp:3
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+

Missing required register target?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[PATCH] D83296: [clang-format] Add a MacroExpander.

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



Comment at: clang/lib/Format/MacroExpander.cpp:186
+Tok->MacroCtx = MacroContext(MR_ExpandedArg);
+  pushToken(Tok);
+}

klimek wrote:
> sammccall wrote:
> > you're pushing here without copying. This means the original tokens from 
> > the ArgsList are mutated. Maybe we own them, but this seems at least wrong 
> > for multiple expansion of the same arg.
> > 
> > e.g.
> > ```
> > #define M(X,Y) X Y X
> > M(1,2)
> > ```
> > 
> > Will expand to:
> > - 1, ExpandedArg, ExpandedFrom = [M, M] // should just be one M
> > - 2, ExpandedArg, ExpandedFrom = [M]
> > - 1, ExpandedArg, ExpandedFrom = [M, M] // this is the same token pointer 
> > as the first one
> > 
> > Maybe it would be better if pushToken performed the copy, and returned a 
> > mutable pointer to the copy. (If you can make the input const, that would 
> > prevent this type of bug)
> Ugh. I'll need to take a deeper look, but generally, the problem is we don't 
> want to copy - we're mutating the data of the token while formatting the 
> expanded token stream, and then re-use that info when formatting the original 
> stream.
> We could copy, add a reference to the original token, and then have a step 
> that adapts in the end, and perhaps that's cleaner overall anyway, but will 
> be quite a change.
> The alternative is that I'll look into how to specifically handle 
> double-expansion (or ... forbid it).
> (or ... forbid it).

I'm starting to think this is the best option.

The downsides seem pretty acceptable to me:
 - it's another wart to document: on the other hand it simplifies the 
conceptual model, I think it helps users understand the deeper behavior
 - some macros require simplification rather than supplying the actual 
definition: already crossed this bridge by not supporting macros in macro 
bodies, variadics, pasting...
 - loses information: one expansion is enough to establish which part of the 
grammar the arguments form in realistic cases. (Even in pathological cases, 
preserving the conflicting info only helps you if you have a plan to resolve 
the conflicts)
 - it's another wart to document: 

Are there any others?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

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


[clang] bcaa806 - [Clang] Fix BZ47169, loader_uninitialized on incomplete types

2020-08-19 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2020-08-19T18:11:50+01:00
New Revision: bcaa806a4747595116b538e8b75b12966e6607f6

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

LOG: [Clang] Fix BZ47169, loader_uninitialized on incomplete types

[Clang] Fix BZ47169, loader_uninitialized on incomplete types

Reported by @erichkeane. Fix proposed by @erichkeane works, tests included.
Bug introduced in D74361. Crash was on querying a CXXRecordDecl for
hasTrivialDefaultConstructor on an incomplete type. Fixed by calling
RequireCompleteType in the right place.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
clang/test/Sema/attr-loader-uninitialized.c
clang/test/Sema/attr-loader-uninitialized.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ab1496337210..566a2f9da681 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12476,6 +12476,17 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
 }
 
 if (!Var->isInvalidDecl() && RealDecl->hasAttr()) 
{
+  if (Var->getStorageClass() == SC_Extern) {
+Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
+<< Var;
+Var->setInvalidDecl();
+return;
+  }
+  if (RequireCompleteType(Var->getLocation(), Var->getType(),
+  diag::err_typecheck_decl_incomplete_type)) {
+Var->setInvalidDecl();
+return;
+  }
   if (CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
 if (!RD->hasTrivialDefaultConstructor()) {
   Diag(Var->getLocation(), 
diag::err_loader_uninitialized_trivial_ctor);
@@ -12483,12 +12494,6 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
   return;
 }
   }
-  if (Var->getStorageClass() == SC_Extern) {
-Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
-<< Var;
-Var->setInvalidDecl();
-return;
-  }
 }
 
 VarDecl::DefinitionKind DefKind = Var->isThisDeclarationADefinition();

diff  --git a/clang/test/CodeGenCXX/attr-loader-uninitialized.cpp 
b/clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
index e82ae47e9f16..6501a25bf5bc 100644
--- a/clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
+++ b/clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
@@ -28,3 +28,15 @@ double arr[32] __attribute__((loader_uninitialized));
 // Defining as arr2[] [[clang..]] raises the error: attribute cannot be 
applied to types
 // CHECK: @arr2 = global [4 x double] undef
 double arr2 [[clang::loader_uninitialized]] [4];
+
+template struct templ{T * t;};
+
+// CHECK: @templ_int = global %struct.templ undef, align 8
+templ templ_int [[clang::loader_uninitialized]];
+
+// CHECK: @templ_trivial = global %struct.templ.0 undef, align 8
+templ templ_trivial [[clang::loader_uninitialized]];
+
+// CHECK: @templ_incomplete = global %struct.templ.1 undef, align 8
+struct incomplete;
+templ templ_incomplete [[clang::loader_uninitialized]];

diff  --git a/clang/test/Sema/attr-loader-uninitialized.c 
b/clang/test/Sema/attr-loader-uninitialized.c
index f2e78d981580..a1edd858e27f 100644
--- a/clang/test/Sema/attr-loader-uninitialized.c
+++ b/clang/test/Sema/attr-loader-uninitialized.c
@@ -10,6 +10,10 @@ const int can_still_be_const 
__attribute__((loader_uninitialized));
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 
'extern' and with the 'loader_uninitialized' attribute}}
 
+struct S;
+extern struct S incomplete_external_rejected 
__attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'incomplete_external_rejected' cannot be 
declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
 int noargs __attribute__((loader_uninitialized(0)));
 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
 
@@ -35,3 +39,8 @@ __private_extern__ int initialized_private_extern_rejected 
__attribute__((loader
 
 extern __attribute__((visibility("hidden"))) int extern_hidden 
__attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'extern_hidden' cannot be declared both 
'extern' and with the 'loader_uninitialized' attribute}}
+
+struct Incomplete;
+struct Incomplete incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
+// expected-note@-3 {{forward declaration of 'struct Incomplete'}}

diff  --git a/clang/test/Sema/attr-loader-uninitialized.cpp 
b/clang/test/Sema/attr-loader-uninitialized.cpp
index 

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

2020-08-19 Thread Jon Chesterfield 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 rGbcaa806a4747: [Clang] Fix BZ47169, loader_uninitialized on 
incomplete types (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85990

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
  clang/test/Sema/attr-loader-uninitialized.c
  clang/test/Sema/attr-loader-uninitialized.cpp

Index: clang/test/Sema/attr-loader-uninitialized.cpp
===
--- clang/test/Sema/attr-loader-uninitialized.cpp
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -9,6 +9,10 @@
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
 
+struct S;
+extern S incomplete_external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'incomplete_external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
 int noargs __attribute__((loader_uninitialized(0)));
 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
 
@@ -58,3 +62,12 @@
 
 nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
+
+struct Incomplete;
+Incomplete incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'Incomplete'}}
+// expected-note@-3 {{forward declaration of 'Incomplete'}}
+
+struct Incomplete s_incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
+// expected-note@-7 {{forward declaration of 'Incomplete'}}
Index: clang/test/Sema/attr-loader-uninitialized.c
===
--- clang/test/Sema/attr-loader-uninitialized.c
+++ clang/test/Sema/attr-loader-uninitialized.c
@@ -10,6 +10,10 @@
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
 
+struct S;
+extern struct S incomplete_external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'incomplete_external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
 int noargs __attribute__((loader_uninitialized(0)));
 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
 
@@ -35,3 +39,8 @@
 
 extern __attribute__((visibility("hidden"))) int extern_hidden __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'extern_hidden' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+struct Incomplete;
+struct Incomplete incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
+// expected-note@-3 {{forward declaration of 'struct Incomplete'}}
Index: clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
===
--- clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
+++ clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
@@ -28,3 +28,15 @@
 // Defining as arr2[] [[clang..]] raises the error: attribute cannot be applied to types
 // CHECK: @arr2 = global [4 x double] undef
 double arr2 [[clang::loader_uninitialized]] [4];
+
+template struct templ{T * t;};
+
+// CHECK: @templ_int = global %struct.templ undef, align 8
+templ templ_int [[clang::loader_uninitialized]];
+
+// CHECK: @templ_trivial = global %struct.templ.0 undef, align 8
+templ templ_trivial [[clang::loader_uninitialized]];
+
+// CHECK: @templ_incomplete = global %struct.templ.1 undef, align 8
+struct incomplete;
+templ templ_incomplete [[clang::loader_uninitialized]];
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12476,6 +12476,17 @@
 }
 
 if (!Var->isInvalidDecl() && RealDecl->hasAttr()) {
+  if (Var->getStorageClass() == SC_Extern) {
+Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
+<< Var;
+Var->setInvalidDecl();
+return;
+  }
+  if (RequireCompleteType(Var->getLocation(), Var->getType(),
+  diag::err_typecheck_decl_incomplete_type)) {
+Var->setInvalidDecl();
+return;
+  }
   if (CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
 if (!RD->hasTrivialDefaultConstructor()) {
   

[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Headers/popcntintrin.h:16
 
+#ifdef __cplusplus
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr

craig.topper wrote:
> Do we need to check for C++11?
I don't actually know - its trivial to add a __cplusplus >= 201103L check but I 
don't know what we are expected to support in compiler headers like these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

___
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-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Works out cleanly, thanks for the suggestion.




Comment at: clang/lib/Sema/SemaDecl.cpp:12478
 
 if (!Var->isInvalidDecl() && RealDecl->hasAttr()) 
{
+  if (Var->getStorageClass() == SC_Extern) {

Same as first diff except for swapping the existing two checks over.


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] D85990: [Clang] Fix BZ47169, loader_uninitialized on incomplete types

2020-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 286598.
JonChesterfield added a comment.

- Use more specific diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85990

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
  clang/test/Sema/attr-loader-uninitialized.c
  clang/test/Sema/attr-loader-uninitialized.cpp

Index: clang/test/Sema/attr-loader-uninitialized.cpp
===
--- clang/test/Sema/attr-loader-uninitialized.cpp
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -9,6 +9,10 @@
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
 
+struct S;
+extern S incomplete_external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'incomplete_external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
 int noargs __attribute__((loader_uninitialized(0)));
 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
 
@@ -58,3 +62,12 @@
 
 nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
+
+struct Incomplete;
+Incomplete incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'Incomplete'}}
+// expected-note@-3 {{forward declaration of 'Incomplete'}}
+
+struct Incomplete s_incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
+// expected-note@-7 {{forward declaration of 'Incomplete'}}
Index: clang/test/Sema/attr-loader-uninitialized.c
===
--- clang/test/Sema/attr-loader-uninitialized.c
+++ clang/test/Sema/attr-loader-uninitialized.c
@@ -10,6 +10,10 @@
 extern int external_rejected __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
 
+struct S;
+extern struct S incomplete_external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'incomplete_external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
 int noargs __attribute__((loader_uninitialized(0)));
 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
 
@@ -35,3 +39,8 @@
 
 extern __attribute__((visibility("hidden"))) int extern_hidden __attribute__((loader_uninitialized));
 // expected-error@-1 {{variable 'extern_hidden' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+struct Incomplete;
+struct Incomplete incomplete __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
+// expected-note@-3 {{forward declaration of 'struct Incomplete'}}
Index: clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
===
--- clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
+++ clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
@@ -28,3 +28,15 @@
 // Defining as arr2[] [[clang..]] raises the error: attribute cannot be applied to types
 // CHECK: @arr2 = global [4 x double] undef
 double arr2 [[clang::loader_uninitialized]] [4];
+
+template struct templ{T * t;};
+
+// CHECK: @templ_int = global %struct.templ undef, align 8
+templ templ_int [[clang::loader_uninitialized]];
+
+// CHECK: @templ_trivial = global %struct.templ.0 undef, align 8
+templ templ_trivial [[clang::loader_uninitialized]];
+
+// CHECK: @templ_incomplete = global %struct.templ.1 undef, align 8
+struct incomplete;
+templ templ_incomplete [[clang::loader_uninitialized]];
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12476,6 +12476,17 @@
 }
 
 if (!Var->isInvalidDecl() && RealDecl->hasAttr()) {
+  if (Var->getStorageClass() == SC_Extern) {
+Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
+<< Var;
+Var->setInvalidDecl();
+return;
+  }
+  if (RequireCompleteType(Var->getLocation(), Var->getType(),
+  diag::err_typecheck_decl_incomplete_type)) {
+Var->setInvalidDecl();
+return;
+  }
   if (CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
 if (!RD->hasTrivialDefaultConstructor()) {
   Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
@@ -12483,12 +12494,6 @@
   return;
 }
   }
-  if 

[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

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



Comment at: clang/lib/Headers/popcntintrin.h:16
 
+#ifdef __cplusplus
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr

Do we need to check for C++11?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86229

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


[PATCH] D86227: [SyntaxTree] Add support for `MemberExpression`

2020-08-19 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:333
+///   expression .  template_opt id-expression
+///   id-expression
+/// e.g. `x.a`, `xp->a` or even just `a` when we have an implicit `this->`.

We could discuss how to model the implicit member expression, as it has a 
totally different syntax.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:1769-1771
+// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
+// implicit copy constructor called on `x`. This should've been ignored 
already,
+// as we `IgnoreImplicit` when traversing an `Stmt`.

Not much progress trying to use other ignores. Perhaps we can treat this 
properly when adding support for `CXXConstructExpr`



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2086-2087
+  int geta(){
+// FIXME: Remove the terminal`UnknownExpression` wrapping `a`. This
+// `UnknownExpression` comes from a terminal implicit `CXXThisExpr`.
+[[a]];

I'm experimenting with that now, but anyways, I think this should go to the 
patch, 
> [SyntaxTree] Add support to `CXXThisExpr`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86227

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


[PATCH] D86229: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: craig.topper, echristo, spatel, erichkeane, andreadb.
Herald added a project: clang.
RKSimon requested review of this revision.

This is a RFC first step patch to enable constexpr support and testing to a 
large number of x86 intrinsics.

All I've done here is provide a __DEFAULT_FN_ATTRS_CONSTEXPR variant to our 
existing __DEFAULT_FN_ATTRS tag approach that adds constexpr on c++ builds. The 
clang cuda headers do something similar.

Testing wise - at the moment I've copied the existing popcnt-builtins.c file - 
popcnt-builtins.cpp will fail to build if the intrinsic can't correctly handle 
the constexpr modifier - I'm open to suggestions on whether we can avoid 
duplication and still have test coverage on c and cpp.

I've started with POPCNT mainly as its tiny and are wrappers to generic 
__builtin_* intrinsics which already act as constexpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86229

Files:
  clang/lib/Headers/popcntintrin.h
  clang/test/CodeGen/popcnt-builtins.cpp


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -13,6 +13,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+#ifdef __cplusplus
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /// Counts the number of bits in the source operand having a value of 1.
 ///
 /// \headerfile 
@@ -23,7 +29,7 @@
 ///An unsigned 32-bit integer operand.
 /// \returns A 32-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -40,7 +46,7 @@
 ///An unsigned 64-bit integer operand.
 /// \returns A 64-bit integer containing the number of bits with value 1 in the
 ///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -48,5 +54,6 @@
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 
 #endif /* __POPCNTINTRIN_H */


Index: clang/test/CodeGen/popcnt-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/popcnt-builtins.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+
+#include 
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long 

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

2020-08-19 Thread Caroline 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 rG33c554d8444a: [clang][driver]Add quotation mark in 
test/fortran.f95  to avoid false positive (authored by CarolineConcatto).

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


[clang] 33c554d - [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-19 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2020-08-19T17:54:32+01:00
New Revision: 33c554d8444a5ce1fb85def04de8c0ebfec643b9

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

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

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 ("")

Reviewed By: DavidTruby, echristo

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

Added: 


Modified: 
clang/test/Driver/fortran.f95

Removed: 




diff  --git a/clang/test/Driver/fortran.f95 b/clang/test/Driver/fortran.f95
index 03ff99f9fbfb..db3ff2da17e8 100644
--- a/clang/test/Driver/fortran.f95
+++ b/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] D86227: [SyntaxTree] Add support for `MemberExpression`

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

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86227

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  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
@@ -491,19 +491,20 @@
   operator int();
 };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
   [[x.operator int()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| |-operator
-| `-int
+| `-IdExpression
+|   `-UnqualifiedId
+| |-operator
+| `-int
 |-(
 `-)
 )txt"}));
@@ -542,19 +543,20 @@
   R"cpp(
 struct X { };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
   [[x.~X()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| |-~
-| `-X
+| `-IdExpression
+|   `-UnqualifiedId
+| |-~
+| `-X
 |-(
 `-)
 )txt"}));
@@ -568,18 +570,23 @@
   R"cpp(
 struct X { };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
+  // FIXME: Make `decltype(x)` a child of `MemberExpression`. It is currently
+  // not because `Expr::getSourceRange()` returns the range of `x.~` for the
+  // `MemberExpr` instead of the expected `x.~decltype(x)`, this is a bug in
+  // clang.
   [[x.~decltype(x)()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| `-~
+| `-IdExpression
+|   `-UnqualifiedId
+| `-~
 |-decltype
 |-(
 |-x
@@ -624,6 +631,9 @@
   struct S { };
 }
 void test() {
+  // FIXME: Remove the terminal `UnknownExpression` wrapping `s1` and `s2`. This
+  // `UnknownExpression` comes from a terminal `CXXConstructExpr` in the
+  // ClangAST. We need to ignore terminal implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -1756,6 +1766,9 @@
 struct X {
   friend X operator+(X, const X&);
 };
+// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
+// implicit copy constructor called on `x`. This should've been ignored already,
+// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
@@ -1961,6 +1974,306 @@
 )txt"}));
 }
 
+TEST_P(SyntaxTreeTest, MemberExpression_SimpleWithDot) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+};
+void test(struct S s) {
+  [[s.a]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-IdExpression
+| `-UnqualifiedId
+|   `-s
+|-.
+`-IdExpression
+  `-UnqualifiedId
+`-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_SimpleWithArrow) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+};
+void test(struct S* sp) {
+  [[sp->a]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-IdExpression
+| `-UnqualifiedId
+|   `-sp
+|-->
+`-IdExpression
+  `-UnqualifiedId
+`-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Chaining) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  struct S* next;
+};
+void test(struct S s){
+  [[s.next->next]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-MemberExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-s
+| |-.
+| `-IdExpression
+|   `-UnqualifiedId
+| `-next
+|-->
+`-IdExpression
+  `-UnqualifiedId
+`-next
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_OperatorFunction) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  bool operator!();
+};
+void test(S s) {
+  [[s.operator!()]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-MemberExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-s
+| |-.
+| `-IdExpression
+|   `-UnqualifiedId
+| |-operator
+| `-!
+|-(
+`-)
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Implicit) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+  int geta(){
+// FIXME: Remove the terminal`UnknownExpression` wrapping `a`. This
+// `UnknownExpression` comes from a terminal implicit `CXXThisExpr`.
+[[a]];
+  }
+};
+)cpp",
+  {R"txt(
+MemberExpression
+`-IdExpression
+  `-UnqualifiedId
+`-UnknownExpression
+  `-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Template) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  template
+  T f();
+};
+void test(S* sp){
+  [[sp->f()]];
+}
+)cpp",
+   

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

2020-08-19 Thread Nathan Lanza via Phabricator via cfe-commits
lanza added a comment.

> This change provides a codegen options flag to clang 
> -fobjc-export-direct-method-wrappers to generate the wrapper functions that 
> begin with the prefix objc_direct_wrapper and are marked as 
> attribute__((alwaysinline)). This way within a link unit the wrapper 
> functions should be inlined away at their call sites, but across a dylib 
> boundary the wrapper call is used.

I think this needing a flag is a bit magical for what seems like such a simple 
concept for the ObjC language. There shouldn't need to be a flag to make it 
work properly.

We have defined more-or-less non-`virtual` methods for ObjC with `objc_direct`. 
The symbol visibility should behave as a reasonable developer should expect and 
the front end should communicate it. Requiring a flag is the compiler requiring 
the developer to understand compiler implementation details for his iOS app to 
work properly. Currently, clang decides the visibility is hidden but can't 
communicate this across library boundaries and you end up with confusing link 
errors for the developer.

There's two routes that make sense in my opinion: library private and class 
private OR library public and class public.

As per the ABI, I don't know of any reasons why `objc_direct` methods require 
the standard ObjC `-[class method]` signature since they won't be participating 
in any part of the ObjectiveC runtime. If that's the case,  a proper 
underscored symbol name seems like the cleaning and most reasonable fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D86227: [SyntaxTree] Add support for `MemberExpression`

2020-08-19 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/D86227

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  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
@@ -491,19 +491,20 @@
   operator int();
 };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
   [[x.operator int()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| |-operator
-| `-int
+| `-IdExpression
+|   `-UnqualifiedId
+| |-operator
+| `-int
 |-(
 `-)
 )txt"}));
@@ -542,19 +543,20 @@
   R"cpp(
 struct X { };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
   [[x.~X()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| |-~
-| `-X
+| `-IdExpression
+|   `-UnqualifiedId
+| |-~
+| `-X
 |-(
 `-)
 )txt"}));
@@ -568,18 +570,23 @@
   R"cpp(
 struct X { };
 void test(X x) {
-  // TODO: Expose `id-expression` from `MemberExpr`
+  // FIXME: Make `decltype(x)` a child of `MemberExpression`. It is currently
+  // not because `Expr::getSourceRange()` returns the range of `x.~` for the
+  // `MemberExpr` instead of the expected `x.~decltype(x)`, this is a bug in
+  // clang.
   [[x.~decltype(x)()]];
 }
 )cpp",
   {R"txt(
 UnknownExpression
-|-UnknownExpression
+|-MemberExpression
 | |-IdExpression
 | | `-UnqualifiedId
 | |   `-x
 | |-.
-| `-~
+| `-IdExpression
+|   `-UnqualifiedId
+| `-~
 |-decltype
 |-(
 |-x
@@ -624,6 +631,9 @@
   struct S { };
 }
 void test() {
+  // FIXME: Remove the terminal `UnknownExpression` wrapping `s1` and `s2`. This
+  // `UnknownExpression` comes from a terminal `CXXConstructExpr` in the
+  // ClangAST. We need to ignore terminal implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -1756,6 +1766,9 @@
 struct X {
   friend X operator+(X, const X&);
 };
+// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
+// implicit copy constructor called on `x`. This should've been ignored already,
+// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
@@ -1961,6 +1974,306 @@
 )txt"}));
 }
 
+TEST_P(SyntaxTreeTest, MemberExpression_SimpleWithDot) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+};
+void test(struct S s) {
+  [[s.a]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-IdExpression
+| `-UnqualifiedId
+|   `-s
+|-.
+`-IdExpression
+  `-UnqualifiedId
+`-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_SimpleWithArrow) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+};
+void test(struct S* sp) {
+  [[sp->a]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-IdExpression
+| `-UnqualifiedId
+|   `-sp
+|-->
+`-IdExpression
+  `-UnqualifiedId
+`-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Chaining) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  struct S* next;
+};
+void test(struct S s){
+  [[s.next->next]];
+}
+)cpp",
+  {R"txt(
+MemberExpression
+|-MemberExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-s
+| |-.
+| `-IdExpression
+|   `-UnqualifiedId
+| `-next
+|-->
+`-IdExpression
+  `-UnqualifiedId
+`-next
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_OperatorFunction) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  bool operator!();
+};
+void test(S s) {
+  [[s.operator!()]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-MemberExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-s
+| |-.
+| `-IdExpression
+|   `-UnqualifiedId
+| |-operator
+| `-!
+|-(
+`-)
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Implicit) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  int a;
+  int geta(){
+// FIXME: Remove the terminal`UnknownExpression` wrapping `a`. This
+// `UnknownExpression` comes from a terminal implicit `CXXThisExpr`.
+[[a]];
+  }
+};
+)cpp",
+  {R"txt(
+MemberExpression
+`-IdExpression
+  `-UnqualifiedId
+`-UnknownExpression
+  `-a
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, MemberExpression_Template) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+struct S {
+  template
+  T f();
+};
+void test(S* sp){
+  [[sp->f()]];
+}
+)cpp",

[clang] 6b742cc - [clang] Replace call to private ctor with ElementCount::getScalable (2/2)

2020-08-19 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:40:46-07:00
New Revision: 6b742cc48d91f35bfa98844d5add3655f33f8326

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

LOG: [clang] Replace call to private ctor with ElementCount::getScalable (2/2)

Update the code for D86120 which made the constructors of `ElementCount`
private. Apparently I missed another instance in the macro just below.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 48ed637e737b..a9cab40247df 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3718,7 +3718,7 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType 
*Ty) const {
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\
-  {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
+  {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
 
   switch (Ty->getKind()) {
   default:



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


[clang] fc53bd6 - [clang] Replace call to private ctor with ElementCount::getScalable

2020-08-19 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:35:08-07:00
New Revision: fc53bd610ff95d2824617095bcf4976035b4cb9a

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

LOG: [clang] Replace call to private ctor with ElementCount::getScalable

Update the code for D86120 which made the constructors of `ElementCount`
private.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c51629ecfd53..48ed637e737b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3714,7 +3714,7 @@ QualType ASTContext::getIncompleteArrayType(QualType 
elementType,
 ASTContext::BuiltinVectorTypeInfo
 ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
 #define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS)  
\
-  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true),
\
+  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), 
\
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\



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


[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-08-19 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/lib/Format/MacroExpander.cpp:186
+Tok->MacroCtx = MacroContext(MR_ExpandedArg);
+  pushToken(Tok);
+}

sammccall wrote:
> you're pushing here without copying. This means the original tokens from the 
> ArgsList are mutated. Maybe we own them, but this seems at least wrong for 
> multiple expansion of the same arg.
> 
> e.g.
> ```
> #define M(X,Y) X Y X
> M(1,2)
> ```
> 
> Will expand to:
> - 1, ExpandedArg, ExpandedFrom = [M, M] // should just be one M
> - 2, ExpandedArg, ExpandedFrom = [M]
> - 1, ExpandedArg, ExpandedFrom = [M, M] // this is the same token pointer as 
> the first one
> 
> Maybe it would be better if pushToken performed the copy, and returned a 
> mutable pointer to the copy. (If you can make the input const, that would 
> prevent this type of bug)
Ugh. I'll need to take a deeper look, but generally, the problem is we don't 
want to copy - we're mutating the data of the token while formatting the 
expanded token stream, and then re-use that info when formatting the original 
stream.
We could copy, add a reference to the original token, and then have a step that 
adapts in the end, and perhaps that's cleaner overall anyway, but will be quite 
a change.
The alternative is that I'll look into how to specifically handle 
double-expansion (or ... forbid it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

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


[PATCH] D86223: [analyzer][z3] Use more elaborate z3 variable names in debug build

2020-08-19 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, Szelethus, vsavchenko, xazax.hun, 
mikhail.ramalho, ddcc.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

Previously, it was a tedious task to comprehend Z3 dumps.
This prettier dumps would help during debugging, so I'm only using the longer 
names in debug build.

For all SymbolData values:

- `$###` -> `$conj_###`
- `$###` -> `$derived_###`
- `$###` -> `$extent_###`
- `$###` -> `$meta_###`
- `$###` -> `$reg_###`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86223

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
  clang/test/Analysis/z3/pretty-dump.c


Index: clang/test/Analysis/z3/pretty-dump.c
===
--- /dev/null
+++ clang/test/Analysis/z3/pretty-dump.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s 2>&1 | FileCheck %s
+//
+// REQUIRES: z3
+//
+// Works only with the z3 constraint manager.
+
+void clang_analyzer_printState();
+
+void foo(int x) {
+  if (x == 3) {
+clang_analyzer_printState();
+(void)x;
+// CHECK: "constraints": [
+// CHECK-NEXT: { "symbol": "(reg_$[[#]]) == 3", "range": "(= 
$reg_[[#]] #x0003)" }
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
@@ -319,11 +319,41 @@
   }
 
   /// Construct an SMTSolverRef from a SymbolData.
-  static inline llvm::SMTExprRef fromData(llvm::SMTSolverRef ,
-  const SymbolID ID, const QualType 
,
-  uint64_t BitWidth) {
-llvm::Twine Name = "$" + llvm::Twine(ID);
-return Solver->mkSymbol(Name.str().c_str(), mkSort(Solver, Ty, BitWidth));
+  static inline llvm::SMTExprRef
+  fromData(llvm::SMTSolverRef , ASTContext , const SymbolData *Sym) 
{
+const SymbolID ID = Sym->getSymbolID();
+const QualType Ty = Sym->getType();
+const uint64_t BitWidth = Ctx.getTypeSize(Ty);
+
+const auto GetPrettyPrefixFor = [](const SymbolData *Sym) -> const char * {
+  switch (Sym->getKind()) {
+  default:
+llvm_unreachable("There should be no other SymbolData kind.");
+  case SymExpr::SymbolConjuredKind:
+return "conj_";
+  case SymExpr::SymbolDerivedKind:
+return "derived_";
+  case SymExpr::SymbolExtentKind:
+return "extent_";
+  case SymExpr::SymbolMetadataKind:
+return "meta_";
+  case SymExpr::SymbolRegionValueKind:
+return "reg_";
+  }
+};
+// Suppress unused variable warning in release build.
+static_cast(GetPrettyPrefixFor);
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+#define PRETTY_SYMBOL_KIND GetPrettyPrefixFor(Sym)
+#else
+#define PRETTY_SYMBOL_KIND ""
+#endif
+llvm::SmallString<16> Str;
+llvm::raw_svector_ostream OS(Str);
+OS << "$" << PRETTY_SYMBOL_KIND << ID;
+#undef PRETTY_SYMBOL_KIND
+return Solver->mkSymbol(Str.c_str(), mkSort(Solver, Ty, BitWidth));
   }
 
   // Wrapper to generate SMTSolverRef from SymbolCast data.
@@ -422,8 +452,7 @@
   if (RetTy)
 *RetTy = Sym->getType();
 
-  return fromData(Solver, SD->getSymbolID(), Sym->getType(),
-  Ctx.getTypeSize(Sym->getType()));
+  return fromData(Solver, Ctx, SD);
 }
 
 if (const SymbolCast *SC = dyn_cast(Sym)) {
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -122,8 +122,7 @@
   // this method tries to get the interpretation (the actual value) from
   // the solver, which is currently not cached.
 
-  llvm::SMTExprRef Exp =
-  SMTConv::fromData(Solver, SD->getSymbolID(), Ty, 
Ctx.getTypeSize(Ty));
+  llvm::SMTExprRef Exp = SMTConv::fromData(Solver, Ctx, SD);
 
   Solver->reset();
   addStateConstraints(State);


Index: clang/test/Analysis/z3/pretty-dump.c
===
--- /dev/null
+++ clang/test/Analysis/z3/pretty-dump.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s 2>&1 | FileCheck %s
+//
+// REQUIRES: z3
+//
+// 

[PATCH] D86218: Teach the swift calling convention about _Atomic types

2020-08-19 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer updated this revision to Diff 286575.
aschwaighofer added a comment.

Try to sooth clang-tidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86218

Files:
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/test/CodeGen/64bit-swiftcall.c


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1042,3 +1042,15 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -62,9 +62,12 @@
 
 void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) {
   // Deal with various aggregate types as special cases:
+  // Atomic types.
+  if (const auto *atomicType = type->getAs()) {
+addTypedData(atomicType->getValueType(), begin);
 
-  // Record types.
-  if (auto recType = type->getAs()) {
+// Record types.
+  } else if (const auto *recType = type->getAs()) {
 addTypedData(recType->getDecl(), begin);
 
   // Array types.


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1042,3 +1042,15 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -62,9 +62,12 @@
 
 void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) {
   // Deal with various aggregate types as special cases:
+  // Atomic types.
+  if (const auto *atomicType = type->getAs()) {
+addTypedData(atomicType->getValueType(), begin);
 
-  // Record types.
-  if (auto recType = type->getAs()) {
+// Record types.
+  } else if (const auto *recType = type->getAs()) {
 addTypedData(recType->getDecl(), begin);
 
   // Array types.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86221: [compiler-rt][builtins] Do not assume int to be at least 32 bit wide

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: efriedma, MaskRay, aykevl, uabelho.
Herald added subscribers: Sanitizers, dberris.
Herald added a project: Sanitizers.
atrosinenko requested review of this revision.

This patch drops implicit assumptions on int/unsigned types being at least 32 
bit wide. This is not always true on 16 bit targets such as MSP430.

This patch contains the following changes:

- `rep_clz(a)` and `src_rep_t_clz(a)` for 64-bit rep_t from soft-float utility 
headers are moved to `int_lib.h` as a common `clzdi(a)` implementation 
(signedness was changed to match one of __builtin_clz series of intrinsics). 
The original functions was turned into inline proxy functions that merely adapt 
the signedness
- `__floatsi[st]f` and `__floatunsi[st]f3` are updated to accept a 
signed/unsigned integer argument of a specific width
- similar changes were made for some unit tests
- `__udivmoddi4` switched to `ctzsi` macro defined in `int_lib.h` instead of 
`__builtin_ctz`
- the `*vfp` LibCall versions were NOT touched


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86221

Files:
  compiler-rt/lib/builtins/floatsisf.c
  compiler-rt/lib/builtins/floatsitf.c
  compiler-rt/lib/builtins/floatunsisf.c
  compiler-rt/lib/builtins/floatunsitf.c
  compiler-rt/lib/builtins/fp_extend.h
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_lib.h
  compiler-rt/lib/builtins/udivmoddi4.c
  compiler-rt/test/builtins/Unit/floatditf_test.c
  compiler-rt/test/builtins/Unit/floatsitf_test.c
  compiler-rt/test/builtins/Unit/floatunditf_test.c
  compiler-rt/test/builtins/Unit/floatunsitf_test.c

Index: compiler-rt/test/builtins/Unit/floatunsitf_test.c
===
--- compiler-rt/test/builtins/Unit/floatunsitf_test.c
+++ compiler-rt/test/builtins/Unit/floatunsitf_test.c
@@ -8,9 +8,9 @@
 
 #include "fp_test.h"
 
-COMPILER_RT_ABI long double __floatunsitf(unsigned int a);
+COMPILER_RT_ABI long double __floatunsitf(su_int a);
 
-int test__floatunsitf(unsigned int a, uint64_t expectedHi, uint64_t expectedLo)
+int test__floatunsitf(su_int a, uint64_t expectedHi, uint64_t expectedLo)
 {
 long double x = __floatunsitf(a);
 int ret = compareResultLD(x, expectedHi, expectedLo);
Index: compiler-rt/test/builtins/Unit/floatunditf_test.c
===
--- compiler-rt/test/builtins/Unit/floatunditf_test.c
+++ compiler-rt/test/builtins/Unit/floatunditf_test.c
@@ -12,9 +12,9 @@
 
 // Returns: long integer converted to long double
 
-COMPILER_RT_ABI long double __floatunditf(unsigned long long a);
+COMPILER_RT_ABI long double __floatunditf(du_int a);
 
-int test__floatunditf(unsigned long long a, uint64_t expectedHi, uint64_t expectedLo)
+int test__floatunditf(du_int a, uint64_t expectedHi, uint64_t expectedLo)
 {
 long double x = __floatunditf(a);
 int ret = compareResultLD(x, expectedHi, expectedLo);
Index: compiler-rt/test/builtins/Unit/floatsitf_test.c
===
--- compiler-rt/test/builtins/Unit/floatsitf_test.c
+++ compiler-rt/test/builtins/Unit/floatsitf_test.c
@@ -8,9 +8,9 @@
 
 #include "fp_test.h"
 
-long COMPILER_RT_ABI double __floatsitf(int a);
+COMPILER_RT_ABI long double __floatsitf(si_int a);
 
-int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
+int test__floatsitf(si_int a, uint64_t expectedHi, uint64_t expectedLo)
 {
 long double x = __floatsitf(a);
 int ret = compareResultLD(x, expectedHi, expectedLo);
Index: compiler-rt/test/builtins/Unit/floatditf_test.c
===
--- compiler-rt/test/builtins/Unit/floatditf_test.c
+++ compiler-rt/test/builtins/Unit/floatditf_test.c
@@ -12,9 +12,9 @@
 
 // Returns: long integer converted to long double
 
-COMPILER_RT_ABI long double __floatditf(long long a);
+COMPILER_RT_ABI long double __floatditf(di_int a);
 
-int test__floatditf(long long a, uint64_t expectedHi, uint64_t expectedLo)
+int test__floatditf(di_int a, uint64_t expectedHi, uint64_t expectedLo)
 {
 long double x = __floatditf(a);
 int ret = compareResultLD(x, expectedHi, expectedLo);
Index: compiler-rt/lib/builtins/udivmoddi4.c
===
--- compiler-rt/lib/builtins/udivmoddi4.c
+++ compiler-rt/lib/builtins/udivmoddi4.c
@@ -82,7 +82,7 @@
 r.s.high = n.s.high & (d.s.high - 1);
 *rem = r.all;
   }
-  return n.s.high >> __builtin_ctz(d.s.high);
+  return n.s.high >> ctzsi(d.s.high);
 }
 // K K
 // ---
@@ -112,7 +112,7 @@
   *rem = n.s.low & (d.s.low - 1);
 if (d.s.low == 1)
   return n.all;
-sr = __builtin_ctz(d.s.low);
+sr = ctzsi(d.s.low);
 q.s.high = n.s.high >> sr;
 q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
 return 

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-08-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Somehow I missed the email from your replies.

Mostly nits that you can take or leave, but I think potential bugs around 
functionlike-vs-objectlike and multiple-expansion of args.




Comment at: clang/lib/Format/FormatToken.h:177
+/// EndOfExpansion:   0  0 0   21 0 1
+struct MacroContext {
+  MacroContext(MacroRole Role) : Role(Role) {}

"context" is often pretty vague - "MacroSource" isn't a brilliant name but at 
least seems to hint at the direction (that the FormatToken is the expanded 
token and the MacroSource gives information about what it was expanded from)

I don't feel strongly about this though, up to you.



Comment at: clang/lib/Format/FormatToken.h:646
 private:
-  // Disallow copying.
+  // Only allow copying via the explicit copyInto method.
   FormatToken(const FormatToken &) = delete;

nit: comment -> copyFrom



Comment at: clang/lib/Format/MacroExpander.cpp:1
+//===--- MacroExpander.h - Format C++ code --*- C++ 
-*-===//
+//

nit: banner is for wrong filename



Comment at: clang/lib/Format/MacroExpander.cpp:81
+  nextToken();
+}
+if (Current->isNot(tok::r_paren))

this accepts `FOO(A,B,)=...` as equivalent to `FOO(A,B)=...`. Not sure if worth 
fixing.



Comment at: clang/lib/Format/MacroExpander.cpp:88
+
+  bool parseExpansion() {
+if (!Current->isOneOf(tok::equal, tok::eof))

(nit: I'd probably find this easier to follow as `if (equal) else if (eof) 
else` with parseTail inlined, but up to you)



Comment at: clang/lib/Format/MacroExpander.cpp:131
+void MacroExpander::parseDefinitions(const std::vector ) {
+  for (const std::string  : Macros) {
+Buffers.push_back(

uber-nit: seems like this loop belongs in the caller



Comment at: clang/lib/Format/MacroExpander.cpp:142
+  auto Definition = Parser.parse();
+  Definitions[Definition.Name] = Definition;
+}

nit: this is a copy for what seems like no reason - move `Parser.parse()` 
inline to this line?



Comment at: clang/lib/Format/MacroExpander.cpp:155
+  SmallVector Result;
+  const Definition  = Definitions.lookup(ID->TokenText);
+

lookup() returns a value, so this is a copy (with lifetime-extension)
I think you want `*find`



Comment at: clang/lib/Format/MacroExpander.cpp:178
+  return true;
+for (const auto  : Args[I->getValue()]) {
+  // A token can be part of multiple macro arguments.

please use a different name for this variable, or the parameter it shadows, or 
preferably both!



Comment at: clang/lib/Format/MacroExpander.cpp:179
+for (const auto  : Args[I->getValue()]) {
+  // A token can be part of multiple macro arguments.
+  // For example, with "ID(x) x":

nit: "part of a macro argument at multiple levels"?
(Current text suggests to me that it can be arg 0 and arg 1 of the same macro)



Comment at: clang/lib/Format/MacroExpander.cpp:186
+Tok->MacroCtx = MacroContext(MR_ExpandedArg);
+  pushToken(Tok);
+}

you're pushing here without copying. This means the original tokens from the 
ArgsList are mutated. Maybe we own them, but this seems at least wrong for 
multiple expansion of the same arg.

e.g.
```
#define M(X,Y) X Y X
M(1,2)
```

Will expand to:
- 1, ExpandedArg, ExpandedFrom = [M, M] // should just be one M
- 2, ExpandedArg, ExpandedFrom = [M]
- 1, ExpandedArg, ExpandedFrom = [M, M] // this is the same token pointer as 
the first one

Maybe it would be better if pushToken performed the copy, and returned a 
mutable pointer to the copy. (If you can make the input const, that would 
prevent this type of bug)



Comment at: clang/lib/Format/Macros.h:82
+///
+/// Furthermore, expansion and definition are independent - a macro defined
+/// as "A()=a" and "A=a" can both be expanded  as "A()" and "A".

Is this saying that the functionlike vs objectlike distiction is not preserved?

This doesn't seem safe (unless the *caller* is required to retain this 
information).
e.g. 
```
#define NUMBER int
using Calculator = NUMBER(); // does expansion consume () or not?
```



Comment at: clang/lib/Format/Macros.h:86
+public:
+  using ArgsList = llvm::ArrayRef>;
+

(Seems a little odd that these pointers to external FormatTokens aren't 
const... I can believe there's a reason though)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

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


[PATCH] D86218: Teach the swift calling convention about _Atomic types

2020-08-19 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer created this revision.
aschwaighofer added a reviewer: rjmccall.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
aschwaighofer requested review of this revision.

rdar://67351073


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86218

Files:
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/test/CodeGen/64bit-swiftcall.c


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1042,3 +1042,15 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -62,9 +62,12 @@
 
 void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) {
   // Deal with various aggregate types as special cases:
+  // Atomic types.
+  if (auto atomicType = type->getAs()) {
+addTypedData(atomicType->getValueType(), begin);
 
-  // Record types.
-  if (auto recType = type->getAs()) {
+// Record types.
+  } else if (auto recType = type->getAs()) {
 addTypedData(recType->getDecl(), begin);
 
   // Array types.


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1042,3 +1042,15 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -62,9 +62,12 @@
 
 void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) {
   // Deal with various aggregate types as special cases:
+  // Atomic types.
+  if (auto atomicType = type->getAs()) {
+addTypedData(atomicType->getValueType(), begin);
 
-  // Record types.
-  if (auto recType = type->getAs()) {
+// Record types.
+  } else if (auto recType = type->getAs()) {
 addTypedData(recType->getDecl(), begin);
 
   // Array types.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86217: rename sram-ecc as sramecc in clang

2020-08-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: kzhuravl, arsenm.
Herald added subscribers: llvm-commits, dang, kerbowa, hiraditya, nhaehnle, 
jvesely.
Herald added a project: LLVM.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

As backend will rename sram-ecc to sramecc, this patch will make corresponding 
change in clang.

This patch depends on backend changing target feature name from sram-ecc to 
sramecc


https://reviews.llvm.org/D86217

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/TargetID.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetID.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/hip-invalid-target-id.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/invalid-target-id.cl
  clang/test/Driver/target-id-macros.cl
  clang/test/Driver/target-id-macros.hip
  clang/test/Driver/target-id.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -97,8 +97,8 @@
   {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
   {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
   {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
-  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAM_ECC},
-  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAM_ECC},
+  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
+  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
   {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
   {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
   {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -119,7 +119,7 @@
   FEATURE_XNACK = 1 << 7,
 
   // Sram-ecc is available.
-  FEATURE_SRAM_ECC = 1 << 8,
+  FEATURE_SRAMECC = 1 << 8,
 };
 
 StringRef getArchNameAMDGCN(GPUKind AK);
Index: clang/test/Driver/target-id.cl
===
--- clang/test/Driver/target-id.cl
+++ clang/test/Driver/target-id.cl
@@ -3,30 +3,30 @@
 // REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa \
-// RUN:   -mcpu=gfx908:xnack+:sram-ecc- \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
 // RUN:   -nostdlib %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa \
-// RUN:   -mcpu=gfx908:xnack+:sram-ecc- \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
 // RUN:   -nostdlib -x ir %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa \
-// RUN:   -mcpu=gfx908:xnack+:sram-ecc- \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
 // RUN:   -nostdlib -x assembler %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### -target amdgcn-amd-amdpal \
-// RUN:   -mcpu=gfx908:xnack+:sram-ecc- \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
 // RUN:   -nostdlib %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### -target amdgcn--mesa3d \
-// RUN:   -mcpu=gfx908:xnack+:sram-ecc- \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
 // RUN:   -nostdlib %s 2>&1 | FileCheck %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa \
 // RUN:   -nostdlib %s 2>&1 | FileCheck -check-prefix=NONE %s
 
 // CHECK: "-target-cpu" "gfx908"
-// CHECK-SAME: "-target-feature" "-sram-ecc"
+// CHECK-SAME: "-target-feature" "-sramecc"
 // CHECK-SAME: "-target-feature" "+xnack"
 
 // NONE-NOT: "-target-cpu"
Index: clang/test/Driver/target-id-macros.hip
===
--- clang/test/Driver/target-id-macros.hip
+++ clang/test/Driver/target-id-macros.hip
@@ -3,10 +3,10 @@
 // REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -E -dM -target x86_64-linux-gnu --cuda-device-only \
-// RUN:   --offload-arch=gfx908:xnack+:sram-ecc- -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx908:xnack+:sramecc- -nogpuinc -nogpulib \
 // RUN:   -o - %s 2>&1 | FileCheck %s
 
 // CHECK-DAG: #define __amdgcn_processor__ "gfx908"
 // CHECK-DAG: #define __amdgcn_feature_xnack__ 1
-// CHECK-DAG: #define __amdgcn_feature_sram_ecc__ 0
-// CHECK-DAG: 

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

2020-08-19 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 286561.
adamcz added a comment.

Added comment in place of a FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86069

Files:
  clang-tools-extra/clangd/unittests/ModulesTests.cpp
  clang/include/clang/Sema/Sema.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/PCH/Inputs/modules/Foo.h
  clang/test/PCH/preamble-modules.cpp

Index: clang/test/PCH/preamble-modules.cpp
===
--- /dev/null
+++ clang/test/PCH/preamble-modules.cpp
@@ -0,0 +1,15 @@
+// Check that modules included in the preamble remain visible to the rest of the
+// file.
+
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -emit-pch -o %t.pch %s -fmodules -fmodule-map-file=%S/Inputs/modules/module.modulemap -fmodules-local-submodule-visibility -fmodules-cache-path=%t.mcp
+// RUN: %clang_cc1 -include-pch %t.pch %s -fmodules -fmodule-map-file=%S/Inputs/modules/module.modulemap -fmodules-local-submodule-visibility -fmodules-cache-path=%t.mcp
+
+#ifndef MAIN_FILE
+#define MAIN_FILE
+// Premable section.
+#include "Inputs/modules/Foo.h"
+#else
+// Main section.
+MyType foo;
+#endif
Index: clang/test/PCH/Inputs/modules/Foo.h
===
--- clang/test/PCH/Inputs/modules/Foo.h
+++ clang/test/PCH/Inputs/modules/Foo.h
@@ -1 +1,3 @@
 void make_foo(void);
+
+typedef int MyType;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4987,10 +4987,10 @@
 /*ImportLoc=*/Import.ImportLoc);
   if (Import.ImportLoc.isValid())
 PP.makeModuleVisible(Imported, Import.ImportLoc);
-  // FIXME: should we tell Sema to make the module visible too?
+  // This updates visibility for Preprocessor only. For Sema, which can be
+  // nullptr here, we do the same later, in UpdateSema().
 }
   }
-  ImportedModules.clear();
 }
 
 void ASTReader::finalizeForWriting() {
@@ -7942,6 +7942,15 @@
   SemaObj->FpPragmaStack.CurrentPragmaLocation = FpPragmaCurrentLocation;
 }
   }
+
+  // For non-modular AST files, restore visiblity of modules.
+  for (auto  : ImportedModules) {
+if (Import.ImportLoc.isInvalid())
+  continue;
+if (Module *Imported = getSubmodule(Import.ID)) {
+  SemaObj->makeModuleVisible(Imported, Import.ImportLoc);
+}
+  }
 }
 
 IdentifierInfo *ASTReader::get(StringRef Name) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1912,6 +1912,12 @@
 
   bool isModuleVisible(const Module *M, bool ModulePrivate = false);
 
+  // When loading a non-modular PCH files, this is used to restore module
+  // visibility.
+  void makeModuleVisible(Module *Mod, SourceLocation ImportLoc) {
+VisibleModules.setVisible(Mod, ImportLoc);
+  }
+
   /// Determine whether a declaration is visible to name lookup.
   bool isVisible(const NamedDecl *D) {
 return D->isUnconditionallyVisible() || isVisibleSlow(D);
Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -26,7 +26,7 @@
 void foo() {}
 )cpp");
   TU.ExtraArgs.push_back("-fmodule-name=M");
-  TU.ExtraArgs.push_back("-fmodule-map-file=m.modulemap");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
   TU.AdditionalFiles["Textual.h"] = "void foo();";
   TU.AdditionalFiles["m.modulemap"] = R"modulemap(
 module M {
@@ -39,6 +39,31 @@
   TU.index();
 }
 
+// Verify that visibility of AST nodes belonging to modules, but loaded from
+// preamble PCH, is restored.
+TEST(Modules, PreambleBuildVisibility) {
+  TestTU TU = TestTU::withCode(R"cpp(
+#include "module.h"
+
+foo x;
+)cpp");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fmodules-strict-decluse");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodules-local-submodule-visibility");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.AdditionalFiles["module.h"] = R"cpp(
+typedef int foo;
+)cpp";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "module.h"
+}
+)modulemap";
+  EXPECT_TRUE(TU.build().getDiagnostics().empty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b98e25b - Make helpers static. NFC.

2020-08-19 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-08-19T16:00:03+02:00
New Revision: b98e25b6d7231798a4d819aae3a93f6f1627931a

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

LOG: Make helpers static. NFC.

Added: 


Modified: 
clang/lib/Tooling/Transformer/RewriteRule.cpp
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Transformer/RewriteRule.cpp 
b/clang/lib/Tooling/Transformer/RewriteRule.cpp
index 89497f67bbb5..fe33f9cf8b0c 100644
--- a/clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -242,7 +242,7 @@ class ApplyRuleCallback : public MatchFinder::MatchCallback 
{
 } // namespace
 
 template 
-llvm::Expected>
+static llvm::Expected>
 rewriteDescendantsImpl(const T , RewriteRule Rule,
const MatchResult ) {
   ApplyRuleCallback Callback(std::move(Rule));

diff  --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp 
b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index b0d2a8b42b9b..cb2bf16392f2 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -800,9 +800,9 @@ static Expected writeListEntry(raw_ostream ,
 }
 
 template 
-Error writeDWARFLists(raw_ostream ,
-  ArrayRef> Tables,
-  bool IsLittleEndian, bool Is64BitAddrSize) {
+static Error writeDWARFLists(raw_ostream ,
+ ArrayRef> Tables,
+ bool IsLittleEndian, bool Is64BitAddrSize) {
   for (const DWARFYAML::ListTable  : Tables) {
 // sizeof(version) + sizeof(address_size) + sizeof(segment_selector_size) +
 // sizeof(offset_entry_count) = 8

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 77e38236686b..c6017b4fc577 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3719,7 +3719,7 @@ Value 
*InstCombinerImpl::foldUnsignedMultiplicationOverflowCheck(ICmpInst ) {
   return Res;
 }
 
-Instruction *foldICmpXNegX(ICmpInst ) {
+static Instruction *foldICmpXNegX(ICmpInst ) {
   CmpInst::Predicate Pred;
   Value *X;
   if (!match(, m_c_ICmp(Pred, m_NSWNeg(m_Value(X)), m_Deferred(X

diff  --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp 
b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 45f6f4d1cf31..23af60be585c 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -136,8 +136,8 @@ LogicalResult getMemRefAlignment(LLVMTypeConverter 
, T op,
 }
 
 // Helper that returns the base address of a memref.
-LogicalResult getBase(ConversionPatternRewriter , Location loc,
-  Value memref, MemRefType memRefType, Value ) {
+static LogicalResult getBase(ConversionPatternRewriter , Location loc,
+ Value memref, MemRefType memRefType, Value ) 
{
   // Inspect stride and offset structure.
   //
   // TODO: flat memory only for now, generalize
@@ -153,8 +153,9 @@ LogicalResult getBase(ConversionPatternRewriter , 
Location loc,
 }
 
 // Helper that returns a pointer given a memref base.
-LogicalResult getBasePtr(ConversionPatternRewriter , Location loc,
- Value memref, MemRefType memRefType, Value ) {
+static LogicalResult getBasePtr(ConversionPatternRewriter ,
+Location loc, Value memref,
+MemRefType memRefType, Value ) {
   Value base;
   if (failed(getBase(rewriter, loc, memref, memRefType, base)))
 return failure();
@@ -164,9 +165,9 @@ LogicalResult getBasePtr(ConversionPatternRewriter 
, Location loc,
 }
 
 // Helper that returns a bit-casted pointer given a memref base.
-LogicalResult getBasePtr(ConversionPatternRewriter , Location loc,
- Value memref, MemRefType memRefType, Type type,
- Value ) {
+static LogicalResult getBasePtr(ConversionPatternRewriter ,
+Location loc, Value memref,
+MemRefType memRefType, Type type, Value ) {
   Value base;
   if (failed(getBase(rewriter, loc, memref, memRefType, base)))
 return failure();
@@ -178,9 +179,10 @@ LogicalResult getBasePtr(ConversionPatternRewriter 
, Location loc,
 
 // Helper that returns vector of pointers given a memref base and an index
 // vector.
-LogicalResult getIndexedPtrs(ConversionPatternRewriter , Location loc,
- Value memref, Value 

[PATCH] D84886: Create LoopNestPass

2020-08-19 Thread Whitney Tsang via Phabricator via cfe-commits
Whitney added a comment.

> I was trying to convert the LoopInterchange pass into a loop-nest pass. 
> However, there seems to be no corresponding loop pass for the NPM.
> Any particular reason for this?

That's true, LoopInterchange pass is not already ported to the NPM, likely 
because no one needed it in the NPM. Maybe you want to convert another pass to 
loop-nest pass as the first loop-nest pass, or you will have to port it to NPM 
first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

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


[clang-tools-extra] 1014a93 - Fix unused variable warnings. NFCI.

2020-08-19 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-19T14:34:32+01:00
New Revision: 1014a93a4e0203eccc20190c31169b26ec4b9058

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

LOG: Fix unused variable warnings. NFCI.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 9f68e248197e..66d9c4c36b12 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -388,9 +388,9 @@ class DefineOutline : public Tweak {
 
 // Bail out if this is a function template or specialization, as their
 // definitions need to be visible in all including translation units.
-if (auto *PT = Source->getDescribedFunctionTemplate())
+if (Source->getDescribedFunctionTemplate())
   return false;
-if (auto *TSI = Source->getTemplateSpecializationInfo())
+if (Source->getTemplateSpecializationInfo())
   return false;
 
 // Bail out in templated classes, as it is hard to spell the class name, 
i.e



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


[clang] 916b750 - [CodeGen] Use existing EmitLambdaVLACapture (NFC)

2020-08-19 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-08-19T15:20:05+02:00
New Revision: 916b750a8d1ab47d41939b42bf1d6eeddbdef686

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

LOG: [CodeGen] Use existing EmitLambdaVLACapture (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CGStmt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index c2bd17a238d0..9dd79469b544 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2418,8 +2418,7 @@ LValue CodeGenFunction::InitCapturedStruct(const 
CapturedStmt ) {
I != E; ++I, ++CurField) {
 LValue LV = EmitLValueForFieldInitialization(SlotLV, *CurField);
 if (CurField->hasCapturedVLAType()) {
-  auto VAT = CurField->getCapturedVLAType();
-  EmitStoreThroughLValue(RValue::get(VLASizeMap[VAT->getSizeExpr()]), LV);
+  EmitLambdaVLACapture(CurField->getCapturedVLAType(), LV);
 } else {
   EmitInitializerForField(*CurField, LV, *I);
 }



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


[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, but perhaps there should be some changes in AttrDocs.td to document the 
new support?


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

https://reviews.llvm.org/D86187

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


[PATCH] D86209: [clang-tidy] run-clang-tidy.py: Fix -allow-enabling-analyzer-alpha-checkers always being passed

2020-08-19 Thread Joachim Priesner via Phabricator via cfe-commits
jspam created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, a.sidorin, baloghadamsoftware, xazax.hun.
Herald added a project: clang.
jspam requested review of this revision.

The `action='store_true'` option of `argparse.add_argument` implicitly
generates a default value of False if the argument is not specified.
Thus, the `allow_enabling_alpha_checkers` argument of
`get_tidy_invocation` is never None.

Fixes: bbb7921da97ce03d2933e185a525c4e452b146b0 


[1] https://docs.python.org/3/library/argparse.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86209

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


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,7 +84,7 @@
 extra_arg, extra_arg_before, quiet, config):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
-  if allow_enabling_alpha_checkers is not None:
+  if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,7 +84,7 @@
 extra_arg, extra_arg_before, quiet, config):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
-  if allow_enabling_alpha_checkers is not None:
+  if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-19 Thread Harmen Stoppels via Phabricator via cfe-commits
haampie added inline comments.



Comment at: llvm/lib/Support/CMakeLists.txt:217
+  endif()
+  if(CMAKE_SHARED_LIBRARY_PREFIX AND CMAKE_SHARED_LIBRARY_SUFFIX AND
+  zlib_library MATCHES 
"^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")

This will not work on macOS since cmake will find stub libraries by default 
(/path/to/libz.tbd), see 
https://github.com/Kitware/CMake/blob/master/Modules/Platform/Darwin.cmake#L71 
for the search order.

Instead you most likely want to use `CMAKE_FIND_LIBRARY_PREFIXES` and 
`CMAKE_FIND_LIBRARY_SUFFIXES`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219

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


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

2020-08-19 Thread Eric Christopher via cfe-commits
This would be because at that point the default cpu was that and it
probably had something to do with fallbacks.

At this point it can be changed I imagine to whatever makes sense.

On Wed, Aug 19, 2020, 1:12 AM Craig Topper via Phabricator <
revi...@reviews.llvm.org> wrote:

> craig.topper added a subscriber: ddunbar.
> craig.topper added a comment.
>
> In D85384#2225434 , @phosek
> wrote:
>
> > This seems to have broken our Mac builders with the following error:
> >
> >   -- Testing: 25226 tests, 24 workers --
> >   Testing:  0.. 10.. 20.
> >   FAIL: Clang :: Frontend/ast-main.c (6834 of 25226)
> >    TEST 'Clang :: Frontend/ast-main.c' FAILED
> 
> >   Script:
> >   --
> >   : 'RUN: at line 1';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
> -x c - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
> >   : 'RUN: at line 2';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-ast -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
> /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
> >   : 'RUN: at line 3';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
> -x ast - <
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
> >   : 'RUN: at line 4';   diff
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
> >   --
> >   Exit Code: 1
> >
> >   Command Output (stdout):
> >   --
> >   14c14
> >   < attributes #0 = { noinline nounwind optnone ssp uwtable
> "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "frame-pointer"="all"
> "less-precise-fpmad"="false" "min-legal-vector-width"="0"
> "no-infs-fp-math"="false" "no-jump-tables"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "no-trapping-math"="true" "stack-protector-buffer-size"="8"
> "target-cpu"="penryn"
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
> "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> >   ---
> >   > attributes #0 = { noinline nounwind optnone ssp uwtable
> "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "frame-pointer"="all"
> "less-precise-fpmad"="false" "min-legal-vector-width"="0"
> "no-infs-fp-math"="false" "no-jump-tables"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "no-trapping-math"="true" "stack-protector-buffer-size"="8"
> "target-cpu"="penryn"
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
> "unsafe-fp-math"="false" "use-soft-float"="false" }
> >
> >   --
> >
> >   
> >   Testing:  0.. 10.. 20.
> >   FAIL: Clang :: Frontend/ast-main.cpp (6835 of 25226)
> >    TEST 'Clang :: Frontend/ast-main.cpp' FAILED
> 
> >   Script:
> >   --
> >   : 'RUN: at line 1';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
> -x c++ - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
> >   : 'RUN: at line 2';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -fno-delayed-template-parsing
> -emit-ast -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
> /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
> >   : 'RUN: at line 3';   env SDKROOT="/"
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
> -x ast - <
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
> >   : 'RUN: at line 4';   diff
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
> >   --
> >   Exit Code: 1
> >
> >   Command Output (stdout):
> >   --
> >   37,39c37,39
> >   < attributes #0 = { noinline optnone ssp uwtable
> "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "frame-pointer"="all"
> "less-precise-fpmad"="false" "min-legal-vector-width"="0"
> "no-infs-fp-math"="false" "no-jump-tables"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "no-trapping-math"="true" "stack-protector-buffer-size"="8"
> "target-cpu"="penryn"
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
> "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> >   < attributes #1 = { noinline 

[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

CFE changes look right to me.  Please give the rest of the reviews a little 
while to  take a look though


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

https://reviews.llvm.org/D86187

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


[PATCH] D84603: Thread safety analysis: More consistent warning message

2020-08-19 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84603

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


[PATCH] D86207: (De-)serialize BindingDecls before DecompositionDecl

2020-08-19 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
aaronpuchert requested review of this revision.

When parsing a C++17 binding declaration, we first create the
BindingDecls in Sema::ActOnDecompositionDeclarator, and then build the
DecompositionDecl in Sema::ActOnVariableDeclarator, so the contained
BindingDecls are never null. But when deserializing, we read the
DecompositionDecl first, do a few operations on it, and only later read
the BindingDecls.

One of those operations is potentially marking the DecompositionDecl as
invalid, and Decl::setInvalidDecl was propagating that to the
BindingDecls that don't yet exist, causing a crash when deserializing
invalid DecompositionDecls.

One way would be to change that function, but I believe this is better,
because the parsing code path is tested more thoroughly and sticking to
the same order for (de-)serialization makes the assumptions one would
derive from the parsing code apply here as well.

Fixes PR34960.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86207

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/PCH/cxx1z-decomposition.cpp


Index: clang/test/PCH/cxx1z-decomposition.cpp
===
--- clang/test/PCH/cxx1z-decomposition.cpp
+++ clang/test/PCH/cxx1z-decomposition.cpp
@@ -2,11 +2,11 @@
 // RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s
 //
 // With PCH:
-// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch %s -o %t
-// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s
+// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch 
-fallow-pch-with-compiler-errors %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t 
-fallow-pch-with-compiler-errors -verify %s
 
-// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fpch-instantiate-templates 
%s -o %t
-// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s
+// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch 
-fallow-pch-with-compiler-errors -fpch-instantiate-templates %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t 
-fallow-pch-with-compiler-errors -verify %s
 
 #ifndef HEADER
 #define HEADER
@@ -22,6 +22,8 @@
   return a * 10 + b;
 }
 
+auto [noinit]; // expected-error{{decomposition declaration '[noinit]' 
requires an initializer}}
+
 #else
 
 int arr[2];
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1140,9 +1140,9 @@
   // Record the number of bindings first to simplify deserialization.
   Record.push_back(D->bindings().size());
 
-  VisitVarDecl(D);
   for (auto *B : D->bindings())
 Record.AddDeclRef(B);
+  VisitVarDecl(D);
   Code = serialization::DECL_DECOMPOSITION;
 }
 
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1495,12 +1495,12 @@
 }
 
 void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) {
-  VisitVarDecl(DD);
   auto **BDs = DD->getTrailingObjects();
   for (unsigned I = 0; I != DD->NumBindings; ++I) {
 BDs[I] = readDeclAs();
 BDs[I]->setDecomposedDecl(DD);
   }
+  VisitVarDecl(DD);
 }
 
 void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) {


Index: clang/test/PCH/cxx1z-decomposition.cpp
===
--- clang/test/PCH/cxx1z-decomposition.cpp
+++ clang/test/PCH/cxx1z-decomposition.cpp
@@ -2,11 +2,11 @@
 // RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s
 //
 // With PCH:
-// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch %s -o %t
-// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s
+// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
 
-// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fpch-instantiate-templates %s -o %t
-// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s
+// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors -fpch-instantiate-templates %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
 
 #ifndef HEADER
 #define HEADER
@@ -22,6 +22,8 @@
   return a * 10 + b;
 }
 
+auto [noinit]; // expected-error{{decomposition declaration '[noinit]' requires an initializer}}
+
 #else
 
 int arr[2];
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1140,9 +1140,9 @@
   

[PATCH] D85485: Fix quiet mode in git-clang-format

2020-08-19 Thread Gvald Ike via Phabricator via cfe-commits
Gvald marked an inline comment as done.
Gvald added a comment.

Tried to `arc land` but don't have the permissions.
From LLVM docs :

> It is sufficient to add a comment to the approved review indicating you 
> cannot commit the patch yourself

So here it is, the comment... 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85485

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


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

2020-08-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Sorry, I was just not reading the test clearly. LGTM




Comment at: clang/lib/Serialization/ASTReader.cpp:4990
 PP.makeModuleVisible(Imported, Import.ImportLoc);
-  // FIXME: should we tell Sema to make the module visible too?
 }

maybe replace this with a comment pointing at UpdateSema() for the sema part


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] D85485: Fix quiet mode in git-clang-format

2020-08-19 Thread Gvald Ike via Phabricator via cfe-commits
Gvald updated this revision to Diff 286531.
Gvald edited the summary of this revision.
Gvald added a project: clang-format.
Gvald added a comment.

PEP8 compliance fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85485

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -148,7 +148,8 @@
   for filename in changed_lines:
 print('%s' % filename)
   if not changed_lines:
-print('no modified files to format')
+if opts.verbose >= 0:
+  print('no modified files to format')
 return
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -148,7 +148,8 @@
   for filename in changed_lines:
 print('%s' % filename)
   if not changed_lines:
-print('no modified files to format')
+if opts.verbose >= 0:
+  print('no modified files to format')
 return
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
___
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-19 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



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

efriedma wrote:
> Can we fix getTypeInfoInChars so it returns all the necessary info, so we 
> don't look up the typeinfo twice?
That feels like a hefty change since it would require changing every caller of 
getTypeInfoInChars. Do you want me to do that in this patch or in a separate 
one?


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] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added inline comments.



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:
> atrosinenko wrote:
> > 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.
> > Divisor is 1.(31 zeroes)1
> 
> So it is **not** `1.0` and the comment is misleading. Try rewording the 
> comment to avoid confusion. Maybe `divisor is truncated to 1.0 in UQ1.31` or 
> something like that. 
Now got it, thank you.


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


  1   2   >