[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D76525#1942825 , @zoecarver wrote:

> @craig.topper I'm not sure what should happen. It should probably just use 
> that CPU (although that's not a great solution). Is there a way to detect if 
> an attribute was used to change the target in which case we could error? What 
> do you think should happen?


I'm not sure what should happen as I'm not familiar with the library feature 
being implemented. As implemented here, the target attribute will be ignored 
and it will just follow the command line. Why do you say that following the 
attribute is not a great solution?




Comment at: clang/test/SemaCXX/builtin-cache-line-size.cpp:1
+// RUN: %clang -mcpu=i368 %s
+// RUN: ./a.out

This say i368 which is not a valid cpu. Did you mean i386? Also x86 uses use 
-march not -mcpu. I don't think -mcpu does anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76525



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


[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-03-25 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp:30
+// Wrapped in correct namespace.
+namespace __llvm_libc {
+class ClassB;

For completeness, can you include a nested namespace and a function declaration 
here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818



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


[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-03-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please also add isLanguageVersionSupported(), because namespaces make sense 
only in C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-25 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added a comment.

In D73307#1942805 , @MaskRay wrote:

> In D73307#1932131 , @rnk wrote:
>
> > At a higher level, should this just be an IR pass that clang adds into the 
> > pipeline when the flag is set? It should be safe to rename internal 
> > functions and give private functions internal linkage. It would be less 
> > invasive to clang and have better separation of concerns. As written, this 
> > is based on the source filename on the module, which is accessible from IR. 
> > The only reason I can think of against this is that the debug info might 
> > refer to the function linkage name, but maybe that is calculated later 
> > during codegen.
>
>
> I second this suggestion. `clang/lib/CodeGen/BackendUtil.cpp` 
> `EmitAssemblyHelper::EmitAssemblyWithNewPassManager` ModulePassManager may be 
> a more appropriate place for this feature. There are examples from both sides:


@rnk getMangledNameImpl for example adds multi-versioning suffixes,  
"__regcall3_" and  "__device_stub".  Adding the hash is just so simple.  Is a 
pass really needed?  If so, I should parse "." suffixed 
Multi-versioining names and insert the hash in between as the demangling looks 
better?

> 
> 
> - clang frontend: `#pragma redefine_extname`
> - middle end IR->IR: the old pass manager has a feature -frewrite-map-file, 
> which does a similar thing but is implemented as an IR transformation.






Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1060
+  const Decl *D = GD.getDecl();
+  if (CGM.getCodeGenOpts().UniqueInternalLinkageNames &&
+  !CGM.getModuleNameHash().empty() &&

davidxl wrote:
> is the first check redundant now?
Good catch, converted to an assert.


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

https://reviews.llvm.org/D73307



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


[clang] d264f02 - Fix `-Wreturn-type` warning. NFC.

2020-03-25 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-03-26T00:53:24-04:00
New Revision: d264f02c6f502960e2bcdd332f250efc702d09f2

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

LOG: Fix `-Wreturn-type` warning. NFC.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index f35b520de657..8a7d0f17760e 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1842,6 +1842,7 @@ Optional X86TargetInfo::getCPUCacheLineSize() 
const {
 case CK_Generic:
   return None;
   }
+  return None;
 }
 
 bool X86TargetInfo::validateOutputSize(const llvm::StringMap ,



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


[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 252742.
zoecarver added a comment.

- Diff from master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76525

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/builtin-cache-line-size.cpp


Index: clang/test/SemaCXX/builtin-cache-line-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-cache-line-size.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang -mcpu=i368 %s
+// RUN: ./a.out
+
+#include 
+
+size_t a() {
+  return __builtin_get_cpu_cache_line_size();
+}
+
+size_t b(bool x) {
+  if (x) {
+return __builtin_get_cpu_cache_line_size();
+  }
+  return 0;
+}
+
+int main() {
+  assert(a() == 64);
+  assert(b(true) == 64);
+  assert(b(false) == 0);
+}
+
+// This is based on the value for i368.
+static_assert(__builtin_get_cpu_cache_line_size() == 64, "");
+
+struct keep_apart {
+  alignas(__builtin_get_cpu_cache_line_size()) int cat;
+  alignas(__builtin_get_cpu_cache_line_size()) int dog;
+};
+
+static_assert(sizeof(keep_apart) == __builtin_get_cpu_cache_line_size() * 2 ||
+  __builtin_get_cpu_cache_line_size() == 0, "");
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10915,6 +10915,14 @@
 return Success(Info.InConstantContext, E);
   }
 
+  case Builtin::BI__builtin_get_cpu_cache_line_size: {
+Optional cacheLineSize =
+  Info.Ctx.getTargetInfo().getCPUCacheLineSize();
+if (cacheLineSize.hasValue())
+  return Success(cacheLineSize.getValue(), E);
+return Success(0, E);
+  }
+
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:
   case Builtin::BI__builtin_ctzll:
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1480,6 +1480,7 @@
 BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
 BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
 BUILTIN(__builtin_preserve_access_index, "v.", "t")
+BUILTIN(__builtin_get_cpu_cache_line_size, "zv", "nc")
 
 // Alignment builtins (uses custom parsing to support pointers and integers)
 BUILTIN(__builtin_is_aligned, "bvC*z", "nct")


Index: clang/test/SemaCXX/builtin-cache-line-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-cache-line-size.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang -mcpu=i368 %s
+// RUN: ./a.out
+
+#include 
+
+size_t a() {
+  return __builtin_get_cpu_cache_line_size();
+}
+
+size_t b(bool x) {
+  if (x) {
+return __builtin_get_cpu_cache_line_size();
+  }
+  return 0;
+}
+
+int main() {
+  assert(a() == 64);
+  assert(b(true) == 64);
+  assert(b(false) == 0);
+}
+
+// This is based on the value for i368.
+static_assert(__builtin_get_cpu_cache_line_size() == 64, "");
+
+struct keep_apart {
+  alignas(__builtin_get_cpu_cache_line_size()) int cat;
+  alignas(__builtin_get_cpu_cache_line_size()) int dog;
+};
+
+static_assert(sizeof(keep_apart) == __builtin_get_cpu_cache_line_size() * 2 ||
+  __builtin_get_cpu_cache_line_size() == 0, "");
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10915,6 +10915,14 @@
 return Success(Info.InConstantContext, E);
   }
 
+  case Builtin::BI__builtin_get_cpu_cache_line_size: {
+Optional cacheLineSize =
+  Info.Ctx.getTargetInfo().getCPUCacheLineSize();
+if (cacheLineSize.hasValue())
+  return Success(cacheLineSize.getValue(), E);
+return Success(0, E);
+  }
+
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:
   case Builtin::BI__builtin_ctzll:
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1480,6 +1480,7 @@
 BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
 BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
 BUILTIN(__builtin_preserve_access_index, "v.", "t")
+BUILTIN(__builtin_get_cpu_cache_line_size, "zv", "nc")
 
 // Alignment builtins (uses custom parsing to support pointers and integers)
 BUILTIN(__builtin_is_aligned, "bvC*z", "nct")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 252741.
zoecarver added a comment.

- Fix based on review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76525

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/test/SemaCXX/builtin-cache-line-size.cpp

Index: clang/test/SemaCXX/builtin-cache-line-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-cache-line-size.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang -mcpu=i368 %s
+// RUN: ./a.out
+
+#include 
+
+size_t a() {
+  return __builtin_get_cpu_cache_line_size();
+}
+
+size_t b(bool x) {
+  if (x) {
+return __builtin_get_cpu_cache_line_size();
+  }
+  return 0;
+}
+
+int main() {
+  assert(a() == 64);
+  assert(b(true) == 64);
+  assert(b(false) == 0);
+}
+
+// This is based on the value for i368.
+static_assert(__builtin_get_cpu_cache_line_size() == 64, "");
+
+struct keep_apart {
+  alignas(__builtin_get_cpu_cache_line_size()) int cat;
+  alignas(__builtin_get_cpu_cache_line_size()) int dog;
+};
+
+static_assert(sizeof(keep_apart) == __builtin_get_cpu_cache_line_size() * 2 ||
+  __builtin_get_cpu_cache_line_size() == 0, "");
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl ) const override;
 
+  Optional getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,118 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  16 | "four doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216=rep1=pdf (page 29) |
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cpu.com/cpu/P6.html|
+// | Netburst/Pentium4  |  64 | https://www.7-cpu.com/cpu/P4-180.html|
+// | Atom   |  64 | https://www.7-cpu.com/cpu/Atom.html  |
+// | Westmere   |  64 | https://en.wikichip.org/wiki/intel/microarchitectures/sandy_bridge_(client) "Cache Architecture" |
+// | Sandy Bridge   |  64 | https://en.wikipedia.org/wiki/Sandy_Bridge and https://www.7-cpu.com/cpu/SandyBridge.html|
+// | Ivy Bridge |  64 | https://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ and https://www.7-cpu.com/cpu/IvyBridge.html  |
+// | Haswell|

[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@craig.topper I'm not sure what should happen. It should probably just use that 
CPU (although that's not a great solution). Is there a way to detect if an 
attribute was used to change the target in which case we could error? What do 
you think should happen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76525



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D73307#1932131 , @rnk wrote:

> At a higher level, should this just be an IR pass that clang adds into the 
> pipeline when the flag is set? It should be safe to rename internal functions 
> and give private functions internal linkage. It would be less invasive to 
> clang and have better separation of concerns. As written, this is based on 
> the source filename on the module, which is accessible from IR. The only 
> reason I can think of against this is that the debug info might refer to the 
> function linkage name, but maybe that is calculated later during codegen.


I second this suggestion. `clang/lib/CodeGen/BackendUtil.cpp` 
`EmitAssemblyHelper::EmitAssemblyWithNewPassManager` ModulePassManager may be a 
more appropriate place for this feature. There are examples from both sides:

- clang frontend: `#pragma redefine_extname`
- middle end IR->IR: the old pass manager has a feature -frewrite-map-file, 
which does a similar thing but is implemented as an IR transformation.


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

https://reviews.llvm.org/D73307



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-25 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252738.
oontvoo added a comment.

...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1619,7 +1619,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch ) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch ) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,8 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HeaderFileInfo *HFI = HS.getExistingFileInfo(File, /*WantExternal*/ !Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1799,8 +1801,13 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+*HFI,
+HS.getModuleMap().findAllModulesForHeader(File),
+{},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2641,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo *HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+case SUBMODULE_IMPORTED_HEADERS:
+  for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+PendingImportedHeaders[].push_back(Record[Idx]);
+  }
+  break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch  = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+  HS.FileInfo[Idx].UID = 0;
+}
+
+

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-25 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252735.
oontvoo added a comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1619,7 +1619,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch ) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch ) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,8 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HeaderFileInfo *HFI = HS.getExistingFileInfo(File, /*WantExternal*/ !Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1799,8 +1801,13 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+*HFI,
+HS.getModuleMap().findAllModulesForHeader(File),
+{},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2641,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo *HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+case SUBMODULE_IMPORTED_HEADERS:
+  for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+PendingImportedHeaders[].push_back(Record[Idx]);
+  }
+  break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch  = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+  HS.FileInfo[Idx].UID = 0;
+}
+
+

[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, if you think that suppress array decay is the right behavior here, that's 
fine with me.  Please check the behavior of other OpenMP implementations, 
though.




Comment at: clang/lib/Sema/SemaExpr.cpp:4848
+  Expr::EvalResult EvResult;
+  if (Dim->EvaluateAsInt(EvResult, Context)) {
+// OpenMP 5.0, [2.1.4 Array Shaping]

You do still need an `isValueDependent()` check here, and you should add a test 
that exercises it.  (A `sizeof(T)` argument is probably good enough.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-25 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 252730.
MarcusJohnson91 added a comment.

Implemented the suggestion to break the test strings down into smaller pieces


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

https://reviews.llvm.org/D75791

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2491,11 +2491,43 @@
Style);
   verifyFormat("extern \"C\"\n"
"{\n"
-   "  int foo();\n"
+   "int foo();\n"
"}",
Style);
 }
 
+TEST_F(FormatTest, FormatsExternBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentWidth = 2;
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "  int foo();"
+   "\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "  int foo();"
+   "\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "int foo();"
+   "\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "int foo();"
+   "\n}", Style);
+}
+
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
   verifyFormat("asm(\"nop\" ::: \"memory\");");
@@ -12660,6 +12692,7 @@
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(IndentExternBlock);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1114,11 +1114,9 @@
   if (FormatTok->Tok.is(tok::l_brace)) {
 if (Style.BraceWrapping.AfterExternBlock) {
   addUnwrappedLine();
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
-  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
 }
-addUnwrappedLine();
+parseBlock(/*MustBeDeclaration=*/true,
+/*AddLevel=*/Style.IndentExternBlock);
 return;
   }
 }
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -493,6 +493,7 @@
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
Style.IndentWrappedFunctionNames);
+IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
 IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
 IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
@@ -801,6 +802,7 @@
   LLVMStyle.IndentGotoLabels = true;
   LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
   LLVMStyle.IndentWrappedFunctionNames = false;
+  LLVMStyle.IndentExternBlock = false;
   LLVMStyle.IndentWidth = 2;
   LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
@@ -888,6 +890,7 @@
   GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   GoogleStyle.IndentCaseLabels = true;
+  GoogleStyle.IndentExternBlock = false;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   GoogleStyle.ObjCSpaceAfterProperty = false;
@@ -1023,6 +1026,7 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+ChromiumStyle.IndentExternBlock = false;
 // See styleguide for import groups:
 // https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
@@ -1072,6 +1076,7 @@
   MozillaStyle.Cpp11BracedListStyle = false;
   MozillaStyle.FixNamespaceComments = false;
   MozillaStyle.IndentCaseLabels = true;
+  

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-25 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252728.
oontvoo added a comment.

Typo - missing ! operator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1619,7 +1619,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch ) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch ) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,8 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HeaderFileInfo *HFI = HS.getExistingFileInfo(File, /*WantExternal*/ !Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1799,8 +1801,13 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+*HFI,
+HS.getModuleMap().findAllModulesForHeader(File),
+{},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2641,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo *HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+case SUBMODULE_IMPORTED_HEADERS:
+  for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+PendingImportedHeaders[].push_back(Record[Idx]);
+  }
+  break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch  = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+  

[PATCH] D76653: [clang] Allow -DDEFAULT_SYSROOT to be a relative path

2020-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Hmm.. `arc diff` was behaving strangely for me and failed to update this PR as 
I expected.  Should fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76653



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


[PATCH] D76653: [clang] Allow -DDEFAULT_SYSROOT to be a relative path

2020-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 252725.
sbc100 added a comment.

squash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76653

Files:
  clang/CMakeLists.txt
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -140,6 +140,13 @@
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -226,7 +226,7 @@
   "Colon separated list of directories clang will search for headers.")
 
 set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
-set(DEFAULT_SYSROOT "" CACHE PATH
+set(DEFAULT_SYSROOT "" CACHE STRING
   "Default  to all compiler invocations for --sysroot=." )
 
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -140,6 +140,13 @@
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -226,7 +226,7 @@
   "Colon separated list of directories clang will search for headers.")
 
 set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
-set(DEFAULT_SYSROOT "" CACHE PATH
+set(DEFAULT_SYSROOT "" CACHE STRING
   "Default  to all compiler invocations for --sysroot=." )
 
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76653: [clang] Allow -DDEFAULT_SYSROOT to be a relative path

2020-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 252724.
sbc100 added a comment.

feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76653

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76744: [clang-tidy] Add check to ensure llvm-libc implementations are defined in correct namespace.

2020-03-25 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast marked 3 inline comments as done.
PaulkaToast added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/EntrypointNamespaceCheck.cpp:67
+  if (Result.SourceManager->getFilename(MatchedDecl->getLocation())
+  .endswith(".h"))
+return;

njames93 wrote:
> Is there a rule that all libc implementation headers must have the extension 
> `.h`. If not there is `utils::FileExtensionSet` that could be used.
> Alternatively you could just check to see if the SourceLocation is in the 
> main file
> `if (!Result.SourceManager->isInMainFile(MatchedDecl->getLocation())`
Thanks for this! I incorporated your recommendations in the new patch. (:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76744



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


[PATCH] D76717: feedback

2020-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 252723.
sbc100 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76717

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76744: [clang-tidy] Add check to ensure llvm-libc implementations are defined in correct namespace.

2020-03-25 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast abandoned this revision.
PaulkaToast added a comment.

Abandoning for a more generalized check. D76818 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76744



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


Buildbot numbers for the week of 03/15/2020 - 03/21/2020

2020-03-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 03/15/2020 -
03/21/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit   | 102:26:58
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 101:44:29
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu   | 101:43:14
 sanitizer-windows| 68:31:06
 libcxx-libcxxabi-libunwind-x86_64-linux-debian   | 25:02:09
 ppc64le-lld-multistage-test  | 21:00:02
 sanitizer-x86_64-linux-android   | 20:32:06
 sanitizer-x86_64-linux   | 20:19:23
 clang-cmake-thumbv7-full-sh  | 16:48:05
 sanitizer-x86_64-linux-bootstrap | 13:49:20
 sanitizer-x86_64-linux-fast  | 11:46:27
 clang-with-lto-ubuntu| 11:20:17
 clang-with-thin-lto-ubuntu   | 10:57:48
 llvm-clang-x86_64-expensive-checks-win   | 10:43:02
 fuchsia-x86_64-linux | 10:34:26
 clang-ppc64le-linux-multistage   | 10:23:16
 llvm-clang-x86_64-expensive-checks-ubuntu| 10:05:59
 llvm-clang-x86_64-expensive-checks-debian| 10:05:37
 clang-x64-windows-msvc   | 08:03:31
 sanitizer-x86_64-linux-bootstrap-ubsan   | 07:59:33
 clang-ppc64le-linux  | 07:50:38
 clang-cmake-x86_64-avx2-linux| 07:48:48
 clang-s390x-linux-multistage | 07:43:39
 llvm-avr-linux   | 07:41:47
 clang-cmake-armv8-lld| 07:37:58
 clang-s390x-linux-lnt| 07:35:39
 clang-hexagon-elf| 07:18:32
 clang-cmake-aarch64-full | 07:17:45
 clang-ppc64le-linux-lnt  | 07:09:53
 clang-cmake-armv7-quick  | 07:04:23
 clang-ppc64le-rhel   | 07:03:01
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 06:59:09
 clang-cmake-x86_64-sde-avx512-linux  | 06:58:55
 clang-cmake-armv7-global-isel| 06:50:28
 llvm-clang-win-x-armv7l  | 06:48:55
 clang-s390x-linux| 06:44:23
 clang-x86_64-debian-fast | 06:40:49
 clang-x86_64-debian-new-pass-manager-fast| 06:40:31
 clang-ppc64be-linux-multistage   | 06:39:37
 lld-x86_64-win7  | 06:29:20
 sanitizer-x86_64-linux-bootstrap-msan| 06:23:18
 clang-cmake-aarch64-global-isel  | 06:19:21
 clang-ppc64be-linux-lnt  | 06:02:53
 clang-cmake-armv7-selfhost-neon  | 06:00:15
 clang-cmake-armv7-selfhost   | 05:57:42
 clang-atom-d525-fedora-rel   | 05:52:21
 clang-cmake-aarch64-quick| 05:47:00
 sanitizer-ppc64be-linux  | 05:21:12
 sanitizer-ppc64le-linux  | 05:14:44
 clang-cmake-aarch64-lld  | 04:58:41
 llvm-clang-win-x-aarch64 | 04:39:12
 clang-ppc64be-linux  | 04:23:17
 openmp-clang-x86_64-linux-debian | 03:50:11
 lld-x86_64-darwin13  | 02:06:58
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 01:47:02
 clang-cmake-armv7-lnt| 01:31:00
 lldb-x64-windows-ninja   | 01:26:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11  | 01:24:39
 polly-arm-linux  | 01:23:20
 lldb-aarch64-ubuntu  | 01:12:40
 openmp-gcc-x86_64-linux-debian   | 01:10:48
 lld-x86_64-freebsd   | 01:08:28
 lld-x86_64-ubuntu-fast   | 00:57:45
 lldb-x86_64-debian   | 00:46:31
 llvm-clang-x86_64-win-fast   | 00:44:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 00:44:18
 clang-aarch64-linux-build-cache  | 00:44:01
 libc-x86_64-debian-asan  | 00:43:45
 libc-x86_64-debian   | 00:43:43
 clang-armv7-linux-build-cache 

Buildbot numbers for the week of 03/8/2020 - 03/14/2020

2020-03-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 03/8/2020 - 03/14/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
buildername| was_red
---+-
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 22:30:47
 clang-x64-windows-msvc| 18:04:44
 llvm-clang-x86_64-expensive-checks-win| 09:37:13
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 09:31:11
 clang-cmake-thumbv7-full-sh   | 09:11:05
 clang-cmake-aarch64-lld   | 08:11:26
 clang-with-lto-ubuntu | 07:45:55
 sanitizer-ppc64le-linux   | 07:38:40
 clang-cmake-armv7-selfhost-neon   | 07:37:04
 clang-cmake-armv8-lld | 07:33:52
 clang-ppc64le-linux-multistage| 07:33:21
 clang-cmake-aarch64-full  | 07:13:20
 llvm-clang-win-x-aarch64  | 07:06:37
 clang-cmake-armv7-selfhost| 07:04:58
 lld-x86_64-win7   | 06:56:08
 clang-native-arm-lnt-perf | 06:51:29
 clang-cmake-armv7-global-isel | 06:43:50
 sanitizer-x86_64-linux-bootstrap-ubsan| 06:32:54
 llvm-avr-linux| 06:28:47
 clang-cmake-armv7-lnt | 06:02:18
 clang-ppc64le-linux-lnt   | 05:59:18
 sanitizer-x86_64-linux-bootstrap  | 05:57:46
 clang-ppc64le-rhel| 05:56:30
 clang-cmake-aarch64-global-isel   | 05:55:15
 clang-ppc64le-linux   | 05:53:41
 sanitizer-x86_64-linux| 05:53:27
 clang-cmake-aarch64-quick | 05:52:29
 clang-ppc64be-linux   | 05:45:33
 clang-cmake-armv7-quick   | 05:30:04
 clang-ppc64be-linux-multistage| 05:24:03
 llvm-clang-win-x-armv7l   | 05:20:20
 clang-ppc64be-linux-lnt   | 05:13:09
 ppc64le-lld-multistage-test   | 05:09:23
 sanitizer-ppc64be-linux   | 04:47:41
 openmp-clang-x86_64-linux-debian  | 04:36:59
 clang-s390x-linux-multistage  | 04:17:33
 libc-x86_64-debian| 04:14:10
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 04:13:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 03:59:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17| 03:58:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 03:57:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 03:57:15
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 03:56:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11   | 03:55:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 03:52:13
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan | 03:50:34
 lldb-x64-windows-ninja| 03:44:53
 lldb-x86_64-debian| 03:40:49
 clang-with-thin-lto-ubuntu| 03:23:00
 sanitizer-x86_64-linux-fuzzer | 03:19:03
 lld-x86_64-freebsd| 03:17:12
 lldb-aarch64-ubuntu   | 03:11:27
 sanitizer-x86_64-linux-android| 03:08:16
 clang-cmake-x86_64-sde-avx512-linux   | 03:07:54
 fuchsia-x86_64-linux  | 03:05:43
 clang-cuda-build  | 03:04:08
 sanitizer-x86_64-linux-bootstrap-msan | 02:59:15
 sanitizer-x86_64-linux-autoconf   | 02:48:32
 sanitizer-x86_64-linux-fast   | 02:21:05
 clang-s390x-linux | 01:55:53
 clang-cmake-x86_64-avx2-linux | 01:55:22
 clang-hexagon-elf | 01:41:36
 openmp-gcc-x86_64-linux-debian| 01:35:18
 clang-s390x-linux-lnt | 01:10:15
 clang-x86_64-linux-abi-test   | 01:05:14
 clang-aarch64-linux-build-cache   | 00:58:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 00:58:04
 clang-armv7-linux-build-cache | 00:55:49
 clang-x86_64-debian-fast

Buildbot numbers for the week of 03/1/2020 - 03/7/2020

2020-03-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 03/1/2020 - 03/7/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 clang-cmake-armv8-lld | 127:36:44
 clang-cmake-armv7-selfhost-neon   | 124:00:48
 clang-cmake-armv7-global-isel | 123:41:59
 clang-cmake-thumbv7-full-sh   | 123:12:26
 clang-cmake-armv7-selfhost| 122:22:06
 clang-cmake-armv7-quick   | 121:45:47
 clang-cmake-aarch64-lld   | 63:35:01
 clang-cmake-aarch64-full  | 62:50:29
 sanitizer-x86_64-linux-android| 59:56:46
 sanitizer-x86_64-linux| 58:21:47
 clang-cmake-aarch64-global-isel   | 55:02:10
 clang-cmake-aarch64-quick | 54:33:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 49:36:08
 sanitizer-x86_64-linux-bootstrap-msan | 43:34:13
 sanitizer-x86_64-linux-fast   | 43:04:57
 libc-x86_64-debian-asan   | 22:38:16
 libc-x86_64-debian| 22:38:16
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 20:56:04
 lldb-aarch64-ubuntu   | 20:03:30
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 16:53:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 16:12:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 16:09:37
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 16:07:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 16:07:30
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11   | 16:05:12
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 16:00:14
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 11:19:34
 clang-with-lto-ubuntu | 11:12:07
 sanitizer-ppc64le-linux   | 11:01:28
 libcxx-libcxxabi-libunwind-armv7-linux| 10:28:15
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 10:02:54
 sanitizer-x86_64-linux-bootstrap-ubsan| 09:37:12
 llvm-avr-linux| 08:40:42
 clang-with-thin-lto-ubuntu| 08:22:03
 sanitizer-x86_64-linux-bootstrap  | 08:05:18
 clang-atom-d525-fedora-rel| 08:01:57
 clang-s390x-linux-multistage  | 07:22:25
 clang-cuda-build  | 06:49:17
 clang-cmake-x86_64-sde-avx512-linux   | 06:32:17
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 06:31:10
 fuchsia-x86_64-linux  | 06:29:05
 clang-ppc64le-linux-multistage| 06:18:37
 clang-x86_64-debian-new-pass-manager-fast | 06:17:50
 clang-x86_64-debian-fast  | 06:17:50
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 06:13:30
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 06:11:30
 libcxx-libcxxabi-libunwind-armv8-linux| 06:01:23
 libcxx-libcxxabi-libunwind-aarch64-linux  | 05:56:07
 clang-cmake-x86_64-avx2-linux | 05:30:31
 sanitizer-ppc64be-linux   | 04:35:24
 openmp-gcc-x86_64-linux-debian| 03:59:24
 ppc64le-lld-multistage-test   | 03:57:05
 clang-x64-windows-msvc| 03:42:18
 clang-ppc64be-linux-lnt   | 02:54:47
 llvm-clang-x86_64-expensive-checks-win| 02:37:08
 clang-s390x-linux | 02:34:10
 clang-ppc64be-linux-multistage| 02:27:27
 clang-ppc64le-rhel| 02:20:16
 libcxx-libcxxabi-x86_64-linux-debian  | 02:13:50
 clang-ppc64le-linux-lnt   | 02:11:40
 openmp-clang-x86_64-linux-debian  | 02:10:39
 clang-s390x-linux-lnt | 02:08:01
 lldb-x64-windows-ninja| 02:03:06
 llvm-clang-x86_64-win-fast| 01:52:44
 

[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-03-25 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast created this revision.
PaulkaToast added reviewers: alexfh, aaron.ballman, hokein, njames93.
PaulkaToast added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, MaskRay, xazax.hun, mgorny.
Herald added a project: clang.

This check makes sure all llvm-libc implementations falls within the 
`__llvm_libc` namespace.

The check is quite general, lots of projects do this by conversion to avoid 
pollution. Not sure if there is a desire to put this in a different module?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76818

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.h
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s llvmlibc-implementation-in-namespace %t
+
+#define MACRO_A "defining macros outside namespace is valid"
+
+class ClassB;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: CXXRecord is not defined in a namespace, please wrap implentation in '__llvm_libc' namespace.
+struct StructC {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: CXXRecord is not defined in a namespace, please wrap implentation in '__llvm_libc' namespace.
+char *VarD = MACRO_A;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Var is not defined in a namespace, please wrap implentation in '__llvm_libc' namespace.
+typedef int typeE;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Typedef is not defined in a namespace, please wrap implentation in '__llvm_libc' namespace.
+void funcF() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function is not defined in a namespace, please wrap implentation in '__llvm_libc' namespace.
+
+namespace namespace_g {
+class ClassB;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: CXXRecord is defined in namespace 'namespace_g', should be in '__llvm_libc' namespace.
+struct StructC {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: CXXRecord is defined in namespace 'namespace_g', should be in '__llvm_libc' namespace.
+char *VarD = MACRO_A;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Var is defined in namespace 'namespace_g', should be in '__llvm_libc' namespace.
+typedef int typeE;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Typedef is defined in namespace 'namespace_g', should be in '__llvm_libc' namespace.
+void funcF() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function is defined in namespace 'namespace_g', should be in '__llvm_libc' namespace.
+} // namespace namespace_g
+
+// Wrapped in correct namespace.
+namespace __llvm_libc {
+class ClassB;
+struct StructC {};
+char *VarD = MACRO_A;
+typedef int typeE;
+void funcF() {}
+} // namespace __llvm_libc
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - llvmlibc-implementation-in-namespace
+
+llvmlibc-implementation-in-namespace
+
+
+Checks all llvm-libc implementation is within the correct namespace.
+
+.. code-block:: c++
+
+// Correct: implementation inside the correct namespace.
+namespace __llvm_libc {
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+}
+
+// Incorrect: implementation not in a namespace.
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+
+// Incorrect: implementation inside an incorrect namespace.
+namespace something_else {
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+}
+
+Options
+---
+
+.. option:: RequiredNamespace
+
+The namespace that llvm-libc implementations must be wrapped in. The default
+is `__llvm_libc`.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -188,6 +188,7 @@
`llvm-prefer-isa-or-dyn-cast-in-conditionals `_, "Yes"
`llvm-prefer-register-over-unsigned `_, "Yes"
`llvm-twine-local `_, "Yes"
+   `llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-25 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 marked 2 inline comments as done.
MarcusJohnson91 added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:2497
Style);
 }
 

MyDeveloperDay wrote:
> my assumption is this test is using `Style.IndentExternBlock =false` correct?
> 
> This suggests the default was previously true not false
> 
> ```
> if (Style.BraceWrapping.AfterExternBlock) {
> if (Style.BraceWrapping.AfterExternBlock) {
>   addUnwrappedLine();
>   parseBlock(/*MustBeDeclaration=*/true);
> } else {
>   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
>}
> ```
> 
> This one test change alone, makes me see that it might be incorrect to set 
> the default Indent to false when AfterExternBlock is true.  (parseBlock 
> default parameter for AddLevel is true)
> 
> shouldn't the default value of `Style.IndentExternBlock = 
> Style.BraceWrapping.AfterExternBlock`?
> 
> (which is 100% why I don't like seeing tests changed).. this was buried in 
> your last changes to the tests and I didn't see it.)
> 
> So now we need to go back and take a look through the clang sources and see 
> what its doing by default, and tests what other default styles are doing 
> prior to this change and if they indent then I think by default we need to 
> indent.
> 
> If we run clang-format on the following code, we see an issues
> 
> https://github.com/llvm/llvm-project/blob/a974b33a10745b528c34f0accbd230b0a4e1fb87/clang/test/SemaCXX/linkage-spec.cpp
> 
> Whats great about this Fix (which is why it needs to go in) this test file 
> despite being part of LLVM its not actually formatted with the LLVM style ;-) 
> i.e. it will come out as
> 
> ```
> extern "C" {
> extern "C" void f(int);
> }
> 
> extern "C++" {
> extern "C++" int (int);
> float ();
> }
> ```
> 
> instead of 
> 
> ```
> extern "C" {
>   extern "C" void f(int);
> }
> 
> extern "C++" {
>   extern "C++" int& g(int);
>   float& g();
> }
> ```
> 
> Thats because they don't want a break after the "C" and before the { but they 
> do what the indent.
> 
> Conversely there is code in
> 
> https://github.com/llvm/llvm-project/blob/a974b33a10745b528c34f0accbd230b0a4e1fb87/llvm/utils/benchmark/test/donotoptimize_assembly_test.cc
> 
> This code IS more formatted than the the previous one (not 100% correct but 
> close enough) and so having the default to true would cause unnecessary churn 
> here.
> 
> Then of course there must be other projects that use BreakAfterExtern=true 
> and they would get the indentation and want to keep it, so the setting of the 
> default value of IndentExternBlock  needs to be dynamic if possible, don't 
> you think.
> 
> To be honest your change should support actually allowing this some of these 
> files to now support keeping its format correclty, which in my view is great! 
> but breaking the default styles is always hard, because we get complaints 
> that different versions of clang-format can cause huge waves of changes and 
> I've seen unless teams are all on the same version then the format can 
> flipflop between versions.
> 
> 
> 
Yes, this test is defaulting to IndentExternBlock = false, because when I was 
initially looking at examples of C code for Google's style, Micorosft, WebKit, 
LLVM, etc (all the built in styles) it appeared that LLVM does not indent their 
extern blocks.

As for linkage-spec.cpp, that file indents extern blocks, and 
donotoptimize_assembly_test.cc doesn't as you pointed out.

As for why I chose to default LLVM to indenting, I don't remember which files 
specifically gave me the impression that LLVM indents.



As for changing the default behavior, I agree It sucks, but I'm not sure how we 
could have this feature without changing the behavior.

Maybe I should just remove the default for LLVM, or maybe I shouldn't default 
to anything for any style period?



Comment at: clang/unittests/Format/FormatTest.cpp:2505
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int foo();\n}", Style);
+

MyDeveloperDay wrote:
> nit: these are a little easier to read when formatted as above
> 
> ```
> verifyFormat("extern \"C\" {\n"
>   "  int foo();\n"
>   "}", Style);
> ```
Yeah, it really tripped me up reading these string literals when they were cut 
up into multiple pieces but without commas between them, so that's why I wrote 
these this way.

I'm not against breaking them up, it was just initially confusing to me.


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

https://reviews.llvm.org/D75791



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


[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2020-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 252715.
arsenm added a comment.
Herald added a subscriber: hiraditya.

Handle wave64 library


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.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
@@ -99,9 +99,9 @@
   {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
+  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
 };
 
 const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef Table) {
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -151,7 +151,10 @@
 
   // Common features.
   FEATURE_FAST_FMA_F32 = 1 << 4,
-  FEATURE_FAST_DENORMAL_F32 = 1 << 5
+  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
+
+  // Wavefront 32 is available.
+  FEATURE_WAVE32 = 1 << 6
 };
 
 StringRef getArchNameAMDGCN(GPUKind AK);
Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,162 @@
+// REQUIRES: clang-driver
+// REQUIRES: amdgpu-registered-target
+
+// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+
+// RUN: 

[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2020-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 252708.
arsenm added a comment.

Cleanup a bit. This should eventually merge with the HIP library handling when 
it switches to using clang cc1 instead of llc


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl

Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,121 @@
+// REQUIRES: clang-driver
+// REQUIRES: amdgpu-registered-target
+
+// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s
+
+
+
+// Make sure the different denormal default is respected for gfx8
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// Make sure the non-canonical name works
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=fiji \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-finite-math-only \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa\
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl 

[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-03-25 Thread Nathan Lanza via Phabricator via cfe-commits
lanza updated this revision to Diff 252706.
lanza added a comment.

Rename and address some issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/ObjCRuntime.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/CodeGenObjC/non-runtime-protocol.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -114,6 +114,7 @@
 // CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface, SubjectMatchRule_objc_implementation)
+// CHECK-NEXT: ObjCNonRuntimeProtocol (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCPreciseLifetime (SubjectMatchRule_variable)
 // CHECK-NEXT: ObjCRequiresPropertyDefs (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCRequiresSuper (SubjectMatchRule_objc_method)
Index: clang/test/CodeGenObjC/non-runtime-protocol.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/non-runtime-protocol.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -o - \
+// RUN: | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DPROTOEXPR -o - 2>&1 \
+// RUN: | FileCheck -check-prefix=PROTOEXPR %s
+
+__attribute__((objc_root_class))
+@interface Root
+@end
+@implementation Root
+@end
+
+// Confirm that we're not emitting protocol information for the
+// CHECK-NOT: OBJC_CLASS_NAME{{.*}}NonRuntimeProtocol
+// CHECK-NOT: _OBJC_$_PROTOCOL_INSTANCE_METHODS_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_$_PROTOCOL_CLASS_METHODS_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_PROTOCOL_$_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_LABEL_PROTOCOL_$_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_CLASS_PROTOCOLS_$_NonRuntimeImplementer
+// CHECK-NOT: @llvm.compiler.used {{.*}}NonRuntimeProtocol
+__attribute__((objc_non_runtime_protocol))
+@protocol NonRuntimeProtocol
+- (void)doThing;
++ (void)doClassThing;
+@end
+// CHECK: @"_OBJC_METACLASS_RO_$_NonRuntimeImplementer" {{.*}} %struct._objc_protocol_list* null
+// CHECK: @"_OBJC_CLASS_RO_$_NonRuntimeImplementer" {{.*}} %struct._objc_protocol_list* null
+@interface NonRuntimeImplementer : Root 
+- (void)doThing;
++ (void)doClassThing;
+@end
+
+@implementation NonRuntimeImplementer
+- (void)doThing {}
++ (void)doClassThing {}
+@end
+
+void useNonRuntime(NonRuntimeImplementer *si) {
+  [si doThing];
+  [NonRuntimeImplementer doClassThing];
+
+#ifdef PROTOEXPR
+// PROTOEXPR: can't use a protocol declared 'objc_non_runtime_protocol' in a @protocol expression
+  Protocol* p = @protocol(NonRuntimeProtocol);
+#endif
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -1280,6 +1280,9 @@
 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
 return true;
   }
+  if (PDecl->isNonRuntimeProtocol())
+Diag(ProtoLoc, diag::err_objc_non_runtime_protocol_in_protocol_expr)
+<< PDecl;
   if (!PDecl->hasDefinition()) {
 Diag(ProtoLoc, diag::err_atprotocol_protocol) << PDecl;
 Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2603,6 +2603,15 @@
 D->addAttr(newAttr);
 }
 
+static void handleObjCNonRuntimeProtocolAttr(Sema , Decl *D,
+ const ParsedAttr ) {
+  if (S.getLangOpts().ObjCRuntime.allowsNonRuntimeProtocols()) {
+handleSimpleAttribute(S, D, AL);
+  } else {
+S.Diag(AL.getLoc(), diag::warn_objc_non_runtime_protocol_ignored) << AL;
+  }
+}
+
 static void handleObjCDirectAttr(Sema , Decl *D, const ParsedAttr ) {
   // objc_direct cannot be set on methods declared in the context of a protocol
   if (isa(D->getDeclContext())) {
@@ -7146,6 +7155,9 @@
   case ParsedAttr::AT_ObjCDirect:
 handleObjCDirectAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ObjCNonRuntimeProtocol:
+handleObjCNonRuntimeProtocolAttr(S, D, AL);
+break;
   case 

[PATCH] D76812: [X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI) [3/3]

2020-03-25 Thread Scott Constable via Phabricator via cfe-commits
sconstab created this revision.
sconstab added reviewers: craig.topper, andrew.w.kaylor, zbrid, chandlerc.
Herald added subscribers: jfb, hiraditya.
sconstab added a parent revision: D76811: [X86] Refactor X86IndirectThunks.cpp 
to Accomodate Mitigations other than Retpoline [2/3].
sconstab retitled this revision from "Add Indirect Thunk Support to X86 to 
mitigate Load Value Injection (LVI) [3/3]" to "[X86] Add Indirect Thunk Support 
to X86 to mitigate Load Value Injection (LVI) [3/3]".

This pass replaces each indirect call/jump with a direct call to a thunk that 
looks like:

  lfence
  jmpq *%r11

This ensures that if the value in register `%r11` was loaded from memory, then
the value in `%r11` is (architecturally) correct prior to the jump.
Also adds a new target feature to X86: +lvi-cfi
("cfi" meaning control-flow integrity)
The feature can be added via clang CLI using `-mlvi-cfi`.

This is an alternate implementation to https://reviews.llvm.org/D75934 That 
merges the thunk insertion functionality with the existing X86 retpoline code.


https://reviews.llvm.org/D76812

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86IndirectThunks.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
@@ -0,0 +1,281 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -mattr=+lvi-cfi < %s | FileCheck %s --check-prefix=X64
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -mattr=+lvi-cfi -O0 < %s | FileCheck %s --check-prefix=X64FAST
+;
+; Note that a lot of this code was lifted from retpoline.ll.
+
+declare void @bar(i32)
+
+; Test a simple indirect call and tail call.
+define void @icall_reg(void (i32)* %fp, i32 %x) {
+entry:
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_reg:
+; X64-DAG:   movq %rdi, %[[fp:[^ ]*]]
+; X64-DAG:   movl %esi, %[[x:[^ ]*]]
+; X64:   movl %esi, %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64:   movl %[[x]], %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_reg:
+; X64FAST:   callq bar
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   callq bar
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+@global_fp = external global void (i32)*
+
+; Test an indirect call through a global variable.
+define void @icall_global_fp(i32 %x, void (i32)** %fpp) #0 {
+  %fp1 = load void (i32)*, void (i32)** @global_fp
+  call void %fp1(i32 %x)
+  %fp2 = load void (i32)*, void (i32)** @global_fp
+  tail call void %fp2(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_global_fp:
+; X64-DAG:   movl %edi, %[[x:[^ ]*]]
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_global_fp:
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+%struct.Foo = type { void (%struct.Foo*)** }
+
+; Test an indirect call through a vtable.
+define void @vcall(%struct.Foo* %obj) #0 {
+  %vptr_field = getelementptr %struct.Foo, %struct.Foo* %obj, i32 0, i32 0
+  %vptr = load void (%struct.Foo*)**, void (%struct.Foo*)*** %vptr_field
+  %vslot = getelementptr void(%struct.Foo*)*, void(%struct.Foo*)** %vptr, i32 1
+  %fp = load void(%struct.Foo*)*, void(%struct.Foo*)** %vslot
+  tail call void %fp(%struct.Foo* %obj)
+  tail call void %fp(%struct.Foo* %obj)
+  ret void
+}
+
+; X64-LABEL: vcall:
+; X64:   movq %rdi, %[[obj:[^ ]*]]
+; X64:   movq (%rdi), %[[vptr:[^ ]*]]
+; X64:   movq 8(%[[vptr]]), %[[fp:[^ ]*]]
+; X64:   movq %[[fp]], %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64-DAG:   movq %[[obj]], %rdi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: vcall:
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+declare void @direct_callee()
+
+define void @direct_tail() #0 {
+  tail call void @direct_callee()
+  ret void
+}
+
+; X64-LABEL: direct_tail:
+; X64:   jmp direct_callee # TAILCALL
+; X64FAST-LABEL: direct_tail:
+; X64FAST:   jmp direct_callee # TAILCALL
+
+
+declare void @nonlazybind_callee() #1
+
+define void @nonlazybind_caller() #0 {
+  call void 

[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-03-25 Thread Nathan Lanza via Phabricator via cfe-commits
lanza updated this revision to Diff 252707.
lanza added a comment.

Reword commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/ObjCRuntime.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/CodeGenObjC/non-runtime-protocol.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -114,6 +114,7 @@
 // CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface, SubjectMatchRule_objc_implementation)
+// CHECK-NEXT: ObjCNonRuntimeProtocol (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCPreciseLifetime (SubjectMatchRule_variable)
 // CHECK-NEXT: ObjCRequiresPropertyDefs (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCRequiresSuper (SubjectMatchRule_objc_method)
Index: clang/test/CodeGenObjC/non-runtime-protocol.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/non-runtime-protocol.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -o - \
+// RUN: | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DPROTOEXPR -o - 2>&1 \
+// RUN: | FileCheck -check-prefix=PROTOEXPR %s
+
+__attribute__((objc_root_class))
+@interface Root
+@end
+@implementation Root
+@end
+
+// Confirm that we're not emitting protocol information for the
+// CHECK-NOT: OBJC_CLASS_NAME{{.*}}NonRuntimeProtocol
+// CHECK-NOT: _OBJC_$_PROTOCOL_INSTANCE_METHODS_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_$_PROTOCOL_CLASS_METHODS_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_PROTOCOL_$_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_LABEL_PROTOCOL_$_NonRuntimeProtocol
+// CHECK-NOT: _OBJC_CLASS_PROTOCOLS_$_NonRuntimeImplementer
+// CHECK-NOT: @llvm.compiler.used {{.*}}NonRuntimeProtocol
+__attribute__((objc_non_runtime_protocol))
+@protocol NonRuntimeProtocol
+- (void)doThing;
++ (void)doClassThing;
+@end
+// CHECK: @"_OBJC_METACLASS_RO_$_NonRuntimeImplementer" {{.*}} %struct._objc_protocol_list* null
+// CHECK: @"_OBJC_CLASS_RO_$_NonRuntimeImplementer" {{.*}} %struct._objc_protocol_list* null
+@interface NonRuntimeImplementer : Root 
+- (void)doThing;
++ (void)doClassThing;
+@end
+
+@implementation NonRuntimeImplementer
+- (void)doThing {}
++ (void)doClassThing {}
+@end
+
+void useNonRuntime(NonRuntimeImplementer *si) {
+  [si doThing];
+  [NonRuntimeImplementer doClassThing];
+
+#ifdef PROTOEXPR
+// PROTOEXPR: can't use a protocol declared 'objc_non_runtime_protocol' in a @protocol expression
+  Protocol* p = @protocol(NonRuntimeProtocol);
+#endif
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -1280,6 +1280,9 @@
 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
 return true;
   }
+  if (PDecl->isNonRuntimeProtocol())
+Diag(ProtoLoc, diag::err_objc_non_runtime_protocol_in_protocol_expr)
+<< PDecl;
   if (!PDecl->hasDefinition()) {
 Diag(ProtoLoc, diag::err_atprotocol_protocol) << PDecl;
 Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2603,6 +2603,15 @@
 D->addAttr(newAttr);
 }
 
+static void handleObjCNonRuntimeProtocolAttr(Sema , Decl *D,
+ const ParsedAttr ) {
+  if (S.getLangOpts().ObjCRuntime.allowsNonRuntimeProtocols()) {
+handleSimpleAttribute(S, D, AL);
+  } else {
+S.Diag(AL.getLoc(), diag::warn_objc_non_runtime_protocol_ignored) << AL;
+  }
+}
+
 static void handleObjCDirectAttr(Sema , Decl *D, const ParsedAttr ) {
   // objc_direct cannot be set on methods declared in the context of a protocol
   if (isa(D->getDeclContext())) {
@@ -7146,6 +7155,9 @@
   case ParsedAttr::AT_ObjCDirect:
 handleObjCDirectAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ObjCNonRuntimeProtocol:
+handleObjCNonRuntimeProtocolAttr(S, D, AL);
+break;
   case 

[clang-tools-extra] c2d7a1f - [clangd] Add test for FindTarget+RecoveryExpr (which already works). NFC

2020-03-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-26T00:40:29+01:00
New Revision: c2d7a1f79cedfc9fcb518596aa839da4de0adb69

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

LOG: [clangd] Add test for FindTarget+RecoveryExpr (which already works). NFC

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index c38ccc3f9441..cd6f2039c888 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -132,6 +132,16 @@ TEST_F(TargetDeclTest, Exprs) {
   EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
+TEST_F(TargetDeclTest, Recovery) {
+  Code = R"cpp(
+// error-ok: testing behavior on broken code
+int f();
+int f(int, int);
+int x = [[f]](42);
+  )cpp";
+  EXPECT_DECLS("UnresolvedLookupExpr", "int f()", "int f(int, int)");
+}
+
 TEST_F(TargetDeclTest, UsingDecl) {
   Code = R"cpp(
 namespace foo {
@@ -685,6 +695,15 @@ TEST_F(FindExplicitReferencesTest, All) {
 )cpp",
 "0: targets = {x}\n"
 "1: targets = {X::a}\n"},
+   {R"cpp(
+   // error-ok: testing with broken code
+   int bar();
+   int foo() {
+ return $0^bar() + $1^bar(42);
+   }
+   )cpp",
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
// Namespaces and aliases.
{R"cpp(
   namespace ns {}



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-03-25 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This needs to be done behind a flag. It's an explicit design goal that 
compilation behavior using a PCH or precompiled preamble behaves identically to 
compilation not using a PCH / precompiled preamble. The behavior of this patch 
is also non-conforming: we're only allowed to perform function template 
instantiations at their points of instantiation (essentially, at points of use 
+ at the end of the translation unit).

I'd be OK with either a (conforming compilation mode) flag that instructs Clang 
to attempt to perform instantiations at the point of use (assuming the template 
is defined at that point), or with a (non-conforming) flag that instructs Clang 
to perform instantiations at the end of the PCH, as it would when compiling a 
header unit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 252700.
ABataev added a comment.

Rebase + fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/depobj_messages.cpp
  clang/test/OpenMP/parallel_reduction_messages.c
  clang/test/OpenMP/task_ast_print.cpp
  clang/test/OpenMP/task_depend_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -423,6 +423,10 @@
 K = CXCursor_OMPArraySectionExpr;
 break;
 
+  case Stmt::OMPArrayShapingExprClass:
+K = CXCursor_OMPArrayShapingExpr;
+break;
+
   case Stmt::BinaryOperatorClass:
 K = CXCursor_BinaryOperator;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5183,6 +5183,8 @@
 return cxstring::createRef("ArraySubscriptExpr");
   case CXCursor_OMPArraySectionExpr:
 return cxstring::createRef("OMPArraySectionExpr");
+  case CXCursor_OMPArrayShapingExpr:
+return cxstring::createRef("OMPArrayShapingExpr");
   case CXCursor_BinaryOperator:
 return cxstring::createRef("BinaryOperator");
   case CXCursor_CompoundAssignOperator:
Index: clang/test/OpenMP/task_depend_messages.cpp
===
--- clang/test/OpenMP/task_depend_messages.cpp
+++ clang/test/OpenMP/task_depend_messages.cpp
@@ -35,14 +35,14 @@
   #pragma omp task depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}} omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected 'in', 'out', 'inout', 'mutexinoutset' or 'depobj' in OpenMP clause 'depend'}}
   #pragma omp task depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   #pragma omp task depend (out: ) // expected-error {{expected expression}}
-  #pragma omp task depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected addressable lvalue expression, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  #pragma omp task depend (inout : foobool(argc)), depend (in, argc) // omp50-error {{expected addressable lvalue expression, array element, array section or array shaping expression}} omp45-error {{expected addressable lvalue expression, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
   #pragma omp task depend (out :S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp task depend(in : argv[1][1] = '2')
-  #pragma omp task depend (in : vec[1]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  #pragma omp task depend (in : vec[1]) // omp50-error {{expected addressable lvalue expression, array element, array section or array shaping expression}} omp45-error {{expected addressable lvalue expression, array element or array section}}
   #pragma omp task depend (in : argv[0])
   #pragma omp task depend (in : ) // expected-error {{expected expression}}
   #pragma omp task depend (in : main)
-  #pragma omp task depend(in : a[0]) // expected-error{{expected addressable lvalue expression, array element or array section}}
+  #pragma omp task depend(in : a[0]) // omp50-error 

[clang-tools-extra] 43c6334 - [clangd] Work around gcc bug after 8f237f9b0

2020-03-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-26T00:06:54+01:00
New Revision: 43c63349f55d89e335108692aa0970a4602f4385

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

LOG: [clangd] Work around gcc bug after 8f237f9b0

Added: 


Modified: 
clang-tools-extra/clangd/SemanticSelection.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticSelection.cpp 
b/clang-tools-extra/clangd/SemanticSelection.cpp
index 7477cb6a737a..a6b1ebfb8327 100644
--- a/clang-tools-extra/clangd/SemanticSelection.cpp
+++ b/clang-tools-extra/clangd/SemanticSelection.cpp
@@ -64,7 +64,7 @@ llvm::Expected getSemanticRanges(ParsedAST 
, Position Pos) {
 // Return an empty range at the point.
 SelectionRange Empty;
 Empty.range.start = Empty.range.end = Pos;
-return Empty;
+return std::move(Empty);
   }
 
   // Convert to the LSP linked-list representation.
@@ -78,7 +78,7 @@ llvm::Expected getSemanticRanges(ParsedAST 
, Position Pos) {
 Tail->range = std::move(Range);
   }
 
-  return Head;
+  return std::move(Head);
 }
 
 } // namespace clangd



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


[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 252690.
sammccall added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -358,15 +358,15 @@
   )cpp",
 
   R"cpp(// Forward class declaration
-class Foo;
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 F^oo* foo();
   )cpp",
 
   R"cpp(// Function declaration
-void foo();
+void $decl[[foo]]();
 void g() { f^oo(); }
-void [[foo]]() {}
+void $def[[foo]]() {}
   )cpp",
 
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -226,23 +226,21 @@
   llvm::DenseMap ResultIndex;
 
   auto AddResultDecl = [&](const NamedDecl *D) {
-const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
-
-auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
-MainFilePath);
+D = llvm::cast(D->getCanonicalDecl());
+auto Loc =
+makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath);
 if (!Loc)
   return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *Preferred);
+Result.back().Name = printName(AST.getASTContext(), *D);
 Result.back().PreferredDeclaration = *Loc;
-// Preferred is always a definition if possible, so this check works.
-if (Def == Preferred)
-  Result.back().Definition = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Result.back().Definition = makeLocation(
+  AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
 
 // Record SymbolID for index lookup later.
-if (auto ID = getSymbolID(Preferred))
+if (auto ID = getSymbolID(D))
   ResultIndex[*ID] = Result.size() - 1;
   };
 


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -358,15 +358,15 @@
   )cpp",
 
   R"cpp(// Forward class declaration
-class Foo;
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 F^oo* foo();
   )cpp",
 
   R"cpp(// Function declaration
-void foo();
+void $decl[[foo]]();
 void g() { f^oo(); }
-void [[foo]]() {}
+void $def[[foo]]() {}
   )cpp",
 
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -226,23 +226,21 @@
   llvm::DenseMap ResultIndex;
 
   auto AddResultDecl = [&](const NamedDecl *D) {
-const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
-
-auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
-MainFilePath);
+D = llvm::cast(D->getCanonicalDecl());
+auto Loc =
+makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath);
 if (!Loc)
   return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *Preferred);
+Result.back().Name = printName(AST.getASTContext(), *D);
 Result.back().PreferredDeclaration = *Loc;
-// Preferred is always a definition if possible, so this check works.
-if (Def == Preferred)
-  Result.back().Definition = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Result.back().Definition = makeLocation(
+  AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
 
 // Record SymbolID for index lookup later.
-if (auto ID = getSymbolID(Preferred))
+if (auto ID = getSymbolID(D))
   ResultIndex[*ID] = Result.size() - 1;
   };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2020-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 252692.
arsenm added a comment.

Use -nogpulib instead of -nodefaultlibs


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl

Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,121 @@
+// REQUIRES: clang-driver
+// REQUIRES: amdgpu-registered-target
+
+// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s
+
+
+
+// Make sure the different denormal default is respected for gfx8
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// Make sure the non-canonical name works
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=fiji \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-finite-math-only \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa\
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure 

[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-25 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 252688.
tmsriram marked 4 inline comments as done.
tmsriram added a comment.

Changes to description of flag, remove redundant check.


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

https://reviews.llvm.org/D73307

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp
  clang/test/Driver/funique-internal-linkage-names.c

Index: clang/test/Driver/funique-internal-linkage-names.c
===
--- /dev/null
+++ clang/test/Driver/funique-internal-linkage-names.c
@@ -0,0 +1,4 @@
+// RUN: %clang -### -funique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -funique-internal-linkage-names -fno-unique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-funique-internal-linkage-names"
+// CHECK-NOOPT-NOT: "-funique-internal-linkage-names"
Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- /dev/null
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -0,0 +1,46 @@
+// This test checks if internal linkage symbols get unique names with
+// -funique-internal-linkage-names option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+static int glob;
+static int foo() {
+  return 0;
+}
+
+int (*bar())() {
+  return foo;
+}
+
+int getGlob() {
+  return glob;
+}
+
+// Multiversioning symbols
+__attribute__((target("default"))) static int mver() {
+  return 0;
+}
+
+__attribute__((target("sse4.2"))) static int mver() {
+  return 1;
+}
+
+int mver_call() {
+  return mver();
+}
+
+// PLAIN: @_ZL4glob = internal global
+// PLAIN: @_ZL3foov()
+// PLAIN: @_ZL4mverv.resolver()
+// PLAIN: @_ZL4mverv()
+// PLAIN: @_ZL4mverv.sse4.2()
+// UNIQUE-NOT: @_ZL4glob = internal global
+// UNIQUE-NOT: @_ZL3foov()
+// UNIQUE-NOT: @_ZL4mverv.resolver()
+// UNIQUE-NOT: @_ZL4mverv()
+// UNIQUE-NOT: @_ZL4mverv.sse4.2()
+// UNIQUE: @_ZL4glob.{{[0-9a-f]+}} = internal global
+// UNIQUE: @_ZL3foov.{{[0-9a-f]+}}()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.resolver()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.sse4.2()
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -958,6 +958,8 @@
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);
 
+  Opts.UniqueInternalLinkageNames =
+  Args.hasArg(OPT_funique_internal_linkage_names);
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1677,6 +1677,24 @@
on ELF targets when using the integrated assembler. This flag currently
only has an effect on ELF targets.
 
+**-f[no]-unique-internal-linkage-names**
+
+   Controls whether Clang emits a unique (best-effort) symbol name for internal
+   linkage symbols. The unique name is obtained by appending the hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple
+   functions with the same private linkage name exist in the binary.
+
+   It should be noted that this option cannot guarantee uniqueness and the
+   following is an example where it is not unique when two modules contain
+   symbols with the same private linkage name:
+
+   .. code-block:: console
+
+ $ cd $P/foo && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
+
 Profile Guided Optimization
 ---
 
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -307,6 +307,7 @@
   const TargetInfo 
   std::unique_ptr ABI;
   llvm::LLVMContext 
+  std::string ModuleNameHash = "";
 
   std::unique_ptr TBAA;
 
@@ -578,6 +579,8 @@
   /// Return true iff an Objective-C runtime has been configured.
   bool hasObjCRuntime() { return 

[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:257
 const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
+if (const NamedDecl *C = llvm::dyn_cast(D->getCanonicalDecl()))
+  D = C;

kadircet wrote:
> Is it possible for this check to ever fail? I think it is safe to just 
> perform a `llvm::cast` instead of `dyn_cast`.
> also why not perform this before getting definition?
Done. (I thought there was such a case, but I was thinking about D vs OrigD in 
IndexDataConusmer, and this happens in one of the rare cases where D isn't the 
canonical decl of OrigD)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369



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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-03-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D76342#1941591 , @JonChesterfield 
wrote:

> edit: actually you've already done the clang-format on trunk as I hoped, 
> phabricator mislead me. Apologies for the noise


The previous diff was against a branch with only the whitespace changes to get 
rid of the noise in the diff. It seems that the pre-merge check instead 
compared formatting to the master (probably Arcanist/Phabricator looked for the 
common ancestor of origin/master and my git branch). This let to weird 
formatting warnings that weren't even changes highlighted in this diff. They 
are gone now with clang-formatted origin/master. Fotunately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342



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


[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 252689.
sammccall marked 3 inline comments as done.
sammccall added a comment.

address comments, rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -358,15 +358,15 @@
   )cpp",
 
   R"cpp(// Forward class declaration
-class Foo;
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 F^oo* foo();
   )cpp",
 
   R"cpp(// Function declaration
-void foo();
+void $decl[[foo]]();
 void g() { f^oo(); }
-void [[foo]]() {}
+void $def[[foo]]() {}
   )cpp",
 
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -226,23 +226,21 @@
   llvm::DenseMap ResultIndex;
 
   auto AddResultDecl = [&](const NamedDecl *D) {
-const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
-
-auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
+D = llvm::cast(D->getCanonicalDecl());
+auto Loc = makeLocation(AST.getASTContext(), nameLocation(*D, SM),
 MainFilePath);
 if (!Loc)
   return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *Preferred);
+Result.back().Name = printName(AST.getASTContext(), *D);
 Result.back().PreferredDeclaration = *Loc;
-// Preferred is always a definition if possible, so this check works.
-if (Def == Preferred)
-  Result.back().Definition = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Result.back().Definition = makeLocation(
+  AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
 
 // Record SymbolID for index lookup later.
-if (auto ID = getSymbolID(Preferred))
+if (auto ID = getSymbolID(D))
   ResultIndex[*ID] = Result.size() - 1;
   };
 


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -358,15 +358,15 @@
   )cpp",
 
   R"cpp(// Forward class declaration
-class Foo;
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 F^oo* foo();
   )cpp",
 
   R"cpp(// Function declaration
-void foo();
+void $decl[[foo]]();
 void g() { f^oo(); }
-void [[foo]]() {}
+void $def[[foo]]() {}
   )cpp",
 
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -226,23 +226,21 @@
   llvm::DenseMap ResultIndex;
 
   auto AddResultDecl = [&](const NamedDecl *D) {
-const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
-
-auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
+D = llvm::cast(D->getCanonicalDecl());
+auto Loc = makeLocation(AST.getASTContext(), nameLocation(*D, SM),
 MainFilePath);
 if (!Loc)
   return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *Preferred);
+Result.back().Name = printName(AST.getASTContext(), *D);
 Result.back().PreferredDeclaration = *Loc;
-// Preferred is always a definition if possible, so this check works.
-if (Def == Preferred)
-  Result.back().Definition = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Result.back().Definition = makeLocation(
+  AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
 
 // Record SymbolID for index lookup later.
-if (auto ID = getSymbolID(Preferred))
+if (auto ID = getSymbolID(D))
   ResultIndex[*ID] = Result.size() - 1;
   };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-25 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 3 inline comments as done.
aganea added a subscriber: respindola.
aganea added a comment.

In D75153#1906580 , @MaskRay wrote:

> Does `taskset -c 0-3 lld -flavor ...` restrict the number of cores?
>
>   cpu_set_t cpu;
>   sched_getaffinity(0, sizeof(cpu), );
>   CPU_COUNT()


Thanks for raising this! This does not seem to work (I currently only have WSL 
at hand, no real Linux machine). I don't think it worked before my patch. The 
current code in LLVM is written such as: (//note the "if" statement//)

  #if defined(HAVE_SCHED_GETAFFINITY) && defined(HAVE_CPU_COUNT)
cpu_set_t Set;
if (sched_getaffinity(0, sizeof(Set), ))
  return CPU_COUNT();
  #endif

The doc  for `sched_getaffinity` 
says:

> On success, sched_setaffinity() and sched_getaffinity() return 0. On error, 
> -1 is returned, and errno is set appropriately.

So it would always fall back to `std::thread::hardware_concurrency`, which 
apparently does not always take affinity into account, according to @respindola 
(please see rG8c0ff9508da5f02e8ce6580a126a2018c9bf702a 
).

I'll write a follow-up patch to test affinity on Linux and Windows.




Comment at: llvm/include/llvm/Support/Threading.h:201
+  /// hardware core is used.
+  inline ThreadPoolStrategy heavyweight_hardware_concurrency(StringRef Num) {
+Optional S =

abrachet wrote:
> Nit: Remove `inline` 
> https://llvm.org/docs/CodingStandards.html#don-t-use-inline-when-defining-a-function-in-a-class-definition
After discussing offling with @abrachet , I'll leave the `inline` for now. It 
makes the symbol weak, removing `inline` would otherwise fail linking. I can 
move the function(s) to the .CPP after this patch to save on link time.


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

https://reviews.llvm.org/D75153



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-25 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252685.
oontvoo added a comment.

Handle the case where the file is first seen


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1619,7 +1619,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch ) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch ) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,8 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HeaderFileInfo *HFI = HS.getExistingFileInfo(File, /*WantExternal*/ !Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1799,8 +1801,13 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+*HFI,
+HS.getModuleMap().findAllModulesForHeader(File),
+{},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2641,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo *HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+case SUBMODULE_IMPORTED_HEADERS:
+  for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+PendingImportedHeaders[].push_back(Record[Idx]);
+  }
+  break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch  = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+ 

[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@kadircet I realized this change was gathering dust, and you've touched 
SemaCodeComplete in recent memory... any interest?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73649



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


[PATCH] D76663: [clangd] Support new semanticTokens request from LSP 3.16.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

For some context here, I was doing some digging as Heyward Fann is looking at 
hooking up our existing syntax highlighting to coc.nvim, and he and Jack Guo 
(of jackguo380/vim-lsp-cxx-highlight) were asking about the protocol.

The new LSP protocol looks really solid, including better incremental highlight 
support than the Theia proposal, though this patch doesn't implement 
incremental yet. (In particular, no sending thousands of re-highlights when 
inserting a new line). It's also request-response rather than 
notification-based, which is easier to implement on the server side. Also the 
VSCode client-side of our highlighting feels like significant technical debt we 
could be rid of.

So I think we should try to support the new LSP and drop the older Theia one 
ASAP (clangd 12?), even if semantic highlighting isn't a really high priority 
for us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76663



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


[PATCH] D76795: [HIP] Change default --gpu-max-threads-per-block value to 1024

2020-03-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

Thanks.  This looks fine to me.


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

https://reviews.llvm.org/D76795



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


[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 252671.
sammccall added a comment.

update/move comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/TypePrinter.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
  clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
  clang/test/Misc/diag-aka-types.cpp
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/OpenMP/distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/distribute_simd_private_messages.cpp
  clang/test/OpenMP/for_private_messages.cpp
  clang/test/OpenMP/for_simd_private_messages.cpp
  clang/test/OpenMP/master_taskloop_private_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/parallel_for_private_messages.cpp
  clang/test/OpenMP/parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/parallel_master_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/parallel_sections_private_messages.cpp
  clang/test/OpenMP/sections_private_messages.cpp
  clang/test/OpenMP/simd_private_messages.cpp
  clang/test/OpenMP/single_private_messages.cpp
  clang/test/OpenMP/target_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/target_private_messages.cpp
  clang/test/OpenMP/target_simd_private_messages.cpp
  clang/test/OpenMP/taskloop_private_messages.cpp
  clang/test/OpenMP/taskloop_simd_private_messages.cpp
  clang/test/SemaTemplate/instantiate-member-expr.cpp
  clang/unittests/AST/DeclPrinterTest.cpp

Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -1158,8 +1158,8 @@
 "template struct X {};"
 "Z> A;",
 "A",
-"Z > A"));
-// Should be: with semicolon, without extra space in "> >"
+"Z> A"));
+// Should be: with semicolon
 }
 
 TEST(DeclPrinter, TestTemplateArgumentList5) {
Index: clang/test/SemaTemplate/instantiate-member-expr.cpp
===
--- clang/test/SemaTemplate/instantiate-member-expr.cpp
+++ clang/test/SemaTemplate/instantiate-member-expr.cpp
@@ -16,7 +16,7 @@
 
  template 
  void registerCheck(CHECKER *check) {
-   Checkers.push_back(S()); // expected-note {{in instantiation of member function 'vector >::push_back' requested here}}
+   Checkers.push_back(S()); // expected-note {{in instantiation of member function 'vector>::push_back' requested here}}
  }
 };
 
Index: clang/test/OpenMP/taskloop_simd_private_messages.cpp
===
--- clang/test/OpenMP/taskloop_simd_private_messages.cpp
+++ clang/test/OpenMP/taskloop_simd_private_messages.cpp
@@ -253,7 +253,7 @@
 si = k + 1;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
-  s7 = s7_0; // expected-note {{in instantiation of member function 'S7 >::operator=' requested here}}
+  s7 = s7_0; // expected-note {{in instantiation of member function 'S7>::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
 }
 
Index: clang/test/OpenMP/taskloop_private_messages.cpp
===
--- clang/test/OpenMP/taskloop_private_messages.cpp
+++ clang/test/OpenMP/taskloop_private_messages.cpp
@@ -253,7 +253,7 @@
 si = k + 1;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
-  s7 = s7_0; // expected-note {{in instantiation of member function 'S7 >::operator=' requested here}}
+  s7 = s7_0; // expected-note {{in instantiation of member function 'S7>::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
 }
 
Index: clang/test/OpenMP/target_simd_private_messages.cpp
===
--- clang/test/OpenMP/target_simd_private_messages.cpp
+++ clang/test/OpenMP/target_simd_private_messages.cpp
@@ -237,7 +237,7 @@
 m = k + 2;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
-  s7 = 

[PATCH] D76663: [clangd] Support new semanticTokens request from LSP 3.16.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 252676.
sammccall added a comment.

Update SemanticHighlighting comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76663

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -720,6 +720,41 @@
   ASSERT_EQ(Counter.Count, 1);
 }
 
+TEST(SemanticHighlighting, toSemanticTokens) {
+  auto CreatePosition = [](int Line, int Character) -> Position {
+Position Pos;
+Pos.line = Line;
+Pos.character = Character;
+return Pos;
+  };
+
+  std::vector Tokens = {
+  {HighlightingKind::Variable,
+   Range{CreatePosition(1, 1), CreatePosition(1, 5)}},
+  {HighlightingKind::Function,
+   Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
+  {HighlightingKind::Variable,
+   Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
+  };
+
+  std::vector Results = toSemanticTokens(Tokens);
+  EXPECT_EQ(Tokens.size(), Results.size());
+  EXPECT_EQ(Results[0].tokenType, unsigned(HighlightingKind::Variable));
+  EXPECT_EQ(Results[0].deltaLine, 1u);
+  EXPECT_EQ(Results[0].deltaStart, 1u);
+  EXPECT_EQ(Results[0].length, 4u);
+
+  EXPECT_EQ(Results[1].tokenType, unsigned(HighlightingKind::Function));
+  EXPECT_EQ(Results[1].deltaLine, 2u);
+  EXPECT_EQ(Results[1].deltaStart, 4u);
+  EXPECT_EQ(Results[1].length, 3u);
+
+  EXPECT_EQ(Results[2].tokenType, unsigned(HighlightingKind::Variable));
+  EXPECT_EQ(Results[2].deltaLine, 0u);
+  EXPECT_EQ(Results[2].deltaStart, 4u);
+  EXPECT_EQ(Results[2].length, 4u);
+}
+
 TEST(SemanticHighlighting, toTheiaSemanticHighlightingInformation) {
   auto CreatePosition = [](int Line, int Character) -> Position {
 Position Pos;
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -0,0 +1,22 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","text":"int x = 2;"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
+# CHECK:   "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"data": [
+#  First line, char 5, variable, no modifiers.
+# CHECK-NEXT:  0,
+# CHECK-NEXT:  4,
+# CHECK-NEXT:  1,
+# CHECK-NEXT:  0,
+# CHECK-NEXT:  0
+# CHECK-NEXT:]
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -38,6 +38,15 @@
 # CHECK-NEXT:  "referencesProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "selectionRangeProvider": true,
+# CHECK-NEXT:  "semanticTokensProvider": {
+# CHECK-NEXT:"documentProvider": true,
+# CHECK-NEXT:"legend": {
+# CHECK-NEXT:  "tokenModifiers": [],
+# CHECK-NEXT:  "tokenTypes": [
+# CHECK-NEXT:"variable",
+# CHECK:   ]
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  "(",
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -6,8 +6,21 @@
 //
 //===--===//
 //
-// An implementation of semantic highlighting based on this proposal:
-// https://github.com/microsoft/vscode-languageserver-node/pull/367 in clangd.
+// This file supports semantic highlighting: categorizing tokens in the file so
+// that the editor can color/style them 

[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@kadircet sending this to you as I noticed it as a clangd hover bug :-) The 
highest impact is probably in diagnostic messages though.

AFAICT the state before this patch is:

- the type printer always printed the space
- the stmt printer calls into the type printer to print arg lists
- the decl printer never prints the space

The best, most consistent thing would be to also fix the decl printer to 
respect the setting. But I haven't done that in this patch. At least the 
default configuration (C++14) is now consistent between type/stmt/decl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-03-25 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added inline comments.



Comment at: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:81
 static llvm::Type *getInnermostElementType(llvm::Type *type) {
-  while (isa(type))
-type = type->getSequentialElementType();
-  return type;
+  do {
+if (auto *arrayTy = dyn_cast(type)) {

Readability: This works, but is a little strange. I'd rewrite:

```
static llvm::Type *getInnermostElementType(llvm::Type *type) {
  while (isa(type) || isa(type)) {
if (auto *arrayTy = dyn_cast(type))
  type = arrayTy->getElementType();
else
  type = cast(type)->getElementType();
  }
  return type;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75661



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

> We cannot build an array type since this expression does not represent a 
> supported array type. Sizes may be non-constant anywhere in the operation, 
> variable array type does not support it.

I don't think that's true; the element type of a C99 VAT can still be another 
VAT.  The only restriction is that we don't allow a CAT of VATs — we require 
the outer array to still be represented as a VAT despite have a constant 
immediate bound — but that's just a representational restriction and doesn't 
restrict what we can express.  But it doesn't matter because, as you say, we 
can and should use a placeholder here in order to enforce the use-restriction.




Comment at: clang/lib/Sema/SemaExpr.cpp:4751
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())
+return ExprError(Diag(Base->getExprLoc(),

ABataev wrote:
> ABataev wrote:
> > rjmccall wrote:
> > > I think you should perform DefaultFunctionArrayLvalueConversion here so 
> > > that e.g. arrays will decay to pointers, you load pointers from l-values, 
> > > and so on.  If you do so, it'll handle placeholders for you.
> > > 
> > > Do you really want to allow this to operate on non-C pointer types?
> > 1. Standard clearly states that the type of the base expression must be a 
> > pointer. I don't think that we should perform implicit type casting here, 
> > like decay to pointers, etc.
> > 2. It is just a simple form of checking that this is a pointer type. Since 
> > this expression is not allowed in other languages (and I filter it out at 
> > the parsing stage), I think it is ok to use the generic form of type 
> > checking.
> Forgot to mention, that I thought about possible conversion here. But it may 
> lead to some unpredictable results, like:
> ```
> int a[3];
> ...([3][4][n])a...
> ```
> Better to do not allow this kind of operation, I think.
> Standard clearly states that the type of the base expression must be a 
> pointer. I don't think that we should perform implicit type casting here, 
> like decay to pointers, etc.

The wording of the C/C++ standard is that expressions of array type decay 
except in certain syntactic positions.  Such expressions then *do* have pointer 
type for this purpose.  If precedent is to forbid array references, so be it, 
but that's not consistent with the normal language behavior.

> It is just a simple form of checking that this is a pointer type. Since this 
> expression is not allowed in other languages (and I filter it out at the 
> parsing stage), I think it is ok to use the generic form of type checking.

If your intent is that this only applies only to C pointers, you should just 
check `isPointerType()` instead of `isAnyPointerType()`, which exists for the 
sole purpose of also including Objective-C pointers.



Comment at: clang/lib/Sema/SemaExpr.cpp:4751
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())
+return ExprError(Diag(Base->getExprLoc(),

rjmccall wrote:
> ABataev wrote:
> > ABataev wrote:
> > > rjmccall wrote:
> > > > I think you should perform DefaultFunctionArrayLvalueConversion here so 
> > > > that e.g. arrays will decay to pointers, you load pointers from 
> > > > l-values, and so on.  If you do so, it'll handle placeholders for you.
> > > > 
> > > > Do you really want to allow this to operate on non-C pointer types?
> > > 1. Standard clearly states that the type of the base expression must be a 
> > > pointer. I don't think that we should perform implicit type casting here, 
> > > like decay to pointers, etc.
> > > 2. It is just a simple form of checking that this is a pointer type. 
> > > Since this expression is not allowed in other languages (and I filter it 
> > > out at the parsing stage), I think it is ok to use the generic form of 
> > > type checking.
> > Forgot to mention, that I thought about possible conversion here. But it 
> > may lead to some unpredictable results, like:
> > ```
> > int a[3];
> > ...([3][4][n])a...
> > ```
> > Better to do not allow this kind of operation, I think.
> > Standard clearly states that the type of the base expression must be a 
> > pointer. I don't think that we should perform implicit type casting here, 
> > like decay to pointers, etc.
> 
> The wording of the C/C++ standard is that expressions of array type decay 
> except in certain syntactic positions.  Such expressions then *do* have 
> pointer type for this purpose.  If precedent is to forbid array references, 
> so be it, but that's not consistent with the normal language behavior.
> 
> > It is just a simple form of checking that this is a pointer type. Since 
> > this expression is not allowed in other languages (and I filter it out at 
> > the parsing stage), I think it is ok to use the generic form of type 
> > checking.
> 
> If your intent is that this only 

[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.

It's not 1998 anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76801

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/TypePrinter.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
  clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
  clang/test/Misc/diag-aka-types.cpp
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/OpenMP/distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/distribute_simd_private_messages.cpp
  clang/test/OpenMP/for_private_messages.cpp
  clang/test/OpenMP/for_simd_private_messages.cpp
  clang/test/OpenMP/master_taskloop_private_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/parallel_for_private_messages.cpp
  clang/test/OpenMP/parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/parallel_master_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/parallel_sections_private_messages.cpp
  clang/test/OpenMP/sections_private_messages.cpp
  clang/test/OpenMP/simd_private_messages.cpp
  clang/test/OpenMP/single_private_messages.cpp
  clang/test/OpenMP/target_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/target_private_messages.cpp
  clang/test/OpenMP/target_simd_private_messages.cpp
  clang/test/OpenMP/taskloop_private_messages.cpp
  clang/test/OpenMP/taskloop_simd_private_messages.cpp
  clang/test/SemaTemplate/instantiate-member-expr.cpp
  clang/unittests/AST/DeclPrinterTest.cpp

Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -1158,8 +1158,8 @@
 "template struct X {};"
 "Z> A;",
 "A",
-"Z > A"));
-// Should be: with semicolon, without extra space in "> >"
+"Z> A"));
+// Should be: with semicolon
 }
 
 TEST(DeclPrinter, TestTemplateArgumentList5) {
Index: clang/test/SemaTemplate/instantiate-member-expr.cpp
===
--- clang/test/SemaTemplate/instantiate-member-expr.cpp
+++ clang/test/SemaTemplate/instantiate-member-expr.cpp
@@ -16,7 +16,7 @@
 
  template 
  void registerCheck(CHECKER *check) {
-   Checkers.push_back(S()); // expected-note {{in instantiation of member function 'vector >::push_back' requested here}}
+   Checkers.push_back(S()); // expected-note {{in instantiation of member function 'vector>::push_back' requested here}}
  }
 };
 
Index: clang/test/OpenMP/taskloop_simd_private_messages.cpp
===
--- clang/test/OpenMP/taskloop_simd_private_messages.cpp
+++ clang/test/OpenMP/taskloop_simd_private_messages.cpp
@@ -253,7 +253,7 @@
 si = k + 1;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
-  s7 = s7_0; // expected-note {{in instantiation of member function 'S7 >::operator=' requested here}}
+  s7 = s7_0; // expected-note {{in instantiation of member function 'S7>::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
 }
 
Index: clang/test/OpenMP/taskloop_private_messages.cpp
===
--- clang/test/OpenMP/taskloop_private_messages.cpp
+++ clang/test/OpenMP/taskloop_private_messages.cpp
@@ -253,7 +253,7 @@
 si = k + 1;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
-  s7 = s7_0; // expected-note {{in instantiation of member function 'S7 >::operator=' requested here}}
+  s7 = s7_0; // expected-note {{in instantiation of member function 'S7>::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
 }
 
Index: clang/test/OpenMP/target_simd_private_messages.cpp
===
--- clang/test/OpenMP/target_simd_private_messages.cpp
+++ clang/test/OpenMP/target_simd_private_messages.cpp
@@ -237,7 +237,7 @@
 m = k + 2;
 
   s6 = s6_0; // expected-note {{in instantiation of member function 

[PATCH] D76795: [HIP] Change default --gpu-max-threads-per-block value to 1024

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 252661.
yaxunl added a comment.

change variable names


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

https://reviews.llvm.org/D76795

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/CodeGenCUDA/kernel-amdgcn.cu


Index: clang/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- clang/test/CodeGenCUDA/kernel-amdgcn.cu
+++ clang/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -39,4 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
-// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8119,9 +8119,13 @@
   assert(Max == 0 && "Max must be zero");
   } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to a value specified by
-// --gpu-max-threads-per-block=n or its default value.
+// --gpu-max-threads-per-block=n or its default value for HIP.
+const unsigned OpenCLDefaultMaxWorkGroupSize = 256;
+const unsigned DefaultMaxWorkGroupSize =
+IsOpenCLKernel ? OpenCLDefaultMaxWorkGroupSize
+   : M.getLangOpts().GPUMaxThreadsPerBlock;
 std::string AttrVal =
-std::string("1,") + 
llvm::utostr(M.getLangOpts().GPUMaxThreadsPerBlock);
+std::string("1,") + llvm::utostr(DefaultMaxWorkGroupSize);
 F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
   }
 
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -231,7 +231,7 @@
 LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate 
transcendental functions")
 LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
-LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
+LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for 
kernel launch bounds for HIP")
 
 LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")


Index: clang/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- clang/test/CodeGenCUDA/kernel-amdgcn.cu
+++ clang/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -39,4 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
-// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8119,9 +8119,13 @@
   

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-25 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

@jyknight  Actually, please hold on on the review ... still working on it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951



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


[PATCH] D76795: [HIP] Change default --gpu-max-threads-per-block value to 1024

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8123
+// --gpu-max-threads-per-block=n or its default value for HIP.
+const unsigned OpenCLMaxWorkGroupSize = 256;
+const unsigned MaxWorkGroupSize =

b-sumner wrote:
> I'd like to see the word default, e.g. OpenCLDefaultMaxWorkGroupSize, used 
> more since that is what this is about.  Ideally the option would have been 
> named gpu-default-max-threads-per-block, but I suppose I can see why it was 
> shortened.
changed variable names.


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

https://reviews.llvm.org/D76795



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 4 inline comments as done.
ABataev added a comment.

In D74144#1941971 , @rjmccall wrote:

> Okay, so these array-shaping expressions are only allowed as operands to 
> specific OpenMP directives?  That's a plausible interpretation of "The 
> shape-operator can appear only in clauses where it is explicitly allowed" 
> from the spec .  If it 
> were a more general l-value expression, we could handle that just fine by 
> building the type using `ConstantArrayType`/`VariableArrayType` as 
> appropriate; but if the language intentionally restricts it, the placeholder 
> approach seems fine.


Hi John, thanks for the review!
Yes, this is not a general form of the expression, it is allowed only in a 
couple of clauses.
We cannot build an array type since this expression does not represent a 
supported array type. Sizes may be non-constant anywhere in the operation, 
variable array type does not support it. It requires extending of the variable 
array types but actually it does not worth a try, since this type is not needed 
at all.




Comment at: clang/lib/Sema/SemaExpr.cpp:4748
+   Base->isInstantiationDependent() ||
+   Base->containsUnexpandedParameterPack()))
+return OMPArrayShapingExpr::Create(Context, Context.DependentTy, Base,

rjmccall wrote:
> Just check `isTypeDependent()`, none of these other conditions should 
> interfere with type-checking.
Ok, will do.



Comment at: clang/lib/Sema/SemaExpr.cpp:4751
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())
+return ExprError(Diag(Base->getExprLoc(),

rjmccall wrote:
> I think you should perform DefaultFunctionArrayLvalueConversion here so that 
> e.g. arrays will decay to pointers, you load pointers from l-values, and so 
> on.  If you do so, it'll handle placeholders for you.
> 
> Do you really want to allow this to operate on non-C pointer types?
1. Standard clearly states that the type of the base expression must be a 
pointer. I don't think that we should perform implicit type casting here, like 
decay to pointers, etc.
2. It is just a simple form of checking that this is a pointer type. Since this 
expression is not allowed in other languages (and I filter it out at the 
parsing stage), I think it is ok to use the generic form of type checking.



Comment at: clang/lib/Sema/SemaExpr.cpp:4758
+  for (Expr *Dim : Dims) {
+if (Dim->getType()->isNonOverloadPlaceholderType()) {
+  ExprResult Result = CheckPlaceholderExpr(Dim);

rjmccall wrote:
> I think overload placeholders need to be resolved here, too.  You may have 
> copied this code from some different place that has the ability to resolve 
> overloads later, but in this case that's not true.
No, YouCompleteMe suggested the wrong function and I just missed it. Will fix 
it, thanks!



Comment at: clang/lib/Sema/SemaExpr.cpp:4771
+}
+if (!Dim->isValueDependent() && !Dim->isTypeDependent()) {
+  ExprResult Result =

rjmccall wrote:
> You don't really care about value-dependence here, just type-dependence.  You 
> can check value-dependence before doing the constant-evaluation check below.
Yes, just a double check to be realy-really sure :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

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



Comment at: clang/lib/Sema/SemaExpr.cpp:4751
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())
+return ExprError(Diag(Base->getExprLoc(),

ABataev wrote:
> rjmccall wrote:
> > I think you should perform DefaultFunctionArrayLvalueConversion here so 
> > that e.g. arrays will decay to pointers, you load pointers from l-values, 
> > and so on.  If you do so, it'll handle placeholders for you.
> > 
> > Do you really want to allow this to operate on non-C pointer types?
> 1. Standard clearly states that the type of the base expression must be a 
> pointer. I don't think that we should perform implicit type casting here, 
> like decay to pointers, etc.
> 2. It is just a simple form of checking that this is a pointer type. Since 
> this expression is not allowed in other languages (and I filter it out at the 
> parsing stage), I think it is ok to use the generic form of type checking.
Forgot to mention, that I thought about possible conversion here. But it may 
lead to some unpredictable results, like:
```
int a[3];
...([3][4][n])a...
```
Better to do not allow this kind of operation, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-03-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 252659.
efriedma added a comment.
Herald added subscribers: Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, 
csigg, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, 
mehdi_amini.

Fix bug in GlobalOpt.  Add fixes for MLIR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75661

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/GetElementPtrTypeIterator.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -51,12 +51,16 @@
 return result;
   }
 
-  if (!isa(type)) {
+  llvm::Type *elementType;
+  if (auto *arrayTy = dyn_cast(type)) {
+elementType = arrayTy->getElementType();
+  } else if (auto *vectorTy = dyn_cast(type)) {
+elementType = vectorTy->getElementType();
+  } else {
 emitError(loc) << "expected sequential LLVM types wrapping a scalar";
 return nullptr;
   }
 
-  llvm::Type *elementType = type->getSequentialElementType();
   SmallVector nested;
   nested.reserve(shape.front());
   for (int64_t i = 0; i < shape.front(); ++i) {
@@ -74,9 +78,15 @@
 
 /// Returns the first non-sequential type nested in sequential types.
 static llvm::Type *getInnermostElementType(llvm::Type *type) {
-  while (isa(type))
-type = type->getSequentialElementType();
-  return type;
+  do {
+if (auto *arrayTy = dyn_cast(type)) {
+  type = arrayTy->getElementType();
+} else if (auto *vectorTy = dyn_cast(type)) {
+  type = vectorTy->getElementType();
+} else {
+  return type;
+}
+  } while (1);
 }
 
 /// Create an LLVM IR constant of `llvmType` from the MLIR attribute `attr`.
@@ -102,17 +112,23 @@
 return llvm::ConstantExpr::getBitCast(
 functionMapping.lookup(funcAttr.getValue()), llvmType);
   if (auto splatAttr = attr.dyn_cast()) {
-auto *sequentialType = cast(llvmType);
-auto elementType = sequentialType->getElementType();
-uint64_t numElements = sequentialType->getNumElements();
+llvm::Type *elementType;
+uint64_t numElements;
+if (auto *arrayTy = dyn_cast(llvmType)) {
+  elementType = arrayTy->getElementType();
+  numElements = arrayTy->getNumElements();
+} else {
+  elementType = llvmType->getVectorElementType();
+  numElements = llvmType->getVectorNumElements();
+}
 // Splat value is a scalar. Extract it only if the element type is not
 // another sequence type. The recursion terminates because each step removes
 // one outer sequential type.
+bool elementTypeSequential =
+isa(elementType) || isa(elementType);
 llvm::Constant *child = getLLVMConstant(
 elementType,
-isa(elementType) ? splatAttr
-   : splatAttr.getSplatValue(),
-loc);
+elementTypeSequential ? splatAttr : splatAttr.getSplatValue(), loc);
 if (!child)
   return nullptr;
 if (llvmType->isVectorTy())
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3131,7 +3131,8 @@
   unsigned N = 1;
   Type *EltTy = T;
 
-  while (isa(EltTy) || isa(EltTy)) {
+  while (isa(EltTy) || isa(EltTy) ||
+ isa(EltTy)) {
 if (auto *ST = dyn_cast(EltTy)) {
   // Check that struct is homogeneous.
   for (const auto *Ty : ST->elements())
@@ -3139,10 +3140,13 @@
   return 0;
   N *= ST->getNumElements();
   EltTy = *ST->element_begin();
+} else if (auto *AT = dyn_cast(EltTy)) {
+  N *= AT->getNumElements();
+  EltTy = AT->getElementType();
 } else {
-  auto *SeqT = cast(EltTy);
-  N *= SeqT->getNumElements();
-  EltTy = SeqT->getElementType();
+  auto *VT = cast(EltTy);
+  N 

[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2020-03-25 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.

Can this be landed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D75638: [Hexagon] Support for Linux/Musl ABI.

2020-03-25 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

I'm not sure if it's worth defining these macros especially if this is the only 
place where they are used.  We'd need a more coordinated effort to replace all 
32's with named constants where it refers to a register size, and I'm not even 
sure if we could classify whether a given 32 is tied to a register size or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75638



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 6 inline comments as done.
Charusso added a comment.

"To prevent such errors, either limit copies through truncation or, preferably, 
ensure that the destination is of sufficient size to hold the character data" - 
from the rule's page.
Most of the projects are fine truncating by hand because the write happens in 
somewhat well-bounded strings: IP-addresses, names, numbers... I wanted to make 
this as practical as possible. Until you are having a null-terminated string 
without being read, you are most likely fine. Feel free to try this out, 
probably you would already understand the `WarnOnCall` option very well.




Comment at: clang/docs/analyzer/checkers.rst:1935
+
+alpha.security.cert.str.31c
+"""

balazske wrote:
> Charusso wrote:
> > Szelethus wrote:
> > > balazske wrote:
> > > > There are already more checkers that can check for CERT related 
> > > > problems but not specially made for these. These checkers do not reside 
> > > > in this new `cert` group. And generally a checker does not check for 
> > > > specifically a CERT rule, instead for more of them or other things too, 
> > > > or more checkers can detect a single rule. (And the user can think that 
> > > > only these CERT rules are checkable that exist in this package, that is 
> > > > not true.) So I do not like the introduction of this new `cert` 
> > > > package. (The documentation of existing checkers lists if the checker 
> > > > is designed for a CERT rule.)
> > > I disagree to some extent. I think it would be great to have a `cert` 
> > > package that houses all checkers for each of the rules with the addition 
> > > of checker aliases. Clang-tidy has something similar as well!
> > I designed the checker only for the rule STR31-C that is why I have picked 
> > package `cert`. Clang-Tidy could aliasing checks. For example the check 
> > could be in the `bugprone` category aliased to `cert` and both could 
> > trigger the analysis.
> > 
> > > the user can think that only these CERT rules are checkable
> > We only need to move `security.FloatLoopCounter` under the `cert` package. 
> > What else SEI CERT rules are finished off other than package `cert`? It is 
> > not my fault if someone could not package well or could not catch most of 
> > the issues of a SEI CERT rule or could not reach the SEI CERT group to note 
> > the fact the Analyzer catch a very tiny part of a rule. However, this patch 
> > package well and could catch most of the STR31-C rule.
> So I can move this checker: D71510 into `alpha.security.cert.err.33c`?
Well, not exactly. No one should care about alpha checkers except advanced 
Static Analyzer developers like you do right now. Since alpha is a dead-zone 
you can put your work anywhere. The core issue was Ted's placing of CERT rules.

I have written the first CERT-checker after Ted's, which introduced such 
packaging, then it became dead, so I have lost interest to make the 
package-aliasing a thing. If you wish to move to `cert`, feel free, but please 
note that, your first idea of bad-packaging is right. We really need the 
functionality of package-aliasing but I have ran out of time and the project 
died as well.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:803
+
+} // end "cert.str"
+

balazske wrote:
> Charusso wrote:
> > balazske wrote:
> > > NoQ wrote:
> > > > `alpha.cert.str`.
> > > This text may be hard to understand. The option means "if it is off, the 
> > > problem report happens only if there is no hand-written null termination 
> > > of the string"? I looked at the CERT rule but did not find out why is 
> > > null termination by hand important here. (I did not look at the code to 
> > > find out what it does.) And "WarnOnCall" suggests that there is warning 
> > > made on calls if on, or not at all or at other location if off, is this 
> > > correct?
> > You let the buffer overflow by a bugprone function call, then you adjust 
> > the null-terminator by simply `buf[size] = '\0'`, then you made sure the 
> > buffer cannot overflow, since you have terminated it. It is a very common 
> > idiom therefore I do not think a hand-written null-termination is a 
> > security issue. The SEI CERT rules are all theoretical so you will not find 
> > anything useful in practice. My solution is practical.
> > 
> > > This text may be hard to understand.
> > Please note that this text only made for Static Analyzer developers. Let us 
> > rephrase it then:
> > 
> > > Whether the checker needs to warn on the bugprone function calls 
> > > immediately or look for bugprone hand-written null-termination of 
> > > bugprone function call made strings. It is a common idiom to 
> > > null-terminate the string by hand after the insecure function call 
> > > produce the string which could be misused so that it is on by default. It 
> > > is useful to turn it off to reduce the noise of the checker, 

[PATCH] D76795: [HIP] Change default --gpu-max-threads-per-block value to 1024

2020-03-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8123
+// --gpu-max-threads-per-block=n or its default value for HIP.
+const unsigned OpenCLMaxWorkGroupSize = 256;
+const unsigned MaxWorkGroupSize =

I'd like to see the word default, e.g. OpenCLDefaultMaxWorkGroupSize, used more 
since that is what this is about.  Ideally the option would have been named 
gpu-default-max-threads-per-block, but I suppose I can see why it was shortened.


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

https://reviews.llvm.org/D76795



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-25 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 3 inline comments as done.
erichkeane added a comment.

Both done here: fe5c719eaf572e23b700e75832ec37a3761b337b 
 .  Thanks 
for the review @Anastasia




Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:12
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}

Anastasia wrote:
> erichkeane wrote:
> > Anastasia wrote:
> > > Any reason to test unmangled?
> > Because you asked to validate the OpenCL cases as well.
> Ok, I guess we should add overloadable attribute otherwise it doesn't go 
> through mangling? Then I guess you only need a check for Linux or Windows 
> cases.
Done, I wasn't able to remove OCLWINDOWS, since windows mangles attribute 
'overloadable' in C only (and thus OpenCL).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75685



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


[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-03-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 252645.
efriedma added a comment.

Address lint comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75661

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/GetElementPtrTypeIterator.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3131,7 +3131,8 @@
   unsigned N = 1;
   Type *EltTy = T;
 
-  while (isa(EltTy) || isa(EltTy)) {
+  while (isa(EltTy) || isa(EltTy) ||
+ isa(EltTy)) {
 if (auto *ST = dyn_cast(EltTy)) {
   // Check that struct is homogeneous.
   for (const auto *Ty : ST->elements())
@@ -3139,10 +3140,13 @@
   return 0;
   N *= ST->getNumElements();
   EltTy = *ST->element_begin();
+} else if (auto *AT = dyn_cast(EltTy)) {
+  N *= AT->getNumElements();
+  EltTy = AT->getElementType();
 } else {
-  auto *SeqT = cast(EltTy);
-  N *= SeqT->getNumElements();
-  EltTy = SeqT->getElementType();
+  auto *VT = cast(EltTy);
+  N *= VT->getNumElements();
+  EltTy = VT->getElementType();
 }
   }
 
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -476,14 +476,24 @@
 return 0;
   }
 
-  case Type::ArrayTyID:
-  case Type::VectorTyID: {
-auto *STyL = cast(TyL);
-auto *STyR = cast(TyR);
+  case Type::ArrayTyID: {
+auto *STyL = cast(TyL);
+auto *STyR = cast(TyR);
 if (STyL->getNumElements() != STyR->getNumElements())
   return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
 return cmpTypes(STyL->getElementType(), STyR->getElementType());
   }
+  case Type::VectorTyID: {
+auto *STyL = cast(TyL);
+auto *STyR = cast(TyR);
+if (STyL->getElementCount().Scalable != STyR->getElementCount().Scalable)
+  return cmpNumbers(STyL->getElementCount().Scalable,
+STyR->getElementCount().Scalable);
+if (STyL->getElementCount().Min != STyR->getElementCount().Min)
+  return cmpNumbers(STyL->getElementCount().Min,
+STyR->getElementCount().Min);
+return cmpTypes(STyL->getElementType(), STyR->getElementType());
+  }
   }
 }
 
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3505,17 +3505,31 @@
 /// return a type if necessary.
 static Type *getTypePartition(const DataLayout , Type *Ty, uint64_t Offset,
   uint64_t Size) {
+  if (Ty->isVectorTy() && Ty->getVectorIsScalable())
+return nullptr;
+
   if (Offset == 0 && DL.getTypeAllocSize(Ty) == Size)
 return stripAggregateTypeWrapping(DL, Ty);
   if (Offset > DL.getTypeAllocSize(Ty) ||
   (DL.getTypeAllocSize(Ty) - Offset) < Size)
 return nullptr;
 
-  if (SequentialType *SeqTy = dyn_cast(Ty)) {
-Type *ElementTy = SeqTy->getElementType();
+  if (isa(Ty) || isa(Ty)) {
+Type *ElementTy;
+uint64_t TyNumElements;
+if (auto *AT = dyn_cast(Ty)) {
+  ElementTy = AT->getElementType();
+  TyNumElements = AT->getNumElements();
+} else {
+  // FIXME: This isn't right for vectors with non-byte-sized or
+  // non-power-of-two sized elements.
+  auto *VT = cast(Ty);
+  ElementTy = VT->getElementType();
+  TyNumElements = VT->getNumElements();
+}
 uint64_t ElementSize = DL.getTypeAllocSize(ElementTy);
 uint64_t NumSkippedElements = Offset / ElementSize;
-if (NumSkippedElements >= SeqTy->getNumElements())
+if (NumSkippedElements >= TyNumElements)
   return nullptr;
 Offset -= NumSkippedElements * ElementSize;
 
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 252646.
njames93 added a comment.

- Fixed by replacing cumbersome code with the arguably proper solution


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76761

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -220,3 +220,27 @@
   m1tp m1p2 = m1;
   m1p2(s.c_str());  
 }
+
+namespace PR45286 {
+struct Foo {
+  void func(const std::string &) {}
+  void func2(std::string &&) {}
+};
+
+void bar() {
+  std::string Str{"aaa"};
+  Foo Foo;
+  Foo.func(Str.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}Foo.func(Str);{{$}}
+
+  // Ensure it doesn't transform Binding to r values
+  Foo.func2(Str.c_str());
+
+  // Ensure its not confused by parens
+  Foo.func((Str.c_str()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}Foo.func((Str));{{$}}
+  Foo.func2((Str.c_str()));
+}
+} // namespace PR45286
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -61,53 +61,8 @@
   return (llvm::Twine("*") + Text).str();
 }
 
-// Trying to get CallExpr in which CxxConstructExpr is called.
-static const clang::CallExpr *
-tryGetCallExprAncestorForCxxConstructExpr(const Expr *TheExpr,
-  ASTContext ) {
-  // We skip nodes such as CXXBindTemporaryExpr, MaterializeTemporaryExpr.
-  for (ast_type_traits::DynTypedNode DynParent : Context.getParents(*TheExpr)) {
-if (const auto *Parent = DynParent.get()) {
-  if (const auto *TheCallExpr = dyn_cast(Parent))
-return TheCallExpr;
-
-  if (const clang::CallExpr *TheCallExpr =
-  tryGetCallExprAncestorForCxxConstructExpr(Parent, Context))
-return TheCallExpr;
-}
-  }
-
-  return nullptr;
-}
-
-// Check that ParamDecl of CallExprDecl has rvalue type.
-static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
-const Expr *TheCxxConstructExpr, ASTContext ) {
-  if (const clang::CallExpr *TheCallExpr =
-  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
-Context)) {
-for (unsigned i = 0; i < TheCallExpr->getNumArgs(); ++i) {
-  const Expr *Arg = TheCallExpr->getArg(i);
-  if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
-if (const auto *TheCallExprFuncProto =
-TheCallExpr->getCallee()
-->getType()
-->getPointeeType()
-->getAs()) {
-  if (TheCallExprFuncProto->getParamType(i)->isRValueReferenceType())
-return true;
-}
-  }
-}
-  }
-
-  return false;
-}
-
-AST_MATCHER(CXXConstructExpr,
-matchedParamDeclOfAncestorCallExprHasRValueRefType) {
-  return checkParamDeclOfAncestorCallExprHasRValueRefType(
-  , Finder->getASTContext());
+AST_MATCHER(MaterializeTemporaryExpr, isBoundToLValue) {
+  return Node.isBoundToLvalueReference();
 }
 
 } // end namespace
@@ -141,11 +96,11 @@
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
-  Finder->addMatcher(
-  cxxConstructExpr(
-  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
-  unless(matchedParamDeclOfAncestorCallExprHasRValueRefType())),
-  this);
+  Finder->addMatcher(cxxConstructExpr(StringConstructorExpr,
+  hasArgument(0, StringCStrCallExpr),
+  unless(hasParent(materializeTemporaryExpr(
+  unless(isBoundToLValue()),
+ this);
 
   // Detect: 's == str.c_str()'  ->  's == str'
   Finder->addMatcher(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D76761#1941476 , @gribozavr2 wrote:

> Right -- what I meant is a more detailed description of why, for example, 
> `tryGetCallExprAncestorForCxxConstructExpr` can't find the `CallExpr` in this 
> case -- is it not there, or does it not have the expected shape, or something 
> else? What does the AST look like?
>
> I'm worried about adding defensive checks because they can make code more 
> difficult to fix in future.


To be honest the whole fix that caused the crash in the first place was a mess, 
I have decided to fix this by checking if the parent is a temporary expr bound 
to an r value, as well as removing the hacky looking code from the previous 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76761



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


[PATCH] D75638: [Hexagon] Support for Linux/Musl ABI.

2020-03-25 Thread Brian Cain via Phabricator via cfe-commits
bcain added a comment.

In D75638#1917565 , @bcain wrote:

> @kparzysz do you have any thoughts about those review comments?


@sidneym is this just pulling existing contents downstream to go upstream?  If 
so let's expedite this please


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75638



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


[PATCH] D76572: Replace `T(x)` with `reinterpret_cast(x)` everywhere it means reinterpret_cast. No functional change

2020-03-25 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone marked 2 inline comments as done.
Quuxplusone added a comment.

Btw, @jhenderson and @rsmith, if you wanted to land your own files' pieces of 
this patch while waiting on whoever-it-is to approve the pieces in other files, 
that'd be cool. As I mentioned initially, I don't have the access necessary to 
land any part of it myself.




Comment at: llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp:150
+ ">= 65536.\n"
+ "(" +
+ Twine(reinterpret_cast()) + ")");

jhenderson wrote:
> Nit: I think you can fold these two string literals together. Not sure why 
> they were separate before.
I think the current code is intentionally parallel to what's on line 162, so 
I'd prefer to leave it alone and let whoever maintains it reflow it if they 
want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76572



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


[clang] fe5c719 - Implement post-commit comments for D75685/rG86e0a6c60627

2020-03-25 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-25T12:24:56-07:00
New Revision: fe5c719eaf572e23b700e75832ec37a3761b337b

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

LOG: Implement post-commit comments for D75685/rG86e0a6c60627

@Anastasia made a pair of comments on D75685 after it was committed
requesting changes to the test.  This patch updates the test based on
her comments.

Added: 


Modified: 
clang/test/CodeGenOpenCL/pipe_types_mangling.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/pipe_types_mangling.cl 
b/clang/test/CodeGenOpenCL/pipe_types_mangling.cl
index 32b3b30759b8..a7439f378b81 100644
--- a/clang/test/CodeGenOpenCL/pipe_types_mangling.cl
+++ b/clang/test/CodeGenOpenCL/pipe_types_mangling.cl
@@ -1,30 +1,32 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=clc++ -o - %s | FileCheck %s --check-prefixes=LINUX
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=clc++ -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=UNMANGLED,OCLLINUX
-// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=UNMANGLED,OCLWINDOWS
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=OCLWINDOWS
 
 typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
 typedef int __attribute__((ext_vector_type(4))) int4;
 
+__attribute__((overloadable))
 void test1(read_only pipe int p) {
 // LINUX: define void @_Z5test18ocl_pipe
 // WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
-// UNMANGLED: define {{.*}}void @test1(
+// OCLWINDOWS: define dso_local void 
@"?test1@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
 }
 
 __attribute__((overloadable))
 void test2(write_only pipe float p) {
 // LINUX: define void @_Z5test28ocl_pipe
 // WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
-// Note: overloadable attribute makes OpenCL Linux still mangle this,
-// but we cannot overload on pipe still.
-// OCLLINUX: define void @_Z5test28ocl_pipe
 // OCLWINDOWS: define dso_local void 
@"?test2@@$$J0YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
 }
 
 #ifdef WIN
-// SPIR Spec specifies mangling on pipes that doesn't include the element type
-//  or write/read. Our Windows mangling does, so make sure this still works.
+// It isn't possible to overload on pipe types in Linux mode
+// because the OCL specification on the Itanium ABI has a specified mangling
+// for the entire class of types, and thus doesn't take element type or 
read/write
+// into account. Thus, both would result in the same mangling, which is an 
IR-CodeGen
+// error. Our windows implementation of this mangling doesn't have that 
problem,
+// so we can test it here.
 __attribute__((overloadable))
 void test2(read_only pipe int p) {
 // WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
@@ -32,30 +34,32 @@ void test2(read_only pipe int p) {
 }
 #endif
 
-
+__attribute__((overloadable))
 void test3(read_only pipe const int p) {
 // LINUX: define void @_Z5test38ocl_pipe
 // WINDOWS: define dso_local void 
@"?test3@@YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
-// UNMANGLED: define {{.*}}void @test3(
+// OCLWINDOWS: define dso_local void 
@"?test3@@$$J0YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
 }
 
+__attribute__((overloadable))
 void test4(read_only pipe uchar3 p) {
 // LINUX: define void @_Z5test48ocl_pipe
 // WINDOWS: define dso_local void 
@"?test4@@YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
-// UNMANGLED: define {{.*}}void @test4(
+// OCLWINDOWS: define dso_local void 
@"?test4@@$$J0YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
 }
 
+__attribute__((overloadable))
 void test5(read_only pipe int4 p) {
 // LINUX: define void @_Z5test58ocl_pipe
 // WINDOWS: define dso_local void 
@"?test5@@YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
-// UNMANGLED: define {{.*}}void @test5(
+// OCLWINDOWS: define dso_local void 
@"?test5@@$$J0YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
 }
 
 typedef read_only pipe int MyPipe;
 kernel void test6(MyPipe p) {
 // LINUX: define spir_kernel void @test6
 // WINDOWS: define dso_local spir_kernel void @test6
-// UNMANGLED: define {{.*}}void @test6(
+// OCLWINDOWS: define dso_local spir_kernel void @test6
 }
 
 struct Person {
@@ -64,9 +68,10 @@ struct Person {
   int ID;
 };
 
+__attribute__((overloadable))
 void test_reserved_read_pipe(global struct Person *SDst,
  

[clang] df48e39 - [Clang] Fix clang-tidy errors.

2020-03-25 Thread Alexander Belyaev via cfe-commits

Author: Alexander Belyaev
Date: 2020-03-25T20:13:43+01:00
New Revision: df48e3920a56b128ad691c258372c641b076f21c

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

LOG: [Clang] Fix clang-tidy errors.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Expr.cpp
llvm/unittests/IR/KnowledgeRetentionTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index fa4918272819..e566e3c6ab89 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2026,7 +2026,8 @@ class PredefinedExpr final
 
   static StringRef getIdentKindName(IdentKind IK);
   static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl);
-  static std::string ComputeName(ASTContext , IdentKind IK, const QualType 
Ty);
+  static std::string ComputeName(ASTContext , IdentKind IK,
+ const QualType Ty);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 841c030cecdb..b09b4eb0de1b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4824,7 +4824,7 @@ class Sema final {
SourceLocation RParen, ParsedType Ty);
   ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
SourceLocation LParen,
-   SourceLocation RParen, Expr *Operand);
+   SourceLocation RParen, Expr *E);
 
   bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
 

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b603d2ab29ee..f0f22b6e4690 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -522,7 +522,7 @@ PredefinedExpr::PredefinedExpr(SourceLocation L, QualType 
FnTy, IdentKind IK,
 }
 
 PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FnTy, IdentKind IK,
-   Expr *Info)
+   Expr *E)
 : Expr(PredefinedExprClass, FnTy, VK_LValue, OK_Ordinary) {
   PredefinedExprBits.Kind = IK;
   assert((getIdentKind() == IK) &&
@@ -531,7 +531,7 @@ PredefinedExpr::PredefinedExpr(SourceLocation L, QualType 
FnTy, IdentKind IK,
  "Constructor only valid with UniqueStableNameExpr");
   PredefinedExprBits.HasFunctionName = false;
   PredefinedExprBits.Loc = L;
-  setExpr(Info);
+  setExpr(E);
   setDependence(computeDependence(this));
 }
 

diff  --git a/llvm/unittests/IR/KnowledgeRetentionTest.cpp 
b/llvm/unittests/IR/KnowledgeRetentionTest.cpp
index 2ed90b8b4e1e..2c923aaa7fbd 100644
--- a/llvm/unittests/IR/KnowledgeRetentionTest.cpp
+++ b/llvm/unittests/IR/KnowledgeRetentionTest.cpp
@@ -476,8 +476,7 @@ static void RunRandTest(uint64_t Seed, int Size, int 
MinCount, int MaxCount,
   }
 
   auto *Assume = cast(IntrinsicInst::Create(
-  FnAssume, ArrayRef({ConstantInt::getTrue(C)}),
-  std::move(OpBundle)));
+  FnAssume, ArrayRef({ConstantInt::getTrue(C)}), OpBundle));
   Assume->insertBefore(>begin()->front());
   RetainedKnowledgeMap Map;
   fillMapFromAssume(*Assume, Map);



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


[PATCH] D76795: [HIP] Change default --gpu-max-threads-per-block value to 1024

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: b-sumner, tra.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

This better matches CUDA behavior.


https://reviews.llvm.org/D76795

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/CodeGenCUDA/kernel-amdgcn.cu


Index: clang/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- clang/test/CodeGenCUDA/kernel-amdgcn.cu
+++ clang/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -39,4 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
-// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8119,9 +8119,12 @@
   assert(Max == 0 && "Max must be zero");
   } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to a value specified by
-// --gpu-max-threads-per-block=n or its default value.
-std::string AttrVal =
-std::string("1,") + 
llvm::utostr(M.getLangOpts().GPUMaxThreadsPerBlock);
+// --gpu-max-threads-per-block=n or its default value for HIP.
+const unsigned OpenCLMaxWorkGroupSize = 256;
+const unsigned MaxWorkGroupSize =
+IsOpenCLKernel ? OpenCLMaxWorkGroupSize
+   : M.getLangOpts().GPUMaxThreadsPerBlock;
+std::string AttrVal = std::string("1,") + llvm::utostr(MaxWorkGroupSize);
 F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
   }
 
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -231,7 +231,7 @@
 LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate 
transcendental functions")
 LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
-LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
+LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for 
kernel launch bounds for HIP")
 
 LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")


Index: clang/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- clang/test/CodeGenCUDA/kernel-amdgcn.cu
+++ clang/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -39,4 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
-// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8119,9 +8119,12 @@
   assert(Max == 

[PATCH] D75779: [OpenMP] `omp begin/end declare variant` - part 2, sema (+"CG")

2020-03-25 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/lib/AST/DeclarationName.cpp:147
+Name = Name.split(getOpenMPVariantManglingSeparatorStr()).first;
+  OS << Name;
+}

Would it make sense to print " (omp variant)" after the name to disambiguate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75779



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, so these array-shaping expressions are only allowed as operands to 
specific OpenMP directives?  That's a plausible interpretation of "The 
shape-operator can appear only in clauses where it is explicitly allowed" from 
the spec .  If it were a 
more general l-value expression, we could handle that just fine by building the 
type using `ConstantArrayType`/`VariableArrayType` as appropriate; but if the 
language intentionally restricts it, the placeholder approach seems fine.




Comment at: clang/lib/Sema/SemaExpr.cpp:4748
+   Base->isInstantiationDependent() ||
+   Base->containsUnexpandedParameterPack()))
+return OMPArrayShapingExpr::Create(Context, Context.DependentTy, Base,

Just check `isTypeDependent()`, none of these other conditions should interfere 
with type-checking.



Comment at: clang/lib/Sema/SemaExpr.cpp:4751
+   LParenLoc, RParenLoc, Dims, Brackets);
+  if (!BaseTy->isAnyPointerType())
+return ExprError(Diag(Base->getExprLoc(),

I think you should perform DefaultFunctionArrayLvalueConversion here so that 
e.g. arrays will decay to pointers, you load pointers from l-values, and so on. 
 If you do so, it'll handle placeholders for you.

Do you really want to allow this to operate on non-C pointer types?



Comment at: clang/lib/Sema/SemaExpr.cpp:4758
+  for (Expr *Dim : Dims) {
+if (Dim->getType()->isNonOverloadPlaceholderType()) {
+  ExprResult Result = CheckPlaceholderExpr(Dim);

I think overload placeholders need to be resolved here, too.  You may have 
copied this code from some different place that has the ability to resolve 
overloads later, but in this case that's not true.



Comment at: clang/lib/Sema/SemaExpr.cpp:4771
+}
+if (!Dim->isValueDependent() && !Dim->isTypeDependent()) {
+  ExprResult Result =

You don't really care about value-dependence here, just type-dependence.  You 
can check value-dependence before doing the constant-evaluation check below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D76724: Prevent immediate evaluations inside of decltype

2020-03-25 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15389
   if (!E.isUsable() || !Decl || !Decl->isConsteval() || isConstantEvaluated() 
||
-  RebuildingImmediateInvocation)
+  isInDeclType(*this) || RebuildingImmediateInvocation)
 return E;

the issue is seems more general than delctype. it applies to all unvealuated 
context (sizeof, alignof ...)

i think we should use Sema::isUnevaluatedContext() here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76724



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


[PATCH] D75779: [OpenMP] `omp begin/end declare variant` - part 2, sema (+"CG")

2020-03-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5396
+  IdentifierInfo  = Context.Idents.get(
+  (D.getIdentifier()->getName() + "." + DVScope.NameSuffix).str());
+  D.SetIdentifier(, D.getBeginLoc());

hfinkel wrote:
> jdoerfert wrote:
> > hfinkel wrote:
> > > Is there any way in which this name might become visible to users (e.g., 
> > > in error messages)?
> > Yes, I think so. One way to trigger it would be to define the same function 
> > in the same `omp begin declare variant scope` (or two with the same 
> > context). I haven't verified this though.
> > TBH, I'm unsure how bad this actually is in the short term. The original 
> > name is still a at the beginning. We should obviously make sure the error 
> > message is appropriate eventually, e.g., it de-mangles the name.
> I think that we have to consider diagnostic quality as a first-class citizen. 
> There are a few different ways that we might approach this. A minimal diff 
> from what you have might be:
> 
>   1. Replace the "." above with ".ompvariant."
>   2. Add logic to FunctionDecl::getNameForDiagnostic (or 
> NamedDecl::getNameForDiagnostic) that recognizes that magic string in the 
> name and alters the printing to do something intelligible for the user with 
> the name.
> 
> (I think that (1) is a good idea anyway).
> 
> Another way would be to add some first-class property to the function and 
> then leave the mangling to CodeGen. Are we mangling these in Sema in other 
> places too?
> 
> 
> 
> 
> Also, these can have external linkage, right?
I added a test for this in `begin_declare_variant_messages.c` and confirmed my 
earlier statement. Then I implemented what you describe above (in spirit).

> Another way would be to add some first-class property to the function and 
> then leave the mangling to CodeGen. Are we mangling these in Sema in other 
> places too?

That would potentially work but require us to touch a lot of places that deal 
with redefinitions and overload resolution. Getting the right clashes between 
specialized versions with the same name and openmp context but not getting the 
clashes for the same name but different openmp context will be non-trivial. 
Similarly, we need to ignore specialized versions during overload resolution, 
etc. etc.

FWIW, this is design 8 or 9, or even more. I tried to keep the names till 
codegen in the beginning, using an approach similar to what you described. I 
tried to use namespaces (even in C) to get the right kind of name clashes and 
interactions, I tried ... This is the only thing that (so far) worked reliably 
and is (IMHO) very non-intrusive.


> Also, these can have external linkage, right?

Yes. My name clash test has 3 different linkages, see 
`begin_declare_variant_messages.c`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75779



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


[PATCH] D76691: [AST][SVE] Treat built-in SVE types as trivially copyable

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76691



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


[PATCH] D76690: [AST][SVE] Treat built-in SVE types as POD

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

Okay, then LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76690



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


[PATCH] D76692: [AST][SVE] Treat built-in SVE types as trivial

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76692



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


[PATCH] D72773: [Matrix] Add __builtin_matrix_{add,sub} to Clang (WIP).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

superseded by D76793  using operators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72773



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


[PATCH] D72772: [Matrix] Add __builtin_matrix_extract to Clang (WIP).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

superseded by D76791  using operators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72772



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


[PATCH] D72774: [Matrix] Add __builtin_matrix_multiply to Clang (WIP).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Superseded by D76794  using operators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72774



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


[PATCH] D72785: [Matrix] Add __builtin_matrix_scalar_multiply to Clang (WIP).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

Superseded by D76794 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72785



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


[PATCH] D76794: [Matrix] Implement * binary operator for MatrixType.

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, anemet, Bigcheese, rsmith, martong.
Herald added subscribers: tschuett, dexonsmith, rnkovacs.
Herald added a project: clang.

This patch implements the * binary operator for values of
MatrixType. It adds support for matrix * matrix, scalar * matrix and
matrix * scalar.

For the matrix, matrix case, the number of columns of the first operand
must match the number of rows of the second. For the scalar,matrix variants,
the element type of the matrix must match the scalar type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76794

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -144,15 +144,24 @@
: B.CreateSub(LHS, RHS);
   }
 
-  /// Multiply matrix \p LHS with scalar \p RHS.
+  /// Multiply matrix \p LHS with scalar \p RHS or scalar \p LHS with matrix \p
+  /// RHS.
   Value *CreateScalarMultiply(Value *LHS, Value *RHS) {
-Value *ScalarVector =
-B.CreateVectorSplat(cast(LHS->getType())->getNumElements(),
-RHS, "scalar.splat");
-if (RHS->getType()->isFloatingPointTy())
-  return B.CreateFMul(LHS, ScalarVector);
-
-return B.CreateMul(LHS, ScalarVector);
+assert(LHS->getType()->isVectorTy() ||
+   RHS->getType()->isVectorTy() &&
+   "One of the operands must be a matrix (embedded in a vector)");
+Value *ScalarVector = B.CreateVectorSplat(
+cast(LHS->getType())->getNumElements(),
+LHS->getType()->isVectorTy() ? RHS : LHS, "scalar.splat");
+if (RHS->getType()->isFloatingPointTy()) {
+  if (LHS->getType()->isVectorTy())
+return B.CreateFMul(LHS, ScalarVector);
+  return B.CreateFMul(ScalarVector, RHS);
+}
+
+if (LHS->getType()->isVectorTy())
+  return B.CreateMul(LHS, ScalarVector);
+return B.CreateMul(ScalarVector, RHS);
   }
 
   /// Extracts the element at (\p Row, \p Column) from \p Matrix.
Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- clang/test/SemaCXX/matrix-type-operators.cpp
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -122,3 +122,26 @@
   Mat1.value = subtract(Mat2, Mat3);
   // expected-note@-1 {{in instantiation of function template specialization 'subtract' requested here}}
 }
+
+template 
+typename MyMatrix::matrix_t multiply(MyMatrix , MyMatrix ) {
+  char *v1 = A.value * B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(2, 2))) '}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value * B.value;
+  // expected-error@-1 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+}
+
+void test_multiply_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  unsigned v1 = multiply(Mat1, Mat1);
+  // expected-note@-1 {{in instantiation of function template specialization 'multiply' requested here}}
+  // expected-error@-2 {{cannot initialize a variable of type 'unsigned int' with an rvalue of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+
+  Mat1.value = multiply(Mat1, Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'multiply' requested here}}
+}
Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -96,3 +96,22 @@
   a = b - 
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
 }
+
+void mat_mat_multiply(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
+  // Invalid dimensions for operands.
+  a = c * c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))') and 'sx10x5_t')}}
+
+  // Shape of multiplication result does not match the type of b.
+  b = a * a;
+  // 

[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, anemet, Bigcheese, rsmith, martong.
Herald added subscribers: tschuett, dexonsmith, rnkovacs.
Herald added a project: clang.

This patch implements the + and - binary operators for values of
MatrixType. It adds support for matrix +/- matrix, scalar +/- matrix and
matrix +/- scalar.

For the matrix, matrix case, the types must initially be structurally
equivalent. For the scalar,matrix variants, the element type of the
matrix must match the scalar type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76793

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp

Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- clang/test/SemaCXX/matrix-type-operators.cpp
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -59,3 +59,66 @@
   float v11 = a[5][10.0];
   // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
 }
+
+template 
+struct MyMatrix {
+  using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+  matrix_t value;
+};
+
+template 
+typename MyMatrix::matrix_t add(MyMatrix , MyMatrix ) {
+  char *v1 = A.value + B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-3 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value + B.value;
+  // expected-error@-1 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+}
+
+void test_add_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  unsigned v1 = add(Mat1, Mat1);
+  // expected-error@-1 {{cannot initialize a variable of type 'unsigned int' with an rvalue of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-note@-2 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat1, Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat2, Mat3);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+}
+
+template 
+typename MyMatrix::matrix_t subtract(MyMatrix , MyMatrix ) {
+  char *v1 = A.value - B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-3 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))')}}
+
+  return A.value - B.value;
+  // expected-error@-1 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))')}}
+}
+
+void test_subtract_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  unsigned v1 = subtract(Mat1, Mat1);
+  // expected-error@-1 {{cannot initialize a variable of type 'unsigned int' with an rvalue of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-note@-2 {{in instantiation of function template 

[PATCH] D72283: [Matrix] Add __builtin_matrix_insert to Clang (WIP).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

superseded by D76791  using operators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72283



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


[PATCH] D76725: [clangd] Build ASTs only with fresh preambles or after building a new preamble

2020-03-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D76725#1940282 , @sammccall wrote:

> So I think we need a careful description of the new model somewhere. Not so 
> much on specific changes/constraints parts of the code operate under, but 
> what it's trying to do.
>
> My best understanding is:
>
> - In general, read requests are processed in order by the ASTWorker, and get 
> exactly the version of the file when the request was received. That is, the 
> ASTworker queue interleaves updates and reads in the same order as LSP.
> - Preambles are built on the PreambleWorker for a certain version of the 
> file, and may be compatible or incompatible with subsequent versions. If a 
> read is "picky" it may block the ASTWorker queue waiting for a compatible 
> preamble, otherwise it will "patch up" an incompatible one.
> - Diagnostics and indexes are updated opportunistically using onMainAST when 
> an AST is built, but only if the used preamble is compatible. Publishing 
> diagnostics from patched preambles is not allowed, but we also do not block 
> waiting for an up-to-date preamble in order to generate publishable 
> diagnostics. (Exception: if WantDiagnostics=Yes, we block).
> - To ensure forward progress with diagnostics if the queue is full, when 
> preamble is built we immediately build a "golden" AST from that version and 
> publish diagnostics. To ensure diagnostics do not "go backwards", 
> opportunistic diagnostics are suppressed if they don't use the latest 
> preamble (the one with the last golden AST). This means the sequence of ASTs 
> producing diagnostics is neatly partitioned into "epochs" of the preambles, 
> the first in the epoch is always the golden version. (Exception: if 
> WantDiagnostics=no, diagnostics are not emitted for the golden AST). Because 
> these versions are built out-of-order (not interleaved with reads per LSP), 
> the golden AST is not cached and reused for reads.
>
>   Is this about right?


Yes that's most of what this patch does. Tried to explain/sum up those in file 
comments.

> Based on this, I do think the model would be much easier to reason about and 
> verify if the golden AST was built on the ASTWorker thread in a queued task, 
> rather than on the PreambleWorker thread in a callback. This means we 
> understand allowed sequencing by looking at the queue rather than reasoning 
> about mutexes/threads with multiple possible interleavings. By pushing the 
> golden AST task to the front of the queue, it's more explicit that this is a 
> priorities/scheduling decision. Following what happened in logs is probably 
> easier due to less interleaving.
> 
>   (The callback could enqueue the task, or the PreambleWorker could just 
> enqueue the task directly at that point - not sure the callback indirection 
> buys anything).

Done. It is still the callback that enqueues the task, but moved storage of 
latest build preamble from PreambleThread to ASTWorker to prevent a possible 
race between currently running update in astworker and build of preamble in 
preamblethread, as discussed offline.
This also enabled us to cache golden ASTs in case ASTWorker hasn't received any 
updates in between which gets rid of the additional AST build cost.

> One thing that seems complicated in the model is that the AST build needs to 
> decide whether to block on a compatible preamble, but it's the following read 
> that determines whether it needs to. In the worst case, the picky read hasn't 
> even been scheduled yet. I think picky reads probably need to block on the 
> target preamble and build their AST themselves if the cached one isn't 
> suitable. If they "miss" their preamble (i.e. preambleVersion >= readVersion 
> but the preamble isn't compatible) then I think we should fail the request 
> (i.e. picky requests may be invalidated by subsequent preamble edits).

Agreed, but this is not in the scope of this patch, will address that in the 
upcoming patches after dropping the synchronization between preamble and ast 
thread. In addition to that i am planning to ensure updates with 
`WantDiagnostics::Yes` gets build by making them non-overwritable in 
PreambleThread. That is any subsequent build requests will block (astworker 
thread) until update with `WantDiags::Yes` starts building.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76725



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


[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 252634.
fhahn edited the summary of this revision.
fhahn added a comment.

Include columns in structural equi check, fixed type printing todo & rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/matrix-type.c
  clang/test/CodeGenCXX/matrix-type.cpp
  clang/test/SemaCXX/matrix-type.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1786,6 +1786,8 @@
 DEFAULT_TYPELOC_IMPL(DependentSizedExtVector, Type)
 DEFAULT_TYPELOC_IMPL(Vector, Type)
 DEFAULT_TYPELOC_IMPL(ExtVector, VectorType)
+DEFAULT_TYPELOC_IMPL(Matrix, Type)
+DEFAULT_TYPELOC_IMPL(DependentSizedMatrix, Type)
 DEFAULT_TYPELOC_IMPL(FunctionProto, FunctionType)
 DEFAULT_TYPELOC_IMPL(FunctionNoProto, FunctionType)
 DEFAULT_TYPELOC_IMPL(Record, TagType)
Index: clang/test/SemaCXX/matrix-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -fenable-matrix -std=c++11 -verify -triple x86_64-apple-darwin %s
+
+using matrix_double_t = double __attribute__((matrix_type(6, 6)));
+using matrix_float_t = float __attribute__((matrix_type(6, 6)));
+using matrix_int_t = int __attribute__((matrix_type(6, 6)));
+
+void matrix_var_dimensions(int Rows, unsigned Columns, char C) {
+  using matrix1_t = int __attribute__((matrix_type(Rows, 1)));// expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix2_t = int __attribute__((matrix_type(1, Columns))); // expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix3_t = int __attribute__((matrix_type(C, C)));   // expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix4_t = int __attribute__((matrix_type(-1, 1)));  // expected-error{{vector size too large}}
+  using matrix5_t = int __attribute__((matrix_type(1, -1)));  // expected-error{{vector size too large}}
+  using matrix6_t = int __attribute__((matrix_type(0, 1)));   // expected-error{{zero vector size}}
+  using matrix7_t = int __attribute__((matrix_type(1, 0)));   // expected-error{{zero vector size}}
+  using matrix7_t = int __attribute__((matrix_type(char, 0)));// expected-error{{expected '(' for function-style cast or type construction}}
+}
+
+struct S1 {};
+
+void matrix_unsupported_element_type() {
+  using matrix1_t = char *__attribute__((matrix_type(1, 1))); // expected-error{{invalid matrix element type 'char *'}}
+  using matrix2_t = S1 __attribute__((matrix_type(1, 1)));// expected-error{{invalid matrix element type 'S1'}}
+}
+
+template  // expected-note{{declared here}}
+void matrix_template_1() {
+  using matrix1_t = float __attribute__((matrix_type(T, T))); // expected-error{{'T' does not refer to a value}}
+}
+
+template  // expected-note{{declared here}}
+void matrix_template_2() {
+  using matrix1_t = float __attribute__((matrix_type(C, C))); // expected-error{{'C' does not refer to a value}}
+}
+
+template 
+void matrix_template_3() {
+  using matrix1_t = float __attribute__((matrix_type(Rows, Cols))); // expected-error{{zero vector size}}
+}
+
+void instantiate_template_3() {
+  matrix_template_3<1, 10>();
+  matrix_template_3<0, 10>(); // expected-note{{in instantiation of function template specialization 'matrix_template_3<0, 10>' requested 

[PATCH] D76791: [Matrix] Implement matrix index expressions ([][]).

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, anemet, Bigcheese, rsmith, martong.
Herald added subscribers: tschuett, arphaman, dexonsmith, rnkovacs.
Herald added a project: clang.

This patch implements matrix index expressions
(matrix[RowIdx][ColumnIdx]).

It does so by utilizing ArraySubscriptExpr: a matrix index expression
is represented as nested ArraySubscriptExpr as follows

  ArraySubscriptExpr(ArraySubscriptExpr(matrix, row index), column index).

A new helper getMatrixFromIndexExpr is added to Expr to check if the
base of an index expression is a matrix, by checking for the nested
expression as described above.

For CodeGen, a new MatrixElt type is added to LValue, which is very
similar to VectorElt. The only difference is that we may need to cast
the type of the base from an array to a vector type when accessing it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76791

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp

Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -std=c++11 -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = 
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes outside allowed dimensions.
+  a[-1][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[3][-1] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[3][-1u] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[-1u][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[5][2] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[4][10] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[5][10.0] = f;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
+
+void extract(sx5x10_t a, float f) {
+  // Non integer indexes.
+  float v1 = a[3][f];
+  // expected-error@-1 {{matrix column index is not an integer}}
+  float v2 = a[f][9];
+  // expected-error@-1 {{matrix row index is not an integer}}
+  float v3 = a[f][f];
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  char *v4 = a[3][4];
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an lvalue of type 'float'}}
+
+  // Indexes outside allowed dimensions.
+  float v5 = a[-1][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v6 = a[3][-1];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v8 = a[-1u][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v9 = a[5][2];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v10 = a[4][10];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v11 = a[5][10.0];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
Index: clang/test/Sema/matrix-type-operators.c
===
--- /dev/null
+++ clang/test/Sema/matrix-type-operators.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = 
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes outside allowed dimensions.
+  a[-1][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the 

[PATCH] D76725: [clangd] Build ASTs only with fresh preambles or after building a new preamble

2020-03-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 252633.
kadircet added a comment.

- Build golden asts in ASTWorker thread, rather than preamble thread.
- Explain new model in file comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76725

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -66,8 +66,7 @@
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   auto Preamble =
-  buildPreamble(FullFilename, *CI,
-/*OldPreamble=*/nullptr, Inputs,
+  buildPreamble(FullFilename, *CI, Inputs,
 /*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
   auto AST =
   buildAST(FullFilename, std::move(CI), Diags.take(), Inputs, Preamble);
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -283,6 +283,7 @@
 S.runWithPreamble("StaleRead", Path, TUScheduler::Stale,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "A");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
@@ -292,11 +293,13 @@
 S.runWithPreamble("ConsistentRead", Path, TUScheduler::Consistent,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "B");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
 ++CallbackCount;
   });
+S.blockUntilIdle(timeoutSeconds(10));
   }
   EXPECT_EQ(2, CallbackCount);
 }
@@ -853,15 +856,19 @@
   TUState(PreambleAction::Idle, ASTAction::RunningAction),
   // We build the preamble
   TUState(PreambleAction::Building, ASTAction::RunningAction),
-  // Preamble worker goes idle
+  // We built the preamble, and issued ast built on ASTWorker
+  // thread. Preambleworker goes idle afterwards.
   TUState(PreambleAction::Idle, ASTAction::RunningAction),
-  // We start building the ast
+  // Start task for building the ast, as a result of building
+  // preamble, on astworker thread.
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // AST build starts.
   TUState(PreambleAction::Idle, ASTAction::Building),
-  // Built finished succesffully
+  // AST built finished successfully
   TUState(PreambleAction::Idle, ASTAction::Building),
-  // Rnning go to def
+  // Running go to def
   TUState(PreambleAction::Idle, ASTAction::RunningAction),
-  // both workers go idle
+  // ASTWorker goes idle.
   TUState(PreambleAction::Idle, ASTAction::Idle)));
 }
 
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -286,7 +286,7 @@
 
   FileIndex Index;
   bool IndexUpdated = false;
-  buildPreamble(FooCpp, *CI, /*OldPreamble=*/nullptr, PI,
+  buildPreamble(FooCpp, *CI, PI,
 /*StoreInMemory=*/true,
 [&](ASTContext , std::shared_ptr PP,
 const CanonicalIncludes ) {
@@ -424,7 +424,7 @@
 }
 
 TEST(FileIndexTest, MergeMainFileSymbols) {
-  const char* CommonHeader = "void foo();";
+  const char *CommonHeader = "void foo();";
   TestTU Header = TestTU::withCode(CommonHeader);
   TestTU Cpp = TestTU::withCode("void foo() {}");
   Cpp.Filename = "foo.cpp";
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -6,16 +6,46 @@
 //
 

[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-03-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a reviewer: rjmccall.
fhahn marked 2 inline comments as done.
fhahn added inline comments.



Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:647
+  return false;
+if (Mat1->getNumRows() != Mat2->getNumRows())
+  return false;

martong wrote:
> Should we check `getNumColumns()` too?
Yes, thanks! Should be fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281



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


[clang] 044c51d - Fix vector type scalar checking when the scalar operand is dependent

2020-03-25 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-25T11:38:58-07:00
New Revision: 044c51d8d433da885438fcb141b15c80d7b62eda

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

LOG: Fix vector type scalar checking when the scalar operand is dependent

As reported in PR45298 and PR45299, vector_size type checking would
crash when done in a situation where the scalar is dependent, such as
a member of the current instantiation.

This is because the scalar checking ensures that you can implicitly
convert a value to a vector-type as long as it doesn't require
truncation. It does this by using the constant evaluator to get the
value as a float. Unfortunately, if the scalar is dependent (such as a
member of the current instantiation), we would hit the assert in the
evaluator.

This patch suppresses the truncation- of-value check in the first phase
of translation. All values are properly errored upon instantiation. This
has one minor regression, in that previously in a non-asserts build,

template
struct S {
  float4 f(float4 f) {
return k + f;
  }
  static constexpr k = 1.1; // causes a truncation on conversion.
};

would error immediately. Because 'k' is value dependent (as a
member-of-the-current-instantiation), this would still be evaluatable
(despite normally asserting).  Due to this patch, this diagnostic is
delayed until instantiation time.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/vector.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7cb12ec9c405..8f4a7f240de1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9201,7 +9201,13 @@ static bool tryGCCVectorConvertAndSplat(Sema , 
ExprResult *Scalar,
   // Reject cases where the scalar type is not a constant and has a higher
   // Order than the vector element type.
   llvm::APFloat Result(0.0);
-  bool CstScalar = Scalar->get()->EvaluateAsFloat(Result, S.Context);
+
+  // Determine whether this is a constant scalar. In the event that the
+  // value is dependent (and thus cannot be evaluated by the constant
+  // evaluator), skip the evaluation. This will then diagnose once the
+  // expression is instantiated.
+  bool CstScalar = Scalar->get()->isValueDependent() ||
+   Scalar->get()->EvaluateAsFloat(Result, S.Context);
   int Order = S.Context.getFloatingTypeOrder(VectorEltTy, ScalarTy);
   if (!CstScalar && Order < 0)
 return true;

diff  --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
index 67e5a94cb108..cabc525771c3 100644
--- a/clang/test/SemaCXX/vector.cpp
+++ b/clang/test/SemaCXX/vector.cpp
@@ -400,3 +400,77 @@ namespace swizzle_typo_correction {
 return A.xyzw < B.x && B.y > A.y; // OK, not a typo for 'xyzv'
   }
 }
+
+namespace PR45299 {
+typedef float float4 __attribute__((vector_size(16)));
+
+// In this example, 'k' is value dependent. PR45299 reported that this asserted
+// because of that, since the truncation check attempted to constant evaluate 
k,
+// which it could not do because it is dependent.
+template 
+struct NormalMember {
+  float4 f(float4 x) {
+return k * x;
+  }
+  float k;
+};
+
+#if __cplusplus >= 201103L
+// This should not diagnose, since the constant evaluator (during 
instantiation)
+// can tell that this isn't a truncation.
+template 
+struct ConstantValueNoDiag {
+  float4 f(float4 x) {
+return k * x;
+  }
+  static constexpr double k = 1;
+};
+
+// The following two both diagnose because they cause a truncation.  Test both
+// the dependent type and non-dependent type versions.
+template 
+struct DiagTrunc {
+  float4 f(float4 x) {
+// expected-error@+1{{as implicit conversion would cause truncation}}
+return k * x;
+  }
+  static constexpr double k = 1340282346638528859811704183484516925443.00;
+};
+template 
+struct DiagTruncDependentType {
+  float4 f(float4 x) {
+// expected-error@+1{{as implicit conversion would cause truncation}}
+return k * x;
+  }
+  static constexpr T k = 1340282346638528859811704183484516925443.00;
+};
+
+template 
+struct PR45298 {
+T k1 = T(0);
+};
+
+// Ensure this no longer asserts.
+template 
+struct PR45298Consumer {
+  float4 f(float4 x) {
+return (float)s.k1 * x;
+  }
+
+  PR45298 s;
+};
+#endif // __cplusplus >= 201103L
+
+void use() {
+  float4 theFloat4;
+  NormalMember().f(theFloat4);
+#if __cplusplus >= 201103L
+  ConstantValueNoDiag().f(theFloat4);
+  // expected-note@+1{{in instantiation of member function}}
+  DiagTrunc().f(theFloat4);
+  // expected-note@+1{{in instantiation of member function}}
+  DiagTruncDependentType().f(theFloat4);
+  PR45298Consumer().f(theFloat4);
+#endif // __cplusplus >= 201103L
+}
+}




[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I just created a quick fix for the issue: https://reviews.llvm.org/D76790


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:409
 
-  Optional FoundSummary = findFunctionSummary(FD, CE, C);
+  for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
+ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);

NoQ wrote:
> NoQ wrote:
> > martong wrote:
> > > NoQ wrote:
> > > > martong wrote:
> > > > > NoQ wrote:
> > > > > > Maybe we should add an assertion that the same argument isn't 
> > > > > > specified multiple times.
> > > > > I think there could be cases when we want to have e.g. a not-null 
> > > > > constraint on the 1st argument, but also we want to express that the 
> > > > > 1st argument's size is described by the 2nd argument. I am planning 
> > > > > to implement such a constraints in the future. In that case we would 
> > > > > have two constraints on the 1st argument and the assert would fire.
> > > > Wait, i misunderstood the code. It's even worse than that: you're 
> > > > adding transitions in a loop, so it'll cause state splits for every 
> > > > constraint. Because you do not intend to create multiple branches here, 
> > > > there needs to be exactly one `addTransition` performed every time 
> > > > `checkPreCall` is called. I.e., for now this code is breaking 
> > > > everything whenever there's more than one constraint, regardless of 
> > > > whether it's on the same argument.
> > > Yeah, that's a very good catch, thanks! I am going to prepare a patch to 
> > > fix this soon. My idea is to store the `SuccessSt` and apply the next 
> > > argument constraint on that. And once the loop is finished I'll have call 
> > > the `addTransition()`.
> > Yup, that's the common thing to do in such cases.
> While we're at it, could you try to come up with a runtime assertion that'll 
> help us prevent these mistakes?
> 
> Like, dunno, make `CheckerContext` crash whenever there's more than one 
> branch being added, and then add a method to opt out when it's actually 
> necessary to add more transitions (i.e., the user would say 
> `C.setMaxTransitions(2)` at the beginning of their checker callback whenever 
> they need to make a state split, defaulting to 1). It's a bit tricky because 
> i still want to allow multiple transitions when they allow one branch (i.e., 
> transitions chained together) but i think it'll take a lot of review anxiety 
> from me because it's a very dangerous mistake to make and for now code review 
> is the only way to catch it. So, yay, faster code reviews.
Hmm I see your point and I agree this would be a valuable sanity check. But if 
you don't mind I'd like to address this in a different and stand-alone patch 
(independently from the quick-fix https://reviews.llvm.org/D76790) because it 
does not seem to be trivial for me. 

My first concern is this: if we have `1` as the default value for 
`maxTranisitions` then we should add an extra `C.setMaxTransitions(N)` in every 
checker callback that does a state split, is that right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D76790: [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: NoQ, Szelethus, baloghadamsoftware.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
xazax.hun, whisperity.
Herald added a project: clang.
martong added a comment.

I was thinking about the below test, but then I reverted back because I don't 
want to add "fake" summaries for testing purposes. Perhaps adding a new checker 
option could enable these "fake" summaries, @Szelethus what's your opinion?

  diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  index 64a412bb4db..c1022492429 100644
  --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  @@ -736,6 +736,14 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 };
  
 FunctionSummaryMap = {
  +  {
  +"__test",
  +Summaries{
  +  Summary(ArgTypes{IntTy, IntTy}, RetType{IntTy}, EvalCallAsPure)
  +.ArgConstraint(ArgumentCondition(0U, WithinRange, 
SingleValue(1)))
  +.ArgConstraint(ArgumentCondition(1U, WithinRange, 
SingleValue(1)))
  +}
  +  },
 // The isascii() family of functions.
 // The behavior is undefined if the value of the argument is not
 // representable as unsigned char or is not equal to EOF. See e.g. C99
  diff --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.c 
b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  index a20b90ad1cc..01109e28b99 100644
  --- a/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  +++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  @@ -85,3 +85,18 @@ void test_notnull_symbolic2(FILE *fp, int *buf) {
   // bugpath-warning{{Function argument constraint is not satisfied}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   }
  +
  +int __test(int, int);
  +
  +void test_multiple_constraints(int x, int y) {
  +  __test(x, y);
  +  clang_analyzer_eval(x == 1); // \
  +  // report-warning{{TRUE}} \
  +  // bugpath-warning{{TRUE}} \
  +  // bugpath-note{{TRUE}}
  +  clang_analyzer_eval(y == 1); // \
  +  // report-warning{{TRUE}} \
  +  // bugpath-warning{{TRUE}} \
  +  // bugpath-note{{TRUE}}
  +}
  +


Previously we induced a state split if there were multiple argument
constraints given for a function. This was because we called
`addTransition` inside the for loop.
The fix is to is to store the state and apply the next argument
constraint on that. And once the loop is finished we call `addTransition`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76790

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -452,23 +452,26 @@
   const Summary  = *FoundSummary;
   ProgramStateRef State = C.getState();
 
+  ProgramStateRef NewState = State;
   for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
-ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);
-ProgramStateRef FailureSt = VC->negate()->apply(State, Call, Summary);
+ProgramStateRef SuccessSt = VC->apply(NewState, Call, Summary);
+ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  if (ExplodedNode *N = C.generateErrorNode(State))
+  if (ExplodedNode *N = C.generateErrorNode(NewState))
 reportBug(Call, N, C);
   break;
 } else {
-  // Apply the constraint even if we cannot reason about the argument. This
-  // means both SuccessSt and FailureSt can be true. If we weren't applying
-  // the constraint that would mean that symbolic execution continues on a
-  // code whose behaviour is undefined.
+  // We will apply the constraint even if we cannot reason about the
+  // argument. This means both SuccessSt and FailureSt can be true. If we
+  // weren't applying the constraint that would mean that symbolic
+  // execution continues on a code whose behaviour is undefined.
   assert(SuccessSt);
-  C.addTransition(SuccessSt);
+  NewState = SuccessSt;
 }
   }
+  if (NewState && NewState != State)
+C.addTransition(NewState);
 }
 
 void StdLibraryFunctionsChecker::checkPostCall(const CallEvent ,


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ 

[PATCH] D76790: [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I was thinking about the below test, but then I reverted back because I don't 
want to add "fake" summaries for testing purposes. Perhaps adding a new checker 
option could enable these "fake" summaries, @Szelethus what's your opinion?

  diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  index 64a412bb4db..c1022492429 100644
  --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  @@ -736,6 +736,14 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 };
  
 FunctionSummaryMap = {
  +  {
  +"__test",
  +Summaries{
  +  Summary(ArgTypes{IntTy, IntTy}, RetType{IntTy}, EvalCallAsPure)
  +.ArgConstraint(ArgumentCondition(0U, WithinRange, 
SingleValue(1)))
  +.ArgConstraint(ArgumentCondition(1U, WithinRange, 
SingleValue(1)))
  +}
  +  },
 // The isascii() family of functions.
 // The behavior is undefined if the value of the argument is not
 // representable as unsigned char or is not equal to EOF. See e.g. C99
  diff --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.c 
b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  index a20b90ad1cc..01109e28b99 100644
  --- a/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  +++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
  @@ -85,3 +85,18 @@ void test_notnull_symbolic2(FILE *fp, int *buf) {
   // bugpath-warning{{Function argument constraint is not satisfied}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   }
  +
  +int __test(int, int);
  +
  +void test_multiple_constraints(int x, int y) {
  +  __test(x, y);
  +  clang_analyzer_eval(x == 1); // \
  +  // report-warning{{TRUE}} \
  +  // bugpath-warning{{TRUE}} \
  +  // bugpath-note{{TRUE}}
  +  clang_analyzer_eval(y == 1); // \
  +  // report-warning{{TRUE}} \
  +  // bugpath-warning{{TRUE}} \
  +  // bugpath-note{{TRUE}}
  +}
  +


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76790



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


[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2020-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 252630.
arsenm added a comment.
Herald added a subscriber: kerbowa.

Rebase


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl

Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nodefaultlibs was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nodefaultlibs.
+
+// RUN: %clang -### -nodefaultlibs --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,121 @@
+// REQUIRES: clang-driver
+// REQUIRES: amdgpu-registered-target
+
+// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900 %s
+
+
+
+// Make sure the different denormal default is respected for gfx8
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// Make sure the non-canonical name works
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=fiji \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX803-DEFAULT,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX900 %s
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-denorms-are-zero \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DAZ,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-finite-math-only \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-FINITE-ONLY,GFX803 %s
+
+
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa\
+// RUN:   -x cl -mcpu=gfx803 \
+// RUN:   -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure 

[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-25 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/docs/UsersManual.rst:1683
+   Controls whether Clang emits a unique (best-effort) symbol name for internal
+   linkage symbols. The unique name is obtained by appending the MD5 hash of 
the
+   full module name to the original symbol. This option is particularly useful

Is it necessary to document 'MD5 hash' as it is an implementation detail? 
Perhaps just 'the name hash'



Comment at: clang/docs/UsersManual.rst:1689
+   It should be noted that this option cannot guarantee uniqueness and the
+   following is an example where it is not unique:
+

if the two modules contain symbols with the same private linkage name.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1060
+  const Decl *D = GD.getDecl();
+  if (CGM.getCodeGenOpts().UniqueInternalLinkageNames &&
+  !CGM.getModuleNameHash().empty() &&

is the first check redundant now?


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

https://reviews.llvm.org/D73307



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Lovely, thank you!


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

https://reviews.llvm.org/D73720



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


[clang] c46a0c0 - [clang codegen] Address review comment on comment in constWithPadding.

2020-03-25 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-03-25T10:58:03-07:00
New Revision: c46a0c07a634d85d3fed2ef94747ea19fb4d2d69

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

LOG: [clang codegen] Address review comment on comment in constWithPadding.

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a6417f05a7a6..a9dbdb2e8713 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1075,7 +1075,9 @@ static llvm::Constant *constWithPadding(CodeGenModule 
, IsPattern isPattern,
 auto *NewArrayTy = llvm::ArrayType::get(NewElemTy, Size);
 return llvm::ConstantArray::get(NewArrayTy, Values);
   }
-  // FIXME: Do we need to handle tail padding in vectors?
+  // FIXME: Add handling for tail padding in vectors. Vectors don't
+  // have padding between or inside elements, but the total amount of
+  // data can be less than the allocated size.
   return constant;
 }
 



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


[clang] d788814 - Suppress a few -Wunreachable-code warnings.

2020-03-25 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-03-25T13:55:42-04:00
New Revision: d7888149aa813fb543d562d0891739b1f85f5622

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

LOG: Suppress a few -Wunreachable-code warnings.

No behavior change. Also fix a comment to say match reality.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/TextAPI/MachO/TextStub.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/utils/PerfectShuffle/PerfectShuffle.cpp
llvm/utils/TableGen/CodeGenSchedule.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index b9adee87436a..5405c812faca 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3173,9 +3173,10 @@ std::string ExprEngine::DumpGraph(bool trim, StringRef 
Filename) {
 /*Title=*/"Exploded Graph",
 /*Filename=*/std::string(Filename));
   }
-#endif
+#else
   llvm::errs() << "Warning: dumping graph requires assertions" << "\n";
   return "";
+#endif
 }
 
 std::string ExprEngine::DumpGraph(ArrayRef Nodes,

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 7541bb794c73..908128b0205c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1931,14 +1931,10 @@ Error DWARFContext::loadRegisterInfo(const 
object::ObjectFile ) {
 uint8_t DWARFContext::getCUAddrSize() {
   // In theory, 
diff erent compile units may have 
diff erent address byte
   // sizes, but for simplicity we just use the address byte size of the
-  // last compile unit. In practice the address size field is repeated across
+  // first compile unit. In practice the address size field is repeated across
   // various DWARF headers (at least in version 5) to make it easier to dump
   // them independently, not to enable varying the address size.
-  uint8_t Addr = 0;
-  for (const auto  : compile_units()) {
-Addr = CU->getAddressByteSize();
-break;
-  }
-  return Addr;
+  unit_iterator_range CUs = compile_units();
+  return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize();
 }
 

diff  --git a/llvm/lib/TextAPI/MachO/TextStub.cpp 
b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 5637639b8ef8..3c6c5ac25308 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -450,10 +450,8 @@ template <> struct MappingTraits {
   if (File->isInstallAPI())
 Flags |= TBDFlags::InstallAPI;
 
-  for (const auto  : File->umbrellas()) {
-ParentUmbrella = Iter.second;
-break;
-  }
+  if (!File->umbrellas().empty())
+ParentUmbrella = File->umbrellas().begin()->second;
 
   std::set ArchSet;
   for (const auto  : File->allowableClients())

diff  --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp 
b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index e75327ee53ab..8c2740d8c94d 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -763,7 +763,6 @@ static void extractSlice(ArrayRef> 
InputBinaries,
 reportError("input file " +
 InputBinaries.front().getBinary()->getFileName() +
 " must be a fat file when the -extract option is specified");
-exit(EXIT_FAILURE);
   }
 
   SmallVector, 2> ExtractedObjects;

diff  --git a/llvm/utils/PerfectShuffle/PerfectShuffle.cpp 
b/llvm/utils/PerfectShuffle/PerfectShuffle.cpp
index 0f2e67298404..d941cd685ece 100644
--- a/llvm/utils/PerfectShuffle/PerfectShuffle.cpp
+++ b/llvm/utils/PerfectShuffle/PerfectShuffle.cpp
@@ -423,7 +423,7 @@ int main() {
   }
   std::cout << "  0\n};\n";
 
-  if (0) {
+  LLVM_DEBUG({
 // Print out the table.
 for (unsigned i = 0; i != 0x8889; ++i) {
   if (!isValidMask(i)) continue;
@@ -440,7 +440,7 @@ int main() {
 std::cerr << "\n";
   }
 }
-  }
+  })
 }
 
 

diff  --git a/llvm/utils/TableGen/CodeGenSchedule.cpp 
b/llvm/utils/TableGen/CodeGenSchedule.cpp
index 09cbb234f893..67583c736cd2 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/CodeGenSchedule.cpp
@@ -1082,15 +1082,14 @@ void CodeGenSchedModels::createInstRWClass(Record 
*InstRWDef) {
   for (Record *RWD : RWDefs) {
 if (RWD->getValueAsDef("SchedModel") == RWModelDef &&
 RWModelDef->getValueAsBit("FullInstRWOverlapCheck")) {
-  for (Record *Inst : InstDefs) {
-PrintFatalError
-(InstRWDef->getLoc(),
- "Overlapping InstRW definition for \"" +
- Inst->getName() +
- "\" also matches previous 

[PATCH] D74183: [IRGen] Add an alignment attribute to underaligned sret parameters

2020-03-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If it's just tramp3d-v4, I'm not that concerned... but that's a weird result.  
On x86 in particular, alignment markings have almost no effect on optimization, 
generally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74183



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


  1   2   >