[PATCH] D79511: [ObjC] Add compatibility mode for type checking of qualified id block parameters.

2020-05-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

It looks like you didn't squash your two commits before uploading, so the diff 
for review now only includes the changes for the comment, not the complete 
patch. Other than needing to squash the commits, LGTM.

May want to wait for approval from one of the objc reviewers as well though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79511



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


[PATCH] D70351: [clang][WIP][clang-scan-deps] Add an experimental C API.

2020-05-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

@Bigcheese wondering if there are things with respect to testing we can do, to 
help the patch move forward :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70351



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


[PATCH] D79835: [Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

2020-05-12 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added a reviewer: phosek.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Follow the model used on Linux, where the clang driver passes the
linker a `-u` switch to force the profile runtime to be linked in,
rather than having every TU emit a dead function with a reference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79835

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-fuchsia/libclang_rt.profile.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-fuchsia/libclang_rt.profile.a
  clang/test/Driver/fuchsia.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll


Index: llvm/test/Instrumentation/InstrProfiling/linkage.ll
===
--- llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -2,9 +2,11 @@
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck 
%s --check-prefixes=POSIX,MACHO
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s 
--check-prefixes=POSIX,LINUX
+; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -instrprof -S | FileCheck %s 
--check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s 
--check-prefixes=COFF
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | 
FileCheck %s --check-prefixes=POSIX,MACHO
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck 
%s --check-prefixes=POSIX,LINUX
+; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | 
FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | 
FileCheck %s --check-prefixes=COFF
 
 ; MACHO: @__llvm_profile_runtime = external global i32
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1036,7 +1036,7 @@
 bool InstrProfiling::emitRuntimeHook() {
   // We expect the linker to be invoked with -u flag for linux,
   // for which case there is no need to emit the user function.
-  if (TT.isOSLinux())
+  if (TT.isOSLinux() || TT.isOSFuchsia())
 return false;
 
   // If the module's provided its own runtime, we don't need to do anything.
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -242,3 +242,21 @@
 // RUN: -gsplit-dwarf -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
 // CHECK-SPLIT-DWARF: "-split-dwarf-output" "fuchsia.dwo"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-AARCH64
+// CHECK-PROFRT-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-AARCH64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.profile.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-X86_64
+// CHECK-PROFRT-X86_64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-X86_64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-X86_64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}libclang_rt.profile.a"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -69,6 +69,9 @@
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
   CXXStdlibType
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -15,6 +15,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include 

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-05-12 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 263590.
asbirlea marked 3 inline comments as done.
asbirlea added a comment.

Address comments.
Thank you for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop , LoopAnalysisManager ,
 LoopStandardAnalysisResults ) {
 auto  = AM.getResult(L, AR);
-auto  = FAMP.getManager();
 Function  = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int , int ,
-   int ,
+   int , ModuleAnalysisManager ,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function , FunctionAnalysisManager ) {
 ++RunCount;
 
-const ModuleAnalysisManager  =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto  = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int 
   int 
   int 
+  ModuleAnalysisManager 
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));
 FPM.addPass(TestInvalidationFunctionPass("f"));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
@@ -482,7 +487,7 @@
   {
 FunctionPassManager 

[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: jkorous.
Herald added subscribers: ributzka, dexonsmith.
Herald added a project: clang.

[clang][Preprocessor] Replace the slow translateFile call by a new, faster 
isMainFile check

  
  The commit 3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0 introduced the check that 
checks if we're
  trying to re-enter a main file when building a preamble. Unfortunately this 
slowed down the preamble
  compilation by 80-90% in some test cases, as translateFile is really slow. 
This change checks
  to see if the FileEntry is the main file without calling translateFile, but 
by using the new
  isMainFile check instead. This speeds up preamble building by 1.5-2x for 
certain test cases that we have.
  
  rdar://59361291


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79834

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


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(>getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -373,6 +373,7 @@
 
 void SourceManager::clearIDTables() {
   MainFileID = FileID();
+  CachedMainFileEntry = None;
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
   SLocEntryLoaded.clear();
@@ -389,6 +390,15 @@
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  if (!CachedMainFileEntry) {
+CachedMainFileEntry = getFileEntryRefForID(MainFileID);
+assert(CachedMainFileEntry && "missing file entry for main file");
+  }
+  return CachedMainFileEntry->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -35,6 +35,7 @@
 #define LLVM_CLANG_BASIC_SOURCEMANAGER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
@@ -59,9 +60,6 @@
 
 class ASTReader;
 class ASTWriter;
-class FileManager;
-class FileEntry;
-class FileEntryRef;
 class LineTableInfo;
 class SourceManager;
 
@@ -706,6 +704,9 @@
   /// The file ID for the main source file of the translation unit.
   FileID MainFileID;
 
+  /// The file entry for the main source file.
+  Optional CachedMainFileEntry;
+
   /// The file ID for the precompiled preamble there is one.
   FileID PreambleFileID;
 
@@ -813,6 +814,9 @@
 MainFileID = FID;
   }
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  bool isMainFile(FileEntryRef SourceFile);
+
   /// Set the file ID for the precompiled preamble.
   void setPreambleFileID(FileID Preamble) {
 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(>getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -373,6 +373,7 @@
 
 void SourceManager::clearIDTables() {
   MainFileID = FileID();
+  CachedMainFileEntry = None;
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
   SLocEntryLoaded.clear();
@@ -389,6 +390,15 @@
   

[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-12 Thread Wei Zhao via Phabricator via cfe-commits
wxz2020 updated this revision to Diff 263582.
wxz2020 added a comment.

Correct the wrong version of llvm/unittests/Support/TargetParserTest.cpp which 
causes the test failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129

Files:
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64SchedA53.td
  llvm/lib/Target/AArch64/AArch64SchedA57.td
  llvm/lib/Target/AArch64/AArch64SchedCyclone.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM3.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM4.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM5.td
  llvm/lib/Target/AArch64/AArch64SchedFalkor.td
  llvm/lib/Target/AArch64/AArch64SchedKryo.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX2T99.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX3T110.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/aarch64-combine-fmul-fsub.mir
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
  llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -942,6 +942,13 @@
   "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD, "8.1-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "thunderx3t110", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD |
+  AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RAND |
+  AArch64::AEK_RCPC,
+  "8.3-A"));
   EXPECT_TRUE(testAArch64CPU(
   "thunderx", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
@@ -983,7 +990,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 38;
+static constexpr unsigned NumAArch64CPUArchs = 39;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/remat.ll
===
--- llvm/test/CodeGen/AArch64/remat.ll
+++ llvm/test/CodeGen/AArch64/remat.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx2t99 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=tsv110 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mattr=+custom-cheap-as-move -o - %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx3t110 -o - %s | FileCheck %s
 
 %X = type { i64, i64, i64 }
 declare void @f(%X*)
Index: llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
===
--- llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
+++ llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt83 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt88 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx2t99 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
+; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx3t110 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=exynos-m3 < %s | FileCheck --check-prefixes=ALIGN5,CHECK %s
 
 define void @test() {
Index: llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
===
--- llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
+++ llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
@@ -6,6 +6,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=exynos-m3  < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=kryo   < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx2t99 < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx3t110 < %s | FileCheck %s
 
 ; Make sure that inst-combine fuses the multiply add in the addressing mode of
 ; the load.
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -24,6 +24,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=saphira 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=kryo 2>&1 | 

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D79704#2032271 , @NoQ wrote:

> Blanket reply! `ParamRegion` is not a `DeclRegion` because it does not 
> necessarily have a corresponding `Decl`. For instance, when calling a 
> function through an unknown function pointer, you don't have the declaration 
> of a function, let alone its parameters.


Well hold on for a second then -- how is this, if it is, different for member 
pointers? Aren't they represented with a `VarRegion`?

> But for parameters of C++ object type you still need your `ParamRegion` 
> because arguments are constructed into it.

Could you give a specific code example?

Since this patch isn't WIP, lets add unit tests that shows the added interface, 
highlighting pain points such as this.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79677: [clang][OpenMP][OMPIRBuilder] Adding some Privatization clauses to OpenMP `parallel` Directive

2020-05-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Generally you copied the existing Clang logic, correct?




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:803
-  OrigVD);
-else
-  (void)CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(*this,

Wasn't this part of D79675?

(btw I tried to comprehend why this is needed and it is on my list for things 
we replace eventually).



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:887
   *this, OrigVD);
+
   llvm::Value *V = EmitLoadOfScalar(

Please undo as it doesn't seem to change anything.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3736
   HintInst =
-  Builder.CreateIntCast(EmitScalarExpr(Hint), CGM.Int32Ty, false);
+  Builder.CreateIntCast(EmitScalarExpr(Hint), CGM.IntPtrTy, false);
 

These 4 lines can go in on their own, LGTM on them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677



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


[PATCH] D79676: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-05-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:878
+  [this, VDInit, OriginalAddr, VD, ThisFirstprivateIsLastprivate,
+   OrigVD, , IRef, ]() {
 // Emit private VarDecl with copy init.

Is this needed?



Comment at: clang/lib/CodeGen/CodeGenFunction.h:1549
+  // region body, and finalization codegen callbacks. This will class will also
+  // contain privatization functions used by the privatization call backs
+  struct OMPBuilderCBHelpers {

Nit: Make it a doxygen comment with 3x`/`, -`will` + full stop.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:1561
+
+private:
+  llvm::CallInst *RTLFnCI;

Nit: No need.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:1581
+++I;
+
+  return &*I;

What is wrong with `BB->getFirstNonPHIOrDbgOrLifetime()`? If it is to avoid too 
many test changes, please add a TODO. I think from a functional perspective 
there is no need to advance it after the first set of allocas that may be 
separated from the phis by non-allocas?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79676



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D79675#2032764 , @fghanim wrote:

> This is a small patch as it is. splitting it any further would make it very 
> very small :D


Very small is great, then I can accept it fast, finding enough time to read 
larger patches is part of why it takes me so long to do reviews.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:101
+extern Type *IntPtrTy;
+extern Type *SizeTy;
+

jdoerfert wrote:
> I can totally see why we need `int` and `size_t` but I'm not sure about the 
> others.
> `void` is universally translated to `i8*` Adding a pointer to a type should 
> be done in OMPKinds.def, something like:
> ```
> #define __OMP_PTR_TYPE(NAME, BASE) OMP_TYPE(NAME, Base->getPointerTo());
> __OMP_PTR_TYPE(VoidPtr, Int8)
> __OMP_PTR_TYPE(VoidPtrPtr, VoidPtr)
> ```
My proposed scheme for the pointers was integrated in D79739 and will be 
commited shortly.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

fghanim wrote:
> jdoerfert wrote:
> > I think this was correct before:
> > ```
> >   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 
> > global_tid, kmp_critical_name *, uint32_t hint);
> > ```
> Nop, it's supposed to be whatever `IntPtrTy` is in the frontend (i.e. 32 for 
> 32bit, 64 for 64bit).
> 
> `IntPtrTy` is actually a union with `sizety` in `CodeGenModule`
I'm confused. I copied the declaration above from the runtime. It doesn't 
contain an `IntPtrTy` or similar. I agree that `IntPtrTy` is machine dependent 
and we need your initializers. What I tried to say is that at least one 
declaration in the runtime has `__kmpc_critical_with_hint` with an int32 as 
last argument. That said, the runtime is not shy of incompatible declarations 
for functions.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:122
+  }
+}
+

fghanim wrote:
> jdoerfert wrote:
> > (I doubt we need the `initVoidPtr` function but if we do, the condition 
> > looks wrong)
> Forgot to refractor when I changed names.
> 
> Regarding `void*` , I am not sure how it is defined in fortran. That's why I 
> made it possible to initialize it separately.
I see. Let's cross that bridge once we get to it.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1013
+  return Builder.CreateCall(Fn, Args);
+}
+

fghanim wrote:
> jdoerfert wrote:
> > I think we should have a unit test for each of these.
> > 
> > Style: drop the `llvm::`, not needed.
> Aside from `CreateCopyinclauseblocks()`, I couldn't think of a unittest for 
> the others, all they do is create a runtime call based on the passed arg. 
> That's why I didn't do it already.
Let's test that one then :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-12 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang created this revision.
LukeZhuang added reviewers: RKSimon, phosek, gribozavr, davidxl, chandlerc, 
pete, jyknight, dblaikie, kuba.
LukeZhuang added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, hiraditya.

Add a new builtin-function `__builtin_expect_with_probability` and intrinsic 
`llvm.expect.with.probability`.
The interface is `__builtin_expect_with_probability(long expr, long expected, 
double probability)`.
It is mainly the same as `__builtin_expect` besides one more argument 
indicating the probability of expression equal to expected value. The 
probability should be a constant floating-point expression and be in range 
[0.0, 1.0] inclusive.
It is similar to builtin-expect-with-probability function in GCC built-in 
functions .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79830

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin-expect-with-probability-switch.c
  clang/test/CodeGen/builtin-expect-with-probability.c
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp

Index: clang/test/CodeGen/builtin-expect-with-probability.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-expect-with-probability.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -O1 | FileCheck %s
+
+int expect_taken(int x) {
+// CHECK: !{{[0-9]+}} = !{!"branch_weights", i32 1932735283, i32 214748366}
+
+	if (__builtin_expect_with_probability (x == 100, 1, 0.9)) {
+		return 0;
+	}
+	return x;
+}
+
Index: clang/test/CodeGen/builtin-expect-with-probability-switch.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-expect-with-probability-switch.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -O1 | FileCheck %s
+
+int expect_taken(int x) {
+// CHECK: !{{[0-9]+}} = !{!"branch_weights", i32 107374184, i32 107374184, i32 1717986918, i32 107374184, i32 107374184}
+	switch(__builtin_expect_with_probability(x, 1, 0.8)) {
+		case 0:
+			x = x + 0;
+		case 1:
+			x = x + 1;
+		case 2:
+			x = x + 2;
+		case 5:
+			x = x + 5;
+		default:
+			x = x + 6;
+	}
+	return x;
+}
+
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2039,6 +2039,37 @@
 Builder.CreateCall(FnExpect, {ArgValue, ExpectedValue}, "expval");
 return RValue::get(Result);
   }
+  case Builtin::BI__builtin_expect_with_probability: {
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+llvm::Type *ArgType = ArgValue->getType();
+
+Value *ExpectedValue = EmitScalarExpr(E->getArg(1));
+Value *Confidence = EmitScalarExpr(E->getArg(2));
+ConstantFP *Confidence_f = dyn_cast(Confidence);
+if (!Confidence_f) {
+  CGM.Error(E->getArg(2)->getLocStart(),
+"probability of __builtin_expect_with_probability must be "
+"constant floating-point expression");
+} else {
+  double prob = Confidence_f->getValueAPF().convertToDouble();
+  if (prob < 0.0 || prob > 1.0) {
+CGM.Error(E->getArg(2)->getLocStart(),
+  "probability of __builtin_expect_with_probability is "
+  "outside the range [0.0, 1.0]");
+  }
+}
+// Don't generate llvm.expect.with.probability on -O0 as the backend
+// won't use it for anything.
+// Note, we still IRGen ExpectedValue because it could have side-effects.
+if (CGM.getCodeGenOpts().OptimizationLevel == 0)
+  return RValue::get(ArgValue);
+
+Value *FnExpect =
+CGM.getIntrinsic(Intrinsic::expect_with_probability, ArgType);
+Value *Result = Builder.CreateCall(
+FnExpect, {ArgValue, ExpectedValue, Confidence}, "expval");
+return RValue::get(Result);
+  }
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -562,6 +562,7 @@
 
 BUILTIN(__builtin_unpredictable, "LiLi"   , "nc")
 BUILTIN(__builtin_expect, "LiLiLi"   , "nc")
+BUILTIN(__builtin_expect_with_probability, "LiLiLid"   , "nc")
 BUILTIN(__builtin_prefetch, "vvC*.", "nc")
 BUILTIN(__builtin_readcyclecounter, "ULLi", "n")
 BUILTIN(__builtin_trap, "v", "nr")
Index: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
===
--- llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -54,13 +54,32 @@
 "unlikely-branch-weight", cl::Hidden, cl::init(1),
 

[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-05-12 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb22ab740355: Add nomerge function attribute to supress tail 
merge optimization in simplifyCFG (authored by zequanwu, committed by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D78659?vs=262977=263576#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78659

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/SimplifyCFG/nomerge.ll

Index: llvm/test/Transforms/SimplifyCFG/nomerge.ll
===
--- /dev/null
+++ llvm/test/Transforms/SimplifyCFG/nomerge.ll
@@ -0,0 +1,71 @@
+; RUN: opt < %s -O1 -S | FileCheck %s
+
+; The attribute nomerge prevents the 3 bar() calls from being sunk/hoisted into 
+; one inside a function. Check that there are still 3 tail calls.
+
+; Test case for preventing sinking
+; CHECK-LABEL: define void @sink
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @bar()
+; CHECK: if.then2:
+; CHECK-NEXT: tail call void @bar()
+; CHECK: if.end3:
+; CHECK-NEXT: tail call void @bar()
+define void @sink(i32 %i) {
+entry:
+  switch i32 %i, label %if.end3 [
+i32 5, label %if.then
+i32 7, label %if.then2
+  ]
+
+if.then:
+  tail call void @bar() #0
+  br label %if.end3
+
+if.then2:
+  tail call void @bar() #0
+  br label %if.end3
+
+if.end3:
+  tail call void @bar() #0
+  ret void
+}
+
+; Test case for preventing hoisting
+; CHECK-LABEL: define void @hoist
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @bar()
+; CHECK: if.then2:
+; CHECK-NEXT: tail call void @bar()
+; CHECK: if.end:
+; CHECK-NEXT: tail call void @bar()
+define void @hoist(i32 %i) {
+entry:
+  %i.addr = alloca i32, align 4
+  store i32 %i, i32* %i.addr, align 4
+  %0 = load i32, i32* %i.addr, align 4
+  %cmp = icmp eq i32 %0, 5
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+  tail call void @bar() #1
+  unreachable
+
+if.else:
+  %1 = load i32, i32* %i.addr, align 4
+  %cmp1 = icmp eq i32 %i, 7
+  br i1 %cmp1, label %if.then2, label %if.end
+
+if.then2:
+  tail call void @bar() #1
+  unreachable
+
+if.end:
+  tail call void @bar() #1
+  unreachable
+}
+
+declare void @bar()
+
+attributes #0 = { nomerge }
+attributes #1 = { noreturn nomerge }
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1300,6 +1300,14 @@
 if (!TTI.isProfitableToHoist(I1) || !TTI.isProfitableToHoist(I2))
   return Changed;
 
+// If any of the two call sites has nomerge attribute, stop hoisting.
+if (const auto *CB1 = dyn_cast(I1))
+  if (CB1->cannotMerge())
+return Changed;
+if (const auto *CB2 = dyn_cast(I2))
+  if (CB2->cannotMerge())
+return Changed;
+
 if (isa(I1) || isa(I2)) {
   assert (isa(I1) && isa(I2));
   // The debug location is an integral part of a debug info intrinsic
@@ -1485,8 +1493,9 @@
 // Conservatively return false if I is an inline-asm instruction. Sinking
 // and merging inline-asm instructions can potentially create arguments
 // that cannot satisfy the inline-asm constraints.
+// If the instruction has nomerge attribute, return false.
 if (const auto *C = dyn_cast(I))
-  if (C->isInlineAsm())
+  if (C->isInlineAsm() || C->cannotMerge())
 return false;
 
 // Each instruction must have zero or one use.
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -874,6 +874,7 @@
   case Attribute::NoAlias:
   case Attribute::NoBuiltin:
   case Attribute::NoCapture:
+  case Attribute::NoMerge:
   case Attribute::NoReturn:
   case Attribute::NoSync:
   case Attribute::None:
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1514,6 +1514,7 @@
 /// Return true if this attribute kind only applies to functions.
 static bool isFuncOnlyAttr(Attribute::AttrKind Kind) {
   switch (Kind) {
+  case Attribute::NoMerge:
   case Attribute::NoReturn:
   case Attribute::NoSync:
   case Attribute::WillReturn:
Index: llvm/lib/IR/Attributes.cpp

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:7899
+if (FpPragmaCurrentLocation.isInvalid()) {
+  assert(*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue &&
+ "Expected a default pragma float_control value");

This changes the behavior regarding AST reader and seems to be too hash 
restriction. Essentially this requires a pch can only be used with the same fp 
options with which the pch is generated. Since there are lots of fp options, it 
is impractical to generate pch for all the combinations.

We have seen regressions due to this assertion.

Can this assertion be dropped or done under some options?

Thanks.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-05-12 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM other than two nits here, this is really awesome!




Comment at: llvm/include/llvm/Analysis/CGSCCPassManager.h:856-858
+auto *ResultFAMCP =
+(*C, CG);
+ResultFAMCP->updateFAM(FAM);

asbirlea wrote:
> chandlerc wrote:
> > Check that it doesn't hit an assert failure, but I think you can remove 
> > this one.
> Removing this hits the assertion.
Dunno what I was thinking. Of course it does.

Anyways, skip the variable and just update the result directly?



Comment at: llvm/include/llvm/Analysis/CGSCCPassManager.h:908
+// result.
+ResultFAMCP =
+(*C, CG);

Similar to above, skip the variable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72893



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-12 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked 5 inline comments as done.
fghanim added a comment.

This is a small patch as it is. splitting it any further would make it very 
very small :D




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

jdoerfert wrote:
> I think this was correct before:
> ```
>   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 global_tid, 
> kmp_critical_name *, uint32_t hint);
> ```
Nop, it's supposed to be whatever `IntPtrTy` is in the frontend (i.e. 32 for 
32bit, 64 for 64bit).

`IntPtrTy` is actually a union with `sizety` in `CodeGenModule`



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:122
+  }
+}
+

jdoerfert wrote:
> (I doubt we need the `initVoidPtr` function but if we do, the condition looks 
> wrong)
Forgot to refractor when I changed names.

Regarding `void*` , I am not sure how it is defined in fortran. That's why I 
made it possible to initialize it separately.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:594
+  // PRegPreFiniTI->getSuccessor(0) == PRegExitBB &&
+  // "Unexpected CFG structure!");
 

jdoerfert wrote:
> Preferably we would have a modified assertion. If that is too cumbersome, we 
> can probably remove it. 
I was going to remove it actually. When running Dtor over an array, clang emits 
some loop logic that makes this untrue.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1013
+  return Builder.CreateCall(Fn, Args);
+}
+

jdoerfert wrote:
> I think we should have a unit test for each of these.
> 
> Style: drop the `llvm::`, not needed.
Aside from `CreateCopyinclauseblocks()`, I couldn't think of a unittest for the 
others, all they do is create a runtime call based on the passed arg. That's 
why I didn't do it already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D72534: Change default traversal in AST Matchers to ignore invisible nodes

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263552.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72534

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ParentMapContext.h


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -249,7 +249,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -249,7 +249,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72534: Change default traversal in AST Matchers to ignore invisible nodes

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263551.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72534

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ParentMapContext.h


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -249,7 +249,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the `ignoringImplicit()` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -249,7 +249,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the `ignoringImplicit()` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-12 Thread Wei Zhao via Phabricator via cfe-commits
wxz2020 updated this revision to Diff 263543.
wxz2020 added a comment.

1. in clang/test/Driver/aarch64-cpus.c, expanded the the same tests for 
thunderx2t99 to thunderx3t110
2. in llvm/unittest/Support/TargetParserTest.cpp, fix the missing target 
features

So far all the existing issues are fixed according to review feedbacks

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129

Files:
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64SchedA53.td
  llvm/lib/Target/AArch64/AArch64SchedA57.td
  llvm/lib/Target/AArch64/AArch64SchedCyclone.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM3.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM4.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM5.td
  llvm/lib/Target/AArch64/AArch64SchedFalkor.td
  llvm/lib/Target/AArch64/AArch64SchedKryo.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX2T99.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX3T110.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/aarch64-combine-fmul-fsub.mir
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
  llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -942,6 +942,12 @@
   "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD, "8.1-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "thunderx3t110", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD |
+  AArch64::AEK_PROFILE | AArch64::AEK_RAS,
+  "8.3-A"));
   EXPECT_TRUE(testAArch64CPU(
   "thunderx", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
@@ -983,7 +989,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 38;
+static constexpr unsigned NumAArch64CPUArchs = 39;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/remat.ll
===
--- llvm/test/CodeGen/AArch64/remat.ll
+++ llvm/test/CodeGen/AArch64/remat.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx2t99 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=tsv110 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mattr=+custom-cheap-as-move -o - %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx3t110 -o - %s | FileCheck %s
 
 %X = type { i64, i64, i64 }
 declare void @f(%X*)
Index: llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
===
--- llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
+++ llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt83 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt88 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx2t99 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
+; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx3t110 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=exynos-m3 < %s | FileCheck --check-prefixes=ALIGN5,CHECK %s
 
 define void @test() {
Index: llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
===
--- llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
+++ llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
@@ -6,6 +6,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=exynos-m3  < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=kryo   < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx2t99 < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx3t110 < %s | FileCheck %s
 
 ; Make sure that inst-combine fuses the multiply add in the addressing mode of
 ; the load.
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -24,6 +24,7 @@
 ; RUN: llc < %s 

[PATCH] D79511: [ObjC] Add compatibility mode for type checking of qualified id block parameters.

2020-05-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 263544.
vsapsai added a comment.

Make compatibility mode accept correct types per James' Y Knight helpful 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79511

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaObjC/block-type-safety.m


Index: clang/test/SemaObjC/block-type-safety.m
===
--- clang/test/SemaObjC/block-type-safety.m
+++ clang/test/SemaObjC/block-type-safety.m
@@ -167,7 +167,7 @@
 void (^blockWithParam)(NSAllArray *);
 void (^genericBlockWithParam)(id);
 genericBlockWithParam = blockWithParam;
-blockWithParam = genericBlockWithParam; // expected-error {{incompatible 
block pointer types assigning to 'void (^)(NSAllArray *)' from 'void 
(^)(id)'}}
+blockWithParam = genericBlockWithParam;
 return 0;
 }
 #endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8501,7 +8501,11 @@
 
   if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) {
 if (getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
-  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false));
+  // Use for block parameters previous type checking for compatibility.
+  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false) ||
+// Or corrected type checking as in non-compat mode.
+(!BlockReturnType &&
+ ObjCQualifiedIdTypesAreCompatible(RHSOPT, LHSOPT, 
false)));
 else
   return finish(ObjCQualifiedIdTypesAreCompatible(
   (BlockReturnType ? LHSOPT : RHSOPT),


Index: clang/test/SemaObjC/block-type-safety.m
===
--- clang/test/SemaObjC/block-type-safety.m
+++ clang/test/SemaObjC/block-type-safety.m
@@ -167,7 +167,7 @@
 void (^blockWithParam)(NSAllArray *);
 void (^genericBlockWithParam)(id);
 genericBlockWithParam = blockWithParam;
-blockWithParam = genericBlockWithParam; // expected-error {{incompatible block pointer types assigning to 'void (^)(NSAllArray *)' from 'void (^)(id)'}}
+blockWithParam = genericBlockWithParam;
 return 0;
 }
 #endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8501,7 +8501,11 @@
 
   if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) {
 if (getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
-  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false));
+  // Use for block parameters previous type checking for compatibility.
+  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false) ||
+// Or corrected type checking as in non-compat mode.
+(!BlockReturnType &&
+ ObjCQualifiedIdTypesAreCompatible(RHSOPT, LHSOPT, false)));
 else
   return finish(ObjCQualifiedIdTypesAreCompatible(
   (BlockReturnType ? LHSOPT : RHSOPT),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72531: Set traversal explicitly where needed in tests

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263540.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72531

Files:
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/SourceLocationTest.cpp
  clang/unittests/AST/StmtPrinterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp
  clang/unittests/Tooling/RefactoringCallbacksTest.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -60,7 +60,8 @@
 return llvm::None;
   }
   ASTContext  = AstUnit->getASTContext();
-  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  auto Matches = ast_matchers::match(
+  traverse(ast_type_traits::TK_AsIs, wrapMatcher(Matcher)), Context);
   // We expect a single, exact match for the statement.
   if (Matches.size() != 1) {
 ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
@@ -333,9 +334,10 @@
   int foo() { return this->x; }
 };
   )cc";
-  auto StmtMatch =
-  matchStmt(Snippet, returnStmt(hasReturnValue(ignoringImplicit(memberExpr(
- hasObjectExpression(expr().bind("obj")));
+  auto StmtMatch = matchStmt(
+  Snippet, traverse(ast_type_traits::TK_AsIs,
+returnStmt(hasReturnValue(ignoringImplicit(memberExpr(
+hasObjectExpression(expr().bind("obj";
   ASSERT_TRUE(StmtMatch);
   const Stencil Stencil = access("obj", "field");
   EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Index: clang/unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- clang/unittests/Tooling/RefactoringCallbacksTest.cpp
+++ clang/unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -22,7 +22,7 @@
  const T , RefactoringCallback ) {
   std::map FileToReplace;
   ASTMatchRefactorer Finder(FileToReplace);
-  Finder.addMatcher(AMatcher, );
+  Finder.addMatcher(traverse(ast_type_traits::TK_AsIs, AMatcher), );
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory());
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -46,6 +46,7 @@
   ASTContext  = ASTUnit->getASTContext();
   assert(!Context.getDiagnostics().hasErrorOccurred() && "Compilation error");
 
+  TraversalKindScope RAII(Context, ast_type_traits::TK_AsIs);
   auto Matches = ast_matchers::match(Matcher, Context);
   // We expect a single, exact match.
   assert(Matches.size() != 0 && "no matches found");
Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -54,6 +54,7 @@
 bool isMutated(const SmallVectorImpl , ASTUnit *AST) {
   const auto *const S = selectFirst("stmt", Results);
   const auto *const E = selectFirst("expr", Results);
+  TraversalKindScope RAII(AST->getASTContext(), ast_type_traits::TK_AsIs);
   return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E);
 }
 
Index: clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -507,8 +507,10 @@
 
 TEST_F(RegistryTest, ParenExpr) {
   Matcher Value = constructMatcher("parenExpr").getTypedMatcher();
-  EXPECT_TRUE(matches("int i = (1);", Value));
-  EXPECT_FALSE(matches("int i = 1;", Value));
+  EXPECT_TRUE(
+  matches("int i = (1);", traverse(ast_type_traits::TK_AsIs, Value)));
+  EXPECT_FALSE(
+  matches("int i = 1;", traverse(ast_type_traits::TK_AsIs, Value)));
 }
 
 TEST_F(RegistryTest, EqualsMatcher) {
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -373,7 +373,8 @@
   EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
   EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
 
-  CallMethodX = callExpr(callee(cxxConversionDecl()));
+  

[PATCH] D72532: Make the ExprMutationAnalyzer explicit about how it traverses the AST

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263541.
steveire added a comment.
Herald added a subscriber: ASDenysPetrov.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72532

Files:
  clang/lib/Analysis/ExprMutationAnalyzer.cpp


Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -280,13 +280,15 @@
   const auto AsNonConstRefReturn = returnStmt(hasReturnValue(
 
maybeEvalCommaExpr(equalsNode(Exp;
 
-  const auto Matches =
-  match(findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, 
AsNonConstThis,
-   AsAmpersandOperand, AsPointerFromArrayDecay,
-   AsOperatorArrowThis, AsNonConstRefArg,
-   AsLambdaRefCaptureInit, AsNonConstRefReturn))
-.bind("stmt")),
-Stm, Context);
+  const auto Matches = match(
+  traverse(
+  ast_type_traits::TK_AsIs,
+  findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
+ AsAmpersandOperand, AsPointerFromArrayDecay,
+ AsOperatorArrowThis, AsNonConstRefArg,
+ AsLambdaRefCaptureInit, AsNonConstRefReturn))
+  .bind("stmt"))),
+  Stm, Context);
   return selectFirst("stmt", Matches);
 }
 
@@ -385,12 +387,15 @@
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
   const auto Matches = match(
-  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
+  traverse(
+  ast_type_traits::TK_AsIs,
+  findAll(
+  expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
   unless(callee(namedDecl(hasAnyName(
   "::std::move", "::std::forward"),
  cxxConstructExpr(NonConstRefParam, IsInstantiated,
   FuncDecl)))
-  .bind(NodeID::value)),
+  .bind(NodeID::value))),
   Stm, Context);
   for (const auto  : Matches) {
 const auto *Exp = Nodes.getNodeAs(NodeID::value);


Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -280,13 +280,15 @@
   const auto AsNonConstRefReturn = returnStmt(hasReturnValue(
 maybeEvalCommaExpr(equalsNode(Exp;
 
-  const auto Matches =
-  match(findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
-   AsAmpersandOperand, AsPointerFromArrayDecay,
-   AsOperatorArrowThis, AsNonConstRefArg,
-   AsLambdaRefCaptureInit, AsNonConstRefReturn))
-.bind("stmt")),
-Stm, Context);
+  const auto Matches = match(
+  traverse(
+  ast_type_traits::TK_AsIs,
+  findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
+ AsAmpersandOperand, AsPointerFromArrayDecay,
+ AsOperatorArrowThis, AsNonConstRefArg,
+ AsLambdaRefCaptureInit, AsNonConstRefReturn))
+  .bind("stmt"))),
+  Stm, Context);
   return selectFirst("stmt", Matches);
 }
 
@@ -385,12 +387,15 @@
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
   const auto Matches = match(
-  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
+  traverse(
+  ast_type_traits::TK_AsIs,
+  findAll(
+  expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
   unless(callee(namedDecl(hasAnyName(
   "::std::move", "::std::forward"),
  cxxConstructExpr(NonConstRefParam, IsInstantiated,
   FuncDecl)))
-  .bind(NodeID::value)),
+  .bind(NodeID::value))),
   Stm, Context);
   for (const auto  : Matches) {
 const auto *Exp = Nodes.getNodeAs(NodeID::value);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73037: Add a way to set traversal mode in clang-query

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263536.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73037

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QueryParser.h
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -110,6 +110,13 @@
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(::BindRoot, cast >(Q)->Var);
   EXPECT_EQ(true, cast >(Q)->Value);
+
+  Q = parse("set traversal AsIs");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(::TK,
+cast>(Q)->Var);
+  EXPECT_EQ(ast_type_traits::TK_AsIs,
+cast>(Q)->Value);
 }
 
 TEST_F(QueryParserTest, Match) {
@@ -197,6 +204,11 @@
   EXPECT_EQ("utput ", Comps[0].TypedText);
   EXPECT_EQ("output", Comps[0].DisplayText);
 
+  Comps = QueryParser::complete("set t", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("raversal ", Comps[0].TypedText);
+  EXPECT_EQ("traversal", Comps[0].DisplayText);
+
   Comps = QueryParser::complete("enable ", 7, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("output ", Comps[0].TypedText);
@@ -214,6 +226,16 @@
   EXPECT_EQ("dump ", Comps[3].TypedText);
   EXPECT_EQ("dump", Comps[3].DisplayText);
 
+  Comps = QueryParser::complete("set traversal ", 14, QS);
+  ASSERT_EQ(3u, Comps.size());
+
+  EXPECT_EQ("AsIs ", Comps[0].TypedText);
+  EXPECT_EQ("AsIs", Comps[0].DisplayText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses ", Comps[1].TypedText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses", Comps[1].DisplayText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[2].TypedText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[2].DisplayText);
+
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("Stmt(", Comps[0].TypedText);
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -25,7 +26,7 @@
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false) {}
+Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}
 
   llvm::ArrayRef> ASTs;
 
@@ -36,6 +37,8 @@
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
+
+  ast_type_traits::TraversalKind TK;
   llvm::StringMap NamedValues;
 };
 
Index: clang-tools-extra/clang-query/QueryParser.h
===
--- clang-tools-extra/clang-query/QueryParser.h
+++ clang-tools-extra/clang-query/QueryParser.h
@@ -43,6 +43,8 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  QueryRef
+  parseSetTraversalKind(ast_type_traits::TraversalKind QuerySession::*Var);
   template  QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -128,6 +128,24 @@
   llvm_unreachable("Invalid output kind");
 }
 
+QueryRef QueryParser::parseSetTraversalKind(
+ast_type_traits::TraversalKind QuerySession::*Var) {
+  StringRef ValStr;
+  unsigned Value =
+  LexOrCompleteWord(this, ValStr)
+  .Case("AsIs", ast_type_traits::TK_AsIs)
+  .Case("IgnoreImplicitCastsAndParentheses",
+ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
+  .Case("IgnoreUnlessSpelledInSource",
+ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  .Default(~0u);
+  if (Value == ~0u) {
+return new InvalidQuery("expected traversal kind, got '" + ValStr + "'");
+  }
+  return new SetQuery(
+  Var, static_cast(Value));
+}
+
 QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.drop_while(
@@ -171,7 +189,8 @@
   PQV_Invalid,
   PQV_Output,
   PQV_BindRoot,
-  PQV_PrintMatcher
+  PQV_PrintMatcher,
+  PQV_Traversal
 };
 
 QueryRef 

[PATCH] D73037: Add a way to set traversal mode in clang-query

2020-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 263535.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73037

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QueryParser.h
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -110,6 +110,11 @@
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(::BindRoot, cast >(Q)->Var);
   EXPECT_EQ(true, cast >(Q)->Value);
+
+  Q = parse("set traversal AsIs");
+  ASSERT_TRUE(isa >(Q));
+  EXPECT_EQ(::TK, cast >(Q)->Var);
+  EXPECT_EQ(ast_type_traits::TK_AsIs, cast >(Q)->Value);
 }
 
 TEST_F(QueryParserTest, Match) {
@@ -197,6 +202,11 @@
   EXPECT_EQ("utput ", Comps[0].TypedText);
   EXPECT_EQ("output", Comps[0].DisplayText);
 
+  Comps = QueryParser::complete("set t", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("raversal ", Comps[0].TypedText);
+  EXPECT_EQ("traversal", Comps[0].DisplayText);
+
   Comps = QueryParser::complete("enable ", 7, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("output ", Comps[0].TypedText);
@@ -214,6 +224,16 @@
   EXPECT_EQ("dump ", Comps[3].TypedText);
   EXPECT_EQ("dump", Comps[3].DisplayText);
 
+  Comps = QueryParser::complete("set traversal ", 14, QS);
+  ASSERT_EQ(3u, Comps.size());
+
+  EXPECT_EQ("AsIs ", Comps[0].TypedText);
+  EXPECT_EQ("AsIs", Comps[0].DisplayText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses ", Comps[1].TypedText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses", Comps[1].DisplayText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[2].TypedText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[2].DisplayText);
+
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("Stmt(", Comps[0].TypedText);
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -25,7 +26,7 @@
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false) {}
+Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}
 
   llvm::ArrayRef> ASTs;
 
@@ -36,6 +37,8 @@
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
+
+  ast_type_traits::TraversalKind TK;
   llvm::StringMap NamedValues;
 };
 
Index: clang-tools-extra/clang-query/QueryParser.h
===
--- clang-tools-extra/clang-query/QueryParser.h
+++ clang-tools-extra/clang-query/QueryParser.h
@@ -43,6 +43,8 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  QueryRef
+  parseSetTraversalKind(ast_type_traits::TraversalKind QuerySession::*Var);
   template  QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -128,6 +128,24 @@
   llvm_unreachable("Invalid output kind");
 }
 
+QueryRef QueryParser::parseSetTraversalKind(
+ast_type_traits::TraversalKind QuerySession::*Var) {
+  StringRef ValStr;
+  unsigned Value =
+  LexOrCompleteWord(this, ValStr)
+  .Case("AsIs", ast_type_traits::TK_AsIs)
+  .Case("IgnoreImplicitCastsAndParentheses",
+ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
+  .Case("IgnoreUnlessSpelledInSource",
+ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  .Default(~0u);
+  if (Value == ~0u) {
+return new InvalidQuery("expected traversal kind, got '" + ValStr + "'");
+  }
+  return new SetQuery(
+  Var, static_cast(Value));
+}
+
 QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.drop_while(
@@ -171,7 +189,8 @@
   PQV_Invalid,
   PQV_Output,
   PQV_BindRoot,
-  PQV_PrintMatcher
+  PQV_PrintMatcher,
+  PQV_Traversal
 };
 
 QueryRef makeInvalidQueryFromDiagnostics(const Diagnostics ) {

[PATCH] D79804: [x86] prevent 64b operands to "r" constrained inline asm for -m32

2020-05-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm trying to catch up here. It looks like gcc has only started complaining 
about this from maybe version 7 on? And only as a warning?

The LLVM X86 backend used a 32-bit register for 'r' or 'R' on -m32 for 64-bit 
values. But the backend would fail for 'q' or 'Q' if the frontend check were 
not there.

Weirdly the backend fails for double with 'Q' in 64-bit mode. But does not fail 
with 'q' or 'r' or 'R'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79804



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


[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2020-05-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie requested changes to this revision.
dblaikie added a comment.
This revision now requires changes to proceed.

So the original commit ( cbc9d22e49b4 
 ) was 
reverted at some point, and now you're proposing recommitting it with a slight 
change?

Could you summarize (in the summary (which should hopefully be included in the 
commit message eventually)) the commit (include the hash), the revert 
(including the hash), reasons for revert and what's changed in this patch 
compared to the original commit that addresses the reasons for reverting? (& 
ideally what extra testing was done on the newer version of the patch to ensure 
the original issue or another like it would now be caught before committing)


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-12 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

In D79715#2029390 , @jbcoe wrote:

> I expect that accepting this patch will need require an update to be made to 
> https://github.com/google/styleguide.


I agree; it would be useful to leave a comment somewhere in this code with a 
link to a Google C# style guide reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715



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


Re: Bug in QualTypeNames.cpp and adding an option to prepend "::" to fully qualified names.

2020-05-12 Thread Jean-Baptiste Lespiau via cfe-commits
On Tue, May 12, 2020 at 11:11 PM David Blaikie  wrote:

> On Tue, May 12, 2020 at 12:40 PM Jean-Baptiste Lespiau <
> jblesp...@google.com> wrote:
>
>> Hi,
>>
>> thanks for your answer.
>>
>> Just a few remarks:
>>
>> 1. I imagine that we cannot know if people are using
>> getFullyQualifiedName. In particular, people could have developed their own
>> internal tools, thus we cannot be aware of all callers. I do not know
>> Clang's policy, but can we delete or completely change a function without
>> deprecating it first?
>>
>
> The LLVM project offers little/no API guarantees - potentially/especially
> for a function with no use in-tree. But, yes, as Googlers we'd be
> encouraged not to commit an API change knowing this might cause widespread
> internal breakage without a plan/pre-emptively fixing things.
>
>
>> I was imagining that the process was to deprecate it, document the case
>> where it can be incorrect, and that in a next release it gets
>> deleted/replaced (or someone steps up to fix it).
>>
>
> Sometimes deprecation is used - certain APIs have a lot of out of tree
> surface area
>
>
>> 2. As example of different behaviors:
>> (a) the qual_type.getAsString() will print implementation namespace
>> details (e.g. ::std*::__u*::variant instead of std::variant).
>>
>
> Yep, that's probably not ideal for most source generating use cases.
>
>
>> (b) It will also display default template arguments, e.g.
>> template 
>> class MyClass
>> is printed as MyClass (I think) in getFullyQualifiedName, while
>> getAsString() will use MyClass.
>>
>
> That seems better/correct - did CLIF actually want/rely on/benefit from
> the old behavior of only printing the template name?
>

I did check to replace all of the getFullyQualifiedName in CLIF with the
new version: it worked like a charm. The error messages are just changed
accordingly (so they will have longer types).
And the generated code was also less verbose.

>
>
>> (c) the example of the nested template argument above.
>>
>
> Which seems just wrong/inconsistent/not-behaving-to-spec to me - I don't
> imagine any caller actually wanted that behavior?
>

I agree.

>
>
>>
>> At the end,what matters is that getAsString() is semantically always
>> correct, even if it can be overly verbose.
>>
>
> The presence of inline namespaces is about the only bit I'd find a touch
> questionable. (Hopefully Sam can chime in on some of that)
>

Me too, I would be curious if it is easy to remove.

>
>
>> I tried to fix getFullyQualifiedName, but I do not understand its code.
>>
>> 3. When the goal we want to reach has been decided, there is also the
>> question on how to transition from the current state to the next state, and
>> who can help with that. To be way clearer, I won't be able to fix all of
>> Google internal usage of this function (I am not at all working on Clang,
>> Clif, or any tools, I just hit the bug and decided to look into it, and it
>> happened that I found a fix). Thus, if we can do the changes using
>> iterative steps, such as
>> (a) add the new "::" prefix configuration,
>> (b) Deprecate/document the fact that getFullyQualifiedName has a bug, and
>> people should move to use qual_type.getAsString(Policy) instead, using
>> "FullyQualifiedName" and "GlobalScopeQualifiedName". We can for example
>> provide :
>>
>
> It'd still fall to one of us Googlers to clean this all up inside Google -
> since we build with -Werror, it's not like folks'll just get soft
> encouragement to migrate away from the API, either the warning will be on
> and their build will be broken (in which case we'll probably pick it up
> when we integrate changes from upstream & have to fix it to complete that
> integration) or no signal, and it'll break when the function is finally
> removed.
>
>
>> std::string GetFullyQualifiedCanonicalType(QualType qual_type, const
>> ASTContext ,)
>>   clang::PrintingPolicy print_policy(ast.GetASTContext().getLangOpts());
>>   print_policy.FullyQualifiedName = 1;
>>   print_policy.SuppressScope = 0;
>>   print_policy.PrintCanonicalTypes = 1;
>>   print_policy.GlobalScopeQualifiedName = 1;
>>   QualType canonical_type = qual_type.getCanonicalType();
>>   return canonical_type.getAsString(print_policy);
>> }
>> (c) Then, people can upgrade asynchronously, maybe someone will be
>> unhappy with this behavior and will suggest something else, etc.
>>
>> If we just blindly delete it, it means for example that we have to fix
>> all usages in Google to be able to upgrade Clang.  It may be the approach
>> that is decided we should follow, but I just wanted to make it clear that I
>> will not be able to do that job^^ While, having an incremental fix in
>> Clang, and then fix Clif is doable as it does not imply to fix all calls in
>> one go.
>>
>> I just wanted to develop these points.
>>
>
> Sure enough - appreciate the awareness of the cost to external clients, to
> be sure.
>
> - Dave
>
>
>>
>> Thanks!
>>
>> On Tue, May 12, 2020 at 7:59 PM David Blaikie  wrote:
>>
>>> 

Re: Bug in QualTypeNames.cpp and adding an option to prepend "::" to fully qualified names.

2020-05-12 Thread David Blaikie via cfe-commits
On Tue, May 12, 2020 at 12:40 PM Jean-Baptiste Lespiau 
wrote:

> Hi,
>
> thanks for your answer.
>
> Just a few remarks:
>
> 1. I imagine that we cannot know if people are using
> getFullyQualifiedName. In particular, people could have developed their own
> internal tools, thus we cannot be aware of all callers. I do not know
> Clang's policy, but can we delete or completely change a function without
> deprecating it first?
>

The LLVM project offers little/no API guarantees - potentially/especially
for a function with no use in-tree. But, yes, as Googlers we'd be
encouraged not to commit an API change knowing this might cause widespread
internal breakage without a plan/pre-emptively fixing things.


> I was imagining that the process was to deprecate it, document the case
> where it can be incorrect, and that in a next release it gets
> deleted/replaced (or someone steps up to fix it).
>

Sometimes deprecation is used - certain APIs have a lot of out of tree
surface area


> 2. As example of different behaviors:
> (a) the qual_type.getAsString() will print implementation namespace
> details (e.g. ::std*::__u*::variant instead of std::variant).
>

Yep, that's probably not ideal for most source generating use cases.


> (b) It will also display default template arguments, e.g.
> template 
> class MyClass
> is printed as MyClass (I think) in getFullyQualifiedName, while
> getAsString() will use MyClass.
>

That seems better/correct - did CLIF actually want/rely on/benefit from the
old behavior of only printing the template name?


> (c) the example of the nested template argument above.
>

Which seems just wrong/inconsistent/not-behaving-to-spec to me - I don't
imagine any caller actually wanted that behavior?


>
> At the end,what matters is that getAsString() is semantically always
> correct, even if it can be overly verbose.
>

The presence of inline namespaces is about the only bit I'd find a touch
questionable. (Hopefully Sam can chime in on some of that)


> I tried to fix getFullyQualifiedName, but I do not understand its code.
>
> 3. When the goal we want to reach has been decided, there is also the
> question on how to transition from the current state to the next state, and
> who can help with that. To be way clearer, I won't be able to fix all of
> Google internal usage of this function (I am not at all working on Clang,
> Clif, or any tools, I just hit the bug and decided to look into it, and it
> happened that I found a fix). Thus, if we can do the changes using
> iterative steps, such as
> (a) add the new "::" prefix configuration,
> (b) Deprecate/document the fact that getFullyQualifiedName has a bug, and
> people should move to use qual_type.getAsString(Policy) instead, using
> "FullyQualifiedName" and "GlobalScopeQualifiedName". We can for example
> provide :
>

It'd still fall to one of us Googlers to clean this all up inside Google -
since we build with -Werror, it's not like folks'll just get soft
encouragement to migrate away from the API, either the warning will be on
and their build will be broken (in which case we'll probably pick it up
when we integrate changes from upstream & have to fix it to complete that
integration) or no signal, and it'll break when the function is finally
removed.


> std::string GetFullyQualifiedCanonicalType(QualType qual_type, const
> ASTContext ,)
>   clang::PrintingPolicy print_policy(ast.GetASTContext().getLangOpts());
>   print_policy.FullyQualifiedName = 1;
>   print_policy.SuppressScope = 0;
>   print_policy.PrintCanonicalTypes = 1;
>   print_policy.GlobalScopeQualifiedName = 1;
>   QualType canonical_type = qual_type.getCanonicalType();
>   return canonical_type.getAsString(print_policy);
> }
> (c) Then, people can upgrade asynchronously, maybe someone will be unhappy
> with this behavior and will suggest something else, etc.
>
> If we just blindly delete it, it means for example that we have to fix all
> usages in Google to be able to upgrade Clang.  It may be the approach that
> is decided we should follow, but I just wanted to make it clear that I will
> not be able to do that job^^ While, having an incremental fix in Clang, and
> then fix Clif is doable as it does not imply to fix all calls in one go.
>
> I just wanted to develop these points.
>

Sure enough - appreciate the awareness of the cost to external clients, to
be sure.

- Dave


>
> Thanks!
>
> On Tue, May 12, 2020 at 7:59 PM David Blaikie  wrote:
>
>> +Mr. Smith for visibility.
>>
>> I'm /guessing/ the right path might be to change the implementation of
>> getFullyQualifiedName to use the type printing/pretty printer approach with
>> the extra feature you're suggesting. That way all users get the desired
>> behavior
>>
>> +Sam McCall   who (if I understand correctly) has
>> a lot to do with the Clang Tooling work - looks like Google's got a bunch
>> of uses of this function (getFullyQualifiedName) internally in clang tools
>> (I wonder why that's the case when there are still zero 

[PATCH] D79325: [clang-format] [PR42164] Add Option to Break before While

2020-05-12 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2170
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.IndentBraces)
+if (Style.BraceWrapping.IndentBraces || Style.BraceWrapping.BeforeWhile)
   addUnwrappedLine();

MyDeveloperDay wrote:
> krasimir wrote:
> > Why not remove `Style.BraceWrapping.IndentBraces`? 
> > - should be a no-op for GNU style, 
> > - other styles don't IndentBraces, 
> > - we can add a sentence in the release notes that previously IndentBraces 
> > implied the new "BeforeWhile" option, and now you just have to set it if 
> > you're using a custom GNU-like style.
> `IndentBraces` is used elsewhere inside parseLabel() and 
> CompoundStatementIndenter, I think I'd be uncomfortable about removing it.
> 
> There are 1000's of references to it in GitHub.
> 
> https://github.com/search?l=YAML=%22IndentBraces%3A+true%22=Code
> 
> https://github.com/search?q=%22IndentBraces%3A+false%22=Code
I'm sorry, I wasn't clear: why not remove `Style.BraceWrapping.IndentBraces || 
` from line 2170, leaving the value of the new option 
`Style.BraceWrapping.BeforeWhile` be the only thing that determines whether a 
newline is added before the `while` in a do-while block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79325



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


[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-05-12 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



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


[PATCH] D27434: [libc++abi] Disable failing test on Darwin

2020-05-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Note for posterity in case someone does some archeology and ends up here (as I 
am doing): the Radar number is 29523281.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D27434



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


[PATCH] D79698: Run Coverage pass before other *San passes under new pass manager

2020-05-12 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

This patch seems to lead to the undefined symbol error we're seeing when 
building fuchsia:

  ld.lld: error: relocation refers to a discarded section: __sancov_guards
  >>> defined in 
user-x64-sancov.shlib/obj/third_party/ulib/scudo/scudo.string_utils.cc.o
  >>> referenced by vector.h:58 
(../../zircon/third_party/ulib/scudo/vector.h:58)
  >>>   
user-x64-sancov.shlib/obj/third_party/ulib/scudo/scudo.string_utils.cc.o:(scudo::ScopedString::append(char
 const*, __va_list_tag*))
  >>> referenced by vector.h:58 
(../../zircon/third_party/ulib/scudo/vector.h:58)
  >>>   
user-x64-sancov.shlib/obj/third_party/ulib/scudo/scudo.string_utils.cc.o:(scudo::Printf(char
 const*, ...))

Checking to see if this is could be an us problem or something this patch 
introduced.

For reference: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8880544155798188656/+/steps/build/0/steps/build_fuchsia/0/steps/ninja/0/steps/zircon/0/logs/raw_io.output_failure_raw_summary_/0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79698



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


[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2020-05-12 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping? I've reopened this one as suggested in D74846 
, but apparently it's kept the accepted state, 
so I'm not sure if this needs another approval or what to do here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[clang] 6c29073 - PR45589: Properly decompose overloaded `&&` and `||` operators in

2020-05-12 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-05-12T13:45:45-07:00
New Revision: 6c29073efb0c22045868bc3622f8fc27f43fca41

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

LOG: PR45589: Properly decompose overloaded `&&` and `||` operators in
constraint expressions.

We create overloaded `&&` and `||` operators to hold the possible
unqualified lookup results (if any) when the operands are dependent. We
could avoid building these in some cases (we will never use the stored
lookup results, and it would be better to not store them or perform the
lookups), but in the general case we will probably still need to handle
overloaded operators even with that optimization.

Added: 
clang/test/SemaTemplate/constraints.cpp

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 202f0f2c9a14..5adb66dc9ec6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6394,15 +6394,10 @@ class Sema final {
   /// A diagnostic is emitted if it is not, false is returned, and
   /// PossibleNonPrimary will be set to true if the failure might be due to a
   /// non-primary expression being used as an atomic constraint.
-  bool CheckConstraintExpression(Expr *CE, Token NextToken = Token(),
+  bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
  bool *PossibleNonPrimary = nullptr,
  bool IsTrailingRequiresClause = false);
 
-  /// Check whether the given type-dependent expression will be the name of a
-  /// function or another callable function-like entity (e.g. a function
-  // template or overload set) for any substitution.
-  bool IsDependentFunctionNameExpr(Expr *E);
-
 private:
   /// Caches pairs of template-like decls whose associated constraints were
   /// checked for subsumption and whether or not the first's constraints did in

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 290e4cbff4fd..ddd95faebe99 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -28,21 +28,47 @@
 using namespace clang;
 using namespace sema;
 
-bool
-Sema::CheckConstraintExpression(Expr *ConstraintExpression, Token NextToken,
-bool *PossibleNonPrimary,
-bool IsTrailingRequiresClause) {
+namespace {
+class LogicalBinOp {
+  OverloadedOperatorKind Op = OO_None;
+  const Expr *LHS = nullptr;
+  const Expr *RHS = nullptr;
+
+public:
+  LogicalBinOp(const Expr *E) {
+if (auto *BO = dyn_cast(E)) {
+  Op = BinaryOperator::getOverloadedOperator(BO->getOpcode());
+  LHS = BO->getLHS();
+  RHS = BO->getRHS();
+} else if (auto *OO = dyn_cast(E)) {
+  Op = OO->getOperator();
+  LHS = OO->getArg(0);
+  RHS = OO->getArg(1);
+}
+  }
+
+  bool isAnd() const { return Op == OO_AmpAmp; }
+  bool isOr() const { return Op == OO_PipePipe; }
+  explicit operator bool() const { return isAnd() || isOr(); }
+
+  const Expr *getLHS() const { return LHS; }
+  const Expr *getRHS() const { return RHS; }
+};
+}
+
+bool Sema::CheckConstraintExpression(const Expr *ConstraintExpression,
+ Token NextToken, bool *PossibleNonPrimary,
+ bool IsTrailingRequiresClause) {
   // C++2a [temp.constr.atomic]p1
   // ..E shall be a constant expression of type bool.
 
   ConstraintExpression = ConstraintExpression->IgnoreParenImpCasts();
 
-  if (auto *BinOp = dyn_cast(ConstraintExpression)) {
-if (BinOp->getOpcode() == BO_LAnd || BinOp->getOpcode() == BO_LOr)
-  return CheckConstraintExpression(BinOp->getLHS(), NextToken,
-   PossibleNonPrimary) &&
- CheckConstraintExpression(BinOp->getRHS(), NextToken,
-   PossibleNonPrimary);
+  if (LogicalBinOp BO = ConstraintExpression) {
+return CheckConstraintExpression(BO.getLHS(), NextToken,
+ PossibleNonPrimary) &&
+   CheckConstraintExpression(BO.getRHS(), NextToken,
+ PossibleNonPrimary);
   } else if (auto *C = dyn_cast(ConstraintExpression))
 return CheckConstraintExpression(C->getSubExpr(), NextToken,
  PossibleNonPrimary);
@@ -60,7 +86,7 @@ Sema::CheckConstraintExpression(Expr *ConstraintExpression, 
Token NextToken,
   (NextToken.is(tok::l_paren) &&
(IsTrailingRequiresClause ||
 (Type->isDependentType() &&
- IsDependentFunctionNameExpr(ConstraintExpression)) ||
+   

[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-05-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2053
+  D, [](OpenMPClauseKind K) -> bool { return K != OMPC_unknown; },
+  Level, /*NotLastprivate=*/true) &&
+  !DSAStack->isLoopControlVariable(D, Level).first) {

`/*NotLastprivate=*/true` is not needed here. Also, could you move it under 
control of the if statement above?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2185-2186
 if (DVarPrivate.CKind != OMPC_unknown ||
-(VD && DSAStack->getDefaultDSA() == DSA_none))
+(VD && (DSAStack->getDefaultDSA() == DSA_none ||
+DSAStack->getDefaultDSA() == DSA_firstprivate)))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());

Why do you need this check here? `getTopDSA` will return `OMPC_firstprivate` 
and one of the previous checks should be fired.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3337
+  if (Stack->getDefaultDSA() == DSA_firstprivate &&
+  VD->getStorageClass() == SC_Static &&
+  (CanonicalVD->getDeclContext()->isNamespace() ||

1. You need to check that the variable is not a loop control variable here.
2. Seems to me you misinterpret the standard. According to the standard `An 
object whose identifier is declared without the storage-class specifier 
_Thread_local, and either with external or internal linkage or with the 
storage-class specifier static, has static storage duration.`. It means that 
non-static globals also must be affected since they have external linkage. So, 
you need to use `getStorageDuration()` function here and check that it returns 
`SD_Static`.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3338-3339
+  VD->getStorageClass() == SC_Static &&
+  (CanonicalVD->getDeclContext()->isNamespace() ||
+   !VD->isLocalVarDeclOrParm())) {
+VarsWithInheritedDSA[VD] = E;

I think just `CanonicalVD->getDeclContext()->isFileContext()` must be enough 
here.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3344-3349
+  // Create implicit firstprivate variables as necessary under
+  // default(firstprivate).
+  if (Stack->getDefaultDSA() == DSA_firstprivate) {
+ImplicitFirstprivate.push_back(E);
+return;
+  }

This code must be somewhere later, otherwise, you're skipping a lot of checks 
for the target-based directives. This must be checked and processed when we 
request implicit data sharing attributes with `Stack->getImplicitDSA(VD, 
/*FromParent=*/false);`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:12745
   }
+
   return Res;

Remove this empty line.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:12783-12787
+  if (getLangOpts().OpenMP < 51 && Kind == OMP_DEFAULT_firstprivate) {
+Diag(StartLoc, diag::err_omp_invalid_dsa)
+<< getOpenMPClauseName(OMPC_firstprivate)
+<< getOpenMPClauseName(OMPC_default) << "5.1";
+  }

Usually, such checks are implemented in ParseOpenMP.cpp rather than in Sema.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-05-12 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1305
+if (const auto *CB1 = dyn_cast(I1))
+  if (CB1->cannotMerge())
+return Changed;

rnk wrote:
> It seems inconsistent that we don't apply the same logic to inline asm here. 
> I think you should modify `cannotMerge` to return `isInlineAsm() || 
> hasFnAttr(...NoMerge)`, and then remove the isInlineAsm case below.
This changes breaks the test `AArch64/arm64-shrink-wrapping.ll` because the 
inlineAsm cannot be deleted. I think we should only check for 
`hasFnAttr(NoMerge)` for `CB1` and `CB2`.


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

https://reviews.llvm.org/D78659



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


[PATCH] D79804: [x86] prevent 64b operands to "r" constrained inline asm for -m32

2020-05-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: ahatanak, craig.topper.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
nickdesaulniers added a subscriber: dwmw2.

As pointed out by David Woodhouse and Akira Hatanaka in
https://bugs.llvm.org/show_bug.cgi?id=33587, Clang was inconsistent with
GCC validating inline asm constraints for -m32.  For -m32 Clang was
disallowing 64b inputs/outputs to inline asm with "q" constraints, but
not for "r" constraints.  This change improves Clang's validations to
match GCC's.

Adds a test case in x86_32-inline-asm.c, and fixes up previous tests
that used "r"+64b operands+32b x86 targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79804

Files:
  clang/lib/Basic/Targets/X86.h
  clang/test/CodeGen/mult-alt-generic.c
  clang/test/CodeGen/mult-alt-x86.c
  clang/test/CodeGen/x86_32-inline-asm.c
  clang/test/Parser/no-gnu-inline-asm.c

Index: clang/test/Parser/no-gnu-inline-asm.c
===
--- clang/test/Parser/no-gnu-inline-asm.c
+++ clang/test/Parser/no-gnu-inline-asm.c
@@ -12,7 +12,7 @@
 asm(" "); // Whitespace is OK
 
 void f (void) {
-  long long foo = 0, bar;
+  long foo = 0, bar;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar)); // expected-error {{GNU-style inline assembly is disabled}}
   asm (""); // Empty is OK
   return;
Index: clang/test/CodeGen/x86_32-inline-asm.c
===
--- clang/test/CodeGen/x86_32-inline-asm.c
+++ clang/test/CodeGen/x86_32-inline-asm.c
@@ -34,6 +34,7 @@
   unsigned int port;
   __asm__ volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); // No error expected.
 
+  __asm__ volatile("outb %0, %w1" : : "r" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'r'}}
   __asm__ volatile("outb %0, %w1" : : "R" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'R'}}
   __asm__ volatile("outb %0, %w1" : : "q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'q'}}
   __asm__ volatile("outb %0, %w1" : : "Q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'Q'}}
@@ -48,6 +49,7 @@
   __asm__ volatile("foo1 %0" : : "u" (val256)); // expected-error {{invalid input size for constraint 'u'}}
   __asm__ volatile("foo1 %0" : : "x" (val512)); // expected-error {{invalid input size for constraint 'x'}}
 
+  __asm__ volatile("foo1 %0" : "=r" (val)); // expected-error {{invalid output size for constraint '=r'}}
   __asm__ volatile("foo1 %0" : "=R" (val)); // expected-error {{invalid output size for constraint '=R'}}
   __asm__ volatile("foo1 %0" : "=q" (val)); // expected-error {{invalid output size for constraint '=q'}}
   __asm__ volatile("foo1 %0" : "=Q" (val)); // expected-error {{invalid output size for constraint '=Q'}}
Index: clang/test/CodeGen/mult-alt-x86.c
===
--- clang/test/CodeGen/mult-alt-x86.c
+++ clang/test/CodeGen/mult-alt-x86.c
@@ -4,6 +4,8 @@
 int mout0;
 int min1;
 int marray[2];
+float fout0;
+float fin1;
 double dout0;
 double din1;
 
@@ -285,15 +287,15 @@
 // CHECK: @multi_y
 void multi_y()
 {
-  // CHECK: asm "foo $1,$0", "=*r|y|m,r|y|m[[CLOBBERS]](double* @dout0, double {{[a-zA-Z0-9@%]+}})
-  asm("foo %1,%0" : "=r,y,m" (dout0) : "r,y,m" (din1));
+  // CHECK: asm "foo $1,$0", "=*r|y|m,r|y|m[[CLOBBERS]](float* @fout0, float {{[a-zA-Z0-9@%]+}})
+  asm("foo %1,%0" : "=r,y,m" (fout0) : "r,y,m" (fin1));
 }
 
 // CHECK: @multi_x
 void multi_x()
 {
-  // CHECK: asm "foo $1,$0", "=*r|x|m,r|x|m[[CLOBBERS]](double* @dout0, double {{[a-zA-Z0-9@%]+}})
-  asm("foo %1,%0" : "=r,x,m" (dout0) : "r,x,m" (din1));
+  // CHECK: asm "foo $1,$0", "=*r|x|m,r|x|m[[CLOBBERS]](float* @fout0, float {{[a-zA-Z0-9@%]+}})
+  asm("foo %1,%0" : "=r,x,m" (fout0) : "r,x,m" (fin1));
 }
 
 // CHECK: @multi_Y
@@ -352,15 +354,15 @@
 // CHECK: @multi_G
 void multi_G()
 {
-  // CHECK: asm "foo $1,$0", "=*r|m|m,r|G|m[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
-  asm("foo %1,%0" : "=r,m,m" (mout0) : "r,G,m" (1.0));
+  // CHECK: asm "foo $1,$0", "=*r|m|m,r|G|m[[CLOBBERS]](i32* @mout0, float {{1.[0]+e[+]*[0]+}})
+  asm("foo %1,%0" : "=r,m,m" (mout0) : "r,G,m" (1.0f));
 }
 
 // CHECK: @multi_C
 void multi_C()
 {
-  // CHECK: asm "foo $1,$0", "=*r|m|m,r|C|m[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
-  asm("foo %1,%0" : "=r,m,m" (mout0) : "r,C,m" (1.0));
+  // CHECK: asm "foo $1,$0", "=*r|m|m,r|C|m[[CLOBBERS]](i32* @mout0, float {{1.[0]+e[+]*[0]+}})
+  asm("foo %1,%0" : "=r,m,m" (mout0) : "r,C,m" (1.0f));
 }
 
 // CHECK: @multi_e
Index: clang/test/CodeGen/mult-alt-generic.c
===
--- clang/test/CodeGen/mult-alt-generic.c
+++ clang/test/CodeGen/mult-alt-generic.c
@@ -86,17 +86,17 @@
 // CHECK: @single_E
 void single_E()
 {
-  register double out0 = 

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Blanket reply! `ParamRegion` is not a `DeclRegion` because it does not 
necessarily have a corresponding `Decl`. For instance, when calling a function 
through an unknown function pointer, you don't have the declaration of a 
function, let alone its parameters. But for parameters of C++ object type you 
still need your `ParamRegion` because arguments are constructed into it.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1051
+
+  const Expr *OriginExpr;
+  unsigned Index;

baloghadamsoftware wrote:
> We do not use this at all. However, if I remove it then tests begin to fail 
> with strange reasons, some of them even crashes at strange points. It seems 
> that we need this for profiling the subclass.
`Profile` is completely essential. Without it different regions will be treated 
as if it's the same region.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1054-1055
+
+  ParamRegion(const Expr *OE, unsigned Idx, const MemRegion *SReg)
+  : TypedValueRegion(SReg, ParamRegionKind), OriginExpr(OE), Index(Idx) {}
+

It looks like you decided to keep `VarRegion` for the top frame.

I want that asserted here, in the constructor, so that never to make a mistake 
on this front.



Comment at: clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp:197-198
+if (const ParamRegion *PR = R->getAs())
+  if (const StackArgumentsSpaceRegion *
+  stackReg = dyn_cast(PR->getMemorySpace()))
+if (stackReg->getStackFrame() == SFC)

Yes it is a `StackArgumentsSpaceRegion`! Because we're a parameter.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:164
+  const auto *SSR = dyn_cast(getMemorySpace());
+  return SSR ? SSR->getStackFrame() : nullptr;
+}

`SSR` shouldn't ever be null. Any parameter must be on the stack.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1579-1584
+  std::tie(Call, Index) = ParamRegion::getExprAndIndexForParam(PVD, LC);
+
+  if (Call)
+OriginalVR = MemMgr.getParamRegion(Call, Index, LC);
+  else
+OriginalVR = MemMgr.getVarRegion(VD, LC);

I suggest making a function in `MemRegionManager` that takes a `Decl` and 
returns a region. There should only be one place in the code that decides when 
exactly do we produce a `ParamRegion` instead of a `VarRegion`.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1732
+ const LocationContext *LC) {
+  unsigned Index = PVD->getFunctionScopeIndex();
+  const StackFrameContext *SFC = LC->getStackFrame();

Does this method also suffer from the parameter vs. argument off-by-one problem 
with operators?



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1735-1736
+  const Stmt *CallSite = SFC->getCallSite();
+  if (!CallSite)
+return std::make_pair(nullptr, UINT_MAX);
+

Does this actually ever happen?



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1740
+  if (const auto *FD = dyn_cast(D)) {
+if (Index >= FD->param_size() || FD->parameters()[Index] != PVD)
+  return std::make_pair(nullptr, UINT_MAX);

Why would that ever happen? If it's just a sanity check, it should be an 
assertion.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2031
+
+  assert (isa(MS));
+

Let's simply make a blanket assertion in `ParamRegion`'s constructor.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-12 Thread Jason Liu via Phabricator via cfe-commits
jasonliu updated this revision to Diff 263502.
jasonliu added a comment.

Add error report in clang_cc1 for unsupported option on AIX.


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

https://reviews.llvm.org/D79035

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-complex.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/aix-vector.c
  clang/test/CodeGen/ppc32-and-aix-struct-return.c
  clang/test/CodeGen/ppc32-dwarf.c
  clang/test/CodeGen/ppc32-struct-return.c
  clang/test/CodeGen/ppc64-dwarf.c
  clang/test/Driver/ppc-unsupported.c
  clang/test/Frontend/aix-unsupported.c

Index: clang/test/Frontend/aix-unsupported.c
===
--- /dev/null
+++ clang/test/Frontend/aix-unsupported.c
@@ -0,0 +1,10 @@
+// REQUIRES: powerpc-registered-target
+// RUN: not %clang_cc1 -triple powerpc-unknown-aix -maix-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc-unknown-aix -msvr4-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -maix-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -msvr4-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// CHECK: unsupported option
Index: clang/test/Driver/ppc-unsupported.c
===
--- clang/test/Driver/ppc-unsupported.c
+++ clang/test/Driver/ppc-unsupported.c
@@ -7,4 +7,12 @@
 // RUN:   -c %s 2>&1 | FileCheck %s
 // RUN: not %clang -target powerpc64le-unknown-linux -msvr4-struct-return \
 // RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-aix -maix-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-aix -msvr4-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-aix -maix-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-aix -msvr4-struct-return \
+// RUN:   -c %s 2>&1 | FileCheck %s
 // CHECK: unsupported option
Index: clang/test/CodeGen/ppc64-dwarf.c
===
--- clang/test/CodeGen/ppc64-dwarf.c
+++ clang/test/CodeGen/ppc64-dwarf.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,PPC64
 static unsigned char dwarf_reg_size_table[1024];
 
 int test() {
@@ -119,10 +120,10 @@
 // CHECK-NEXT: store i8 16, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 108), align 1
 // CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 109), align 1
 // CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 110), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 111), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 112), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 113), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 114), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 115), align 1
-// CHECK-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 116), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 111), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 112), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 113), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 114), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 115), align 1
+// PPC64-NEXT: store i8 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @dwarf_reg_size_table, i64 0, i64 116), align 1
 // CHECK-NEXT: ret i32 1
Index: clang/test/CodeGen/ppc32-struct-return.c
===
--- 

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-12 Thread Matthew Riley via Phabricator via cfe-commits
mattdr added a comment.

I'm no expert in the pass manager, but given the very targeted applicability of 
LVI it definitely seems like our goal should be 0% impact for the vast majority 
of compilations that don't concern themselves with it.

Is there a way to require the pass be enabled for the compiler invocation as 
well as for the subtarget? If there's a mismatch (where LVI is desired but the 
required analyses weren't done) we can fail the compile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-05-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 263499.
Xiangling_L marked 3 inline comments as done.
Xiangling_L added a comment.

Updated the warnings to `report_fatal_error`;
Update the testcases;


Repository:
  rL LLVM

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: define dso_local void @__cxx_global_var_init() {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__dtor_t() {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define dso_local void @__cxx_global_var_destruct_t() {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*)
+
+// CHECK: define dso_local void @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-init-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-init-priority-attribute.cpp
@@ -0,0 +1,16 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+__attribute__ ((init_priority (2000)))
+test t(1);
+
+// CHECK: fatal error: error in backend: 'init_priority' attribute unsupported on AIX yet
Index: clang/test/CodeGen/aix-destructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-destructor-attribute.cpp
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+int bar() __attribute__((destructor(180)));
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+test t(1);
+
+// CHECK: fatal error: error in backend: 'destructor' attribute unsupported on AIX yet
Index: clang/test/CodeGen/aix-constructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-constructor-attribute.cpp
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ 

[PATCH] D79800: [Sema] Remove default values for arguments prior to a parameter pack if the pack is used

2020-05-12 Thread Raul Tambre via Phabricator via cfe-commits
tambre created this revision.
tambre added reviewers: rsmith, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When a parameter pack is expanded the expanded parameters don't have default 
values.
Thus if a parameter pack is expanded after any arguments with a default value, 
the function is incorrectly rejected in CheckCXXDefaultArguments().

Fix this by removing default arguments for prior parameters if a parameter pack 
is expanded.

Fixes PR23029.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79800

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/drs/dr7xx.cpp


Index: clang/test/CXX/drs/dr7xx.cpp
===
--- clang/test/CXX/drs/dr7xx.cpp
+++ clang/test/CXX/drs/dr7xx.cpp
@@ -230,5 +230,12 @@
 
 template 
 void h(int i = 0, T ...args, int j = 1) {}
+
+// PR23029
+// Ensure passing parameters using the parameter packs actually works.
+void use() {
+  f(0, 1);
+  h(0, 1);
+}
 #endif
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1974,6 +1974,54 @@
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
+
+// Parameter packs are allowed after parameters with default values.
+// If the specialized Function has more parameters than the TemplatedDecl
+// then the default values aren't used and the parameter pack is used and 
we
+// need to remove default values from previous parameters to prevent it
+// being diagnosed as invalid code due to the expanded parameter lacking
+// default values.
+FunctionDecl *TemplatedDecl = FunctionTemplate->getTemplatedDecl();
+unsigned NumTemplatedParams = TemplatedDecl->getNumParams();
+
+if (Function->getNumParams() >= NumTemplatedParams) {
+  unsigned FirstDefault = 0;
+  unsigned LastDefault = 0;
+  bool FoundDefault = false;
+  bool RemoveDefaults = false;
+
+  // Find the FirstDefault up to LastDefault that need to be removed.
+  // We don't remove if the code's invalid, i.e. a default value missing on
+  // a regular parameter if there's any with a default value before.
+  for (unsigned p = 0; p < NumTemplatedParams; ++p) {
+ParmVarDecl *Param = TemplatedDecl->getParamDecl(p);
+
+if (FoundDefault) {
+  if (Param->isParameterPack()) {
+RemoveDefaults = true;
+LastDefault = p;
+break;
+  }
+
+  // If we encounter a regular parameter with no default value after
+  // we've encountered any with a default, then this is invalid code 
and
+  // we bail out. This is diagnosed later in 
CheckCXXDefaultArguments().
+  if (!Param->hasDefaultArg())
+break;
+} else if (Param->hasDefaultArg()) {
+  FirstDefault = p;
+  FoundDefault = true;
+}
+  }
+
+  // Remove default arguments if this is valid code.
+  if (RemoveDefaults) {
+for (unsigned p = FirstDefault; p < LastDefault; ++p) {
+  ParmVarDecl *Param = Function->getParamDecl(p);
+  Param->setDefaultArg(nullptr);
+}
+  }
+}
   } else if (isFriend && D->isThisDeclarationADefinition()) {
 // Do not connect the friend to the template unless it's actually a
 // definition. We don't want non-template functions to be marked as being


Index: clang/test/CXX/drs/dr7xx.cpp
===
--- clang/test/CXX/drs/dr7xx.cpp
+++ clang/test/CXX/drs/dr7xx.cpp
@@ -230,5 +230,12 @@
 
 template 
 void h(int i = 0, T ...args, int j = 1) {}
+
+// PR23029
+// Ensure passing parameters using the parameter packs actually works.
+void use() {
+  f(0, 1);
+  h(0, 1);
+}
 #endif
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1974,6 +1974,54 @@
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
+
+// Parameter packs are allowed after parameters with default values.
+// If the specialized Function has more parameters than the TemplatedDecl
+// then the default values aren't used and the parameter pack is used and we
+// need to remove default values from previous parameters to prevent it
+// being diagnosed as invalid code due to the expanded parameter lacking
+// default values.

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-05-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 263494.
MyDeveloperDay added a reviewer: saar.raz.
MyDeveloperDay added a subscriber: saar.raz.
MyDeveloperDay added a comment.

Add additional parsing of concept and require keywords to allow formatting

Include some more of @saar.raz examples in the tests


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

https://reviews.llvm.org/D79773

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.cpp.new
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15849,6 +15849,51 @@
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, ConceptsImplicitConversionConstraint) {
+  FormatStyle Style = getLLVMStyle();
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};",
+   Style);
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -113,6 +113,8 @@
   void parseNew();
   void parseAccessSpecifier();
   bool parseEnum();
+  void parseConcept();
+  void parseRequires();
   void parseJavaEnumBody();
   // Parses a record (aka class) as a top level element. If ParseAsExpr is true,
   // parses the record as a child block, i.e. if the class declaration is an
Index: clang/lib/Format/UnwrappedLineParser.cpp.new
===
--- /dev/null
+++ clang/lib/Format/UnwrappedLineParser.cpp.new
@@ -0,0 +1,3002 @@
+//===--- UnwrappedLineParser.cpp - Format C++ code ===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of the UnwrappedLineParser,
+/// which turns a stream of tokens into UnwrappedLines.
+///
+//===--===//
+
+#include "UnwrappedLineParser.h"
+#include "FormatToken.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include 
+
+#define DEBUG_TYPE "format-parser"
+
+namespace clang {
+namespace format {
+
+class FormatTokenSource {
+public:
+  virtual ~FormatTokenSource() {}
+  virtual FormatToken *getNextToken() = 0;
+
+  virtual unsigned getPosition() = 0;
+  virtual FormatToken *setPosition(unsigned Position) = 0;
+};
+
+namespace {
+
+class ScopedDeclarationState {
+public:
+  ScopedDeclarationState(UnwrappedLine , std::vector ,
+ bool MustBeDeclaration)
+  : Line(Line), Stack(Stack) {
+Line.MustBeDeclaration = MustBeDeclaration;
+Stack.push_back(MustBeDeclaration);
+  }
+  ~ScopedDeclarationState() {
+Stack.pop_back();
+if (!Stack.empty())
+  Line.MustBeDeclaration = Stack.back();
+else
+  Line.MustBeDeclaration = true;
+  }
+
+private:
+  UnwrappedLine 
+  std::vector 
+};
+
+static bool isLineComment(const FormatToken ) {
+  return FormatTok.is(tok::comment) && !FormatTok.TokenText.startswith("/*");
+}
+
+// Checks if 

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-05-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 7 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:691
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }

ZarkoCA wrote:
> I may be missing something but why do we need this now, as opposed to not 
> needing it before? Why didn't we need to clear the CXXGlobalDtors after 
> emitting the function function before?
No, you didn't miss anything here. I just followed what 
`EmitCXXGlobalInitFunc()` does, which is to clear the std::vecotr once we are 
certain it's useless.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6898
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << "";

aaron.ballman wrote:
> This change (and the others like it) should be done within Attr.td and not 
> exposed here. You should make these attributes target-specific.
> 
> You should also update AttrDocs.td for these attributes to document that 
> they're not supported on AIX.
Thanks for your comments. As I mentioned in the below testcase, those three 
attributes actually will be supported by the follow-up patches for AIX.  I will 
update them to `report_fatal_error` instead.



Comment at: clang/test/CodeGen/aix-priority-attribute.cpp:1-4
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | 
\
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 
| \
+// RUN: FileCheck %s

aaron.ballman wrote:
> I think this test file should live in SemaCXX instead, as this is not testing 
> the codegen behavior, but testing the semantic checking behavior.
Actually we will support those three attributes in the future, so the warning 
are placeholders waiting for the future upgrade where we do want to check the 
codegen results. 

I agree the warnings here are confusing, I will update them with 
report_fatal_error.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D74166



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-05-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1924
 return TT_BinaryOperator;
 }
 

This change it to resolve the missing gap between `&&` and `Concept2`, 
clang-format incorrectly labels the && as TT_PointerOrReference

```
template  void f(I i) requires Concept1 & {
  // ...
}
```

vs

```
template  void f(I i) requires Concept1 && Concept2 {
  // ...
}
```



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

https://reviews.llvm.org/D79773



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13111
+  }
+  }
+  return std::make_tuple(false, CharUnits::Zero(), CharUnits::Zero());

ahatanak wrote:
> rjmccall wrote:
> > Derived-to-base conversions.
> Does this include cases where bases are virtual? I think that would be more 
> complex as it requires tracking the most-derived object. Do you think it's 
> important to handle virtual bases in this patch or should it be done 
> separately in a follow-up?
You should handle virtual bases, but it's okay to assume they're not within 
known-complete objects; i.e. you just need to reset the alignment to the 
alignment of the base.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/X86/O3-pipeline.ll:147
+; CHECK-NEXT:   X86 Load Value Injection (LVI) Load Hardening
 ; CHECK-NEXT:   Fixup Statepoint Caller Saved
 ; CHECK-NEXT:   PostRA Machine Sink

I'm curious what happens if we add AU.setPreservesCFG() to getAnalysisUsage in 
FixupStatepointCallerSaved.cpp  From a quick look through that pass it doesn't 
look like it changes the Machine CFG.

PostRA Machine Sink already preserves CFG. So I think that should remove the 
dominator tree construction after PostRA machine sink.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[clang] 11c8c2a - [analyzer] SATestBuild.py: Fix support for #NOPREFIX.

2020-05-12 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-05-12T22:43:32+03:00
New Revision: 11c8c2a551c53db5ecf8c1f253b1a49d5e98324f

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

LOG: [analyzer] SATestBuild.py: Fix support for #NOPREFIX.

Regressed in ec2d93c.

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index 38273af27f21..347f1e2dd5e0 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -298,7 +298,7 @@ def runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile):
 SBPrefix = "scan-build " + SBOptions + " "
 for Command in SBCommandFile:
 Command = Command.strip()
-if len(Command) == 0 or Command.startswith("#"):
+if len(Command) == 0:
 continue
 
 # Custom analyzer invocation specified by project.
@@ -311,6 +311,9 @@ def runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile):
 ExtraEnv['ANALYZER_CONFIG'] = generateAnalyzerConfig(Args)
 continue
 
+if Command.startswith("#"):
+continue
+
 # If using 'make', auto imply a -jX argument
 # to speed up analysis.  xcodebuild will
 # automatically use the maximum number of cores.



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


Re: Bug in QualTypeNames.cpp and adding an option to prepend "::" to fully qualified names.

2020-05-12 Thread Jean-Baptiste Lespiau via cfe-commits
Hi,

thanks for your answer.

Just a few remarks:

1. I imagine that we cannot know if people are using getFullyQualifiedName.
In particular, people could have developed their own internal tools, thus
we cannot be aware of all callers. I do not know Clang's policy, but can we
delete or completely change a function without deprecating it first? I was
imagining that the process was to deprecate it, document the case where it
can be incorrect, and that in a next release it gets deleted/replaced (or
someone steps up to fix it).
2. As example of different behaviors:
(a) the qual_type.getAsString() will print implementation namespace details
(e.g. ::std*::__u*::variant instead of std::variant).
(b) It will also display default template arguments, e.g.
template 
class MyClass
is printed as MyClass (I think) in getFullyQualifiedName, while
getAsString() will use MyClass.
(c) the example of the nested template argument above.

At the end,what matters is that getAsString() is semantically always
correct, even if it can be overly verbose. I tried to
fix getFullyQualifiedName, but I do not understand its code.

3. When the goal we want to reach has been decided, there is also the
question on how to transition from the current state to the next state, and
who can help with that. To be way clearer, I won't be able to fix all of
Google internal usage of this function (I am not at all working on Clang,
Clif, or any tools, I just hit the bug and decided to look into it, and it
happened that I found a fix). Thus, if we can do the changes using
iterative steps, such as
(a) add the new "::" prefix configuration,
(b) Deprecate/document the fact that getFullyQualifiedName has a bug, and
people should move to use qual_type.getAsString(Policy) instead, using
"FullyQualifiedName" and "GlobalScopeQualifiedName". We can for example
provide :

std::string GetFullyQualifiedCanonicalType(QualType qual_type, const
ASTContext ,)
  clang::PrintingPolicy print_policy(ast.GetASTContext().getLangOpts());
  print_policy.FullyQualifiedName = 1;
  print_policy.SuppressScope = 0;
  print_policy.PrintCanonicalTypes = 1;
  print_policy.GlobalScopeQualifiedName = 1;
  QualType canonical_type = qual_type.getCanonicalType();
  return canonical_type.getAsString(print_policy);
}
(c) Then, people can upgrade asynchronously, maybe someone will be unhappy
with this behavior and will suggest something else, etc.

If we just blindly delete it, it means for example that we have to fix all
usages in Google to be able to upgrade Clang.  It may be the approach that
is decided we should follow, but I just wanted to make it clear that I will
not be able to do that job^^ While, having an incremental fix in Clang, and
then fix Clif is doable as it does not imply to fix all calls in one go.

I just wanted to develop these points.

Thanks!

On Tue, May 12, 2020 at 7:59 PM David Blaikie  wrote:

> +Mr. Smith for visibility.
>
> I'm /guessing/ the right path might be to change the implementation of
> getFullyQualifiedName to use the type printing/pretty printer approach with
> the extra feature you're suggesting. That way all users get the desired
> behavior
>
> +Sam McCall   who (if I understand correctly) has a
> lot to do with the Clang Tooling work - looks like Google's got a bunch of
> uses of this function (getFullyQualifiedName) internally in clang tools (I
> wonder why that's the case when there are still zero external callers - is
> that OK? Or are external users doing something different (better? worse?)
> to answer this question - or the tooling uses in LLVM proper just don't
> have the same needs?). So probably best not to leave a buggy implementation
> lying around - either deleting it, or fixing it.
>
> On Mon, May 11, 2020 at 11:28 PM Jean-Baptiste Lespiau via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi,
>>
>> *Context and history:*
>>
>> I have found a bug in CLIF , which does
>> not correctly fully qualify templated names when they are nested, e.g.
>>
>> ::tensorfn::Nested< ::std::variant >
>>
>> should have been:
>>
>> ::tensorfn::Nested<
>> ::std::variant<::tensorflow::Tensor,::tensorfn::DeviceTensor> >
>>
>> I tracked it down to
>> https://github.com/google/clif/blob/master/clif/backend/matcher.cc#L172
>> which calls
>> https://github.com/llvm-mirror/clang/blob/master/lib/AST/QualTypeNames.cpp
>> and the error is exactly at the line, but I could not really understand
>> why.
>>
>> https://github.com/llvm-mirror/clang/blob/master/lib/AST/QualTypeNames.cpp#L457
>>
>> Historically, it has been added by the developers of CLIF
>> (including Sterling Augustine)
>>
>> https://github.com/llvm/llvm-project/commit/0dd191a5c4bf27cc8a2b6033436b00f0cbdc4ce7
>> .
>> They explained to me, that they pushed this to Clang hoping it would be
>> used by other tools and maintained by the community, but that it kind of
>> failed at that, and it (i.e. QualTypeName.pp) is not much used, and not
>> much maintained.
>>
>> I was 

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13111
+  }
+  }
+  return std::make_tuple(false, CharUnits::Zero(), CharUnits::Zero());

rjmccall wrote:
> Derived-to-base conversions.
Does this include cases where bases are virtual? I think that would be more 
complex as it requires tracking the most-derived object. Do you think it's 
important to handle virtual bases in this patch or should it be done separately 
in a follow-up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D75936#2032078 , @sconstab wrote:

> In D75936#2032027 , @nikic wrote:
>
> > This change causes a 0.8% compile-time regression for unoptimized builds 
> > .
> >  Based on the pipeline test diffs, I expect this is because the new pass 
> > requests a bunch of analyses, which it most likely (LVI load hardening 
> > disabled) will not need. Would it be possible to compute the analyses only 
> > if LVI load hardening is actually enabled?
>
>
> @craig.topper Do you have any ideas on how this could be done?


Unfortunately due to LTO the need for LVI hardening is carried as a function 
attribute. The pass manager system doesn't allow for running different passes 
per function. So I don't have any good ideas of how to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-12 Thread Scott Constable via Phabricator via cfe-commits
sconstab added a comment.

In D75936#2032027 , @nikic wrote:

> This change causes a 0.8% compile-time regression for unoptimized builds 
> .
>  Based on the pipeline test diffs, I expect this is because the new pass 
> requests a bunch of analyses, which it most likely (LVI load hardening 
> disabled) will not need. Would it be possible to compute the analyses only if 
> LVI load hardening is actually enabled?


@craig.topper Do you have any ideas on how this could be done?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-12 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This change causes a 0.8% compile-time regression for unoptimized builds 
.
 Based on the pipeline test diffs, I expect this is because the new pass 
requests a bunch of analyses, which it most likely (LVI load hardening 
disabled) will not need. Would it be possible to compute the analyses only if 
LVI load hardening is actually enabled?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:227
+  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement() ||
+   FPFeatures.allowFPContractWithinStatement());
 }

michele.scandale wrote:
> I'm not convinced it correct to set `contract` when 
> `allowFPContractWithinStatement` return true. Can someone clarify this?
> 
> If I compile the following example with `-ffp-contract=on`:
> ```
> float test1(float a, float b, float c) {
>   float x = a * b;
>   return x + c;
> }
> 
> float test2(float a, float b, float c) {
>   return a * b + c;
> }
> ```
> 
> Before this change the generated code was:
> ```
> define float @test1(float %a, float %b, float %c) {
>   %0 = fmul float %a, %b
>   %1 = fadd float %0, %c
>   ret float %1
> }
> 
> define float @test2(float %a, float %b, float %c) {
>   %0 = call float @llvm.fmuladd.f32(float %a, float%b, float %c)
>   ret float %0
> }
> ```
> 
> And my understanding is that the in-statement contraction is implemented by 
> emitting the `llvm.fmuladd` call that a backend might decide to implement as 
> `fmul + fadd` or as `fma`.
> 
> With this change the generated code is:
> ```
> define float @test1(float %a, float %b, float %c) {
>   %0 = fmul contract float %a, %b
>   %1 = fadd contract float %0, %c
>   ret float %1
> }
> 
> define float @test2(float %a, float %b, float %c) {
>   %0 = call contract float @llvm.fmuladd.f32(float %a, float%b, float %c)
>   ret float %0
> }
> ```
> and it seems to me that in `test1` (where multiple statements where 
> explicitly used) the optimizer is now allowed to perform the contraction, 
> violating the original program semantic where only "in-statement" contraction 
> was allowed.
Thanks @michele.scandale i will work on a patch for this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79796: [DO NOT REVIEW] Sketch support for generating CC1 command line from CompilerInvocation

2020-05-12 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, mgorny.
Herald added projects: clang, LLVM.
dang added reviewers: Bigcheese, dexonsmith.
dang edited the summary of this revision.

This is an add-on to the RFC at 
http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html 


This only works for -fmodules-strict-context-hash at the moment.
This introduces optional additional information in Option records that can
specify a mapping between an option and a field of a class (used here for
CompilerInvocation).
Also it adds a GenerateCC1CommandLine method to Compiler invocation that uses
the TableGen definitions to generate command line argument strings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -33,6 +33,20 @@
   return OS;
 }
 
+static void EmitMarshallingInfo(raw_ostream , const Record ) {
+  OS << R.getValueAsString("KeyPath");
+  OS << ", ";
+  if (!isa(R.getValueInit("IsPositive")))
+OS << R.getValueAsBit("IsPositive");
+  else
+OS << "INVALID";
+  OS << ", ";
+  if (!isa(R.getValueInit("DefaultValue")))
+OS << R.getValueAsString("DefaultValue");
+  else
+OS << "INVALID";
+}
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +149,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record  = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream , const Record ) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -149,7 +159,7 @@
 write_cstring(OS, R.getValueAsString("Name"));
 
 // The option identifier name.
-OS  << ", "<< getOptionName(R);
+OS << ", " << getOptionName(R);
 
 // The option kind.
 OS << ", " << R.getValueAsDef("Kind")->getValueAsString("Name");
@@ -190,8 +200,7 @@
 int NumFlags = 0;
 const ListInit *LI = R.getValueAsListInit("Flags");
 for (Init *I : *LI)
-  OS << (NumFlags++ ? " | " : "")
- << cast(I)->getDef()->getName();
+  OS << (NumFlags++ ? " | " : "") << cast(I)->getDef()->getName();
 if (GroupFlags) {
   for (Init *I : *GroupFlags)
 OS << (NumFlags++ ? " | " : "")
@@ -224,11 +233,33 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
+
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record  = *Opts[i];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
 
+  OS << "#ifdef OPTION_WITH_MARSHALLING\n";
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record  = *Opts[i];
+
+if (!isa(R.getValueInit("MarshallingInfo"))) {
+  OS << "OPTION_WITH_MARSHALLING(";
+  WriteOptRecordFields(OS, R);
+  OS << ", ";
+  EmitMarshallingInfo(
+  OS, *cast(R.getValueInit("MarshallingInfo"))->getDef());
+  OS << ")\n";
+}
+  }
+  OS << "#endif // OPTION_WITH_MARSHALLING\n";
+
   OS << "\n";
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
@@ -252,8 +283,8 @@
 "OptTable!\");\n";
 }
 OS << "}\n";
+}
+OS << "\n";
+OS << "#endif // OPTTABLE_ARG_INIT\n";
   }
-  OS << "\n";
-  OS << "#endif // OPTTABLE_ARG_INIT\n";
-}
 } // end namespace llvm
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -80,6 +80,16 @@
   list Flags = [];
 }
 
+// Add support for generating marshalling code
+
+class OptionMarshallingInfo {
+  code KeyPath = keypath;
+  // Used by the Flag option kind.
+  bit IsPositive = ?;
+  code DefaultValue = ?;
+  list EnumValues = ?;
+}
+
 // Define the option class.
 
 class Option prefixes, string name, OptionKind kind> {
@@ -97,6 +107,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  OptionMarshallingInfo MarshallingInfo = ?;
 }
 
 // Helpers for defining options.
@@ -130,6 +141,22 @@
 class Values { 

Re: Bug in QualTypeNames.cpp and adding an option to prepend "::" to fully qualified names.

2020-05-12 Thread David Blaikie via cfe-commits
+Mr. Smith for visibility.

I'm /guessing/ the right path might be to change the implementation of
getFullyQualifiedName to use the type printing/pretty printer approach with
the extra feature you're suggesting. That way all users get the desired
behavior

+Sam McCall   who (if I understand correctly) has a
lot to do with the Clang Tooling work - looks like Google's got a bunch of
uses of this function (getFullyQualifiedName) internally in clang tools (I
wonder why that's the case when there are still zero external callers - is
that OK? Or are external users doing something different (better? worse?)
to answer this question - or the tooling uses in LLVM proper just don't
have the same needs?). So probably best not to leave a buggy implementation
lying around - either deleting it, or fixing it.

On Mon, May 11, 2020 at 11:28 PM Jean-Baptiste Lespiau via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi,
>
> *Context and history:*
>
> I have found a bug in CLIF , which does
> not correctly fully qualify templated names when they are nested, e.g.
>
> ::tensorfn::Nested< ::std::variant >
>
> should have been:
>
> ::tensorfn::Nested<
> ::std::variant<::tensorflow::Tensor,::tensorfn::DeviceTensor> >
>
> I tracked it down to
> https://github.com/google/clif/blob/master/clif/backend/matcher.cc#L172
> which calls
> https://github.com/llvm-mirror/clang/blob/master/lib/AST/QualTypeNames.cpp
> and the error is exactly at the line, but I could not really understand
> why.
>
> https://github.com/llvm-mirror/clang/blob/master/lib/AST/QualTypeNames.cpp#L457
>
> Historically, it has been added by the developers of CLIF
> (including Sterling Augustine)
>
> https://github.com/llvm/llvm-project/commit/0dd191a5c4bf27cc8a2b6033436b00f0cbdc4ce7
> .
> They explained to me, that they pushed this to Clang hoping it would be
> used by other tools and maintained by the community, but that it kind of
> failed at that, and it (i.e. QualTypeName.pp) is not much used, and not
> much maintained.
>
> I was not able to understand this file to provide a fix. On the other
> side, it was easy to understand TypePrinter.cpp and PrettyPrinter.cpp, so I
> tried extending it to fit my need.
>
> *Suggestion*
>
>  As I wanted fully qualified types (it's usually more convenient for tools
> generating code), to prevent some complex errors), I added ~10 lines that
> add an option to prepend "::" to qualified types (see the patch).
>
> In practice, it is still a different display at what QualTypeNames.cpp was
> doing, as, for example, it displays
>
> ::tensorfn::Nested<::std*::__u*::variant ::tensorfn::DeviceTensor>>
>
> but I was able to solve my issues. More generally, it is more verbose, as
> it displays the exact underlying type, including default parameter types in
> template arguments. So it's verbose, but it's correct (what is best?^^).
>
> I am contacting you, so we can discuss:
>
> - Whether QualTypeNames.cpp
>  
> is
> something useful for the Clang project, whether you think we should fix the
> bug I have found (but I cannot, as I do not understand it), or whether we
> should deprecate it, or modify the current printing mechanism
> (TypePrinter.cpp and PrettyPrinter.cpp) to add more options to tune the
> display in ways people may want to.
> - Whether adding the CL I have attached is positive, and if yes, what
> should be done in addition to that (does it need tests? Are there more
> types that we may want to prepend "::" to its fully qualified name?).
>
> Thanks!
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78444: Perform ActOnConversionDeclarator after looking for any virtual functions it overrides

2020-05-12 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler updated this revision to Diff 263466.
rdwampler added a comment.

Fixed indentation.


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

https://reviews.llvm.org/D78444

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/conversion-function.cpp


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' 
to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function 
converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function 
converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10486,15 +10486,12 @@
 
   // Make sure we aren't redeclaring the conversion function.
   QualType ConvType = 
Context.getCanonicalType(Conversion->getConversionType());
-
   // C++ [class.conv.fct]p1:
   //   [...] A conversion function is never used to convert a
   //   (possibly cv-qualified) object to the (possibly cv-qualified)
   //   same object type (or a reference to it), to a (possibly
   //   cv-qualified) base class of that type (or a reference to it),
   //   or to (possibly cv-qualified) void.
-  // FIXME: Suppress this warning if the conversion function ends up being a
-  // virtual function that overrides a virtual function in a base class.
   QualType ClassType
 = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
   if (const ReferenceType *ConvTypeRef = ConvType->getAs())
@@ -10502,6 +10499,8 @@
   if (Conversion->getTemplateSpecializationKind() != TSK_Undeclared &&
   Conversion->getTemplateSpecializationKind() != 
TSK_ExplicitSpecialization)
 /* Suppress diagnostics for instantiations. */;
+  else if (Conversion->size_overridden_methods() != 0)
+/* Suppress diagnostics for overriding virtual function in a base class. 
*/;
   else if (ConvType->isRecordType()) {
 ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
 if (ConvType == ClassType)
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10716,9 +10716,6 @@
   return Redeclaration;
 }
   }
-} else if (CXXConversionDecl *Conversion
-   = dyn_cast(NewFD)) {
-  ActOnConversionDeclarator(Conversion);
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())
 CheckDeductionGuideTemplate(TD);
@@ -10747,6 +10744,9 @@
 checkThisInStaticMemberFunctionType(Method);
 }
 
+if (CXXConversionDecl *Conversion = dyn_cast(NewFD))
+  ActOnConversionDeclarator(Conversion);
+
 // Extra checking for C++ overloaded operators (C++ [over.oper]).
 if (NewFD->isOverloadedOperator() &&
 CheckOverloadedOperatorDeclaration(NewFD)) {


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10486,15 

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-12 Thread Steve Canon via Phabricator via cfe-commits
scanon added a comment.

> Prior to this change contract was never generated in the case of in-statement 
> contraction only, instead clang was emitting llvm.fmuladd to inform the 
> backend that only those were eligible for contraction. From a correctness 
> perspective I think this was perfectly fine.
> 
> Currently I don't see any logic to generate "blocking intrinsics" (I guess to 
> define a region around the instructions emitted for the given statement). 
> Until such mechanism is in place, I think that generating the contract 
> fast-math flag also for in-statement contraction is wrong because it breaks 
> the original program semantic.

This is exactly right. If we are going to have new in-statement optimizations, 
then we probably do need to add some blocking intrinsic (which would be 
elidable given suitable fast-math flags); the system of generating fmuladd 
works well for FMA contraction, but doesn't really generalize to other 
optimizations of this sort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79237: [CUDA][HIP] Fix constexpr variables for C++17

2020-05-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> constexpr variables are compile time constants and implicitly const, therefore
>  they are safe to emit on both device and host side. Besides, in many cases
>  they are intended for both device and host, therefore it makes sense
>  to emit them on both device and host sides if necessary.
> 
> In most cases constexpr variables are used as rvalue and the variables
>  themselves do not need to be emitted.

Agreed so far. constexpr values are usable on both sides.

> However if their address is taken, then they need to be emitted.

Agreed.

That's where the fun starts. Will this assertion trigger or not?

constexpr int ce = 42;
__global__ void kernel() {

  assert(p == ); 

}
void f() {

  kernel<<<1,1>>>();

}

  NVCC does not allow accessing ce, so this does not compile.
  Clang allows taking a reference, but the variable is not emitted, so the 
failure will happen in ptxas.
  If compiler does emit ce on device side, the addresses will be different, 
unless we rely on 
   CUDA runtime magic to translate addresses of shadows into real device-side 
address.
  If we do that, then we should probably add an implicit __constant__ on the 
constexpr vars.
  
  > 
  > The following example shows constexpr is available on device side without
  > __device__ or __constant__ attribute
  > 
  > https://godbolt.org/z/Uf7CgK
  
  If you clear output filters, you will see that the reference to constexpr is 
emitted as `.extern .global .align 4 .u32 _ZN1B1bE;` and the varible's address 
is not actually available. If you were to actually compile the example, ptxas 
would complain about ti.
  NVCC, predictably, allows using constexpr values, but not the variables 
themselves: https://godbolt.org/z/DXy65T


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

https://reviews.llvm.org/D79237



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

No, if that's how we handle that, then you're absolutely right that we 
shouldn't set the `contract` flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79742: [WebAssembly] Implement pseudo-min/max SIMD instructions

2020-05-12 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d49d1cfa768: [WebAssembly] Implement pseudo-min/max SIMD 
instructions (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79742

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -535,6 +535,12 @@
 # CHECK: f32x4.max # encoding: [0xfd,0xe9,0x01]
 f32x4.max
 
+# CHECK: f32x4.pmin # encoding: [0xfd,0xea,0x01]
+f32x4.pmin
+
+# CHECK: f32x4.pmax # encoding: [0xfd,0xeb,0x01]
+f32x4.pmax
+
 # CHECK: f64x2.abs # encoding: [0xfd,0xec,0x01]
 f64x2.abs
 
@@ -562,6 +568,12 @@
 # CHECK: f64x2.max # encoding: [0xfd,0xf5,0x01]
 f64x2.max
 
+# CHECK: f64x2.pmin # encoding: [0xfd,0xf6,0x01]
+f64x2.pmin
+
+# CHECK: f64x2.pmax # encoding: [0xfd,0xf7,0x01]
+f64x2.pmax
+
 # CHECK: i32x4.trunc_sat_f32x4_s # encoding: [0xfd,0xf8,0x01]
 i32x4.trunc_sat_f32x4_s
 
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -501,6 +501,26 @@
   ret <4 x float> %a
 }
 
+; CHECK-LABEL: pmin_v4f32:
+; SIMD128-NEXT: .functype pmin_v4f32 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmin.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmin_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmin.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
+; CHECK-LABEL: pmax_v4f32:
+; SIMD128-NEXT: .functype pmax_v4f32 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmax.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmax_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmax.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
 ; CHECK-LABEL: qfma_v4f32:
 ; SIMD128-NEXT: .functype qfma_v4f32 (v128, v128, v128) -> (v128){{$}}
 ; SIMD128-NEXT: f32x4.qfma $push[[R:[0-9]+]]=, $0, $1, $2{{$}}
@@ -540,6 +560,26 @@
   ret <2 x double> %a
 }
 
+; CHECK-LABEL: pmin_v2f64:
+; SIMD128-NEXT: .functype pmin_v2f64 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmin.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmin_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmin.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: pmax_v2f64:
+; SIMD128-NEXT: .functype pmax_v2f64 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f64x2.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmax.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmax_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmax.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
 ; CHECK-LABEL: qfma_v2f64:
 ; SIMD128-NEXT: .functype qfma_v2f64 (v128, v128, v128) -> (v128){{$}}
 ; SIMD128-NEXT: f64x2.qfma $push[[R:[0-9]+]]=, $0, $1, $2{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -794,6 +794,12 @@
 // NaN-propagating maximum: max
 defm MAX : SIMDBinaryFP;
 
+// Pseudo-minimum: pmin
+defm PMIN : SIMDBinaryFP;
+
+// Pseudo-maximum: pmax
+defm PMAX : SIMDBinaryFP;
+
 //===--===//
 // Conversions
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -176,6 +176,17 @@
 [llvm_anyvector_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
+// TODO: Replace these intrinsics with normal ISel patterns once the
+// pmin/pmax instructions are merged to the 

[clang] 3d49d1c - [WebAssembly] Implement pseudo-min/max SIMD instructions

2020-05-12 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-05-12T09:39:01-07:00
New Revision: 3d49d1cfa768c046394b316d838907f2018390b8

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

LOG: [WebAssembly] Implement pseudo-min/max SIMD instructions

Summary:
As proposed in https://github.com/WebAssembly/simd/pull/122. Since
these instructions are not yet merged to the SIMD spec proposal, this
patch makes them entirely opt-in by surfacing them only through LLVM
intrinsics and clang builtins. If these instructions are made
official, these intrinsics and builtins should be replaced with simple
instruction patterns.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/wasm_simd128.h
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 3c7e27544856..5955237a0f58 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -139,8 +139,12 @@ TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_min_f32x4, "V4fV4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmin_f32x4, "V4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmax_f32x4, "V4fV4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmin_f64x2, "V2dV2dV2d", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmax_f64x2, "V2dV2dV2d", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 47620c13aed6..5166f91e252c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15758,6 +15758,22 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
  ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_pmin_f32x4:
+  case WebAssembly::BI__builtin_wasm_pmin_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee =
+CGM.getIntrinsic(Intrinsic::wasm_pmin, ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
+  case WebAssembly::BI__builtin_wasm_pmax_f32x4:
+  case WebAssembly::BI__builtin_wasm_pmax_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee =
+CGM.getIntrinsic(Intrinsic::wasm_pmax, ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_swizzle_v8x16: {
 Value *Src = EmitScalarExpr(E->getArg(0));
 Value *Indices = EmitScalarExpr(E->getArg(1));

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index b81594efcc82..51e2a07716b3 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -937,6 +937,16 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_f32x4_max(v128_t __a,
   return (v128_t)__builtin_wasm_max_f32x4((__f32x4)__a, (__f32x4)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmin(v128_t __a,
+v128_t __b) {
+  return (v128_t)__builtin_wasm_pmin_f32x4((__f32x4)__a, (__f32x4)__b);
+}
+
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmax(v128_t __a,
+v128_t __b) {
+  return (v128_t)__builtin_wasm_pmax_f32x4((__f32x4)__a, (__f32x4)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f64x2((__f64x2)__a);
 }
@@ -997,6 +1007,16 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_f64x2_max(v128_t __a,
   return (v128_t)__builtin_wasm_max_f64x2((__f64x2)__a, (__f64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmin(v128_t __a,
+

[PATCH] D79565: Add -print-targets to print the registered targets

2020-05-12 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.

Thanks!


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

https://reviews.llvm.org/D79565



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


[clang] 25a95f4 - [gcov][test] Fix clang test

2020-05-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-05-12T09:21:19-07:00
New Revision: 25a95f49b07ff5796f4dfc3d4c05e4c09c6bef4d

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

LOG: [gcov][test] Fix clang test

Added: 


Modified: 
clang/test/CodeGen/code-coverage.c

Removed: 




diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index 5c73760f9a28..2b3e90fac5cd 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -1,11 +1,12 @@
-/// We support coverage versions 4.2 and 4.7.
-/// 4.7 (default, compatible with gcov 7) enables cfg_checksum.
+/// We support coverage versions 4.2, 4.7 and 4.8.
+/// 4.7 enables cfg_checksum.
+/// 4.8 (default, compatible with gcov 7) emits the exit block the second.
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data 
-coverage-version='402*' %s -o - | \
 // RUN:   FileCheck --check-prefixes=CHECK,402 %s
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data 
-coverage-version='407*' %s -o - | \
 // RUN:   FileCheck --check-prefixes=CHECK,407 %s
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data %s -o - | 
\
-// RUN:   FileCheck --check-prefixes=CHECK,407 %s
+// RUN:   FileCheck --check-prefixes=CHECK,408 %s
 
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data 
-coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -dwarf-column-info 
-debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix 
GCOV_FILE_INFO
 
@@ -36,6 +37,7 @@ int test2(int b) {
 
 // 402: private unnamed_addr constant [5 x i8] c"*204\00"
 // 407: private unnamed_addr constant [5 x i8] c"*704\00"
+// 408: private unnamed_addr constant [5 x i8] c"*804\00"
 
 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr 
constant [2 x %0]
 // CHECK-SAME: [%0 zeroinitializer, %0 { i32 1, i32 0, i32 0 }]



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


[clang] b56b1e6 - [gcov] Default coverage version to '408*' and delete CC1 option -coverage-exit-block-before-body

2020-05-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-05-12T09:14:03-07:00
New Revision: b56b1e67e38e5f18318b411587a952bc7c586ac4

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

LOG: [gcov] Default coverage version to '408*' and delete CC1 option 
-coverage-exit-block-before-body

gcov 4.8 (r189778) moved the exit block from the last to the second.
The .gcda format is compatible with 4.7 but

* decoding libgcov 4.7 produced .gcda with gcov [4.7,8) can mistake the
  exit block, emit bogus `%s:'%s' has arcs from exit block\n` warnings,
  and print wrong `" returned %s` for branch statistics (-b).
* decoding libgcov 4.8 produced .gcda with gcov 4.7 has similar issues.

Also, rename "return block" to "exit block" because the latter is the
appropriate term.

Added: 
llvm/test/Transforms/GCOVProfiling/exit-block.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/Basic/CodeGenOptions.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/ProfileData/GCOV.h
llvm/include/llvm/Transforms/Instrumentation.h
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/test/Transforms/GCOVProfiling/version.ll

Removed: 
llvm/test/Transforms/GCOVProfiling/return-block.ll



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 61982da889ed..363ee1eb16ac 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -39,7 +39,6 @@ CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether 
ARC should be EH-safe
 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
 CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0) ///< -cfguard-no-checks
 CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
-CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit 
block before the body blocks in GCNO files.
 CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling 
destructors.
 CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or 
__cxa_atexit to register global destructors.
 CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index 7e0038e04b01..526a51085ce7 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -262,8 +262,6 @@ def coverage_notes_file : Separate<["-"], 
"coverage-notes-file">,
   HelpText<"Emit coverage notes to this filename.">;
 def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">,
   Alias;
-def coverage_exit_block_before_body : Flag<["-"], 
"coverage-exit-block-before-body">,
-  HelpText<"Emit the exit block before the body blocks in .gcno files.">;
 def coverage_version_EQ : Joined<["-"], "coverage-version=">,
   HelpText<"Four-byte version string for gcov files.">;
 def test_coverage : Flag<["-"], "test-coverage">,

diff  --git a/clang/lib/Basic/CodeGenOptions.cpp 
b/clang/lib/Basic/CodeGenOptions.cpp
index 8d3aeda1b91f..4fc7a535c9eb 100644
--- a/clang/lib/Basic/CodeGenOptions.cpp
+++ b/clang/lib/Basic/CodeGenOptions.cpp
@@ -17,7 +17,7 @@ CodeGenOptions::CodeGenOptions() {
 #include "clang/Basic/CodeGenOptions.def"
 
   RelocationModel = llvm::Reloc::PIC_;
-  memcpy(CoverageVersion, "407*", 4);
+  memcpy(CoverageVersion, "408*", 4);
 }
 
 bool CodeGenOptions::isNoBuiltinFunc(const char *Name) const {

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 0dc6c08eafe3..7b876df852b5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -533,7 +533,6 @@ static Optional getGCOVOptions(const 
CodeGenOptions ) {
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
   Options.Filter = CodeGenOpts.ProfileFilterFiles;
   Options.Exclude = CodeGenOpts.ProfileExcludeFiles;
-  Options.ExitBlockBeforeBody = CodeGenOpts.CoverageExitBlockBeforeBody;
   return Options;
 }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 649e78e19c93..ff2683c3db70 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1021,8 +1021,6 @@ static bool ParseCodeGenArgs(CodeGenOptions , 
ArgList , InputKind IK,
 std::string(Args.getLastArgValue(OPT_fprofile_filter_files_EQ));
 Opts.ProfileExcludeFiles =
 std::string(Args.getLastArgValue(OPT_fprofile_exclude_files_EQ));
-Opts.CoverageExitBlockBeforeBody =
-Args.hasArg(OPT_coverage_exit_block_before_body);
 if (Args.hasArg(OPT_coverage_version_EQ)) {
   StringRef CoverageVersion = 

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-12 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

In D72841#2030707 , @rjmccall wrote:

> IIUC, the way within-statement contraction is supposed to work is that there 
> are supposed to be blocking intrinsics inserted at various places.  I don't 
> remember the details, though, or if anyone's thought about how it interacts 
> with cross-statement contraction, which this pragma permits within the same 
> function (and could occur with inlining regardless).


Prior to this change `contract` was never generated in the case of in-statement 
contraction only, instead clang was emitting `llvm.fmuladd` to inform the 
backend that only those were eligible for contraction. From a correctness 
perspective I think this was perfectly fine.

Currently I don't see any logic to generate "blocking intrinsics" (I guess to 
define a region around the instructions emitted for the given statement). Until 
such mechanism is in place, I think that generating the `contract` fast-math 
flag  also for in-statement contraction is wrong because it breaks the original 
program semantic.

Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov marked 3 inline comments as done.
ASDenysPetrov added a comment.

> The measurements I mentioned earlier about runtimes, node count and so on 
> could help answer some of those questions.

I'm looking for an appropriate project to measure performance, since I have 
some troubles running the test-suite on Windows.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:597
+  static constexpr size_t CmpOpCount = BO_NE - BO_LT + 1;
+  static const TriState CmpOpTable[CmpOpCount][CmpOpCount + 1] = {
+  // <  >  <= >= == !=UnknownX2

xazax.hun wrote:
> I think this table together with the operations that transform between 
> indices and operators could be factored out into a separate class. That would 
> make this method slightly cleaner.
I'll try to come up how to turn it into the class.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:613
+
+  auto OP = SSE->getOpcode();
+

xazax.hun wrote:
> In LLVM we usually only use `auto` for iterators and to avoid repeating the 
> type twice. Auto is ok above with the `dynamic_cast`, but here and some other 
> places the type should be spelled out.
Thanks for the guidance, I'll check the code for implicit types.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:668
+
+auto BranchState = CmpOpTable[IndexSymOP][IndexPrevOP];
+

xazax.hun wrote:
> I think `IndexPrevOP` is confusing as the "previous" operation is not 
> necessarily the previous operation we evaluated. In fact `IndexPrevOP` could 
> have been evaluated any time in the past. We query the known facts that are 
> known for the current state, I think this is what the names should reflect. I 
> suggest to use `CurrentOP` and `QueriedOP`.
No problem. I'll rename them.


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

https://reviews.llvm.org/D78933



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


[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 263447.
balazske added a comment.

Added state split before fread to make warning for error state possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -3,6 +3,7 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
 void StreamTesterChecker_make_feof_stream(FILE *);
 void StreamTesterChecker_make_ferror_stream(FILE *);
 
@@ -53,6 +54,80 @@
   fclose(F);
 }
 
+void error_fread() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  int Ret = fread(0, 1, 10, F);
+  if (Ret == 10) {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{TRUE}}
+if (feof(F)) {
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  fread(0, 1, 10, F); // expected-warning {{Function called when stream has already error state}}
+}
+if (ferror(F)) {
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  fread(0, 1, 10, F); // expected-warning {{Stream might be in indeterminate state}}
+}
+  }
+  fclose(F);
+  Ret = fread(0, 1, 10, F); // expected-warning {{Stream might be already closed}}
+}
+
+void error_fwrite() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  int Ret = fwrite(0, 1, 10, F);
+  if (Ret == 10) {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+fwrite(0, 1, 10, F);// expected-warning {{Stream might be in indeterminate state}}
+  }
+  fclose(F);
+  Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already closed}}
+}
+
+void freadwrite_zerosize(FILE *F) {
+  fwrite(0, 1, 0, F);
+  fwrite(0, 0, 1, F);
+  fread(0, 1, 0, F);
+  fread(0, 0, 1, F);
+}
+
+void freadwrite_zerosize_errorstate(FILE *F) {
+  fwrite(0, 1, 0, F);
+  fwrite(0, 0, 1, F);
+  fread(0, 1, 0, F); // expected-warning {{Function called when stream has already error state}}
+  fread(0, 0, 1, F); // expected-warning {{Function called when stream has already error state}}
+}
+
+void error_fread_fwrite_zerosize() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+
+  freadwrite_zerosize(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+
+  StreamTesterChecker_make_ferror_stream(F);
+  freadwrite_zerosize_errorstate(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+
+  StreamTesterChecker_make_feof_stream(F);
+  freadwrite_zerosize_errorstate(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{TRUE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+
+  fclose(F);
+}
+
 void error_fseek() {
   FILE *F = fopen("file", "r");
   if (!F)
@@ -83,3 +158,34 @@
   }
   fclose(F);
 }
+
+void error_fseek_indeterminate() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (feof(F)) {
+  fwrite(0, 1, 10, F); // no warning
+} else if (ferror(F)) {
+  fwrite(0, 1, 10, F); // expected-warning {{Stream might be in indeterminate state}}
+} else {
+  fwrite(0, 1, 10, F); // expected-warning {{Stream might be in indeterminate state}}
+}
+  }
+  fclose(F);
+}
+
+void error_clearerr_indeterminate() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (!feof(F)) {
+  clearerr(F);
+  fwrite(0, 1, 10, F); // expected-warning {{Stream might be in indeterminate state}}
+}
+  }
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -19,15 +19,66 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include 
 
 using namespace clang;
 using namespace ento;
+using namespace std::placeholders;
 
 namespace {
 
 struct FnDescription;
 
+/// State of the stream related error flags.
+/// It indicates possibility of different error states.
+/// In other sense, every set flag means a separate 

[clang] ffcaed3 - [Matrix] Check non-dependent elt type before creating DepSizedMatrix.

2020-05-12 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-05-12T16:46:37+01:00
New Revision: ffcaed32ef1cf5226cc376b6c911183db690402f

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

LOG: [Matrix] Check non-dependent elt type before creating DepSizedMatrix.

We should check non-dependent element types before creating a
DependentSizedMatrixType. Otherwise we do not generate an error message
for dependent-sized matrix types with invalid non-dependent element
types, if the template is never instantiated. See the make5 struct in
the tests.

It also moves the SEMA template tests to
clang/test/SemaTemplate/matrix-type.cpp and introduces a few more test
cases.

Added: 
clang/test/SemaTemplate/matrix-type.cpp

Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/matrix-type.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index df8ad7ad78b9..1822951266f5 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2574,11 +2574,6 @@ QualType Sema::BuildMatrixType(QualType ElementTy, Expr 
*NumRows, Expr *NumCols,
   assert(Context.getLangOpts().MatrixTypes &&
  "Should never build a matrix type when it is disabled");
 
-  if (NumRows->isTypeDependent() || NumCols->isTypeDependent() ||
-  NumRows->isValueDependent() || NumCols->isValueDependent())
-return Context.getDependentSizedMatrixType(ElementTy, NumRows, NumCols,
-   AttrLoc);
-
   // Check element type, if it is not dependent.
   if (!ElementTy->isDependentType() &&
   !MatrixType::isValidElementType(ElementTy)) {
@@ -2586,6 +2581,11 @@ QualType Sema::BuildMatrixType(QualType ElementTy, Expr 
*NumRows, Expr *NumCols,
 return QualType();
   }
 
+  if (NumRows->isTypeDependent() || NumCols->isTypeDependent() ||
+  NumRows->isValueDependent() || NumCols->isValueDependent())
+return Context.getDependentSizedMatrixType(ElementTy, NumRows, NumCols,
+   AttrLoc);
+
   // Both row and column values can only be 20 bit wide currently.
   llvm::APSInt ValueRows(32), ValueColumns(32);
 

diff  --git a/clang/test/SemaCXX/matrix-type.cpp 
b/clang/test/SemaCXX/matrix-type.cpp
index 76f288d83e6e..af31e267fdca 100644
--- a/clang/test/SemaCXX/matrix-type.cpp
+++ b/clang/test/SemaCXX/matrix-type.cpp
@@ -29,101 +29,3 @@ void matrix_unsupported_element_type() {
   using matrix3_t = bool __attribute__((matrix_type(1, 1))); // 
expected-error{{invalid matrix element type 'bool'}}
   using matrix4_t = TestEnum __attribute__((matrix_type(1, 1))); // 
expected-error{{invalid matrix element type 'TestEnum'}}
 }
-
-template  // expected-note{{declared here}}
-void matrix_template_1() {
-  using matrix1_t = float __attribute__((matrix_type(T, T))); // 
expected-error{{'T' does not refer to a value}}
-}
-
-template  // expected-note{{declared here}}
-void matrix_template_2() {
-  using matrix1_t = float __attribute__((matrix_type(C, C))); // 
expected-error{{'C' does not refer to a value}}
-}
-
-template 
-void matrix_template_3() {
-  using matrix1_t = float __attribute__((matrix_type(Rows, Cols))); // 
expected-error{{zero matrix size}}
-}
-
-void instantiate_template_3() {
-  matrix_template_3<1, 10>();
-  matrix_template_3<0, 10>(); // expected-note{{in instantiation of function 
template specialization 'matrix_template_3<0, 10>' requested here}}
-}
-
-template 
-void matrix_template_4() {
-  using matrix1_t = float __attribute__((matrix_type(Rows, Cols))); // 
expected-error{{matrix row size too large}}
-}
-
-void instantiate_template_4() {
-  matrix_template_4<2, 10>();
-  matrix_template_4<-3, 10>(); // expected-note{{in instantiation of function 
template specialization 'matrix_template_4<-3, 10>' requested here}}
-}
-
-template 
-using matrix = T __attribute__((matrix_type(R, C)));
-
-template 
-void use_matrix(matrix ) {}
-// expected-note@-1 {{candidate function [with T = float, R = 10]}}
-
-template 
-void use_matrix(matrix ) {}
-// expected-note@-1 {{candidate function [with T = float, C = 10]}}
-
-void test_ambigous_deduction1() {
-  matrix m;
-  use_matrix(m);
-  // expected-error@-1 {{call to 'use_matrix' is ambiguous}}
-}
-
-template 
-void type_conflict(matrix , T x) {}
-// expected-note@-1 {{candidate template ignored: deduced conflicting types 
for parameter 'T' ('float' vs. 'char *')}}
-
-void test_type_conflict(char *p) {
-  matrix m;
-  type_conflict(m, p);
-  // expected-error@-1 {{no matching function for call to 'type_conflict'}}
-}
-
-template 
-matrix use_matrix_2(matrix ) {}
-// expected-note@-1 {{candidate function template not viable: requires single 
argument 'm', but 2 arguments were provided}}
-// expected-note@-2 {{candidate function template not viable: 

[PATCH] D77802: [analyzer] Improved RangeSet::Negate support of unsigned ranges

2020-05-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ , ping. Look please.


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

https://reviews.llvm.org/D77802



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


[PATCH] D79788: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, Anastasia, svenvh.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

-nogpulib makes sense when there is a host (where -nostdlib would
apply) and offload target. Accept nostdlib when there is no offload
target as an alias.


https://reviews.llvm.org/D79788

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/rocm-detect.hip
  clang/test/Driver/rocm-not-found.cl


Index: clang/test/Driver/rocm-not-found.cl
===
--- clang/test/Driver/rocm-not-found.cl
+++ clang/test/Driver/rocm-not-found.cl
@@ -7,5 +7,7 @@
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 
2>&1 | FileCheck %s --check-prefix ERR
 // ERR: cannot find ROCm installation. Provide its path via --rocm-path, or 
pass -nogpulib.
 
+// Accept nogpulib or nostdlib for OpenCL.
 // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
+// RUN: %clang -### -nostdlib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
 // OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-detect.hip
===
--- /dev/null
+++ clang/test/Driver/rocm-detect.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Make sure the appropriate device specific library is available.
+
+// We don't include every target in the test directory, so just pick a valid
+// target not included in the test.
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+// Should not interpret -nostdlib as disabling offload libraries.
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nostdlib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nogpulib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902,NODEFAULTLIBS %s
+
+
+// GFX902-DEFAULTLIBS: error: cannot find device library for gfx902. Provide 
path to different ROCm installation via --rocm-path, or pass -nogpulib to build 
without linking default libraries.
+
+// NODEFAULTLIBS-NOT: error: cannot find
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -361,6 +361,12 @@
   AMDGPUToolChain::addClangTargetOptions(DriverArgs, CC1Args,
  DeviceOffloadingKind);
 
+  // For the OpenCL case where there is no offload target, accept -nostdlib to
+  // disable bitcode linking.
+  if (DeviceOffloadingKind == Action::OFK_None &&
+  DriverArgs.hasArg(options::OPT_nostdlib))
+return;
+
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 


Index: clang/test/Driver/rocm-not-found.cl
===
--- clang/test/Driver/rocm-not-found.cl
+++ clang/test/Driver/rocm-not-found.cl
@@ -7,5 +7,7 @@
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
 // ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
 
+// Accept nogpulib or nostdlib for OpenCL.
 // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// RUN: %clang -### -nostdlib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
 // OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-detect.hip
===
--- /dev/null
+++ clang/test/Driver/rocm-detect.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Make sure the appropriate device specific library is available.
+
+// We don't include every target in the test directory, so just pick a valid
+// target not included in the test.
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+// Should not interpret -nostdlib as disabling offload libraries.
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 

[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata

2020-05-12 Thread Nigel Perks via Phabricator via cfe-commits
nigelp-xmos added a comment.

Thanks for the comment, I will look into that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77068



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


[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata

2020-05-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

It doesn't seem like it would be much work to move the EmitTargetMetadata 
function into the TargetInfo object (as a virtual function taking a reference 
to the collection).  Essentially, have this take a reference to the collection 
instead of the 'D' and 'GV'.

I say that,  because to me it seems that this check should likely be a part of 
that EmitTargetMetadata calling process (meaning, GV! = null is a precondition 
of this function).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77068



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


[PATCH] D79701: [clangd] Add metrics for selection tree and recovery expressions.

2020-05-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG774acdfb8c46: [clangd] Add metrics for selection tree and 
recovery expressions. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D79701?vs=263382=263433#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79701

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "support/TestTracer.h"
 #include "clang/AST/Decl.h"
 #include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
@@ -390,6 +391,7 @@
   )cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
   };
   for (const Case  : Cases) {
+trace::TestTracer Tracer;
 Annotations Test(C.Code);
 
 TestTU TU;
@@ -407,6 +409,7 @@
 if (Test.ranges().empty()) {
   // If no [[range]] is marked in the example, there should be no 
selection.
   EXPECT_FALSE(T.commonAncestor()) << C.Code << "\n" << T;
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"), testing::IsEmpty());
 } else {
   // If there is an expected selection, common ancestor should exist
   // with the appropriate node type.
@@ -422,6 +425,8 @@
   // and no nodes outside it are selected.
   EXPECT_TRUE(verifyCommonAncestor(T.root(), T.commonAncestor(), C.Code))
   << C.Code;
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
+  testing::ElementsAreArray({0}));
 }
   }
 }
@@ -436,6 +441,20 @@
   EXPECT_FALSE(D->isInjectedClassName());
 }
 
+TEST(SelectionTree, Metrics) {
+  const char *Code = R"cpp(
+// error-ok: testing behavior on recovery expression
+int foo();
+int foo(int, int);
+int x = fo^o(42);
+  )cpp";
+  auto AST = TestTU::withCode(Annotations(Code).code()).build();
+  trace::TestTracer Tracer;
+  auto T = makeSelectionTree(Code, AST);
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
+  testing::ElementsAreArray({1}));
+}
+
 // FIXME: Doesn't select the binary operator node in
 //  #define FOO(X) X + 1
 //  int a, b = [[FOO(a)]];
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
@@ -35,6 +36,21 @@
 using Node = SelectionTree::Node;
 using ast_type_traits::DynTypedNode;
 
+// Measure the fraction of selections that were enabled by recovery AST.
+void recordMetrics(const SelectionTree ) {
+  static constexpr trace::Metric SelectionUsedRecovery(
+  "selection_recovery", trace::Metric::Distribution);
+  const auto *Common = S.commonAncestor();
+  for (const auto *N = Common; N; N = N->Parent) {
+if (N->ASTNode.get()) {
+  SelectionUsedRecovery.record(1); // used recovery ast.
+  return;
+}
+  }
+  if (Common)
+SelectionUsedRecovery.record(0); // unused.
+}
+
 // An IntervalSet maintains a set of disjoint subranges of an array.
 //
 // Initially, it contains the entire array.
@@ -774,6 +790,7 @@
.printToString(SM));
   Nodes = SelectionVisitor::collect(AST, Tokens, PrintPolicy, Begin, End, FID);
   Root = Nodes.empty() ? nullptr : ();
+  recordMetrics(*this);
   dlog("Built selection tree\n{0}", *this);
 }
 


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "support/TestTracer.h"
 #include "clang/AST/Decl.h"
 #include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
@@ -390,6 +391,7 @@
   )cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
   };
   for (const Case  : Cases) {
+trace::TestTracer Tracer;
 Annotations Test(C.Code);
 
 TestTU TU;
@@ -407,6 +409,7 @@
 if (Test.ranges().empty()) {
   // If no [[range]] is marked in the example, there should be no selection.
   EXPECT_FALSE(T.commonAncestor()) << C.Code << "\n" << T;
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"), testing::IsEmpty());
 } else {
   // If there is an expected selection, common ancestor should exist
   // with the appropriate node 

[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4684
 return false;
   case CodeGenOptions::SRCK_InRegs: // -msvr4-struct-return
 return true;

jasonliu wrote:
> Xiangling_L wrote:
> > I noticed that in patch https://reviews.llvm.org/D76360, Zarko added a 
> > check to emit an error for using this option within cc1. But in your patch, 
> > this option only emit error when invoked by the driver. Does that mean we 
> > are pretty sure this option is doing what we want on AIX?
> Are you able to set this CodeGen option when it is disabled in the 
> Frontend/CompilerInvocation.cpp?
I would say if you disable it in this function 
`PPC32TargetCodeGenInfo::isStructReturnInRegABI`, neither driver and FE can 
invoke it. However, in your patch, the option is disabled only in the driver, 
that means you can still invoke it with clang_cc1.



Comment at: clang/test/CodeGen/aix-vector.c:11
+}
+

Please remove the extra blank line


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

https://reviews.llvm.org/D79035



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


[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata

2020-05-12 Thread Nigel Perks via Phabricator via cfe-commits
nigelp-xmos added reviewers: jasonliu, erichkeane, RKSimon, jhibbits, ctetreau, 
george.burgess.iv, efriedma.
nigelp-xmos added a comment.

Adding code reviewer suggestions from git history. I would be grateful for 
review and/or reviewer suggestions. Many thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77068



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


[clang-tools-extra] 774acdf - [clangd] Add metrics for selection tree and recovery expressions.

2020-05-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-05-12T16:14:48+02:00
New Revision: 774acdfb8c46de9b4f8a92d80bbbd96e4d467682

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

LOG: [clangd] Add metrics for selection tree and recovery expressions.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Selection.cpp 
b/clang-tools-extra/clangd/Selection.cpp
index 7d52714ad3fa..df7e82ccb2d3 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
@@ -35,6 +36,21 @@ namespace {
 using Node = SelectionTree::Node;
 using ast_type_traits::DynTypedNode;
 
+// Measure the fraction of selections that were enabled by recovery AST.
+void recordMetrics(const SelectionTree ) {
+  static constexpr trace::Metric SelectionUsedRecovery(
+  "selection_recovery", trace::Metric::Distribution);
+  const auto *Common = S.commonAncestor();
+  for (const auto *N = Common; N; N = N->Parent) {
+if (N->ASTNode.get()) {
+  SelectionUsedRecovery.record(1); // used recovery ast.
+  return;
+}
+  }
+  if (Common)
+SelectionUsedRecovery.record(0); // unused.
+}
+
 // An IntervalSet maintains a set of disjoint subranges of an array.
 //
 // Initially, it contains the entire array.
@@ -774,6 +790,7 @@ SelectionTree::SelectionTree(ASTContext , const 
syntax::TokenBuffer ,
.printToString(SM));
   Nodes = SelectionVisitor::collect(AST, Tokens, PrintPolicy, Begin, End, FID);
   Root = Nodes.empty() ? nullptr : ();
+  recordMetrics(*this);
   dlog("Built selection tree\n{0}", *this);
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp 
b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index e1c873a22b13..6f8c10e966a8 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "support/TestTracer.h"
 #include "clang/AST/Decl.h"
 #include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
@@ -390,6 +391,7 @@ TEST(SelectionTest, CommonAncestor) {
   )cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
   };
   for (const Case  : Cases) {
+trace::TestTracer Tracer;
 Annotations Test(C.Code);
 
 TestTU TU;
@@ -407,6 +409,7 @@ TEST(SelectionTest, CommonAncestor) {
 if (Test.ranges().empty()) {
   // If no [[range]] is marked in the example, there should be no 
selection.
   EXPECT_FALSE(T.commonAncestor()) << C.Code << "\n" << T;
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"), testing::IsEmpty());
 } else {
   // If there is an expected selection, common ancestor should exist
   // with the appropriate node type.
@@ -422,6 +425,8 @@ TEST(SelectionTest, CommonAncestor) {
   // and no nodes outside it are selected.
   EXPECT_TRUE(verifyCommonAncestor(T.root(), T.commonAncestor(), C.Code))
   << C.Code;
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
+  testing::ElementsAreArray({0}));
 }
   }
 }
@@ -436,6 +441,20 @@ TEST(SelectionTest, InjectedClassName) {
   EXPECT_FALSE(D->isInjectedClassName());
 }
 
+TEST(SelectionTree, Metrics) {
+  const char *Code = R"cpp(
+// error-ok: testing behavior on recovery expression
+int foo();
+int foo(int, int);
+int x = fo^o(42);
+  )cpp";
+  auto AST = TestTU::withCode(Annotations(Code).code()).build();
+  trace::TestTracer Tracer;
+  auto T = makeSelectionTree(Code, AST);
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
+  testing::ElementsAreArray({1}));
+}
+
 // FIXME: Doesn't select the binary operator node in
 //  #define FOO(X) X + 1
 //  int a, b = [[FOO(a)]];



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


[PATCH] D77885: AMDGPU: Search for new ROCm bitcode library structure

2020-05-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

Device library change submitted. 123bee602a260150ff55c74287f583a67ee78f36 



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

https://reviews.llvm.org/D77885



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


[PATCH] D77885: AMDGPU: Search for new ROCm bitcode library structure

2020-05-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:75
+// The desired structure is (${ROCM_ROOT} or
+// ${OPENCL_ROOT})/amdgcn/bitcode/*, so try to detect this layout.
 

yaxunl wrote:
> with your change, the structure becomes
> 
> ${ROCM_ROOT}/amdgcn/bitcode/*.bc
> 
> Does the toolchain support ${OPENCL_ROOT} ?
This is just pseudocode and no environment variable is read. This corresponds 
to --rocm-path


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

https://reviews.llvm.org/D77885



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


[PATCH] D76957: HIP: Merge builtin library handling

2020-05-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

14e184571139ba4c7347ea547074c6d9ec9c7b14 



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

https://reviews.llvm.org/D76957



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


[PATCH] D79237: [CUDA][HIP] Fix constexpr variables for C++17

2020-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D79237



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


[clang] 14e1845 - HIP: Merge builtin library handling

2020-05-12 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-05-12T09:50:22-04:00
New Revision: 14e184571139ba4c7347ea547074c6d9ec9c7b14

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

LOG: HIP: Merge builtin library handling

Merge with the new --rocm-path handling used for OpenCL. This looks
for a usable set of device libraries upfront, rather than giving a
generic "no such file or directory error". If any of the required
bitcode libraries are missing, this will now produce a "cannot find
ROCm installation." error. This differs from the existing hip specific
flags by pointing to a rocm root install instead of a single directory
with bitcode files.

This tries to maintain compatibility with the existing the
--hip-device-lib and --hip-device-lib-path flags, as well as the
HIP_DEVICE_LIB_PATH environment variable, or at least the range of
uses with testcases. The existing range of uses and behavior doesn't
entirely make sense to me, so some of the untested edge cases change
behavior. Currently the two path forms seem to have the double purpose
of a search path for an arbitrary --hip-device-lib, and for finding
the stock set of libraries. Since the stock set of libraries This also
changes the behavior when multiple paths are specified, and only takes
the last one (and the environment variable only handles a single
path).

If --hip-device-lib is used, it now only treats --hip-device-lib-path
as the search path for it, and does not attempt to find the rocm
installation. If not, --hip-device-lib-path and the environment
variable are used as the directory to search instead of the rocm root
based path.

This should also automatically fix handling of the options to use
wave64.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-device-libs.hip
clang/test/Driver/rocm-device-libs.cl

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 345a24b10018..fd81fec5f452 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -21,6 +21,67 @@ using namespace clang::driver::toolchains;
 using namespace clang;
 using namespace llvm::opt;
 
+void RocmInstallationDetector::scanLibDevicePath() {
+  assert(!LibDevicePath.empty());
+
+  const StringRef Suffix(".bc");
+
+  std::error_code EC;
+  for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
+StringRef FilePath = LI->path();
+StringRef FileName = llvm::sys::path::filename(FilePath);
+if (!FileName.endswith(Suffix))
+  continue;
+
+StringRef BaseName = FileName.drop_back(Suffix.size());
+
+if (BaseName == "ocml") {
+  OCML = FilePath;
+} else if (BaseName == "ockl") {
+  OCKL = FilePath;
+} else if (BaseName == "opencl") {
+  OpenCL = FilePath;
+} else if (BaseName == "hip") {
+  HIP = FilePath;
+} else if (BaseName == "oclc_finite_only_off") {
+  FiniteOnly.Off = FilePath;
+} else if (BaseName == "oclc_finite_only_on") {
+  FiniteOnly.On = FilePath;
+} else if (BaseName == "oclc_daz_opt_on") {
+  DenormalsAreZero.On = FilePath;
+} else if (BaseName == "oclc_daz_opt_off") {
+  DenormalsAreZero.Off = FilePath;
+} else if (BaseName == "oclc_correctly_rounded_sqrt_on") {
+  CorrectlyRoundedSqrt.On = FilePath;
+} else if (BaseName == "oclc_correctly_rounded_sqrt_off") {
+  CorrectlyRoundedSqrt.Off = FilePath;
+} else if (BaseName == "oclc_unsafe_math_on") {
+  UnsafeMath.On = FilePath;
+} else if (BaseName == "oclc_unsafe_math_off") {
+  UnsafeMath.Off = FilePath;
+} else if (BaseName == "oclc_wavefrontsize64_on") {
+  WavefrontSize64.On = FilePath;
+} else if (BaseName == "oclc_wavefrontsize64_off") {
+  WavefrontSize64.Off = FilePath;
+} else {
+  // Process all bitcode filenames that look like
+  // ocl_isa_version_XXX.amdgcn.bc
+  const StringRef DeviceLibPrefix = "oclc_isa_version_";
+  if (!BaseName.startswith(DeviceLibPrefix))
+continue;
+
+  StringRef IsaVersionNumber =
+BaseName.drop_front(DeviceLibPrefix.size());
+
+  llvm::Twine GfxName = Twine("gfx") + IsaVersionNumber;
+  SmallString<8> Tmp;
+  LibDeviceMap.insert(
+std::make_pair(GfxName.toStringRef(Tmp), FilePath.str()));
+}
+  }
+}
+
 RocmInstallationDetector::RocmInstallationDetector(
 const Driver , const llvm::Triple ,
 const llvm::opt::ArgList )
@@ -60,6 +121,27 @@ RocmInstallationDetector::RocmInstallationDetector(
 
   bool NoBuiltinLibs = Args.hasArg(options::OPT_nogpulib);
 
+  assert(LibDevicePath.empty());
+
+  if 

[clang] 123bee6 - AMDGPU: Search for new ROCm bitcode library structure

2020-05-12 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-05-12T09:41:07-04:00
New Revision: 123bee602a260150ff55c74287f583a67ee78f36

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

LOG: AMDGPU: Search for new ROCm bitcode library structure

The current install situation is a mess, but I'm working on fixing
it. Search for the target layout instead of one of the N options that
exist today.

Added: 
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/hip.bc
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ockl.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_off.bc
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_on.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_off.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_on.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1010.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1011.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1012.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_803.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_900.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_off.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_on.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_off.bc

clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ocml.bc
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/opencl.bc

Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/rocm-device-libs.cl

Removed: 
clang/test/Driver/Inputs/rocm-device-libs/lib/hip.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc

clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc



diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e8c0b824ace1..345a24b10018 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -65,30 +65,18 @@ RocmInstallationDetector::RocmInstallationDetector(
 if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
   continue;
 
-// FIXME: The install path situation is a real mess.
-
-// For a cmake install, these are placed directly in
-// ${INSTALL_PREFIX}/lib
-
-// In the separate OpenCL builds, the bitcode libraries are placed in
-// ${OPENCL_ROOT}/lib/x86_64/bitcode/*
-
-// For the rocm installed packages, these are placed at
-// /opt/rocm/opencl/lib/x86_64/bitcode
-
-// An additional copy is installed, in scattered locations between
-// /opt/rocm/hcc/rocdl/oclc
-// /opt/rocm/hcc/rocdl/ockl
-// /opt/rocm/hcc/rocdl/lib
+// The install path situation in old versions of ROCm is a real mess, and
+// use a 
diff erent install layout. Multiple copies of the device libraries
+// exist for each frontend project, and 
diff er depending on which build
+// system produced the 

[PATCH] D79631: #pragma float_control should be permitted at namespace scope

2020-05-12 Thread Melanie Blower via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f2db9935009: [PATCH] #pragma float_control should be 
permitted in namespace scope. (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79631

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/Parser/fp-floatcontrol-syntax.cpp

Index: clang/test/Parser/fp-floatcontrol-syntax.cpp
===
--- clang/test/Parser/fp-floatcontrol-syntax.cpp
+++ clang/test/Parser/fp-floatcontrol-syntax.cpp
@@ -10,10 +10,10 @@
 #pragma float_control(pop)
 #pragma float_control(precise, on, push)
 void check_stack() {
-#pragma float_control(push)   // expected-error {{can only appear at file scope}}
-#pragma float_control(pop)// expected-error {{can only appear at file scope}}
-#pragma float_control(precise, on, push)  // expected-error {{can only appear at file scope}}
-#pragma float_control(except, on, push)   // expected-error {{can only appear at file scope}}
+#pragma float_control(push)   // expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(pop)// expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(precise, on, push)  // expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(except, on, push)   // expected-error {{can only appear at file scope or namespace scope}}
 #pragma float_control(except, on, push, junk) // expected-error {{float_control is malformed}}
   return;
 }
Index: clang/test/CodeGen/fp-floatcontrol-pragma.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
 
@@ -59,3 +60,56 @@
   z = z * z;
 //CHECK: = fmul float
 }
+
+#if EXCEPT
+namespace ns {
+// Check that pragma float_control can appear in namespace.
+#pragma float_control(except, on, push)
+float exc_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+}
+
+// Check pragma is still effective after namespace closes
+float exc_still_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_still_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+
+#pragma float_control(pop)
+float exc_off(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_off{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: fdiv contract double
+  } catch (...) {}
+  return zero;
+}
+
+namespace fc_template_namespace {
+#pragma float_control(except, on, push)
+template 
+T exc_on(double x, T zero) {
+// CHECK-NS: define {{.*}}fc_template_namespace{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+}
+
+#pragma float_control(pop)
+float xx(double x, float z) {
+  return fc_template_namespace::exc_on(x, z);
+}
+#endif // EXCEPT
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1911,6 +1911,7 @@
 D->hasWrittenPrototype(), D->getConstexprKind(),
 TrailingRequiresClause);
 Function->setRangeEnd(D->getSourceRange().getEnd());
+Function->setUsesFPIntrin(D->usesFPIntrin());
   }
 
   if (D->isInlined())
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -420,8 +420,8 @@
   auto NewValue = FpPragmaStack.CurrentValue;
   FPOptions NewFPFeatures(NewValue);
   if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
-  !CurContext->isTranslationUnit()) {
-// Push and pop can only occur at file scope.
+  !(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {

[PATCH] D79565: Add -print-targets to print the registered targets

2020-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 263410.
yaxunl retitled this revision from "Document outputing registered targets with 
-v in release notes" to "Add -print-targets to print the registered targets".
yaxunl added reviewers: MaskRay, thakis, echristo, tra.
yaxunl added a comment.

add option -print-targets to print the registered targets.


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

https://reviews.llvm.org/D79565

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1815,6 +1815,11 @@
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_targets)) {
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2804,6 +2804,8 @@
   HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
+def print_targets : Flag<["-", "--"], "print-targets">,
+  HelpText<"Print the registered targets">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,7 @@
 - ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
   ``char8_t`` as the character type of ``u8`` literals. This restores the
   Clang 8 behavior that regressed in Clang 9 and 10.
+- -print-targets has been added to print the registered targets.
 
 New Pragmas in Clang
 


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1815,6 +1815,11 @@
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_targets)) {
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2804,6 +2804,8 @@
   HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
+def print_targets : Flag<["-", "--"], "print-targets">,
+  HelpText<"Print the registered targets">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,7 @@
 - ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
   ``char8_t`` as the character type of ``u8`` literals. This restores the
   Clang 8 behavior that regressed in Clang 9 and 10.
+- -print-targets has been added to print the registered targets.
 
 New Pragmas in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f2db99 - [PATCH] #pragma float_control should be permitted in namespace scope.

2020-05-12 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-12T06:10:19-07:00
New Revision: 7f2db993500923a51c0b0aed650a3e0d4241205b

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

LOG: [PATCH] #pragma float_control should be permitted in namespace scope.

Summary: Erroneous error diagnostic observed in VS2017  header
Also correction to propagate usesFPIntrin from template func to instantiation.

Reviewers: rjmccall, erichkeane (no feedback received)

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Parser/fp-floatcontrol-syntax.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 44a34080b239..371e20183e1e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -860,7 +860,7 @@ def warn_pragma_pack_pop_identifier_and_alignment : Warning<
 def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">,
   InGroup;
 def err_pragma_fc_pp_scope : Error<
-  "'#pragma float_control push/pop' can only appear at file scope">;
+  "'#pragma float_control push/pop' can only appear at file scope or namespace 
scope">;
 def err_pragma_fc_noprecise_requires_nofenv : Error<
   "'#pragma float_control(precise, off)' is illegal when fenv_access is 
enabled">;
 def err_pragma_fc_except_requires_precise : Error<

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 01f30a985935..222aaf3049ae 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -420,8 +420,8 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
   auto NewValue = FpPragmaStack.CurrentValue;
   FPOptions NewFPFeatures(NewValue);
   if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
-  !CurContext->isTranslationUnit()) {
-// Push and pop can only occur at file scope.
+  !(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {
+// Push and pop can only occur at file or namespace scope.
 Diag(Loc, diag::err_pragma_fc_pp_scope);
 return;
   }

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index a6541dabe6b2..327022218e01 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1911,6 +1911,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
 D->hasWrittenPrototype(), D->getConstexprKind(),
 TrailingRequiresClause);
 Function->setRangeEnd(D->getSourceRange().getEnd());
+Function->setUsesFPIntrin(D->usesFPIntrin());
   }
 
   if (D->isInlined())

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index 773cfcdd2829..a80a4d377660 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu 
-emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
 
@@ -59,3 +60,56 @@ void callt() {
   z = z * z;
 //CHECK: = fmul float
 }
+
+#if EXCEPT
+namespace ns {
+// Check that pragma float_control can appear in namespace.
+#pragma float_control(except, on, push)
+float exc_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+}
+
+// Check pragma is still effective after namespace closes
+float exc_still_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_still_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+
+#pragma float_control(pop)
+float exc_off(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_off{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: fdiv contract double
+  } catch (...) {}
+  return zero;
+}
+
+namespace fc_template_namespace {
+#pragma float_control(except, on, push)
+template 
+T exc_on(double x, T zero) {
+// CHECK-NS: define {{.*}}fc_template_namespace{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: 

[PATCH] D79526: [CUDA][HIP] Workaround for resolving host device function against wrong-sided function

2020-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 3 inline comments as done.
Closed by commit rGe03394c6a6ff: [CUDA][HIP] Workaround for resolving host 
device function against wrong-sided… (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D79526?vs=263268=263408#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79526

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu

Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -1,8 +1,8 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
 
 #include "Inputs/cuda.h"
 
@@ -14,6 +14,13 @@
 struct HostDeviceReturnTy {};
 struct TemplateReturnTy {};
 
+struct CorrectOverloadRetTy{};
+#if __CUDA_ARCH__
+// expected-note@-2 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'IncorrectOverloadRetTy' to 'const CorrectOverloadRetTy &' for 1st argument}}
+// expected-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'IncorrectOverloadRetTy' to 'CorrectOverloadRetTy &&' for 1st argument}}
+#endif
+struct IncorrectOverloadRetTy{};
+
 typedef HostReturnTy (*HostFnPtr)();
 typedef DeviceReturnTy (*DeviceFnPtr)();
 typedef HostDeviceReturnTy (*HostDeviceFnPtr)();
@@ -331,9 +338,6 @@
 // If we have a mix of HD and H-only or D-only candidates in the overload set,
 // normal C++ overload resolution rules apply first.
 template  TemplateReturnTy template_vs_hd_function(T arg)
-#ifdef __CUDA_ARCH__
-//expected-note@-2 {{declared here}}
-#endif
 {
   return TemplateReturnTy();
 }
@@ -342,11 +346,13 @@
 }
 
 __host__ __device__ void test_host_device_calls_hd_template() {
-  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
-  TemplateReturnTy ret2 = template_vs_hd_function(1);
 #ifdef __CUDA_ARCH__
-  // expected-error@-2 {{reference to __host__ function 'template_vs_hd_function' in __host__ __device__ function}}
+  typedef HostDeviceReturnTy ExpectedReturnTy;
+#else
+  typedef TemplateReturnTy ExpectedReturnTy;
 #endif
+  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
+  ExpectedReturnTy ret2 = template_vs_hd_function(1);
 }
 
 __host__ void test_host_calls_hd_template() {
@@ -367,14 +373,14 @@
 __device__ DeviceReturnTy device_only_function(int arg) { return DeviceReturnTy(); }
 __device__ DeviceReturnTy2 device_only_function(float arg) { return DeviceReturnTy2(); }
 #ifndef __CUDA_ARCH__
-  // expected-note@-3 {{'device_only_function' declared here}}
-  // expected-note@-3 {{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
 #endif
 __host__ HostReturnTy host_only_function(int arg) { return HostReturnTy(); }
 __host__ HostReturnTy2 host_only_function(float arg) { return HostReturnTy2(); }
 #ifdef __CUDA_ARCH__
-  // expected-note@-3 {{'host_only_function' declared here}}
-  // expected-note@-3 {{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
 #endif
 
 __host__ __device__ void test_host_device_single_side_overloading() {
@@ -392,6 +398,37 @@
 #endif
 }
 
+// wrong-sided overloading should not cause diagnostic unless it is emitted.
+// This inline function is not emitted.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_no_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+  HostReturnTy ret3 = host_only_function(1);
+  HostReturnTy2 ret4 = host_only_function(1.0f);
+}
+
+// wrong-sided overloading should cause diagnostic if it is emitted.
+// This inline function is emitted since it is called by an emitted function.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+#ifndef __CUDA_ARCH__
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ function}}
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ 

[PATCH] D78443: [Local] Update getOrEnforceKnownAlignment/getKnownAlignment to use Align/MaybeAlign.

2020-05-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

Thx @craig.topper ! I'm happy to see this effort percolate :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78443



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


[clang] e03394c - [CUDA][HIP] Workaround for resolving host device function against wrong-sided function

2020-05-12 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-05-12T08:27:50-04:00
New Revision: e03394c6a6ff5832aa43259d4b8345f40ca6a22c

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

LOG: [CUDA][HIP] Workaround for resolving host device function against 
wrong-sided function

recommit c77a4078e01033aa2206c31a579d217c8a07569b with fix

https://reviews.llvm.org/D77954 caused regressions due to diagnostics in 
implicit
host device functions.

For now, it seems the most feasible workaround is to treat implicit host device 
function and explicit host
device function differently. Basically in device compilation for implicit host 
device functions, keep the
old behavior, i.e. give host device candidates and wrong-sided candidates equal 
preference. For explicit
host device functions, favor host device candidates against wrong-sided 
candidates.

The rationale is that explicit host device functions are blessed by the user to 
be valid host device functions,
that is, they should not cause diagnostics in both host and device compilation. 
If diagnostics occur, user is
able to fix them. However, there is no guarantee that implicit host device 
function can be compiled in
device compilation, therefore we need to preserve its overloading resolution in 
device compilation.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5aeb410e7288..202f0f2c9a14 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11671,6 +11671,8 @@ class Sema final {
 return IdentifyCUDATarget(dyn_cast(CurContext));
   }
 
+  static bool IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D);
+
   // CUDA function call preference. Must be ordered numerically from
   // worst to best.
   enum CUDAFunctionPreference {

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 73d190891b0f..eecea94e0dad 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -211,6 +211,20 @@ Sema::IdentifyCUDAPreference(const FunctionDecl *Caller,
   llvm_unreachable("All cases should've been handled by now.");
 }
 
+template  static bool hasImplicitAttr(const FunctionDecl *D) {
+  if (!D)
+return false;
+  if (auto *A = D->getAttr())
+return A->isImplicit();
+  return D->isImplicit();
+}
+
+bool Sema::IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D) {
+  bool IsImplicitDevAttr = hasImplicitAttr(D);
+  bool IsImplicitHostAttr = hasImplicitAttr(D);
+  return IsImplicitDevAttr && IsImplicitHostAttr;
+}
+
 void Sema::EraseUnwantedCUDAMatches(
 const FunctionDecl *Caller,
 SmallVectorImpl> ) {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1b00b2b18572..18ce491580c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9374,16 +9374,22 @@ static Comparison compareEnableIfAttrs(const Sema , 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static bool isBetterMultiversionCandidate(const OverloadCandidate ,
-  const OverloadCandidate ) {
+static Comparison
+isBetterMultiversionCandidate(const OverloadCandidate ,
+  const OverloadCandidate ) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return false;
+return Comparison::Equal;
 
-  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
-  // is obviously better.
-  if (Cand1.Function->isInvalidDecl()) return false;
-  if (Cand2.Function->isInvalidDecl()) return true;
+  // If both are invalid, they are equal. If one of them is invalid, the other
+  // is better.
+  if (Cand1.Function->isInvalidDecl()) {
+if (Cand2.Function->isInvalidDecl())
+  return Comparison::Equal;
+return Comparison::Worse;
+  }
+  if (Cand2.Function->isInvalidDecl())
+return Comparison::Better;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9393,16 +9399,18 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate ,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return false;
+return Comparison::Equal;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return true;
+return Comparison::Better;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return false;
+return Comparison::Worse;
 
   if 

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D79704#2029305 , 
@baloghadamsoftware wrote:

> Thank you for quickly looking into this.
>
> In D79704#2029230 , @Szelethus wrote:
>
> > - What identifies a `MemRegion`, `TypedValueRegion`s in particular? Why are 
> > parameters so special that they deserve their own region? Do you have a 
> > concrete, problematic example?
>
>
> `ParamRegion` contains different data: mainly the index of the parameter. 
> This makes it independent of the actual `Decl` of the parameter.
>
> > - Why is it an issue that we don't always use the same declaration? Does 
> > this result in a crash, incorrect modeling?
>
> See D49443#1193290 .
>
> > - Why are we making `ParamRegion` **not** a subclass of `VarRegion`?
>
> Because `VarRegion` is a `DeclRegion` which stores the `Decl` of the 
> variable. Here the main purpose is to not to store it.


To me that sounds like a technicality. Sure, inheriting from `VarRegion` would 
make you carry around a field or two you may not need/use, but is that a big 
deal? To me it feels like all the problems you're solving should be an 
implementation detail. The interface of `ParamRegion` looks like a superset of 
`VarRegion`'s. The code changes suggests that every time we're interested in a 
`VarRegion`, we're also interested in parameters.

I may not see the obvious just yet, but I invite you to correct me! :)


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

https://reviews.llvm.org/D79704



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


Re: [clang] d82538b - Fix -Wunused compiler warning.

2020-05-12 Thread Haojian Wu via cfe-commits
This is neat, fixed in 40ef4274600316ed12a26a73265cf34432e1fbf7, thanks for
the suggestion!

On Tue, 12 May 2020 at 05:13, Eric Christopher  wrote:

> Very much so. Also nice all_of use! I'd have never thought about that :)
>
> -eric
>
> On Mon, May 11, 2020 at 7:03 PM David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>>
>> On Mon, May 11, 2020 at 12:21 AM Haojian Wu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Haojian Wu
>>> Date: 2020-05-11T09:20:48+02:00
>>> New Revision: d82538b3f691f3ba1cb7a945a5f8594f71816fdf
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/d82538b3f691f3ba1cb7a945a5f8594f71816fdf
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/d82538b3f691f3ba1cb7a945a5f8594f71816fdf.diff
>>>
>>> LOG: Fix -Wunused compiler warning.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/AST/Expr.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
>>> index 2a0e0425ef1f..8b327300fb2d 100644
>>> --- a/clang/lib/AST/Expr.cpp
>>> +++ b/clang/lib/AST/Expr.cpp
>>> @@ -4686,8 +4686,10 @@ RecoveryExpr::RecoveryExpr(ASTContext ,
>>> QualType T, SourceLocation BeginLoc,
>>>  : Expr(RecoveryExprClass, T, VK_LValue, OK_Ordinary),
>>> BeginLoc(BeginLoc),
>>>EndLoc(EndLoc), NumExprs(SubExprs.size()) {
>>>assert(!T.isNull());
>>> +#ifndef NDEBUG // avoid -Wunused warnings.
>>>for (auto *E : SubExprs)
>>>  assert(E != nullptr);
>>> +#endif
>>>
>>
>> This might be better written as:
>>
>> assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; }));
>>
>> & probably include some kind of message (... && "message") about this
>> precondition.
>>
>>
>>>
>>>llvm::copy(SubExprs, getTrailingObjects());
>>>setDependence(computeDependence(this));
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-05-12 Thread Whisperity via Phabricator via cfe-commits
whisperity requested changes to this revision.
whisperity added a comment.
This revision now requires changes to proceed.

(Maybe this will make Phab not show "✅ Accepted"...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-05-12 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Please check the summary of the patch, it seems to contain old information as 
well.




Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:210-212
+Preferably the same compilation database should be used when generating the 
external definitions, and
+during analysis.  The analysis invocation must be provided with the directory 
which contains the mapping
+files, and the compilation database which is used to determine compiler flags.

This is obsolete information.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:234
+  public:
+explicit ASTFileLoader(CompilerInstance , StringRef CTUDir);
+

Is the `explicit` needed here?



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:388-389
+"parsing there is no need for pre-dumping ASTs. External "
+"definition mapping is still needed, and a valid compilation "
+"database with compile commands for the external TUs is also "
+"necessary. Disabled by default.",

"valid compilation database" is this line still what we wish to say? A YAML is 
used, so most likely we need a "valid invocation list" or something.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:393-398
+ANALYZER_OPTION(
+StringRef, CTUInvocationList, "ctu-invocation-list",
+"The path to the YAML format file containing a mapping from source file "
+"paths to command-line invocations represented as a list of arguments. "
+"This invocation is used produce the source-file's AST.",
+"invocations.yaml")

Maybe it would be worthwhile to add a dummy example like `main.cpp: g++ 
hello-world.cpp` which has the proper format into this help.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:23-24
 #include "clang/Index/USRGeneration.h"
-#include "llvm/ADT/Triple.h"
+#include "clang/Tooling/JSONCompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"

The idea here was to not depend on libtooling but these lines are still here!



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:34
 #include 
+#include 
 #include 

<> -> "" and order



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:122-123
   return "Load threshold reached";
+case index_error_code::ambiguous_compilation_database:
+  return "Compilation database contains multiple references to the same "
+ "source file.";

still using terms "compilation database", is this intended?



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:583
+ CommandLineArgs.begin(),
+ [](auto &) { return CmdPart.c_str(); });
+

balazske wrote:
> Is here a special reason to use `auto &&` type (and not `auto &` or 
> `std::string &`)? Probably this code is faulty: The `CmdPart` is moved out 
> and then destructed, before the content of it (where the `c_str` points to) 
> is used?
@balazske This is a generic lambda where `auto&&` is the universal reference. 
It is equivalent to writing `template  f(T&& param)`. It obeys the 
usual point of instantiation and reference cascading rules, if a `const 
std::string&` is given as `T`, `const std::string& &&` will become a single `&`.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:609
+  llvm::SourceMgr SM;
+  llvm::yaml::Stream InvocationFiles(*ContentBuffer, SM);
+

Are the headers from which these types come from included?



Comment at: clang/test/Analysis/Inputs/ctu-other.c:34-38
+// TODO: Support the GNU extension asm keyword as well.
+// Example using the GNU extension: asm("mov $42, %0" : "=r"(res));
 int inlineAsm() {
   int res;
+  __asm__("mov $42, %0"

Possibly unrelated change?



Comment at: clang/test/Analysis/ctu-on-demand-parsing.c:1-15
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp "%s" "%t/ctu-on-demand-parsing.c"
+// RUN: cp "%S/Inputs/ctu-other.c" "%t/ctu-other.c"
+// Path substitutions on Windows platform could contain backslashes. These are 
escaped in the json file.
+// RUN: echo '[{"directory":"%t","command":"gcc -std=c89 -Wno-visibility 
ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo '"%t/ctu-other.c": ["gcc", "-std=c89", "-Wno-visibility", 
"ctu-other.c"]' | sed -e 's/\\//g' > %t/invocations.yaml

Does the LIT syntax allow for better organising these commands? This is now a 
bit hard to read


Something like this would help:
```
// RUN: rm -rf %t && mkdir -p %t
// RUN: cp "%s" "%t/ctu-on-demand-parsing.c" && cp "%S/Inputs/ctu-other.c" 
"%t/ctu-other.c"
// [empty]
// [comment]
// RUN: [json 

[PATCH] D79357: [SveEmitter] Add builtins for svdup and svindex

2020-05-12 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd6936be2ef8c: [SveEmitter] Add builtins for svdup and 
svindex (authored by sdesmalen).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79357

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
@@ -0,0 +1,524 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svdup_n_s8(int8_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv16i8(i8 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s8,)(op);
+}
+
+svint16_t test_svdup_n_s16(int16_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv8i16(i16 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s16,)(op);
+}
+
+svint32_t test_svdup_n_s32(int32_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv4i32(i32 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s32,)(op);
+}
+
+svint64_t test_svdup_n_s64(int64_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s64,)(op);
+}
+
+svuint8_t test_svdup_n_u8(uint8_t op)
+{
+  // CHECK-LABEL: test_svdup_n_u8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv16i8(i8 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_u8,)(op);
+}
+
+svuint16_t test_svdup_n_u16(uint16_t op)
+{
+  // CHECK-LABEL: test_svdup_n_u16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv8i16(i16 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_u16,)(op);
+}
+
+svuint32_t test_svdup_n_u32(uint32_t op)
+{
+  // CHECK-LABEL: test_svdup_n_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv4i32(i32 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_u32,)(op);
+}
+
+svuint64_t test_svdup_n_u64(uint64_t op)
+{
+  // CHECK-LABEL: test_svdup_n_u64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv2i64(i64 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_u64,)(op);
+}
+
+svfloat16_t test_svdup_n_f16(float16_t op)
+{
+  // CHECK-LABEL: test_svdup_n_f16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv8f16(half %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_f16,)(op);
+}
+
+svfloat32_t test_svdup_n_f32(float32_t op)
+{
+  // CHECK-LABEL: test_svdup_n_f32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv4f32(float %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_f32,)(op);
+}
+
+svfloat64_t test_svdup_n_f64(float64_t op)
+{
+  // CHECK-LABEL: test_svdup_n_f64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.x.nxv2f64(double %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_f64,)(op);
+}
+
+svint8_t test_svdup_n_s8_z(svbool_t pg, int8_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s8_z
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.nxv16i8( zeroinitializer,  %pg, i8 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s8_z,)(pg, op);
+}
+
+svint16_t test_svdup_n_s16_z(svbool_t pg, int16_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s16_z
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.nxv8i16( zeroinitializer,  %[[PG]], i16 %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdup,_n,_s16_z,)(pg, op);
+}
+
+svint32_t test_svdup_n_s32_z(svbool_t pg, int32_t op)
+{
+  // CHECK-LABEL: test_svdup_n_s32_z
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dup.nxv4i32( zeroinitializer,  %[[PG]], i32 

[PATCH] D79755: Implement constexpr BinaryOperator for vector types

2020-05-12 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added reviewers: rsmith, void.
RKSimon added a comment.

Adding some people who know more about this


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

https://reviews.llvm.org/D79755



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


[clang] d6936be - [SveEmitter] Add builtins for svdup and svindex

2020-05-12 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-05-12T11:02:32+01:00
New Revision: d6936be2ef8ce5d5d85b8a6cdd1477cd79688c3a

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

LOG: [SveEmitter] Add builtins for svdup and svindex

Reviewed By: efriedma

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index b827601d56c1..e8e05902102a 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -627,6 +627,13 @@ def SVDUPQ_16 : SInst<"svdupq[_n]_{d}", "d",  
"sUsh", MergeNone>;
 def SVDUPQ_32 : SInst<"svdupq[_n]_{d}", "d",  "iUif", MergeNone>;
 def SVDUPQ_64 : SInst<"svdupq[_n]_{d}", "dss",  "lUld", MergeNone>;
 
+def SVDUP   : SInst<"svdup[_n]_{d}", "ds",   "csilUcUsUiUlhfd", MergeNone,
"aarch64_sve_dup_x">;
+def SVDUP_M : SInst<"svdup[_n]_{d}", "ddPs", "csilUcUsUiUlhfd", MergeOp1, 
"aarch64_sve_dup">;
+def SVDUP_X : SInst<"svdup[_n]_{d}", "dPs",  "csilUcUsUiUlhfd", MergeAnyExp,  
"aarch64_sve_dup">;
+def SVDUP_Z : SInst<"svdup[_n]_{d}", "dPs",  "csilUcUsUiUlhfd", MergeZeroExp, 
"aarch64_sve_dup">;
+
+def SVINDEX : SInst<"svindex_{d}",   "dss",  "csilUcUsUiUl",MergeNone,
"aarch64_sve_index">;
+
 // Integer arithmetic
 
 multiclass SInstZPZ flags=[]> {
@@ -1061,7 +1068,11 @@ def SVCLASTA_N   : SInst<"svclasta[_n_{d}]",  "sPsd", 
"csilUcUsUiUlhfd", MergeNo
 def SVCLASTB : SInst<"svclastb[_{d}]","dPdd", "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_clastb">;
 def SVCLASTB_N   : SInst<"svclastb[_n_{d}]",  "sPsd", "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_clastb_n">;
 def SVCOMPACT: SInst<"svcompact[_{d}]",   "dPd",  "ilUiUlfd",
MergeNone, "aarch64_sve_compact">;
-//  SVDUP_LANE(to land in D78750)
+// Note: svdup_lane is implemented using the intrinsic for TBL to represent a
+// splat of any possible lane. It is upto LLVM to pick a more efficient
+// instruction such as DUP (indexed) if the lane index fits the range of the
+// instruction's immediate.
+def SVDUP_LANE   : SInst<"svdup_lane[_{d}]",  "ddL",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_tbl">;
 def SVDUPQ_LANE  : SInst<"svdupq_lane[_{d}]", "ddn",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_dupq_lane">;
 def SVEXT: SInst<"svext[_{d}]",   "dddi", "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_ext", [], [ImmCheck<2, ImmCheckExtract, 1>]>;
 def SVLASTA  : SInst<"svlasta[_{d}]", "sPd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_lasta">;
@@ -1104,6 +1115,7 @@ def SVDUPQ_B8  : SInst<"svdupq[_n]_{d}",  
"P",  "Pc", MergeN
 def SVDUPQ_B16 : SInst<"svdupq[_n]_{d}", "P",  "Ps", MergeNone>;
 def SVDUPQ_B32 : SInst<"svdupq[_n]_{d}", "P",  "Pi", MergeNone>;
 def SVDUPQ_B64 : SInst<"svdupq[_n]_{d}", "Pss",  "Pl", MergeNone>;
+def SVDUP_N_B  : SInst<"svdup[_n]_{d}",  "Ps", "PcPsPiPl", MergeNone>;
 
 
 


diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 541dac7b7580..47620c13aed6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7909,12 +7909,15 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const 
CallExpr *E,
 
 // Limit the usage of scalable llvm IR generated by the ACLE by using the
 // sve dup.x intrinsic instead of IRBuilder::CreateVectorSplat.
-Value *CodeGenFunction::EmitSVEDupX(Value* Scalar) {
-  auto F = CGM.getIntrinsic(Intrinsic::aarch64_sve_dup_x,
-getSVEVectorForElementType(Scalar->getType()));
+Value *CodeGenFunction::EmitSVEDupX(Value *Scalar, llvm::Type *Ty) {
+  auto F = CGM.getIntrinsic(Intrinsic::aarch64_sve_dup_x, Ty);
   return Builder.CreateCall(F, Scalar);
 }
 
+Value *CodeGenFunction::EmitSVEDupX(Value* Scalar) {
+  return EmitSVEDupX(Scalar, getSVEVectorForElementType(Scalar->getType()));
+}
+
 Value *CodeGenFunction::EmitSVEReinterpret(Value *Val, llvm::Type *Ty) {
   // FIXME: For big endian this needs an additional REV, or needs a separate
   // intrinsic that is code-generated as a no-op, because the LLVM bitcast
@@ -8109,6 +8112,17 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
   case SVE::BI__builtin_sve_svpmullb_n_u64:
 return EmitSVEPMull(TypeFlags, Ops, Intrinsic::aarch64_sve_pmullb_pair);
 
+  case SVE::BI__builtin_sve_svdup_n_b8:
+  case SVE::BI__builtin_sve_svdup_n_b16:
+  case SVE::BI__builtin_sve_svdup_n_b32:
+  case SVE::BI__builtin_sve_svdup_n_b64: {

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-05-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, sammccall, owenpan, jbcoe, 
mitchell-stellar.
MyDeveloperDay added projects: clang, clang-format.

This is a starting point to improve the handling of concepts in clang-format. 
There is currently no real formatting of concepts and this can lead to some odd 
formatting, e.g.

  requires(R range) {
typename Iterator_type;
{ begin(range) }
->Iterator_type;
{ end(range) }
->Iterator_type;
requires Input_iterator>();
  };

The revision starts by resolving the additional newline added before the 
implicit conversion constraint and ensures that the concept keyword is always 
on the line below template<>

  template 
  concept bool EqualityComparable = requires(T a, T b) {
{ a == b } -> bool;
  };




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79773

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15849,6 +15849,41 @@
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, ConceptsImplicitConversionConstraint) {
+  FormatStyle Style = getLLVMStyle();
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("requires(R range) {\n"
+   "  typename Iterator_type;\n"
+   "  { begin(range) } -> Iterator_type;\n"
+   "  { end(range) } -> Iterator_type;\n"
+   "  requires Input_iterator>();\n"
+   "};\n",
+   Style);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -628,6 +628,13 @@
 
   if (MunchSemi && FormatTok->Tok.is(tok::semi))
 nextToken();
+  else if (FormatTok->is(tok::arrow)) {
+// Following the } we can find a trailing return type arrow
+// as part of an implicit conversion constraint.
+nextToken();
+parseStructuralElement();
+  }
+
   Line->Level = InitialLevel;
 
   if (PPStartHash == PPEndHash) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1563,7 +1563,11 @@
!Current.Previous->is(tok::kw_operator)) {
   // not auto operator->() -> xxx;
   Current.Type = TT_TrailingReturnArrow;
-
+} else if (Current.is(tok::arrow) && Current.Previous &&
+   Current.Previous->is(tok::r_brace)) {
+  // Concept implicit conversion contrain needs to be treated like
+  // a trailing return type  ... } -> .
+  Current.Type = TT_TrailingReturnArrow;
 } else if (isDeductionGuide(Current)) {
   // Deduction guides trailing arrow " A(...) -> A;".
   Current.Type = TT_TrailingReturnArrow;
@@ -3466,6 +3470,12 @@
   return true;
   }
 
+  // Put concepts on the next line e.g.
+  // template
+  // concept ...
+  if (Left.is(TT_TemplateCloser) && Right.is(tok::kw_concept))
+return true;
+
   if (Right.is(tok::comment))
 return Left.BlockKind != BK_BracedInit &&
Left.isNot(TT_CtorInitializerColon) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15849,6 +15849,41 @@
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, ConceptsImplicitConversionConstraint) {
+  FormatStyle Style = getLLVMStyle();
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept bool 

[PATCH] D79411: [VE] Clang toolchain for VE

2020-05-12 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

FYI This passes all tests on the mergebot. There are some obscure lint 
suggestions that make it report a failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79411



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


[PATCH] D79701: [clangd] Add metrics for selection tree and recovery expressions.

2020-05-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:454
+  auto T = makeSelectionTree(Code, AST);
+  // EXPECT_THAT(Tracer.takeMetric("selection"), testing::SizeIs(1));
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery"),

delete commented code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79701



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-05-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:362
 
-  return ASTUnit::LoadFromASTFile(
-  std::string(ASTFilePath), CI.getPCHContainerOperations()->getRawReader(),
-  ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts());
+  auto LoadFromFile = [this](StringRef Path) {
+IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();

Is here a lambda necessary? I think it must not be over-used. In this case we 
can construct the file path as the first step and then use it to load the file, 
without using lambda call.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:583
+ CommandLineArgs.begin(),
+ [](auto &) { return CmdPart.c_str(); });
+

Is here a special reason to use `auto &&` type (and not `auto &` or 
`std::string &`)? Probably this code is faulty: The `CmdPart` is moved out and 
then destructed, before the content of it (where the `c_str` points to) is used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


  1   2   >