[PATCH] D89844: [Clang][OpenMP] Fixed an issue of segment fault when using target nowait

2020-10-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 300451.
tianshilei1992 added a comment.

Reverted changes for target data. It will be in another patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89844

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9664,11 +9664,10 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9664,11 +9664,10 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 74910cb - HeaderSearch: Simplify use of FileEntryRef in HeaderSearch::LookupFile, NFC

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T22:10:50-04:00
New Revision: 74910cbbd8d1df824ab1d5e742c50641d0fee907

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

LOG: HeaderSearch: Simplify use of FileEntryRef in HeaderSearch::LookupFile, NFC

Simplify `HeaderSearch::LookupFile`. Instead of deconstructing a
`FileEntryRef` into a name and `FileEntry` and then rebuilding it later,
use it as is. This helps to unblock making the constructor of
`FileEntryRef` private to `FileManager`.

Differential Revision:

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 3fd43e0e3aad..50c1fb984206 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -765,8 +765,7 @@ Optional HeaderSearch::LookupFile(
 
   // This is the header that MSVC's header search would have found.
   ModuleMap::KnownHeader MSSuggestedModule;
-  const FileEntry *MSFE_FE = nullptr;
-  StringRef MSFE_Name;
+  Optional MSFE;
 
   // Unless disabled, check to see if the file is in the #includer's
   // directory.  This cannot be based on CurDir, because each includer could be
@@ -841,8 +840,7 @@ Optional HeaderSearch::LookupFile(
 if (Diags.isIgnored(diag::ext_pp_include_search_ms, IncludeLoc)) {
   return FE;
 } else {
-  MSFE_FE = >getFileEntry();
-  MSFE_Name = FE->getName();
+  MSFE = FE;
   if (SuggestedModule) {
 MSSuggestedModule = *SuggestedModule;
 *SuggestedModule = ModuleMap::KnownHeader();
@@ -854,9 +852,6 @@ Optional HeaderSearch::LookupFile(
 }
   }
 
-  Optional MSFE(MSFE_FE ? FileEntryRef(MSFE_Name, *MSFE_FE)
-  : Optional());
-
   CurDir = nullptr;
 
   // If this is a system #include, ignore the user #include locs.



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


[PATCH] D87956: [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

2020-10-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I missed adding to llvm/lib/Bitcode/Reader/BitcodeReader.cpp, so LTO is broken 
with this fn attribute...todo...fix

  diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  index f8069b93103f..a99d6baa8d9d 100644
  --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  @@ -1537,6 +1537,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t 
Code) {
   return Attribute::ByRef;
 case bitc::ATTR_KIND_MUSTPROGRESS:
   return Attribute::MustProgress;
  +  case bitc::ATTR_KIND_NO_STACK_PROTECT:
  +return Attribute::NoStackProtect;
 }
   }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87956

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


[PATCH] D89514: clangd: Stop calling FileEntryRef::FileEntryRef

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith marked an inline comment as done.
dexonsmith added a comment.

Committed in 434f3774f629f5896614e9efb4eda82d813402ed 
.




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:222
   if (File)
 // FIXME: Use correctly named FileEntryRef.
+Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);

arphaman wrote:
> You can drop the FIXME here now.
Good point, fixed.


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

https://reviews.llvm.org/D89514

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


[clang-tools-extra] 434f377 - clangd: Stop calling FileEntryRef::FileEntryRef

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T21:28:09-04:00
New Revision: 434f3774f629f5896614e9efb4eda82d813402ed

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

LOG: clangd: Stop calling FileEntryRef::FileEntryRef

In `ReplayPreamble::replay`, use `getFileRef` instead of `getFile`, and
then use that `FileEntryRef` later to avoid needing
`FileEntryRef::FileEntryRef`. The latter is going to become private to
`FileManager` in a later commit.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index c8096017b50a..6ca9c4f93d16 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -170,10 +170,9 @@ class ReplayPreamble : private PPCallbacks {
 
   void replay() {
 for (const auto  : Includes) {
-  const FileEntry *File = nullptr;
+  llvm::Optional File;
   if (Inc.Resolved != "")
-if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
-  File = *FE;
+File = 
expectedToOptional(SM.getFileManager().getFileRef(Inc.Resolved));
 
   // Re-lex the #include directive to find its interesting parts.
   auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
@@ -211,17 +210,16 @@ class ReplayPreamble : private PPCallbacks {
   SynthesizedFilenameTok.setKind(tok::header_name);
   SynthesizedFilenameTok.setLiteralData(Inc.Written.data());
 
+  const FileEntry *FE = File ? >getFileEntry() : nullptr;
   llvm::StringRef WrittenFilename =
   llvm::StringRef(Inc.Written).drop_front().drop_back();
   Delegate->InclusionDirective(HashTok->location(), SynthesizedIncludeTok,
WrittenFilename, Inc.Written.front() == '<',
-   FileTok->range(SM).toCharRange(SM), File,
+   FileTok->range(SM).toCharRange(SM), FE,
"SearchPath", "RelPath",
/*Imported=*/nullptr, Inc.FileKind);
   if (File)
-// FIXME: Use correctly named FileEntryRef.
-Delegate->FileSkipped(FileEntryRef(File->getName(), *File),
-  SynthesizedFilenameTok, Inc.FileKind);
+Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);
   else {
 llvm::SmallString<1> UnusedRecovery;
 Delegate->FileNotFound(WrittenFilename, UnusedRecovery);



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


[PATCH] D89580: SourceManager: Fix an SLocEntry memory regression introduced with FileEntryRef

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Thanks for the review! @JDevlieghere, let me know if the updated patch looks 
good to you too (also the prep commit).


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

https://reviews.llvm.org/D89580

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


[clang] 81ac81f - FileManager: Reorder declarations of FileEntry and FileEntryRef, NFC

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T20:47:15-04:00
New Revision: 81ac81f8644a7c6ed19bea95385794f7870d0fda

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

LOG: FileManager: Reorder declarations of FileEntry and FileEntryRef, NFC

This reduces noise in a future patch, but shouldn't change anything
otherwise.

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

Added: 


Modified: 
clang/include/clang/Basic/FileManager.h

Removed: 




diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index 089304e1d1e6..8fcea2d5cbf3 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -71,6 +71,37 @@ class DirectoryEntryRef {
   const llvm::StringMapEntry> *Entry;
 };
 
+class FileEntry;
+
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {
+public:
+  FileEntryRef() = delete;
+  FileEntryRef(StringRef Name, const FileEntry )
+  : Name(Name), Entry() {}
+
+  const StringRef getName() const { return Name; }
+  const FileEntry () const { return *Entry; }
+
+  inline bool isValid() const;
+  inline off_t getSize() const;
+  inline unsigned getUID() const;
+  inline const llvm::sys::fs::UniqueID () const;
+  inline time_t getModificationTime() const;
+
+  friend bool operator==(const FileEntryRef , const FileEntryRef ) {
+return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
+  }
+  friend bool operator!=(const FileEntryRef , const FileEntryRef ) {
+return !(LHS == RHS);
+  }
+
+private:
+  StringRef Name;
+  const FileEntry *Entry;
+};
+
 /// Cached information about one file (either on disk
 /// or in the virtual file system).
 ///
@@ -126,41 +157,19 @@ class FileEntry {
   bool isOpenForTests() const { return File != nullptr; }
 };
 
-/// A reference to a \c FileEntry that includes the name of the file as it was
-/// accessed by the FileManager's client.
-class FileEntryRef {
-public:
-  FileEntryRef() = delete;
-  FileEntryRef(StringRef Name, const FileEntry )
-  : Name(Name), Entry() {}
+bool FileEntryRef::isValid() const { return getFileEntry().isValid(); }
 
-  const StringRef getName() const { return Name; }
-
-  bool isValid() const { return Entry->isValid(); }
-
-  const FileEntry () const { return *Entry; }
-
-  off_t getSize() const { return Entry->getSize(); }
+off_t FileEntryRef::getSize() const { return getFileEntry().getSize(); }
 
-  unsigned getUID() const { return Entry->getUID(); }
+unsigned FileEntryRef::getUID() const { return getFileEntry().getUID(); }
 
-  const llvm::sys::fs::UniqueID () const {
-return Entry->getUniqueID();
-  }
+const llvm::sys::fs::UniqueID ::getUniqueID() const {
+  return getFileEntry().getUniqueID();
+}
 
-  time_t getModificationTime() const { return Entry->getModificationTime(); }
-
-  friend bool operator==(const FileEntryRef , const FileEntryRef ) {
-return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
-  }
-  friend bool operator!=(const FileEntryRef , const FileEntryRef ) {
-return !(LHS == RHS);
-  }
-
-private:
-  StringRef Name;
-  const FileEntry *Entry;
-};
+time_t FileEntryRef::getModificationTime() const {
+  return getFileEntry().getModificationTime();
+}
 
 /// Implements support for file system lookup, file system caching,
 /// and directory search management.



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


[PATCH] D89521: FileManager: Reorder declarations of FileEntry and FileEntryRef, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81ac81f8644a: FileManager: Reorder declarations of FileEntry 
and FileEntryRef, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89521

Files:
  clang/include/clang/Basic/FileManager.h


Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/include/clang/Basic/FileManager.h
@@ -71,6 +71,37 @@
   const llvm::StringMapEntry> *Entry;
 };
 
+class FileEntry;
+
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {
+public:
+  FileEntryRef() = delete;
+  FileEntryRef(StringRef Name, const FileEntry )
+  : Name(Name), Entry() {}
+
+  const StringRef getName() const { return Name; }
+  const FileEntry () const { return *Entry; }
+
+  inline bool isValid() const;
+  inline off_t getSize() const;
+  inline unsigned getUID() const;
+  inline const llvm::sys::fs::UniqueID () const;
+  inline time_t getModificationTime() const;
+
+  friend bool operator==(const FileEntryRef , const FileEntryRef ) {
+return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
+  }
+  friend bool operator!=(const FileEntryRef , const FileEntryRef ) {
+return !(LHS == RHS);
+  }
+
+private:
+  StringRef Name;
+  const FileEntry *Entry;
+};
+
 /// Cached information about one file (either on disk
 /// or in the virtual file system).
 ///
@@ -126,41 +157,19 @@
   bool isOpenForTests() const { return File != nullptr; }
 };
 
-/// A reference to a \c FileEntry that includes the name of the file as it was
-/// accessed by the FileManager's client.
-class FileEntryRef {
-public:
-  FileEntryRef() = delete;
-  FileEntryRef(StringRef Name, const FileEntry )
-  : Name(Name), Entry() {}
+bool FileEntryRef::isValid() const { return getFileEntry().isValid(); }
 
-  const StringRef getName() const { return Name; }
-
-  bool isValid() const { return Entry->isValid(); }
-
-  const FileEntry () const { return *Entry; }
-
-  off_t getSize() const { return Entry->getSize(); }
+off_t FileEntryRef::getSize() const { return getFileEntry().getSize(); }
 
-  unsigned getUID() const { return Entry->getUID(); }
+unsigned FileEntryRef::getUID() const { return getFileEntry().getUID(); }
 
-  const llvm::sys::fs::UniqueID () const {
-return Entry->getUniqueID();
-  }
+const llvm::sys::fs::UniqueID ::getUniqueID() const {
+  return getFileEntry().getUniqueID();
+}
 
-  time_t getModificationTime() const { return Entry->getModificationTime(); }
-
-  friend bool operator==(const FileEntryRef , const FileEntryRef ) {
-return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
-  }
-  friend bool operator!=(const FileEntryRef , const FileEntryRef ) {
-return !(LHS == RHS);
-  }
-
-private:
-  StringRef Name;
-  const FileEntry *Entry;
-};
+time_t FileEntryRef::getModificationTime() const {
+  return getFileEntry().getModificationTime();
+}
 
 /// Implements support for file system lookup, file system caching,
 /// and directory search management.


Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/include/clang/Basic/FileManager.h
@@ -71,6 +71,37 @@
   const llvm::StringMapEntry> *Entry;
 };
 
+class FileEntry;
+
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {
+public:
+  FileEntryRef() = delete;
+  FileEntryRef(StringRef Name, const FileEntry )
+  : Name(Name), Entry() {}
+
+  const StringRef getName() const { return Name; }
+  const FileEntry () const { return *Entry; }
+
+  inline bool isValid() const;
+  inline off_t getSize() const;
+  inline unsigned getUID() const;
+  inline const llvm::sys::fs::UniqueID () const;
+  inline time_t getModificationTime() const;
+
+  friend bool operator==(const FileEntryRef , const FileEntryRef ) {
+return LHS.Entry == RHS.Entry && LHS.Name == RHS.Name;
+  }
+  friend bool operator!=(const FileEntryRef , const FileEntryRef ) {
+return !(LHS == RHS);
+  }
+
+private:
+  StringRef Name;
+  const FileEntry *Entry;
+};
+
 /// Cached information about one file (either on disk
 /// or in the virtual file system).
 ///
@@ -126,41 +157,19 @@
   bool isOpenForTests() const { return File != nullptr; }
 };
 
-/// A reference to a \c FileEntry that includes the name of the file as it was
-/// accessed by the FileManager's client.
-class FileEntryRef {
-public:
-  FileEntryRef() = delete;
-  FileEntryRef(StringRef Name, const FileEntry )
-  : Name(Name), Entry() {}
+bool FileEntryRef::isValid() const { return getFileEntry().isValid(); }
 
-  const StringRef 

[PATCH] D89844: [Clang][OpenMP][WIP] Fixed an issue of segment fault when using target nowait

2020-10-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 300443.
tianshilei1992 added a comment.

Fixed the issue using a way that no need to change test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89844

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9664,11 +9664,10 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());
@@ -10518,11 +10517,12 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
+bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());
@@ -10532,7 +10532,7 @@
 Address(Info.SizesArray, CGM.getPointerAlign());
 InputInfo.MappersArray = Address(Info.MappersArray, CGM.getPointerAlign());
 MapTypesArray = Info.MapTypesArray;
-if (HasDependClauses)
+if (RequiresOuterTask)
   CGF.EmitOMPTargetTaskBasedDirective(D, ThenGen, InputInfo);
 else
   emitInlinedDirective(CGF, D.getDirectiveKind(), ThenGen);


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9664,11 +9664,10 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());
@@ -10518,11 +10517,12 @@
 TargetDataInfo Info;
 // Fill up the arrays and create the arguments.
 emitOffloadingArrays(CGF, CombinedInfo, Info);
-bool HasDependClauses = D.hasClausesOfKind();
+bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
 emitOffloadingArraysArgument(CGF, Info.BasePointersArray,
  Info.PointersArray, Info.SizesArray,
  Info.MapTypesArray, Info.MappersArray, Info,
- {/*ForEndTask=*/false, HasDependClauses});
+ {/*ForEndTask=*/false, RequiresOuterTask});
 InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
 InputInfo.BasePointersArray =
 Address(Info.BasePointersArray, CGM.getPointerAlign());
@@ -10532,7 +10532,7 @@
 Address(Info.SizesArray, CGM.getPointerAlign());
 InputInfo.MappersArray = Address(Info.MappersArray, CGM.getPointerAlign());
 MapTypesArray = Info.MapTypesArray;
-if (HasDependClauses)
+if (RequiresOuterTask)
   CGF.EmitOMPTargetTaskBasedDirective(D, ThenGen, InputInfo);
 else
   emitInlinedDirective(CGF, D.getDirectiveKind(), ThenGen);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89072: [CodeView] Emit static data members as S_CONSTANTs.

2020-10-23 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 300438.
akhuang added a comment.

Fix test failures; remove assert for signed APSInts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89072

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-static-member.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
  llvm/test/DebugInfo/COFF/global-constants.ll
  llvm/test/DebugInfo/COFF/types-array-unsized.ll

Index: llvm/test/DebugInfo/COFF/types-array-unsized.ll
===
--- llvm/test/DebugInfo/COFF/types-array-unsized.ll
+++ llvm/test/DebugInfo/COFF/types-array-unsized.ll
@@ -12,14 +12,22 @@
 ; Foo f; // FIXME: only needed to force emit 'Foo'
 
 ; CHECK:  CodeViewTypes [
+; CHECK:Array ([[ARRAY_COMPLETE:0x.*]]) {
+; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
+; CHECK-NEXT: ElementType: const char ({{.*}})
+; CHECK-NEXT: IndexType: unsigned __int64 (0x23)
+; CHECK-NEXT: SizeOf: 5
+; CHECK-NEXT: Name:
+; CHECK-NEXT:   }
+; CHECK:  ]
 ; CHECK:Array ([[ARRAY_FWD:0x.*]]) {
 ; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
 ; CHECK-NEXT: ElementType: const char ({{.*}})
 ; CHECK-NEXT: IndexType: unsigned __int64 (0x23)
 ; CHECK-NEXT: SizeOf: 0
-; CHECK-NEXT: Name: 
+; CHECK-NEXT: Name:
 ; CHECK-NEXT:   }
-; CHECK:FieldList (0x1003) {
+; CHECK:FieldList (0x1004) {
 ; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203)
 ; CHECK-NEXT: StaticDataMember {
 ; CHECK-NEXT:   TypeLeafKind: LF_STMEMBER (0x150E)
@@ -28,14 +36,6 @@
 ; CHECK-NEXT:   Name: str
 ; CHECK-NEXT: }
 ; CHECK-NEXT:   }
-; CHECK:Array ([[ARRAY_COMPLETE:0x.*]]) {
-; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
-; CHECK-NEXT: ElementType: const char ({{.*}})
-; CHECK-NEXT: IndexType: unsigned __int64 (0x23)
-; CHECK-NEXT: SizeOf: 5
-; CHECK-NEXT: Name: 
-; CHECK-NEXT:   }
-; CHECK:  ]
 
 ; CHECK:  GlobalData {
 ; CHECK-NEXT:   Kind: S_GDATA32 (0x110D)
Index: llvm/test/DebugInfo/COFF/global-constants.ll
===
--- llvm/test/DebugInfo/COFF/global-constants.ll
+++ llvm/test/DebugInfo/COFF/global-constants.ll
@@ -7,6 +7,9 @@
 ; }
 ; struct S {
 ;   static const int TestConst2 = -10;
+;   // Unused static consts should still be emitted.
+;   static const int TestConst3 = 3;
+;   static constexpr int TestConst 4 = 4;
 ;   enum { SEnum = 42 };
 ; };
 ; enum TestEnum : int {
@@ -34,14 +37,6 @@
 
 ; ASM:	  .short	4359# Record kind: S_CONSTANT
 ; ASM-NEXT:	  .long	4101# Type
-; ASM-NEXT:	  .byte	0x0a, 0x80, 0xf6, 0xff  # Value
-; ASM-NEXT:	  .byte	0xff, 0xff, 0xff, 0xff
-; ASM-NEXT:	  .byte	0xff, 0xff
-; ASM-NEXT:	  .asciz	"S::TestConst2" # Name
-; ASM-NEXT:	  .p2align	2
-
-; ASM:	  .short	4359# Record kind: S_CONSTANT
-; ASM-NEXT:	  .long	4110# Type
 ; ASM-NEXT:	  .byte	0x0a, 0x80, 0x40, 0x61  # Value
 ; ASM-NEXT:	  .byte	0x07, 0x80, 0xff, 0xff
 ; ASM-NEXT:	  .byte	0xff, 0xff
@@ -49,6 +44,12 @@
 ; ASM-NEXT:	  .p2align	2
 ; ASM-NOT:.asciz "S::SEnum" # Name
 
+; ASM:	  .short	4359# Record kind: S_CONSTANT
+; ASM-NEXT:	  .long	4105# Type
+; ASM-NEXT:	  .byte	0x00, 0x80, 0xf6# Value
+; ASM-NEXT:	  .asciz	"S::TestConst2" # Name
+; ASM-NEXT:	  .p2align	2
+
 ; OBJ:CodeViewDebugInfo [
 ; OBJ:  Section: .debug$S
 ; OBJ:  Magic: 0x4
@@ -62,17 +63,17 @@
 ; OBJ-NEXT:   }
 ; OBJ-NEXT:   ConstantSym {
 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
-; OBJ-NEXT: Type: const int (0x1005)
-; OBJ-NEXT: Value: 18446744073709551606
-; OBJ-NEXT: Name: S::TestConst2
-; OBJ-NEXT:   }
-; OBJ-NEXT:   ConstantSym {
-; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
-; OBJ-NEXT: Type: TestEnum (0x100E)
+; OBJ-NEXT: Type: TestEnum (0x1005)
 ; OBJ-NEXT: Value: 18446744071562551616
 ; OBJ-NEXT: Name: ENUM_B
 ; OBJ-NEXT:   }
 ; OBJ-NOT:  Name: S::SEnum
+; OBJ-NEXT:   ConstantSym {
+; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT: Type: const int (0x1009)
+; OBJ-NEXT: Value: -10
+; OBJ-NEXT: Name: S::TestConst2
+; OBJ-NEXT:   }
 
 ; ModuleID = 'a.cpp'
 source_filename = "a.cpp"
@@ -98,43 +99,43 @@
 !llvm.module.flags = !{!26, !27, !28, !29}
 !llvm.ident = !{!30}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, 

[PATCH] D89514: clangd: Stop calling FileEntryRef::FileEntryRef

2020-10-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM with a nit.




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:222
   if (File)
 // FIXME: Use correctly named FileEntryRef.
+Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);

You can drop the FIXME here now.


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

https://reviews.llvm.org/D89514

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


[clang] ccca93b - Don't allow structured binding declarations to decompose a

2020-10-23 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-23T16:28:25-07:00
New Revision: ccca93b5a2cb284dcdfecd34db1ca14632d6a1c1

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

LOG: Don't allow structured binding declarations to decompose a
lambda-expression's captures.

The built-in structured binding rules for classes require that all
fields can be accessed by name, and the fields introduced for lambda
captures are unnamed, so decomposing a capturing lambda is ill-formed.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/cxx1z-decomposition.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 641d3e73905e..1aa6064d2210 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -486,6 +486,8 @@ def err_decomp_decl_inaccessible_base : Error<
 def err_decomp_decl_inaccessible_field : Error<
   "cannot decompose %select{private|protected}0 member %1 of %3">,
   AccessControl;
+def err_decomp_decl_lambda : Error<
+  "cannot decompose lambda closure type">;
 def err_decomp_decl_anon_union_member : Error<
   "cannot decompose class type %0 because it has an anonymous "
   "%select{struct|union}1 member">;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 72dfa37c321e..6589b37338e9 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1374,11 +1374,23 @@ static bool checkMemberDecomposition(Sema , 
ArrayRef Bindings,
 if (FD->isUnnamedBitfield())
   continue;
 
-if (FD->isAnonymousStructOrUnion()) {
-  S.Diag(Src->getLocation(), diag::err_decomp_decl_anon_union_member)
-<< DecompType << FD->getType()->isUnionType();
-  S.Diag(FD->getLocation(), diag::note_declared_at);
-  return true;
+// All the non-static data members are required to be nameable, so they
+// must all have names.
+if (!FD->getDeclName()) {
+  if (RD->isLambda()) {
+S.Diag(Src->getLocation(), diag::err_decomp_decl_lambda);
+S.Diag(RD->getLocation(), diag::note_lambda_decl);
+return true;
+  }
+
+  if (FD->isAnonymousStructOrUnion()) {
+S.Diag(Src->getLocation(), diag::err_decomp_decl_anon_union_member)
+  << DecompType << FD->getType()->isUnionType();
+S.Diag(FD->getLocation(), diag::note_declared_at);
+return true;
+  }
+
+  // FIXME: Are there any other ways we could have an anonymous member?
 }
 
 // We have a real field to bind.

diff  --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index 336c103ef0a4..45a062a916f3 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -103,4 +103,49 @@ int f2() {
 
 } // namespace instantiate_template
 
+namespace lambdas {
+  void f() {
+int n;
+auto [a] =  // expected-error {{cannot decompose lambda closure type}}
+[n] {}; // expected-note {{lambda expression}}
+  }
+
+  auto [] = []{}; // expected-warning {{ISO C++17 does not allow a 
decomposition group to be empty}}
+
+  int g() {
+int n = 0;
+auto a = [=](auto ) { // expected-note {{lambda expression}}
+  auto &[capture] = self; // expected-error {{cannot decompose lambda 
closure type}}
+  ++capture;
+  return n;
+};
+return a(a); // expected-note {{in instantiation of}}
+  }
+
+  int h() {
+auto x = [] {};
+struct A : decltype(x) {
+  int n;
+};
+auto &&[r] = A{x, 0}; // OK (presumably), non-capturing lambda has no 
non-static data members
+return r;
+  }
+
+  int i() {
+int n;
+auto x = [n] {};
+struct A : decltype(x) {
+  int n;
+};
+auto &&[r] = A{x, 0}; // expected-error-re {{cannot decompose class type 
'A': both it and its base class 'decltype(x)' (aka '(lambda {{.*}})') have 
non-static data members}}
+return r;
+  }
+
+  void j() {
+auto x = [] {};
+struct A : decltype(x) {};
+auto &&[] = A{x}; // expected-warning {{ISO C++17 does not allow a 
decomposition group to be empty}}
+  }
+}
+
 // FIXME: by-value array copies



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


[PATCH] D89072: [CodeView] Emit static data members as S_CONSTANTs.

2020-10-23 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added a comment.

Whoops, forgot to check the tests. Apparently `mapEncodedInteger` asserts if a 
signed APInt is not less than 0. I just removed the assert because it doesn't 
seem necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89072

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


[PATCH] D90079: CGLoopInfo: Avoid unnecessary uses of `MDNode::getTemporary`, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

BTW, this is a long-delayed follow-up to 
5e5b85098dbeaea2cfa5d01695b5d2982634d7dd.


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

https://reviews.llvm.org/D90079

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


[PATCH] D90079: CGLoopInfo: Avoid unnecessary uses of `MDNode::getTemporary`, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/Metadata.cpp#L716 
is where the auto-detection of self-references is:

  // Drop uniquing for self-reference cycles and deleted constants.
  if (New == this || (!New && Old && isa(Old))) {
if (!isResolved())
  resolve();
storeDistinctInContext();
return;
  }


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

https://reviews.llvm.org/D90079

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


[PATCH] D90079: CGLoopInfo: Avoid unnecessary uses of `MDNode::getTemporary`, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: dblaikie, aprantl.
Herald added a reviewer: bollu.
Herald added subscribers: ributzka, hiraditya, kristof.beyls.
Herald added a project: LLVM.
dexonsmith requested review of this revision.

`TempMDNode` includes a bunch of machinery for RAUW, and should only be
used when necessary. RAUW wasn't being used in any of these cases... it
was just a placeholder for a self-reference.

Where the real node was using `MDNode::getDistinct`, just replace the
temporary argument with `nullptr`.

Where the real node was using `MDNode::get`, the `replaceOperandWith`
call was "promoting" the node to a distinct one implicitly due to
self-reference detection in `MDNode::handleChangedOperand`. The
`TempMDNode` was serving a purpose by delaying uniquing, but it's way
simpler to just call `MDNode::getDistinct` in the first place.

Note that using a self-reference at all in these places is a hold-over
from before `distinct` metadata existed. It was an old trick to create
distinct nodes. It would be intrusive to change, including bitcode
upgrades, etc., and it's harmless so I'm not sure there's much value in
removing it from existing schemas. After this commit it still has a tiny
memory cost (in the extra metadata operand) but no more overhead in
construction.


https://reviews.llvm.org/D90079

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  polly/lib/CodeGen/IRBuilder.cpp

Index: polly/lib/CodeGen/IRBuilder.cpp
===
--- polly/lib/CodeGen/IRBuilder.cpp
+++ polly/lib/CodeGen/IRBuilder.cpp
@@ -26,24 +26,22 @@
 ///
 /// The MDNode looks like this (if arg0/arg1 are not null):
 ///
-///'!n = metadata !{metadata !n, arg0, arg1}'
+///'!n = distinct !{!n, arg0, arg1}'
 ///
 /// @return The self referencing id metadata node.
 static MDNode *getID(LLVMContext , Metadata *arg0 = nullptr,
  Metadata *arg1 = nullptr) {
   MDNode *ID;
   SmallVector Args;
-  // Use a temporary node to safely create a unique pointer for the first arg.
-  auto TempNode = MDNode::getTemporary(Ctx, None);
   // Reserve operand 0 for loop id self reference.
-  Args.push_back(TempNode.get());
+  Args.push_back(nullptr);
 
   if (arg0)
 Args.push_back(arg0);
   if (arg1)
 Args.push_back(arg1);
 
-  ID = MDNode::get(Ctx, Args);
+  ID = MDNode::getDistinct(Ctx, Args);
   ID->replaceOperandWith(0, ID);
   return ID;
 }
Index: llvm/lib/IR/MDBuilder.cpp
===
--- llvm/lib/IR/MDBuilder.cpp
+++ llvm/lib/IR/MDBuilder.cpp
@@ -151,24 +151,20 @@
 }
 
 MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) {
-  // To ensure uniqueness the root node is self-referential.
-  auto Dummy = MDNode::getTemporary(Context, None);
-
-  SmallVector Args(1, Dummy.get());
+  SmallVector Args(1, nullptr);
   if (Extra)
 Args.push_back(Extra);
   if (!Name.empty())
 Args.push_back(createString(Name));
-  MDNode *Root = MDNode::get(Context, Args);
+  MDNode *Root = MDNode::getDistinct(Context, Args);
 
   // At this point we have
-  //   !0 = metadata !{}<- dummy
-  //   !1 = metadata !{metadata !0} <- root
-  // Replace the dummy operand with the root node itself and delete the dummy.
+  //   !0 = distinct !{null} <- root
+  // Replace the reserved operand with the root node itself.
   Root->replaceOperandWith(0, Root);
 
   // We now have
-  //   !1 = metadata !{metadata !1} <- self-referential root
+  //   !0 = distinct !{!0} <- root
   return Root;
 }
 
Index: llvm/lib/Analysis/LoopInfo.cpp
===
--- llvm/lib/Analysis/LoopInfo.cpp
+++ llvm/lib/Analysis/LoopInfo.cpp
@@ -1017,8 +1017,7 @@
   SmallVector MDs;
 
   // Reserve first location for self reference to the LoopID metadata node.
-  TempMDTuple TempNode = MDNode::getTemporary(Context, None);
-  MDs.push_back(TempNode.get());
+  MDs.push_back(nullptr);
 
   // Remove metadata for the transformation that has been applied or that became
   // outdated.
Index: clang/lib/CodeGen/CGLoopInfo.cpp
===
--- clang/lib/CodeGen/CGLoopInfo.cpp
+++ clang/lib/CodeGen/CGLoopInfo.cpp
@@ -24,8 +24,7 @@
 LoopInfo::createLoopPropertiesMetadata(ArrayRef LoopProperties) {
   LLVMContext  = Header->getContext();
   SmallVector NewLoopProperties;
-  TempMDTuple TempNode = MDNode::getTemporary(Ctx, None);
-  NewLoopProperties.push_back(TempNode.get());
+  NewLoopProperties.push_back(nullptr);
   NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end());
 
   MDNode *LoopID = MDNode::getDistinct(Ctx, NewLoopProperties);
@@ -58,8 +57,7 @@
   }
 
   SmallVector Args;
-  TempMDTuple TempNode = MDNode::getTemporary(Ctx, None);
-  Args.push_back(TempNode.get());
+  Args.push_back(nullptr);
   

[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2020-10-23 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 300421.
DiggerLin added a comment.

delete asm test case from clang/test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,43 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -fvisibility-inlines-hidden \ 
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+// COMMON-IR-NEXT:  entry:
+// COMMON-IR-NEXT:store i32 55, i32* @x, align 4
+// COMMON-IR-NEXT:ret void
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
+// COMMON-IR-NEXT:  entry:
+// COMMON-IR-NEXT:store i32 55, i32* @x, align 4
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,24 +1,10 @@
 // REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
@@ -70,28 +56,12 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z5foo_hPi,hidden
-// VISIBILITY-ASM: .globl  _Z3barv[DS],protected
-// VISIBILITY-ASM: .globl  ._Z3barv,protected
-// VISIBILITY-ASM: .weak   _ZNK9TestClass5valueEv[DS],hidden
-// VISIBILITY-ASM: .weak   ._ZNK9TestClass5valueEv,hidden
-// VISIBILITY-ASM: .weak   _ZN5basicIiE7getdataEv[DS],protected
-// VISIBILITY-ASM: .weak   ._ZN5basicIiE7getdataEv,protected
-// VISIBILITY-ASM: .globl  _Z7prambarv[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z7prambarv,hidden
-// VISIBILITY-ASM: .globl  b,protected
-// VISIBILITY-ASM: .globl  pramb,hidden
-
-// IGNOREVISIBILITY-ASM: .globl  _Z5foo_hPi[DS]
-// IGNOREVISIBILITY-ASM: .globl  ._Z5foo_hPi
-// 

[clang] 71e1a56 - [CodeGen] Emit destructor calls to destruct non-trivial C struct

2020-10-23 Thread via cfe-commits

Author: Akira Hatanaka
Date: 2020-10-23T14:46:17-07:00
New Revision: 71e1a56de153536b9ff655fe740ccbf3f6b1faf0

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

LOG: [CodeGen] Emit destructor calls to destruct non-trivial C struct
temporaries created by conditional and assignment operators

rdar://problem/64989559

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprAgg.cpp
clang/test/CodeGenObjC/strong-in-c-struct.m

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 9106b90525db..60ea1b2af037 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1216,6 +1216,11 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator 
*E) {
 
   // Copy into the destination if the assignment isn't ignored.
   EmitFinalDestCopy(E->getType(), LHS);
+
+  if (!Dest.isIgnored() && !Dest.isExternallyDestructed() &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
 }
 
 void AggExprEmitter::
@@ -1233,6 +1238,11 @@ VisitAbstractConditionalOperator(const 
AbstractConditionalOperator *E) {
 
   // Save whether the destination's lifetime is externally managed.
   bool isExternallyDestructed = Dest.isExternallyDestructed();
+  bool destructNonTrivialCStruct =
+  !isExternallyDestructed &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct;
+  isExternallyDestructed |= destructNonTrivialCStruct;
+  Dest.setExternallyDestructed(isExternallyDestructed);
 
   eval.begin(CGF);
   CGF.EmitBlock(LHSBlock);
@@ -1254,6 +1264,10 @@ VisitAbstractConditionalOperator(const 
AbstractConditionalOperator *E) {
   Visit(E->getFalseExpr());
   eval.end(CGF);
 
+  if (destructNonTrivialCStruct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
+
   CGF.EmitBlock(ContBlock);
 }
 

diff  --git a/clang/test/CodeGenObjC/strong-in-c-struct.m 
b/clang/test/CodeGenObjC/strong-in-c-struct.m
index f0227119279f..4e098c352ab5 100644
--- a/clang/test/CodeGenObjC/strong-in-c-struct.m
+++ b/clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -95,12 +95,13 @@ + (StrongSmall)getStrongSmallClass;
 @end
 
 id g0;
+StrongSmall g1, g2;
 
+// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, 
double }
 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
 // CHECK: %[[STRUCT_BLOCK_BYREF_T:.*]] = type { i8*, 
%[[STRUCT_BLOCK_BYREF_T]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_STRONGOUTER]] }
-// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGBLOCK:.*]] = type { void ()* }
 // CHECK: %[[STRUCT_BITFIELD1:.*]] = type { i8, i8, i8*, i32, i8*, [3 x i32], 
i8*, double, i8, i8 }
 
@@ -900,4 +901,47 @@ void test_zero_bitfield() {
   a = b;
 }
 
+// CHECK-LABEL: define i8* @test_conditional0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+
+// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** bitcast 
(%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+
+// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V2]], i8** bitcast 
(%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
+
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V5]])
+// CHECK: @llvm.objc.autoreleaseReturnValue
+
+id test_conditional0(int c) {
+  return (c ? g2 : g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_conditional1(
+// CHECK-NOT: call void @__destructor
+
+id test_conditional1(int c) {
+  calleeStrongSmall(c ? g2 : g1);
+}
+
+// CHECK-LABEL: define i8* @test_assignment0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** bitcast 
(%[[STRUCT_STRONGSMALL]]* @g2 to i8**), i8** bitcast (%[[STRUCT_STRONGSMALL]]* 
@g1 to i8**))
+// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V0]], i8** bitcast 
(%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+
+id test_assignment0(void) {
+  return (g2 = g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_assignment1(
+// CHECK-NOT: call void @__destructor
+
+id test_assignment1(void) {
+  calleeStrongSmall(g2 = g1);
+}
+
 

[PATCH] D83448: [CodeGen] Emit destructor calls to destruct non-trivial C struct temporaries created by conditional and assignment operators

2020-10-23 Thread Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71e1a56de153: [CodeGen] Emit destructor calls to destruct 
non-trivial C struct (authored by ahatanak, committed by --local 
ahatan...@apple.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83448

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenObjC/strong-in-c-struct.m

Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -95,12 +95,13 @@
 @end
 
 id g0;
+StrongSmall g1, g2;
 
+// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double }
 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
 // CHECK: %[[STRUCT_BLOCK_BYREF_T:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_T]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_STRONGOUTER]] }
-// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGBLOCK:.*]] = type { void ()* }
 // CHECK: %[[STRUCT_BITFIELD1:.*]] = type { i8, i8, i8*, i32, i8*, [3 x i32], i8*, double, i8, i8 }
 
@@ -900,4 +901,47 @@
   a = b;
 }
 
+// CHECK-LABEL: define i8* @test_conditional0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+
+// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+
+// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V2]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
+
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V5]])
+// CHECK: @llvm.objc.autoreleaseReturnValue
+
+id test_conditional0(int c) {
+  return (c ? g2 : g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_conditional1(
+// CHECK-NOT: call void @__destructor
+
+id test_conditional1(int c) {
+  calleeStrongSmall(c ? g2 : g1);
+}
+
+// CHECK-LABEL: define i8* @test_assignment0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**), i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
+// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V0]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+
+id test_assignment0(void) {
+  return (g2 = g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_assignment1(
+// CHECK-NOT: call void @__destructor
+
+id test_assignment1(void) {
+  calleeStrongSmall(g2 = g1);
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1216,6 +1216,11 @@
 
   // Copy into the destination if the assignment isn't ignored.
   EmitFinalDestCopy(E->getType(), LHS);
+
+  if (!Dest.isIgnored() && !Dest.isExternallyDestructed() &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
 }
 
 void AggExprEmitter::
@@ -1233,6 +1238,11 @@
 
   // Save whether the destination's lifetime is externally managed.
   bool isExternallyDestructed = Dest.isExternallyDestructed();
+  bool destructNonTrivialCStruct =
+  !isExternallyDestructed &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct;
+  isExternallyDestructed |= destructNonTrivialCStruct;
+  Dest.setExternallyDestructed(isExternallyDestructed);
 
   eval.begin(CGF);
   CGF.EmitBlock(LHSBlock);
@@ -1254,6 +1264,10 @@
   Visit(E->getFalseExpr());
   eval.end(CGF);
 
+  if (destructNonTrivialCStruct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
+
   CGF.EmitBlock(ContBlock);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cb9b984 - PR47954 / DR2126: permit temporary objects that are lifetime-extended by

2020-10-23 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-23T14:29:18-07:00
New Revision: cb9b9842d31d6082c6a2259a64eb5d47bd680d32

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

LOG: PR47954 / DR2126: permit temporary objects that are lifetime-extended by
variables that are usable in constant expressions to themselves be
usable in constant expressions.

Added: 


Modified: 
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/drs/dr21xx.cpp
clang/test/CodeGenCXX/const-init-cxx11.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 61a23ddaa368..2144279f132b 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4519,6 +4519,10 @@ class MaterializeTemporaryExpr : public Expr {
 return getValueKind() == VK_LValue;
   }
 
+  /// Determine whether this temporary object is usable in constant
+  /// expressions, as specified in C++20 [expr.const]p4.
+  bool isUsableInConstantExpressions(const ASTContext ) const;
+
   SourceLocation getBeginLoc() const LLVM_READONLY {
 return getSubExpr()->getBeginLoc();
   }

diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index c1ec86075772..b7f677051ea2 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1647,6 +1647,20 @@ void 
MaterializeTemporaryExpr::setExtendingDecl(ValueDecl *ExtendedBy,
   ES->ManglingNumber = ManglingNumber;
 }
 
+bool MaterializeTemporaryExpr::isUsableInConstantExpressions(
+const ASTContext ) const {
+  // C++20 [expr.const]p4:
+  //   An object or reference is usable in constant expressions if it is [...]
+  //   a temporary object of non-volatile const-qualified literal type
+  //   whose lifetime is extended to that of a variable that is usable
+  //   in constant expressions
+  auto *VD = dyn_cast_or_null(getExtendingDecl());
+  return VD && getType().isConstant(Context) &&
+ !getType().isVolatileQualified() &&
+ getType()->isLiteralType(Context) &&
+ VD->isUsableInConstantExpressions(Context);
+}
+
 TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
  ArrayRef Args,
  SourceLocation RParenLoc, bool Value)

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b33ce14b3658..fa666930ef1d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4093,27 +4093,32 @@ static CompleteObject findCompleteObject(EvalInfo 
, const Expr *E,
 assert(MTE->getStorageDuration() == SD_Static &&
"should have a frame for a non-global materialized temporary");
 
-// Per C++1y [expr.const]p2:
+// C++20 [expr.const]p4: [DR2126]
+//   An object or reference is usable in constant expressions if it is
+//   - a temporary object of non-volatile const-qualified literal type
+// whose lifetime is extended to that of a variable that is usable
+// in constant expressions
+//
+// C++20 [expr.const]p5:
 //  an lvalue-to-rvalue conversion [is not allowed unless it applies 
to]
-//   - a [...] glvalue of integral or enumeration type that refers to
-// a non-volatile const object [...]
-//   [...]
-//   - a [...] glvalue of literal type that refers to a non-volatile
-// object whose lifetime began within the evaluation of e.
+//   - a non-volatile glvalue that refers to an object that is usable
+// in constant expressions, or
+//   - a non-volatile glvalue of literal type that refers to a
+// non-volatile object whose lifetime began within the evaluation
+// of E;
 //
 // C++11 misses the 'began within the evaluation of e' check and
 // instead allows all temporaries, including things like:
 //   int & = 1;
 //   int x = ++r;
 //   constexpr int k = r;
-// Therefore we use the C++14 rules in C++11 too.
+// Therefore we use the C++14-onwards rules in C++11 too.
 //
 // Note that temporaries whose lifetimes began while evaluating a
 // variable's constructor are not usable while evaluating the
 // corresponding destructor, not even if they're of const-qualified
 // types.
-if (!(BaseType.isConstQualified() &&
-  BaseType->isIntegralOrEnumerationType()) &&
+if (!MTE->isUsableInConstantExpressions(Info.Ctx) &&
 !lifetimeStartedInEvaluation(Info, LVal.Base)) {
   if 

[PATCH] D83812: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs

2020-10-23 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 300410.
leonardchan retitled this revision from "[clang][RelativeVTablesABI] Do not 
emit stubs for architectures that support a PLT relocation" to 
"[clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting 
stubs".
leonardchan edited the summary of this revision.
leonardchan added a comment.

Update to use `dso_local_equivalent` instead of emitting stubs in the frontend. 
`dso_local_equivalent` should emit a stub automatically if one is required for 
the target (ie. it does not support PLTs).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83812

Files:
  clang/lib/CodeGen/CGVTables.cpp
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Index: clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
@@ -6,8 +6,6 @@
 // CHECK: %class.B = type { %class.A }
 // CHECK: %"class.std::type_info" = type { i32 (...)**, i8* }
 
-// CHECK: $_ZN1A3fooEv.stub = comdat any
-// CHECK: $_ZN1B3fooEv.stub = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
Index: clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// If the linkage of the class is internal, then the stubs and proxies should
-// also be internally linked.
-
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
-
-// External linkage.
-// CHECK: @_ZTI8External.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI8External, comdat
-
-class External {
-public:
-  virtual void func();
-};
-
-void External::func() {}
-
-// Internal linkage.
-// CHECK: @_ZTIN12_GLOBAL__N_18InternalE.rtti_proxy = internal unnamed_addr constant { i8*, i8* }* @_ZTIN12_GLOBAL__N_18InternalE
-namespace {
-
-class Internal {
-public:
-  virtual void func();
-};
-
-void Internal::func() {}
-
-} // namespace
-
-// This gets the same treatment as an externally available vtable.
-// CHECK: @_ZTI11LinkOnceODR.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI11LinkOnceODR, comdat
-class LinkOnceODR {
-public:
-  virtual void func() {} // A method defined in the class definition results in this linkage for the vtable.
-};
-
-// Force an emission of a vtable for Internal by using it here.
-void manifest_internal() {
-  Internal internal;
-  (void)internal;
-  LinkOnceODR linkonceodr;
-  (void)linkonceodr;
-}
-
-// Aliases are typically emitted after the vtable definitions but before the
-// function definitions.
-// CHECK: @_ZTV8External = unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV8External.local
-// CHECK: @_ZTV11LinkOnceODR = linkonce_odr unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV11LinkOnceODR.local
-
-// CHECK: define void @_ZN8External4funcEv
-// CHECK: define internal void @_ZN12_GLOBAL__N_18Internal4funcEv.stub
-// CHECK: define hidden void @_ZN11LinkOnceODR4funcEv.stub
Index: clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
@@ -2,35 +2,23 @@
 
 // RUN: 

[PATCH] D81508: [PowerPC] Add __vector_pair and __vector_quad types

2020-10-23 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 300408.
bsaleil added a comment.
Herald added a subscriber: dexonsmith.

Rebasing the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81508

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/PPCTypes.def
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/AST/ast-dump-ppc-mma-types.c
  clang/test/CodeGen/ppc-mma-types.c
  clang/test/CodeGenCXX/ppc-mangle-mma-types.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1546,6 +1546,8 @@
   case BuiltinType::OCLReserveID:
 #define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/AArch64SVEACLETypes.def"
+#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
+#include "clang/Basic/PPCTypes.def"
 #define BUILTIN_TYPE(Id, SingletonId)
 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
Index: clang/test/CodeGenCXX/ppc-mangle-mma-types.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ppc-mangle-mma-types.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu future %s \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+// CHECK: _Z2f1Pu13__vector_quad
+void f1(__vector_quad *vq) {}
+
+// CHECK: _Z2f2Pu13__vector_pair
+void f2(__vector_pair *vp) {}
+
+// CHECK: _Z2f3Pu13__vector_quad
+void f3(__vector_quad *vq) {}
+
+// CHECK: _Z2f3Pu13__vector_pair
+void f3(__vector_pair *vp) {}
Index: clang/test/CodeGen/ppc-mma-types.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc-mma-types.c
@@ -0,0 +1,27 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu future \
+// RUN:   -emit-llvm -O3 -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds <512 x i1>, <512 x i1>* [[PTR1:%.*]], i64 2
+// CHECK-NEXT:[[TMP0:%.*]] = load <512 x i1>, <512 x i1>* [[ADD_PTR]], align 64, [[TBAA2:!tbaa !.*]]
+// CHECK-NEXT:[[ADD_PTR1:%.*]] = getelementptr inbounds <512 x i1>, <512 x i1>* [[PTR2:%.*]], i64 1
+// CHECK-NEXT:store <512 x i1> [[TMP0]], <512 x i1>* [[ADD_PTR1]], align 64, [[TBAA2]]
+// CHECK-NEXT:ret void
+//
+void test1(__vector_quad *ptr1, __vector_quad *ptr2) {
+  *(ptr2 + 1) = *(ptr1 + 2);
+}
+
+// CHECK-LABEL: @test2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds <256 x i1>, <256 x i1>* [[PTR1:%.*]], i64 2
+// CHECK-NEXT:[[TMP0:%.*]] = load <256 x i1>, <256 x i1>* [[ADD_PTR]], align 32, [[TBAA6:!tbaa !.*]]
+// CHECK-NEXT:[[ADD_PTR1:%.*]] = getelementptr inbounds <256 x i1>, <256 x i1>* [[PTR2:%.*]], i64 1
+// CHECK-NEXT:store <256 x i1> [[TMP0]], <256 x i1>* [[ADD_PTR1]], align 32, [[TBAA6]]
+// CHECK-NEXT:ret void
+//
+void test2(__vector_pair *ptr1, __vector_pair *ptr2) {
+  *(ptr2 + 1) = *(ptr1 + 2);
+}
Index: clang/test/AST/ast-dump-ppc-mma-types.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-ppc-mma-types.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -target-feature -mma -ast-dump %s | FileCheck %s \
+// RUN:   --check-prefix=CHECK-NO-MMA
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr9 \
+// RUN:   -ast-dump %s | FileCheck %s --check-prefix=CHECK-PWR9
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck %s \
+// RUN:   --check-prefix=CHECK-X86_64
+// RUN: %clang_cc1 -triple arm-unknown-unknown -ast-dump %s | FileCheck %s \
+// RUN:   --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -triple riscv64-unknown-unknown -ast-dump %s | FileCheck %s \
+// RUN:   --check-prefix=CHECK-RISCV64
+
+// This test case checks that 

[PATCH] D89608: Make sure Objective-C category support in IncludeSorter handles top-level imports

2020-10-23 Thread Joe Turner via Phabricator via cfe-commits
compositeprimes updated this revision to Diff 300402.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89608

Files:
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -133,7 +133,7 @@
  utils::IncludeSorter::IS_Google_ObjC) {}
 
   std::vector headersToInclude() const override {
-return {"clang_tidy/tests/insert_includes_test_header+foo.h"};
+return {"top_level_test_header+foo.h"};
   }
 };
 
@@ -158,6 +158,10 @@
   {"clang_tidy/tests/"
"insert_includes_test_header.h",
"\n"},
+  // Top-level main file include +
+  // category.
+  {"top_level_test_header.h", "\n"},
+  {"top_level_test_header+foo.h", "\n"},
   // ObjC category.
   {"clang_tidy/tests/"
"insert_includes_test_header+foo.h",
@@ -708,14 +712,14 @@
 
 TEST(IncludeInserterTest, InsertCategoryHeaderObjectiveC) {
   const char *PreCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
+#import "top_level_test_header.h"
 
 void foo() {
   int a = 0;
 })";
   const char *PostCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
-#import "clang_tidy/tests/insert_includes_test_header+foo.h"
+#import "top_level_test_header.h"
+#import "top_level_test_header+foo.h"
 
 void foo() {
   int a = 0;
@@ -724,7 +728,7 @@
   EXPECT_EQ(
   PostCode,
   runCheckOnCode(
-  PreCode, "repo/clang_tidy/tests/insert_includes_test_header.mm"));
+  PreCode, "top_level_test_header.mm"));
 }
 
 TEST(IncludeInserterTest, InsertGeneratedHeaderObjectiveC) {
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -45,8 +45,12 @@
 
 // Objective-C categories have a `+suffix` format, but should be grouped
 // with the file they are a category of.
+size_t start_index = Canonical.find_last_of('/');
+if (start_index == StringRef::npos) {
+  start_index = 0;
+}
 return Canonical.substr(
-0, Canonical.find_first_of('+', Canonical.find_last_of('/')));
+0, Canonical.find_first_of('+', start_index));
   }
   return RemoveFirstSuffix(
   RemoveFirstSuffix(Str, {".cc", ".cpp", ".c", ".h", ".hpp"}),


Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -133,7 +133,7 @@
  utils::IncludeSorter::IS_Google_ObjC) {}
 
   std::vector headersToInclude() const override {
-return {"clang_tidy/tests/insert_includes_test_header+foo.h"};
+return {"top_level_test_header+foo.h"};
   }
 };
 
@@ -158,6 +158,10 @@
   {"clang_tidy/tests/"
"insert_includes_test_header.h",
"\n"},
+  // Top-level main file include +
+  // category.
+  {"top_level_test_header.h", "\n"},
+  {"top_level_test_header+foo.h", "\n"},
   // ObjC category.
   {"clang_tidy/tests/"
"insert_includes_test_header+foo.h",
@@ -708,14 +712,14 @@
 
 TEST(IncludeInserterTest, InsertCategoryHeaderObjectiveC) {
   const char *PreCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
+#import "top_level_test_header.h"
 
 void foo() {
   int a = 0;
 })";
   const char *PostCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
-#import "clang_tidy/tests/insert_includes_test_header+foo.h"
+#import "top_level_test_header.h"
+#import "top_level_test_header+foo.h"
 
 void foo() {
   int a = 0;
@@ -724,7 +728,7 @@
   EXPECT_EQ(
   PostCode,
   runCheckOnCode(
-  PreCode, "repo/clang_tidy/tests/insert_includes_test_header.mm"));
+  PreCode, "top_level_test_header.mm"));
 }
 

[PATCH] D89559: PR47372: Fix Lambda invoker calling conventions

2020-10-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 300396.
erichkeane added a comment.

Alright, I have the multi-emit dealt with, and the problems that come with that 
solved.  This doesn't do the MSVC-emit-for-all-CCs thing, but I intend to do 
that in a separate patch with the same infrastructure.


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

https://reviews.llvm.org/D89559

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
  clang/test/SemaCXX/lambda-conversion-op-cc.cpp

Index: clang/test/SemaCXX/lambda-conversion-op-cc.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-conversion-op-cc.cpp
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc %s -verify -DBAD_CONVERSION
+// RUN: %clang_cc1 -fsyntax-only -triple i386-windows-pc %s -verify -DBAD_CONVERSION -DWIN32
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc %s -ast-dump | FileCheck %s --check-prefixes=CHECK,LIN64,NODEF
+// RUN: %clang_cc1 -fsyntax-only -triple i386-windows-pc %s -ast-dump -DWIN32 | FileCheck %s --check-prefixes=CHECK,WIN32,NODEF
+
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -verify -DBAD_VEC_CONVERS
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -ast-dump | FileCheck %s --check-prefixes=CHECK,VECTDEF
+
+void useage() {
+  auto normal = [](int, float, double) {};// #1
+  auto vectorcall = [](int, float, double) __attribute__((vectorcall)){}; // #2
+#ifdef WIN32
+  auto thiscall = [](int, float, double) __attribute__((thiscall)){}; // #3
+#endif// WIN32
+  auto cdecl = [](int, float, double) __attribute__((cdecl)){};
+
+  auto genericlambda = [](auto a) {};  // #4
+  auto genericvectorcalllambda = [](auto a) __attribute__((vectorcall)){}; // #5
+
+  // None of these should be ambiguous.
+  (void)+normal;
+  (void)+vectorcall;
+#ifdef WIN32
+  (void)+thiscall;
+#endif // WIN32
+  (void)+cdecl;
+
+#ifdef BAD_CONVERSION
+  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}
+  (void)+genericlambda;
+  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}
+  (void)+genericvectorcalllambda;
+#endif // BAD_CONVERSION
+
+  // CHECK: VarDecl {{.*}} normal '
+  // CHECK: LambdaExpr
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((thiscall)) const'
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // VECTDEF: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // CHECK: VarDecl {{.*}} vectorcall '
+  // CHECK: LambdaExpr
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((vectorcall)) const'
+  // CHECK: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // CHECK: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // WIN32: VarDecl {{.*}} thiscall '
+  // WIN32: LambdaExpr
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((thiscall)) const'
+  // WIN32: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // WIN32: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+
+  // CHECK: VarDecl {{.*}} cdecl '
+  // CHECK: LambdaExpr
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // CHECK: VarDecl {{.*}} genericlambda '
+  // CHECK: LambdaExpr
+  //
+  // CHECK: FunctionTemplateDecl {{.*}} operator()
+  // LIN64: CXXMethodDecl {{.*}} operator() 'auto (auto) const' inline
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (char) const' inline
+  // LIN64: CXXMethodDecl {{.*}} 

[PATCH] D83088: Introduce CfgTraits abstraction

2020-10-23 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D83088#2350287 , @nhaehnle wrote:

> Hi Mehdi, this is not an appropriate place for this discussion. Yes, we have 
> a general rule that patches can be reverted if they're obviously broken (e.g. 
> build bot problems) or clearly violate some other standard. This is a good 
> rule, but it doesn't apply here. If you think it does, please state your case 
> in the email thread that I've started on llvm-dev for this very purpose. Just 
> one thing:

I strongly disagree: the bar for post-review commit is not lower than 
pre-commit review.

Again: please revert when someone has a concern, including a *design* concern 
with you patch.

> P.S.: It's easy to miss on Phabricator, but there is already a long stack of 
> patches which build on this

(this is part of my previous point).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D90073: [Clang][CodeGen] fix failed assertion

2020-10-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4643
+   D->getType().isConstQualified());
+else if (isa(GD.getDecl()))
+  LT = getFunctionLinkage(GD);

I'd suggest making this just 'else', that way you don't have to do the assert 
below.  The first line of getFunctionLinkage does the cast to FunctionDecl, so 
that part is already taken care of.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90073

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


[clang] 2b7dfdd - Fix typo in diagnostic name.

2020-10-23 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-23T13:21:21-07:00
New Revision: 2b7dfdd319c0e6e3a8934bcf4019f402d63f7539

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

LOG: Fix typo in diagnostic name.

No functionality change intended.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 231d597fe36a..b6262518b81f 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -252,7 +252,7 @@ def note_constexpr_destroy_out_of_lifetime : Note<
   "destroying object '%0' whose lifetime has already ended">;
 def note_constexpr_unsupported_destruction : Note<
   "non-trivial destruction of type %0 in a constant expression is not 
supported">;
-def note_constexpr_unsupported_tempoarary_nontrivial_dtor : Note<
+def note_constexpr_unsupported_temporary_nontrivial_dtor : Note<
   "non-trivial destruction of lifetime-extended temporary with type %0 "
   "used in the result of a constant expression is not yet supported">;
 def note_constexpr_unsupported_unsized_array : Note<

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c6fc02a6fe91..b33ce14b3658 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2215,7 +2215,7 @@ static bool CheckLValueConstantExpression(EvalInfo , 
SourceLocation Loc,
   QualType TempType = getType(Base);
   if (TempType.isDestructedType()) {
 Info.FFDiag(MTE->getExprLoc(),
-
diag::note_constexpr_unsupported_tempoarary_nontrivial_dtor)
+diag::note_constexpr_unsupported_temporary_nontrivial_dtor)
 << TempType;
 return false;
   }



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


[PATCH] D90063: [AIX] Also error on -G for link-only step

2020-10-23 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 300391.
Xiangling_L added a comment.

Fixed the duplication in the testcase;


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

https://reviews.llvm.org/D90063

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/Inputs/aix_ppc_tree/dummy0.o
  clang/test/Driver/aix-err-options.c


Index: clang/test/Driver/aix-err-options.c
===
--- clang/test/Driver/aix-err-options.c
+++ clang/test/Driver/aix-err-options.c
@@ -1,7 +1,28 @@
-// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | 
\
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
 // RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
 
-// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff'
+// CHECK32: error: unsupported option '-G' for target 'powerpc-ibm-aix-xcoff'
 // CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4958,11 +4958,6 @@
   if (D.CCGenDiagnostics)
 CmdArgs.push_back("-disable-pragma-debug-crash");
 
-  if (RawTriple.isOSAIX())
-if (Arg *A = Args.getLastArg(options::OPT_G))
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getSpelling() << RawTriple.str();
-
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3876,9 +3876,15 @@
 }
   }
 
+  const llvm::Triple  = C.getDefaultToolChain().getTriple();
+  if (RawTriple.isOSAIX())
+if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
+  Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << RawTriple.str();
+
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;
-  if (C.getDefaultToolChain().getTriple().isOSBinFormatMachO())
+  if (RawTriple.isOSBinFormatMachO())
 for (const Arg *A : C.getArgs())
   if (A->getOption().matches(options::OPT_arch))
 ArchNames.insert(A->getValue());


Index: clang/test/Driver/aix-err-options.c
===
--- clang/test/Driver/aix-err-options.c
+++ clang/test/Driver/aix-err-options.c
@@ -1,7 +1,28 @@
-// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
 // RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target 

[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2020-10-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D66492#2350947 , @iajbar wrote:

> Clang crashes when calling getLLVMLinkageVarDefinition() in 
> EmitAliasDefinition() when compiling this testcase:
> enum a_type { a , b, c};
> typedef enum a_type b_type;
> void foo(b_type x, enum a_type y){}
> void bar(b_type x, enum b_type y) __attribute__ ((alias ("foo")));
>
> DeclTy is not set because of "enum b_type" is incomplete type. So calling 
> getLLVMLinkageVarDefinition(cast(GD.getDecl()),..) triggered an 
> assert because GD.getDecl() is FunctionDecl.

It's probably worth noting that the input is funny because `enum b_type` != 
`b_type`.

>> warning: declaration of 'enum b_type' will not be visible outside of this 
>> function [-Wvisibility]

Turns out, the enum and the typedef are red herrings. Because the types don't 
match we should be warning via `-Wattribute-alias=1` that GCC has but we don't.

  void test13(float y) {}
  void test13_foo(int y) __attribute__((alias ("test13")));

GCC:

  :5:6: warning: 'test13_foo' alias between functions of incompatible 
types 'void(int)' and 'void(float)' [-Wattribute-alias=]

We should still not crash.  I don't plan on implementing `-Wattribute-alias=` 
today, but will try to fix up the crash.
https://bugs.llvm.org/show_bug.cgi?id=47957 for the feature request.
https://reviews.llvm.org/D90073


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492

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


[PATCH] D90073: [Clang][CodeGen] fix failed assertion

2020-10-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: aaron.ballman, iajbar.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers requested review of this revision.

Via bugreport:
https://reviews.llvm.org/D66492#2350947


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90073

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -109,3 +109,9 @@
 // CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
 void test12(void) {}
 inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
+
+// Test that a non visible (-Wvisibility) type doesn't assert.
+// CHECKGLOBALS: @test13_alias = alias {}, bitcast (void (i32)* @test13 to {}*)
+enum a_type { test13_a };
+void test13(enum a_type y) {}
+void test13_alias(enum undeclared_type y) __attribute__((alias ("test13")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4637,8 +4637,13 @@
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
-LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
- D->getType().isConstQualified());
+if (isa(GD.getDecl()))
+  LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+   D->getType().isConstQualified());
+else if (isa(GD.getDecl()))
+  LT = getFunctionLinkage(GD);
+assert((isa(GD.getDecl()) || isa(GD.getDecl())) &&
+   "unexpected DeclType");
   }
 
   // Create the new alias itself, but don't set a name yet.


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -109,3 +109,9 @@
 // CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
 void test12(void) {}
 inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
+
+// Test that a non visible (-Wvisibility) type doesn't assert.
+// CHECKGLOBALS: @test13_alias = alias {}, bitcast (void (i32)* @test13 to {}*)
+enum a_type { test13_a };
+void test13(enum a_type y) {}
+void test13_alias(enum undeclared_type y) __attribute__((alias ("test13")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4637,8 +4637,13 @@
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
-LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
- D->getType().isConstQualified());
+if (isa(GD.getDecl()))
+  LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+   D->getType().isConstQualified());
+else if (isa(GD.getDecl()))
+  LT = getFunctionLinkage(GD);
+assert((isa(GD.getDecl()) || isa(GD.getDecl())) &&
+   "unexpected DeclType");
   }
 
   // Create the new alias itself, but don't set a name yet.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2020-10-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp:30-34
+// COMMON-ASM: mflr 0
+// COMMON-ASM-NEXT:stw 0, 8(1)
+// COMMON-ASM-NEXT:stwu 1, -64(1)
+// COMMON-ASM-NEXT:bl ._Z1fv
+// NOP-ASM-NEXT:   nop

DiggerLin wrote:
> nemanjai wrote:
> > rsmith wrote:
> > > Generally we strongly prefer for frontend tests to test only the 
> > > frontend; in this case, that means testing only the IR that Clang is 
> > > producing and not the assembly that comes out of LLVM for that IR. This 
> > > should also remove the need to require PPC as a registered target.
> > +1
> > The asm test can go into `llvm/test/CodeGen/PowerPC`.
> If I put the ASM test as separate test case in the llvm/test/CodeGen/PowerPC 
> .it will have error as :
> 
> ine 1: %clang_cc1: command not found
That's precisely the point.
Clang codegen tests should only test clang IR generation.
They should not invoke -O1/etc optimization pipelines.
LLVM transform tests should only test IR->IR transforms, they should not invoke 
clang/llc
LLVM codegen tests should only test IR->ASM codegen, they should not invoke 
clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D89986: [AIX]ignore the option -fvisibility-inlines-hidden when there is no option -fvisibility=*

2020-10-23 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 300383.
DiggerLin added a comment.
Herald added a subscriber: dexonsmith.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,68 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -fvisibility-inlines-hidden \ 
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefixes=COMMON-IR,NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -o - -x c++ -S  %s  |\
+// RUN:   FileCheck --check-prefixes=NOP-ASM,COMMON-ASM %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden -o - -x c++ -S %s  | \
+// RUN: FileCheck --check-prefixes=NOP-ASM,COMMON-ASM %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -o - -x c++ -S %s  | \
+// RUN: FileCheck --check-prefix=COMMON-ASM %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility \
+// RUN:-fvisibility-inlines-hidden  -fvisibility default -o - -x c++ -S %s  | \
+// RUN: FileCheck --check-prefixes=NOP-ASM,COMMON-ASM %s
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+// COMMON-IR-NEXT:  entry:
+// COMMON-IR-NEXT:store i32 55, i32* @x, align 4
+// COMMON-IR-NEXT:ret void
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
+// COMMON-IR-NEXT:  entry:
+// COMMON-IR-NEXT:store i32 55, i32* @x, align 4
+
+// COMMON-ASM: mflr 0
+// COMMON-ASM-NEXT:stw 0, 8(1)
+// COMMON-ASM-NEXT:stwu 1, -64(1)
+// COMMON-ASM-NEXT:bl ._Z1fv
+// NOP-ASM-NEXT:   nop
+// COMMON-ASM-NEXT:bl ._Z3foov
+// NOP-ASM-NEXT:   nop
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden  -fvisibility default -o - -x c++ -S %s  | \
+// RUN: FileCheck --check-prefix=CHECK %s
+/// CHECK-NOT: nop
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -17,8 +17,11 @@
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
 
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
@@ -70,6 +73,15 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
+// NOVISIBILITY-IR:@b = global i32 0
+// NOVISIBILITY-IR:@pramb = global i32 0
+// NOVISIBILITY-IR:define void @_Z5foo_hPi(i32* %p)
+// NOVISIBILITY-IR:declare void @_Z12zoo_extern_hv()
+// NOVISIBILITY-IR:define void @_Z3barv()
+// NOVISIBILITY-IR:define linkonce_odr i32 

[PATCH] D89986: [AIX]ignore the option -fvisibility-inlines-hidden when there is no option -fvisibility=*

2020-10-23 Thread Digger via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp:30-34
+// COMMON-ASM: mflr 0
+// COMMON-ASM-NEXT:stw 0, 8(1)
+// COMMON-ASM-NEXT:stwu 1, -64(1)
+// COMMON-ASM-NEXT:bl ._Z1fv
+// NOP-ASM-NEXT:   nop

nemanjai wrote:
> rsmith wrote:
> > Generally we strongly prefer for frontend tests to test only the frontend; 
> > in this case, that means testing only the IR that Clang is producing and 
> > not the assembly that comes out of LLVM for that IR. This should also 
> > remove the need to require PPC as a registered target.
> +1
> The asm test can go into `llvm/test/CodeGen/PowerPC`.
If I put the ASM test as separate test case in the llvm/test/CodeGen/PowerPC 
.it will have error as :

ine 1: %clang_cc1: command not found


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D90063: [AIX] Also error on -G for link-only step

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



Comment at: clang/test/Driver/aix-err-options.c:14-15
+
 // RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \

Replace duplicate compile-to-IR step with preprocess-only step.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90063

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

> Yes, there are no generically available libcalls for atomic float math -- but 
> that's okay -- let LLVM handle transform into a cmpxchg loop when required.

I suspect Yaxun's target cannot provide libcalls at all, which is why he wants 
to diagnose up-front.  But I agree that we should be thinking about this 
uniformly, and that his target should be diagnosing *all* unsupported atomics.


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

https://reviews.llvm.org/D71726

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


[PATCH] D89608: Make sure Objective-C category support in IncludeSorter handles top-level imports

2020-10-23 Thread Joe Turner via Phabricator via cfe-commits
compositeprimes added a comment.

In D89608#2336596 , @gribozavr2 wrote:

> Any chance of adding a test?

Done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89608

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


[PATCH] D89608: Make sure Objective-C category support in IncludeSorter handles top-level imports

2020-10-23 Thread Joe Turner via Phabricator via cfe-commits
compositeprimes updated this revision to Diff 300380.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89608

Files:
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -158,6 +158,10 @@
   {"clang_tidy/tests/"
"insert_includes_test_header.h",
"\n"},
+  // Top-level main file include +
+  // category.
+  {"top_level_test_header.h", "\n"},
+  {"top_level_test_header+foo.h", "\n"},
   // ObjC category.
   {"clang_tidy/tests/"
"insert_includes_test_header+foo.h",
@@ -708,14 +712,14 @@
 
 TEST(IncludeInserterTest, InsertCategoryHeaderObjectiveC) {
   const char *PreCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
+#import "top_level_test_header.h"
 
 void foo() {
   int a = 0;
 })";
   const char *PostCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
-#import "clang_tidy/tests/insert_includes_test_header+foo.h"
+#import "top_level_test_header.h"
+#import "top_level_test_header+foo.h"
 
 void foo() {
   int a = 0;
@@ -724,7 +728,7 @@
   EXPECT_EQ(
   PostCode,
   runCheckOnCode(
-  PreCode, "repo/clang_tidy/tests/insert_includes_test_header.mm"));
+  PreCode, "top_level_test_header.mm"));
 }
 
 TEST(IncludeInserterTest, InsertGeneratedHeaderObjectiveC) {
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -45,8 +45,12 @@
 
 // Objective-C categories have a `+suffix` format, but should be grouped
 // with the file they are a category of.
+size_t start_index = Canonical.find_last_of('/');
+if (start_index == StringRef::npos) {
+  start_index = 0;
+}
 return Canonical.substr(
-0, Canonical.find_first_of('+', Canonical.find_last_of('/')));
+0, Canonical.find_first_of('+', start_index));
   }
   return RemoveFirstSuffix(
   RemoveFirstSuffix(Str, {".cc", ".cpp", ".c", ".h", ".hpp"}),


Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -158,6 +158,10 @@
   {"clang_tidy/tests/"
"insert_includes_test_header.h",
"\n"},
+  // Top-level main file include +
+  // category.
+  {"top_level_test_header.h", "\n"},
+  {"top_level_test_header+foo.h", "\n"},
   // ObjC category.
   {"clang_tidy/tests/"
"insert_includes_test_header+foo.h",
@@ -708,14 +712,14 @@
 
 TEST(IncludeInserterTest, InsertCategoryHeaderObjectiveC) {
   const char *PreCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
+#import "top_level_test_header.h"
 
 void foo() {
   int a = 0;
 })";
   const char *PostCode = R"(
-#import "clang_tidy/tests/insert_includes_test_header.h"
-#import "clang_tidy/tests/insert_includes_test_header+foo.h"
+#import "top_level_test_header.h"
+#import "top_level_test_header+foo.h"
 
 void foo() {
   int a = 0;
@@ -724,7 +728,7 @@
   EXPECT_EQ(
   PostCode,
   runCheckOnCode(
-  PreCode, "repo/clang_tidy/tests/insert_includes_test_header.mm"));
+  PreCode, "top_level_test_header.mm"));
 }
 
 TEST(IncludeInserterTest, InsertGeneratedHeaderObjectiveC) {
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -45,8 +45,12 @@
 
 // Objective-C categories have a `+suffix` format, but should be grouped
 // with the file they are a category of.
+size_t start_index = Canonical.find_last_of('/');
+if (start_index == 

[PATCH] D89580: SourceManager: Fix an SLocEntry memory regression introduced with FileEntryRef

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 300377.
dexonsmith added a comment.

Rebased on top of https://reviews.llvm.org/D89580, which implements 
@JDevlieghere's suggestion.


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

https://reviews.llvm.org/D89580

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1734,7 +1734,7 @@
   // Predefined header doesn't have a valid include location in main
   // file, but any files created by it should still be skipped when
   // computing macro args expanded in the main file.
-  (FID == MainFileID && Entry.getFile().Filename == "");
+  (FID == MainFileID && Entry.getFile().getName() == "");
   if (IncludedInFID) {
 // Skip the files/macros of the #include'd file, we only care about
 // macros that lexed macro arguments from our file.
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -134,6 +134,8 @@
 ///
 /// It is possible for this to be NULL if the ContentCache encapsulates
 /// an imaginary text buffer.
+///
+/// FIXME: Turn this into a FileEntryRef and remove Filename.
 const FileEntry *OrigEntry;
 
 /// References the file which the contents were actually loaded from.
@@ -142,6 +144,11 @@
 /// with the contents of another file.
 const FileEntry *ContentsEntry;
 
+/// The filename that is used to access OrigEntry.
+///
+/// FIXME: Remove this once OrigEntry is a FileEntryRef with a stable name.
+StringRef Filename;
+
 /// A bump pointer allocated array of offsets for each source line.
 ///
 /// This is lazily computed.  The lines are owned by the SourceManager
@@ -266,7 +273,11 @@
   /// from. This information encodes the \#include chain that a token was
   /// expanded from. The main include file has an invalid IncludeLoc.
   ///
-  /// FileInfos contain a "ContentCache *", with the contents of the file.
+  /// FileInfo should not grow larger than ExpansionInfo. Doing so will
+  /// cause memory to bloat in compilations with many unloaded macro
+  /// expansions, since the two data structurs are stored in a union in
+  /// SLocEntry. Extra fields should instead go in "ContentCache *", which
+  /// stores file contents and other bits on the side.
   ///
   class FileInfo {
 friend class clang::SourceManager;
@@ -291,10 +302,6 @@
 llvm::PointerIntPair
 ContentAndKind;
 
-/// The filename that is used to access the file entry represented by the
-/// content cache.
-StringRef Filename;
-
   public:
 /// Return a FileInfo object.
 static FileInfo get(SourceLocation IL, ContentCache ,
@@ -305,7 +312,7 @@
   X.HasLineDirectives = false;
   X.ContentAndKind.setPointer();
   X.ContentAndKind.setInt(FileCharacter);
-  X.Filename = Filename;
+  Con.Filename = Filename;
   return X;
 }
 
@@ -333,7 +340,7 @@
 
 /// Returns the name of the file that was used when the file was loaded 
from
 /// the underlying file system.
-StringRef getName() const { return Filename; }
+StringRef getName() const { return getContentCache().Filename; }
   };
 
   /// Each ExpansionInfo encodes the expansion location - where
@@ -454,6 +461,13 @@
 }
   };
 
+  // Assert that the \c FileInfo objects are no bigger than \c ExpansionInfo
+  // objects. This controls the size of \c SLocEntry, of which we have one for
+  // each macro expansion. The number of (unloaded) macro expansions can be
+  // very large. Any other fields needed in FileInfo should go in ContentCache.
+  static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),
+"FileInfo must be no larger than ExpansionInfo.");
+
   /// This is a discriminated union of FileInfo and ExpansionInfo.
   ///
   /// SourceManager keeps an array of these objects, and they are uniquely


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1734,7 +1734,7 @@
   // Predefined header doesn't have a valid include location in main
   // file, but any files created by it should still be skipped when
   // computing macro args expanded in the main file.
-  (FID == MainFileID && Entry.getFile().Filename == "");
+  (FID == MainFileID && Entry.getFile().getName() == "");
   if (IncludedInFID) {
 // Skip the files/macros of the #include'd file, we only care about
 // macros that lexed macro arguments from our file.
Index: 

[PATCH] D90067: SourceManager: Return non-const references in getOrCreateContentCache and related, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: JDevlieghere.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Update a few APIs to return non-const references instead of pointers,
and remove associated `const_cast`s and non-null assertions.


https://reviews.llvm.org/D90067

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1538,11 +1538,11 @@
  NumFileDecls));
 }
 
-const SrcMgr::ContentCache *ContentCache
-  = SourceMgr.getOrCreateContentCache(File, isSystem(FileCharacter));
-if (OverriddenBuffer && !ContentCache->BufferOverridden &&
-ContentCache->ContentsEntry == ContentCache->OrigEntry &&
-!ContentCache->getBufferIfLoaded()) {
+const SrcMgr::ContentCache  =
+SourceMgr.getOrCreateContentCache(File, isSystem(FileCharacter));
+if (OverriddenBuffer && !ContentCache.BufferOverridden &&
+ContentCache.ContentsEntry == ContentCache.OrigEntry &&
+!ContentCache.getBufferIfLoaded()) {
   auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
   if (!Buffer)
 return true;
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -380,16 +380,14 @@
   }
 }
 
-/// getOrCreateContentCache - Create or return a cached ContentCache for the
-/// specified file.
-const ContentCache *
-SourceManager::getOrCreateContentCache(const FileEntry *FileEnt,
-   bool isSystemFile) {
+ContentCache ::getOrCreateContentCache(const FileEntry *FileEnt,
+ bool isSystemFile) {
   assert(FileEnt && "Didn't specify a file entry to use?");
 
   // Do we already have information about this file?
   ContentCache * = FileInfos[FileEnt];
-  if (Entry) return Entry;
+  if (Entry)
+return *Entry;
 
   // Nope, create a new Cache entry.
   Entry = ContentCacheAlloc.Allocate();
@@ -412,19 +410,19 @@
   Entry->IsFileVolatile = UserFilesAreVolatile && !isSystemFile;
   Entry->IsTransient = FilesAreTransient;
 
-  return Entry;
+  return *Entry;
 }
 
 /// Create a new ContentCache for the specified memory buffer.
 /// This does no caching.
-const ContentCache *SourceManager::createMemBufferContentCache(
+ContentCache ::createMemBufferContentCache(
 std::unique_ptr Buffer) {
   // Add a new ContentCache to the MemBufferInfos list and return it.
   ContentCache *Entry = ContentCacheAlloc.Allocate();
   new (Entry) ContentCache();
   MemBufferInfos.push_back(Entry);
   Entry->setBuffer(std::move(Buffer));
-  return Entry;
+  return *Entry;
 }
 
 const SrcMgr::SLocEntry ::loadSLocEntry(unsigned Index,
@@ -437,7 +435,7 @@
 if (!SLocEntryLoaded[Index]) {
   // Try to recover; create a SLocEntry so the rest of clang can handle it.
   LoadedSLocEntryTable[Index] = SLocEntry::get(
-  0, FileInfo::get(SourceLocation(), *getFakeContentCacheForRecovery(),
+  0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(),
SrcMgr::C_User, ""));
 }
   }
@@ -461,24 +459,22 @@
 
 /// As part of recovering from missing or changed content, produce a
 /// fake, non-empty buffer.
-llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const {
+llvm::MemoryBufferRef SourceManager::getFakeBufferForRecovery() const {
   if (!FakeBufferForRecovery)
 FakeBufferForRecovery =
 llvm::MemoryBuffer::getMemBuffer("<<>");
 
-  return FakeBufferForRecovery.get();
+  return *FakeBufferForRecovery;
 }
 
 /// As part of recovering from missing or changed content, produce a
 /// fake content cache.
-const SrcMgr::ContentCache *
-SourceManager::getFakeContentCacheForRecovery() const {
+SrcMgr::ContentCache ::getFakeContentCacheForRecovery() const {
   if (!FakeContentCacheForRecovery) {
 FakeContentCacheForRecovery = std::make_unique();
-FakeContentCacheForRecovery->setUnownedBuffer(
-getFakeBufferForRecovery()->getMemBufferRef());
+FakeContentCacheForRecovery->setUnownedBuffer(getFakeBufferForRecovery());
   }
-  return FakeContentCacheForRecovery.get();
+  return *FakeContentCacheForRecovery;
 }
 
 /// Returns the previous in-order FileID or an invalid FileID if there
@@ -531,21 +527,19 @@
SrcMgr::CharacteristicKind FileCharacter,
int LoadedID, unsigned LoadedOffset) {
   assert(SourceFile && "Null source file!");
-  const SrcMgr::ContentCache *IR =
+  SrcMgr::ContentCache  =
   getOrCreateContentCache(SourceFile, 

[PATCH] D89072: [CodeView] Emit static data members as S_CONSTANTs.

2020-10-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

It seems like there are related test failures according to the 
Phabricator/Jenkins automation. Is that a true positive? Please confirm either 
way before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89072

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


[PATCH] D89844: [Clang][OpenMP][WIP] Fixed an issue of segment fault when using target nowait

2020-10-23 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 300371.
tianshilei1992 added a comment.

Removed useless code and fixed some cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89844

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp

Index: clang/test/OpenMP/target_parallel_for_codegen.cpp
===
--- clang/test/OpenMP/target_parallel_for_codegen.cpp
+++ clang/test/OpenMP/target_parallel_for_codegen.cpp
@@ -182,8 +182,8 @@
   // CHECK:   store i[[SZ]] [[VAL2]], i[[SZ]]* [[P2ADDR]], align
   // CHECK:   [[BPGEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BP]], i32 0, i32 0
   // CHECK:   [[PGEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_P]], i32 0, i32 0
-  // CHECK-32:[[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i32 84, i32 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
-  // CHECK-64:[[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 144, i64 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-32:[[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i32 72, i32 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
+  // CHECK-64:[[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 120, i64 12, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T_WITH_PRIVATES]]*)* [[OMP_TASK_ENTRY:@[^,]+]] to i32 (i32, i8*)*), i64 -1)
   // CHECK:   [[TASK_WITH_PRIVATES_CAST:%.+]] = bitcast i8* [[TASK]] to [[KMP_TASK_T_WITH_PRIVATES]]*
   // CHECK:   [[KMP_PRIVATES:%.+]] = getelementptr inbounds [[KMP_TASK_T_WITH_PRIVATES]], [[KMP_TASK_T_WITH_PRIVATES]]* [[TASK_WITH_PRIVATES_CAST]], i32 0, i32 1
   // CEHCK-32:[[FPSIZEGEP]] = getelementptr inbounds [[KMP_PRIVATES_T]], [[KMP_PRIVATES_T]]* [[KMP_PRIVATES]], i32 0, i32 0
@@ -448,16 +448,14 @@
 // CHECK-NEXT:  }
 
 // CHECK:   define internal {{.*}}i32 [[OMP_TASK_ENTRY]](i32 {{.*}}%0, [[KMP_TASK_T_WITH_PRIVATES]]* noalias %1)
-// CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target_teams_nowait_mapper(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BPR:%[^,]+]], i8** [[PR:%[^,]+]], i64* [[SIZE:%[^,]+]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPT2]], i32 0, i32 0), i8** [[MAPPER:%[^,]+]], i32 1, i32 0)
+// CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target_teams_nowait_mapper(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BPR:%[^,]+]], i8** [[PR:%[^,]+]], i64* [[SIZE:%[^,]+]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPT2]], i32 0, i32 0), i8** null, i32 1, i32 0)
 // CHECK-DAG:   [[BPR]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[FPBPR:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
 // CHECK-DAG:   [[PR]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[FPPR:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
 // CHECK-DAG:   [[SIZE]] = getelementptr inbounds [3 x i64], [3 x i64]* [[FPSIZE:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
-// CHECK-DAG:   [[MAPPER]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[FPMAPPER:%[^,]+]], i[[SZ]] 0, i[[SZ]] 0
 // CHECK-DAG:   [[FPBPR]] = load [3 x i8*]*, [3 x i8*]** [[FPBPRADDR:%[^,]+]], align
 // CHECK-DAG:   [[FPPR]] = load [3 x i8*]*, [3 x i8*]** [[FPPRADDR:%[^,]+]], align
 // CHECK-DAG:   [[FPSIZE]] = load [3 x i64]*, [3 x i64]** [[FPSIZEADDR:%[^,]+]], align
-// CHECK-DAG:   [[FPMAPPER]] = load [3 x i8*]*, [3 x i8*]** [[FPMAPPERADDR:%[^,]+]], align
-// CHECK-DAG:   call void (i8*, ...) %{{[0-9]+}}(i8* %{{[^,]+}}, i16** %{{[^,]+}}, [3 x i8*]** [[FPBPRADDR]], [3 x i8*]** [[FPPRADDR]], [3 x i64]** [[FPSIZEADDR]], [3 x i8*]** [[FPMAPPERADDR]])
+// CHECK-DAG:   call void (i8*, ...) %{{[0-9]+}}(i8* %{{[^,]+}}, i16** %{{[^,]+}}, [3 x i8*]** [[FPBPRADDR]], [3 x i8*]** [[FPPRADDR]], [3 x i64]** [[FPSIZEADDR]])
 // CHECK:   [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
 // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
 // CHECK:   [[FAIL]]
Index: clang/test/OpenMP/target_parallel_depend_codegen.cpp
===
--- clang/test/OpenMP/target_parallel_depend_codegen.cpp
+++ clang/test/OpenMP/target_parallel_depend_codegen.cpp
@@ -124,7 +124,7 @@
   // CHECK:   [[DEV1:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
 
-  // CHECK:   

[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2020-10-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D66492#2350947 , @iajbar wrote:

> Clang crashes when calling getLLVMLinkageVarDefinition() in 
> EmitAliasDefinition() when compiling this testcase:
> enum a_type { a , b, c};
> typedef enum a_type b_type;
> void foo(b_type x, enum a_type y){}
> void bar(b_type x, enum b_type y) __attribute__ ((alias ("foo")));
>
> DeclTy is not set because of "enum b_type" is incomplete type. So calling 
> getLLVMLinkageVarDefinition(cast(GD.getDecl()),..) triggered an 
> assert because GD.getDecl() is FunctionDecl.

Thanks for the report and concise test case; sorry for breaking your build!  
I'll take a look and CC you when I have a fix.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492

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


[clang] cf52a85 - SourceManager: Simplify by inlining what remains of ComputeLineNumbers, NFC

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T14:56:41-04:00
New Revision: cf52a85ddc9be165daca3d32521747c898f4ffd1

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

LOG: SourceManager: Simplify by inlining what remains of ComputeLineNumbers, NFC

Use `LineOffsetMapping:get` directly and remove/inline the helper
`ComputeLineNumbers`, simplifying the callers.

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

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index f8607b0d4c24..1feb8c7b66dd 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1260,23 +1260,6 @@ unsigned 
SourceManager::getPresumedColumnNumber(SourceLocation Loc,
 #include 
 #endif
 
-static LLVM_ATTRIBUTE_NOINLINE void
-ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool );
-static void ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool ) {
-  // Note that calling 'getBuffer()' may lazily page in the file.
-  llvm::Optional Buffer =
-  FI.getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
-  Invalid = !Buffer;
-  if (Invalid)
-return;
-
-  FI.SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
-}
-
 LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
  llvm::BumpPtrAllocator ) {
   // Find the file offsets of all of the *physical* source lines.  This does
@@ -1342,12 +1325,15 @@ unsigned SourceManager::getLineNumber(FileID FID, 
unsigned FilePos,
   // If this is the first use of line information for this buffer, compute the
   /// SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
+llvm::Optional Buffer =
+Content->getBufferOrNone(Diag, getFileManager(), SourceLocation());
 if (Invalid)
-  *Invalid = MyInvalid;
-if (MyInvalid)
+  *Invalid = !Buffer;
+if (!Buffer)
   return 1;
+
+Content->SourceLineCache =
+LineOffsetMapping::get(*Buffer, ContentCacheAlloc);
   } else if (Invalid)
 *Invalid = false;
 
@@ -1689,17 +1675,13 @@ SourceLocation SourceManager::translateLineCol(FileID 
FID,
 
   // If this is the first use of line information for this buffer, compute the
   // SourceLineCache for it on demand.
-  if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
-if (MyInvalid)
-  return SourceLocation();
-  }
-
   llvm::Optional Buffer =
   Content->getBufferOrNone(Diag, getFileManager());
   if (!Buffer)
 return SourceLocation();
+  if (!Content->SourceLineCache)
+Content->SourceLineCache =
+LineOffsetMapping::get(*Buffer, ContentCacheAlloc);
 
   if (Line > Content->SourceLineCache.size()) {
 unsigned Size = Buffer->getBufferSize();



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


[PATCH] D89922: SourceManager: Simplify by inlining what remains of ComputeLineNumbers, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf52a85ddc9b: SourceManager: Simplify by inlining what 
remains of ComputeLineNumbers, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89922

Files:
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1260,23 +1260,6 @@
 #include 
 #endif
 
-static LLVM_ATTRIBUTE_NOINLINE void
-ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool );
-static void ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool ) {
-  // Note that calling 'getBuffer()' may lazily page in the file.
-  llvm::Optional Buffer =
-  FI.getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
-  Invalid = !Buffer;
-  if (Invalid)
-return;
-
-  FI.SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
-}
-
 LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
  llvm::BumpPtrAllocator ) {
   // Find the file offsets of all of the *physical* source lines.  This does
@@ -1342,12 +1325,15 @@
   // If this is the first use of line information for this buffer, compute the
   /// SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
+llvm::Optional Buffer =
+Content->getBufferOrNone(Diag, getFileManager(), SourceLocation());
 if (Invalid)
-  *Invalid = MyInvalid;
-if (MyInvalid)
+  *Invalid = !Buffer;
+if (!Buffer)
   return 1;
+
+Content->SourceLineCache =
+LineOffsetMapping::get(*Buffer, ContentCacheAlloc);
   } else if (Invalid)
 *Invalid = false;
 
@@ -1689,17 +1675,13 @@
 
   // If this is the first use of line information for this buffer, compute the
   // SourceLineCache for it on demand.
-  if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
-if (MyInvalid)
-  return SourceLocation();
-  }
-
   llvm::Optional Buffer =
   Content->getBufferOrNone(Diag, getFileManager());
   if (!Buffer)
 return SourceLocation();
+  if (!Content->SourceLineCache)
+Content->SourceLineCache =
+LineOffsetMapping::get(*Buffer, ContentCacheAlloc);
 
   if (Line > Content->SourceLineCache.size()) {
 unsigned Size = Buffer->getBufferSize();


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1260,23 +1260,6 @@
 #include 
 #endif
 
-static LLVM_ATTRIBUTE_NOINLINE void
-ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool );
-static void ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
-   llvm::BumpPtrAllocator ,
-   const SourceManager , bool ) {
-  // Note that calling 'getBuffer()' may lazily page in the file.
-  llvm::Optional Buffer =
-  FI.getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
-  Invalid = !Buffer;
-  if (Invalid)
-return;
-
-  FI.SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
-}
-
 LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
  llvm::BumpPtrAllocator ) {
   // Find the file offsets of all of the *physical* source lines.  This does
@@ -1342,12 +1325,15 @@
   // If this is the first use of line information for this buffer, compute the
   /// SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
+llvm::Optional Buffer =
+Content->getBufferOrNone(Diag, getFileManager(), SourceLocation());
 if (Invalid)
-  *Invalid = MyInvalid;
-if (MyInvalid)
+  *Invalid = !Buffer;
+if (!Buffer)
   return 1;
+
+Content->SourceLineCache =
+LineOffsetMapping::get(*Buffer, ContentCacheAlloc);
   } else if (Invalid)
 *Invalid = false;
 
@@ -1689,17 +1675,13 @@
 
   // If this is the first use of line information for this buffer, compute the
   // SourceLineCache for it on demand.
-  if (!Content->SourceLineCache) {
-bool MyInvalid = false;
-ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
-

[PATCH] D87956: [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

2020-10-23 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7926ce6d7a8: [IR] add fn attr for no_stack_protector; 
prevent inlining on mismatch (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87956

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stack-protector.c
  clang/test/Frontend/optimization-remark-missed-inline-stack-protectors.c
  llvm/bindings/go/llvm/ir_test.go
  llvm/bindings/ocaml/llvm/llvm.ml
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/CodeGen/X86/stack-protector-2.ll
  llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll
  llvm/test/Transforms/Inline/inline_nossp.ll
  llvm/test/Transforms/Inline/inline_ssp.ll
  llvm/test/Verifier/function-attribute-nossp-ssp-sspreq-sspstrong.ll
  llvm/utils/emacs/llvm-mode.el
  llvm/utils/kate/llvm.xml
  llvm/utils/llvm.grm
  llvm/utils/vim/syntax/llvm.vim
  llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml

Index: llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
===
--- llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
+++ llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
@@ -245,6 +245,7 @@
 \\bspir_func\\b|\
 \\bspir_kernel\\b|\
 \\bsret\\b|\
+\\bnossp\\b|\
 \\bssp\\b|\
 \\bsspreq\\b|\
 \\bsspstrong\\b|\
Index: llvm/utils/vim/syntax/llvm.vim
===
--- llvm/utils/vim/syntax/llvm.vim
+++ llvm/utils/vim/syntax/llvm.vim
@@ -148,6 +148,7 @@
   \ spir_func
   \ spir_kernel
   \ sret
+  \ nossp
   \ ssp
   \ sspreq
   \ sspstrong
Index: llvm/utils/llvm.grm
===
--- llvm/utils/llvm.grm
+++ llvm/utils/llvm.grm
@@ -168,6 +168,7 @@
  | noinline
  | alwaysinline
  | optsize
+ | nossp
  | ssp
  | sspreq
  | returns_twice
Index: llvm/utils/kate/llvm.xml
===
--- llvm/utils/kate/llvm.xml
+++ llvm/utils/kate/llvm.xml
@@ -93,6 +93,7 @@
optsize 
readnone 
readonly 
+   nossp 
ssp 
sspreq 
sspstrong 
Index: llvm/utils/emacs/llvm-mode.el
===
--- llvm/utils/emacs/llvm-mode.el
+++ llvm/utils/emacs/llvm-mode.el
@@ -26,7 +26,7 @@
  "inaccessiblemem_or_argmemonly" "inlinehint" "jumptable" "minsize" "mustprogress" "naked" "nobuiltin"
  "noduplicate" "nofree" "noimplicitfloat" "noinline" "nonlazybind" "noredzone" "noreturn"
  "norecurse" "noundef" "nounwind" "optnone" "optsize" "readnone" "readonly" "returns_twice"
- "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag"
+ "speculatable" "nossp" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag"
  "sanitize_thread" "sanitize_memory" "strictfp" "uwtable" "willreturn" "writeonly" "immarg") 'symbols) . font-lock-constant-face)
;; Variables
'("%[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-variable-name-face)
Index: llvm/test/Verifier/function-attribute-nossp-ssp-sspreq-sspstrong.ll
===
--- /dev/null
+++ llvm/test/Verifier/function-attribute-nossp-ssp-sspreq-sspstrong.ll
@@ -0,0 +1,58 @@
+; RUN: not opt -verify -o - %s 2>&1 | FileCheck %s
+define void @test_1 () #1 { ret void }
+define void @test_2 () #2 { ret void }
+define void @test_3 () #3 { ret void }
+define void @test_4 () #4 { ret void }
+define void @test_5 () #5 { ret void }
+define void @test_6 () #6 { ret void }
+define void @test_7 () #7 { ret void }
+define void @test_8 () #8 { ret void }
+define void @test_9 () #9 { ret void }
+define void @test_10 () #10 { ret void }
+define void @test_11 () #10 { ret void }
+define void @test_12 () #10 { ret void }
+define void @test_13 () #10 { ret void }
+define void @test_14 () #10 { ret void }
+
+attributes #0 = { nossp }
+attributes #1 = { ssp }
+attributes #2 = { sspreq }
+attributes #3 = { sspstrong }
+
+attributes #4 = { nossp ssp }
+attributes #5 = { nossp sspreq }
+attributes #6 = { nossp 

[clang] b7926ce - [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

2020-10-23 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-10-23T11:55:39-07:00
New Revision: b7926ce6d7a83cdf70c68d82bc3389c04009b841

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

LOG: [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

It's currently ambiguous in IR whether the source language explicitly
did not want a stack a stack protector (in C, via function attribute
no_stack_protector) or doesn't care for any given function.

It's common for code that manipulates the stack via inline assembly or
that has to set up its own stack canary (such as the Linux kernel) would
like to avoid stack protectors in certain functions. In this case, we've
been bitten by numerous bugs where a callee with a stack protector is
inlined into an __attribute__((__no_stack_protector__)) caller, which
generally breaks the caller's assumptions about not having a stack
protector. LTO exacerbates the issue.

While developers can avoid this by putting all no_stack_protector
functions in one translation unit together and compiling those with
-fno-stack-protector, it's generally not very ergonomic or as
ergonomic as a function attribute, and still doesn't work for LTO. See also:
https://lore.kernel.org/linux-pm/20200915172658.1432732-1-r...@google.com/
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolva...@google.com/T/#u

Typically, when inlining a callee into a caller, the caller will be
upgraded in its level of stack protection (see adjustCallerSSPLevel()).
By adding an explicit attribute in the IR when the function attribute is
used in the source language, we can now identify such cases and prevent
inlining.  Block inlining when the callee and caller differ in the case that one
contains `nossp` when the other has `ssp`, `sspstrong`, or `sspreq`.

Fixes pr/47479.

Reviewed By: void

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

Added: 
clang/test/Frontend/optimization-remark-missed-inline-stack-protectors.c
llvm/test/Transforms/Inline/inline_nossp.ll
llvm/test/Verifier/function-attribute-nossp-ssp-sspreq-sspstrong.ll

Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/stack-protector.c
llvm/bindings/go/llvm/ir_test.go
llvm/bindings/ocaml/llvm/llvm.ml
llvm/docs/BitCodeFormat.rst
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/StackProtector.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/CodeGen/X86/stack-protector-2.ll
llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll
llvm/test/Transforms/Inline/inline_ssp.ll
llvm/utils/emacs/llvm-mode.el
llvm/utils/kate/llvm.xml
llvm/utils/llvm.grm
llvm/utils/vim/syntax/llvm.vim
llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 43ca7dd7424f..912af82dee8c 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3920,6 +3920,10 @@ option.
 
 int bar(int y); // bar can be built with the stack protector.
 
+A callee that has a stack protector will not be inlined into a
+``__attribute__((no_stack_protector))`` caller, and vice-versa, even if the
+callee is marked ``__attribute__((always_inline))``.
+
 }];
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 8b53ec9ab4a9..809e877e42aa 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1594,14 +1594,14 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
-  if (!D || !D->hasAttr()) {
-if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-  B.addAttribute(llvm::Attribute::StackProtect);
-else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-  B.addAttribute(llvm::Attribute::StackProtectStrong);
-else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-  B.addAttribute(llvm::Attribute::StackProtectReq);
-  }
+  if (D && D->hasAttr())
+B.addAttribute(llvm::Attribute::NoStackProtect);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+B.addAttribute(llvm::Attribute::StackProtect);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+  

[PATCH] D89910: [AIX] Let alloca return 16 bytes alignment

2020-10-23 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05bef88eb3ec: [AIX] Let alloca return 16 bytes alignment 
(authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89910

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/aix_alloca_align.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -666,7 +666,7 @@
 // PPC64-AIX:#define _LP64 1
 // PPC64-AIX:#define _POWER 1
 // PPC64-AIX:#define __64BIT__ 1
-// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC64-AIX:#define __BIG_ENDIAN__ 1
 // PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC64-AIX:#define __CHAR16_TYPE__ unsigned short
Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -398,7 +398,7 @@
 // PPC-AIX:#define _LONG_LONG 1
 // PPC-AIX-NOT:#define _LP64 1
 // PPC-AIX:#define _POWER 1
-// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC-AIX:#define __BIG_ENDIAN__ 1
 // PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC-AIX:#define __CHAR16_TYPE__ unsigned short
Index: clang/test/CodeGen/aix_alloca_align.c
===
--- /dev/null
+++ clang/test/CodeGen/aix_alloca_align.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=32BIT %s
+
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=64BIT %s
+
+typedef __SIZE_TYPE__ size_t;
+extern void *alloca(size_t __size) __attribute__((__nothrow__));
+
+void foo() {
+  char *ptr1 = (char *)alloca(sizeof(char) * 9);
+  char *ptr2 = (char *)alloca(sizeof(char) * 32);
+}
+
+// 32BIT: %0 = alloca i8, i32 9, align 16
+// 32BIT: %1 = alloca i8, i32 32, align 16
+
+// 64BIT: %0 = alloca i8, i64 9, align 16
+// 64BIT: %1 = alloca i8, i64 32, align 16
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -370,7 +370,6 @@
   SizeType = UnsignedLong;
   PtrDiffType = SignedLong;
   IntPtrType = SignedLong;
-  SuitableAlign = 64;
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = ::APFloat::IEEEdouble();
@@ -409,7 +408,6 @@
 if (Triple.isOSAIX()) {
   // TODO: Set appropriate ABI for AIX platform.
   DataLayout = "E-m:a-i64:64-n32:64";
-  SuitableAlign = 64;
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = ::APFloat::IEEEdouble();


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -666,7 +666,7 @@
 // PPC64-AIX:#define _LP64 1
 // PPC64-AIX:#define _POWER 1
 // PPC64-AIX:#define __64BIT__ 1
-// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC64-AIX:#define __BIG_ENDIAN__ 1
 // PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC64-AIX:#define __CHAR16_TYPE__ unsigned short
Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -398,7 +398,7 @@
 // PPC-AIX:#define _LONG_LONG 1
 // PPC-AIX-NOT:#define _LP64 1
 // PPC-AIX:#define _POWER 1
-// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC-AIX:#define __BIG_ENDIAN__ 1
 // PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC-AIX:#define __CHAR16_TYPE__ unsigned short
Index: clang/test/CodeGen/aix_alloca_align.c
===
--- /dev/null
+++ clang/test/CodeGen/aix_alloca_align.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=32BIT %s
+
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=64BIT %s
+
+typedef __SIZE_TYPE__ size_t;
+extern void *alloca(size_t __size) __attribute__((__nothrow__));
+
+void foo() {
+  char *ptr1 = (char *)alloca(sizeof(char) * 9);
+  char *ptr2 = (char *)alloca(sizeof(char) * 32);
+}
+
+// 32BIT: %0 = alloca i8, i32 9, align 16
+// 32BIT: %1 = alloca i8, i32 32, align 16
+
+// 64BIT: %0 = alloca i8, i64 9, align 16
+// 64BIT: 

[clang] 05bef88 - [AIX] Let alloca return 16 bytes alignment

2020-10-23 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-10-23T14:41:32-04:00
New Revision: 05bef88eb3ecb8519a871ca9aa53caeca5add555

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

LOG: [AIX] Let alloca return 16 bytes alignment

On AIX, to support vector types, which should always be 16 bytes aligned,
we set alloca to return 16 bytes aligned memory space.

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

Added: 
clang/test/CodeGen/aix_alloca_align.c

Modified: 
clang/lib/Basic/Targets/PPC.h
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 597508207ffb..ad754462370f 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -370,7 +370,6 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public 
PPCTargetInfo {
   SizeType = UnsignedLong;
   PtrDiffType = SignedLong;
   IntPtrType = SignedLong;
-  SuitableAlign = 64;
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = ::APFloat::IEEEdouble();
@@ -409,7 +408,6 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
 if (Triple.isOSAIX()) {
   // TODO: Set appropriate ABI for AIX platform.
   DataLayout = "E-m:a-i64:64-n32:64";
-  SuitableAlign = 64;
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = ::APFloat::IEEEdouble();

diff  --git a/clang/test/CodeGen/aix_alloca_align.c 
b/clang/test/CodeGen/aix_alloca_align.c
new file mode 100644
index ..e235abdd1630
--- /dev/null
+++ b/clang/test/CodeGen/aix_alloca_align.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=32BIT %s
+
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck --check-prefix=64BIT %s
+
+typedef __SIZE_TYPE__ size_t;
+extern void *alloca(size_t __size) __attribute__((__nothrow__));
+
+void foo() {
+  char *ptr1 = (char *)alloca(sizeof(char) * 9);
+  char *ptr2 = (char *)alloca(sizeof(char) * 32);
+}
+
+// 32BIT: %0 = alloca i8, i32 9, align 16
+// 32BIT: %1 = alloca i8, i32 32, align 16
+
+// 64BIT: %0 = alloca i8, i64 9, align 16
+// 64BIT: %1 = alloca i8, i64 32, align 16

diff  --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 275757631c6c..aa0f8c97de12 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -398,7 +398,7 @@
 // PPC-AIX:#define _LONG_LONG 1
 // PPC-AIX-NOT:#define _LP64 1
 // PPC-AIX:#define _POWER 1
-// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC-AIX:#define __BIG_ENDIAN__ 1
 // PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC-AIX:#define __CHAR16_TYPE__ unsigned short

diff  --git a/clang/test/Preprocessor/init-ppc64.c 
b/clang/test/Preprocessor/init-ppc64.c
index b553d07183ec..dd965b86b879 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -666,7 +666,7 @@
 // PPC64-AIX:#define _LP64 1
 // PPC64-AIX:#define _POWER 1
 // PPC64-AIX:#define __64BIT__ 1
-// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC64-AIX:#define __BIG_ENDIAN__ 1
 // PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC64-AIX:#define __CHAR16_TYPE__ unsigned short



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


[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2020-10-23 Thread Ikhlas Ajbar via Phabricator via cfe-commits
iajbar added a comment.

Clang crashes when calling getLLVMLinkageVarDefinition() in 
EmitAliasDefinition() when compiling this testcase:
enum a_type { a , b, c};
typedef enum a_type b_type;
void foo(b_type x, enum a_type y){}
void bar(b_type x, enum b_type y) __attribute__ ((alias ("foo")));

DeclTy is not set because of "enum b_type" is incomplete type. So calling 
getLLVMLinkageVarDefinition(cast(GD.getDecl()),..) triggered an assert 
because GD.getDecl() is FunctionDecl.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2020-10-23 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D71726#2207700 , @yaxunl wrote:

> clang does not always emit atomic instructions for atomic builtins. Clang may 
> emit lib calls for atomic builtins. Basically clang checks target info about 
> max atomic inline width and if the desired atomic operation exceeds the 
> supported atomic inline width, clang will emit lib calls for atomic builtins. 
> The rationale is that the lib calls may be faster than the IR generated by 
> the LLVM pass. This behavior has long existed and it also applies to fp 
> atomics. I don't think emitting lib calls for atomic builtins is a bug. 
> However, this does introduce the issue about whether the library functions 
> for atomics are available for a specific target. As I said, only the target 
> owners have the answer and therefore I introduced the target hook.

The LLVM AtomicExpandPass is _also_ introducing libcalls (or cmpxchg loops), as 
is appropriate for a given target. We currently, redundantly, support the same 
thing in two places. It's a long-term goal of mine to simplify the atomics code 
in clang, by deferring more of it to LLVM, but some prerequisites (e.g. 
supporting misaligned atomicrmw) are not yet in place. The intent is that it is 
always valid to emit the LLVM atomic IR, and it will be transformed into 
whatever is best on a given target. As such, there's no reason to restrict 
these clang intrinsics.

Yes, there are no generically available libcalls for atomic float math -- but 
that's okay -- let LLVM handle transform into a cmpxchg loop when required.


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

https://reviews.llvm.org/D71726

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


[PATCH] D90063: [AIX] Also error on -G for link-only step

2020-10-23 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: hubert.reinterpretcast, daltenty, jasonliu.
Herald added subscribers: cfe-commits, kbarton, nemanjai.
Herald added a project: clang.
Xiangling_L requested review of this revision.

The change in [[ https://reviews.llvm.org/D89897 | [AIX] Emit error for -G 
option on AIX ]] didn't issue an error for link-only steps. The patch fixes 
that problem and also update related testcases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90063

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/Inputs/aix_ppc_tree/dummy0.o
  clang/test/Driver/aix-err-options.c


Index: clang/test/Driver/aix-err-options.c
===
--- clang/test/Driver/aix-err-options.c
+++ clang/test/Driver/aix-err-options.c
@@ -1,7 +1,28 @@
-// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | 
\
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+
 // RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
 // RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s 
| \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
 
-// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff'
+// CHECK32: error: unsupported option '-G' for target 'powerpc-ibm-aix-xcoff'
 // CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4958,11 +4958,6 @@
   if (D.CCGenDiagnostics)
 CmdArgs.push_back("-disable-pragma-debug-crash");
 
-  if (RawTriple.isOSAIX())
-if (Arg *A = Args.getLastArg(options::OPT_G))
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getSpelling() << RawTriple.str();
-
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3876,9 +3876,15 @@
 }
   }
 
+  const llvm::Triple  = C.getDefaultToolChain().getTriple();
+  if (RawTriple.isOSAIX())
+if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
+  Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << RawTriple.str();
+
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;
-  if (C.getDefaultToolChain().getTriple().isOSBinFormatMachO())
+  if (RawTriple.isOSBinFormatMachO())
 for (const Arg *A : C.getArgs())
   if (A->getOption().matches(options::OPT_arch))
 ArchNames.insert(A->getValue());


Index: clang/test/Driver/aix-err-options.c
===
--- clang/test/Driver/aix-err-options.c
+++ clang/test/Driver/aix-err-options.c
@@ -1,7 +1,28 @@
-// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \
 // RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -o dummy.so \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \
+// RUN:   FileCheck 

[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

kpn wrote:
> sepavloff wrote:
> > kpn wrote:
> > > sepavloff wrote:
> > > > Why they are wrong?
> > > Because the #pragma covers the entire file and sets exception handling to 
> > > "strict". Thus all constrained intrinsic calls should be "strict", and if 
> > > they are "maytrap" or "ignore" then we have a bug.
> > What is the reason for that? Does `#pragma float_control` work incorrectly? 
> > Why  in `clang/test/CodeGen/complex-math-strictfp.c` exception handling is 
> > correct?
> The #pragma works just fine. The problem is that we need to get the strictfp 
> bits from the AST to the IRBuilder, and we haven't finished implementing 
> that. So sometimes it works, like in complex-math-strictfp.c, and sometimes 
> it doesn't. As you can see in the tests in this patch.
I forgot to mention that complex-math-strictfp.c gets a correct BinOpInfo 
passed down to get the IRBuilder set correctly. But there are other places that 
don't correctly set BinOpInfo and so we get inconsistent behavior despite the 
call to the IRBuilder being wrapped in FPOptsRAII. And _that's_ why I 
structured this patch the way I did.


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

https://reviews.llvm.org/D88913

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:154-155
+  OldRounding = CGF.Builder.getDefaultConstrainedRounding();
   if (OldFPFeatures == FPFeatures)
 return;
 

sepavloff wrote:
> This check can be lifted to just after the definition of `OldFPFeatures`.
Actually, no, because this leaves OldExcept and OldRounding uninitialized when 
they get used by the destructor.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

sepavloff wrote:
> kpn wrote:
> > sepavloff wrote:
> > > Why they are wrong?
> > Because the #pragma covers the entire file and sets exception handling to 
> > "strict". Thus all constrained intrinsic calls should be "strict", and if 
> > they are "maytrap" or "ignore" then we have a bug.
> What is the reason for that? Does `#pragma float_control` work incorrectly? 
> Why  in `clang/test/CodeGen/complex-math-strictfp.c` exception handling is 
> correct?
The #pragma works just fine. The problem is that we need to get the strictfp 
bits from the AST to the IRBuilder, and we haven't finished implementing that. 
So sometimes it works, like in complex-math-strictfp.c, and sometimes it 
doesn't. As you can see in the tests in this patch.


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

https://reviews.llvm.org/D88913

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

In D71726#2207700 , @yaxunl wrote:

> clang does not always emit atomic instructions for atomic builtins. Clang may 
> emit lib calls for atomic builtins. Basically clang checks target info about 
> max atomic inline width and if the desired atomic operation exceeds the 
> supported atomic inline width, clang will emit lib calls for atomic builtins. 
> The rationale is that the lib calls may be faster than the IR generated by 
> the LLVM pass. This behavior has long existed and it also applies to fp 
> atomics. I don't think emitting lib calls for atomic builtins is a bug. 
> However, this does introduce the issue about whether the library functions 
> for atomics are available for a specific target. As I said, only the target 
> owners have the answer and therefore I introduced the target hook.

If we want the frontend to emit an error when the target doesn't support 
library-based atomics, that seems fine, but there's no reason to only do so for 
floating-point types.  That is, we should have a TargetInfo method that asks 
whether atomics at a given size and alignment are supported at all, similar to 
what we have for "builtin" (lock-free) atomics, and we should check it for all 
the atomic types and operations.

Actually, maybe we should take the existing hook and have it return one of { 
LockFree, Library, Unsupported }.


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

https://reviews.llvm.org/D71726

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


[PATCH] D90023: [Syntax] Add iterators over children of syntax trees.

2020-10-23 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

Thanks Sam! I learned a lot from your patch ^^




Comment at: clang/include/clang/Tooling/Syntax/Tree.h:157-184
+  /// Iterator over children (common base for const/non-const).
+  /// Not invalidated by tree mutations (holds a stable node pointer).
+  template 
+  class child_iterator_base
+  : public llvm::iterator_facade_base {
+  protected:

I think we should only have an iterator through `Node`s, not a general one like 
this.

In general `Tree` has *heterogeneous* children:
For instance, `1+2` yields the syntax tree:
```
BinaryOperatorExpression
|-  IntegerLiteralExpression
|-  Leaf
`- IntegerLiteralExpression
```

Very rarely will syntax trees have all their children of the same kind, so I 
don't think it makes sense to try an provide an iterator template. That makes 
sense for lists , because generally they *have* the same kind. But in that case 
we provide special iterators for lists only.




Comment at: clang/include/clang/Tooling/Syntax/Tree.h:202-219
+  /// child_iterator is not invalidated by mutations.
+  struct child_iterator : child_iterator_base {
+using Base::Base;
+  };
+  struct const_child_iterator
+  : child_iterator_base {
+using Base::Base;

TL;DR:
`child_iterator` -> `ChildIterator`
`const_child_iterator` -> `ConstChildIterator`
`children` -> `getChildren`

I see you followed the naming convention of the ClangAST, which makes loads of 
sense. 

In syntax trees we follow the naming conventions of the [conding 
standard](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly)
 -- just because we want consistency and we had to pick a guideline to follow 
-- according to that, functions should be verb like and names should be camel 
case.

If like us you chose `const_child_iterator` and `children` kind of "just 
because", could you change it to follow `ConstChildIterator` and `getChildren` 
respectively. 



Comment at: clang/lib/Tooling/Syntax/Tree.cpp:22-23
   if (auto *T = dyn_cast(N)) {
-for (const auto *C = T->getFirstChild(); C; C = C->getNextSibling())
-  traverse(C, Visit);
+for (const syntax::Node  : T->children())
+  traverse(, Visit);
   }

Hmm... 
That looks funny, if the user uses a range-based for loop and forgets the `&`, 
then we would be copying the Node???

Also in many places we had to get the address to the node. That is not really 
consistent with how the syntax trees API's were designed, they generally take 
pointers instead of references. (that said we could obviously reconsider those 
design choices)



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:129
 
+TEST_F(TreeTest, Iterators) {
+  buildTree("", allTestClangConfigs().front());

Suggestion:
I would split this into `Iterators` and `ConstIterators`.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:139
+  NodeKind::TranslationUnit);
+  const syntax::Tree *ConstTree = Tree;
+

nit, feel free to ignore.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:159-169
+  for (unsigned I = 0; I < 3; ++I) {
+EXPECT_EQ(It, CIt);
+EXPECT_TRUE(It);
+EXPECT_TRUE(CIt);
+EXPECT_EQ(It.asPointer(), Children[I]);
+EXPECT_EQ(CIt.asPointer(), Children[I]);
+EXPECT_EQ(&*It, Children[I]);

Is there a reason why you didn't use a range-based for loop over Children?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90023

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

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



Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:57
+Constant, // sycl_constant
+Private,  // sycl_private
 Generic,  // ptr32_sptr

I feel like we may be outgrowing these address-space map arrays.



Comment at: clang/lib/CodeGen/CGCall.cpp:4596
+
IRFuncTy->getParamType(FirstIRArg));
+}
+

This seems problematic; code like this shouldn't be necessary in every place 
that uses a pointer value.  The general rule needs to be that expression 
emission produces a value of its expected type, so the places that emit 
pointers need to be casting to the generic address space.  We can avoid that in 
some special expression emitters, like maybe EmitLValue, as long as the LValue 
records what happened and can apply the appropriate transform later.

Also, in IRGen we work as much as possible with AST address spaces rather than 
IR address spaces.  That is, code like this that's checking for address space 
mismatches needs to be comparing the source AST address space with the 
destination AST address space and calling a method on the TargetInfo when a 
mismatch is detected, rather than comparing IR address spaces and directly 
building an `addrspacecast`.  The idea is that in principle a target should be 
able to have two logical address spaces that are actually implemented in IR 
with the same underlying address space, with some arbitrary transform between 
them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D89982: [analyzer] [NFC] Simplify SVal::getAsLocSymbol function using existing functions

2020-10-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks correct, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89982

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


[PATCH] D89987: [analyzer] [NFC] Rename SymbolRef to SymExprRef

2020-10-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Honestly i'd rather eliminate `SymExpr` and go with `Symbol` everywhere. It's 
an overloaded term but appending "Expr" to it doesn't really make it 
significantly less overloaded. We're also properly namespaced so there wouldn't 
be any linking issues with the rest of LLVM. "Symbol" is catchy and it's one of 
the most important concepts to grasp in the static analyzer, i'd love to keep 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89987

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


[PATCH] D83448: [CodeGen] Emit destructor calls to destruct non-trivial C struct temporaries created by conditional and assignment operators

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83448

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


[PATCH] D89914: SourceManager: Make LastLineNoContentCache and ContentCache::SourceLineCache mutable, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5431c37b55e2: SourceManager: Make LastLineNoContentCache and 
ContentCache::SourceLineCache… (authored by dexonsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D89914?vs=299812=300339#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89914

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/ScratchBuffer.cpp

Index: clang/lib/Lex/ScratchBuffer.cpp
===
--- clang/lib/Lex/ScratchBuffer.cpp
+++ clang/lib/Lex/ScratchBuffer.cpp
@@ -37,11 +37,10 @@
   else {
 // Clear out the source line cache if it's already been computed.
 // FIXME: Allow this to be incrementally extended.
-auto *ContentCache = const_cast(
-(SourceMgr.getFileID(BufferStartLoc))
- .getFile()
- .getContentCache());
-ContentCache->SourceLineCache = SrcMgr::LineOffsetMapping();
+SourceMgr.getSLocEntry(SourceMgr.getFileID(BufferStartLoc))
+.getFile()
+.getContentCache()
+.SourceLineCache = SrcMgr::LineOffsetMapping();
   }
 
   // Prefix the token with a \n, so that it looks like it is the first thing on
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1261,20 +1261,20 @@
 #endif
 
 static LLVM_ATTRIBUTE_NOINLINE void
-ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
+ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
llvm::BumpPtrAllocator ,
const SourceManager , bool );
-static void ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
+static void ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
llvm::BumpPtrAllocator ,
const SourceManager , bool ) {
   // Note that calling 'getBuffer()' may lazily page in the file.
   llvm::Optional Buffer =
-  FI->getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
+  FI.getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
   Invalid = !Buffer;
   if (Invalid)
 return;
 
-  FI->SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
+  FI.SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
 }
 
 LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
@@ -1324,7 +1324,7 @@
 return 1;
   }
 
-  ContentCache *Content;
+  const ContentCache *Content;
   if (LastLineNoFileIDQuery == FID)
 Content = LastLineNoContentCache;
   else {
@@ -1336,14 +1336,14 @@
   return 1;
 }
 
-Content = const_cast(().getContentCache());
+Content = ().getContentCache();
   }
 
   // If this is the first use of line information for this buffer, compute the
   /// SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
 bool MyInvalid = false;
-ComputeLineNumbers(Diag, Content, ContentCacheAlloc, *this, MyInvalid);
+ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
 if (Invalid)
   *Invalid = MyInvalid;
 if (MyInvalid)
@@ -1685,14 +1685,13 @@
   if (Line == 1 && Col == 1)
 return FileLoc;
 
-  ContentCache *Content =
-  const_cast(().getContentCache());
+  const ContentCache *Content = ().getContentCache();
 
   // If this is the first use of line information for this buffer, compute the
   // SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
 bool MyInvalid = false;
-ComputeLineNumbers(Diag, Content, ContentCacheAlloc, *this, MyInvalid);
+ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
 if (MyInvalid)
   return SourceLocation();
   }
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -146,7 +146,7 @@
 ///
 /// This is lazily computed.  The lines are owned by the SourceManager
 /// BumpPointerAllocator object.
-LineOffsetMapping SourceLineCache;
+mutable LineOffsetMapping SourceLineCache;
 
 /// Indicates whether the buffer itself was provided to override
 /// the actual file contents.
@@ -719,7 +719,7 @@
   /// These ivars serve as a cache used in the getLineNumber
   /// method which is used to speedup getLineNumber calls to nearby locations.
   mutable FileID LastLineNoFileIDQuery;
-  mutable SrcMgr::ContentCache *LastLineNoContentCache;
+  mutable const SrcMgr::ContentCache *LastLineNoContentCache;
   mutable unsigned LastLineNoFilePos;
   mutable unsigned LastLineNoResult;
 
___
cfe-commits mailing list

[clang] 5431c37 - SourceManager: Make LastLineNoContentCache and ContentCache::SourceLineCache mutable, NFC

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T13:22:47-04:00
New Revision: 5431c37b55e2c2952b6b56c9690bd1ce05b23c7e

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

LOG: SourceManager: Make LastLineNoContentCache and 
ContentCache::SourceLineCache mutable, NFC

Avoid some noisy `const_cast`s by making `ContentCache::SourceLineCache`
and `SourceManager::LastLineNoContentCache` both mutable.

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/ScratchBuffer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 00a790038dbf..a458ef7e72a8 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -146,7 +146,7 @@ namespace SrcMgr {
 ///
 /// This is lazily computed.  The lines are owned by the SourceManager
 /// BumpPointerAllocator object.
-LineOffsetMapping SourceLineCache;
+mutable LineOffsetMapping SourceLineCache;
 
 /// Indicates whether the buffer itself was provided to override
 /// the actual file contents.
@@ -719,7 +719,7 @@ class SourceManager : public RefCountedBase {
   /// These ivars serve as a cache used in the getLineNumber
   /// method which is used to speedup getLineNumber calls to nearby locations.
   mutable FileID LastLineNoFileIDQuery;
-  mutable SrcMgr::ContentCache *LastLineNoContentCache;
+  mutable const SrcMgr::ContentCache *LastLineNoContentCache;
   mutable unsigned LastLineNoFilePos;
   mutable unsigned LastLineNoResult;
 

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 778fd0dca329..f8607b0d4c24 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1261,20 +1261,20 @@ unsigned 
SourceManager::getPresumedColumnNumber(SourceLocation Loc,
 #endif
 
 static LLVM_ATTRIBUTE_NOINLINE void
-ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
+ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
llvm::BumpPtrAllocator ,
const SourceManager , bool );
-static void ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
+static void ComputeLineNumbers(DiagnosticsEngine , const ContentCache ,
llvm::BumpPtrAllocator ,
const SourceManager , bool ) {
   // Note that calling 'getBuffer()' may lazily page in the file.
   llvm::Optional Buffer =
-  FI->getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
+  FI.getBufferOrNone(Diag, SM.getFileManager(), SourceLocation());
   Invalid = !Buffer;
   if (Invalid)
 return;
 
-  FI->SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
+  FI.SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
 }
 
 LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
@@ -1324,7 +1324,7 @@ unsigned SourceManager::getLineNumber(FileID FID, 
unsigned FilePos,
 return 1;
   }
 
-  ContentCache *Content;
+  const ContentCache *Content;
   if (LastLineNoFileIDQuery == FID)
 Content = LastLineNoContentCache;
   else {
@@ -1336,14 +1336,14 @@ unsigned SourceManager::getLineNumber(FileID FID, 
unsigned FilePos,
   return 1;
 }
 
-Content = const_cast(().getContentCache());
+Content = ().getContentCache();
   }
 
   // If this is the first use of line information for this buffer, compute the
   /// SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
 bool MyInvalid = false;
-ComputeLineNumbers(Diag, Content, ContentCacheAlloc, *this, MyInvalid);
+ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
 if (Invalid)
   *Invalid = MyInvalid;
 if (MyInvalid)
@@ -1685,14 +1685,13 @@ SourceLocation SourceManager::translateLineCol(FileID 
FID,
   if (Line == 1 && Col == 1)
 return FileLoc;
 
-  ContentCache *Content =
-  const_cast(().getContentCache());
+  const ContentCache *Content = ().getContentCache();
 
   // If this is the first use of line information for this buffer, compute the
   // SourceLineCache for it on demand.
   if (!Content->SourceLineCache) {
 bool MyInvalid = false;
-ComputeLineNumbers(Diag, Content, ContentCacheAlloc, *this, MyInvalid);
+ComputeLineNumbers(Diag, *Content, ContentCacheAlloc, *this, MyInvalid);
 if (MyInvalid)
   return SourceLocation();
   }

diff  --git a/clang/lib/Lex/ScratchBuffer.cpp b/clang/lib/Lex/ScratchBuffer.cpp
index 56ea9b71fd02..51435225a676 100644
--- a/clang/lib/Lex/ScratchBuffer.cpp
+++ b/clang/lib/Lex/ScratchBuffer.cpp
@@ -37,11 +37,10 @@ SourceLocation 

[PATCH] D69844: [clang][Basic] Integrate SourceLocation with FoldingSet, NFCI

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



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:1088
+  ID.Add(Range.getEnd());
+  ID.Add(static_cast(Loc));
 }

I'm surprised you need this `static_cast`, can you explain why it was necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69844

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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

IOW, the goal of formalizing would just be to:

- error if the `.td` file defined options in the wrong order to get correct 
parsing
- automatically generate the code for default value, instead of having to 
re-type the name of the keypath


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

https://reviews.llvm.org/D82756

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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D82756#2350233 , @jansvoboda11 
wrote:

> Correct me if I'm wrong, but when generating the command line, all "implied" 
> flags would be hidden, even if they were explicit in the original comand line:
>
> - original command line:  `clang -cc1 -cl-unsafe-math-optimizations 
> -cl-mad-enable -menable-unsafe-fp-math -mreassociate -fno-signed-zeros 
> -freciprocal-math -fapprox-func [...]`
> - generated command line: `clang -cc1 -cl-unsafe-math-optimizations [...]`
>
> This might be a bit surprising, but I don't think this would cause issues for 
> explicit modules. What are your thoughts?

I think this is fine. It's similar to a case where the caller might explicitly 
specify the default value, and it'll get canonicalized out.

> Formalizing the "implies" relationships would make it possible to remove the 
> ordering-sensitivity and possibly generate implied flags even when explicitly 
> passed to `cc1`. It would complicate the TableGen backend, which I'd prefer 
> to keep as simple as possible.

I was't thinking of dropping the ordering-sensitivity. Instead, you could just 
error if the referenced option hadn't declared already. One idea would be to 
change the tablegen to something like:

  MarshallingInfoFlag<
  "CodeGenOpts.LessPreciseFPMAD",
  DefaultAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>>;

in the definition of `cl_mad_enable`, then:

- error if they aren't defined first; and
- construct a default value out of the key-paths.

I think this would less error-prone for maintenance, since it designs away some 
really subtle bugs.


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

https://reviews.llvm.org/D82756

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


[clang] e7fe125 - [CUDA] Extract CUDA version from cuda.h if version.txt is not found

2020-10-23 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-10-23T10:03:30-07:00
New Revision: e7fe125b776bf08d95e60ff3354a5c836218a0e6

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

LOG: [CUDA] Extract CUDA version from cuda.h if version.txt is not found

If CUDA version can not be determined based on version.txt file, attempt to find
CUDA_VERSION macro in cuda.h.

This is a follow-up to D89752,

Differntial Revision: https://reviews.llvm.org/D89832

Added: 
clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/bin/.keep
clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/include/.keep
clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/lib/.keep
clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/lib64/.keep

clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
clang/test/Driver/Inputs/CUDA_102/usr/local/cuda/version.txt
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/include/cuda.h

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Cuda.h
clang/test/Driver/cuda-version-check.cu

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index ced2d4435cfe..5336e7648001 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -69,7 +69,7 @@ def err_drv_cuda_version_unsupported : Error<
   "install, pass a 
diff erent GPU arch with --cuda-gpu-arch, or pass "
   "--no-cuda-version-check.">;
 def warn_drv_unknown_cuda_version: Warning<
-  "Unknown CUDA version %0. Assuming the latest supported version %1">,
+  "Unknown CUDA version. %0 Assuming the latest supported version %1">,
   InGroup;
 def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host 
compilation.">;
 def err_drv_mix_cuda_hip : Error<"Mixed Cuda and HIP compilation is not 
supported.">;

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 197685b51df4..58178d5d11bc 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -32,29 +33,80 @@ using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
+namespace {
+struct CudaVersionInfo {
+  std::string DetectedVersion;
+  CudaVersion Version;
+};
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
-  Version = CudaVersion::UNKNOWN;
+CudaVersionInfo parseCudaVersionFile(llvm::StringRef V) {
+  V = V.trim();
   if (!V.startswith("CUDA Version "))
-return;
+return {V.str(), CudaVersion::UNKNOWN};
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
-  if (VersionParts.size() < 2)
-return;
-  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
-  Version = CudaStringToVersion(DetectedVersion);
-  if (Version != CudaVersion::UNKNOWN) {
-// TODO(tra): remove the warning once we have all features of 10.2 and 11.0
-// implemented.
-DetectedVersionIsNotSupported = Version > CudaVersion::LATEST_SUPPORTED;
-return;
-  }
+  return {"version.txt: " + V.str() + ".",
+  VersionParts.size() < 2
+  ? CudaVersion::UNKNOWN
+  : CudaStringToVersion(
+join_items(".", VersionParts[0], VersionParts[1]))};
+}
+
+CudaVersion getCudaVersion(uint32_t raw_version) {
+  if (raw_version < 7050)
+return CudaVersion::CUDA_70;
+  if (raw_version < 8000)
+return CudaVersion::CUDA_75;
+  if (raw_version < 9000)
+return CudaVersion::CUDA_80;
+  if (raw_version < 9010)
+return CudaVersion::CUDA_90;
+  if (raw_version < 9020)
+return CudaVersion::CUDA_91;
+  if (raw_version < 1)
+return CudaVersion::CUDA_92;
+  if (raw_version < 10010)
+return CudaVersion::CUDA_100;
+  if (raw_version < 10020)
+return CudaVersion::CUDA_101;
+  if (raw_version < 11000)
+return CudaVersion::CUDA_102;
+  if (raw_version < 11010)
+return CudaVersion::CUDA_110;
+  return CudaVersion::LATEST;
+}
 
-  Version = CudaVersion::LATEST_SUPPORTED;
-  DetectedVersionIsNotSupported = true;
+CudaVersionInfo parseCudaHFile(llvm::StringRef Input) {
+  // Helper lambda which skips the words if the line starts with them or 
returns
+  // None otherwise.
+  auto 

[PATCH] D89752: [CUDA] Improve clang's ability to detect recent CUDA versions.

2020-10-23 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65d206484c54: [CUDA] Improve clangs ability to detect 
recent CUDA versions. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89752

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/bin/.keep
  clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/include/.keep
  clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib/.keep
  clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib64/.keep
  
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
  clang/test/Driver/cuda-version-check.cu


Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,11 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// CUDA versions after 11.0 (update 1) do not carry version.txt file. Make sure
+// we still detect them as a new version and handle them the same as we handle
+// other new CUDA versions.
+// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
 // Make sure that we don't warn about CUDA version during C++ compilation.
 // RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
 // RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
@@ -65,5 +70,5 @@
 // ERR_SM61: error: GPU arch sm_61 {{.*}}
 // ERR_SM61-NOT: error: GPU arch sm_61
 
-// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest 
supported version
+// UNKNOWN_VERSION: Unknown CUDA version {{.*}}. Assuming the latest supported 
version
 // UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -155,9 +155,14 @@
 llvm::ErrorOr> VersionFile =
 FS.getBufferForFile(InstallPath + "/version.txt");
 if (!VersionFile) {
-  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
-  // version.txt isn't present.
-  Version = CudaVersion::CUDA_70;
+  // CUDA 7.0 and CUDA 11.1+ do not have version.txt file.
+  // Use libdevice file to distinguish 7.0 from the new versions.
+  if (FS.exists(LibDevicePath + "/libdevice.10.bc")) {
+Version = CudaVersion::LATEST;
+DetectedVersionIsNotSupported = Version > 
CudaVersion::LATEST_SUPPORTED;
+  } else {
+Version = CudaVersion::CUDA_70;
+  }
 } else {
   ParseCudaVersionFile((*VersionFile)->getBuffer());
 }


Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,11 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// CUDA versions after 11.0 (update 1) do not carry version.txt file. Make sure
+// we still detect them as a new version and handle them the same as we handle
+// other new CUDA versions.
+// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
 // Make sure that we don't warn about CUDA version during C++ compilation.
 // RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
 // RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
@@ -65,5 +70,5 @@
 // ERR_SM61: error: GPU arch sm_61 {{.*}}
 // ERR_SM61-NOT: error: GPU arch sm_61
 
-// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
+// UNKNOWN_VERSION: Unknown CUDA version {{.*}}. Assuming the latest supported version
 // UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -155,9 +155,14 @@
 llvm::ErrorOr> VersionFile =
 FS.getBufferForFile(InstallPath + "/version.txt");
 if (!VersionFile) {
-  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
-  // version.txt isn't present.
-  Version = CudaVersion::CUDA_70;
+  // CUDA 7.0 and CUDA 11.1+ do not 

[clang] 65d2064 - [CUDA] Improve clang's ability to detect recent CUDA versions.

2020-10-23 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-10-23T10:03:29-07:00
New Revision: 65d206484c54177641d4b11d42cab1f1acc8c0c7

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

LOG: [CUDA] Improve clang's ability to detect recent CUDA versions.

CUDA-11.1 does not carry version.txt which causes clang to assume that it's
CUDA-7.0, which used to be the only CUDA version w/o version.txt.

In order to tell CUDA-7.0 apart from the new versions, clang now probes for the
presence of libdevice.10.bc which is not present in the old CUDA versions.

This should keep Clang working for CUDA-11.1.

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

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

Added: 
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/bin/.keep
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/include/.keep
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib/.keep
clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib64/.keep

clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/nvvm/libdevice/libdevice.10.bc

Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/cuda-version-check.cu

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 217a0155a52d..197685b51df4 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -155,9 +155,14 @@ CudaInstallationDetector::CudaInstallationDetector(
 llvm::ErrorOr> VersionFile =
 FS.getBufferForFile(InstallPath + "/version.txt");
 if (!VersionFile) {
-  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
-  // version.txt isn't present.
-  Version = CudaVersion::CUDA_70;
+  // CUDA 7.0 and CUDA 11.1+ do not have version.txt file.
+  // Use libdevice file to distinguish 7.0 from the new versions.
+  if (FS.exists(LibDevicePath + "/libdevice.10.bc")) {
+Version = CudaVersion::LATEST;
+DetectedVersionIsNotSupported = Version > 
CudaVersion::LATEST_SUPPORTED;
+  } else {
+Version = CudaVersion::CUDA_70;
+  }
 } else {
   ParseCudaVersionFile((*VersionFile)->getBuffer());
 }

diff  --git a/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/bin/.keep 
b/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/bin/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/include/.keep 
b/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/include/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib/.keep 
b/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib64/.keep 
b/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/lib64/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
 
b/clang/test/Driver/Inputs/CUDA_111/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/cuda-version-check.cu 
b/clang/test/Driver/cuda-version-check.cu
index a09b248304f2..1e6af029202f 100644
--- a/clang/test/Driver/cuda-version-check.cu
+++ b/clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,11 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// CUDA versions after 11.0 (update 1) do not carry version.txt file. Make sure
+// we still detect them as a new version and handle them the same as we handle
+// other new CUDA versions.
+// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
 // Make sure that we don't warn about CUDA version during C++ compilation.
 // RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
 // RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
@@ -65,5 +70,5 @@
 // ERR_SM61: error: GPU arch sm_61 {{.*}}
 // ERR_SM61-NOT: error: GPU arch sm_61
 
-// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest 
supported version
+// UNKNOWN_VERSION: Unknown CUDA version {{.*}}. Assuming the latest supported 
version
 // UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version



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


[clang] dbbc4f4 - SourceManager: Encapsulate line number mapping into SrcMgr::LineOffsetMapping

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T12:55:51-04:00
New Revision: dbbc4f4e226be44e484f448be2d308d205c81038

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

LOG: SourceManager: Encapsulate line number mapping into 
SrcMgr::LineOffsetMapping

Put the guts of `ComputeLineNumbers` into `LineOffsetMapping::get` and
`LineOffsetMapping::LineOffsetMapping`.  As a drive-by, store the number
of lines directly in the bump-ptr-allocated array.

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

Added: 
clang/unittests/Basic/LineOffsetMappingTest.cpp

Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/ScratchBuffer.cpp
clang/unittests/Basic/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 06bec09cda98..00a790038dbf 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -90,6 +90,35 @@ namespace SrcMgr {
 return CK == C_User_ModuleMap || CK == C_System_ModuleMap;
   }
 
+  /// Mapping of line offsets into a source file. This does not own the storage
+  /// for the line numbers.
+  class LineOffsetMapping {
+  public:
+explicit operator bool() const { return Storage; }
+unsigned size() const {
+  assert(Storage);
+  return Storage[0];
+}
+ArrayRef getLines() const {
+  assert(Storage);
+  return ArrayRef(Storage + 1, Storage + 1 + size());
+}
+const unsigned *begin() const { return getLines().begin(); }
+const unsigned *end() const { return getLines().end(); }
+const unsigned [](int I) const { return getLines()[I]; }
+
+static LineOffsetMapping get(llvm::MemoryBufferRef Buffer,
+ llvm::BumpPtrAllocator );
+
+LineOffsetMapping() = default;
+LineOffsetMapping(ArrayRef LineOffsets,
+  llvm::BumpPtrAllocator );
+
+  private:
+/// First element is the size, followed by elements at off-by-one indexes.
+unsigned *Storage = nullptr;
+  };
+
   /// One instance of this struct is kept for every file loaded or used.
   ///
   /// This object owns the MemoryBuffer object.
@@ -115,14 +144,9 @@ namespace SrcMgr {
 
 /// A bump pointer allocated array of offsets for each source line.
 ///
-/// This is lazily computed.  This is owned by the SourceManager
+/// This is lazily computed.  The lines are owned by the SourceManager
 /// BumpPointerAllocator object.
-unsigned *SourceLineCache = nullptr;
-
-/// The number of lines in this ContentCache.
-///
-/// This is only valid if SourceLineCache is non-null.
-unsigned NumLines = 0;
+LineOffsetMapping SourceLineCache;
 
 /// Indicates whether the buffer itself was provided to override
 /// the actual file contents.
@@ -157,10 +181,8 @@ namespace SrcMgr {
   OrigEntry = RHS.OrigEntry;
   ContentsEntry = RHS.ContentsEntry;
 
-  assert(!RHS.Buffer && RHS.SourceLineCache == nullptr &&
+  assert(!RHS.Buffer && !RHS.SourceLineCache &&
  "Passed ContentCache object cannot own a buffer.");
-
-  NumLines = RHS.NumLines;
 }
 
 ContentCache =(const ContentCache& RHS) = delete;

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index d2015b55c03f..778fd0dca329 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1200,10 +1200,10 @@ unsigned SourceManager::getColumnNumber(FileID FID, 
unsigned FilePos,
   const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
-  if (LastLineNoFileIDQuery == FID &&
-  LastLineNoContentCache->SourceLineCache != nullptr &&
-  LastLineNoResult < LastLineNoContentCache->NumLines) {
-unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
+  if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache 
&&
+  LastLineNoResult < LastLineNoContentCache->SourceLineCache.size()) {
+const unsigned *SourceLineCache =
+LastLineNoContentCache->SourceLineCache.begin();
 unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
 unsigned LineEnd = SourceLineCache[LastLineNoResult];
 if (FilePos >= LineStart && FilePos < LineEnd) {
@@ -1274,6 +1274,11 @@ static void ComputeLineNumbers(DiagnosticsEngine , 
ContentCache *FI,
   if (Invalid)
 return;
 
+  FI->SourceLineCache = LineOffsetMapping::get(*Buffer, Alloc);
+}
+
+LineOffsetMapping LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
+ llvm::BumpPtrAllocator ) 

[PATCH] D89913: SourceManager: Encapsulate line number mapping into SrcMgr::LineOffsetMapping

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdbbc4f4e226b: SourceManager: Encapsulate line number mapping 
into SrcMgr::LineOffsetMapping (authored by dexonsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D89913?vs=27=300333#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89913

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/ScratchBuffer.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/LineOffsetMappingTest.cpp

Index: clang/unittests/Basic/LineOffsetMappingTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/LineOffsetMappingTest.cpp
@@ -0,0 +1,79 @@
+//===- unittests/Basic/LineOffsetMappingTest.cpp - Test LineOffsetMapping -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/SourceManager.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace clang::SrcMgr;
+using namespace llvm;
+
+namespace {
+
+TEST(LineOffsetMappingTest, empty) {
+  LineOffsetMapping Mapping;
+  EXPECT_FALSE(Mapping);
+
+#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  EXPECT_DEATH((void)Mapping.getLines(), "Assertion");
+#endif
+}
+
+TEST(LineOffsetMappingTest, construct) {
+  BumpPtrAllocator Alloc;
+  unsigned Offsets[] = {0, 10, 20};
+  LineOffsetMapping Mapping(Offsets, Alloc);
+  EXPECT_EQ(3u, Mapping.size());
+  EXPECT_EQ(0u, Mapping[0]);
+  EXPECT_EQ(10u, Mapping[1]);
+  EXPECT_EQ(20u, Mapping[2]);
+
+#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  EXPECT_DEATH((void)Mapping[3], "Assertion");
+#endif
+}
+
+TEST(LineOffsetMappingTest, constructTwo) {
+  // Confirm allocation size is big enough, convering an off-by-one bug.
+  BumpPtrAllocator Alloc;
+  unsigned Offsets1[] = {0, 10};
+  unsigned Offsets2[] = {0, 20};
+  LineOffsetMapping Mapping1(Offsets1, Alloc);
+  LineOffsetMapping Mapping2(Offsets2, Alloc);
+
+  // Need to check Mapping1 *after* building Mapping2.
+  EXPECT_EQ(2u, Mapping1.size());
+  EXPECT_EQ(0u, Mapping1[0]);
+  EXPECT_EQ(10u, Mapping1[1]);
+  EXPECT_EQ(2u, Mapping2.size());
+  EXPECT_EQ(0u, Mapping2[0]);
+  EXPECT_EQ(20u, Mapping2[1]);
+}
+
+TEST(LineOffsetMappingTest, get) {
+  BumpPtrAllocator Alloc;
+  StringRef Source = "first line\n"
+ "second line\n";
+  auto Mapping = LineOffsetMapping::get(MemoryBufferRef(Source, ""), Alloc);
+  EXPECT_EQ(3u, Mapping.size());
+  EXPECT_EQ(0u, Mapping[0]);
+  EXPECT_EQ(11u, Mapping[1]);
+  EXPECT_EQ(23u, Mapping[2]);
+}
+
+TEST(LineOffsetMappingTest, getMissingFinalNewline) {
+  BumpPtrAllocator Alloc;
+  StringRef Source = "first line\n"
+ "second line";
+  auto Mapping = LineOffsetMapping::get(MemoryBufferRef(Source, ""), Alloc);
+  EXPECT_EQ(2u, Mapping.size());
+  EXPECT_EQ(0u, Mapping[0]);
+  EXPECT_EQ(11u, Mapping[1]);
+}
+
+} // end namespace
Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -6,6 +6,7 @@
   CharInfoTest.cpp
   DiagnosticTest.cpp
   FileManagerTest.cpp
+  LineOffsetMappingTest.cpp
   SourceManagerTest.cpp
   )
 
Index: clang/lib/Lex/ScratchBuffer.cpp
===
--- clang/lib/Lex/ScratchBuffer.cpp
+++ clang/lib/Lex/ScratchBuffer.cpp
@@ -41,7 +41,7 @@
 (SourceMgr.getFileID(BufferStartLoc))
  .getFile()
  .getContentCache());
-ContentCache->SourceLineCache = nullptr;
+ContentCache->SourceLineCache = SrcMgr::LineOffsetMapping();
   }
 
   // Prefix the token with a \n, so that it looks like it is the first thing on
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1200,10 +1200,10 @@
   const char *Buf = MemBuf->getBufferStart();
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
-  if (LastLineNoFileIDQuery == FID &&
-  LastLineNoContentCache->SourceLineCache != nullptr &&
-  LastLineNoResult < LastLineNoContentCache->NumLines) {
-unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
+  if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache &&
+  LastLineNoResult < LastLineNoContentCache->SourceLineCache.size()) {
+const unsigned *SourceLineCache =
+

[PATCH] D89913: SourceManager: Encapsulate line number mapping into SrcMgr::LineOffsetMapping

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



Comment at: clang/include/clang/Basic/SourceManager.h:118
+  private:
+unsigned *Storage = nullptr;
+  };

JDevlieghere wrote:
> I guess it's implicit in the implementation, but maybe it's worth adding a 
> comment describing the layout (first element is the size, elements at index i 
> are at index i+1. 
Thanks, good idea; I'll have that in the commit.


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

https://reviews.llvm.org/D89913

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


[PATCH] D89580: SourceManager: Fix an SLocEntry memory regression introduced with FileEntryRef

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith planned changes to this revision.
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/SourceManager.h:293
   X.ContentAndKind.setInt(FileCharacter);
-  X.Filename = Filename;
+  const_cast(Con).Filename = Filename;
   return X;

JDevlieghere wrote:
> Would it possibly make more sense to drop the `const` qualifier from the 
> argument? 
Yes, that's probably better. I'll make a prep commit that changes 
`getOrCreateContentCache()` to return non-`const` and thread that through to 
here, and then this is just `Con.Filename = Filename`.


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

https://reviews.llvm.org/D89580

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


[clang] 74a8783 - SourceManager: Clarify that FileInfo always has a ContentCache, NFC

2020-10-23 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-23T12:38:53-04:00
New Revision: 74a8783480219f5f0e5c4673a6d0e29b4ad99877

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

LOG: SourceManager: Clarify that FileInfo always has a ContentCache, NFC

It turns out that `FileInfo` *always* has a ContentCache. Clarify that
in the code:
- Update the private version of `SourceManager::createFileID` to take a
  `ContentCache&` instead of `ContentCache*`, and rename it to
  `createFileIDImpl` for clarity.
- Change `FileInfo::getContentCache` to return a reference.

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/AST/ASTImporter.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/ScratchBuffer.cpp
clang/lib/Rewrite/Rewriter.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndexInclusionStack.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 5035326297f7..06bec09cda98 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -275,13 +275,13 @@ namespace SrcMgr {
 
   public:
 /// Return a FileInfo object.
-static FileInfo get(SourceLocation IL, const ContentCache *Con,
+static FileInfo get(SourceLocation IL, const ContentCache ,
 CharacteristicKind FileCharacter, StringRef Filename) {
   FileInfo X;
   X.IncludeLoc = IL.getRawEncoding();
   X.NumCreatedFIDs = 0;
   X.HasLineDirectives = false;
-  X.ContentAndKind.setPointer(Con);
+  X.ContentAndKind.setPointer();
   X.ContentAndKind.setInt(FileCharacter);
   X.Filename = Filename;
   return X;
@@ -291,8 +291,8 @@ namespace SrcMgr {
   return SourceLocation::getFromRawEncoding(IncludeLoc);
 }
 
-const ContentCache *getContentCache() const {
-  return ContentAndKind.getPointer();
+const ContentCache () const {
+  return *ContentAndKind.getPointer();
 }
 
 /// Return whether this is a system header or not.
@@ -973,7 +973,7 @@ class SourceManager : public RefCountedBase {
   llvm::Optional
   getBufferOrNone(FileID FID, SourceLocation Loc = SourceLocation()) const {
 if (auto *Entry = getSLocEntryForFile(FID))
-  return Entry->getFile().getContentCache()->getBufferOrNone(
+  return Entry->getFile().getContentCache().getBufferOrNone(
   Diag, getFileManager(), Loc);
 return None;
   }
@@ -992,8 +992,7 @@ class SourceManager : public RefCountedBase {
   /// Returns the FileEntry record for the provided FileID.
   const FileEntry *getFileEntryForID(FileID FID) const {
 if (auto *Entry = getSLocEntryForFile(FID))
-  if (auto *Content = Entry->getFile().getContentCache())
-return Content->OrigEntry;
+  return Entry->getFile().getContentCache().OrigEntry;
 return nullptr;
   }
 
@@ -1006,10 +1005,7 @@ class SourceManager : public 
RefCountedBase {
   /// Returns the FileEntry record for the provided SLocEntry.
   const FileEntry *getFileEntryForSLocEntry(const SrcMgr::SLocEntry ) 
const
   {
-const SrcMgr::ContentCache *Content = sloc.getFile().getContentCache();
-if (!Content)
-  return nullptr;
-return Content->OrigEntry;
+return sloc.getFile().getContentCache().OrigEntry;
   }
 
   /// Return a StringRef to the source buffer data for the
@@ -1793,10 +1789,10 @@ class SourceManager : public 
RefCountedBase {
   ///
   /// This works regardless of whether the ContentCache corresponds to a
   /// file or some other input source.
-  FileID createFileID(const SrcMgr::ContentCache *File, StringRef Filename,
-  SourceLocation IncludePos,
-  SrcMgr::CharacteristicKind DirCharacter, int LoadedID,
-  unsigned LoadedOffset);
+  FileID createFileIDImpl(const SrcMgr::ContentCache , StringRef Filename,
+  SourceLocation IncludePos,
+  SrcMgr::CharacteristicKind DirCharacter, int 
LoadedID,
+  unsigned LoadedOffset);
 
   const SrcMgr::ContentCache *
 getOrCreateContentCache(const FileEntry *SourceFile,

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index ce79b99d7043..f15be09f0e5d 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8654,7 +8654,7 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
 }
 ToID = ToSM.getFileID(MLoc);
   } else {
-const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache();
+const SrcMgr::ContentCache *Cache = ().getContentCache();
 
 if (!IsBuiltin && !Cache->BufferOverridden) {
   

[PATCH] D89554: SourceManager: Clarify that FileInfo always has a ContentCache, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74a878348021: SourceManager: Clarify that FileInfo always 
has a ContentCache, NFC (authored by dexonsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D89554?vs=298634=300329#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89554

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/ScratchBuffer.cpp
  clang/lib/Rewrite/Rewriter.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndexInclusionStack.cpp

Index: clang/tools/libclang/CIndexInclusionStack.cpp
===
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -35,7 +35,7 @@
   continue;
 
 const SrcMgr::FileInfo  = SL.getFile();
-if (!FI.getContentCache()->OrigEntry)
+if (!FI.getContentCache().OrigEntry)
   continue;
 
 // If this is the main file, and there is a preamble, skip this SLoc. The
@@ -60,7 +60,7 @@
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
-   const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache().OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1452,7 +1452,7 @@
 if (!SLoc->isFile())
   continue;
 const SrcMgr::FileInfo  = SLoc->getFile();
-const SrcMgr::ContentCache *Cache = File.getContentCache();
+const SrcMgr::ContentCache *Cache = ();
 if (!Cache->OrigEntry)
   continue;
 
@@ -1952,7 +1952,7 @@
 // Figure out which record code to use.
 unsigned Code;
 if (SLoc->isFile()) {
-  const SrcMgr::ContentCache *Cache = SLoc->getFile().getContentCache();
+  const SrcMgr::ContentCache *Cache = >getFile().getContentCache();
   if (Cache->OrigEntry) {
 Code = SM_SLOC_FILE_ENTRY;
   } else
@@ -1970,7 +1970,7 @@
   Record.push_back(File.getFileCharacteristic()); // FIXME: stable encoding
   Record.push_back(File.hasLineDirectives());
 
-  const SrcMgr::ContentCache *Content = File.getContentCache();
+  const SrcMgr::ContentCache *Content = ();
   bool EmitBlob = false;
   if (Content->OrigEntry) {
 assert(Content->OrigEntry == Content->ContentsEntry &&
Index: clang/lib/Rewrite/Rewriter.cpp
===
--- clang/lib/Rewrite/Rewriter.cpp
+++ clang/lib/Rewrite/Rewriter.cpp
@@ -263,8 +263,8 @@
 StringRef MB = SourceMgr->getBufferData(FID);
 
 unsigned lineNo = SourceMgr->getLineNumber(FID, StartOffs) - 1;
-const SrcMgr::ContentCache *
-Content = SourceMgr->getSLocEntry(FID).getFile().getContentCache();
+const SrcMgr::ContentCache *Content =
+>getSLocEntry(FID).getFile().getContentCache();
 unsigned lineOffs = Content->SourceLineCache[lineNo];
 
 // Find the whitespace at the start of the line.
@@ -367,8 +367,8 @@
   unsigned startLineNo = SourceMgr->getLineNumber(FID, StartOff) - 1;
   unsigned endLineNo = SourceMgr->getLineNumber(FID, EndOff) - 1;
 
-  const SrcMgr::ContentCache *
-  Content = SourceMgr->getSLocEntry(FID).getFile().getContentCache();
+  const SrcMgr::ContentCache *Content =
+  >getSLocEntry(FID).getFile().getContentCache();
 
   // Find where the lines start.
   unsigned parentLineOffs = Content->SourceLineCache[parentLineNo];
Index: clang/lib/Lex/ScratchBuffer.cpp
===
--- clang/lib/Lex/ScratchBuffer.cpp
+++ clang/lib/Lex/ScratchBuffer.cpp
@@ -38,8 +38,9 @@
 // Clear out the source line cache if it's already been computed.
 // FIXME: Allow this to be incrementally extended.
 auto *ContentCache = const_cast(
-SourceMgr.getSLocEntry(SourceMgr.getFileID(BufferStartLoc))
- .getFile().getContentCache());
+(SourceMgr.getFileID(BufferStartLoc))
+ .getFile()
+ .getContentCache());
 ContentCache->SourceLineCache = nullptr;
   }
 
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -437,7 +437,7 @@
 if (!SLocEntryLoaded[Index]) {
   // Try to recover; create a SLocEntry so the rest of clang can handle it.
   LoadedSLocEntryTable[Index] = SLocEntry::get(
-  0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(),
+  0, 

[PATCH] D89832: [CUDA] Extract CUDA version from cuda.h if version.txt is not found

2020-10-23 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D89832#2349915 , @emankov wrote:

> I confirm that D89752  eliminates 47332 
>  on Windows. Tested against the 
> following CUDA versions: 7.0, 7,5, 9,2, 10.0, 10,1, 10.2, 11.0 Update 1, 11.1.

Thank you! I appreciate your help testing this patch. I'll land the patches 
shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89832

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


[PATCH] D89987: [analyzer] [NFC] Rename SymbolRef to SymExprRef

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

In D89987#2349959 , @ASDenysPetrov 
wrote:

> @OikawaKirie
>
>> Different from ProgramStateRef which is an alias to IntrusiveRefCntPtr, or 
>> StoreRef which is a wrapper object, an alias to a const SymExpr * makes no 
>> sense to me.
>
> Yes. I omit this, because in such case we should go further and rename all 
> those which are not real `Ref` to `Ptr` or smth that would emphasise that 
> it's just a pointer alias, not a wrapper or another class.
> That's why I prefered to change the name a little in favor of complex 
> approach of renaming all the rest.
>
>> And this is also where I have been confused for a long while.
>
> So have been I. The patch is called to make it more clear :)
>
> Thanks to @steakhal comment I investigated more in terms of what other names 
> use `Symbol` but mean `SymExpr`. They are:
>
>   class SymbolManager;
>   using SymbolID;
>   using SymbolDependTy;
>   class SymbolData;
>   class SymbolMetadata;
>   class SymbolReaper;
>   enum SymbolStatus;
>   using SymbolSetTy;
>   using SymbolMapTy;
>   class SymbolCast;
>   class SymbolVal;
>   class symbol_iterator;
>   etc.
>
> This is not a full list! I also didn't count //methods// and //file names//.
> There is also a list of objects names which straightly use `SymExpr`. They 
> are less spread. Mostly they are derived classes:
>
>   class BinarySymExprImpl;
>   class SymIntExpr;
>   class IntSymExpr;
>   class SymSymExpr;
>   some enums, several methods, etc.
>
> As a result we should accurately define the difference between `Symbol` and 
> `SymExpr`.

There are some cases, when `Symbol` refers to the base-class of the inheritance 
hierachy. In those cases the renaming would be appropiate.
Though, I'm sure there are cases, when the `Symbol` refers simply to 
`SymbolData` - in which cases we should rename accordingly.

At the previous LLVM SA round table @xazax.hun also mentioned that we could 
have chosen better names. Maybe it's the time to have consensus about this.

> I see the next options:
>
> 1. `Symbol` and `SymExpr` are different. Leave the names as are. Fix minor 
> mismatches if presented. And follow that definitions.
> 2. `Symbol` and `SymExpr` are the same. `SymExpr` is a dominant one. Change 
> all the names from `Symbol` to `SymExpr` and get rid of `Symbol`.
> 3. `Symbol` and `SymExpr` are the same. `Symbol` is a dominant one. Change 
> all the names from `SymExpr` to `Symbol` and get rid of `SymExpr`.
> 4. Ignore the naming due to loss of **git blame** (or any other reason) like 
> in an llvm naming rules topic.

Losing **git blame** would have a signifficant impact in deed, however we 
always have the option to add the renaming commit to the 
`.git-blame-ignore-revs`.
To achieve that, we should probably have a better reason behind it besides 
simply //renaming// stuff.

> 5. For now just rename `SymbolRef` alias as the beggining of the story in 
> scope of 2nd option.
>
> What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89987

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


[PATCH] D90047: [clangd] Fix remote-server build and add it to check-clangd

2020-10-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dd39923a09e: [clangd] Fix remote-server build and add it to 
check-clangd (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90047

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,6 +21,10 @@
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
+if(CLANGD_ENABLE_REMOTE)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+endif()
+
 foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -33,8 +33,6 @@
 #include 
 #include 
 
-#include "Index.grpc.pb.h"
-
 namespace clang {
 namespace clangd {
 namespace remote {


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,6 +21,10 @@
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
+if(CLANGD_ENABLE_REMOTE)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+endif()
+
 foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -33,8 +33,6 @@
 #include 
 #include 
 
-#include "Index.grpc.pb.h"
-
 namespace clang {
 namespace clangd {
 namespace remote {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5dd3992 - [clangd] Fix remote-server build and add it to check-clangd

2020-10-23 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-10-23T18:08:02+02:00
New Revision: 5dd39923a09ec284d30083e5fadaa29e618d4446

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

LOG: [clangd] Fix remote-server build and add it to check-clangd

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/test/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 750c659381af..7b68549a4afd 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -33,8 +33,6 @@
 #include 
 #include 
 
-#include "Index.grpc.pb.h"
-
 namespace clang {
 namespace clangd {
 namespace remote {

diff  --git a/clang-tools-extra/clangd/test/CMakeLists.txt 
b/clang-tools-extra/clangd/test/CMakeLists.txt
index 878408cc5483..ade42ac457e0 100644
--- a/clang-tools-extra/clangd/test/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,6 +21,10 @@ if(CLANGD_BUILD_XPC)
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
+if(CLANGD_ENABLE_REMOTE)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+endif()
+
 foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})



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


[PATCH] D90054: Added remotely ran compiler-rt tests.

2020-10-23 Thread Alex Orlov via Phabricator via cfe-commits
aorlov created this revision.
aorlov added reviewers: vvereschaka, broadwaylamb.
aorlov added a project: LLVM.
Herald added subscribers: cfe-commits, mgorny, dberris.
Herald added a project: clang.
aorlov requested review of this revision.

Use LLVM/utils/remote-exec.py to run compiler-rt tests remotely on the target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90054

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -72,6 +72,7 @@
 set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
 set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
 set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS   ON CACHE BOOL "")
 
 set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
 set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
@@ -108,6 +109,9 @@
   set(DEFAULT_TEST_TARGET_INFO  
"libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.
+  if(NOT DEFINED COMPILER_RT_EMULATOR)
+set(COMPILER_RT_EMULATOR"\\\"${Python3_EXECUTABLE}\\\" 
\\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --execdir %%T 
--exec-pattern='.*\\.c.*\\.tmp.*' 
--host='${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}'" CACHE STRING "")
+  endif()
   if(NOT DEFINED LIBUNWIND_TARGET_INFO)
 set(LIBUNWIND_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" 
CACHE STRING "")
   endif()


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -72,6 +72,7 @@
 set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
 set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
 set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS   ON CACHE BOOL "")
 
 set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
 set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
@@ -108,6 +109,9 @@
   set(DEFAULT_TEST_TARGET_INFO  "libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.
+  if(NOT DEFINED COMPILER_RT_EMULATOR)
+set(COMPILER_RT_EMULATOR"\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --execdir %%T --exec-pattern='.*\\.c.*\\.tmp.*' --host='${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}'" CACHE STRING "")
+  endif()
   if(NOT DEFINED LIBUNWIND_TARGET_INFO)
 set(LIBUNWIND_TARGET_INFO   "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90053: Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC

2020-10-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere, teemperor.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Change the `InputFile` class to store a `MaybeFileEntryRef` instead of
`FileEntry*`. This paged in a few API changes:

- Added `FileManager::getVirtualFileRef`, and converted `getVirtualFile` to a 
wrapper of it.
- Added `{Maybe,}FileEntryRef::getMapEntry`, which gives access to the 
underlying `StringMapEntry*` pointer, to enable clients (`InputFile`) to store 
a `FileEntryRef` in a `PointerIntPair`.
- Updated `SourceManager::bypassFileContentsOverride` to take `FileEntryRef` 
and return `MaybeFileEntry` (`ASTReader::getInputFile` is the only caller).


https://reviews.llvm.org/D90053

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/unittests/Basic/FileEntryTest.cpp

Index: clang/unittests/Basic/FileEntryTest.cpp
===
--- clang/unittests/Basic/FileEntryTest.cpp
+++ clang/unittests/Basic/FileEntryTest.cpp
@@ -112,6 +112,7 @@
   FileEntryRef R1Also = addRef(Refs, "1-also", E1);
 
   EXPECT_TRUE(R1.isSameRef(FileEntryRef(R1)));
+  EXPECT_TRUE(R1.isSameRef(FileEntryRef(R1.getMapEntry(;
   EXPECT_FALSE(R1.isSameRef(R2));
   EXPECT_FALSE(R1.isSameRef(R1Also));
 
@@ -123,6 +124,7 @@
   EXPECT_FALSE(M0.isSameRef(M1));
   EXPECT_FALSE(M1.isSameRef(M0));
   EXPECT_TRUE(M1.isSameRef(MaybeFileEntryRef(M1)));
+  EXPECT_TRUE(M1.isSameRef(MaybeFileEntryRef(M1.getMapEntry(;
   EXPECT_FALSE(M1.isSameRef(M1Also));
   EXPECT_FALSE(M1.isSameRef(M2));
   EXPECT_TRUE(M1.isSameRef(R1));
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2312,27 +2312,25 @@
   StringRef Filename = FI.Filename;
   uint64_t StoredContentHash = FI.ContentHash;
 
-  const FileEntry *File = nullptr;
-  if (auto FE = FileMgr.getFile(Filename, /*OpenFile=*/false))
-File = *FE;
+  MaybeFileEntryRef File =
+  expectedToOptional(FileMgr.getFileRef(Filename, /*OpenFile=*/false));
 
   // If we didn't find the file, resolve it relative to the
   // original directory from which this AST file was created.
-  if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
+  if (!File && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
   F.OriginalDir != F.BaseDirectory) {
 std::string Resolved = resolveFileRelativeToOriginalDir(
 std::string(Filename), F.OriginalDir, F.BaseDirectory);
 if (!Resolved.empty())
-  if (auto FE = FileMgr.getFile(Resolved))
-File = *FE;
+  File = expectedToOptional(FileMgr.getFileRef(Resolved));
   }
 
   // For an overridden file, create a virtual file with the stored
   // size/timestamp.
-  if ((Overridden || Transient) && File == nullptr)
-File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
+  if ((Overridden || Transient) && !File)
+File = FileMgr.getVirtualFileRef(Filename, StoredSize, StoredTime);
 
-  if (File == nullptr) {
+  if (!File) {
 if (Complain) {
   std::string ErrorStr = "could not find file '";
   ErrorStr += Filename;
@@ -2443,7 +2441,7 @@
   // FIXME: If the file is overridden and we've already opened it,
   // issue an error (or split it into a separate FileEntry).
 
-  InputFile IF = InputFile(File, Overridden || Transient, IsOutOfDate);
+  InputFile IF = InputFile(*File, Overridden || Transient, IsOutOfDate);
 
   // Note that we've loaded this input file.
   F.InputFilesLoaded[ID-1] = IF;
@@ -9195,7 +9193,7 @@
 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
 if (IFI.TopLevelModuleMap)
   // FIXME: This unnecessarily re-reads the InputFileInfo.
-  if (auto *FE = getInputFile(MF, I + 1).getFile())
+  if (auto FE = getInputFile(MF, I + 1).getFile())
 Visitor(FE);
   }
 }
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -703,19 +703,16 @@
   getOverriddenFilesInfo().OverriddenFiles[SourceFile] = NewFile;
 }
 
-const FileEntry *
-SourceManager::bypassFileContentsOverride(const FileEntry ) {
-  assert(isFileOverridden());
-  llvm::Optional BypassFile =
-  FileMgr.getBypassFile(File.getLastRef());
+MaybeFileEntryRef SourceManager::bypassFileContentsOverride(FileEntryRef File) {
+  assert(isFileOverridden(()));
+  llvm::Optional BypassFile = FileMgr.getBypassFile(File);
 
   // If the file can't be found in the FS, give up.
   if (!BypassFile)
-return nullptr;
+return None;
 
-  const FileEntry *FE 

[PATCH] D89994: [libomptarget][nvptx] Undef, internal shared variables

2020-10-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:2858
 TransferMedium = new llvm::GlobalVariable(
-M, Ty, /*isConstant=*/false, llvm::GlobalVariable::CommonLinkage,
-llvm::Constant::getNullValue(Ty), TransferMediumName,
+M, Ty, /*isConstant=*/false, llvm::GlobalVariable::InternalLinkage,
+llvm::UndefValue::get(Ty), TransferMediumName,

jdoerfert wrote:
> ABataev wrote:
> > "Internalization" is not the best option, it increases mem pressure. Common 
> > linkage is a better choice, allows to "squash" the same objects, defined in 
> > different units. Make it arch dependable, maybe?
> > For NVPTX zero initialization is not a problem, it is resolved when PTX is 
> > generated.
> FWIW, if we do not depend on the zero initialization, we should go with undef.
> 
Sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89994

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


[PATCH] D89994: [libomptarget][nvptx] Undef, internal shared variables

2020-10-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:2858
 TransferMedium = new llvm::GlobalVariable(
-M, Ty, /*isConstant=*/false, llvm::GlobalVariable::CommonLinkage,
-llvm::Constant::getNullValue(Ty), TransferMediumName,
+M, Ty, /*isConstant=*/false, llvm::GlobalVariable::InternalLinkage,
+llvm::UndefValue::get(Ty), TransferMediumName,

ABataev wrote:
> "Internalization" is not the best option, it increases mem pressure. Common 
> linkage is a better choice, allows to "squash" the same objects, defined in 
> different units. Make it arch dependable, maybe?
> For NVPTX zero initialization is not a problem, it is resolved when PTX is 
> generated.
FWIW, if we do not depend on the zero initialization, we should go with undef.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89994

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


[PATCH] D83088: Introduce CfgTraits abstraction

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

In D83088#2348641 , @mehdi_amini wrote:

> In D83088#2347111 , @arsenm wrote:
>
>> In D83088#2346322 , @mehdi_amini 
>> wrote:
>>
>>> In D83088#2345540 , @nhaehnle 
>>> wrote:
>>>
 David, I don't think this is appropriate here. Let's take the discussion 
 to llvm-dev.
>>>
>>> Seems like David asked to revert in the meantime?
>>
>> -1 to reverting, which will just make the history messier with no tangible 
>> benefit
>
> This is the usual LLVM policy I believe: someone expressed a concern and ask 
> to revert. We revert and discuss first.
> So again: please revert.
>
> The messier history is not an argument: we revert so many times for any 
> random bot failures already, and our contribution guidelines still tell 
> people to push a "fake commit" with a whitespace change to test their access.

Unrelated, but I think the test commit process should be dropped

> I also see tangile benefits:
>
> - we don't start building dependencies on newly introduced API making a 
> revert more difficult later.
> - the burden of convincing of the approach is on the patch author, reverting 
> is forcing the discussion here.

This patch has been up for review for almost 4 months, with a corresponding RFC 
on llvm-dev. The last review comments were over 2 months ago. Coming back to 
this so long after to ask for a revert is an unworkable level of review 
paralysis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D83088: Introduce CfgTraits abstraction

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

Hi Mehdi, this is not an appropriate place for this discussion. Yes, we have a 
general rule that patches can be reverted if they're obviously broken (e.g. 
build bot problems) or clearly violate some other standard. This is a good 
rule, but it doesn't apply here. If you think it does, please state your case 
in the email thread that I've started on llvm-dev for this very purpose. Just 
one thing:

> - the burden of convincing of the approach is on the patch author, reverting 
> is forcing the discussion here.

I was trying to have this conversation. I am more than happy to have it, and I 
would be happy for me people to participate! But what can I do if the only(!) 
person who voices concerns just goes into radio silence, and the total number 
of people who participate is small in any case, despite raising it on llvm-dev 
as well?

It is in fact the decision to **not** revert the change which is apparently 
required to force the discussion!

P.S.: It's easy to miss on Phabricator, but there is already a long stack of 
patches which build on this. In a way this is a good thing because it can 
inform the discussion, but I will hold off from pushing more for now even 
though many of them have already been accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-10-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

@dexonsmith, thanks for sharing your idea. Overall, I like the simplicity.

As you say, not every command line option has an associated `CodeGenOptions` or 
`LangOptions` field. For this patch only, we'd need to create the following 
fields:

- `CLUnsafeOptimizations` for `OPT_cl_unsafe_math_optimizations`
- `CLFiniteMathOnly` for `OPT_cl_finite_math_only`
- `CLNoSignedZeros` for `OPT_cl_no_signed_zeros`

I'm not sure how many other cases there are outside of what this patch touches.

Introducing ordering-sensitivity is not ideal, but if all options are defined 
in close proximity to each other, it should be relatively easy to reason about.

Correct me if I'm wrong, but when generating the command line, all "implied" 
flags would be hidden, even if they were explicit in the original comand line:

- original command line:  `clang -cc1 -cl-unsafe-math-optimizations 
-cl-mad-enable -menable-unsafe-fp-math -mreassociate -fno-signed-zeros 
-freciprocal-math -fapprox-func [...]`
- generated command line: `clang -cc1 -cl-unsafe-math-optimizations [...]`

This might be a bit surprising, but I don't think this would cause issues for 
explicit modules. What are your thoughts?

Formalizing the "implies" relationships would make it possible to remove the 
ordering-sensitivity and possibly generate implied flags even when explicitly 
passed to `cc1`. It would complicate the TableGen backend, which I'd prefer to 
keep as simple as possible.


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

https://reviews.llvm.org/D82756

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


[PATCH] D90047: [clangd] Fix remote-server build and add it to check-clangd

2020-10-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90047

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


[PATCH] D89814: [TableGen] Change !getop and !setop to !getdagop and !setdagop

2020-10-23 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG876af264c118: [TableGen] Change !getop and !setop to 
!getdagop and !setdagop. (authored by Paul-C-Anagnostopoulos).

Changed prior to commit:
  https://reviews.llvm.org/D89814?vs=299428=300289#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89814

Files:
  clang/include/clang/Basic/arm_mve.td
  llvm/docs/TableGen/ProgRef.rst
  llvm/include/llvm/TableGen/Record.h
  llvm/lib/TableGen/Record.cpp
  llvm/lib/TableGen/TGLexer.cpp
  llvm/lib/TableGen/TGLexer.h
  llvm/lib/TableGen/TGParser.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/TableGen/getsetop.td

Index: llvm/test/TableGen/getsetop.td
===
--- llvm/test/TableGen/getsetop.td
+++ llvm/test/TableGen/getsetop.td
@@ -3,6 +3,9 @@
 // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s
 
+// !setop and !getop are deprecated in favor of !setdagop and !getdagop.
+// Two tests retain the old names just to be sure they are still supported.
+
 class Base;
 class OtherBase;
 
@@ -18,28 +21,28 @@
   dag replaceWithBar = !setop(orig, bar);
 
   // CHECK: dag replaceWithBaz = (qux 1, 2:$a, ?:$b);
-  dag replaceWithBaz = !setop(orig, qux);
+  dag replaceWithBaz = !setdagop(orig, qux);
 
   // CHECK: Base getopWithCast = foo;
   Base getopWithCast = !getop(orig);
 
   // CHECK: dag getopToSetop = (foo "hello", ?:$world);
-  dag getopToSetop = !setop(another, !getop(orig));
+  dag getopToSetop = !setdagop(another, !getdagop(orig));
 
   // CHECK: dag getopToBangDag = (foo 1:$a, 2:$b, 3:$c);
-  dag getopToBangDag = !dag(!getop(orig), [1, 2, 3], ["a", "b", "c"]);
+  dag getopToBangDag = !dag(!getdagop(orig), [1, 2, 3], ["a", "b", "c"]);
 
   // CHECK: dag getopToDagInit = (foo "it worked");
-  dag getopToDagInit = (!getop(orig) "it worked");
+  dag getopToDagInit = (!getdagop(orig) "it worked");
 
 #ifdef ERROR1
-  // !getop(...) has a static type of 'any record at all, with no
+  // !getdagop(...) has a static type of 'any record at all, with no
   // required superclasses'. That's too general to use in an
   // assignment whose LHS demands an instance of Base, so we expect a
   // static (parse-time) type-checking error.
 
-  // ERROR1: error: Field 'noCast' of type 'Base' is incompatible with value '!getop(orig)' of type '{}'
-  Base noCast = !getop(orig);
+  // ERROR1: error: Field 'noCast' of type 'Base' is incompatible with value '!getdagop(orig)' of type '{}'
+  Base noCast = !getdagop(orig);
 #endif
 
 #ifdef ERROR2
@@ -47,15 +50,15 @@
   // evaluation time that the operator of 'another' is a record that
   // isn't an instance of the specified base class.
 
-  // ERROR2: error: Expected type 'Base', got 'OtherBase' in: !getop((qux "hello", ?:$world))
-  Base badCast = !getop(another);
+  // ERROR2: error: Expected type 'Base', got 'OtherBase' in: !getdagop((qux "hello", ?:$world))
+  Base badCast = !getdagop(another);
 #endif
 
 #ifdef ERROR3
-  // Obviously, you shouldn't be able to give any type to !getop that
+  // Obviously, you shouldn't be able to give any type to !getdagop that
   // isn't a class type.
 
-  // ERROR3: error: type for !getop must be a record type
-  int ridiculousCast = !getop(orig);
+  // ERROR3: error: type for !getdagop must be a record type
+  int ridiculousCast = !getdagop(orig);
 #endif
 }
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3033,7 +3033,7 @@
   defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
(imm:$imm));
 
-  def : Pat<(OutVTI.Vec !setop(inparams, int_arm_mve_vshrn)),
+  def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)),
 (OutVTI.Vec outparams)>;
   def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated
(InVTI.Pred VCCR:$pred,
@@ -3235,7 +3235,7 @@
   defvar unpred_int = !cast("int_arm_mve_" # name);
   defvar pred_int = !cast("int_arm_mve_" # name # "_predicated");
 
-  def : Pat<(VTI.Vec !setop(inparams, unpred_int)),
+  def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)),
 (VTI.Vec outparams)>;
   def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred,
 (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred)))>;
Index: llvm/lib/TableGen/TGParser.cpp
===
--- llvm/lib/TableGen/TGParser.cpp
+++ llvm/lib/TableGen/TGParser.cpp
@@ -813,12 +813,12 @@
   TokError("expected '<' after bits type");
   return nullptr;
 }
-if (Lex.Lex() != 

[PATCH] D90047: [clangd] Fix remote-server build and add it to check-clangd

2020-10-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgorny.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90047

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,6 +21,10 @@
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
+if(CLANGD_ENABLE_REMOTE)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+endif()
+
 foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -33,8 +33,6 @@
 #include 
 #include 
 
-#include "Index.grpc.pb.h"
-
 namespace clang {
 namespace clangd {
 namespace remote {


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,6 +21,10 @@
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
+if(CLANGD_ENABLE_REMOTE)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+endif()
+
 foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -33,8 +33,6 @@
 #include 
 #include 
 
-#include "Index.grpc.pb.h"
-
 namespace clang {
 namespace clangd {
 namespace remote {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 876af26 - [TableGen] Change !getop and !setop to !getdagop and !setdagop.

2020-10-23 Thread Paul C. Anagnostopoulos via cfe-commits

Author: Paul C. Anagnostopoulos
Date: 2020-10-23T10:36:05-04:00
New Revision: 876af264c118c6ebcb8d79ab1a25d061f98fde82

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

LOG: [TableGen] Change !getop and !setop to !getdagop and !setdagop.

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGParser.cpp
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/TableGen/getsetop.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 94f76dd729b0..8106f9a5a9de 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -545,8 +545,8 @@ multiclass Reduction basetypes,
   defvar intArgsUnpred = !con(intArgsBase,
   !if(needSign, (? (unsignedflag Scalar)), (?)));
   defvar intArgsPred   = !con(intArgsUnpred, (? $pred));
-  defvar intUnpred = !setop(intArgsUnpred, IRInt);
-  defvar intPred   = !setop(intArgsPred, IRInt<
+  defvar intUnpred = !setdagop(intArgsUnpred, IRInt);
+  defvar intPred   = !setdagop(intArgsPred, IRInt<
 basename#"_predicated", !listconcat(basetypes, [Predicate])>);
 
   def "": Intrinsic<

diff  --git a/llvm/docs/TableGen/ProgRef.rst b/llvm/docs/TableGen/ProgRef.rst
index fa9989d77a24..f1179f076d9d 100644
--- a/llvm/docs/TableGen/ProgRef.rst
+++ b/llvm/docs/TableGen/ProgRef.rst
@@ -206,13 +206,13 @@ TableGen provides "bang operators" that have a wide 
variety of uses:
 
 .. productionlist::
BangOperator: one of
-   : !add !and !cast!con !dag
-   : !empty   !eq  !foldl   !foreach !ge
-   : !getop   !gt  !head!if  !isa
-   : !le  !listconcat  !listsplat   !lt  !mul
-   : !ne  !not !or  !setop   !shl
-   : !size!sra !srl !strconcat   !subst
-   : !tail!xor
+   : !add!and !cast!con !dag
+   : !empty  !eq  !foldl   !foreach !ge
+   : !getdagop   !gt  !head!if  !isa
+   : !le !listconcat  !listsplat   !lt  !mul
+   : !ne !not !or  !setdagop!shl
+   : !size   !sra !srl !strconcat   !subst
+   : !tail   !xor
 
 The ``!cond`` operator has a slightly 
diff erent
 syntax compared to other bang operators, so it is defined separately:
@@ -1243,7 +1243,7 @@ or to associate an argument in one DAG with a like-named 
argument in another
 DAG.
 
 The following bang operators are useful for working with DAGs:
-``!con``, ``!dag``, ``!empty``, ``!foreach``, ``!getop``, ``!setop``, 
``!size``.
+``!con``, ``!dag``, ``!empty``, ``!foreach``, ``!getdagop``, ``!setdagop``, 
``!size``.
 
 Defvar in a record body
 ---
@@ -1445,6 +1445,10 @@ operator produces a boolean result, the result value 
will be 1 for true or 0
 for false. When an operator tests a boolean argument, it interprets 0 as false
 and non-0 as true.
 
+.. warning::
+  The ``!getop`` and ``!setop`` bang operators are deprecated in favor of
+  ``!getdagop`` and ``!setdagop``.
+
 ``!add(``\ *a*\ ``,`` *b*\ ``, ...)``
 This operator adds *a*, *b*, etc., and produces the sum.
 
@@ -1544,26 +1548,27 @@ and non-0 as true.
 The arguments must be ``bit``, ``int``, or ``string`` values.
 Use ``!cast`` to compare other types of objects.
 
-``!getop(``\ *dag*\ ``)`` --or-- ``!getop<``\ *type*\ ``>(``\ *dag*\ ``)``
+``!getdagop(``\ *dag*\ ``)`` --or-- ``!getdagop<``\ *type*\ ``>(``\ *dag*\ 
``)``
 This operator produces the operator of the given *dag* node.
-Example: ``!getop((foo 1, 2))`` results in ``foo``.
+Example: ``!getdagop((foo 1, 2))`` results in ``foo``. Recall that
+DAG operators are always records.
 
-The result of ``!getop`` can be used directly in a context where
-any record value at all is acceptable (typically placing it into
+The result of ``!getdagop`` can be used directly in a context where
+any record class at all is acceptable (typically placing it into
 another dag value). But in other contexts, it must be explicitly
-cast to a particular class type. The ``<``\ *type*\ ``>`` syntax is
+cast to a particular class. The ``<``\ *type*\ ``>`` syntax is
 provided to make this easy.
 
 For example, to 

[PATCH] D89920: Export TemplateArgumentMatcher so clients defining custom matchers don't need to use the internal namespace

2020-10-23 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf55eeea4024c: Export TemplateArgumentMatcher so clients 
defining custom matchers dont need… (authored by davidvancleve, committed 
by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89920

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -145,6 +145,7 @@
 using NestedNameSpecifierMatcher = internal::Matcher;
 using NestedNameSpecifierLocMatcher = 
internal::Matcher;
 using CXXCtorInitializerMatcher = internal::Matcher;
+using TemplateArgumentMatcher = internal::Matcher;
 using TemplateArgumentLocMatcher = internal::Matcher;
 /// @}
 


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -145,6 +145,7 @@
 using NestedNameSpecifierMatcher = internal::Matcher;
 using NestedNameSpecifierLocMatcher = internal::Matcher;
 using CXXCtorInitializerMatcher = internal::Matcher;
+using TemplateArgumentMatcher = internal::Matcher;
 using TemplateArgumentLocMatcher = internal::Matcher;
 /// @}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f55eeea - Export TemplateArgumentMatcher so clients defining custom matchers don't need to use the internal namespace

2020-10-23 Thread Sam McCall via cfe-commits

Author: David Van Cleve
Date: 2020-10-23T16:13:56+02:00
New Revision: f55eeea4024cb05bff2c9f72968f23183e992a32

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

LOG: Export TemplateArgumentMatcher so clients defining custom matchers don't 
need to use the internal namespace

This change adds another export, `using TemplateArgumentMatcher = 
internal::Matcher;`, to the collection of exports that put 
instantiations of the `clang::ast_matchers::internal::Matcher` into the 
`clang::ast_matchers` namespace. This makes it possible to define custom 
TemplateArgument matchers without reaching into the `internal` namespace.

Reviewed By: klimek

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchers.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 51d51d707de4..11886dcafa61 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -145,6 +145,7 @@ using TypeLocMatcher = internal::Matcher;
 using NestedNameSpecifierMatcher = internal::Matcher;
 using NestedNameSpecifierLocMatcher = 
internal::Matcher;
 using CXXCtorInitializerMatcher = internal::Matcher;
+using TemplateArgumentMatcher = internal::Matcher;
 using TemplateArgumentLocMatcher = internal::Matcher;
 /// @}
 



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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-10-23 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

I should note that I was only able to reproduce the false positive with the 
actual implementation std::function and not our fake version here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-10-23 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 300276.
flx added a comment.

Revert -std=c++17 change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

Files:
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, 

[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-10-23 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 300274.
flx added a comment.

Remove code comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

Files:
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s 
performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
   ExpensiveToCopyType();
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
   ExpensiveToCopyType();
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  

[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-10-23 Thread Felix Berger via Phabricator via cfe-commits
flx created this revision.
flx added reviewers: aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
flx requested review of this revision.

This fixes false positive cases where a non-const reference is passed to a
std::function but interpreted as a const reference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90042

Files:
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s 
performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
   ExpensiveToCopyType();
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -57,11 +57,15 @@
   Stmt, Context);
   SmallPtrSet DeclRefs;
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
-  auto ConstReferenceOrValue =
-  qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+  auto ConstReferenceOrValue = qualType(
+  anyOf(referenceType(pointee(qualType(isConstQualified(,
+unless(anyOf(referenceType(),
+ pointerType() /*, substTemplateTypeParmType()*/;
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
   ExpensiveToCopyType();
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes &&...Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -57,11 +57,15 @@
   Stmt, 

[PATCH] D89987: [analyzer] [NFC] Rename SymbolRef to SymExprRef

2020-10-23 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@OikawaKirie

> Different from ProgramStateRef which is an alias to IntrusiveRefCntPtr, or 
> StoreRef which is a wrapper object, an alias to a const SymExpr * makes no 
> sense to me.

Yes. I omit this, because in such case we should go further and rename all 
those which are not real `Ref` to `Ptr` or smth that would emphasise that it's 
just a pointer alias, not a wrapper or another class.
That's why I prefered to change the name a little in favor of complex approach 
of renaming all the rest.

> And this is also where I have been confused for a long while.

So have been I. The patch is called to make it more clear :)

Thanks to @steakhal comment I investigated more in terms of what other names 
use `Symbol` but mean `SymExpr`. They are:

  class SymbolManager;
  using SymbolID;
  using SymbolDependTy;
  class SymbolData;
  class SymbolMetadata;
  class SymbolReaper;
  enum SymbolStatus;
  using SymbolSetTy;
  using SymbolMapTy;
  class SymbolCast;
  class SymbolVal;
  class symbol_iterator;
  etc.

This is not a full list! I also didn't count //methods// and //file names//.
There is also a list of objects names which straightly use `SymExpr`. They are 
less spread. Mostly they a derived classes:

  class BinarySymExprImpl;
  class SymIntExpr;
  class IntSymExpr;
  class SymSymExpr;
  some enums, several methods, etc.

As a result we whould accurately define the difference between `Symbol` and 
`SymExpr`.
I see the next options:

1. `Symbol` and `SymExpr` are different. Leave the names as are. Fix minor 
mismatches if presented. And follow that definitions.
2. `Symbol` and `SymExpr` are the same. `SymExpr` is a dominant one. Change all 
the names from `Symbol` to `SymExpr` and get rid of `Symbol`.
3. `Symbol` and `SymExpr` are the same. `Symbol` is a dominant one. Change all 
the names from `SymExpr` to `Symbol` and get rid of `SymExpr`.
4. Ignore the naming due to loss of **git blame** (or any other reason) like in 
an llvm naming rules topic.
5. For now just rename `SymbolRef` alias as the beggining of the story in scope 
of 2nd option.

What do you think?




Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h:111
+using SymExprRef = const SymExpr *;
+using SymbolRefSmallVectorTy = SmallVector;
 using SymbolID = unsigned;

steakhal wrote:
> `SymbolRefSmallVectorTy` -> `SymExprRefSmallVectorTy`
Thanks for a reasonable remark!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89987

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


[clang-tools-extra] ce63383 - [clangd] Drop version from remote index proto names, fix clangd-index-server

2020-10-23 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-23T15:28:11+02:00
New Revision: ce63383e45f4c833dbff6a89b242bfd1d188786e

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

LOG: [clangd] Drop version from remote index proto names, fix 
clangd-index-server

We only need to version these messages if they actually diverge.
Unlike the service, the namespace name isn't part of the wire format.

clangd-index-server was broken by 81e5f298c431555d809f898c196945ca879c1150
as the namespace names weren't updated there, this fixes it (by adding
them for the service, and not requiring them elsewhere).

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Index.proto
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Index.proto 
b/clang-tools-extra/clangd/index/remote/Index.proto
index 654d1eb750f0..7619d0cb2ef3 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -8,7 +8,7 @@
 
 syntax = "proto2";
 
-package clang.clangd.remote.v1;
+package clang.clangd.remote;
 
 message LookupRequest { repeated string ids = 1; }
 

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 598d9434023f..296f99cdfa38 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -76,7 +76,7 @@ Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
 }
 
 llvm::Expected
-Marshaller::fromProtobuf(const v1::LookupRequest *Message) {
+Marshaller::fromProtobuf(const LookupRequest *Message) {
   clangd::LookupRequest Req;
   auto IDs = getIDs(Message->ids());
   if (!IDs)
@@ -86,7 +86,7 @@ Marshaller::fromProtobuf(const v1::LookupRequest *Message) {
 }
 
 llvm::Expected
-Marshaller::fromProtobuf(const v1::FuzzyFindRequest *Message) {
+Marshaller::fromProtobuf(const FuzzyFindRequest *Message) {
   assert(!RemoteIndexRoot.empty());
   clangd::FuzzyFindRequest Result;
   Result.Query = Message->query();
@@ -110,7 +110,7 @@ Marshaller::fromProtobuf(const v1::FuzzyFindRequest 
*Message) {
 }
 
 llvm::Expected
-Marshaller::fromProtobuf(const v1::RefsRequest *Message) {
+Marshaller::fromProtobuf(const RefsRequest *Message) {
   clangd::RefsRequest Req;
   auto IDs = getIDs(Message->ids());
   if (!IDs)
@@ -126,7 +126,7 @@ Marshaller::fromProtobuf(const v1::RefsRequest *Message) {
 }
 
 llvm::Expected
-Marshaller::fromProtobuf(const v1::RelationsRequest *Message) {
+Marshaller::fromProtobuf(const RelationsRequest *Message) {
   clangd::RelationsRequest Req;
   auto IDs = getIDs(Message->subjects());
   if (!IDs)
@@ -140,8 +140,7 @@ Marshaller::fromProtobuf(const v1::RelationsRequest 
*Message) {
   return Req;
 }
 
-llvm::Expected
-Marshaller::fromProtobuf(const v1::Symbol ) {
+llvm::Expected Marshaller::fromProtobuf(const Symbol ) 
{
   if (!Message.has_info() || !Message.has_canonical_declaration())
 return error("Missing info or declaration.");
   clangd::Symbol Result;
@@ -179,7 +178,7 @@ Marshaller::fromProtobuf(const v1::Symbol ) {
   return Result;
 }
 
-llvm::Expected Marshaller::fromProtobuf(const v1::Ref ) {
+llvm::Expected Marshaller::fromProtobuf(const Ref ) {
   if (!Message.has_location())
 return error("Missing location.");
   clangd::Ref Result;
@@ -192,7 +191,7 @@ llvm::Expected Marshaller::fromProtobuf(const 
v1::Ref ) {
 }
 
 llvm::Expected>
-Marshaller::fromProtobuf(const v1::Relation ) {
+Marshaller::fromProtobuf(const Relation ) {
   auto SubjectID = SymbolID::fromStr(Message.subject_id());
   if (!SubjectID)
 return SubjectID.takeError();
@@ -204,17 +203,16 @@ Marshaller::fromProtobuf(const v1::Relation ) {
   return std::make_pair(*SubjectID, *Object);
 }
 
-v1::LookupRequest Marshaller::toProtobuf(const clangd::LookupRequest ) {
-  v1::LookupRequest RPCRequest;
+LookupRequest Marshaller::toProtobuf(const clangd::LookupRequest ) {
+  LookupRequest RPCRequest;
   for (const auto  : From.IDs)
 RPCRequest.add_ids(SymbolID.str());
   return RPCRequest;
 }
 
-v1::FuzzyFindRequest
-Marshaller::toProtobuf(const clangd::FuzzyFindRequest ) {
+FuzzyFindRequest Marshaller::toProtobuf(const clangd::FuzzyFindRequest ) {
   assert(!LocalIndexRoot.empty());
-  v1::FuzzyFindRequest RPCRequest;
+  FuzzyFindRequest RPCRequest;
   RPCRequest.set_query(From.Query);
   for (const auto  : From.Scopes)
 RPCRequest.add_scopes(Scope);
@@ -233,8 +231,8 @@ Marshaller::toProtobuf(const 

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-10-23 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

Hi @aaron.ballman,

Thank you for the suggestion.




Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:237
+static void getHungarianNotationDefaultConfig(
+std::shared_ptr HNOption) {
+

aaron.ballman wrote:
> It seems like this function should take `HNOption` as a reference rather than 
> a `shared_ptr`.
OK!



Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h:87
+HungarianPrefixOption HungarianPrefixOpt;
+std::shared_ptr
+HungarianNotationOption;

aaron.ballman wrote:
> I'd like to avoid using a `shared_ptr` here if we can avoid it -- do we 
> expect this to be super expensive to copy by value (I would imagine it'll be 
> an expensive copy but we don't make copies all that often, but maybe my 
> intuition is wrong)?
Good idea. A reference object is good enough. I will change it at next commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D89832: [CUDA] Extract CUDA version from cuda.h if version.txt is not found

2020-10-23 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov added a comment.

I confirm that D89752  eliminates 47332 
 on Windows. Tested against the 
following CUDA versions: 7.0, 7,5, 9,2, 10.0, 10,1, 10.2, 11.0 Update 1, 11.1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89832

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


[PATCH] D89994: [libomptarget][nvptx] Undef, internal shared variables

2020-10-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:2858
 TransferMedium = new llvm::GlobalVariable(
-M, Ty, /*isConstant=*/false, llvm::GlobalVariable::CommonLinkage,
-llvm::Constant::getNullValue(Ty), TransferMediumName,
+M, Ty, /*isConstant=*/false, llvm::GlobalVariable::InternalLinkage,
+llvm::UndefValue::get(Ty), TransferMediumName,

"Internalization" is not the best option, it increases mem pressure. Common 
linkage is a better choice, allows to "squash" the same objects, defined in 
different units. Make it arch dependable, maybe?
For NVPTX zero initialization is not a problem, it is resolved when PTX is 
generated.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:4794
   CGM.getModule(), LLVMStaticTy,
-  /*isConstant=*/false, llvm::GlobalValue::CommonLinkage,
-  llvm::Constant::getNullValue(LLVMStaticTy),
+  /*isConstant=*/false, llvm::GlobalValue::InternalLinkage,
+  llvm::UndefValue::get(LLVMStaticTy),

JonChesterfield wrote:
> Perhaps weak_any + undef?
> 
> Could use internal for symbols that may vary in size and weak_any for those 
> that don't.
Yeah, it is a good idea, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89994

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


[clang-tools-extra] e6c1c3f - [clang] Split remote index service definition into a separate file.

2020-10-23 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-23T15:20:51+02:00
New Revision: e6c1c3f97f13b7d973fa786a3f2da883fa31bdf6

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

LOG: [clang] Split remote index service definition into a separate file.

This allows it to have a separate namespace (grpc versioned service) without
putting versioning info on all of the other protos (before we need it).

clang-index-server is still broken (from 81e5f298c431555).

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

Added: 
clang-tools-extra/clangd/index/remote/Service.proto

Modified: 
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/Index.proto
clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
clang-tools-extra/clangd/index/remote/server/Server.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 8bd5db543921..94f5699b42d6 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -1,5 +1,6 @@
 if (CLANGD_ENABLE_REMOTE)
-  generate_protos(RemoteIndexProtos "Index.proto" GRPC)
+  generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
+  generate_protos(RemoteIndexProto "Index.proto")
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -12,7 +13,8 @@ if (CLANGD_ENABLE_REMOTE)
 Client.cpp
 
 LINK_LIBS
-RemoteIndexProtos
+RemoteIndexProto
+RemoteIndexServiceProto
 clangdRemoteMarshalling
 
 protobuf
@@ -21,7 +23,8 @@ if (CLANGD_ENABLE_REMOTE)
 clangdSupport
 
 DEPENDS
-RemoteIndexProtos
+RemoteIndexProto
+RemoteIndexServiceProto
 )
 
   add_subdirectory(marshalling)

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index d01dd4483974..a134d9c72932 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -9,7 +9,7 @@
 #include 
 
 #include "Client.h"
-#include "Index.grpc.pb.h"
+#include "Service.grpc.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "marshalling/Marshalling.h"

diff  --git a/clang-tools-extra/clangd/index/remote/Index.proto 
b/clang-tools-extra/clangd/index/remote/Index.proto
index a9ebc75ebc88..654d1eb750f0 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -10,19 +10,6 @@ syntax = "proto2";
 
 package clang.clangd.remote.v1;
 
-// Semantics of SymbolIndex match clangd::SymbolIndex with all required
-// structures corresponding to their clangd::* counterparts.
-// NOTE: Enum values are offset by one to detect missing values.
-service SymbolIndex {
-  rpc Lookup(LookupRequest) returns (stream LookupReply) {}
-
-  rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
-
-  rpc Refs(RefsRequest) returns (stream RefsReply) {}
-
-  rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
-}
-
 message LookupRequest { repeated string ids = 1; }
 
 // The response is a stream of symbol messages and the terminating message

diff  --git a/clang-tools-extra/clangd/index/remote/Service.proto 
b/clang-tools-extra/clangd/index/remote/Service.proto
new file mode 100644
index ..4e39ff9ec666
--- /dev/null
+++ b/clang-tools-extra/clangd/index/remote/Service.proto
@@ -0,0 +1,26 @@
+//===--- Service.proto - Remote index service definition 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+syntax = "proto2";
+
+package clang.clangd.remote.v1;
+
+import "Index.proto";
+
+// Semantics of SymbolIndex match clangd::SymbolIndex with all required
+// structures corresponding to their clangd::* counterparts.
+service SymbolIndex {
+  rpc Lookup(LookupRequest) returns (stream LookupReply) {}
+
+  rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
+
+  rpc Refs(RefsRequest) returns (stream RefsReply) {}
+
+  rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
+}
+

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
index 75e57edd45d9..7b78ba3bb690 100644
--- 

  1   2   >