[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-14 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the update.


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

https://reviews.llvm.org/D100976

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


[PATCH] D102244: [llvm][AsmPrinter] Restore source location to register clobber warning

2021-05-14 Thread David Spickett 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 rG2db090a2ebd7: [llvm][AsmPrinter] Restore source location to 
register clobber warning (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102244

Files:
  clang/test/Misc/inline-asm-clobber-warning.c
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp


Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
@@ -527,11 +528,6 @@
   }
 
   if (!RestrRegs.empty()) {
-unsigned BufNum = addInlineAsmDiagBuffer(OS.str(), LocMD);
-auto &SrcMgr = *MMI->getContext().getInlineSourceManager();
-SMLoc Loc = SMLoc::getFromPointer(
-SrcMgr.getMemoryBuffer(BufNum)->getBuffer().begin());
-
 std::string Msg = "inline asm clobber list contains reserved registers: ";
 ListSeparator LS;
 for (const Register &RR : RestrRegs) {
@@ -542,8 +538,10 @@
 "Reserved registers on the clobber list may not be "
 "preserved across the asm statement, and clobbering them may "
 "lead to undefined behaviour.";
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg);
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, Note);
+MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
+LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+MMI->getModule()->getContext().diagnose(
+DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
   }
 
   emitInlineAsm(OS.str(), getSubtargetInfo(), TM.Options.MCOptions, LocMD,
Index: clang/test/Misc/inline-asm-clobber-warning.c
===
--- /dev/null
+++ clang/test/Misc/inline-asm-clobber-warning.c
@@ -0,0 +1,21 @@
+/// This test checks that the warning includes the location in the C source
+/// file that contains the inline asm. Instead of saying  for both.
+/// Although this warning is emitted in llvm it cannot be tested from IR as
+/// it does not have that location information at that stage.
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -c %s -o /dev/null \
+// RUN:   2>&1 | FileCheck %s
+
+// REQUIRES: arm-registered-target
+
+void bar(void) {
+  __asm__ __volatile__("nop"
+   :
+   :
+   : "sp");
+}
+
+// CHECK:  inline-asm-clobber-warning.c:12:24: warning: inline asm clobber 
list contains reserved registers: SP [-Winline-asm]
+// CHECK-NEXT: __asm__ __volatile__("nop"
+// CHECK-NEXT:  ^
+// CHECK-NEXT: inline-asm-clobber-warning.c:12:24: note: Reserved registers on 
the clobber list may not be preserved across the asm statement, and clobbering 
them may lead to undefined behaviour.


Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
@@ -527,11 +528,6 @@
   }
 
   if (!RestrRegs.empty()) {
-unsigned BufNum = addInlineAsmDiagBuffer(OS.str(), LocMD);
-auto &SrcMgr = *MMI->getContext().getInlineSourceManager();
-SMLoc Loc = SMLoc::getFromPointer(
-SrcMgr.getMemoryBuffer(BufNum)->getBuffer().begin());
-
 std::string Msg = "inline asm clobber list contains reserved registers: ";
 ListSeparator LS;
 for (const Register &RR : RestrRegs) {
@@ -542,8 +538,10 @@
 "Reserved registers on the clobber list may not be "
 "preserved across the asm statement, and clobbering them may "
 "lead to undefined behaviour.";
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg);
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, Note);
+MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
+LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+MMI->getModule()->getContext().diagnose(
+DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
   }
 
   emitInlineAsm(OS.str(), getSubtargetInfo(), TM.Options.MCOptions, LocMD,
Index: clang/test/Misc/inline-asm-clobber-warning.c
===

[clang] 2db090a - [llvm][AsmPrinter] Restore source location to register clobber warning

2021-05-14 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-05-14T08:22:57Z
New Revision: 2db090a2ebd76f120bfae4fbe4b7241667aa585e

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

LOG: [llvm][AsmPrinter] Restore source location to register clobber warning

Since 5de2d189e6ad466a1f0616195e8c524a4eb3cbc0 this particular warning
hasn't had the location of the source file containing the inline
assembly.

Fix this by reporting via LLVMContext. Which means that we no longer
have the "instantiated into assembly here" lines but they were going to
point to the start of the inline asm string anyway.

This message is already tested via IR in llvm. However we won't have
the required location info there so I've added a C file test in clang
to cover it.
(though strictly, this is testing llvm code)

Reviewed By: ychen

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

Added: 
clang/test/Misc/inline-asm-clobber-warning.c

Modified: 
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Removed: 




diff  --git a/clang/test/Misc/inline-asm-clobber-warning.c 
b/clang/test/Misc/inline-asm-clobber-warning.c
new file mode 100644
index 0..69bd4809848b1
--- /dev/null
+++ b/clang/test/Misc/inline-asm-clobber-warning.c
@@ -0,0 +1,21 @@
+/// This test checks that the warning includes the location in the C source
+/// file that contains the inline asm. Instead of saying  for both.
+/// Although this warning is emitted in llvm it cannot be tested from IR as
+/// it does not have that location information at that stage.
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -c %s -o /dev/null \
+// RUN:   2>&1 | FileCheck %s
+
+// REQUIRES: arm-registered-target
+
+void bar(void) {
+  __asm__ __volatile__("nop"
+   :
+   :
+   : "sp");
+}
+
+// CHECK:  inline-asm-clobber-warning.c:12:24: warning: inline asm clobber 
list contains reserved registers: SP [-Winline-asm]
+// CHECK-NEXT: __asm__ __volatile__("nop"
+// CHECK-NEXT:  ^
+// CHECK-NEXT: inline-asm-clobber-warning.c:12:24: note: Reserved registers on 
the clobber list may not be preserved across the asm statement, and clobbering 
them may lead to undefined behaviour.

diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 9f7c71c676a6e..c494510044bde 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
@@ -527,11 +528,6 @@ void AsmPrinter::emitInlineAsm(const MachineInstr *MI) 
const {
   }
 
   if (!RestrRegs.empty()) {
-unsigned BufNum = addInlineAsmDiagBuffer(OS.str(), LocMD);
-auto &SrcMgr = *MMI->getContext().getInlineSourceManager();
-SMLoc Loc = SMLoc::getFromPointer(
-SrcMgr.getMemoryBuffer(BufNum)->getBuffer().begin());
-
 std::string Msg = "inline asm clobber list contains reserved registers: ";
 ListSeparator LS;
 for (const Register &RR : RestrRegs) {
@@ -542,8 +538,10 @@ void AsmPrinter::emitInlineAsm(const MachineInstr *MI) 
const {
 "Reserved registers on the clobber list may not be "
 "preserved across the asm statement, and clobbering them may "
 "lead to undefined behaviour.";
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg);
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, Note);
+MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
+LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+MMI->getModule()->getContext().diagnose(
+DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
   }
 
   emitInlineAsm(OS.str(), getSubtargetInfo(), TM.Options.MCOptions, LocMD,



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


[PATCH] D102473: [clang][deps] Stop assuming the TU's context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The context hash of modular dependencies can be different from the context hash 
of the original translation unit if we modify its CompilerInvocation.

Stop assuming the TU's context hash everywhere.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102473

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Support/Threading.h"
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace tooling::dependencies;
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -144,8 +144,6 @@
 return;
 
   const Module *TopLevelModule = Imported->getTopLevelModule();
-  MDC.ModularDeps[MDC.ContextHash + TopLevelModule->getFullModuleName()]
-  .ImportedByMainFile = true;
   DirectModularDeps.insert(TopLevelModule);
 }
 
@@ -157,35 +155,45 @@
   for (const Module *M : DirectModularDeps)
 handleTopLevelModule(M);
 
-  for (auto &&I : MDC.ModularDeps)
-MDC.Consumer.handleModuleDependency(I.second);
+  for (auto &MD : MDC.ModularDeps)
+MDC.Consumer.handleModuleDependency(MD);
 
   for (auto &&I : MDC.FileDeps)
 MDC.Consumer.handleFileDependency(*MDC.Opts, I);
 }
 
-void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
+ModuleID ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
   assert(M == M->getTopLevelModule() && "Expected top level module!");
 
-  auto ModI = MDC.ModularDeps.insert(
-  std::make_pair(MDC.ContextHash + M->getFullModuleName(), ModuleDeps{}));
+  // If this module hasn't been transformed into an instance of ModuleDeps yet,
+  // this is the index the new instance will occupy in the ModularDeps vector.
+  size_t MDIdx = MDC.ModularDeps.size();
 
-  if (!ModI.first->second.ID.ModuleName.empty())
-return;
+  // If this module has been handled already, just return its ID.
+  auto ModI = MDC.HandledTopLevelModules.insert({M, MDIdx});
+  if (!ModI.second)
+return MDC.ModularDeps[ModI.first->second].ID;
+
+  MDC.ModularDeps.push_back(ModuleDeps{});
+  ModuleDeps &MD = MDC.ModularDeps.back();
+
+  // FIXME: Prepare the CompilerInvocation for building this module **now**, so
+  //that we store the actual context hash for this module (not just the
+  //context hash inherited from the original TU).
+  MD.Invocation = Instance.getInvocationPtr();
+  ModuleID ID{M->getFullModuleName(), MD.Invocation->getModuleHash()};
+  MD.ID = ID;
 
-  ModuleDeps &MD = ModI.first->second;
+  MD.ImportedByMainFile = DirectModularDeps.contains(M);
+  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
+  MD.IsSystem = M->IsSystem;
 
   const FileEntry *ModuleMap = Instance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getContainingModuleMapFile(M);
-
-  MD.Invocation = Instance.getInvocationPtr();
   MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
-  MD.ID.ModuleName = M->getFullModuleName();
-  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
-  MD.ID.ContextHash = MDC.ContextHash;
-  MD.IsSystem = M->IsSystem;
+
   serialization::ModuleFile *MF =
   MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
   MDC.Instance.getASTReader()->visitInputFiles(
@@ -194,28 +202,28 @@
   });
 
   llvm::DenseSet AddedModules;
-  addAllSubmoduleDeps(M, MD, AddedModules);
+  addAllSubmoduleDeps(M, MDIdx, AddedModules);
+
+  return ID;
 }
 
 void ModuleDepCollectorPP::addAllSubmoduleDeps(
-const Module *M, ModuleDeps &MD,
+const Module *M, size_t MDIdx,
 llvm::DenseSet &AddedModules) {
-  addModuleDep(M, MD, AddedModules);
+  addModuleDep(M, MDIdx, AddedModules);
 
   for (const Module *SubM : M->submodules())
-addAllSubmoduleDeps(SubM, MD, AddedModules);
+addAllSubmoduleDeps(SubM, MDIdx, AddedModules);
 }
 
 void ModuleDepCollectorPP::addModuleDep(
-const Module *M, ModuleDeps &MD,
+const Module *M, size_t MDIdx,
 llvm::DenseSet &AddedModules) {
   for (const Module *Import : M->Imports) {
 if (Import->getTopLevelModule() != M->getTopLeve

[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 345381.
AbbasSabra added a comment.

Updating D102280 : [analyzer] Apply code 
review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

Files:
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/test/Analysis/misc-ms-leave.cpp


Index: clang/test/Analysis/misc-ms-leave.cpp
===
--- /dev/null
+++ clang/test/Analysis/misc-ms-leave.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple 
x86_64-pc-windows-msvc19.11.0 -fms-extensions -verify %s
+
+void clang_analyzer_warnIfReached();
+int filter();
+
+void try_except_leave() {
+  __try {
+__leave; // no-crash
+  } __except (filter()) {
+  }
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+}
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -349,6 +349,7 @@
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:
   case Stmt::BreakStmtClass:
   case Stmt::GotoStmtClass:


Index: clang/test/Analysis/misc-ms-leave.cpp
===
--- /dev/null
+++ clang/test/Analysis/misc-ms-leave.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions -verify %s
+
+void clang_analyzer_warnIfReached();
+int filter();
+
+void try_except_leave() {
+  __try {
+__leave; // no-crash
+  } __except (filter()) {
+  }
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+}
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -349,6 +349,7 @@
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:
   case Stmt::BreakStmtClass:
   case Stmt::GotoStmtClass:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra marked 2 inline comments as done.
AbbasSabra added a comment.

> Please, add these reviewers for your upcoming [analyzer] patches.

Thanks, I was planning to add reviewers after making sure that the pre-checks 
are green.

> Nice to see some fixes for visual c++ stuff.

Thanks for the quick review!




Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:352
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:

steakhal wrote:
> You should probably extend the `ExprEngine.cpp:1312` in a similar fashion.
isn't it already handled in  !!ExprEngine.cpp:1239!!?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

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


[PATCH] D102473: [clang][deps] Stop assuming the TU's context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 345383.
jansvoboda11 added a comment.

Use `std::unordered_map` again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102473

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -144,8 +144,6 @@
 return;
 
   const Module *TopLevelModule = Imported->getTopLevelModule();
-  MDC.ModularDeps[MDC.ContextHash + TopLevelModule->getFullModuleName()]
-  .ImportedByMainFile = true;
   DirectModularDeps.insert(TopLevelModule);
 }
 
@@ -164,28 +162,32 @@
 MDC.Consumer.handleFileDependency(*MDC.Opts, I);
 }
 
-void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
+ModuleID ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
   assert(M == M->getTopLevelModule() && "Expected top level module!");
 
-  auto ModI = MDC.ModularDeps.insert(
-  std::make_pair(MDC.ContextHash + M->getFullModuleName(), ModuleDeps{}));
-
-  if (!ModI.first->second.ID.ModuleName.empty())
-return;
+  // If this module has been handled already, just return its ID.
+  auto ModI = MDC.ModularDeps.insert({M, ModuleDeps{}});
+  if (!ModI.second)
+return ModI.first->second.ID;
 
   ModuleDeps &MD = ModI.first->second;
 
+  // FIXME: Prepare the CompilerInvocation for building this module **now**, so
+  //that we store the actual context hash for this module (not just the
+  //context hash inherited from the original TU).
+  MD.Invocation = Instance.getInvocationPtr();
+  MD.ID = ModuleID{M->getFullModuleName(), MD.Invocation->getModuleHash()};
+
+  MD.ImportedByMainFile = DirectModularDeps.contains(M);
+  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
+  MD.IsSystem = M->IsSystem;
+
   const FileEntry *ModuleMap = Instance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getContainingModuleMapFile(M);
-
-  MD.Invocation = Instance.getInvocationPtr();
   MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
-  MD.ID.ModuleName = M->getFullModuleName();
-  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
-  MD.ID.ContextHash = MDC.ContextHash;
-  MD.IsSystem = M->IsSystem;
+
   serialization::ModuleFile *MF =
   MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
   MDC.Instance.getASTReader()->visitInputFiles(
@@ -195,6 +197,8 @@
 
   llvm::DenseSet AddedModules;
   addAllSubmoduleDeps(M, MD, AddedModules);
+
+  return MD.ID;
 }
 
 void ModuleDepCollectorPP::addAllSubmoduleDeps(
@@ -211,11 +215,9 @@
 llvm::DenseSet &AddedModules) {
   for (const Module *Import : M->Imports) {
 if (Import->getTopLevelModule() != M->getTopLevelModule()) {
+  ModuleID ImportID = handleTopLevelModule(Import->getTopLevelModule());
   if (AddedModules.insert(Import->getTopLevelModule()).second)
-MD.ClangModuleDeps.push_back(
-{std::string(Import->getTopLevelModuleName()),
- Instance.getInvocation().getModuleHash()});
-  handleTopLevelModule(Import->getTopLevelModule());
+MD.ClangModuleDeps.push_back(ImportID);
 }
   }
 }
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -143,7 +143,7 @@
   for (auto &&M : ClangModuleDeps) {
 auto &MD = M.second;
 if (MD.ImportedByMainFile)
-  FD.ClangModuleDeps.push_back({MD.ID.ModuleName, ContextHash});
+  FD.ClangModuleDeps.push_back(MD.ID);
   }
 
   FullDependenciesResult FDR;
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -147,7 +147,7 @@
   /// Traverses the previously collected direct modular dependencies to discover
   /// transitive modular dependencies and fills the parent \c ModuleDepCollector
   /// with both.
-  void handleTopLevelModule(const Module *M);
+  ModuleID handleTopLevelModule(const Module *M);
   void addAllSubmoduleDeps(const Module *M, ModuleDeps &MD,
llvm::DenseSet &AddedModules);
   void addModuleDep(const Module *M, M

[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Do you have any good (mature, big enough) open-source projects for these msvc 
constructs?




Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:352
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:

AbbasSabra wrote:
> steakhal wrote:
> > You should probably extend the `ExprEngine.cpp:1312` in a similar fashion.
> isn't it already handled in  !!ExprEngine.cpp:1239!!?
Good point.
At the other switch it states, that this leave statement is unsupported. I 
guess it will stay unsupported for a while because we don't model exceptions at 
all. Treat my previous comment as resolved.



Comment at: clang/test/Analysis/misc-ms-leave.cpp:9
+__leave; // no-crash
+  } __except (filter()) {
+  }

I'm curious to see if any statement after the `__leave` is executed. Could you 
place another warnIfReached there too?

Also, this file could contain all the ms try except constructs. That we might 
plan to support in the future.
So, a more generic file name would be more future-proof I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

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


[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-14 Thread Zhiwei Chen via Phabricator via cfe-commits
condy updated this revision to Diff 345386.
condy added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix clang/codegen tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_constant_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/debug-info-global-var.ll
  llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -8,13 +8,13 @@
 ; CHECK: $"??_C@_04JIHMPGLA@asdf?$AA@" = comdat any
 
 ; CHECK: @"??_C@_04JIHMPGLA@asdf?$AA@" =
-; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [59 x i8] }
-; CHECK-SAME: { [5 x i8] c"asdf\00", [59 x i8] zeroinitializer }, comdat, align 32
+; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
+; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
 ; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
-; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [59 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 64, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
+; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
 ; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
 ; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
 ; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
Index: llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -11,15 +11,15 @@
 @c = internal global [2 x i32] zeroinitializer, align 4
 @d = unnamed_addr global [2 x i32] zeroinitializer, align 4
 
-; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @a to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
-; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @b to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @c to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.3 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @a to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @b to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
+; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i

[PATCH] D102392: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to the ColumnLimit

2021-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D102392#2756779 , @curdeius wrote:

> LGTM. Not blocking, but I'd add foo4 example from the description as a test 
> case (with a link to the bug maybe).

Of course I should have added that too! let me do that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102392

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-14 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 345333.
shchenz added a comment.

1: add the FIXME for the duplicated tags issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,67 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; CHECK-NEXT: DW_AT_type {{.*}} "int"
+; CHECK: DW_TAG_base_type
+; CHECK-NOT: DW_TAG
+; CHECK: DW_AT_name {{.*}}"int"
+; CHECK: DW_TAG_reference_type
+; CHECK-NEXT: DW_AT_type {{.*}} "int"
+;
+; FIXME: remove the redundant tag DW_TAG_reference_type. We only need one tag
+; DW_TAG_reference_type with base type int.
+;
+; STRICT-NOT: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+; STRICT-NEXT: DW_AT_type {{.*}} "int"
+; STRICT: DW_TAG_base_type
+; STRICT-NOT: DW_TAG
+; STRICT: DW_AT_name {{.}}"int"
+; STRICT: DW_TAG_reference_type
+; STRICT-NEXT: DW_AT_type {{.*}} "int"
+
+define void @_Z2f1OiRi(i32* dereferenceable(4) %0, i32* dereferenceable(4) %1) 
#0 !dbg !9 {
+  %3 = alloca i32*, align 8
+  %4 = alloca i32*, align 8
+  store i32* %0, i32** %3, align 8
+  call void @llvm.dbg.declare(metadata i32** %3, metadata !15, metadata 
!DIExpression()), !dbg !16
+  store i32* %1, i32** %4, align 8
+  call void @llvm.dbg.declare(metadata i32** %4, metadata !17, metadata 
!DIExpression()), !dbg !18
+  ret void, !dbg !19
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 2}
+!8 = !{!"clang version 13.0.0"}
+!9 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1OiRi", scope: !1, 
file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: 
DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{null, !12, !14}
+!12 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !13, size: 
64)
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !13, size: 64)
+!15 = !DILocalVariable(name: "x", arg: 1, scope: !9, file: !1, line: 1, type: 
!12)
+!16 = !DILocation(line: 1, column: 15, scope: !9)
+!17 = !DILocalVariable(name: "y", arg: 2, scope: !9, file: !1, line: 1, type: 
!14)
+!18 = !DILocation(line: 1, column: 23, scope: !9)
+!19 = !DILocation(line: 2, column: 1, scope: !9)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,6 +386,22 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N) {
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(Tag)) {
+// See if there is any replacement for some tags.
+// TODO: the naively replacement may introduce duplicated tags. For 
example,
+// before the replacement, we have DW_TAG_rvalue_reference_type with type
+// int and DW_TAG_reference_type with type int, after the replacement, now
+// we have two DW_TAG_reference_type with type int. We should fix this.
+if (Tag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  Tag = dwarf::DW_TAG_reference_type;
+else
+  // Assertion for other cases.
+  assert(false && "Tag is generated not following strict DWARF!");
+  }
   DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, Tag));
   if (N)
 insertDIE(N, &Die);


Index: llvm/tes

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-14 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Thanks for your comments! @dblaikie @aprantl . I think we have an agreement 
that we should handle the strict dwarf tag in the backend.

And for duplicated tags issue, since it may need a while to fix, I have added a 
TODO in the code change and also update to test case to show the duplicated 
tags issue and also a FIXME in the case.

Do you think it is good to treat it as a FIXME for now? I currently have no 
time to fix this, but I will keep this in mind and will fix this later when I 
get a better understanding of the DWARF codes. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D102478: [Matrix] Emit assumption that matrix indices are valid.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, anemet, rsmith, erichkeane.
Herald added subscribers: dexonsmith, tschuett.
fhahn requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

The matrix extension requires the indices for matrix subscript
expression to be valid and it is UB otherwise.

extract/insertelement produce poison if the index is invalid, which
limits the optimizer to not be bale to scalarize load/extract pairs for
example, which causes very suboptimal code to be generated when using
matrix subscript expressions with variable indices for large matrixes.

This patch updates IRGen to emit assumes to for index expression to
convey the information that the index must be valid.

This also adjusts the order in which operations are emitted slightly, so
indices & assumes are added before the load of the matrix value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102478

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/CodeGenObjC/matrix-type-operators.m
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -231,9 +231,25 @@
: (IsUnsigned ? B.CreateUDiv(LHS, RHS) : B.CreateSDiv(LHS, RHS));
   }
 
-  /// Extracts the element at (\p RowIdx, \p ColumnIdx) from \p Matrix.
-  Value *CreateExtractElement(Value *Matrix, Value *RowIdx, Value *ColumnIdx,
-  unsigned NumRows, Twine const &Name = "") {
+  /// Create an assumption that \p Idx is less than \p NumElements.
+  void CreateIndexAssumption(Value *Idx, unsigned NumElements,
+ Twine const &Name = "") {
+
+Value *NumElts =
+B.getIntN(Idx->getType()->getScalarSizeInBits(), NumElements);
+
+auto *Cmp = B.CreateICmpULT(Idx, NumElts);
+if (!isa(Cmp)) {
+  Function *TheFn =
+  Intrinsic::getDeclaration(getModule(), Intrinsic::assume);
+  B.CreateCall(TheFn->getFunctionType(), TheFn, {Cmp}, Name);
+}
+  }
+
+  /// Compute the index to access the element at (\p RowIdx, \p ColumnIdx) from
+  /// a matrix with \p NumRows embedded in a vector.
+  Value *CreateIndex(Value *RowIdx, Value *ColumnIdx, unsigned NumRows,
+ Twine const &Name = "") {
 
 unsigned MaxWidth = std::max(RowIdx->getType()->getScalarSizeInBits(),
  ColumnIdx->getType()->getScalarSizeInBits());
@@ -241,9 +257,7 @@
 RowIdx = B.CreateZExt(RowIdx, IntTy);
 ColumnIdx = B.CreateZExt(ColumnIdx, IntTy);
 Value *NumRowsV = B.getIntN(MaxWidth, NumRows);
-return B.CreateExtractElement(
-Matrix, B.CreateAdd(B.CreateMul(ColumnIdx, NumRowsV), RowIdx),
-"matext");
+return B.CreateAdd(B.CreateMul(ColumnIdx, NumRowsV), RowIdx);
   }
 };
 
Index: clang/test/CodeGenObjC/matrix-type-operators.m
===
--- clang/test/CodeGenObjC/matrix-type-operators.m
+++ clang/test/CodeGenObjC/matrix-type-operators.m
@@ -22,9 +22,11 @@
 // CHECK-NEXT:[[IV2_PTR:%.*]] = bitcast %0* [[IV2]] to i8*
 // CHECK-NEXT:[[CALL1:%.*]] = call i32 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 (i8*, i8*)*)(i8* [[IV2_PTR]], i8* [[SEL2]])
 // CHECK-NEXT:[[CONV2:%.*]] = sext i32 [[CALL1]] to i64
-// CHECK-NEXT:[[MAT:%.*]] = load <16 x double>, <16 x double>* {{.*}} align 8
 // CHECK-NEXT:[[IDX1:%.*]] = mul i64 [[CONV2]], 4
 // CHECK-NEXT:[[IDX2:%.*]] = add i64 [[IDX1]], [[CONV]]
+// CHECK-NEXT:   [[CMP:%.*]] = icmp ult i64 [[IDX2]], 16
+// CHECK-NEXT:call void @llvm.assume(i1 [[CMP]])
+// CHECK-NEXT:[[MAT:%.*]] = load <16 x double>, <16 x double>* {{.*}} align 8
 // CHECK-NEXT:[[MATEXT:%.*]] = extractelement <16 x double> [[MAT]], i64 [[IDX2]]
 // CHECK-NEXT:ret double [[MATEXT]]
 //
@@ -49,12 +51,14 @@
 // CHECK-NEXT:[[IV2_PTR:%.*]] = bitcast %0* [[IV2]] to i8*
 // CHECK-NEXT:[[CALL1:%.*]] = call i32 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 (i8*, i8*)*)(i8* [[IV2_PTR]], i8* [[SEL2]])
 // CHECK-NEXT:[[CONV2:%.*]] = sext i32 [[CALL1]] to i64
+// CHECK-NEXT:[[IDX1:%.*]] = mul i64 [[CONV2]], 4
+// CHECK-NEXT:[[IDX2:%.*]] = add i64 [[IDX1]], [[CONV]]
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult i64 [[IDX2]], 16
+// CHECK-NEXT:call void @llvm.assume(i1 [[CMP]])
 // CHECK-NEXT:[[M:%.*]] = load %1*, %1** %m.addr, align 8
 // CHECK-NEXT:[[SEL3:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load !7
 // CHECK-NEXT:[[M_PTR:%.*]] = bitcast %1* [[M]] to i8*
 // CHECK-NEXT:[[MAT:%.*]] = call <16 x double> bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to <16 x double> (i8*, i8*)*)(i8* [[

[PATCH] D102479: [clang][driver] Treat unkonwn -flto= values as -flto

2021-05-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added a reviewer: tejohnson.
Herald added subscribers: dang, inglorion.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The current behavior was introduced in 
https://github.com/llvm/llvm-project/commit/1628486548420f85b3467026d54663d1516404f5
 and simply ignores the options, which will of course not turn on any form of 
LTO. When they are passed, I think it's sensible to at least turn on full LTO.

This makes clang basically accept all `-flto=val` values and treat them like 
`-flto=full`. I didn't implement anything that checks for only `=auto` or 
`=jobserver`, I'm not sure if that would be the right thing to do.

Thoughts?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102479

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -258,7 +258,6 @@
 // RUN: -fstrength-reduce -fno-strength-reduce\
 // RUN: -finline-limit=1000   \
 // RUN: -finline-limit\
-// RUN: -flto=1   \
 // RUN: -falign-labels\
 // RUN: -falign-labels=100\
 // RUN: -falign-loops \
@@ -292,7 +291,6 @@
 // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks  \
 // RUN: -fno-inline-small-functions -finline-small-functions  \
 // RUN: -fno-fat-lto-objects -ffat-lto-objects\
-// RUN: -flto=auto -flto=jobserver\
 // RUN: -fno-merge-constants -fmerge-constants\
 // RUN: -fno-caller-saves -fcaller-saves  \
 // RUN: -fno-reorder-blocks -freorder-blocks  \
@@ -332,6 +330,8 @@
 // RUN: -funroll-all-loops\
 // RUN: -funswitch-loops  \
 // RUN: -flto=1   \
+// RUN: -flto=auto\
+// RUN: -flto=jobserver   \
 // RUN: -falign-labels\
 // RUN: -falign-labels=100\
 // RUN: -falign-loops \
@@ -392,7 +392,9 @@
 // CHECK-WARNING-DAG: optimization flag '-ftracer' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funroll-all-loops' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funswitch-loops' is not supported
-// CHECK-WARNING-DAG: unsupported argument '1' to option 'flto='
+// CHECK-WARNING_DAG: Unknown option -flto=1, treating as -flto=full
+// CHECK-WARNING_DAG: Unknown option -flto=auto, treating as -flto=full
+// CHECK-WARNING_DAG: Unknown option -flto=jobserver, treating as -flto=full
 // CHECK-WARNING-DAG: optimization flag '-falign-labels' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-labels=100' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1707,8 +1707,7 @@
 StringRef S = A->getValue();
 if (S == "thin")
   Opts.PrepareForThinLTO = true;
-else if (S != "full")
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+// -flto=full and invalid values are handled elsewhere.
   }
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != Language::LLVM_IR)
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -613,9 +613,12 @@
 .Default(LTOK_Unknown);
 
   if (LTOMode == LTOK_Unknown) {
+// Treat all other options as "full", but warn that the option
+// value is unknown.
 assert(A);
-Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName()
-<< A->getValue();
+Diag(diag::warn_drv_treating_option_as)
+<< A

[PATCH] D102473: [clang][deps] Stop assuming the TU's context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 345399.
jansvoboda11 added a comment.

Shuffle lines around to minimize diff in the next patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102473

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -144,8 +144,6 @@
 return;
 
   const Module *TopLevelModule = Imported->getTopLevelModule();
-  MDC.ModularDeps[MDC.ContextHash + TopLevelModule->getFullModuleName()]
-  .ImportedByMainFile = true;
   DirectModularDeps.insert(TopLevelModule);
 }
 
@@ -164,28 +162,27 @@
 MDC.Consumer.handleFileDependency(*MDC.Opts, I);
 }
 
-void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
+ModuleID ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
   assert(M == M->getTopLevelModule() && "Expected top level module!");
 
-  auto ModI = MDC.ModularDeps.insert(
-  std::make_pair(MDC.ContextHash + M->getFullModuleName(), ModuleDeps{}));
-
-  if (!ModI.first->second.ID.ModuleName.empty())
-return;
+  // If this module has been handled already, just return its ID.
+  auto ModI = MDC.ModularDeps.insert({M, ModuleDeps{}});
+  if (!ModI.second)
+return ModI.first->second.ID;
 
   ModuleDeps &MD = ModI.first->second;
 
+  MD.ID.ModuleName = M->getFullModuleName();
+  MD.ImportedByMainFile = DirectModularDeps.contains(M);
+  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
+  MD.IsSystem = M->IsSystem;
+
   const FileEntry *ModuleMap = Instance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getContainingModuleMapFile(M);
-
-  MD.Invocation = Instance.getInvocationPtr();
   MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
-  MD.ID.ModuleName = M->getFullModuleName();
-  MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
-  MD.ID.ContextHash = MDC.ContextHash;
-  MD.IsSystem = M->IsSystem;
+
   serialization::ModuleFile *MF =
   MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
   MDC.Instance.getASTReader()->visitInputFiles(
@@ -193,8 +190,16 @@
 MD.FileDeps.insert(IF.getFile()->getName());
   });
 
+  // FIXME: Prepare the CompilerInvocation for building this module **now**, so
+  //that we store the actual context hash for this module (not just the
+  //context hash inherited from the original TU).
+  MD.Invocation = Instance.getInvocationPtr();
+  MD.ID.ContextHash = MD.Invocation->getModuleHash();
+
   llvm::DenseSet AddedModules;
   addAllSubmoduleDeps(M, MD, AddedModules);
+
+  return MD.ID;
 }
 
 void ModuleDepCollectorPP::addAllSubmoduleDeps(
@@ -211,11 +216,9 @@
 llvm::DenseSet &AddedModules) {
   for (const Module *Import : M->Imports) {
 if (Import->getTopLevelModule() != M->getTopLevelModule()) {
+  ModuleID ImportID = handleTopLevelModule(Import->getTopLevelModule());
   if (AddedModules.insert(Import->getTopLevelModule()).second)
-MD.ClangModuleDeps.push_back(
-{std::string(Import->getTopLevelModuleName()),
- Instance.getInvocation().getModuleHash()});
-  handleTopLevelModule(Import->getTopLevelModule());
+MD.ClangModuleDeps.push_back(ImportID);
 }
   }
 }
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -143,7 +143,7 @@
   for (auto &&M : ClangModuleDeps) {
 auto &MD = M.second;
 if (MD.ImportedByMainFile)
-  FD.ClangModuleDeps.push_back({MD.ID.ModuleName, ContextHash});
+  FD.ClangModuleDeps.push_back(MD.ID);
   }
 
   FullDependenciesResult FDR;
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -147,7 +147,7 @@
   /// Traverses the previously collected direct modular dependencies to discover
   /// transitive modular dependencies and fills the parent \c ModuleDepCollector
   /// with both.
-  void handleTopLevelModule(const Module *M);
+  ModuleID handleTopLevelModule(const Module *M);
   void addAllSubmoduleDeps(const Module *M,

[PATCH] D102473: [clang][deps] Stop assuming the TU's context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:147
   const Module *TopLevelModule = Imported->getTopLevelModule();
-  MDC.ModularDeps[MDC.ContextHash + TopLevelModule->getFullModuleName()]
-  .ImportedByMainFile = true;

We don't know the context hash of the imported module just yet. Let's postpone 
its creation until `EndOfMainFile`, where we iterate over `DirectModularDeps` 
that also contains this module. We can also use its presence in 
`DirectModularDeps` to determine that it was imported by the main file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102473

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


[PATCH] D102482: [clang][deps] NFC: Report modules' context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch eagerly constructs and modifies CompilerInvocation of modular 
dependencies in order to report the correct context hash instead of the hash of 
the original translation unit.

No functionality change here, since we currently don't modify 
CompilerInvocation in a way that affects the context hash.

Depends on D102473 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102482

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -19,9 +19,10 @@
 using namespace dependencies;
 
 static CompilerInvocation
-makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps) {
+makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps,
+ const CompilerInvocation &Invocation) 
{
   // Make a deep copy of the invocation.
-  CompilerInvocation CI(*Deps.Invocation);
+  CompilerInvocation CI(Invocation);
 
   // Remove options incompatible with explicit module build.
   CI.getFrontendOpts().Inputs.clear();
@@ -38,7 +39,7 @@
 }
 
 static std::vector
-serializeCompilerInvocation(CompilerInvocation &CI) {
+serializeCompilerInvocation(const CompilerInvocation &CI) {
   // Set up string allocator.
   llvm::BumpPtrAllocator Alloc;
   llvm::StringSaver Strings(Alloc);
@@ -55,7 +56,7 @@
 std::vector ModuleDeps::getCanonicalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  CompilerInvocation CI(makeInvocationForModuleBuildWithoutPaths(*this));
+  CompilerInvocation CI(Invocation);
 
   dependencies::detail::collectPCMAndModuleMapPaths(
   ClangModuleDeps, LookupPCMPath, LookupModuleDeps,
@@ -66,9 +67,7 @@
 
 std::vector
 ModuleDeps::getCanonicalCommandLineWithoutModulePaths() const {
-  CompilerInvocation CI(makeInvocationForModuleBuildWithoutPaths(*this));
-
-  return serializeCompilerInvocation(CI);
+  return serializeCompilerInvocation(Invocation);
 }
 
 void dependencies::detail::collectPCMAndModuleMapPaths(
@@ -190,11 +189,9 @@
 MD.FileDeps.insert(IF.getFile()->getName());
   });
 
-  // FIXME: Prepare the CompilerInvocation for building this module **now**, so
-  //that we store the actual context hash for this module (not just the
-  //context hash inherited from the original TU).
-  MD.Invocation = Instance.getInvocationPtr();
-  MD.ID.ContextHash = MD.Invocation->getModuleHash();
+  MD.Invocation =
+  makeInvocationForModuleBuildWithoutPaths(MD, Instance.getInvocation());
+  MD.ID.ContextHash = MD.Invocation.getModuleHash();
 
   llvm::DenseSet AddedModules;
   addAllSubmoduleDeps(M, MD, AddedModules);
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -75,9 +75,8 @@
   // the primary TU.
   bool ImportedByMainFile = false;
 
-  /// The compiler invocation associated with the translation unit that imports
-  /// this module.
-  std::shared_ptr Invocation;
+  /// Compiler invocation that can be used to build this module (without 
paths).
+  CompilerInvocation Invocation;
 
   /// Gets the canonical command line suitable for passing to clang.
   ///
Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -225,11 +225,9 @@
 
   bool hasInvocation() const { return Invocation != nullptr; }
 
-  CompilerInvocation &getInvocation() { return *getInvocationPtr(); }
-
-  std::shared_ptr getInvocationPtr() {
+  CompilerInvocation &getInvocation() {
 assert(Invocation && "Compiler instance has no invocation!");
-return Invocation;
+return *Invocation;
   }
 
   /// setInvocation - Replace the current invocation.


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -19,9 +19,10 @@
 using namespace dependencies;
 
 static CompilerInvocation
-makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps) {
+makeInvocat

[clang] 0566f97 - [clang][NFC] remove unused return value

2021-05-14 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-05-14T05:25:47-07:00
New Revision: 0566f979619cf49a62804a7e3530438f1319fa7c

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

LOG: [clang][NFC] remove unused return value

In working on p0388 (ary[N] -> ary[] conversion), I discovered neither
use of UnwrapSimilarArrayTypes used the return value. So let's nuke
it.

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

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 6ebdca06d58ff..be6170564fcd0 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2455,7 +2455,7 @@ class ASTContext : public RefCountedBase {
const ObjCMethodDecl *MethodImp);
 
   bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
-  bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
+  void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
 
   /// Determine if two types are similar, according to the C++ rules. That is,
   /// determine if they are the same other than qualifiers on the initial

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6eb8da7411237..06f232557708b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5766,29 +5766,29 @@ QualType ASTContext::getUnqualifiedArrayType(QualType 
type,
 /// Attempt to unwrap two types that may both be array types with the same 
bound
 /// (or both be array types of unknown bound) for the purpose of comparing the
 /// cv-decomposition of two types per C++ [conv.qual].
-bool ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
-  bool UnwrappedAny = false;
+void ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
   while (true) {
 auto *AT1 = getAsArrayType(T1);
-if (!AT1) return UnwrappedAny;
+if (!AT1)
+  return;
 
 auto *AT2 = getAsArrayType(T2);
-if (!AT2) return UnwrappedAny;
+if (!AT2)
+  return;
 
 // If we don't have two array types with the same constant bound nor two
 // incomplete array types, we've unwrapped everything we can.
 if (auto *CAT1 = dyn_cast(AT1)) {
   auto *CAT2 = dyn_cast(AT2);
   if (!CAT2 || CAT1->getSize() != CAT2->getSize())
-return UnwrappedAny;
+return;
 } else if (!isa(AT1) ||
!isa(AT2)) {
-  return UnwrappedAny;
+  return;
 }
 
 T1 = AT1->getElementType();
 T2 = AT2->getElementType();
-UnwrappedAny = true;
   }
 }
 



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


[PATCH] D102480: [clang][NFC] remove unused return value

2021-05-14 Thread Nathan Sidwell 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 rG0566f979619c: [clang][NFC] remove unused return value 
(authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102480

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -5766,29 +5766,29 @@
 /// Attempt to unwrap two types that may both be array types with the same 
bound
 /// (or both be array types of unknown bound) for the purpose of comparing the
 /// cv-decomposition of two types per C++ [conv.qual].
-bool ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
-  bool UnwrappedAny = false;
+void ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
   while (true) {
 auto *AT1 = getAsArrayType(T1);
-if (!AT1) return UnwrappedAny;
+if (!AT1)
+  return;
 
 auto *AT2 = getAsArrayType(T2);
-if (!AT2) return UnwrappedAny;
+if (!AT2)
+  return;
 
 // If we don't have two array types with the same constant bound nor two
 // incomplete array types, we've unwrapped everything we can.
 if (auto *CAT1 = dyn_cast(AT1)) {
   auto *CAT2 = dyn_cast(AT2);
   if (!CAT2 || CAT1->getSize() != CAT2->getSize())
-return UnwrappedAny;
+return;
 } else if (!isa(AT1) ||
!isa(AT2)) {
-  return UnwrappedAny;
+  return;
 }
 
 T1 = AT1->getElementType();
 T2 = AT2->getElementType();
-UnwrappedAny = true;
   }
 }
 
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2455,7 +2455,7 @@
const ObjCMethodDecl *MethodImp);
 
   bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
-  bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
+  void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
 
   /// Determine if two types are similar, according to the C++ rules. That is,
   /// determine if they are the same other than qualifiers on the initial


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -5766,29 +5766,29 @@
 /// Attempt to unwrap two types that may both be array types with the same bound
 /// (or both be array types of unknown bound) for the purpose of comparing the
 /// cv-decomposition of two types per C++ [conv.qual].
-bool ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
-  bool UnwrappedAny = false;
+void ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
   while (true) {
 auto *AT1 = getAsArrayType(T1);
-if (!AT1) return UnwrappedAny;
+if (!AT1)
+  return;
 
 auto *AT2 = getAsArrayType(T2);
-if (!AT2) return UnwrappedAny;
+if (!AT2)
+  return;
 
 // If we don't have two array types with the same constant bound nor two
 // incomplete array types, we've unwrapped everything we can.
 if (auto *CAT1 = dyn_cast(AT1)) {
   auto *CAT2 = dyn_cast(AT2);
   if (!CAT2 || CAT1->getSize() != CAT2->getSize())
-return UnwrappedAny;
+return;
 } else if (!isa(AT1) ||
!isa(AT2)) {
-  return UnwrappedAny;
+  return;
 }
 
 T1 = AT1->getElementType();
 T2 = AT2->getElementType();
-UnwrappedAny = true;
   }
 }
 
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2455,7 +2455,7 @@
const ObjCMethodDecl *MethodImp);
 
   bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
-  bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
+  void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
 
   /// Determine if two types are similar, according to the C++ rules. That is,
   /// determine if they are the same other than qualifiers on the initial
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102488: [clang][deps] Prune unused header search paths

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To reduce the number of explicit builds of a single module, we can try to 
squash multiple occurances of the module with different command-lines (and 
context hashes) by removing benign command-line options. The greatest 
contributors to benign differences between command-lines are the header search 
paths.

In this patch, the lookup cache in `HeaderSearch` is used to determine which 
paths were actually used when implicitly building the module during scanning. 
This information is serialized into the unhashed control block of the 
implicitly-built PCM. The dependency scanner then loads this and may use it to 
prune the header search paths before computing the context hash of the module 
and generating the command-line.

We could also prune the header search paths when serializing 
`HeaderSearchOptions` into the PCM. That way, we could do it only once instead 
of every load of the PCM file by dependency scanner. However, that would result 
in a PCM file whose contents don't produce the same context hash, which is 
probably highly surprising.

There is an alternative approach to storing extra information into the PCM: 
wire up preprocessor callbacks to capture the used header search paths 
on-the-fly during preprocessing of modularized headers (similar to what we 
currently do for the main source file and textual headers). Right now, that's 
not compatible with the fact that we do an actual implicit build producing PCM 
files during dependency scanning. The second run of dependency scanner loads 
the PCM from the first run, skipping the preprocessing altogether, which would 
result in different results between runs. We can revisit this approach when we


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102488

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/header-search-pruning/a/a.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/b/b.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json
  clang/test/ClangScanDeps/Inputs/header-search-pruning/mod.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/module.modulemap
  clang/test/ClangScanDeps/header-search-pruning.cpp
  clang/test/ClangScanDeps/modules-full.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -163,6 +163,11 @@
 "'-fmodule-file=', '-o', '-fmodule-map-file='."),
 llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
 
+static llvm::cl::opt OptimizeArgs(
+"optimize-args",
+llvm::cl::desc("Whether to optimize command-line arguments of modules."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -357,7 +362,26 @@
 
 private:
   StringRef lookupPCMPath(ModuleID MID) {
-return Modules[IndexedModuleID{MID, 0}].ImplicitModulePCMPath;
+auto PCMPath = PCMPaths.insert({IndexedModuleID{MID, 0}, ""});
+if (PCMPath.second)
+  PCMPath.first->second = constructPCMPath(lookupModuleDeps(MID));
+return PCMPath.first->second;
+  }
+
+  /// Construct a path where to put the explicitly built PCM - essentially the
+  /// path to implicitly built PCM with the context hash replaced by the final
+  /// (potentially modified) context hash.
+  std::string constructPCMPath(const ModuleDeps &MD) const {
+const std::string &ImplicitPCMPath = MD.ImplicitModulePCMPath;
+StringRef Filename = llvm::sys::path::filename(ImplicitPCMPath);
+StringRef ImplicitContextHashPath =
+llvm::sys::path::parent_path(ImplicitPCMPath);
+StringRef ModuleCachePath =
+llvm::sys::path::parent_path(ImplicitContextHashPath);
+
+SmallString<64> ExplicitPCMPath = ModuleCachePath;
+llvm::sys::path::append(ExplicitPCMPath, MD.ID.ContextHash, Filename);
+return std::string(ExplicitPCMPath);
   }
 
   const ModuleDeps &lookupModuleDeps(ModuleID MID) {
@@ -395,6 

[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: jroelofs, ab, scanon, arphaman.
Herald added subscribers: dexonsmith, dang.
fhahn requested review of this revision.
Herald added a project: clang.

Support for Darwin's libsystem_m's vector functions has been added to
LLVM in 93a9a8a8d90f 
.

This patch adds support for -fveclib=Darwin_libsystem_m to Clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102489

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fveclib.c


Index: clang/test/Driver/fveclib.c
===
--- clang/test/Driver/fveclib.c
+++ clang/test/Driver/fveclib.c
@@ -2,12 +2,14 @@
 // RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix 
CHECK-ACCELERATE %s
 // RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix 
CHECK-libmvec %s
 // RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix 
CHECK-MASSV %s
+// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck 
-check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
 // RUN: not %clang -c -fveclib=something %s 2>&1 | FileCheck -check-prefix 
CHECK-INVALID %s
 
 // CHECK-NOLIB: "-fveclib=none"
 // CHECK-ACCELERATE: "-fveclib=Accelerate"
 // CHECK-libmvec: "-fveclib=libmvec"
 // CHECK-MASSV: "-fveclib=MASSV"
+// CHECK-DARWIN_LIBSYSTEM_M: "-fveclib=Darwin_libsystem_m"
 
 // CHECK-INVALID: error: invalid value 'something' in '-fveclib=something'
 
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -76,6 +76,7 @@
 // FLTOALL-NEXT: thin
 // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
 // FVECLIBALL: Accelerate
+// FVECLIBALL-NEXT: Darwin_libsystem_m
 // FVECLIBALL-NEXT: libmvec
 // FVECLIBALL-NEXT: MASSV
 // FVECLIBALL-NEXT: none
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -402,6 +402,10 @@
   case CodeGenOptions::SVML:
 TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML);
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(
+TargetLibraryInfoImpl::DarwinLibSystemM);
+break;
   default:
 break;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2163,9 +2163,10 @@
   Alias;
 def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>,
 HelpText<"Use the given vector functions library">,
-Values<"Accelerate,libmvec,MASSV,SVML,none">,
+Values<"Accelerate,libmvec,MASSV,SVML,Darwin_libsystem_m,none">,
 NormalizedValuesScope<"CodeGenOptions">,
-NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "NoLibrary"]>,
+NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML",
+  "Darwin_libsystem_m", "NoLibrary"]>,
 MarshallingInfoEnum, "NoLibrary">;
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, 
Group,
   Alias, AliasArgs<["none"]>;
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -55,11 +55,12 @@
   };
 
   enum VectorLibrary {
-NoLibrary,  // Don't use any vector library.
-Accelerate, // Use the Accelerate framework.
-LIBMVEC,// GLIBC vector math library.
-MASSV,  // IBM MASS vector library.
-SVML// Intel short vector math library.
+NoLibrary, // Don't use any vector library.
+Accelerate,// Use the Accelerate framework.
+LIBMVEC,   // GLIBC vector math library.
+MASSV, // IBM MASS vector library.
+SVML,  // Intel short vector math library.
+Darwin_libsystem_m // Use Darwin's libsytem_m vector functions.
   };
 
   enum ObjCDispatchMethodKind {


Index: clang/test/Driver/fveclib.c
===
--- clang/test/Driver/fveclib.c
+++ clang/test/Driver/fveclib.c
@@ -2,12 +2,14 @@
 // RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix CHECK-ACCELERATE %s
 // RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix CHECK-libmvec %s
 // RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix CHECK-MASSV %s
+// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck -check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
 // RUN: n

[PATCH] D102397: [AArch64] Lower bitreverse in ISel

2021-05-14 Thread Irina Dobrescu via Phabricator via cfe-commits
Rin updated this revision to Diff 345411.
Rin added a comment.

Remove unnecessary comment and add more bitreverse tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102397

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-misc.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
  llvm/test/CodeGen/AArch64/bitreverse.ll

Index: llvm/test/CodeGen/AArch64/bitreverse.ll
===
--- llvm/test/CodeGen/AArch64/bitreverse.ll
+++ llvm/test/CodeGen/AArch64/bitreverse.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=aarch64-eabi %s -o - | FileCheck %s
 
 ; These tests just check that the plumbing is in place for @llvm.bitreverse.
@@ -6,13 +7,16 @@
 
 define <2 x i16> @f(<2 x i16> %a) {
 ; CHECK-LABEL: f:
-; CHECK: fmov [[REG1:w[0-9]+]], s0
-; CHECK-DAG: rbit [[REG2:w[0-9]+]], [[REG1]]
-; CHECK-DAG: fmov s0, [[REG2]]
-; CHECK-DAG: mov [[REG3:w[0-9]+]], v0.s[1]
-; CHECK-DAG: rbit [[REG4:w[0-9]+]], [[REG3]]
-; CHECK-DAG: mov v0.s[1], [[REG4]]
-; CHECK-DAG: ushr v0.2s, v0.2s, #16
+; CHECK:   // %bb.0:
+; CHECK-NEXT:// kill: def $d0 killed $d0 def $q0
+; CHECK-NEXT:fmov w8, s0
+; CHECK-NEXT:rbit w8, w8
+; CHECK-NEXT:mov w9, v0.s[1]
+; CHECK-NEXT:fmov s0, w8
+; CHECK-NEXT:rbit w8, w9
+; CHECK-NEXT:mov v0.s[1], w8
+; CHECK-NEXT:ushr v0.2s, v0.2s, #16
+; CHECK-NEXT:ret
   %b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a)
   ret <2 x i16> %b
 }
@@ -21,41 +25,161 @@
 
 define i8 @g(i8 %a) {
 ; CHECK-LABEL: g:
-; CHECK: rbit [[REG:w[0-9]+]], w0
-; CHECK-NEXT: lsr w0, [[REG]], #24
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit w8, w0
+; CHECK-NEXT:lsr w0, w8, #24
+; CHECK-NEXT:ret
   %b = call i8 @llvm.bitreverse.i8(i8 %a)
   ret i8 %b
 }
 
+declare i16 @llvm.bitreverse.i16(i16) readnone
+
+define i16 @g_16(i16 %a) {
+; CHECK-LABEL: g_16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit w8, w0
+; CHECK-NEXT:lsr w0, w8, #16
+; CHECK-NEXT:ret
+  %b = call i16 @llvm.bitreverse.i16(i16 %a)
+  ret i16 %b
+}
+
+declare i32 @llvm.bitreverse.i32(i32) readnone
+
+define i32 @g_32(i32 %a) {
+; CHECK-LABEL: g_32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit w0, w0
+; CHECK-NEXT:ret
+  %b = call i32 @llvm.bitreverse.i32(i32 %a)
+  ret i32 %b
+}
+
+declare i64 @llvm.bitreverse.i64(i64) readnone
+
+define i64 @g_64(i64 %a) {
+; CHECK-LABEL: g_64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit x0, x0
+; CHECK-NEXT:ret
+  %b = call i64 @llvm.bitreverse.i64(i64 %a)
+  ret i64 %b
+}
+
 declare <8 x i8> @llvm.bitreverse.v8i8(<8 x i8>) readnone
 
 define <8 x i8> @g_vec(<8 x i8> %a) {
-; CHECK-DAG: movi [[M1:v.*]], #15
-; CHECK-DAG: movi [[M2:v.*]], #240
-; CHECK: and  [[A1:v.*]], v0.8b, [[M1]]
-; CHECK: and  [[A2:v.*]], v0.8b, [[M2]]
-; CHECK-DAG: shl  [[L4:v.*]], [[A1]], #4
-; CHECK-DAG: ushr [[R4:v.*]], [[A2]], #4
-; CHECK-DAG: orr  [[V4:v.*]], [[R4]], [[L4]]
-
-; CHECK-DAG: movi [[M3:v.*]], #51
-; CHECK-DAG: movi [[M4:v.*]], #204
-; CHECK: and  [[A3:v.*]], [[V4]], [[M3]]
-; CHECK: and  [[A4:v.*]], [[V4]], [[M4]]
-; CHECK-DAG: shl  [[L2:v.*]], [[A3]], #2
-; CHECK-DAG: ushr [[R2:v.*]], [[A4]], #2
-; CHECK-DAG: orr  [[V2:v.*]], [[R2]], [[L2]]
-
-; CHECK-DAG: movi [[M5:v.*]], #85
-; CHECK-DAG: movi [[M6:v.*]], #170
-; CHECK: and  [[A5:v.*]], [[V2]], [[M5]]
-; CHECK: and  [[A6:v.*]], [[V2]], [[M6]]
-; CHECK-DAG: shl  [[L1:v.*]], [[A5]], #1
-; CHECK-DAG: ushr [[R1:v.*]], [[A6]], #1
-; CHECK: orr  [[V1:v.*]], [[R1]], [[L1]]
-
-; CHECK: ret
+; CHECK-LABEL: g_vec:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit v0.8b, v0.8b
+; CHECK-NEXT:ret
   %b = call <8 x i8> @llvm.bitreverse.v8i8(<8 x i8> %a)
   ret <8 x i8> %b
 }
+
+declare <16 x i8> @llvm.bitreverse.v16i8(<16 x i8>) readnone
+
+define <16 x i8> @g_vec_16x8(<16 x i8> %a) {
+; CHECK-LABEL: g_vec_16x8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit v0.16b, v0.16b
+; CHECK-NEXT:ret
+  %b = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %a)
+  ret <16 x i8> %b
+}
+
+declare <4 x i16> @llvm.bitreverse.v4i16(<4 x i16>) readnone
+
+define <4 x i16> @g_vec_4x16(<4 x i16> %a) {
+; CHECK-LABEL: g_vec_4x16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev16 v0.8b, v0.8b
+; CHECK-NEXT:rbit v0.8b, v0.8b
+; CHECK-NEXT:ret
+  %b = call <4 x i16> @llvm.bitreverse.v4i16(<4 x i16> %a)
+  ret <4 x i16> %b
+}
+
+declare <8 x i16> @llvm.bitreverse.v8i16(<8 x i16>) readnone
+
+define <8 x i16> @g_vec_8x16(<8 x i16> %a) {
+; CHECK-LABEL: g_vec_8x16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev16 v0.16b, v0.16b
+; CHECK-NEXT:rbit v0.16b, v0.16b
+; CHECK-NEXT:r

[PATCH] D102488: [clang][deps] Prune unused header search paths

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 345412.
jansvoboda11 added a comment.

Undo changes to `modules-full.cpp` test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102488

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/header-search-pruning/a/a.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/b/b.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json
  clang/test/ClangScanDeps/Inputs/header-search-pruning/mod.h
  clang/test/ClangScanDeps/Inputs/header-search-pruning/module.modulemap
  clang/test/ClangScanDeps/header-search-pruning.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -163,6 +163,11 @@
 "'-fmodule-file=', '-o', '-fmodule-map-file='."),
 llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
 
+static llvm::cl::opt OptimizeArgs(
+"optimize-args",
+llvm::cl::desc("Whether to optimize command-line arguments of modules."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -357,7 +362,26 @@
 
 private:
   StringRef lookupPCMPath(ModuleID MID) {
-return Modules[IndexedModuleID{MID, 0}].ImplicitModulePCMPath;
+auto PCMPath = PCMPaths.insert({IndexedModuleID{MID, 0}, ""});
+if (PCMPath.second)
+  PCMPath.first->second = constructPCMPath(lookupModuleDeps(MID));
+return PCMPath.first->second;
+  }
+
+  /// Construct a path where to put the explicitly built PCM - essentially the
+  /// path to implicitly built PCM with the context hash replaced by the final
+  /// (potentially modified) context hash.
+  std::string constructPCMPath(const ModuleDeps &MD) const {
+const std::string &ImplicitPCMPath = MD.ImplicitModulePCMPath;
+StringRef Filename = llvm::sys::path::filename(ImplicitPCMPath);
+StringRef ImplicitContextHashPath =
+llvm::sys::path::parent_path(ImplicitPCMPath);
+StringRef ModuleCachePath =
+llvm::sys::path::parent_path(ImplicitContextHashPath);
+
+SmallString<64> ExplicitPCMPath = ModuleCachePath;
+llvm::sys::path::append(ExplicitPCMPath, MD.ID.ContextHash, Filename);
+return std::string(ExplicitPCMPath);
   }
 
   const ModuleDeps &lookupModuleDeps(ModuleID MID) {
@@ -395,6 +419,8 @@
   std::mutex Lock;
   std::unordered_map
   Modules;
+  std::unordered_map
+  PCMPaths;
   std::vector Inputs;
 };
 
@@ -554,7 +580,7 @@
   SharedStream DependencyOS(llvm::outs());
 
   DependencyScanningService Service(ScanMode, Format, ReuseFileManager,
-SkipExcludedPPRanges);
+SkipExcludedPPRanges, OptimizeArgs);
   llvm::ThreadPool Pool(llvm::hardware_concurrency(NumThreads));
   std::vector> WorkerTools;
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I)
Index: clang/test/ClangScanDeps/header-search-pruning.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/header-search-pruning.cpp
@@ -0,0 +1,87 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: cp -r %S/Inputs/header-search-pruning/* %t
+// RUN: cp %S/header-search-pruning.cpp %t/header-search-pruning.cpp
+// RUN: sed -e "s|DIR|%t|g" -e "s|DEFINES|-DINCLUDE_A|g" %S/Inputs/header-search-pruning/cdb.json > %t/cdb_a.json
+// RUN: sed -e "s|DIR|%t|g" -e "s|DEFINES|-DINCLUDE_B|g" %S/Inputs/header-search-pruning/cdb.json > %t/cdb_b.json
+// RUN: sed -e "s|DIR|%t|g" -e "s|DEFINES|-DINCLUDE_A -DINCLUDE_B|g" %S/Inputs/header-search-pruning/cdb.json > %t/cdb_ab.json
+//
+// RUN: clang-scan-deps -compilation-database %t/cdb_a.json -format experimental-full -optimize-args >> %t/result_a.json
+// RUN: cat %t/result_a.json | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK_A %s
+//
+// RUN: clang-scan-deps -compilation-database %t/cdb_b.json -format experimental-full -optimize-args >> %t/result_b.json
+// RUN: cat %t/result_b.json | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK_B %s
+//
+/

[PATCH] D102473: [clang][deps] NFC: Stop assuming the TU's context hash

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h:182
   /// Direct and transitive modular dependencies of the main source file.
-  std::unordered_map ModularDeps;
+  std::unordered_map ModularDeps;
   /// Options that control the dependency output generation.

Computing the context hash might be expensive now, so use `const Module *` 
instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102473

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


[PATCH] D101777: [clang] p1099 1/5: [NFC] Break out BaseUsingDecl from UsingDecl

2021-05-14 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan updated this revision to Diff 345416.
urnathan added a comment.
Herald added subscribers: cfe-commits, usaxena95, kadircet.
Herald added a project: clang-tools-extra.

Address the build failure --thanks for explaining, it wasn;t clear what else I 
should try and build.  Grepping showed no other getUsingDecl calls.  Let's see 
...


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

https://reviews.llvm.org/D101777

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6540,7 +6540,7 @@
   }
 
   case Decl::Using:
-return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
+return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
TU);
 
   case Decl::UsingShadow:
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1870,7 +1870,7 @@
   Diag(KWLoc, diag::err_using_decl_conflict_reverse);
   Diag(Shadow->getTargetDecl()->getLocation(),
diag::note_using_decl_target);
-  Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
+  Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
   // Recover by ignoring the old declaration.
   PrevDecl = PrevClassTemplate = nullptr;
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3732,7 +3732,7 @@
   // A shadow declaration that's created by a resolved using declaration
   // is not hidden by the same using declaration.
   if (isa(ND) && isa(D) &&
-  cast(ND)->getUsingDecl() == D)
+  cast(ND)->getIntroducer() == D)
 continue;
 
   // We've found a declaration that hides this one.
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6992,7 +6992,7 @@
   : S(S), UseLoc(UseLoc) {
 bool DiagnosedMultipleConstructedBases = false;
 CXXRecordDecl *ConstructedBase = nullptr;
-UsingDecl *ConstructedBaseUsing = nullptr;
+BaseUsingDecl *ConstructedBaseIntroducer = nullptr;
 
 // Find the set of such base class subobjects and check that there's a
 // unique constructed subobject.
@@ -7016,18 +7016,18 @@
   //   of type B, the program is ill-formed.
   if (!ConstructedBase) {
 ConstructedBase = DConstructedBase;
-ConstructedBaseUsing = D->getUsingDecl();
+ConstructedBaseIntroducer = D->getIntroducer();
   } else if (ConstructedBase != DConstructedBase &&
  !Shadow->isInvalidDecl()) {
 if (!DiagnosedMultipleConstructedBases) {
   S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
   << Shadow->getTargetDecl();
-  S.Diag(ConstructedBaseUsing->getLocation(),
-   diag::note_ambiguous_inherited_constructor_using)
+  S.Diag(ConstructedBaseIntroducer->getLocation(),
+ diag::note_ambiguous_inherited_constructor_using)
   << ConstructedBase;
   DiagnosedMultipleConstructedBases = true;
 }
-S.Diag(D->getUsingDecl()->getLocation(),
+S.Diag(D->getIntroducer()->getLocation(),
diag::note_ambiguous_inherited_constructor_using)
 << DConstructedBase;
   }
@@ -11625,7 +11625,7 @@
 
 /// Determines whether to create a using shadow decl for a particular
 /// decl, given the set of decls existing prior to this using lookup.
-bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig,
+bool Sema::CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Orig,
 const LookupResult &Previous,
 UsingShadowDecl *&PrevShadow) {
   // Diagnose finding a decl which is not from a base class of the
@@ -11647,35 +11647,36 @@
   // specialization.  The UsingShadowDecl in D then points directly
   // to A::foo, which will look well-formed when we instantiate.
   // The right solution is to not collapse the shadow-decl chain.
-  if (!getLangOpts().CPlusPlus11 && CurContext->isRecord()) {
-DeclContext *OrigDC = Orig->getDeclContext();
-
-// H

[PATCH] D94376: [MemCpyOpt] Enable MemorySSA by default

2021-05-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In my premerge testing, I see this fail which looks like the check string is 
incorrect:

  command stderr:
  
C:\ws\w16e2-2\llvm-project\premerge-checks\llvm\test\Other\new-pm-lto-defaults.ll:84:21:
 error: CHECK-O23SZ-NEXT: expected string not found in input
  
  ; CHECK-O23SZ-NEXT: Running pass: InvalidateAnalysisPass on 
foo
  
  ^
  
  :49:40: note: scanning from here
  
  Running analysis: GlobalsAA on [module]
  
 ^
  
  :50:1: note: possible intended match here
  
  Running pass: InvalidateAnalysisPass on foo
  
  https://reviews.llvm.org/harbormaster/unit/view/743692/ for D101640


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94376

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


[PATCH] D102491: [clang][modules] Build inferred modules

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch enables explicitly building inferred modules.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 
authored by @Bigcheese with libclang and dependency scanner changes omitted.

Contains the following changes:

1. [Clang] Fix the header paths in clang::Module for inferred modules.
  - The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie 
for framework modules. For those they actually are the path to the header or 
umbrella relative to the clang::Module::Directory.
  - The exception to this case is for inferred modules. Here it actually is the 
name as written, because we print out the module and read it back in when 
implicitly building modules. This causes a problem when explicitly building an 
inferred module, as we skip the printing out step.
  - In order to fix this issue this patch adds a new field for the path we want 
to use in getInputBufferForModule. It also makes NameAsWritten actually be the 
name written in the module map file (or that would be, in the case of an 
inferred module).

2. [Clang] Allow explicitly building an inferred module.
  - Building the actual module still fails, but make sure it fails for the 
right reason.

Split from D100934 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102491

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  
clang/test/Modules/Inputs/explicit-build-inferred/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/Modules/Inputs/explicit-build-inferred/frameworks/module.modulemap
  clang/test/Modules/explicit-build-inferred.cpp

Index: clang/test/Modules/explicit-build-inferred.cpp
===
--- /dev/null
+++ clang/test/Modules/explicit-build-inferred.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t && mkdir %t
+//
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fimplicit-module-maps \
+// RUN:   -emit-module -x c++ %S/Inputs/explicit-build-inferred/frameworks/module.modulemap \
+// RUN:   -fmodule-name=Inferred -o %t/Inferred.pcm -F %S/Inputs/explicit-build-inferred/frameworks
+//
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fsyntax-only %s \
+// RUN:   -fmodule-map-file=%S/Inputs/explicit-build-inferred/frameworks/module.modulemap \
+// RUN:   -fmodule-file=%t/Inferred.pcm -F %S/Inputs/explicit-build-inferred/frameworks
+
+#include 
+
+inferred a = 0;
Index: clang/test/Modules/Inputs/explicit-build-inferred/frameworks/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-inferred/frameworks/module.modulemap
@@ -0,0 +1 @@
+framework module * {}
Index: clang/test/Modules/Inputs/explicit-build-inferred/frameworks/Inferred.framework/Headers/Inferred.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-inferred/frameworks/Inferred.framework/Headers/Inferred.h
@@ -0,0 +1 @@
+typedef int inferred;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1921,10 +1921,9 @@
 std::string Filename = std::string(key.Filename);
 if (key.Imported)
   Reader.ResolveImportedPath(M, Filename);
-// FIXME: This is not always the right filename-as-written, but we're not
-// going to use this information to rebuild the module, so it doesn't make
-// a lot of difference.
-Module::Header H = {std::string(key.Filename), *FileMgr.getFile(Filename)};
+// FIXME: NameAsWritten
+Module::Header H = {std::string(key.Filename), "",
+*FileMgr.getFile(Filename)};
 ModMap.addHeader(Mod, H, HeaderRole, /*Imported*/true);
 HFI.isModuleHeader |= !(HeaderRole & ModuleMap::TextualHeader);
   }
@@ -5618,7 +5617,8 @@
   ResolveImportedPath(F, Filename);
   if (auto Umbrella = PP.getFileManager().getFile(Filename)) {
 if (!CurrentModule->getUmbrellaHeader())
-  ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob);
+  // FIXME: NameAsWritten
+  ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob, "");
 else if (CurrentModule->getUmbrellaHeader().Entry != *Umbrella) {
   if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
 Error("mismatched umbrella headers in submodule");
@@ -5651,7 +5651,8 @@
   ResolveImportedPath(F, Dirname);
   if (auto Umbrella = 

[PATCH] D102492: [clang][AST] Add support for BindingDecl to ASTImporter.

2021-05-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, 
dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102492

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -868,6 +868,14 @@
  namespaceDecl(has(usingShadowDecl(;
 }
 
+TEST_P(ImportDecl, ImportBindingDecl) {
+  MatchVerifier Verifier;
+  testImport("int a[2] = {1, 2};"
+ "auto [declToImport, x] = a;",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ bindingDecl(hasType(asString("int";
+}
+
 TEST_P(ImportExpr, ImportUnresolvedLookupExpr) {
   MatchVerifier Verifier;
   testImport("template int foo();"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -481,6 +481,7 @@
 ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D);
 ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D);
 ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D);
+ExpectedDecl VisitBindingDecl(BindingDecl *D);
 ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D);
 ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
 ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
@@ -2274,6 +2275,36 @@
   return ToD;
 }
 
+ExpectedDecl ASTNodeImporter::VisitBindingDecl(BindingDecl *D) {
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToND;
+  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToND, Loc))
+return std::move(Err);
+  if (ToND)
+return ToND;
+
+  Error Err = Error::success();
+  auto ToType = importChecked(Err, D->getType());
+  auto ToBinding = importChecked(Err, D->getBinding());
+  auto ToDecomposedDecl = importChecked(Err, D->getDecomposedDecl());
+  if (Err)
+return std::move(Err);
+
+  BindingDecl *ToD;
+  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
+  Name.getAsIdentifierInfo()))
+return ToD;
+
+  ToD->setLexicalDeclContext(LexicalDC);
+  DC->addDeclInternal(ToD);
+  ToD->setBinding(ToType, ToBinding);
+  ToD->setDecomposedDecl(ToDecomposedDecl);
+
+  return ToD;
+}
+
 ExpectedDecl ASTNodeImporter::VisitAccessSpecDecl(AccessSpecDecl *D) {
   ExpectedSLoc LocOrErr = import(D->getLocation());
   if (!LocOrErr)


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -868,6 +868,14 @@
  namespaceDecl(has(usingShadowDecl(;
 }
 
+TEST_P(ImportDecl, ImportBindingDecl) {
+  MatchVerifier Verifier;
+  testImport("int a[2] = {1, 2};"
+ "auto [declToImport, x] = a;",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ bindingDecl(hasType(asString("int";
+}
+
 TEST_P(ImportExpr, ImportUnresolvedLookupExpr) {
   MatchVerifier Verifier;
   testImport("template int foo();"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -481,6 +481,7 @@
 ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D);
 ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D);
 ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D);
+ExpectedDecl VisitBindingDecl(BindingDecl *D);
 ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D);
 ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
 ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
@@ -2274,6 +2275,36 @@
   return ToD;
 }
 
+ExpectedDecl ASTNodeImporter::VisitBindingDecl(BindingDecl *D) {
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToND;
+  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToND, Loc))
+return std::move(Err);
+  if (ToND)
+return ToND;
+
+  Error Err = Error::success();
+  auto ToType = importChecked(Err, D->getType());
+  auto ToBinding = importChecked(Err, D->getBinding());
+  auto ToDecomposedDecl = importChecked(Err, D->getDecomposedDecl());
+  if (Err)
+return std::move(Err);
+
+  BindingDecl *ToD;
+  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
+  Name.getAsIdentifierInfo()))
+return ToD;
+
+  ToD->setLexicalDeclContext(LexicalDC);
+  DC->addDeclInternal(ToD);
+  ToD->setBinding(ToType, ToBinding);
+

[clang] 7cd2833 - [PowerPC] Add vec_vupkhpx and vec_vupklpx for XL compatibility

2021-05-14 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-05-14T08:02:00-05:00
New Revision: 7cd2833311ab614775bc695e7bb808159a02e2a9

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

LOG: [PowerPC] Add vec_vupkhpx and vec_vupklpx for XL compatibility

These are old names for these functions that XL still supports.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-altivec.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 25c1b1de998df..dadf6b5cf75bb 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -12520,6 +12520,13 @@ vec_vrfiz(vector float __a) {
 
 /* The vector unpack instructions all have a big-endian bias, so for
little endian we must reverse the meanings of "high" and "low."  */
+#ifdef __LITTLE_ENDIAN__
+#define vec_vupkhpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
+#define vec_vupklpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
+#else
+#define vec_vupkhpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
+#define vec_vupklpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
+#endif
 
 static __inline__ vector short __ATTRS_o_ai
 vec_unpackh(vector signed char __a) {

diff  --git a/clang/test/CodeGen/builtins-ppc-altivec.c 
b/clang/test/CodeGen/builtins-ppc-altivec.c
index e7593ca9021cf..8edef9806af22 100644
--- a/clang/test/CodeGen/builtins-ppc-altivec.c
+++ b/clang/test/CodeGen/builtins-ppc-altivec.c
@@ -5788,6 +5788,10 @@ void test6() {
 
   res_vui = vec_unpackh(vp);
 // CHECK: @llvm.ppc.altivec.vupkhpx
+// CHECK-LE: @llvm.ppc.altivec.vupklpx
+
+  res_vui = vec_vupkhpx(vp);
+// CHECK: @llvm.ppc.altivec.vupkhpx
 // CHECK-LE: @llvm.ppc.altivec.vupklpx
 
   res_vs  = vec_vupkhsb(vsc);
@@ -5829,6 +5833,10 @@ void test6() {
 
   res_vui = vec_unpackl(vp);
 // CHECK: @llvm.ppc.altivec.vupklpx
+// CHECK-LE: @llvm.ppc.altivec.vupkhpx
+
+  res_vui = vec_vupklpx(vp);
+// CHECK: @llvm.ppc.altivec.vupklpx
 // CHECK-LE: @llvm.ppc.altivec.vupkhpx
 
   res_vs  = vec_vupklsb(vsc);



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


[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 345422.
AbbasSabra added a comment.

Updating D102280 : [analyzer] rename test 
file + make sure that statements after "__leave" are not reached


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

Files:
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/test/Analysis/ms-seh.cpp


Index: clang/test/Analysis/ms-seh.cpp
===
--- /dev/null
+++ clang/test/Analysis/ms-seh.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple 
x86_64-pc-windows-msvc19.11.0 -fms-extensions -verify %s
+
+void clang_analyzer_warnIfReached();
+int filter();
+
+void try_except_leave() {
+  __try {
+__leave;// no-crash
+clang_analyzer_warnIfReached(); // no-warning
+  } __except (filter()) {
+  }
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+}
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -349,6 +349,7 @@
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:
   case Stmt::BreakStmtClass:
   case Stmt::GotoStmtClass:


Index: clang/test/Analysis/ms-seh.cpp
===
--- /dev/null
+++ clang/test/Analysis/ms-seh.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions -verify %s
+
+void clang_analyzer_warnIfReached();
+int filter();
+
+void try_except_leave() {
+  __try {
+__leave;// no-crash
+clang_analyzer_warnIfReached(); // no-warning
+  } __except (filter()) {
+  }
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+}
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -349,6 +349,7 @@
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
 
+  case Stmt::SEHLeaveStmtClass:
   case Stmt::ContinueStmtClass:
   case Stmt::BreakStmtClass:
   case Stmt::GotoStmtClass:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100934: [clang][modules] Build inferred modules

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 abandoned this revision.
jansvoboda11 added a comment.

I split out the support for building inferred modules explicitly: D102491 
.

Patch with changes to the dependency scanner will follow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

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


[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra added a comment.

In D102280#2759167 , @steakhal wrote:

> Do you have any good (mature, big enough) open-source projects for these msvc 
> constructs?

https://github.com/microsoft/winfile and 
https://github.com/chakra-core/ChakraCore seem to be using SEH but not heavily.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

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


[clang] 3d59f9d - [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO macro and crypto feature

2021-05-14 Thread David Candler via cfe-commits

Author: David Candler
Date: 2021-05-14T14:19:46+01:00
New Revision: 3d59f9d22440645ca0237dfc5d91ca09f749174b

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

LOG: [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO macro and crypto feature

This patch contains a couple of minor corrections to my previous
crypto patch:

Since both AArch32 and AArch64 are now correctly setting the aes and
sha2 features individually, it is not necessary to continue to check
the crypto feature when defining feature macros.

In the AArch32 driver, the feature vector is only modified when the
crypto feature is actually in the vector. If crypto is not present,
there is no need to split it and explicitly define crypto/sha2/aes.

Reviewed By: lenary

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index d26ae943b2e8a..82273a5e97aef 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)

diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 748a59525ef20..12439fcbeff96 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 // ACLE 6.5.7 Crypto Extension
 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
 // feature macros for AES and SHA2
-if (Crypto || (SHA2 && AES))
+if (SHA2 && AES)
   Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 if (SHA2)
   Builder.defineMacro("__ARM_FEATURE_SHA2", "1");

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 061eaf7924dbe..16d72e5367f58 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+  llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+return F.contains("crypto");
+  });
   const auto ItSHA2 =
   llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
 return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
 HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
 if (HasSHA2 && HasAES)
   Features.push_back("+crypto");
 else



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


[PATCH] D102406: [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO macro and crypto feature

2021-05-14 Thread David Candler 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 rG3d59f9d22440: [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO 
macro and crypto feature (authored by dcandler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102406

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+  llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+return F.contains("crypto");
+  });
   const auto ItSHA2 =
   llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
 return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@
 HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
 HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
 if (HasSHA2 && HasAES)
   Features.push_back("+crypto");
 else
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@
 // ACLE 6.5.7 Crypto Extension
 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
 // feature macros for AES and SHA2
-if (Crypto || (SHA2 && AES))
+if (SHA2 && AES)
   Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 if (SHA2)
   Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+  llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+return F.contains("crypto");
+  });
   const auto ItSHA2 =
   llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
 return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@
 HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
 HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
 if (HasSHA2 && HasAES)
   Features.push_back("+crypto");
 else
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@
 // ACLE 6.5.7 Crypto Extension
 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
 // feature macros for AES and SHA2
-if (Crypto || (SHA2 && AES))
+if (SHA2 && AES)
   Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 if (SHA2)
   Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102494: [Clang, Driver] Default to Darwin_libsystem_m veclib on iOS based targets.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: jroelofs, ab, scanon, arphaman.
fhahn requested review of this revision.
Herald added a project: clang.

Building on D102489 , default to 
Darwin_libsystem_m veclib on iOS based
targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102494

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-veclib-default.c


Index: clang/test/Driver/darwin-veclib-default.c
===
--- /dev/null
+++ clang/test/Driver/darwin-veclib-default.c
@@ -0,0 +1,24 @@
+// Check default vector library options on Darwin platforms.
+
+// RUN: %clang -target x86_64-apple-darwin -S -### %s -arch x86_64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-MACOS %s
+
+// CHECK-MACOS: "-cc1"
+// CHECK-MACOS-NOT: -fveclib
+
+// RUN: %clang -target arm64-apple-darwinos -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s
+
+// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s
+
+// CHECK-IOS-DEFAULT: "-cc1"
+// CHECK-IOS-DEFAULT: "-fveclib=Darwin_libsystem_m"
+
+// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 
-fveclib=Accelerate 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-ACCELERATE %s
+
+// CHECK-IOS-ACCELERATE: "-cc1"
+// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m"
+// CHECK-IOS-ACCELERATE: "-fveclib=Accelerate"
+// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2486,6 +2486,11 @@
   options::OPT_fvisibility_inlines_hidden_static_local_var,
   options::OPT_fno_visibility_inlines_hidden_static_local_var))
 CC1Args.push_back("-fvisibility-inlines-hidden-static-local-var");
+
+  // If no vector library is specified by the user, default to
+  // Darwin_libsystem_m for iOS based targets.
+  if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib))
+CC1Args.push_back("-fveclib=Darwin_libsystem_m");
 }
 
 DerivedArgList *


Index: clang/test/Driver/darwin-veclib-default.c
===
--- /dev/null
+++ clang/test/Driver/darwin-veclib-default.c
@@ -0,0 +1,24 @@
+// Check default vector library options on Darwin platforms.
+
+// RUN: %clang -target x86_64-apple-darwin -S -### %s -arch x86_64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-MACOS %s
+
+// CHECK-MACOS: "-cc1"
+// CHECK-MACOS-NOT: -fveclib
+
+// RUN: %clang -target arm64-apple-darwinos -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s
+
+// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s
+
+// CHECK-IOS-DEFAULT: "-cc1"
+// CHECK-IOS-DEFAULT: "-fveclib=Darwin_libsystem_m"
+
+// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 -fveclib=Accelerate 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-ACCELERATE %s
+
+// CHECK-IOS-ACCELERATE: "-cc1"
+// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m"
+// CHECK-IOS-ACCELERATE: "-fveclib=Accelerate"
+// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2486,6 +2486,11 @@
   options::OPT_fvisibility_inlines_hidden_static_local_var,
   options::OPT_fno_visibility_inlines_hidden_static_local_var))
 CC1Args.push_back("-fvisibility-inlines-hidden-static-local-var");
+
+  // If no vector library is specified by the user, default to
+  // Darwin_libsystem_m for iOS based targets.
+  if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib))
+CC1Args.push_back("-fveclib=Darwin_libsystem_m");
 }
 
 DerivedArgList *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101777: [clang] p1099 1/5: [NFC] Break out BaseUsingDecl from UsingDecl

2021-05-14 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan updated this revision to Diff 345426.
urnathan added a comment.

I stupidly tested that on the stack, not just the first diff.  This removes the 
reference to bits from a later patch


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

https://reviews.llvm.org/D101777

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6539,7 +6539,7 @@
   }
 
   case Decl::Using:
-return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
+return MakeCursorOverloadedDeclRef(cast(D), D->getLocation(),
TU);
 
   case Decl::UsingShadow:
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1852,7 +1852,7 @@
   Diag(KWLoc, diag::err_using_decl_conflict_reverse);
   Diag(Shadow->getTargetDecl()->getLocation(),
diag::note_using_decl_target);
-  Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
+  Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
   // Recover by ignoring the old declaration.
   PrevDecl = PrevClassTemplate = nullptr;
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3732,7 +3732,7 @@
   // A shadow declaration that's created by a resolved using declaration
   // is not hidden by the same using declaration.
   if (isa(ND) && isa(D) &&
-  cast(ND)->getUsingDecl() == D)
+  cast(ND)->getIntroducer() == D)
 continue;
 
   // We've found a declaration that hides this one.
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6984,7 +6984,7 @@
   : S(S), UseLoc(UseLoc) {
 bool DiagnosedMultipleConstructedBases = false;
 CXXRecordDecl *ConstructedBase = nullptr;
-UsingDecl *ConstructedBaseUsing = nullptr;
+BaseUsingDecl *ConstructedBaseIntroducer = nullptr;
 
 // Find the set of such base class subobjects and check that there's a
 // unique constructed subobject.
@@ -7008,18 +7008,18 @@
   //   of type B, the program is ill-formed.
   if (!ConstructedBase) {
 ConstructedBase = DConstructedBase;
-ConstructedBaseUsing = D->getUsingDecl();
+ConstructedBaseIntroducer = D->getIntroducer();
   } else if (ConstructedBase != DConstructedBase &&
  !Shadow->isInvalidDecl()) {
 if (!DiagnosedMultipleConstructedBases) {
   S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
   << Shadow->getTargetDecl();
-  S.Diag(ConstructedBaseUsing->getLocation(),
-   diag::note_ambiguous_inherited_constructor_using)
+  S.Diag(ConstructedBaseIntroducer->getLocation(),
+ diag::note_ambiguous_inherited_constructor_using)
   << ConstructedBase;
   DiagnosedMultipleConstructedBases = true;
 }
-S.Diag(D->getUsingDecl()->getLocation(),
+S.Diag(D->getIntroducer()->getLocation(),
diag::note_ambiguous_inherited_constructor_using)
 << DConstructedBase;
   }
@@ -11617,7 +11617,7 @@
 
 /// Determines whether to create a using shadow decl for a particular
 /// decl, given the set of decls existing prior to this using lookup.
-bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig,
+bool Sema::CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Orig,
 const LookupResult &Previous,
 UsingShadowDecl *&PrevShadow) {
   // Diagnose finding a decl which is not from a base class of the
@@ -11639,35 +11639,36 @@
   // specialization.  The UsingShadowDecl in D then points directly
   // to A::foo, which will look well-formed when we instantiate.
   // The right solution is to not collapse the shadow-decl chain.
-  if (!getLangOpts().CPlusPlus11 && CurContext->isRecord()) {
-DeclContext *OrigDC = Orig->getDeclContext();
-
-// Handle enums and anonymous structs.
-if (isa(OrigDC)) OrigDC = OrigDC->getParent();
-CXXRecordDecl *OrigRec = cast(OrigDC);
-while (OrigRe

[PATCH] D102495: [clang][deps] Support inferred modules

2021-05-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds support for inferred modules to the dependency scanner.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 
authored by @Bigcheese with libclang and other changes omitted.

Contains following changes:

1. [Clang][ScanDeps] Ignore __inferred_module.map dependency.
  - This shows up with inferred modules, but it doesn't exist on disk, so don't 
report it as a dependency.

2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred 
modules.

Also includes a smoke test that uses clang-scan-deps output to perform an 
explicit build. There's no intention to duplicate whatever `test/Modules` 
contains, just to verify the produced command-line does "work" (with very loose 
definition of work).

Split from D100934 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102495

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m
  clang/utils/module-deps-to-rsp.py

Index: clang/utils/module-deps-to-rsp.py
===
--- /dev/null
+++ clang/utils/module-deps-to-rsp.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+
+# Converts clang-scan-deps output into response files.
+#   * For modules, arguments in the resulting response file are enough to build a PCM.
+#   * For translation units, the response file needs to be added to the original Clang invocation from compilation
+# database.
+#
+# Usage:
+#
+#   clang-scan-deps -compilation-database compile_commands.json ... > deps.json
+#   module-deps-to-rsp.py deps.json --module-name=ModuleName > module_name.cc1.rsp
+#   module-deps-to-rsp.py deps.json --tu-index=0 > tu.rsp
+#   clang @module_name.cc1.rsp
+#   clang ... @tu.rsp
+
+import argparse
+import json
+import sys
+
+class ModuleNotFoundError(Exception):
+  def __init__(self, module_name):
+self.module_name = module_name
+
+class FullDeps:
+  def __init__(self):
+self.modules = dict()
+self.translation_units = str()
+
+def getModulePathArgs(modules, full_deps):
+  cmd = []
+  for md in modules:
+m = full_deps.modules[md['module-name'] + '-' + md['context-hash']]
+cmd += [u'-fmodule-map-file=' + m['clang-modulemap-file']]
+cmd += [u'-fmodule-file=' + md['module-name'] + '-' + md['context-hash'] + '.pcm']
+  return cmd
+
+def getCommandLineForModule(module_name, full_deps):
+  for m in full_deps.modules.values():
+if m['name'] == module_name:
+  module = m
+  break
+  else:
+raise ModuleNotFoundError(module_name)
+
+  cmd = m['command-line']
+  cmd += getModulePathArgs(m['clang-module-deps'], full_deps)
+  cmd += [u'-o', m['name'] + '-' + m['context-hash'] + '.pcm']
+  cmd += [m['clang-modulemap-file']]
+  
+  return cmd
+  
+def getCommandLineForTU(tu, full_deps):
+  cmd = tu['command-line']
+  cmd += getModulePathArgs(tu['clang-module-deps'], full_deps)
+  return cmd
+
+def parseFullDeps(json):
+  ret = FullDeps()
+  for m in json['modules']:
+ret.modules[m['name'] + '-' + m['context-hash']] = m
+  ret.translation_units = json['translation-units']
+  return ret
+
+def main():
+  parser = argparse.ArgumentParser()
+  parser.add_argument("full_deps_file", help="Path to the full dependencies json file",
+  type=str)
+  action = parser.add_mutually_exclusive_group(required=True)
+  action.add_argument("--module-name", help="The name of the module to get arguments for",
+  type=str)
+  action.add_argument("--tu-index", help="The index of the translation unit to get arguments for",
+  type=int)
+  args = parser.parse_args()
+  
+  full_deps = parseFullDeps(json.load(open(args.full_deps_file, 'r')))
+  
+  try:
+if args.module_name:
+  print(" ".join(getCommandLineForModule(args.module_name, full_deps)))
+
+elif args.tu_index != None:
+  print(" ".join(getCommandLineForTU(full_deps.translation_units[args.tu_index], full_deps)))
+  except:
+print("Unexpected error:", sys.exc_info()[0])
+raise
+
+if __name__ == '__main__':
+  main()
Index: clang/test/ClangScanDeps/modules-inferred.m
=

[PATCH] D102397: [AArch64] Lower bitreverse in ISel

2021-05-14 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:556
 }
+if (Name.startswith("aarch64.neon.rbit")) {
+  NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::bitreverse,

Do we have a test for the autoupgrade, to show that @llvm.aarch64.neon.rbit 
turns into @llvm.bitreverse?



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:381
   setOperationAction(ISD::BITREVERSE, MVT::i64, Legal);
+  setOperationAction(ISD::BITREVERSE, MVT::v8i8, Legal);
+  setOperationAction(ISD::BITREVERSE, MVT::v16i8, Legal);

Can we move this to the other "hasNeon" section?



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:1019
 setOperationAction(ISD::CTLZ,   MVT::v1i64, Expand);
 setOperationAction(ISD::CTLZ,   MVT::v2i64, Expand);
 

Perhaps here. This looks quite neon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102397

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


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-14 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 345432.
flip1995 added a comment.

- [MC] Don't check if constructed MOFI is a nullptr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.h
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,10 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &srcMgr, &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), STI.get(), &SrcMgr,
+&MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -41,7 +41,7 @@
 MCTargetOptions MCOptions;
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 Ctx = std::make_unique(Triple(TripleName), MAI.get(), MRI.get(),
-  /*MOFI=*/nullptr, /*MSTI=*/nullptr);
+  /*MSTI=*/nullptr);
   }
 
   operator bool() { return Ctx.get(); }
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -464,9 +464,10 @@
 return make_error("no target machine for target " + TripleName,
  

[PATCH] D100733: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

2021-05-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a subscriber: aaron.ballman.
aaronpuchert added a comment.

@aaron.ballman, what do you think about this? We can't really prevent anyone 
from writing `.getValueKind() == VK_*Value` instead of `.is*Value()`, so this 
change will make things consistent only for now.

In D100733#2697540 , @mizvekov wrote:

> In D100733#2697537 , @aaronpuchert 
> wrote:
>
>> The change seems to be correct, but I'm wondering if `x.getValueKind() == 
>> VK_*Value` doesn't have one advantage over `x.is*Value()`: it's obvious that 
>> this is exclusive with the other values. Especially with `isRValue()` it 
>> might not be so obvious, because Clang doesn't follow the C++11 terminology 
>> with this.
>>
>> But it's admittedly shorter, so I'd be willing to approve this.
>
> This came up in a patch where I am experimenting with a new value category.

Not sure how to feel about this, the value categories are already hard to grasp 
for most C++ programmers. To solve the implicit move concerns with a new value 
category seems like cracking a nut with a sledgehammer. But that's not directly 
related to this change, we can discuss this when the change is there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100733

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


[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:12577-12578
   Stmt *Body = nullptr;
-  SmallVector OriginalInits;
+  SmallVector>, 4> 
OriginalInits;
+  OriginalInits.emplace_back();
   if (!OMPLoopBasedDirective::doForAllLoops(

`SmallVector>> OriginalEmits(1);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

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


[PATCH] D99459: [OpenMP] Implement '#pragma omp unroll'.

2021-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Some previous comments were not addressed yet




Comment at: clang/include/clang/AST/OpenMPClause.h:972-974
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

Make it private



Comment at: clang/lib/AST/StmtOpenMP.cpp:141
+  } else
+break;
+

Enclose in braces



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2600-2604
+  RValue FactorRVal = EmitAnyExpr(FactorExpr, AggValueSlot::ignored(),
+  /*ignoreResult=*/true);
+  Factor =
+  cast(FactorRVal.getScalarVal())->getZExtValue();
+  assert(Factor >= 1 && "Only positive factors are valid");

I suppose it is compiled-time expression, right? If so, use 
`FactorExpr->EvaluateKnownConstInt()` or something similar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99459

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


[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:405
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(

Can you add an IRGen testcase that verifies that TLII is setting the vecLib 
correctly here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102489

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


[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 345435.
AbbasSabra marked 4 inline comments as done.
AbbasSabra added a comment.

Updating D102273 : [analyzer] Apply code 
review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp

Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 -analyzer-config exploration_strategy=unexplored_first_queue %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++11 -DDFS=1 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++14 -analyzer-config exploration_strategy=unexplored_first_queue %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++14 -DDFS=1 %s
 
 void clang_analyzer_numTimesReached();
 void clang_analyzer_warnIfReached();
@@ -511,3 +511,39 @@
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
+
+void capture_by_value_as_loop_counter() {
+  int out = 0;
+  auto l = [i = out]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_by_ref_as_loop_counter() {
+  int out = 0;
+  auto l = [&i = out]() {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
+
+void capture_implicitly_by_value_as_loop_counter() {
+  int i = 0;
+  auto l = [=]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_implicitly_by_ref_as_loop_counter() {
+  int i = 0;
+  auto l = [&]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -79,14 +79,17 @@
   return State;
 }
 
-static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
-  hasOperatorName("<="), hasOperatorName(">="),
-  hasOperatorName("!=")),
-hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
+static internal::Matcher simpleCondition(StringRef BindName,
+   StringRef RefName) {
+  return binaryOperator(
+ anyOf(hasOperatorName("<"), hasOperatorName(">"),
+   hasOperatorName("<="), hasOperatorName(">="),
+   hasOperatorName("!=")),
+ hasEitherOperand(ignoringParenImpCasts(
+ declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+ .bind(RefName))),
+ hasEitherOperand(
+ ignoringParenImpCasts(integerLiteral().bind("boundNum"
   .bind("conditionOperator");
 }
 
@@ -138,7 +141,7 @@
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
+ hasCondition(simpleCondition("initVarName", "initVarRef")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
@@ -156,17 +159,53 @@
  hasUnaryOperand(declRefExpr(
  to(varDecl(allOf(equalsBoundNode("initVarName"),
   hasType(isInteger(),
- unless(hasBody(hasSuspiciousStmt("initVarName".bind("forLoop");
+ unless(hasBody(hasSuspiciousStmt("initVarName"
+  .bind("forLoop");
 }
 
-static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
+static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
+  assert(DR->refersToEnclosingVariableOrCapture());
+
+  const LocationContext *LocCtxt = N->getLocationContext();
+  const Decl *D = LocCtxt->getDecl();
+  c

[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:185-186
+  return FD->getType()->isReferenceType();
+} else {
+  assert(false && "Unknown captured variable");
+}

vsavchenko wrote:
> But actually, it's a bit different with this one. I don't know exact details 
> and rules how clang sema fills in the class for lambda.
> According to [[ https://en.cppreference.com/w/cpp/language/lambda | 
> cppreference ]]:
> > For the entities that are captured by reference (with the default capture 
> > [&] or when using the character &, e.g. [&a, &b, &c]), it is unspecified if 
> > additional data members are declared in the closure type
> 
> It can be pretty much specified in clang, that's true, but it looks like in 
> `DeadStoreChecker` we have a very similar situation and we do not assume that 
> captured variable always have a corresponding field.
Yes, I based this on the fact that DeadStoreChecker considers it possible, but 
I have never faced a case where it does not have a corresponding field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

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


[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:405
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(

arphaman wrote:
> Can you add an IRGen testcase that verifies that TLII is setting the vecLib 
> correctly here?
Like a test that generates IR using a vector function from Darwin's libsystem m?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102489

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


[PATCH] D102494: [Clang, Driver] Default to Darwin_libsystem_m veclib on iOS based targets.

2021-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2492
+  // Darwin_libsystem_m for iOS based targets.
+  if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib))
+CC1Args.push_back("-fveclib=Darwin_libsystem_m");

Is this applicable to the watchOS targets as well? The iOS based check doesn't 
cover it.



Comment at: clang/test/Driver/darwin-veclib-default.c:9
+
+// RUN: %clang -target arm64-apple-darwinos -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s

`darwinos` isn't a valid OS type, what's your intent with this testcase here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102494

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


[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:405
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(

fhahn wrote:
> arphaman wrote:
> > Can you add an IRGen testcase that verifies that TLII is setting the vecLib 
> > correctly here?
> Like a test that generates IR using a vector function from Darwin's libsystem 
> m?
Sure, I think that should cover this switch case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102489

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


[PATCH] D100713: [clang] NFC: refactor usage of getDecltypeForParenthesizedExpr

2021-05-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Again, I'm not sure if it helps to use `getDecltypeForParenthesizedExpr` where 
we don't actually have the `decltype` of a parenthesized expression.

It's probably not entirely coincidental, but things aren't defined this way.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+  if (!To->isRValue()) {
+QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);

mizvekov wrote:
> aaronpuchert wrote:
> > The quote doesn't reference parenthesized expressions, isn't this just 
> > coincidentally the same thing?
> It's fundamentally the same thing. The `getDecltypeForParenthesizedExpr` name 
> is what I tried to keep, I don't have better ideas there.
What this is doing is pointwise equal to `getDecltypeForParenthesizedExpr`, but 
there is no parenthesized expression, and no `decltype`. There is a quote from 
the standard that defines this separately (by now this seems to be 
[[http://eel.is/c++draft/expr.cond#4|expr.cond#4]]), and there are some 
differences especially in the prvalue case. So I'm not sure this helps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713

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


[clang-tools-extra] ed33911 - [clangd] Always default to raw pch format

2021-05-14 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-05-14T16:34:57+02:00
New Revision: ed339111bff690c6ba87d5e25c50bcad6793a309

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

LOG: [clangd] Always default to raw pch format

Clang would emit a fatal error when it encounters an unregistered PCH
format. This change ensures clangd will always use raw format no matter what
user specifies.

As side effects:

- serializing an AST in an unknown format might throw off build
systems. I suppose this would only be an issue when build system and clangd are
racing for same PCM modules, hopefully this should be rare and both clangd or
the build system should recover on the next run.

- whenever clang reads a serialized AST it seems to be checking for file
signature and emitting non-fatal errors. so this should be fine again.

The only other valid module format in clang is `obj` but it is part of codegen,
i don't think it is worth the dependency. Hence chosing to not register it, at
least yet.

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

Added: 


Modified: 
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/unittests/ModulesTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index 0a1e43d808643..a7e48934ddaf2 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -85,6 +85,11 @@ buildCompilerInvocation(const ParseInputs &Inputs, 
clang::DiagnosticConsumer &D,
   // Don't crash on `#pragma clang __debug parser_crash`
   CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
 
+  // Always default to raw container format as clangd doesn't registry any 
other
+  // and clang dies when faced with unknown formats.
+  CI->getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
   return CI;
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/ModulesTests.cpp 
b/clang-tools-extra/clangd/unittests/ModulesTests.cpp
index b56b91836508f..0fdc22c954336 100644
--- a/clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -92,6 +92,24 @@ TEST(Modules, Diagnostic) {
   TU.build();
 }
 
+// Unknown module formats are a fatal failure for clang. Ensure we don't crash.
+TEST(Modules, UnknownFormat) {
+  TestTU TU = TestTU::withCode(R"(#include "modular.h")");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodule-format=obj");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.AdditionalFiles["modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+})modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D102418: [clangd] Always default to raw pch format

2021-05-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed339111bff6: [clangd] Always default to raw pch format 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102418

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/ModulesTests.cpp


Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -92,6 +92,24 @@
   TU.build();
 }
 
+// Unknown module formats are a fatal failure for clang. Ensure we don't crash.
+TEST(Modules, UnknownFormat) {
+  TestTU TU = TestTU::withCode(R"(#include "modular.h")");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodule-format=obj");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.AdditionalFiles["modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+})modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,6 +85,11 @@
   // Don't crash on `#pragma clang __debug parser_crash`
   CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
 
+  // Always default to raw container format as clangd doesn't registry any 
other
+  // and clang dies when faced with unknown formats.
+  CI->getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
   return CI;
 }
 


Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -92,6 +92,24 @@
   TU.build();
 }
 
+// Unknown module formats are a fatal failure for clang. Ensure we don't crash.
+TEST(Modules, UnknownFormat) {
+  TestTU TU = TestTU::withCode(R"(#include "modular.h")");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodule-format=obj");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.AdditionalFiles["modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+})modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,6 +85,11 @@
   // Don't crash on `#pragma clang __debug parser_crash`
   CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
 
+  // Always default to raw container format as clangd doesn't registry any other
+  // and clang dies when faced with unknown formats.
+  CI->getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
   return CI;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102248: [C++4OpenCL] Fix initialization of __constant constructors without arguments

2021-05-14 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 345436.
olestrohm added a comment.

Added a codegen test and clarified what some parts are testing.


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

https://reviews.llvm.org/D102248

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+__constant int g1; // expected-error {{variable in constant address space must be initialized}}
+__constant int g2 = 0;
+
+struct X {
+  int x;
+  constexpr X() __constant : x(0) {}
+  constexpr X(int x) __constant : x(x) {}
+};
+
+//expected-note@+2{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const __generic Y' for 1st argument}}
+//expected-note@+1{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to '__generic Y' for 1st argument}}
+struct Y {
+  int y;
+  Y() __generic = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+};
+
+kernel void k() {
+  __constant X cx1;
+  __constant X cx2(1);
+  __local X lx;
+
+  __private Y py;
+  __constant Y cy1; // expected-error{{variable in constant address space must be initialized}}
+  __constant Y cy2(1); // expected-error{{no matching constructor for initialization of '__constant Y'}}
+}
+
+struct Z {
+  int z;
+  // The address space is deduced to be __generic if omitted
+  Z() = default; // expected-note{{previous definition is here}}
+  Z() __generic = default; // expected-error {{constructor cannot be redeclared}}
+
+  Z() __private = default;
+  Z() __local = default;
+  Z() __global = default;
+  // Can't default constexpr constructors
+  constexpr Z() __constant : z(0) {}
+};
+
+struct W {
+  int w;
+  constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+};
Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+
+// CHECK: %struct.X = type { i32 }
+
+// CHECK: @ci = dso_local addrspace(2) constant i32 0, align 4
+// CHECK: @gi = dso_local addrspace(1) global i32 0, align 4
+__constant int ci = 0;
+__global int gi = 0;
+
+struct X {
+  int x;
+
+  // Local variables are handled in local_addrspace_init.clcpp
+  // FIXME: __private and __generic constructors clash for __private variable
+  // X() /*__generic*/ = default;
+  X() __private : x(0) {}
+  X() __global : x(0) {}
+  constexpr X() __constant : x(0) {}
+  constexpr X(int x) __constant : x(x) {}
+};
+
+// CHECK: @cx1 = dso_local addrspace(2) constant %struct.X zeroinitializer, align 4
+// CHECK: @cx2 = dso_local addrspace(2) constant %struct.X { i32 1 }, align 4
+// CHECK: @gx = dso_local addrspace(1) global %struct.X zeroinitializer, align 4
+__constant X cx1;
+__constant X cx2(1);
+__global X gx;
+
+// CHECK: @_ZZ1kE3cx1 = internal addrspace(2) constant %struct.X zeroinitializer, align 4
+// CHECK: @_ZZ1kE3cx2 = internal addrspace(2) constant %struct.X { i32 1 }, align 4
+kernel void k() {
+  // Check that the constructor for px is executed
+  __private X px;
+  // CHECK: [[PX:%[.a-z0-9]+]] = alloca %struct.X, align 4
+  // CHECK-NEXT: call spir_func void @_ZN1XC1Ev(%struct.X* nonnull dereferenceable(4) [[PX]]) #3
+
+  __constant X cx1;
+  __constant X cx2(1);
+  // CHECK-NEXT: ret void
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12638,9 +12638,21 @@
 if (!Var->isInvalidDecl() &&
 Var->getType().getAddressSpace() == LangAS::opencl_constant &&
 Var->getStorageClass() != SC_Extern && !Var->getInit()) {
-  Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
-  Var->setInvalidDecl();
-  return;
+  bool HasConstExprDefaultConstructor = false;
+  if (CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
+for (auto *Ctor : RD->ctors()) {
+  if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
+  Ctor->getMethodQualifiers().getAddressSpace() ==
+  LangAS::opencl_constant) {
+HasConstExprDefaultConstructor = true;
+  }
+}
+  }
+  if (!HasConstExprDefaultConstructor) {
+Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
+Var->setInvalidDecl();
+return;
+  }
 }
 
 if (

[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-05-14 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:306
+// Set conditionally to provide correct diagnostics for 'double' type
+llvm::StringRef FP64Feature(
+getLangOpts().OpenCLVersion >= 300 ? "__opencl_c_fp64" : 
"cl_khr_fp64");

Anastasia wrote:
> Technically both "__opencl_c_fp64" and "cl_khr_fp64" are required in OpenCL, 
> perhaps we should report both in OpenCL 3?
Even better, can we merge this first https://reviews.llvm.org/D100976? This is 
needed to completely remove such check for fp64.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

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


[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for addressing my comments! I still have some left though




Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:171
+  const Decl *D = LocCtxt->getDecl();
+  const auto *MD = dyn_cast_or_null(D);
+  assert(MD && MD->getParent()->isLambda() &&

`dyn_cast_or_null` also tells the reader that `D` can be null and can be not 
`CXXMethodDecl`.  So it's better to use `cast` here if you are sure about `D` 
and have assertions about it.



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:175-178
+  const CXXRecordDecl *CXXRec = MD->getParent();
+  llvm::DenseMap LambdaCaptureFields;
+  FieldDecl *LambdaThisCaptureField;
+  CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);

Body of this function seems to be too dense.  It is usually hard to read 
something that doesn't have rest places for eyes.  You can think of it as 
paragraphs in the written text.
In this particular situation, you can split all these statements and 
declarations in groups of 3-4.  It would be perfect if they are grouped 
semantically (like good paragraphs).



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:179
+  CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
+  const VarDecl *VD = dyn_cast(DR->getDecl()->getCanonicalDecl());
+  assert(VD);

We can just do `cast` here



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:185-186
+return FD->getType()->isReferenceType();
+  } else {
+assert(false && "Unknown captured variable");
+  }

I still think that we should do something about this `else`



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:192-193
+
+// A loop counter is considered escaped if:
+// - It is a global variable.
+// - It is an entry value: a reference parameter or a reference capture.

I think it's a great idea to list all the cases.  I think we can go even 
further: enumerate them and actually pinpoint in the implementation where we 
cover which case.  With numbers it can be much easier.



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:194
+// - It is a global variable.
+// - It is an entry value: a reference parameter or a reference capture.
+// - It is assigned to a non-const reference variable or parameter.

Can we not introduce new terms and simply call it a **reference**?



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:197
+// - Has its address taken.
+static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N,
+  const DeclRefExpr *DR) {

This should be also modified then


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

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


[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:185-186
+  return FD->getType()->isReferenceType();
+} else {
+  assert(false && "Unknown captured variable");
+}

AbbasSabra wrote:
> vsavchenko wrote:
> > But actually, it's a bit different with this one. I don't know exact 
> > details and rules how clang sema fills in the class for lambda.
> > According to [[ https://en.cppreference.com/w/cpp/language/lambda | 
> > cppreference ]]:
> > > For the entities that are captured by reference (with the default capture 
> > > [&] or when using the character &, e.g. [&a, &b, &c]), it is unspecified 
> > > if additional data members are declared in the closure type
> > 
> > It can be pretty much specified in clang, that's true, but it looks like in 
> > `DeadStoreChecker` we have a very similar situation and we do not assume 
> > that captured variable always have a corresponding field.
> Yes, I based this on the fact that DeadStoreChecker considers it possible, 
> but I have never faced a case where it does not have a corresponding field.
It still would be good to have some proof that it is indeed like this or simply 
fallback into returning true (which you already do when in doubt).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

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


[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors

2021-05-14 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 345442.
olestrohm added a comment.

Fixed the code style and added some comments to the tests.


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

https://reviews.llvm.org/D101519

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
  clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp

Index: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+
+kernel void foo() {
+  // Testing conversions between vectors and vectors/scalars
+  long l1;
+  auto l_to_i2 = reinterpret_cast(l1);
+  int2 i2;
+  auto i2_to_l = reinterpret_cast(i2);
+  auto i2_to_i = reinterpret_cast(i2); // expected-error{{reinterpret_cast from vector 'int2' (vector of 2 'int' values) to scalar 'int' of different size}}
+  auto i2_to_i2 = reinterpret_cast(i2);
+
+  // Only integral types (and pointer/references) can be reinterpret casted to themselves.
+  // Currently this does not include any opencl types.
+  reserve_id_t r_id1;
+  auto r_id2 = reinterpret_cast(r_id1); // expected-error{{reinterpret_cast from 'reserve_id_t' to 'reserve_id_t' is not allowed}}
+}
Index: clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
@@ -0,0 +1,17 @@
+//RUN: %clang_cc1 %s -triple spir -emit-llvm -O0 -o - | FileCheck %s
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+typedef long long2 __attribute__((ext_vector_type(2)));
+
+//CHECK-LABEL: define{{.*}} spir_func void @_Z3barPU3AS1Dv2_i
+void bar(global int2 *in) {
+  //CHECK: bitcast <2 x i32> %{{[0-9]+}} to i64
+  auto l = reinterpret_cast(in[0]);
+  //CHECK: bitcast i64 %{{[0-9]+}} to <2 x i32>
+  auto i2 = reinterpret_cast(l);
+
+  int4 i4;
+  //CHECK: bitcast <4 x i32> %{{[0-9]+}} to <2 x i64>
+  auto l2 = reinterpret_cast(i4);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7344,6 +7344,25 @@
  matSrcType->getNumColumns() == matDestType->getNumColumns();
 }
 
+bool Sema::areVectorTypesSameSize(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());
+
+  uint64_t SrcLen, DestLen;
+  QualType SrcEltTy, DestEltTy;
+  if (!breakDownVectorType(SrcTy, SrcLen, SrcEltTy))
+return false;
+  if (!breakDownVectorType(DestTy, DestLen, DestEltTy))
+return false;
+
+  // ASTContext::getTypeSize will return the size rounded up to a
+  // power of 2, so instead of using that, we need to use the raw
+  // element size multiplied by the element count.
+  uint64_t SrcEltSize = Context.getTypeSize(SrcEltTy);
+  uint64_t DestEltSize = Context.getTypeSize(DestEltTy);
+
+  return (SrcLen * SrcEltSize == DestLen * DestEltSize);
+}
+
 /// Are the two types lax-compatible vector types?  That is, given
 /// that one of them is a vector, do they have equal storage sizes,
 /// where the storage size is the number of elements times the element
@@ -7362,18 +7381,7 @@
   if (srcTy->isScalarType() && destTy->isExtVectorType()) return false;
   if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
 
-  uint64_t srcLen, destLen;
-  QualType srcEltTy, destEltTy;
-  if (!breakDownVectorType(srcTy, srcLen, srcEltTy)) return false;
-  if (!breakDownVectorType(destTy, destLen, destEltTy)) return false;
-
-  // ASTContext::getTypeSize will return the size rounded up to a
-  // power of 2, so instead of using that, we need to use the raw
-  // element size multiplied by the element count.
-  uint64_t srcEltSize = Context.getTypeSize(srcEltTy);
-  uint64_t destEltSize = Context.getTypeSize(destEltTy);
-
-  return (srcLen * srcEltSize == destLen * destEltSize);
+  return areVectorTypesSameSize(srcTy, destTy);
 }
 
 /// Is this a legal conversion between two types, one of which is
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2328,6 +2328,16 @@
   return TC_Success;
 }
 
+if (Self.LangOpts.OpenCL && !CStyle) {
+  if (DestType->isExtVectorType() || SrcType->isExtVectorType()) {
+// FIXME: Allow for reinterpret cast between 3 and 4 element vectors
+if (Self.areVectorTypesSameSize(SrcType, DestType)) {
+  Kind = CK_BitCast;
+  return TC_Success;
+}
+  }
+}
+

[PATCH] D102248: [C++4OpenCL] Fix initialization of __constant constructors without arguments

2021-05-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!




Comment at: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp:22
+
+// CHECK: @cx1 = dso_local addrspace(2) constant %struct.X zeroinitializer, 
align 4
+// CHECK: @cx2 = dso_local addrspace(2) constant %struct.X { i32 1 }, align 4

FYI, I would remove `, align 4` to simplify testing.


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

https://reviews.llvm.org/D102248

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


[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors

2021-05-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!

Just remember to reflect your final change in the commit message description. :)


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

https://reviews.llvm.org/D101519

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


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Danila Kutenin via Phabricator via cfe-commits
danlark created this revision.
danlark added a reviewer: rsmith.
danlark requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix ternary operator in for loop argument, it was by mistake not set as 
CanBeForRangeDecl and led to incorrect codegen. It fixes 
https://bugs.llvm.org/show_bug.cgi?id=50038. I don't have commit rights. Danila 
Kutenin. kutdan...@yandex.ru


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102502

Files:
  clang/lib/Parse/ParseTentative.cpp
  clang/test/Parser/cxx2a-init-statement.cpp


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 345449.
fhahn added a comment.

Add end-to-end test, as suggested. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102489

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/veclib-darwin-libsystem-m.c
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fveclib.c

Index: clang/test/Driver/fveclib.c
===
--- clang/test/Driver/fveclib.c
+++ clang/test/Driver/fveclib.c
@@ -2,12 +2,14 @@
 // RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix CHECK-ACCELERATE %s
 // RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix CHECK-libmvec %s
 // RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix CHECK-MASSV %s
+// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck -check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
 // RUN: not %clang -c -fveclib=something %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s
 
 // CHECK-NOLIB: "-fveclib=none"
 // CHECK-ACCELERATE: "-fveclib=Accelerate"
 // CHECK-libmvec: "-fveclib=libmvec"
 // CHECK-MASSV: "-fveclib=MASSV"
+// CHECK-DARWIN_LIBSYSTEM_M: "-fveclib=Darwin_libsystem_m"
 
 // CHECK-INVALID: error: invalid value 'something' in '-fveclib=something'
 
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -76,6 +76,7 @@
 // FLTOALL-NEXT: thin
 // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL
 // FVECLIBALL: Accelerate
+// FVECLIBALL-NEXT: Darwin_libsystem_m
 // FVECLIBALL-NEXT: libmvec
 // FVECLIBALL-NEXT: MASSV
 // FVECLIBALL-NEXT: none
Index: clang/test/CodeGen/veclib-darwin-libsystem-m.c
===
--- /dev/null
+++ clang/test/CodeGen/veclib-darwin-libsystem-m.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fveclib=Darwin_libsystem_m -triple arm64-apple-darwin %s -target-cpu apple-a7 -vectorize-loops -emit-llvm -O3 -o - | FileCheck %s
+
+// Make sure -fveclib=Darwin_libsystem_m gets passed through to LLVM as
+// expected: a call to _simd_sin_f4 should be generated.
+
+extern float sinf(float);
+
+// CHECK-LABEL: define{{.*}}@apply_sin
+// CHECK: call <4 x float> @_simd_sin_f4(
+//
+void apply_sin(float *A, float *B, float *C, unsigned N) {
+  for (unsigned i = 0; i < N; i++)
+C[i] = sinf(A[i]) + sinf(B[i]);
+}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -402,6 +402,10 @@
   case CodeGenOptions::SVML:
 TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML);
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(
+TargetLibraryInfoImpl::DarwinLibSystemM);
+break;
   default:
 break;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2163,9 +2163,10 @@
   Alias;
 def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>,
 HelpText<"Use the given vector functions library">,
-Values<"Accelerate,libmvec,MASSV,SVML,none">,
+Values<"Accelerate,libmvec,MASSV,SVML,Darwin_libsystem_m,none">,
 NormalizedValuesScope<"CodeGenOptions">,
-NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "NoLibrary"]>,
+NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML",
+  "Darwin_libsystem_m", "NoLibrary"]>,
 MarshallingInfoEnum, "NoLibrary">;
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group,
   Alias, AliasArgs<["none"]>;
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -55,11 +55,12 @@
   };
 
   enum VectorLibrary {
-NoLibrary,  // Don't use any vector library.
-Accelerate, // Use the Accelerate framework.
-LIBMVEC,// GLIBC vector math library.
-MASSV,  // IBM MASS vector library.
-SVML// Intel short vector math library.
+NoLibrary, // Don't use any vector library.
+Accelerate,// Use the Accelerate framework.
+LIBMVEC,   // GLIBC vector math library.
+MASSV, // IBM MASS vector library.
+SVML,  // Intel short vector math library.
+Darwin_libsystem_m // Use Darwin's libsytem_m vector functions.
   };
 
   enum ObjCDispatchMethodKind {
___
cfe-commit

[PATCH] D102494: [Clang, Driver] Default to Darwin_libsystem_m veclib on iOS based targets.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2492
+  // Darwin_libsystem_m for iOS based targets.
+  if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib))
+CC1Args.push_back("-fveclib=Darwin_libsystem_m");

arphaman wrote:
> Is this applicable to the watchOS targets as well? The iOS based check 
> doesn't cover it.
`libsystem_m`'s vector functions should be available on all Darwin platforms I 
think. I'd gradually opt-in additional platforms, once we verified it is 
clearly beneficial for each platform individually.

Should I add a TODO?



Comment at: clang/test/Driver/darwin-veclib-default.c:9
+
+// RUN: %clang -target arm64-apple-darwinos -S -### %s -arch arm64 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-IOS-DEFAULT %s

arphaman wrote:
> `darwinos` isn't a valid OS type, what's your intent with this testcase here?
Ah OK! Would it make sense to check `-darwin`? Or just `-iOS`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102494

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


[PATCH] D102489: [Clang,Driver] Add -fveclib=Darwin_libsystem_m support.

2021-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:405
 break;
+  case CodeGenOptions::Darwin_libsystem_m:
+TLII->addVectorizableFunctionsFromVecLib(

arphaman wrote:
> fhahn wrote:
> > arphaman wrote:
> > > Can you add an IRGen testcase that verifies that TLII is setting the 
> > > vecLib correctly here?
> > Like a test that generates IR using a vector function from Darwin's 
> > libsystem m?
> Sure, I think that should cover this switch case.
I added `clang/test/CodeGen/veclib-darwin-libsystem-m.c` which should contain 
an end-to-end test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102489

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


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This should have codegen, and maybe AST, tests.




Comment at: clang/test/Parser/cxx2a-init-statement.cpp:18
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+

This isn't cxx2a-specific isn't it?
Isn't this valid even in C99?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

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


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Danila Kutenin via Phabricator via cfe-commits
danlark added a comment.

In D102502#2759776 , @lebedev.ri 
wrote:

> This should have codegen, and maybe AST, tests.

Will add shortly




Comment at: clang/test/Parser/cxx2a-init-statement.cpp:18
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+

lebedev.ri wrote:
> This isn't cxx2a-specific isn't it?
> Isn't this valid even in C99?
clang even in C++11 versions go to this branch and produce warning that this 
feature is c++2a, so it fails currently for everything but the culprit was 
https://github.com/llvm/llvm-project/commit/8baa50013c86c34a58d8327c5d1a043898b86398


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Hi @hubert.reinterpretcast,

Would you mind testing this patch:

  diff
  diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
  index 8de38c0afcd9..79acb5bd6898 100644
  --- a/clang/lib/Interpreter/Interpreter.cpp
  +++ b/clang/lib/Interpreter/Interpreter.cpp
  @@ -157,7 +157,7 @@ IncrementalCompilerBuilder::create(std::vector &ClangArgv) {
 ParseDiagnosticArgs(*DiagOpts, ParsedArgs, &Diags);
   
 driver::Driver Driver(/*MainBinaryName=*/ClangArgv[0],
  -llvm::sys::getDefaultTargetTriple(), Diags);
  +llvm::sys::getProcessTriple(), Diags);
 Driver.setCheckInputsExist(false); // the input comes from mem buffers
 llvm::ArrayRef RF = llvm::makeArrayRef(ClangArgv);
 std::unique_ptr 
Compilation(Driver.BuildCompilation(RF));
  diff --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
  index a9beed5714d0..81ab57e955cf 100644
  --- a/clang/test/Interpreter/execute.cpp
  +++ b/clang/test/Interpreter/execute.cpp
  @@ -1,6 +1,5 @@
   // RUN: cat %s | clang-repl | FileCheck %s
   // REQUIRES: host-supports-jit
  -// UNSUPPORTED: powerpc64
   
   extern "C" int printf(const char *, ...);
   int i = 42;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D102339: [clang] On Windows, ignore case and separators when discarding duplicate dependency file paths.

2021-05-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

Ideally we should avoid the ifdef, but we don't have a good proxy for case 
sensitivity of the filesystem here.


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

https://reviews.llvm.org/D102339

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


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Danila Kutenin via Phabricator via cfe-commits
danlark updated this revision to Diff 345458.
danlark added a comment.

- Add codegen test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

Files:
  clang/lib/Parse/ParseTentative.cpp
  clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
  clang/test/Parser/cxx2a-init-statement.cpp


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: define{{.*}} i32 @_Z1fv()
+int f() {
+  // CHECK: ret i32 1
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define{{.*}} i32 @_Z1fv()
+int f() {
+  // CHECK: ret i32 1
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102125: [Matrix] Implement static cast for matrix types

2021-05-14 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

I am planning to commit this on Sunday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102125

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


[PATCH] D102507: [HIP] Support in device code

2021-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a subscriber: mgorny.
yaxunl requested review of this revision.

This patch adds wrapper headers for ``
and a few others which is required to support
``.

The basic idea is to make template functions
defined in these headers host device by pragmas.

Since this only works for libc++. The code is conditioned
for libc++ only. For libstdc++ it is NFC.


https://reviews.llvm.org/D102507

Files:
  clang/docs/HIPSupport.rst
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/lib/Headers/cuda_wrappers/__tuple
  clang/lib/Headers/cuda_wrappers/array
  clang/lib/Headers/cuda_wrappers/functional
  clang/lib/Headers/cuda_wrappers/tuple
  clang/lib/Headers/cuda_wrappers/type_traits
  clang/lib/Headers/cuda_wrappers/utility

Index: clang/lib/Headers/cuda_wrappers/utility
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/utility
@@ -0,0 +1,24 @@
+/*=== utility - CUDA/HIP wrapper for  -===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_WRAPPERS_UTILITY
+#define __CLANG_CUDA_WRAPPERS_UTILITY
+
+#if __HIP_USE_LIBCPP
+#pragma push_macro("_LIBCPP_NO_EXCEPTIONS")
+#define _LIBCPP_NO_EXCEPTIONS
+#pragma clang force_cuda_host_device begin
+#include_next 
+#pragma clang force_cuda_host_device end
+#pragma pop_macro("_LIBCPP_NO_EXCEPTIONS")
+#else
+#include_next 
+#endif // __HIP_USE_LIBCPP
+
+#endif // __CLANG_CUDA_WRAPPERS_UTILITY
Index: clang/lib/Headers/cuda_wrappers/type_traits
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/type_traits
@@ -0,0 +1,24 @@
+/*=== type_traits - CUDA/HIP wrapper for  -===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_WRAPPERS_TYPE_TRAITS
+#define __CLANG_CUDA_WRAPPERS_TYPE_TRAITS
+
+#if __HIP_USE_LIBCPP
+#pragma push_macro("_LIBCPP_NO_EXCEPTIONS")
+#define _LIBCPP_NO_EXCEPTIONS
+#pragma clang force_cuda_host_device begin
+#include_next 
+#pragma clang force_cuda_host_device end
+#pragma pop_macro("_LIBCPP_NO_EXCEPTIONS")
+#else
+#include_next 
+#endif // __HIP_USE_LIBCPP
+
+#endif // __CLANG_CUDA_WRAPPERS_TYPE_TRAITS
Index: clang/lib/Headers/cuda_wrappers/tuple
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/tuple
@@ -0,0 +1,24 @@
+/*=== tuple - CUDA/HIP wrapper for  -===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_WRAPPERS_TUPLE
+#define __CLANG_CUDA_WRAPPERS_TUPLE
+
+#if __HIP_USE_LIBCPP
+#pragma push_macro("_LIBCPP_NO_EXCEPTIONS")
+#define _LIBCPP_NO_EXCEPTIONS
+#pragma clang force_cuda_host_device begin
+#include_next 
+#pragma clang force_cuda_host_device end
+#pragma pop_macro("_LIBCPP_NO_EXCEPTIONS")
+#else
+#include_next 
+#endif // __HIP_USE_LIBCPP
+
+#endif // __CLANG_CUDA_WRAPPERS_TUPLE
Index: clang/lib/Headers/cuda_wrappers/functional
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/functional
@@ -0,0 +1,34 @@
+/*=== functional - CUDA/HIP wrapper for  ---===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_WRAPPERS_FUNCTIONAL
+#define __CLANG_CUDA_WRAPPERS_FUNCTIONAL
+
+#if __HIP_USE_LIBCPP
+#pragma push_macro("_LIBCPP_NO_EXCEPTIONS")
+#define _LIBCPP_NO_EXCEPTIONS
+
+extern __device__ void abort() __attribute__ ((__noreturn__));
+namespace std {
+namespace __1 {
+  inline __device__ void abort() {
+return ::abort();
+  }
+}
+}
+
+#pragma clang force_cuda_host_device begin
+#include_next 
+#pragma clang force_cuda_host_device end
+#pragma pop_macro("_LIBCPP_NO_EXCEPTIONS")
+#else
+#include_next 
+#endif // __HIP_USE_LIBCPP
+
+#endif // __CLANG_CUDA_WRAPPERS_FUNCTIONAL
Index: clang/lib/Headers/cuda_wrappers/array
===

[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Danila Kutenin via Phabricator via cfe-commits
danlark updated this revision to Diff 345460.
danlark added a comment.

- Add codegen and AST tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

Files:
  clang/lib/Parse/ParseTentative.cpp
  clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
  clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
  clang/test/Parser/cxx2a-init-statement.cpp


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-pch -std=c++2a -o %t %s
+// RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
+
+int f() {
+  // CHECK: for (int i = 0; x; i++) {
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
+
Index: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: define{{.*}} i32 @_Z1fv()
+int f() {
+  // CHECK: ret i32 1
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))


Index: clang/test/Parser/cxx2a-init-statement.cpp
===
--- clang/test/Parser/cxx2a-init-statement.cpp
+++ clang/test/Parser/cxx2a-init-statement.cpp
@@ -15,6 +15,8 @@
   int A<0>::*arr2[3];
   for (int n = 5; int A::*x : arr2) {}
 
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {}
+
   F (*arr3[3])(int);
   for (int n = 5; F (*p)(int n) : arr3) {}
   for (int n = 5; F (*p)(int (n)) : arr3) {}
Index: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-pch -std=c++2a -o %t %s
+// RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
+
+int f() {
+  // CHECK: for (int i = 0; x; i++) {
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
+
Index: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define{{.*}} i32 @_Z1fv()
+int f() {
+  // CHECK: ret i32 1
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
+return x;
+  }
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -353,8 +353,8 @@
   if (CanBeForRangeDecl) {
 // Skip until we hit a ')', ';', or a ':' with no matching '?'.
 // The final case is a for range declaration, the rest are not.
+unsigned QuestionColonDepth = 0;
 while (true) {
-  unsigned QuestionColonDepth = 0;
   P.SkipUntil({tok::r_paren, tok::semi, tok::question, tok::colon},
   StopBeforeMatch);
   if (P.Tok.is(tok::question))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Danila Kutenin via Phabricator via cfe-commits
danlark added a comment.

Done, please, take a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

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


[PATCH] D102508: [HIP] Add test libstd_functional

2021-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, ashi1.
Herald added a subscriber: mgorny.
yaxunl requested review of this revision.

This patch adds a test for using  in HIP device code.


Repository:
  rT test-suite

https://reviews.llvm.org/D102508

Files:
  External/HIP/CMakeLists.txt
  External/HIP/stdlib_functional.hip
  External/HIP/stdlib_functional.reference_output


Index: External/HIP/stdlib_functional.reference_output
===
--- /dev/null
+++ External/HIP/stdlib_functional.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/stdlib_functional.hip
===
--- /dev/null
+++ External/HIP/stdlib_functional.hip
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+
+#if !__HIP_USE_LIBCPP
+#error "This test requests -stdlib=libc++"
+#endif // __HIP_USE_LIBCPP
+
+__managed__ int x;
+
+__global__ void kern() {
+  auto plus = std::plus();
+  auto plus2 = std::bind(plus, std::placeholders::_1, 2);
+  x = plus2(x);
+}
+
+int main() {
+  kern<<<1,1>>>();
+  hipDeviceSynchronize();
+  if (x != 2) {
+printf("FAILED!\n");
+return 1;
+  }
+
+  printf("PASSED!\n");
+  return 0;
+}
Index: External/HIP/CMakeLists.txt
===
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
 # Create targets for HIP tests that are part of the test suite.
 macro(create_local_hip_tests VariantSuffix)
   set(VariantOffload "hip")
+  # Set per-source compilation/link options
+  set_source_files_properties(stdlib_functional.hip PROPERTIES
+COMPILE_FLAGS -stdlib=libc++)
   # Add HIP tests to be added to hip-tests-simple
   list(APPEND HIP_LOCAL_TESTS empty)
+  list(APPEND HIP_LOCAL_TESTS stdlib_functional)
   list(APPEND HIP_LOCAL_TESTS saxpy)
   foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
 create_one_local_test(${_hip_test} ${_hip_test}.hip


Index: External/HIP/stdlib_functional.reference_output
===
--- /dev/null
+++ External/HIP/stdlib_functional.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/stdlib_functional.hip
===
--- /dev/null
+++ External/HIP/stdlib_functional.hip
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+
+#if !__HIP_USE_LIBCPP
+#error "This test requests -stdlib=libc++"
+#endif // __HIP_USE_LIBCPP
+
+__managed__ int x;
+
+__global__ void kern() {
+  auto plus = std::plus();
+  auto plus2 = std::bind(plus, std::placeholders::_1, 2);
+  x = plus2(x);
+}
+
+int main() {
+  kern<<<1,1>>>();
+  hipDeviceSynchronize();
+  if (x != 2) {
+printf("FAILED!\n");
+return 1;
+  }
+
+  printf("PASSED!\n");
+  return 0;
+}
Index: External/HIP/CMakeLists.txt
===
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
 # Create targets for HIP tests that are part of the test suite.
 macro(create_local_hip_tests VariantSuffix)
   set(VariantOffload "hip")
+  # Set per-source compilation/link options
+  set_source_files_properties(stdlib_functional.hip PROPERTIES
+COMPILE_FLAGS -stdlib=libc++)
   # Add HIP tests to be added to hip-tests-simple
   list(APPEND HIP_LOCAL_TESTS empty)
+  list(APPEND HIP_LOCAL_TESTS stdlib_functional)
   list(APPEND HIP_LOCAL_TESTS saxpy)
   foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
 create_one_local_test(${_hip_test} ${_hip_test}.hip
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100733: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

2021-05-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

In D100733#2759592 , @aaronpuchert 
wrote:

> @aaron.ballman, what do you think about this? We can't really prevent anyone 
> from writing `.getValueKind() == VK_*Value` instead of `.is*Value()`, so this 
> change will make things consistent only for now.

I'm not certain this is a big win in all cases, especially because the standard 
has one set of terminology and we use another. e.g., the standard makes a 
distinction between rvalue and prvalue that we don't make, same for lvalue and 
glvalue. When I see the equality expression, I know that only one category is 
being tested, but when I see the function call expression, I have to think more 
about "does `isRValue()` return true for a prvalue and an xvalue, or just a 
prvalue?"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100733

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


[PATCH] D102502: [clang] Fix ternary operator in second for loop argument

2021-05-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, nice catch!

Can we also add an assert when parsing a `for` statement that we actually find 
a range if the tentative parse said we were expecting one?




Comment at: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp:1
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | 
FileCheck %s
+

We don't use `-O3` tests for this kind of thing, to avoid depending on the 
behaviour of the optimizer; instead you should test that the (unoptimized) IR 
generated by clang is correct.



Comment at: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp:5
+int f() {
+  // CHECK: for (int i = 0; x; i++) {
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {

This ast-print output looks wrong; I assume that's an unrelated bug?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502

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


[PATCH] D102508: [HIP] Add test libstd_functional

2021-05-14 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

Looks good, let me verify on HIP builder.


Repository:
  rT test-suite

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

https://reviews.llvm.org/D102508

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


[PATCH] D102508: [HIP] Add test libstd_functional

2021-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D102508#2759905 , @ashi1 wrote:

> Looks good, let me verify on HIP builder.

It depends on https://reviews.llvm.org/D102507


Repository:
  rT test-suite

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

https://reviews.llvm.org/D102508

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


[PATCH] D102508: [HIP] Add test libstd_functional

2021-05-14 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

In D102508#2759906 , @yaxunl wrote:

> In D102508#2759905 , @ashi1 wrote:
>
>> Looks good, let me verify on HIP builder.
>
> It depends on https://reviews.llvm.org/D102507

Okay, let's wait for that to merge first. Thanks.


Repository:
  rT test-suite

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

https://reviews.llvm.org/D102508

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D96033#2759808 , @v.g.vassilev 
wrote:

> Hi @hubert.reinterpretcast,
>
> Would you mind testing this patch:

Running it now. I've applied the first diff here to the base of my previously 
reported result to minimize build time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D102397: [AArch64] Lower bitreverse in ISel

2021-05-14 Thread Irina Dobrescu via Phabricator via cfe-commits
Rin updated this revision to Diff 345465.
Rin added a comment.

Add AutoUpgrade test and move bitreverse lowering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102397

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-misc.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
  llvm/test/CodeGen/AArch64/bitreverse.ll
  llvm/test/CodeGen/AArch64/neon_rbit.ll

Index: llvm/test/CodeGen/AArch64/neon_rbit.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon_rbit.ll
@@ -0,0 +1,121 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-eabi -mattr=+fullfp16 %s -o - | FileCheck %s
+
+; The llvm.aarch64_neon_rbit intrinsic should be auto-upgraded to the
+; target-independent bitreverse intrinsic.
+
+declare <8 x i8> @llvm.aarch64.neon.rbit.v8i8(<8 x i8>) nounwind readnone
+
+define <8 x i8> @rbit_8x8(<8 x i8> %A) nounwind {
+; CHECK-LABEL: rbit_8x8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit v0.8b, v0.8b
+; CHECK-NEXT:ret
+%tmp3 = call <8 x i8> @llvm.aarch64.neon.rbit.v8i8(<8 x i8> %A)
+	ret <8 x i8> %tmp3
+}
+
+declare <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8>) nounwind readnone
+
+define <16 x i8> @rbit_16x8(<16 x i8> %A) nounwind {
+; CHECK-LABEL: rbit_16x8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rbit v0.16b, v0.16b
+; CHECK-NEXT:ret
+%tmp3 = call <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8> %A)
+	ret <16 x i8> %tmp3
+}
+
+declare <4 x i16> @llvm.aarch64.neon.rbit.v4i16(<4 x i16>) nounwind readnone
+
+define <4 x i16> @rbit_4x16(<4 x i16> %A) nounwind {
+; CHECK-LABEL: rbit_4x16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev16 v0.8b, v0.8b
+; CHECK-NEXT:rbit v0.8b, v0.8b
+; CHECK-NEXT:ret
+%tmp3 = call <4 x i16> @llvm.aarch64.neon.rbit.v4i16(<4 x i16> %A)
+	ret <4 x i16> %tmp3
+}
+
+declare <8 x i16> @llvm.aarch64.neon.rbit.v8i16(<8 x i16>) nounwind readnone
+
+define <8 x i16> @rbit_8x16(<8 x i16> %A) {
+; CHECK-LABEL: rbit_8x16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev16 v0.16b, v0.16b
+; CHECK-NEXT:rbit v0.16b, v0.16b
+; CHECK-NEXT:ret
+  %tmp3 = call <8 x i16> @llvm.aarch64.neon.rbit.v8i16(<8 x i16> %A)
+  ret <8 x i16> %tmp3
+}
+
+declare <2 x i32> @llvm.aarch64.neon.rbit.v2i32(<2 x i32>) nounwind readnone
+
+define <2 x i32> @rbit_2x32(<2 x i32> %A) {
+; CHECK-LABEL: rbit_2x32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:// kill: def $d0 killed $d0 def $q0
+; CHECK-NEXT:fmov w8, s0
+; CHECK-NEXT:rbit w8, w8
+; CHECK-NEXT:mov w9, v0.s[1]
+; CHECK-NEXT:fmov s0, w8
+; CHECK-NEXT:rbit w8, w9
+; CHECK-NEXT:mov v0.s[1], w8
+; CHECK-NEXT:// kill: def $d0 killed $d0 killed $q0
+; CHECK-NEXT:ret
+  %tmp3 = call <2 x i32> @llvm.aarch64.neon.rbit.v2i32(<2 x i32> %A)
+  ret <2 x i32> %tmp3
+}
+
+declare <4 x i32> @llvm.aarch64.neon.rbit.v4i32(<4 x i32>) nounwind readnone
+
+define <4 x i32> @rbit_4x32(<4 x i32> %A) {
+; CHECK-LABEL: rbit_4x32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:fmov w10, s0
+; CHECK-NEXT:mov w8, v0.s[1]
+; CHECK-NEXT:rbit w10, w10
+; CHECK-NEXT:mov w9, v0.s[2]
+; CHECK-NEXT:mov w11, v0.s[3]
+; CHECK-NEXT:fmov s0, w10
+; CHECK-NEXT:rbit w8, w8
+; CHECK-NEXT:rbit w9, w9
+; CHECK-NEXT:mov v0.s[1], w8
+; CHECK-NEXT:mov v0.s[2], w9
+; CHECK-NEXT:rbit w8, w11
+; CHECK-NEXT:mov v0.s[3], w8
+; CHECK-NEXT:ret
+  %tmp3 = call <4 x i32> @llvm.aarch64.neon.rbit.v4i32(<4 x i32> %A)
+  ret <4 x i32> %tmp3
+}
+
+declare <1 x i64> @llvm.aarch64.neon.rbit.v1i64(<1 x i64>) readnone
+
+define <1 x i64> @rbit_1x64(<1 x i64> %A) {
+; CHECK-LABEL: rbit_1x64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:// kill: def $d0 killed $d0 def $q0
+; CHECK-NEXT:fmov x8, d0
+; CHECK-NEXT:rbit x8, x8
+; CHECK-NEXT:fmov d0, x8
+; CHECK-NEXT:ret
+  %tmp3 = call <1 x i64> @llvm.aarch64.neon.rbit.v1i64(<1 x i64> %A)
+  ret <1 x i64> %tmp3
+}
+
+declare <2 x i64> @llvm.aarch64.neon.rbit.v2i64(<2 x i64>) readnone
+
+define <2 x i64> @rbit_2x64(<2 x i64> %A) {
+; CHECK-LABEL: rbit_2x64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:fmov x8, d0
+; CHECK-NEXT:rbit x8, x8
+; CHECK-NEXT:mov x9, v0.d[1]
+; CHECK-NEXT:fmov d0, x8
+; CHECK-NEXT:rbit x8, x9
+; CHECK-NEXT:mov v0.d[1], x8
+; CHECK-NEXT:ret
+  %tmp3 = call <2 x i64> @llvm.aarch64.neon.rbit.v2i64(<2 x i64> %A)
+  ret <2 x i64> %tmp3
+}
Index: llvm/test/CodeGen/AArch64/bitreverse.ll
===
--- llvm/test/CodeGen/AArch64/bitreverse.ll
+++ llvm/test/CodeGen/AArch64/bitreverse.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/

[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

The changes LGTM, but you should wait a bit before landing in case @rsmith or 
one of the other reviewers has concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[PATCH] D102175: [clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

2021-05-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Hi Felix,
Can you clarify your concern over the warning? Is it the case that the warning 
is not present before the fix and is only triggered after the fix?  I'm 
concerned that removing the call may have unintended side effects and I would 
think it might better to leave the check for usage separate.  However, if the 
fix is causing the warning then I can understand better why you want to make 
this change.  That said, have considered replacing the var binding with 
`(void)`, rather than deleting the statement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102175

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


[clang] 769cc33 - [OpenCL] Simplify use of C11 atomic types.

2021-05-14 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-05-14T17:43:00+01:00
New Revision: 769cc335e6e63e5eac0c0ac849de44714326e20b

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

LOG: [OpenCL] Simplify use of C11 atomic types.

Remove requirements on extension pragma in atomic types
because it has not respected the spec wrt disabling types
and hasn't been useful either. With this change, the
developers can use atomic types from the extensions if they
are supported without enabling the pragma just like the builtin
functions

This patch does not break backward compatibility since the
extension pragma is still supported and it makes the behavior of
the compiler less strict by accepting code without needless and
inconsistent pragma statements.

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

Added: 


Modified: 
clang/lib/Sema/Sema.cpp
clang/test/Parser/opencl-atomics-cl20.cl

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 72e2ee613cbf4..36fcadfc9b9b7 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -313,8 +313,7 @@ void Sema::Initialize() {
   // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
   // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
   addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
-  auto AtomicSizeT = Context.getAtomicType(Context.getSizeType());
-  addImplicitTypedef("atomic_size_t", AtomicSizeT);
+
 
   // OpenCL v2.0 s6.13.11.6:
   // - The atomic_long and atomic_ulong types are supported if the
@@ -327,6 +326,23 @@ void Sema::Initialize() {
   //   atomic_intptr_t, atomic_uintptr_t, atomic_size_t and
   //   atomic_ptr
diff _t are supported if the cl_khr_int64_base_atomics and
   //   cl_khr_int64_extended_atomics extensions are supported.
+
+  auto AddPointerSizeDependentTypes = [&]() {
+auto AtomicSizeT = Context.getAtomicType(Context.getSizeType());
+auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
+auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
+auto AtomicPtrDiffT =
+Context.getAtomicType(Context.getPointerDiffType());
+addImplicitTypedef("atomic_size_t", AtomicSizeT);
+addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
+addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
+addImplicitTypedef("atomic_ptr
diff _t", AtomicPtrDiffT);
+  };
+
+  if (Context.getTypeSize(Context.getSizeType()) == 32) {
+AddPointerSizeDependentTypes();
+  }
+
   std::vector Atomic64BitTypes;
   if (getOpenCLOptions().isSupported("cl_khr_int64_base_atomics",
  getLangOpts()) &&
@@ -335,35 +351,18 @@ void Sema::Initialize() {
 if (getOpenCLOptions().isSupported("cl_khr_fp64", getLangOpts())) {
   auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
   addImplicitTypedef("atomic_double", AtomicDoubleT);
-  setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64");
   Atomic64BitTypes.push_back(AtomicDoubleT);
 }
 auto AtomicLongT = Context.getAtomicType(Context.LongTy);
 auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy);
-auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
-auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
-auto AtomicPtrDiffT =
-Context.getAtomicType(Context.getPointerDiffType());
-
 addImplicitTypedef("atomic_long", AtomicLongT);
 addImplicitTypedef("atomic_ulong", AtomicULongT);
-addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
-addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
-addImplicitTypedef("atomic_ptr
diff _t", AtomicPtrDiffT);
 
-Atomic64BitTypes.push_back(AtomicLongT);
-Atomic64BitTypes.push_back(AtomicULongT);
-if (Context.getTypeSize(AtomicSizeT) == 64) {
-  Atomic64BitTypes.push_back(AtomicSizeT);
-  Atomic64BitTypes.push_back(AtomicIntPtrT);
-  Atomic64BitTypes.push_back(AtomicUIntPtrT);
-  Atomic64BitTypes.push_back(AtomicPtrDiffT);
+
+if (Context.getTypeSize(Context.getSizeType()) == 64) {
+  AddPointerSizeDependentTypes();
 }
   }
-
-  for (auto &I : Atomic64BitTypes)
-setOpenCLExtensionForType(I,
-"cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");
 }
 
 

diff  --git a/clang/test/Parser/opencl-atomics-cl20.cl 
b/clang/test/Parser/opencl-atomics-cl20.cl
index 2f5f913d28738..c3f86b6a44c49 100644
--- a/clang/test/Parser/opencl-atomics-cl20.cl
+++ b/clang/test/Parser/ope

[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-14 Thread Anastasia Stulova 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 rG769cc335e6e6: [OpenCL] Simplify use of C11 atomic types. 
(authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D100976?vs=344781&id=345469#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100976

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/Parser/opencl-atomics-cl20.cl

Index: clang/test/Parser/opencl-atomics-cl20.cl
===
--- clang/test/Parser/opencl-atomics-cl20.cl
+++ clang/test/Parser/opencl-atomics-cl20.cl
@@ -1,66 +1,78 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
-// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT -Wpedantic-core-features
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics
+// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CLC++
+// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics
 
-#ifdef EXT
-#pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable
-#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics:enable
-#pragma OPENCL EXTENSION cl_khr_fp64:enable
-#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
-// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}}
-#endif
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#define LANG_VER_OK
 #endif
 
 void atomic_types_test() {
 // OpenCL v2.0 s6.13.11.6 defines supported atomic types.
+
+// Non-optional types
   atomic_int i;
   atomic_uint ui;
+  atomic_float f;
+  atomic_flag fl;
+#if !defined(LANG_VER_OK)
+// expected-error@-5 {{use of undeclared identifier 'atomic_int'}}
+// expected-error@-5 {{use of undeclared identifier 'atomic_uint'}}
+// expected-error@-5 {{use of undeclared identifier 'atomic_float'}}
+// expected-error@-5 {{use of undeclared identifier 'atomic_flag'}}
+#endif
+
+// Optional types
   atomic_long l;
   atomic_ulong ul;
-  atomic_float f;
   atomic_double d;
-  atomic_flag fl;
+  atomic_size_t s;
   atomic_intptr_t ip;
   atomic_uintptr_t uip;
-  atomic_size_t s;
   atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
+// Optional type identifiers are not added in earlier version or if at least
+// one of the extensions is not supported. Here we check with
+// `cl_khr_int64_base_atomics` only.
+#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics)
+// expected-error@-11 {{use of undeclared identifier 'atomic_long'}}
+// expected-error@-11 {{use of undeclared identifier 'atomic_ulong'}}
+// expected-error@-11 {{use of undeclared identifier 'atomic_double'}}
+#if defined(LANG_VER_OK)
+// expected-error@-15 {{expected ';' after expression}}
+// expected-error@-16 {{use of undeclared identifier 'l'}}
+// expected-error@-16 {{expected ';' after expression}}
+// expected-error@-17 {{use of undeclared identifier 'ul'}}
+#endif
+#if !defined(LANG_VER_OK) || defined(__SPIR64__)
+// expected-error@-18 {{use of undeclared identifier 'atomic_size_t'}}
 // expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_base_atomics support}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-14 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 345470.
pzheng added a comment.

Address @MaskRay's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1185,6 +1185,37 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+
+  // OutputFilename empty implies -fstack-usage is not passed.
+  if (OutputFilename.empty())
+return;
+
+  const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ':' << DSP->getLine();
+
+  *StackUsageStream << ':' << MF.getName() << '\t' << StackSize << '\t';
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
   MachineModuleInfo &MMI = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1469,6 +1500,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -342,6 +342,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file) if user passes
+/// -fstack-usage. If empty, it can be implied that -fstack-usage is not
+/// passed on the command line.
+std::string StackUsageOutput;
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -182,6 +182,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream;
+
   static char ID;
 
 protected:
@@ -358,6 +361,8 @@
 
   void emitStackSizeSection(const MachineFunction &MF);
 
+  void emitStackUsage(const MachineFunction &MF);
+
   void emitBBAddrMapSection(const MachineFunction &MF);
 
   void emitPseudoProbe(const MachineInstr &MI);
Index: clang/test/Driver/stack-usage.c
===
--- /dev/null
+++ clang/test/Driver/stack-usage.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
+// CHECK-ABSENT-NOT: "-stack-usage-file"
+
+// RUN: %clang -target aarch64-unknown -fstack-usage %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: "-stack-usage-file"
+
+int foo() { return 42; }
Index: clang/test/CodeGen/stack-usage.c
===
--- /dev/null
+++ clang/test/CodeGen/stack-usage.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -triple aarch64-unknown -stack-usage-file %t/b.su -emit-obj %s -o %t/b.o
+// RUN: FileCheck %s < %t/b.su
+
+// CHECK: stack-usage.c:[[#@LINE+1]]:foo	{{[0-9]+}}	static
+int foo() {
+  char a[8];
+
+  return 0;
+}
+
+// CHECK: stack-usage.c:[[#@LINE+1]]:bar	{{[0-9]+}}	dynamic
+int bar(int len) {
+  char a[len];
+
+  return 1;
+}
Index: clang/lib/Frontend/C

[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 345471.
AbbasSabra marked 7 inline comments as done.
AbbasSabra added a comment.

Updating D102273 : [analyzer] Apply code 
review part 2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp

Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 -analyzer-config exploration_strategy=unexplored_first_queue %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++11 -DDFS=1 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++14 -analyzer-config exploration_strategy=unexplored_first_queue %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++14 -DDFS=1 %s
 
 void clang_analyzer_numTimesReached();
 void clang_analyzer_warnIfReached();
@@ -511,3 +511,39 @@
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
+
+void capture_by_value_as_loop_counter() {
+  int out = 0;
+  auto l = [i = out]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_by_ref_as_loop_counter() {
+  int out = 0;
+  auto l = [&i = out]() {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
+
+void capture_implicitly_by_value_as_loop_counter() {
+  int i = 0;
+  auto l = [=]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_implicitly_by_ref_as_loop_counter() {
+  int i = 0;
+  auto l = [&]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -79,14 +79,17 @@
   return State;
 }
 
-static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
-  hasOperatorName("<="), hasOperatorName(">="),
-  hasOperatorName("!=")),
-hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
+static internal::Matcher simpleCondition(StringRef BindName,
+   StringRef RefName) {
+  return binaryOperator(
+ anyOf(hasOperatorName("<"), hasOperatorName(">"),
+   hasOperatorName("<="), hasOperatorName(">="),
+   hasOperatorName("!=")),
+ hasEitherOperand(ignoringParenImpCasts(
+ declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+ .bind(RefName))),
+ hasEitherOperand(
+ ignoringParenImpCasts(integerLiteral().bind("boundNum"
   .bind("conditionOperator");
 }
 
@@ -138,7 +141,7 @@
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
+ hasCondition(simpleCondition("initVarName", "initVarRef")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
@@ -156,17 +159,54 @@
  hasUnaryOperand(declRefExpr(
  to(varDecl(allOf(equalsBoundNode("initVarName"),
   hasType(isInteger(),
- unless(hasBody(hasSuspiciousStmt("initVarName".bind("forLoop");
+ unless(hasBody(hasSuspiciousStmt("initVarName"
+  .bind("forLoop");
 }
 
-static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables assumed as escaped variables.
+static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
+
+  // Get the lambda CXXRecordDecl
+  assert(DR->refersToEnclosingVariableOrCapture());
+  const 

[clang] b7d1ab7 - [HWASan] Add aliasing flag and enable HWASan to use it.

2021-05-14 Thread Matt Morehouse via cfe-commits

Author: Matt Morehouse
Date: 2021-05-14T09:47:20-07:00
New Revision: b7d1ab75cf474fb3ffc7e7173762c4d83eb2ef8e

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

LOG: [HWASan] Add aliasing flag and enable HWASan to use it.

-fsanitize-hwaddress-experimental-aliasing is intended to distinguish
aliasing mode from LAM mode on x86_64.  check-hwasan is configured
to use aliasing mode while check-hwasan-lam is configured to use LAM
mode.

The current patch doesn't actually do anything differently in the two
modes.  A subsequent patch will actually build the separate runtimes
and use them in each mode.

Currently LAM mode tests must be run in an emulator that
has LAM support.  To ensure LAM mode isn't broken by future patches, I
will next set up a QEMU buildbot to run the HWASan tests in LAM.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
compiler-rt/test/hwasan/CMakeLists.txt
compiler-rt/test/hwasan/TestCases/Linux/vfork.c
compiler-rt/test/hwasan/lit.cfg.py
compiler-rt/test/hwasan/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1fda2dac0f76f..a7adab50657af 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1547,6 +1547,14 @@ def fno_sanitize_memory_track_origins : Flag<["-"], 
"fno-sanitize-memory-track-o
 Group,
 Flags<[CoreOption, NoXarchOption]>,
 HelpText<"Disable origins tracking in 
MemorySanitizer">;
+def fsanitize_hwaddress_experimental_aliasing
+  : Flag<["-"], "fsanitize-hwaddress-experimental-aliasing">,
+Group,
+HelpText<"Enable aliasing mode in HWAddressSanitizer">;
+def fno_sanitize_hwaddress_experimental_aliasing
+  : Flag<["-"], "fno-sanitize-hwaddress-experimental-aliasing">,
+Group, Flags<[CoreOption, NoXarchOption]>,
+HelpText<"Disable aliasing mode in HWAddressSanitizer">;
 defm sanitize_memory_use_after_dtor : BoolOption<"f", 
"sanitize-memory-use-after-dtor",
   CodeGenOpts<"SanitizeMemoryUseAfterDtor">, DefaultFalse,
   PosFlag, NegFlag,

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index e9609268ecd73..adfc26382f607 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -57,6 +57,7 @@ class SanitizerArgs {
   // True if cross-dso CFI support if provided by the system (i.e. Android).
   bool ImplicitCfiRuntime = false;
   bool NeedsMemProfRt = false;
+  bool HwasanUseAliases = false;
 
 public:
   /// Parses the sanitizer arguments from an argument list.
@@ -69,6 +70,9 @@ class SanitizerArgs {
   bool needsHwasanRt() const {
 return Sanitizers.has(SanitizerKind::HWAddress);
   }
+  bool needsHwasanAliasesRt() const {
+return needsHwasanRt() && HwasanUseAliases;
+  }
   bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
   bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
   bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 7bd99e13010a6..9c54bd5fbab6c 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -865,6 +865,11 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
 } else {
   HwasanAbi = "interceptor";
 }
+if (TC.getTriple().getArch() == llvm::Triple::x86_64)
+  HwasanUseAliases = Args.hasFlag(
+  options::OPT_fsanitize_hwaddress_experimental_aliasing,
+  options::OPT_fno_sanitize_hwaddress_experimental_aliasing,
+  HwasanUseAliases);
   }
 
   if (AllAddedKinds & SanitizerKind::SafeStack) {

diff  --git a/compiler-rt/test/hwasan/CMakeLists.txt 
b/compiler-rt/test/hwasan/CMakeLists.txt
index f6bdd510ad312..b463146132dbf 100644
--- a/compiler-rt/test/hwasan/CMakeLists.txt
+++ b/compiler-rt/test/hwasan/CMakeLists.txt
@@ -33,5 +33,15 @@ endif()
 add_lit_testsuite(check-hwasan "Running the HWAddressSanitizer tests"
   ${HWASAN_TESTSUITES}
   DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "HWASAN_ENABLE_ALIASES=1"
   )
 set_target_properties(check-hwasan PROPERTIES FOLDER "Compiler-RT Misc")
+
+add_lit_testsuite(check-hwasan-lam
+  "Running the HWAddressSanitizer tests with Intel LAM"
+  ${HWASAN_TESTSUITES}
+  DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "HWASAN_ENABLE_ALIASES=0"
+  EXCLUDE_FROM_CHECK_ALL
+  )
+set_target_properties(check-hwasan-lam PROPER

[PATCH] D102288: [HWASan] Add aliasing flag and enable HWASan to use it.

2021-05-14 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7d1ab75cf47: [HWASan] Add aliasing flag and enable HWASan 
to use it. (authored by morehouse).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102288

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/hwasan/CMakeLists.txt
  compiler-rt/test/hwasan/TestCases/Linux/vfork.c
  compiler-rt/test/hwasan/lit.cfg.py
  compiler-rt/test/hwasan/lit.site.cfg.py.in

Index: compiler-rt/test/hwasan/lit.site.cfg.py.in
===
--- compiler-rt/test/hwasan/lit.site.cfg.py.in
+++ compiler-rt/test/hwasan/lit.site.cfg.py.in
@@ -6,6 +6,9 @@
 config.target_arch = "@HWASAN_TEST_TARGET_ARCH@"
 config.android_files_to_push = @HWASAN_ANDROID_FILES_TO_PUSH@
 
+# Whether to use -mlam or not.
+config.enable_aliases = lit_config.params.get("HWASAN_ENABLE_ALIASES", "@HWASAN_ENABLE_ALIASES@")
+
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
 
Index: compiler-rt/test/hwasan/lit.cfg.py
===
--- compiler-rt/test/hwasan/lit.cfg.py
+++ compiler-rt/test/hwasan/lit.cfg.py
@@ -12,6 +12,11 @@
 clang_cflags = [config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 clang_hwasan_common_cflags = clang_cflags + ["-fsanitize=hwaddress", "-fuse-ld=lld"]
+
+if config.target_arch == 'x86_64' and config.enable_aliases == '1':
+  clang_hwasan_common_cflags += ["-fsanitize-hwaddress-experimental-aliasing"]
+if config.enable_aliases != '1':
+  config.available_features.add('pointer-tagging')
 if config.target_arch == 'x86_64':
   # This does basically the same thing as tagged-globals on aarch64. Because
   # the x86_64 implementation is for testing purposes only there is no
Index: compiler-rt/test/hwasan/TestCases/Linux/vfork.c
===
--- compiler-rt/test/hwasan/TestCases/Linux/vfork.c
+++ compiler-rt/test/hwasan/TestCases/Linux/vfork.c
@@ -2,9 +2,7 @@
 // RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1
 
 // REQUIRES: aarch64-target-arch || x86_64-target-arch
-
-// Aliasing mode does not support stack tagging.
-// XFAIL: x86_64
+// REQUIRES: pointer-tagging
 
 #include 
 #include 
Index: compiler-rt/test/hwasan/CMakeLists.txt
===
--- compiler-rt/test/hwasan/CMakeLists.txt
+++ compiler-rt/test/hwasan/CMakeLists.txt
@@ -33,5 +33,15 @@
 add_lit_testsuite(check-hwasan "Running the HWAddressSanitizer tests"
   ${HWASAN_TESTSUITES}
   DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "HWASAN_ENABLE_ALIASES=1"
   )
 set_target_properties(check-hwasan PROPERTIES FOLDER "Compiler-RT Misc")
+
+add_lit_testsuite(check-hwasan-lam
+  "Running the HWAddressSanitizer tests with Intel LAM"
+  ${HWASAN_TESTSUITES}
+  DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "HWASAN_ENABLE_ALIASES=0"
+  EXCLUDE_FROM_CHECK_ALL
+  )
+set_target_properties(check-hwasan-lam PROPERTIES FOLDER "Compiler-RT Misc")
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -865,6 +865,11 @@
 } else {
   HwasanAbi = "interceptor";
 }
+if (TC.getTriple().getArch() == llvm::Triple::x86_64)
+  HwasanUseAliases = Args.hasFlag(
+  options::OPT_fsanitize_hwaddress_experimental_aliasing,
+  options::OPT_fno_sanitize_hwaddress_experimental_aliasing,
+  HwasanUseAliases);
   }
 
   if (AllAddedKinds & SanitizerKind::SafeStack) {
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -57,6 +57,7 @@
   // True if cross-dso CFI support if provided by the system (i.e. Android).
   bool ImplicitCfiRuntime = false;
   bool NeedsMemProfRt = false;
+  bool HwasanUseAliases = false;
 
 public:
   /// Parses the sanitizer arguments from an argument list.
@@ -69,6 +70,9 @@
   bool needsHwasanRt() const {
 return Sanitizers.has(SanitizerKind::HWAddress);
   }
+  bool needsHwasanAliasesRt() const {
+return needsHwasanRt() && HwasanUseAliases;
+  }
   bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
   bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
   bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/c

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LG with some nits. After fixes, please wait one day or so in case there are 
further comments.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5500
+  SmallString<128> OutputFilename(OutputOpt->getValue());
+  llvm::sys::path::replace_extension(OutputFilename, llvm::Twine("su"));
+  CmdArgs.push_back(Args.MakeArgString(OutputFilename));

remove `llvm::Twine`



Comment at: clang/test/CodeGen/stack-usage.c:4
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -triple aarch64-unknown -stack-usage-file %t/b.su -emit-obj 
%s -o %t/b.o
+// RUN: FileCheck %s < %t/b.su

`%t/b.su` can be simplified to `b.su` since you have changed cwd.



Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1189
+void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+

const std::string &

otherwise there will be an unneeded copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D102507: [HIP] Support in device code

2021-05-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: rsmith.
tra added a comment.

In effect this patch applies `__host__ __device__` to a subset of the standard 
library headers and whatever headers *they* happen to include. While it may 
happen to work, I'm not at all confident that it does not create interesting 
issues.

Considering that the patch only works with libc++ anyways, perhaps it's time to 
make (parts) of libc++ itself usable from CUDA/HIP, instead of hacking around 
it in the wrappers?

@rsmith Richard, who would be the right person to discuss the standard library 
changes we may need?


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

https://reviews.llvm.org/D102507

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


[PATCH] D100671: [ADT] Factor out in_place_t and expose in Optional ctor

2021-05-14 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 345475.
scott.linder added a comment.

Add constexpr convenience variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100671

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/STLForwardCompat.h
  llvm/unittests/ADT/OptionalTest.cpp

Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -195,6 +195,14 @@
   EXPECT_EQ(0u, NonDefaultConstructible::Destructions);
 }
 
+TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
+  NonDefaultConstructible::ResetCounts();
+  { Optional A{in_place, 1}; }
+  EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
+  EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
+  EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
+}
+
 TEST(OptionalTest, GetValueOr) {
   Optional A;
   EXPECT_EQ(42, A.getValueOr(42));
@@ -214,6 +222,11 @@
   MultiArgConstructor &operator=(const MultiArgConstructor &) = delete;
   MultiArgConstructor &operator=(MultiArgConstructor &&) = delete;
 
+  friend bool operator==(const MultiArgConstructor &LHS,
+ const MultiArgConstructor &RHS) {
+return LHS.x == RHS.x && LHS.y == RHS.y;
+  }
+
   static unsigned Destructions;
   ~MultiArgConstructor() {
 ++Destructions;
@@ -244,6 +257,34 @@
   EXPECT_EQ(1u, MultiArgConstructor::Destructions);
 }
 
+TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
+  MultiArgConstructor::ResetCounts();
+  {
+Optional A{in_place, 1, 2};
+EXPECT_TRUE(A.hasValue());
+EXPECT_EQ(1, A->x);
+EXPECT_EQ(2, A->y);
+Optional B{in_place, 5, false};
+EXPECT_TRUE(B.hasValue());
+EXPECT_EQ(5, B->x);
+EXPECT_EQ(-5, B->y);
+EXPECT_EQ(0u, MultiArgConstructor::Destructions);
+  }
+  EXPECT_EQ(2u, MultiArgConstructor::Destructions);
+}
+
+TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
+  MultiArgConstructor::ResetCounts();
+  {
+Optional A{in_place, 1, 2};
+Optional B;
+B.emplace(1, 2);
+EXPECT_EQ(0u, MultiArgConstructor::Destructions);
+ASSERT_EQ(A, B);
+  }
+  EXPECT_EQ(2u, MultiArgConstructor::Destructions);
+}
+
 struct MoveOnly {
   static unsigned MoveConstructions;
   static unsigned Destructions;
@@ -391,6 +432,15 @@
   EXPECT_EQ(0u, Immovable::Destructions);
 }
 
+TEST(OptionalTest, ImmovableInPlaceConstruction) {
+  Immovable::ResetCounts();
+  Optional A{in_place, 4};
+  EXPECT_TRUE((bool)A);
+  EXPECT_EQ(4, A->val);
+  EXPECT_EQ(1u, Immovable::Constructions);
+  EXPECT_EQ(0u, Immovable::Destructions);
+}
+
 // Craft a class which is_trivially_copyable, but not
 // is_trivially_copy_constructible.
 struct NonTCopy {
Index: llvm/include/llvm/ADT/STLForwardCompat.h
===
--- llvm/include/llvm/ADT/STLForwardCompat.h
+++ llvm/include/llvm/ADT/STLForwardCompat.h
@@ -44,6 +44,33 @@
 struct disjunction
 : std::conditional>::type {};
 
+struct in_place_t // NOLINT(readability-identifier-naming)
+{
+  explicit in_place_t() = default;
+};
+/// \warning This must not be odr-used, as it cannot be made \c inline in C++14.
+constexpr in_place_t in_place; // NOLINT(readability-identifier-naming)
+
+template 
+struct in_place_type_t // NOLINT(readability-identifier-naming)
+{
+  explicit in_place_type_t() = default;
+};
+/// \warning This must not be odr-used, as it cannot be made \c inline in C++14.
+template 
+constexpr in_place_type_t
+in_place_type; // NOLINT(readability-identifier-naming)
+
+template 
+struct in_place_index_t // NOLINT(readability-identifier-naming)
+{
+  explicit in_place_index_t() = default;
+};
+/// \warning This must not be odr-used, as it cannot be made \c inline in C++14.
+template 
+constexpr in_place_index_t
+in_place_index; // NOLINT(readability-identifier-naming)
+
 //===--===//
 // Features from C++20
 //===--===//
Index: llvm/include/llvm/ADT/Optional.h
===
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/type_traits.h"
 #include 
@@ -30,8 +31,6 @@
 
 namespace optional_detail {
 
-struct in_place_t {};
-
 /// Storage for any type.
 //
 // The specialization condition intentionally uses
@@ -245,13 +244,16 @@
   constexpr Optional() {}
   constexpr Optional(NoneType) {}
 
-  constexpr Optional(const T &y) : Storage(optional_detail::in_place_t{}, y) {}
+  constexpr O

[PATCH] D102494: [Clang, Driver] Default to Darwin_libsystem_m veclib on iOS based targets.

2021-05-14 Thread Steve Canon via Phabricator via cfe-commits
scanon added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2492
+  // Darwin_libsystem_m for iOS based targets.
+  if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib))
+CC1Args.push_back("-fveclib=Darwin_libsystem_m");

fhahn wrote:
> arphaman wrote:
> > Is this applicable to the watchOS targets as well? The iOS based check 
> > doesn't cover it.
> `libsystem_m`'s vector functions should be available on all Darwin platforms 
> I think. I'd gradually opt-in additional platforms, once we verified it is 
> clearly beneficial for each platform individually.
> 
> Should I add a TODO?
Correct, available on all Darwin systems. These APIs were introduced in macOS 
10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, and driverkit 19.0. I think we need a 
check that the target is at least those versions somewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102494

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D96033#2759808 , @v.g.vassilev 
wrote:

> Hi @hubert.reinterpretcast,
>
> Would you mind testing this patch:

Does the test try to generate native object files in some way? There is 
functionality (with some limitations) for that under 32-bit AIX; however, we're 
running a 64-bit build and we don't have integrated-as capability for that at 
this time. This is what I'm seeing:

   TEST 'Clang :: Interpreter/execute.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   cat 
/home/hstong/.Liodine/llvmproj/clang/test/Interpreter/execute.cpp | 
/home/hstong/.Nrtphome/.Liodine/llcrossbld/dev/build/bin/clang-repl | 
/home/hstong/.Nrtphome/.Liodine/llcrossbld/dev/build/bin/FileCheck 
/home/hstong/.Liodine/llvmproj/clang/test/Interpreter/execute.cpp
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  clang-repl: Driver initialization failed. Incremental mode for action is not 
supported
  FileCheck error: '' is empty.
  FileCheck command line:  
/home/hstong/.Nrtphome/.Liodine/llcrossbld/dev/build/bin/FileCheck 
/home/hstong/.Liodine/llvmproj/clang/test/Interpreter/execute.cpp
  
  --
  
  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:185-186
+  return FD->getType()->isReferenceType();
+} else {
+  assert(false && "Unknown captured variable");
+}

vsavchenko wrote:
> AbbasSabra wrote:
> > vsavchenko wrote:
> > > But actually, it's a bit different with this one. I don't know exact 
> > > details and rules how clang sema fills in the class for lambda.
> > > According to [[ https://en.cppreference.com/w/cpp/language/lambda | 
> > > cppreference ]]:
> > > > For the entities that are captured by reference (with the default 
> > > > capture [&] or when using the character &, e.g. [&a, &b, &c]), it is 
> > > > unspecified if additional data members are declared in the closure type
> > > 
> > > It can be pretty much specified in clang, that's true, but it looks like 
> > > in `DeadStoreChecker` we have a very similar situation and we do not 
> > > assume that captured variable always have a corresponding field.
> > Yes, I based this on the fact that DeadStoreChecker considers it possible, 
> > but I have never faced a case where it does not have a corresponding field.
> It still would be good to have some proof that it is indeed like this or 
> simply fallback into returning true (which you already do when in doubt).
As I said, I believe it cannot happen but I assumed based on the other checker 
that there is something I don't know.
I think based on !!getCaptureFields!! the implementation we are iterating over 
all captures. For that algorithm to work number of captures should be equal to 
number of fields
```
void CXXRecordDecl::getCaptureFields(
   llvm::DenseMap &Captures,
   FieldDecl *&ThisCapture) const {
  Captures.clear();
  ThisCapture = nullptr;

  LambdaDefinitionData &Lambda = getLambdaData();
  RecordDecl::field_iterator Field = field_begin();
  for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
   C != CEnd; ++C, ++Field) {
if (C->capturesThis())
  ThisCapture = *Field;
else if (C->capturesVariable())
  Captures[C->getCapturedVar()] = *Field;
  }
  assert(Field == field_end());
}
```

I dropped the defensive code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

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


[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-05-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:306
+// Set conditionally to provide correct diagnostics for 'double' type
+llvm::StringRef FP64Feature(
+getLangOpts().OpenCLVersion >= 300 ? "__opencl_c_fp64" : 
"cl_khr_fp64");

azabaznov wrote:
> Anastasia wrote:
> > Technically both "__opencl_c_fp64" and "cl_khr_fp64" are required in 
> > OpenCL, perhaps we should report both in OpenCL 3?
> Even better, can we merge this first https://reviews.llvm.org/D100976? This 
> is needed to completely remove such check for fp64.
Sure I have committed it now: 
https://reviews.llvm.org/rG769cc335e6e63e5eac0c0ac849de44714326e20b

Btw, I will also commit https://reviews.llvm.org/D101043 soon. That should 
hopefully remove the remianing confusions around pragmas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

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


[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-05-14 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 345482.
AbbasSabra added a comment.

Updating D102273 : [analyzer] Update comments 
+ fix typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp

Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 -analyzer-config exploration_strategy=unexplored_first_queue %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++11 -DDFS=1 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++14 -analyzer-config exploration_strategy=unexplored_first_queue %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++14 -DDFS=1 %s
 
 void clang_analyzer_numTimesReached();
 void clang_analyzer_warnIfReached();
@@ -511,3 +511,39 @@
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
+
+void capture_by_value_as_loop_counter() {
+  int out = 0;
+  auto l = [i = out]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_by_ref_as_loop_counter() {
+  int out = 0;
+  auto l = [&i = out]() {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
+
+void capture_implicitly_by_value_as_loop_counter() {
+  int i = 0;
+  auto l = [=]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_implicitly_by_ref_as_loop_counter() {
+  int i = 0;
+  auto l = [&]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -79,14 +79,17 @@
   return State;
 }
 
-static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
-  hasOperatorName("<="), hasOperatorName(">="),
-  hasOperatorName("!=")),
-hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
+static internal::Matcher simpleCondition(StringRef BindName,
+   StringRef RefName) {
+  return binaryOperator(
+ anyOf(hasOperatorName("<"), hasOperatorName(">"),
+   hasOperatorName("<="), hasOperatorName(">="),
+   hasOperatorName("!=")),
+ hasEitherOperand(ignoringParenImpCasts(
+ declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+ .bind(RefName))),
+ hasEitherOperand(
+ ignoringParenImpCasts(integerLiteral().bind("boundNum"
   .bind("conditionOperator");
 }
 
@@ -138,7 +141,7 @@
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
+ hasCondition(simpleCondition("initVarName", "initVarRef")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
@@ -156,17 +159,52 @@
  hasUnaryOperand(declRefExpr(
  to(varDecl(allOf(equalsBoundNode("initVarName"),
   hasType(isInteger(),
- unless(hasBody(hasSuspiciousStmt("initVarName".bind("forLoop");
+ unless(hasBody(hasSuspiciousStmt("initVarName"
+  .bind("forLoop");
 }
 
-static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables assumed as escaped variables.
+static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
+
+  // Get the lambda CXXRecordDecl
+  assert(DR->refersToEnclosingVariableOrCapture());
+  const LocationContext *LocCtxt = N->getLocationC

[PATCH] D100396: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL

2021-05-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/SYCLSupport.rst:96
  - global_space, constant_space
+   * - ``__attribute__((opencl_global_device))``
+ - global_space

I think we should extend conversion rules too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100396

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


[PATCH] D102374: [clang][Fuchsia] Turn on relative-vtables by default for Fuchsia

2021-05-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 345484.
leonardchan marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102374

Files:
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/available_externally-vtable.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/dynamic-cast.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/no-alias-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/relative-vtables-flag.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/thunk-mangling.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp

Index: clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
===
--- clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
+++ clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
@@ -151,8 +151,10 @@
 
 // Verify that virtual calls to destructors are not marked with a 'returned'
 // this parameter at the call site...
-// CHECKARM,CHECKFUCHSIA: [[VFN:%.*]] = getelementptr inbounds %class.E* (%class.E*)*, %class.E* (%class.E*)**
-// CHECKARM,CHECKFUCHSIA: [[THUNK:%.*]] = load %class.E* (%class.E*)*, %class.E* (%class.E*)** [[VFN]]
+// CHECKARM: [[VFN:%.*]] = getelementptr inbounds %class.E* (%class.E*)*, %class.E* (%class.E*)**
+// CHECKARM: [[THUNK:%.*]] = load %class.E* (%class.E*)*, %class.E* (%class.E*)** [[VFN]]
+// CHECKFUCHSIA: [[THUNK_I8:%.*]] = call i8* @llvm.load.relative.i32(i8* {{.*}}, i32 0)
+// CHECKFUCHSIA: [[THUNK:%.*]] = bitcast i8* [[THUNK_I8]] to %class.E* (%class.E*)*
 // CHECKARM,CHECKFUCHSIA: call %class.E* [[THUNK]](%class.E* {{[^,]*}} %
 
 // ...but static calls create declarations with 'returned' this
Index: clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp
@@ -2,7 +2,7 @@
 // is not dso_local. The vtable will need to be hidden and not private so it can
 // be used as acomdat key signature.
 
-// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm | FileCheck %s
 
 // CHECK: @_ZTV1B.local = linkonce_odr hidden unnamed_addr constant
 // CHECK: @_ZTV1B = linkonce_odr unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV1B.local
Index: clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
@@ -1,6 +1,6 @@
 // Check that we call llvm.load.relative() on a vtable function call.
 
-// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O3 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O3 -S -o - -emit-llvm | FileCheck %s
 
 // CHECK:  define{{.*}} void @_Z5A_fooP1A(%class.A* %a) local_unnamed_addr
 // CHECK-NEXT: entry:
Index: clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
@@ -1,7 +1,7 @@
 // Check that the pointer adjustment from th

[PATCH] D102280: [analyzer] Engine: fix crash with SEH __leave keyword

2021-05-14 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D102280#2759480 , @AbbasSabra 
wrote:

> In D102280#2759167 , @steakhal 
> wrote:
>
>> Do you have any good (mature, big enough) open-source projects for these 
>> msvc constructs?
>
> https://github.com/microsoft/winfile and 
> https://github.com/chakra-core/ChakraCore seem to be using SEH but not 
> heavily.

Well, and how can I build them on Linux xD
I tried mingw64, but failed :D

How do you use clang exactly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102280

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


[PATCH] D102175: [clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

2021-05-14 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

In D102175#2759945 , @ymandel wrote:

> Hi Felix,
> Can you clarify your concern over the warning? Is it the case that the 
> warning is not present before the fix and is only triggered after the fix?  
> I'm concerned that removing the call may have unintended side effects and I 
> would think it might better to leave the check for usage separate.  However, 
> if the fix is causing the warning then I can understand better why you want 
> to make this change.  That said, have considered replacing the var binding 
> with `(void)`, rather than deleting the statement?

Yes, the fix of converting the copied variable to a const reference introduces 
a warning when -Wall (or more specifically -Wunused) is specified and the 
variable is not used at all. The fix converts the local variable to a const 
reference. Take a const reference of an object and not using it has no 
observable side effects I think.

Here is an example of an unused, but copied variable before the fix:

https://godbolt.org/z/a5E4fMWKj

The compiler flags are "-Werror -Wall": no warnings or errors are produced.

Now after the fix:

https://godbolt.org/z/a5E4fMWKj

For more context, the assumption the check makes is that the copy is 
unnecessary. If the type executes specific side-effects in its copy-constructor 
code the type should be excluded from the check using the `AllowedTypes` 
setting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102175

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


[clang-tools-extra] fde5b24 - [clangd] Make unit test compatible with gtest 1.10.0

2021-05-14 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2021-05-14T19:37:46+02:00
New Revision: fde5b24963f42c8f21e32e1c5b19e81ddc52e575

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

LOG: [clangd] Make unit test compatible with gtest 1.10.0

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/PrintASTTests.cpp 
b/clang-tools-extra/clangd/unittests/PrintASTTests.cpp
index 9e4cc565003f4..d0e2c2406abfb 100644
--- a/clang-tools-extra/clangd/unittests/PrintASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/PrintASTTests.cpp
@@ -53,15 +53,15 @@ TEST_P(ASTUtils, PrintTemplateArgs) {
   EXPECT_THAT(V.TemplateArgsAtPoints, ElementsAreArray(Pair.Expected));
 }
 
-INSTANTIATE_TEST_CASE_P(ASTUtilsTests, ASTUtils,
-::testing::ValuesIn(std::vector({
-{
-R"cpp(
+INSTANTIATE_TEST_SUITE_P(ASTUtilsTests, ASTUtils,
+ ::testing::ValuesIn(std::vector({
+ {
+ R"cpp(
   template  class Bar {};
   template <> class ^Bar {};)cpp",
-{""}},
-{
-R"cpp(
+ {""}},
+ {
+ R"cpp(
   template  class Bar {};
   template  class Z, int Q>
@@ -69,42 +69,42 @@ INSTANTIATE_TEST_CASE_P(ASTUtilsTests, ASTUtils,
   template struct ^Foo;
   template 
   struct ^Foo {};)cpp",
-{"", ""}},
-{
-R"cpp(
+ {"", ""}},
+ {
+ R"cpp(
   template  void Foz() {};
   template <> void ^Foz<3, 5, 8>() {};)cpp",
-{"<3, 5, 8>"}},
-{
-R"cpp(
+ {"<3, 5, 8>"}},
+ {
+ R"cpp(
   template  class Bar {};
   template  class ...>
   class Aux {};
   template <> class ^Aux {};
   template  class T>
   class ^Aux {};)cpp",
-{"", ""}},
-{
-R"cpp(
+ {"", ""}},
+ {
+ R"cpp(
   template  T var = 1234;
   template <> int ^var = 1;)cpp",
-{""}},
-{
-R"cpp(
+ {""}},
+ {
+ R"cpp(
   template  struct Foo;
   struct Bar { friend class Foo; };
   template <> struct ^Foo {};)cpp",
-{""}},
-{
-R"cpp(
+ {""}},
+ {
+ R"cpp(
   template
   T S = T(10);
   template 
   int ^S = 0;
   template <>
   int ^S = 0;)cpp",
-{"", ""}},
-})), );
+ {"", ""}},
+ })));
 } // namespace
 } // namespace clangd
 } // namespace clang



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


  1   2   >