[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-10-13 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

> Can you explain what does this mean

It was trying to clarify a potential misunderstanding of how programs are 
compiled when HIPSPV is targeted:  For HIPSPV, the SPIR-V code generation is 
done by the clang driver. When we compile HIP programs for HIPCL or the HIPLZ 
runtime, we issue a single clang command such as this:

  clang++ --offload=spirv64 foo.hip -l -o foo

With this, the clang driver compiles the device side code to a SPIR-V binary 
and then compiles host side code, and embeds the SPIR-V binary to the host 
(fat) binary.

> ? In the tests I can see the following `--offload=spirv64` which does feel 
> like it is specified explicitly that the target is SPIR-V...

For HIPSPV the `--offload` option is used to specify the device code target but 
the end result is a host binary (e.g. x86_64) with device code (SPIR-V binary) 
embedded in it. We need a way to specify the device code target to be other 
than the currently fixed `amdgcn-amd-amdhsa` and using the `--offload` switch 
is a solution we are suggesting here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


[PATCH] D111078: [AIX] Enable int128 in 64 bit mode

2021-10-13 Thread Kai Luo via Phabricator via cfe-commits
lkail accepted this revision as: lkail.
lkail added a comment.
This revision is now accepted and ready to land.

This LGTM as the start point to support int128 on AIX. We might need more 
patches involving libraries in the LLVM monorepo, we can do that progressively.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111078

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


[clang] e567f37 - [clang] Use llvm::is_contained (NFC)

2021-10-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-13T20:41:55-07:00
New Revision: e567f37dabc242cb02fb8b8b288fd05a0aebfb8f

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

LOG: [clang] Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/Edit/EditedSource.cpp
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CIndexHigh.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index 36fbe90e1e3a5..4851c434d7652 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -65,7 +65,7 @@ bool CapturedDiagList::hasDiagnostic(ArrayRef IDs,
   while (I != List.end()) {
 FullSourceLoc diagLoc = I->getLocation();
 if ((IDs.empty() || // empty means any diagnostic in the range.
- llvm::find(IDs, I->getID()) != IDs.end()) &&
+ llvm::is_contained(IDs, I->getID())) &&
 !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) &&
 (diagLoc == range.getEnd() ||
  diagLoc.isBeforeInTranslationUnitThan(range.getEnd( {

diff  --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp
index 43da3451aa15a..ee57660b8c72c 100644
--- a/clang/lib/Edit/EditedSource.cpp
+++ b/clang/lib/Edit/EditedSource.cpp
@@ -60,7 +60,7 @@ void EditedSource::finishedCommit() {
 MacroArgUse ArgUse;
 std::tie(ExpLoc, ArgUse) = ExpArg;
 auto  = ExpansionToArgMap[ExpLoc];
-if (llvm::find(ArgUses, ArgUse) == ArgUses.end())
+if (!llvm::is_contained(ArgUses, ArgUse))
   ArgUses.push_back(ArgUse);
   }
   CurrCommitMacroArgExps.clear();

diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index b1a0fd84fa698..c70705a1cd7ff 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -419,7 +419,7 @@ void QualifierAlignmentFixer::PrepareLeftRightOrdering(
   // To iterate forward or backward through the order list as qualifier
   // can push through each other.
   // The Order list must define the position of "type" to signify
-  assert(std::find(Order.begin(), Order.end(), "type") != Order.end() &&
+  assert(llvm::is_contained(Order, "type") &&
  "QualifierOrder must contain type");
   // Split the Order list by type and reverse the left side.
 
@@ -447,8 +447,7 @@ void QualifierAlignmentFixer::PrepareLeftRightOrdering(
 bool LeftRightQualifierAlignmentFixer::isQualifierOrType(
 const FormatToken *Tok, const std::vector ) 
{
   return Tok && (Tok->isSimpleTypeSpecifier() || Tok->is(tok::kw_auto) ||
- (std::find(specifiedTypes.begin(), specifiedTypes.end(),
-Tok->Tok.getKind()) != specifiedTypes.end()));
+ llvm::is_contained(specifiedTypes, Tok->Tok.getKind()));
 }
 
 // If a token is an identifier and it's upper case, it could

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 34cbb7aab2666..7360e6b40d69a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1120,10 +1120,9 @@ static void parseAnalyzerConfigs(AnalyzerOptions ,
 for (const StringRef  : CheckersAndPackages) {
   if (Diags) {
 bool IsChecker = CheckerOrPackage.contains('.');
-bool IsValidName =
-IsChecker
-? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
-: llvm::find(Packages, CheckerOrPackage) != Packages.end();
+bool IsValidName = IsChecker
+   ? llvm::is_contained(Checkers, CheckerOrPackage)
+   : llvm::is_contained(Packages, 
CheckerOrPackage);
 
 if (!IsValidName)
   Diags->Report(diag::err_unknown_analyzer_checker_or_package)
@@ -2875,7 +2874,7 @@ static void GenerateHeaderSearchArgs(HeaderSearchOptions 
,
 llvm::ArrayRef Groups,
 llvm::Optional IsFramework,
 llvm::Optional IgnoreSysRoot) {
-return llvm::find(Groups, Entry.Group) != Groups.end() &&
+return 

[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-13 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 379598.
noajshu added a comment.

Rebase against main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1096,7 +1095,7 @@
 
   NativeObjectCache Cache;
   if (!options::cache_dir.empty())
-Cache = check(localCache(options::cache_dir, AddBuffer));
+Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
   check(Lto->run(AddStream, Cache));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM Link Time Optimizer Cache Handling ---===//
+//===-Caching.cpp - LLVM File Cache Handling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,11 @@
 //
 //===--===//
 //
-// This file implements the Caching for ThinLTO.
+// This file implements the Caching used by ThinLTO.
 //
 //===--===//
 
-#include "llvm/LTO/Caching.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
 #include 

[PATCH] D111468: [clang] Capture Framework when HeaderSearch is resolved via headermap

2021-10-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a reviewer: jansvoboda11.
dexonsmith added a subscriber: jansvoboda11.
dexonsmith added a comment.

@jansvoboda11, can you help to review this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111468

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


[PATCH] D111720: [clang][deps] Ensure reported context hash is strict

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



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:56-58
+  // Ensure the reported context hash is strict.
+  CI.getHeaderSearchOpts().ModulesStrictContextHash = true;
+

IIUC, explicit modules don't really have/need a context hash. Can related 
options be stripped out when serializing to `-cc1` when `ImplicitModules` is 
false?

Basically, I'm asking if `ModulesStrictContextHash` is a no-op when 
`ImplicitModules` is false. If not, can we make it a no-op?
(If we can, then maybe rename the field to `ImplicitModulesStrictContextHash` 
and audit that no one reads it when `ImplicitModules` is off...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111720

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


[PATCH] D111724: [clang][deps] NFC: Remove redundant CompilerInstance reference

2021-10-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111724

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


[PATCH] D111725: [clang][deps] NFC: Rename scanning CompilerInstance

2021-10-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111725

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


[PATCH] D111728: [clang][deps] NFC: Rename building CompilerInvocation

2021-10-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111728

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


[PATCH] D111269: [clang][Driver] Make multiarch output file basenames reproducible

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379570.
keith added a comment.

Fix windows test paths


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111269

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111566: [SYCL] Fix function pointer address space

2021-10-13 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 379562.
eandrews added a comment.

Added a test


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

https://reviews.llvm.org/D111566

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGenSYCL/functionptr-addressspace.cpp


Index: clang/test/CodeGenSYCL/functionptr-addressspace.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/functionptr-addressspace.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -triple spir64 -verify 
-emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(const Func ) {
+  kernelFunc();
+}
+
+// CHECK: define dso_local spir_func{{.*}}invoke_function{{.*}}(i32 ()* %fptr, 
i32 addrspace(4)* %ptr)
+void invoke_function(int (*fptr)(), int *ptr) {}
+
+int f() { return 0; }
+
+int main() {
+  kernel_single_task([=]() {
+int (*p)() = f;
+int ()() = *p;
+int a = 10;
+invoke_function(p, );
+invoke_function(r, );
+invoke_function(f, );
+  });
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -633,7 +633,9 @@
 const ReferenceType *RTy = cast(Ty);
 QualType ETy = RTy->getPointeeType();
 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
-unsigned AS = Context.getTargetAddressSpace(ETy);
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }


Index: clang/test/CodeGenSYCL/functionptr-addressspace.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/functionptr-addressspace.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -triple spir64 -verify -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(const Func ) {
+  kernelFunc();
+}
+
+// CHECK: define dso_local spir_func{{.*}}invoke_function{{.*}}(i32 ()* %fptr, i32 addrspace(4)* %ptr)
+void invoke_function(int (*fptr)(), int *ptr) {}
+
+int f() { return 0; }
+
+int main() {
+  kernel_single_task([=]() {
+int (*p)() = f;
+int ()() = *p;
+int a = 10;
+invoke_function(p, );
+invoke_function(r, );
+invoke_function(f, );
+  });
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -633,7 +633,9 @@
 const ReferenceType *RTy = cast(Ty);
 QualType ETy = RTy->getPointeeType();
 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
-unsigned AS = Context.getTargetAddressSpace(ETy);
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Ok I've updated the diff here based on @dexonsmith's original suggestion, and 
some offline discussion with @JDevlieghere

The new logic remaps the files and statuses, in the fallback to the external FS 
case, to use the originally requested path. I opted not to use the second 
suggestion with passing the `struct` containing both paths through because of 
the churn that would have on the API to maintain the current public signatures 
while also supporting that. This approach is analogous to how we're currently 
remapping the statuses for `use-external-names` as well. Please let me know 
what you think!

Note there's some churn from me renaming `Path` -> `CanonicalPath` and `Path_` 
-> `OriginalPath`, let me know if you'd prefer I extract this into a separate 
diff that we land first without any logic changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379559.
keith marked 4 inline comments as done.
keith added a comment.

Update to remap file paths after fetching them from the external FS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: 

[PATCH] D111270: [clang] Pass -clear-ast-before-backend in Clang::ConstructJob()

2021-10-13 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D111270#3060484 , @dblaikie wrote:

> Plan is still to address the "this only works with disable free" issue? (I've 
> some preference that be addressed before this feature is turned on by default)

https://reviews.llvm.org/D111767. Thanks for pushing back, this actually does 
help a bit more with memory savings. I was worried that we'd be doing a bunch 
of pointer chasing if we supported -clear-ast-before-backend without 
-disable-free but couldn't measure any runtime regressions aside from some 
nullifying tiny wins gained by this patch.

> & is there a flag to pass to turn this off if someone had trouble with it? 
> (doesn't necessarily have to be, but just checking)

Just like `-disable-free` doesn't have a flag, I don't want one for this at 
least for now. I'd rather just revert this change and fix any issues. If we 
come across weird issues then we may have to add a flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111270

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


[PATCH] D111767: [clang] Support -clear-ast-before-backend without -disable-free

2021-10-13 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added a reviewer: dblaikie.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously without -disable-free, -clear-ast-before-backend would crash in 
~ASTContext() due to various reasons.
This works around that by doing a lot of the cleanup ahead of the destructor so 
that the destructor doesn't actually do any manual cleanup if we've already 
cleaned up beforehand.

This actually does save a measurable amount of memory with 
-clear-ast-before-backend, although at an almost unnoticeable runtime cost:
https://llvm-compile-time-tracker.com/compare.php?from=5d755b32f2775b9219f6d6e2feda5e1417dc993b=58ef1c7ad7e2ad45f9c97597905a8cf05a26258c=max-rss

Previously we weren't doing any cleanup with -disable-free, so I tried 
measuring the impact of always doing the cleanup and didn't measure anything 
noticeable on llvm-compile-time-tracker.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111767

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/CodeGen/CodeGenAction.cpp


Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -351,10 +351,11 @@
 }
   }
 
-  // FIXME: Fix cleanup issues with clearing the AST when we properly free
-  // things.
-  if (CodeGenOpts.DisableFree && CodeGenOpts.ClearASTBeforeBackend)
+  if (CodeGenOpts.ClearASTBeforeBackend) {
+// The ASTContext may be unusable after this.
+C.cleanup();
 C.getAllocator().Reset();
+  }
 
   EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef());
 
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1962,6 +1962,7 @@
   // pointer because the subclass doesn't add anything that needs to
   // be deleted.
   StoredDeclsMap::DestroyAll(LastSDM.getPointer(), LastSDM.getInt());
+  LastSDM.setPointer(nullptr);
 }
 
 void StoredDeclsMap::DestroyAll(StoredDeclsMap *Map, bool Dependent) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -990,7 +990,7 @@
   addTranslationUnitDecl();
 }
 
-ASTContext::~ASTContext() {
+void ASTContext::cleanup() {
   // Release the DenseMaps associated with DeclContext objects.
   // FIXME: Is this the ideal solution?
   ReleaseDeclContextMaps();
@@ -998,6 +998,7 @@
   // Call all of the deallocation functions on all of their targets.
   for (auto  : Deallocations)
 (Pair.first)(Pair.second);
+  Deallocations.clear();
 
   // ASTRecordLayout objects in ASTRecordLayouts must always be destroyed
   // because they can contain DenseMaps.
@@ -1007,6 +1008,7 @@
 // Increment in loop to prevent using deallocated memory.
 if (auto *R = const_cast((I++)->second))
   R->Destroy(*this);
+  ObjCLayouts.clear();
 
   for (llvm::DenseMap::iterator
I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
@@ -1014,16 +1016,21 @@
 if (auto *R = const_cast((I++)->second))
   R->Destroy(*this);
   }
+  ASTRecordLayouts.clear();
 
   for (llvm::DenseMap::iterator A = DeclAttrs.begin(),
 AEnd = DeclAttrs.end();
A != AEnd; ++A)
 A->second->~AttrVec();
+  DeclAttrs.clear();
 
   for (const auto  : ModuleInitializers)
 Value.second->~PerModuleInitializers();
+  ModuleInitializers.clear();
 }
 
+ASTContext::~ASTContext() { cleanup(); }
+
 void ASTContext::setTraversalScope(const std::vector ) {
   TraversalScope = TopLevelDecls;
   getParentMapContext().clear();
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -695,6 +695,12 @@
   SourceManager& getSourceManager() { return SourceMgr; }
   const SourceManager& getSourceManager() const { return SourceMgr; }
 
+  // Cleans up some of the data structures. This allows us to do cleanup
+  // normally done in the constructor earlier. May render much of the
+  // ASTContext unusable so should be called when ASTContext will no longer be
+  // used.
+  void cleanup();
+
   llvm::BumpPtrAllocator () const {
 return BumpAlloc;
   }


Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -351,10 +351,11 @@
 }
   }
 
-  // FIXME: Fix cleanup issues with clearing the AST when we properly free
-  // things.
-  if (CodeGenOpts.DisableFree && 

[PATCH] D111760: [clang] Support __float128 on DragonFlyBSD.

2021-10-13 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus created this revision.
fcambus added reviewers: emaste, joerg, mgorny, krytarowski.
fcambus requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111760

Files:
  clang/lib/Basic/Targets/OSTargets.h


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -179,6 +179,8 @@
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 Builder.defineMacro("__tune_i386__");
 DefineStd(Builder, "unix", Opts);
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
@@ -188,6 +190,7 @@
 default:
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
   this->MCountName = ".mcount";
   break;
 }


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -179,6 +179,8 @@
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 Builder.defineMacro("__tune_i386__");
 DefineStd(Builder, "unix", Opts);
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
@@ -188,6 +190,7 @@
 default:
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
   this->MCountName = ".mcount";
   break;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

It's good to know `ASTReader::ReadMethodPool` is pretty close for both 
approaches. And as far as I understand, it includes the code

  ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration);
  ModuleMgr.visit(Visitor);

so the module visiting doesn't seem to be too expensive.

I can be wrong but I like writing less data as it can result in savings for 
more projects. For example, if compile time is dominated by method 
deserialization and not by `Sema::addMethodToGlobalList`, we still should see 
an improvement. I can try to experiment on a bunch of other projects and their 
heavy .m files and report the results, if you'd like.

Also I've updated D110123  to preserve the 
order of methods (mostly, there are still some differences). Works better than 
the previous approach, compilation time difference is within the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-13 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:553
+Each builtin returns a scalar equivalent to applying the specified
+operation(x, y) as horizontal recursive pairwise reduction to all vector
+elements. In each reduction step, ``operation(x, y)`` is applied to adjacent

It's really not clear what "horizontal recursive pairwise" means unless one has 
read the mailing list discussions.  Maybe you could spell it out, e.g. 
"recursive even-odd pairwise reduction" or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:552
+operation(x, y) as pairwise tree reduction to the input. The pairs are formed
+by concatenating both inputs and pairing adjacent elements.
+

fhahn wrote:
> craig.topper wrote:
> > scanon wrote:
> > > fhahn wrote:
> > > > craig.topper wrote:
> > > > > I'm not sure I understand what is being concatenated here.
> > > > I tried to spell it out more clearly. I'm still not sure if that spells 
> > > > it out as clearly as possibly and I'd appreciate any suggestions on how 
> > > > to improve the wording.
> > > It's unclear because there's no apparent "first" or "second" vector; 
> > > there's just a single argument, and the result isn't a vector, it's a 
> > > scalar. I think you want to say something like: "the operation is 
> > > repeatedly applied to adjacent pairs of elements until the result is a 
> > > scalar" and then provide a worked example.
> > The input is a single vector. I'm not understanding where we get a second 
> > vector to concatenate.
> Oh yes, now I see where the confusion was coming from. I was thinking about 
> the reduction tree and how the input is broken up. Sorry for the confusing 
> wording. I gave it another try, should be much simpler again now.
Should it somehow mention the pair is the even element `i` and the odd element 
`i+1`. There are n-1 adjacent pairs in an n element vector, but we want 
non-overlapping pairs.

Should probably spell out the non-power2 behavior. Presumably we pad identity 
elements after the last element to widen the vector out to a power 2 and then 
proceed normally?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-13 Thread Steve Canon via Phabricator via cfe-commits
scanon accepted this revision.
scanon added a comment.
This revision is now accepted and ready to land.

I'm happy with this now.




Comment at: clang/docs/LanguageExtensions.rst:552
+operation(x, y) as pairwise tree reduction to the input. The pairs are formed
+by concatenating both inputs and pairing adjacent elements.
+

fhahn wrote:
> craig.topper wrote:
> > I'm not sure I understand what is being concatenated here.
> I tried to spell it out more clearly. I'm still not sure if that spells it 
> out as clearly as possibly and I'd appreciate any suggestions on how to 
> improve the wording.
It's unclear because there's no apparent "first" or "second" vector; there's 
just a single argument, and the result isn't a vector, it's a scalar. I think 
you want to say something like: "the operation is repeatedly applied to 
adjacent pairs of elements until the result is a scalar" and then provide a 
worked example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-13 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked an inline comment as done.
fhahn added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:552
+operation(x, y) as pairwise tree reduction to the input. The pairs are formed
+by concatenating both inputs and pairing adjacent elements.
+

craig.topper wrote:
> fhahn wrote:
> > craig.topper wrote:
> > > I'm not sure I understand what is being concatenated here.
> > I tried to spell it out more clearly. I'm still not sure if that spells it 
> > out as clearly as possibly and I'd appreciate any suggestions on how to 
> > improve the wording.
> The input is a single vector. I'm not understanding where we get a second 
> vector to concatenate.
Oh yes, now I see where the confusion was coming from. I was thinking about the 
reduction tree and how the input is broken up. Sorry for the confusing wording. 
I gave it another try, should be much simpler again now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-13 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 379517.
fhahn marked 2 inline comments as done.
fhahn added a comment.

Another stab at phrasing the reduction step. Also added a note that the 
implementation is work-in-progress.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -506,6 +506,71 @@
   If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
   And it selects base on signedness of the condition operands (OpenCL v1.1 
s6.3.9).
 
+Vector Builtins
+---
+
+**Note: The implementation of vector builtins is work-in-progress and 
incomplete.**
+
+In addition to the operators mentioned above, Clang provides a set of builtins
+to perform additional operations on certain scalar and vector types.
+
+Let ``T`` be one of the following types:
+
+* an integer type (as in C2x 6.2.5p19), but excluding enumerated types and 
_Bool
+* the standard floating types float or double
+* a half-precision floating point type, if one is supported on the target
+* a vector type.
+
+For scalar types, consider the operation applied to a vector with a single 
element.
+
+*Elementwise Builtins*
+
+Each builtin returns a vector equivalent to applying the specified operation
+elementwise to the input.
+
+Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = 
±infinity
+
+= 
 
==
+ Name  Operation   
 Supported element types
+= 
 
==
+ T __builtin_elementwise_abs(T x)  return the absolute value of a 
number x   integer and floating point types
+ T __builtin_elementwise_ceil(T x) return the smallest integral value 
greater than or equal to x floating point types
+ T __builtin_elementwise_floor(T x)return the largest integral value 
less than or equal to x floating point types
+ T __builtin_elementwise_roundeven(T x)round x to the nearest integer 
value in floating point format,floating point types
+   rounding halfway cases to even 
(that is, to the nearest value
+   that is an even integer), 
regardless of the current rounding
+   direction.
+ T__builtin_elementwise_trunc(T x) return the integral value nearest 
to but no larger in floating point types
+   magnitude than x
+ T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger  
  integer and floating point types
+ T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller 
  integer and floating point types
+= 
 
==
+
+
+*Reduction Builtins*
+
+Each builtin returns a scalar equivalent to applying the specified
+operation(x, y) as horizontal recursive pairwise reduction to all vector
+elements. In each reduction step, ``operation(x, y)`` is applied to adjacent
+elements.
+
+Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
+
+=== 
 
==
+ NameOperation 
   Supported element types
+=== 
 
==
+ ET __builtin_reduce_max(VT a)   return x or y, whichever is larger; 
If exactly one argument is   integer and floating point types
+ a NaN, return the other argument. If 
both arguments are NaNs,
+ fmax() return a NaN.
+ ET __builtin_reduce_min(VT a)   return x or y, whichever is smaller; 
If exactly one argument integer and floating point types
+ is a NaN, return the other argument. 
If both arguments are
+ NaNs, fmax() return a NaN.
+ ET __builtin_reduce_add(VT a)   \+
   integer and floating point 

[PATCH] D110123: [Proof of concept] Serialize fewer transitive methods in `METHOD_POOL`.

2021-10-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 379516.
vsapsai added a comment.

Try to preserve the order of methods when populating the global method pool.

This attempt is more successful at keeping the existing code working though I
still have 1 unexpected warning that requires further investigation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110123

Files:
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/lookup.m
  clang/test/Modules/method_pool_transitive.m

Index: clang/test/Modules/method_pool_transitive.m
===
--- /dev/null
+++ clang/test/Modules/method_pool_transitive.m
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -Wobjc-multiple-method-names -fsyntax-only -fmodules-cache-path=%t/modules.cache -fmodules -fimplicit-module-maps -F %t/Frameworks %t/test.m -verify
+
+// Verify we are handling methods from transitive modules, not just from immediate ones.
+
+//--- Frameworks/Indirect.framework/Headers/Indirect.h
+@interface NSObject
+@end
+
+@interface Indirect : NSObject
+- (int)method;
+@end
+
+//--- Frameworks/Indirect.framework/Modules/module.modulemap
+framework module Indirect {
+  header "Indirect.h"
+  export *
+}
+
+//--- Frameworks/Immediate.framework/Headers/Immediate.h
+#import 
+@interface Immediate : NSObject
+- (void)method;
+@end
+
+//--- Frameworks/Immediate.framework/Modules/module.modulemap
+framework module Immediate {
+  header "Immediate.h"
+  export *
+}
+
+//--- test.m
+#import 
+
+void test(id obj) {
+  [obj method];  // expected-warning{{multiple methods named 'method' found}}
+  // expected-note@Frameworks/Indirect.framework/Headers/Indirect.h:5{{using}}
+  // expected-note@Frameworks/Immediate.framework/Headers/Immediate.h:3{{also found}}
+}
Index: clang/test/Modules/lookup.m
===
--- clang/test/Modules/lookup.m
+++ clang/test/Modules/lookup.m
@@ -10,8 +10,8 @@
 void test(id x) {
   [x method];
 // expected-warning@-1{{multiple methods named 'method' found}}
-// expected-note@Inputs/lookup_left.h:2{{using}}
-// expected-note@Inputs/lookup_right.h:3{{also found}}
+// expected-note@Inputs/lookup_right.h:3{{using}}
+// expected-note@Inputs/lookup_left.h:2{{also found}}
 }
 
 // CHECK-PRINT: - (int)method;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3017,11 +3017,11 @@
 unsigned DataLen = 4 + 2 + 2; // 2 bytes for each of the method counts
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 DataLen += 4;
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 DataLen += 4;
 return emitULEBKeyDataLength(KeyLen, DataLen, Out);
   }
@@ -3052,13 +3052,13 @@
 unsigned NumInstanceMethods = 0;
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 ++NumInstanceMethods;
 
 unsigned NumFactoryMethods = 0;
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 ++NumFactoryMethods;
 
 unsigned InstanceBits = Methods.Instance.getBits();
@@ -3079,15 +3079,20 @@
 LE.write(FullFactoryBits);
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 LE.write(Writer.getDeclID(Method->getMethod()));
 for (const ObjCMethodList *Method =  Method;
  Method = Method->getNext())
-  if (Method->getMethod())
+  if (ShouldWriteMethodListNode(Method))
 LE.write(Writer.getDeclID(Method->getMethod()));
 
 assert(Out.tell() - Start == DataLen && "Data length is wrong");
   }
+
+private:
+  static bool ShouldWriteMethodListNode(const ObjCMethodList *Node) {
+return (Node->getMethod() && !Node->getMethod()->isFromASTFile());
+  }
 };
 
 } // namespace
@@ -3130,15 +3135,21 @@
   if (Chain && ID < FirstSelectorID) {
 // Selector already exists. Did it change?
 bool changed = false;
-for (ObjCMethodList *M = 
- !changed && M && M->getMethod(); M = M->getNext()) {
-  if (!M->getMethod()->isFromASTFile())
+for (ObjCMethodList *M =  M && M->getMethod();
+ M = M->getNext()) {
+  if (!M->getMethod()->isFromASTFile()) {
 changed = true;
+   

[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-13 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I don't have a problem with deleting the code if there's a technical 
justification, just wanted to avoid churn if it was purely for "it's not 
ratified" reasons and we think it'll reappear in another form later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111692

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


[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

My motivation was to reduce clang binary size by at least 50K and reduce our 
intrinsic count by 4% while we figure out ways to reduce the RISCV vector 
intrinsic load on clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111692

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


[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-13 Thread ShihPo Hung via Phabricator via cfe-commits
arcbbb added a reviewer: jrtc27.
arcbbb added a comment.

@jrtc27 commented to keep it in https://reviews.llvm.org/D105396?id=356342

LGTM otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111692

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


[PATCH] D111755: [ARM] Don't use TARGET_HEADER_BUILTIN in arm_mve_builtins.inc or arm_cde_builtins.inc

2021-10-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: simon_tatham, efriedma, miyuki, rnk.
Herald added subscribers: dmgreen, kristof.beyls.
craig.topper requested review of this revision.
Herald added a project: clang.

The attributes string doesn't include 'f' or 'h'. I don't think
any code looks at the header name without those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111755

Files:
  clang/utils/TableGen/MveEmitter.cpp


Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1941,8 +1941,8 @@
 void MveEmitter::EmitBuiltinDef(raw_ostream ) {
   for (const auto  : ACLEIntrinsics) {
 const ACLEIntrinsic  = *kv.second;
-OS << "TARGET_HEADER_BUILTIN(__builtin_arm_mve_" << Int.fullName()
-   << ", \"\", \"n\", \"arm_mve.h\", ALL_LANGUAGES, \"\")\n";
+OS << "BUILTIN(__builtin_arm_mve_" << Int.fullName()
+   << ", \"\", \"n\")\n";
   }
 
   std::set ShortNamesSeen;
@@ -2151,8 +2151,8 @@
 if (kv.second->headerOnly())
   continue;
 const ACLEIntrinsic  = *kv.second;
-OS << "TARGET_HEADER_BUILTIN(__builtin_arm_cde_" << Int.fullName()
-   << ", \"\", \"ncU\", \"arm_cde.h\", ALL_LANGUAGES, \"\")\n";
+OS << "BUILTIN(__builtin_arm_cde_" << Int.fullName()
+   << ", \"\", \"ncU\")\n";
   }
 }
 


Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1941,8 +1941,8 @@
 void MveEmitter::EmitBuiltinDef(raw_ostream ) {
   for (const auto  : ACLEIntrinsics) {
 const ACLEIntrinsic  = *kv.second;
-OS << "TARGET_HEADER_BUILTIN(__builtin_arm_mve_" << Int.fullName()
-   << ", \"\", \"n\", \"arm_mve.h\", ALL_LANGUAGES, \"\")\n";
+OS << "BUILTIN(__builtin_arm_mve_" << Int.fullName()
+   << ", \"\", \"n\")\n";
   }
 
   std::set ShortNamesSeen;
@@ -2151,8 +2151,8 @@
 if (kv.second->headerOnly())
   continue;
 const ACLEIntrinsic  = *kv.second;
-OS << "TARGET_HEADER_BUILTIN(__builtin_arm_cde_" << Int.fullName()
-   << ", \"\", \"ncU\", \"arm_cde.h\", ALL_LANGUAGES, \"\")\n";
+OS << "BUILTIN(__builtin_arm_cde_" << Int.fullName()
+   << ", \"\", \"ncU\")\n";
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111195: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9b9a7f42870: [clang][Tooling] Use Windows command lines on 
all Windows, except Cygwin (authored by jeremyd2019, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -135,15 +135,12 @@
 std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax,
  StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+// Assume Windows command line parsing on Win32
+Syntax = JSONCommandLineSyntax::Windows;
+#else
 Syntax = JSONCommandLineSyntax::Gnu;
-llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-  // Assume Windows command line parsing on Win32 unless the triple
-  // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-Syntax = JSONCommandLineSyntax::Windows;
-}
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -135,15 +135,12 @@
 std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax,
  StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+// Assume Windows command line parsing on Win32
+Syntax = JSONCommandLineSyntax::Windows;
+#else
 Syntax = JSONCommandLineSyntax::Gnu;
-llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-  // Assume Windows command line parsing on Win32 unless the triple
-  // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-Syntax = JSONCommandLineSyntax::Windows;
-}
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb541845ea082: [clang] [Windows] Mark PIC as implicitly 
enabled for aarch64, just like for… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/pic.c


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 void MSVCToolChain::AddCudaIncludeArgs(const ArgList ,


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() 

[clang] d9b9a7f - [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

2021-10-13 Thread Martin Storsjö via cfe-commits

Author: Jeremy Drake
Date: 2021-10-13T22:55:14+03:00
New Revision: d9b9a7f4287019ad7fb5ae35523e81dee36c1b40

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

LOG: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

Previously it only used Windows command lines for MSVC triples, but this
was causing issues for windows-gnu.  In fact, everything 'native' Windows
(ie, not Cygwin) should use Windows command line parsing.

Reviewed By: mstorsjo

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

Added: 


Modified: 
clang/lib/Tooling/JSONCompilationDatabase.cpp

Removed: 




diff  --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp 
b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 97ba7e411fbb..5e18d7a576c0 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -135,15 +135,12 @@ class CommandLineArgumentParser {
 std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax,
  StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+// Assume Windows command line parsing on Win32
+Syntax = JSONCommandLineSyntax::Windows;
+#else
 Syntax = JSONCommandLineSyntax::Gnu;
-llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-  // Assume Windows command line parsing on Win32 unless the triple
-  // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-Syntax = JSONCommandLineSyntax::Windows;
-}
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {



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


[clang] b541845 - [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-10-13T22:55:00+03:00
New Revision: b541845ea082d1dfca53074b4353e1ee0c22dd76

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

LOG: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like 
for x86_64

This doesn't practically affect the code generation.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/pic.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 046ef8024c6e4..5b7600493893e 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@ bool MSVCToolChain::IsUnwindTablesDefault(const ArgList 
) const {
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@ bool MSVCToolChain::isPIEDefault() const {
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 void MSVCToolChain::AddCudaIncludeArgs(const ArgList ,

diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 1aaa941498322..6f1b7dd330fd0 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@ bool toolchains::MinGW::IsUnwindTablesDefault(const 
ArgList ) const {
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling

diff  --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index 57924cd1bbb43..6f8d6cc75c006 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2



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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D111707#3062384 , @mstorsjo wrote:

> In D111707#3062361 , @MaskRay wrote:
>
>> I was thinking of when testing "windows" x "pic", whether the test should 
>> reside in "windows" or "pic".
>> If in "windows", we can decrease the number of RUN lines and use one RUN 
>> line to test multiple properties at one time.
>> If in "pic", it does make it clear what platforms default to pic but I think 
>> many platforms have dedicated tests and duplicate the coverage here anyway.
>
> True, but then again, this avoids needing to duplicate the PIC level checks 
> across two files. It costs a couple more `RUN` lines, true...
>
> Anyway, I'm not strongly opposed to restructuring it, but feel free to pick 
> that up as a followup if you want to - I'd rather keep this one as-is.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D111078: [AIX] Enable int128 in 64 bit mode

2021-10-13 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

ppc64-i128-abi.ll CHECK-P9 part depends on D94282 
: [PowerPC] Support ppc-asm-full-reg-names for 
AIX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111078

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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D111707#3062361 , @MaskRay wrote:

> I was thinking of when testing "windows" x "pic", whether the test should 
> reside in "windows" or "pic".
> If in "windows", we can decrease the number of RUN lines and use one RUN line 
> to test multiple properties at one time.
> If in "pic", it does make it clear what platforms default to pic but I think 
> many platforms have dedicated tests and duplicate the coverage here anyway.

True, but then again, this avoids needing to duplicate the PIC level checks 
across two files. It costs a couple more `RUN` lines, true...

Anyway, I'm not strongly opposed to restructuring it, but feel free to pick 
that up as a followup if you want to - I'd rather keep this one as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D111081: [clang] [MinGW] Fix paths on Gentoo

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Looks ok to me - WDYT @mgorny?


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

https://reviews.llvm.org/D111081

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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/Driver/pic.c:322
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2

MaskRay wrote:
> perhaps change windows-pic.cpp instead
That file actually doesn't test the thing that this patch touches (if I remove 
the existing cases for `x86_64` in the modified functions, that test still 
passes but this one breaks), so I thought this one is a better fit, wrt what 
the test actually tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I was thinking for testing "windows" x "pic", whether the test should reside in 
windows or pic.
If in "windows", we can decrease the number of RUN lines and use one RUN line 
to test multiple properties at one time.
If in "pic", it does make it clear what platforms default to pic but I think 
many platforms have dedicated tests and duplicate the coverage here anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D111195: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D95

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


[PATCH] D111726: [HIP] Fix test rcom-detect.hip

2021-10-13 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1439df00fc5e: [HIP] Fix test rcom-detect.hip (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111726

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -42,6 +42,7 @@
 // RUN: cp -r %S/Inputs/rocm-spack %T
 // RUN: ln -fs %clang 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN:   
-resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 
--print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
@@ -83,7 +84,7 @@
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -42,6 +42,7 @@
 // RUN: cp -r %S/Inputs/rocm-spack %T
 // RUN: ln -fs %clang %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
+// RUN:   -resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
@@ -83,7 +84,7 @@
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
-// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1439df0 - [HIP] Fix test rcom-detect.hip

2021-10-13 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-10-13T15:01:07-04:00
New Revision: 1439df00fc5e6dfffeb6a99e3537f6de2e539785

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

LOG: [HIP] Fix test rcom-detect.hip

This patches fixes https://bugs.llvm.org/show_bug.cgi?id=51404

Some builds use custom resource directory for clang, therefore the test
cannot assume default resource directory for clang. Use -resource-dir
to force it.

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

Added: 


Modified: 
clang/test/Driver/rocm-detect.hip

Removed: 




diff  --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index b54107f2bd014..3ab0175cf1f15 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -42,6 +42,7 @@
 // RUN: cp -r %S/Inputs/rocm-spack %T
 // RUN: ln -fs %clang 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN:   
-resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 
--print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
@@ -83,7 +84,7 @@
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd



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


[PATCH] D111078: [AIX] Enable int128 in 64 bit mode

2021-10-13 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 379485.
jsji added a comment.

Add AIX XCOFF triples to i128 tests, especially ppc64-i128-abi.ll.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111078

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/AST/ast-print-int128.cpp
  clang/test/Analysis/sval-dump-int128.c
  clang/test/CodeGen/dbg-const-int128.c
  clang/test/CodeGen/debug-info.c
  clang/test/CodeGen/extend-arg-64.c
  clang/test/CodeGen/ppc-varargs-struct.c
  clang/test/CodeGen/uint128_t.c
  clang/test/CodeGenCXX/debug-info-enum-i128.cpp
  clang/test/Driver/types.c
  clang/test/Preprocessor/init-ppc64.c
  clang/test/Sema/128bitint.c
  clang/test/Sema/const-eval.c
  clang/test/Sema/redefine_extname.c
  clang/test/Sema/types.c
  llvm/test/CodeGen/PowerPC/ctrloop-i128.ll
  llvm/test/CodeGen/PowerPC/int128_ldst.ll
  llvm/test/CodeGen/PowerPC/ppc64-i128-abi.ll

Index: llvm/test/CodeGen/PowerPC/ppc64-i128-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-i128-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-i128-abi.ll
@@ -5,9 +5,15 @@
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 < %s | FileCheck %s -check-prefix=CHECK-BE
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s -check-prefix=CHECK-BE
+
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-NOVSX
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
+; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-NOVSX
+
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-NOVSX \
 ; RUN:   --implicit-check-not xxswapd
@@ -15,6 +21,9 @@
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-BE-NOVSX
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
+; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-BE-NOVSX
+
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr8 -mattr=-vsx < %s | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-LE-NOVSX --implicit-check-not xxswapd
@@ -23,10 +32,16 @@
 ; RUN:   -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-P9 --implicit-check-not xxswapd
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
+; RUN:   -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s -check-prefix=CHECK-P9
+
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr9 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-NOVSX \
 ; RUN:   --implicit-check-not xxswapd
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
+; RUN:   -mcpu=pwr9 -mattr=-vsx < %s | FileCheck %s -check-prefix=CHECK-NOVSX
+
 ; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr9 -mattr=-power9-vector -mattr=-direct-move < %s | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-LE --implicit-check-not xxswapd
@@ -208,19 +223,19 @@
 
 ; CHECK-P9-LABEL: @call_v1i128_increment_by_one
 ; CHECK-P9: lxv
-; CHECK-P9: bl v1i128_increment_by_one
+; CHECK-P9: bl {{.?}}v1i128_increment_by_one
 ; CHECK-P9: blr
 
 ; CHECK-BE-LABEL: @call_v1i128_increment_by_one
 ; CHECK-BE: lxvw4x 34, {{[0-9]+}}, {{[0-9]+}}
 ; CHECK-BE-NOT: xxswapd 34, {{[0-9]+}}
-; CHECK-BE: bl v1i128_increment_by_one
+; CHECK-BE: bl {{.?}}v1i128_increment_by_one
 ; CHECK-BE: blr
 
 ; CHECK-NOVSX-LABEL: @call_v1i128_increment_by_one
 ; CHECK-NOVSX: lvx 2, {{[0-9]+}}, {{[0-9]+}}
 ; CHECK-NOVSX-NOT: xxswapd {{[0-9]+}}, {{[0-9]+}}
-; CHECK-NOVSX: bl v1i128_increment_by_one
+; CHECK-NOVSX: bl {{.?}}v1i128_increment_by_one
 ; CHECK-NOVSX: blr
 }
 
@@ -239,7 +254,7 @@
 ; CHECK-P9-LABEL: @call_v1i128_increment_by_val
 ; CHECK-P9-DAG: lxv v2
 ; CHECK-P9-DAG: lxv v3
-; CHECK-P9: bl v1i128_increment_by_val
+; CHECK-P9: bl {{.?}}v1i128_increment_by_val
 ; CHECK-P9: blr
 
 ; CHECK-BE-LABEL: @call_v1i128_increment_by_val
@@ -248,7 +263,7 @@
 ; CHECK-BE-DAG: lxvw4x 35, {{[0-9]+}}, {{[0-9]+}}
 ; CHECK-BE-NOT: xxswapd 34, {{[0-9]+}}
 ; CHECK-BE-NOT: xxswapd 35, {{[0-9]+}}
-; CHECK-BE: bl v1i128_increment_by_val
+; CHECK-BE: bl {{.?}}v1i128_increment_by_val
 ; CHECK-BE: blr
 
 ; CHECK-NOVSX-LABEL: @call_v1i128_increment_by_val
@@ -256,7 +271,7 @@
 ; CHECK-NOVSX-DAG: lvx 3, {{[0-9]+}}, {{[0-9]+}}
 ; CHECK-NOVSX-NOT: xxswapd 34, {{[0-9]+}}
 ; CHECK-NOVSX-NOT: xxswapd 35, 

[clang] d2e6f47 - [Builtins] Remove stale comment. NFC

2021-10-13 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-13T11:47:13-07:00
New Revision: d2e6f471b012579f950b81a2460393e0299f10d2

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

LOG: [Builtins] Remove stale comment. NFC

The header name was made a separate string more than 12.5 years ago.
I think it was part of the attribute string for less than a week.

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 0e3898537bcf..7a099326b68c 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -80,9 +80,7 @@
 //   builtin even if type doesn't match signature, and don't warn if we
 //   can't be sure the type is right
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
-//  f -> this is a libc/libm function without the '__builtin_' prefix. It can
-//   be followed by ':headername:' to state which header this function
-//   comes from.
+//  f -> this is a libc/libm function without the '__builtin_' prefix.
 //  h -> this function requires a specific header or an explicit declaration.
 //  i -> this is a runtime library implemented function without the
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.



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


[clang] 1bef229 - [clang] Delete unused class DiagsUninitializedSeveretyRAII

2021-10-13 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-13T14:27:26-04:00
New Revision: 1bef22950a5c72fe630f4d6aa7f161bc1e2cb2d1

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

LOG: [clang] Delete unused class DiagsUninitializedSeveretyRAII

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index da78212e29f4..2e8f20886680 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15884,29 +15884,6 @@ OMPClause 
*Sema::ActOnOpenMPPrivateClause(ArrayRef VarList,
   PrivateCopies);
 }
 
-namespace {
-class DiagsUninitializedSeveretyRAII {
-private:
-  DiagnosticsEngine 
-  SourceLocation SavedLoc;
-  bool IsIgnored = false;
-
-public:
-  DiagsUninitializedSeveretyRAII(DiagnosticsEngine , SourceLocation Loc,
- bool IsIgnored)
-  : Diags(Diags), SavedLoc(Loc), IsIgnored(IsIgnored) {
-if (!IsIgnored) {
-  Diags.setSeverity(/*Diag*/ diag::warn_uninit_self_reference_in_init,
-/*Map*/ diag::Severity::Ignored, Loc);
-}
-  }
-  ~DiagsUninitializedSeveretyRAII() {
-if (!IsIgnored)
-  Diags.popMappings(SavedLoc);
-  }
-};
-}
-
 OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef VarList,
SourceLocation StartLoc,
SourceLocation LParenLoc,



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


[PATCH] D111726: [HIP] Fix test rcom-detect.hip

2021-10-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I can confirm that the tests pass for me with this patch.


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

https://reviews.llvm.org/D111726

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


[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

2021-10-13 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I think for a Sema change there should be a **Sema** test, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111734

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


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-10-13 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Right, but a cache for SanitizerArgs is not enough to avoid repeated 
diagnostics, is it? Ex. if I request a non-existing sanitizer, I think I would 
get errors from host arg parsing, as well as from each of device1 and device2, 
because each device will have a unique ArgList.

Is it even possible for the driver to introduce new diagnostics in offload 
SanitizerArgs parsing? Is it possible to catch those cases ahead of time, when 
parsing SanitizerArgs for the first time, by looking at a target triple or 
something? That would be the most user friendly approach.


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

https://reviews.llvm.org/D111443

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


[PATCH] D111543: [clang][modules] Stop creating `IdentifierInfo` for names of explicit modules

2021-10-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'm concerned that this is adding complexity to paper over a bug elsewhere. 
Creating an `IdentifierInfo` should never cause unrelated uses of that 
identifier to change their meaning or behavior. My guess is that there's a bug 
in how we resolve or merge identifier  information in the AST reader.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111543

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


[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-10-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D110618#3054257 , 
@pekka.jaaskelainen wrote:

>> I don't feel it is different for OpenCL though... I am not in favour of 
>> repeating the same functionality for every language since the requirement 
>> will be likely identical. There is no timeline for when this functionality 
>> will be dropped so we have to assume that even though temporary it might be 
>> a solution for long enough.
>
> If it is likely the SPIR-V backend won’t land soon and it is expected that 
> also other languages might benefit from the calls to the llvm-spirv tool, the 
> functionality to do so would be better placed in a more generally useful 
> place. Do you have suggestions where this functionality could be moved?
>
> I believe it concerns mostly the call to the llvm-spriv (this is sought in 
> PATH, not given via a command line parameter) inside 
> constructEmitSpirvCommand(). This could be extracted to another function in a 
> utility library so it could be accessed by other languages/tools in the 
> future. Does it sound OK?

I believe this is indeed the most common functionality at this point, so if we 
could factor it out already now it would make sense. However, towards the 
common tooling we would probably need to create a special Tool/ToolChain for 
SPIR-V which could be derived from or used for the languages/toochains that 
target SPIR-V generation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-10-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D111443#3052697 , @tra wrote:

> In D111443#3052381 , @yaxunl wrote:
>
>> In D111443#3052099 , @tra wrote:
>>
>>> I'm curious why we need the cache at all. While the construction of 
>>> sanitizer args is hairy, it's only called few times from the driver and 
>>> will be lost in the noise compared to everything else.
>>
>> It is for avoiding repeated diagnostics. For example, -fsanitize=xxx is 
>> passed to clang and ld. If it is parsed twice, the diagnostics are emitted 
>> twice. There are lit tests to prevent the repeated diagnostics.
>> For this reason, using job action as cache key will not work since it will 
>> not prevent repeated diagnostics.
>
> Fair enough. Perhaps that's what we need to refactor first. We could separate 
> processing of the arguments from diagnosing issues there. I.e. something like 
> `getSanitizerArgs(const llvm::opt::ArgList , bool diag = false)` and 
> call it once with diag=true. Or just make diag a static local var and just 
> enable diags on the first call.



>> For most non-offloading toolchain, ld and clang job action will not create 
>> new ArgList, therefore they share the same ArgList and avoid repeated 
>> parsing. The ArgList persists for the whole life span of driver, therefore 
>> no life time issue.
>
> It may work now, but to me it looks like a dependence on an implementation 
> detail. I do not think it's reasonable to assume that ArgList pointer is 
> immutable and that it coexists with particular job.
>
> @eugenis -- WDYT?



In D111443#3055522 , @eugenis wrote:

> Don't we want to diagnose the problems in the job's command line? What kind 
> of changes can the driver do there that would affect SanitizerArgs?
>
> I wonder if diagnostics should still be performed on the job args, but 
> presented to the user differently, mainly because we can no longer refer to 
> the user-provided command line?

For offloading toolchain, the driver could remove -fsanitize for certain 
devices if they do not support them. Consider the following use case:

-fsanitize=address is passed by the user to clang driver, clang driver 
constructs 4 jobs by passing translated arguments to the tools:

1. clang for host: -fsanitize=address is passed to clang tool

2. ld for host: -fsantize=address is passed to host linker tool

3. clang for device 1: -fsanitize=address is not passed to clang tool

4. clang for device 2: -fsanitize=address is passed to clang tool

This demonstrates the necessity to parse the sanitizer arguments per job 
instead of per toolchain, since the same toolchain may parse different 
sanitizer arguments for different jobs.

If we need not avoid repeated diagnostics, we just need to parse the arguments 
for each job.

However, if we passed an invalid sanitizer argument to jobs 1, 2, and 4, we 
will get 3 identical diagnostics. This is annoying. That is why there are lit 
tests to prevent that.

Basically we need a way to know if the same argument list has been diagnosed. 
The simplest way is to check the pointer to the argument list since toolchain 
will reuse the original argument list if it does not change it. In this case, 
jobs 1, 2 and 4 share the same pointer to argument list, therefore they will be 
diagnosed only once. Since they are the same, they can be cached by pointer to 
the argument list.

This is also why separating diagnosing and parsing of sanitizer args does not 
help avoid repeated diagnostics for different jobs, since different jobs may 
have different sanitizer args. Then you have to have a map IsDiagnosed[JobArg] 
to track whether a job arg has been diagnosed. However, if you have that, then 
it is not too much different than having a cache for SanitizerArgs.


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

https://reviews.llvm.org/D111443

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


[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

2021-10-13 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 379444.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

adding codegen test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111734

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+// CHECK: %[[ADDR_ADDR:.*]] = alloca float*, align 8, addrspace(5)
+// CHECK: %[[ADDR_ADDR_ASCAST_PTR:.*]] = addrspacecast float* addrspace(5)* 
%[[ADDR_ADDR]] to float**
+// CHECK: store float* %addr, float** %[[ADDR_ADDR_ASCAST_PTR]], align 8
+// CHECK: %[[ADDR_ADDR_ASCAST:.*]] = load float*, float** 
%[[ADDR_ADDR_ASCAST_PTR]], align 8
+// CHECK: %[[AS_CAST:.*]] = addrspacecast float* %[[ADDR_ADDR_ASCAST]] to 
float addrspace(3)*
+// CHECK: %3 = call contract float @llvm.amdgcn.ds.fadd.f32(float 
addrspace(3)* %[[AS_CAST]]
+// CHECK: %4 = load float*, float** %rtn.ascast, align 8
+// CHECK: store float %3, float* %4, align 4
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6545,9 +6545,14 @@
 auto ArgPtTy = ArgTy->getPointeeType();
 auto ArgAS = ArgPtTy.getAddressSpace();
 
-// Only allow implicit casting from a non-default address space pointee
-// type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+// Only allow implicit casting when either the argument has a pointee 
in 
+// a non-default address space and the target address spaces of the 
argument
+// pointee is different from the target address space of the pointee 
of the
+// parameter, or the parameter is in the default address space.
+if ((ArgAS != LangAS::Default && 
+  getASTContext().getTargetAddressSpace(ArgAS) != 
+  getASTContext().getTargetAddressSpace(ParamAS)) || 
+  ParamAS == LangAS::Default)
   continue;
 
 // First, ensure that the Arg is an RValue.


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+// CHECK: %[[ADDR_ADDR:.*]] = alloca float*, align 8, addrspace(5)
+// CHECK: %[[ADDR_ADDR_ASCAST_PTR:.*]] = addrspacecast float* addrspace(5)* %[[ADDR_ADDR]] to float**
+// CHECK: store float* %addr, float** %[[ADDR_ADDR_ASCAST_PTR]], align 8
+// CHECK: %[[ADDR_ADDR_ASCAST:.*]] = load float*, float** %[[ADDR_ADDR_ASCAST_PTR]], align 8
+// CHECK: %[[AS_CAST:.*]] = addrspacecast float* %[[ADDR_ADDR_ASCAST]] to float addrspace(3)*
+// CHECK: %3 = call contract float @llvm.amdgcn.ds.fadd.f32(float addrspace(3)* %[[AS_CAST]]
+// CHECK: %4 = load float*, float** %rtn.ascast, align 8
+// CHECK: store float %3, float* %4, align 4
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6545,9 +6545,14 @@
 auto ArgPtTy = ArgTy->getPointeeType();
 auto ArgAS = ArgPtTy.getAddressSpace();
 
-// Only allow implicit casting from a non-default address space pointee
-// type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+// Only allow implicit casting when either the argument has a pointee in 
+// a non-default address space and the target address spaces of the argument
+// pointee is different from the target address space of the pointee of the
+// parameter, or the parameter is in the default address space.
+if ((ArgAS 

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM other than that comment about removing 'b' from AllStdExts.




Comment at: llvm/lib/Support/RISCVISAInfo.cpp:39
+
+static constexpr StringLiteral AllStdExts = "mafdqlcbjtpvn";
+

'b' shouldn't be in this list anymore?



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:388
+const std::vector ) {
+  std::unique_ptr ISAInfo(new RISCVISAInfo());
+  assert(XLen == 32 || XLen == 64);

kito-cheng wrote:
> craig.topper wrote:
> > Use
> > 
> > ```
> > auto ISAInfo = std::make_unique()
> > ```
> `std::make_unique()` require a `public` constructor, but I 
> would prefer keep that in `private`.
I agree with keeping the constructor private. I didn't realize make_unique had 
that restriction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/pic.c:322
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2

perhaps change windows-pic.cpp instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D99905: [OPENMP51]Initial parsing/sema for adjust_args clause for 'declare variant'

2021-10-13 Thread Mike Rice via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb4c451001d0: [OPENMP51]Initial parsing/sema for adjust_args 
clause for declare variant (authored by mikerice).
Herald added projects: clang, Flang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D99905?vs=379196=379439#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99905

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/OpenMP/declare_variant_clauses_ast_print.cpp
  clang/test/OpenMP/declare_variant_clauses_messages.cpp
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -314,6 +314,7 @@
 }
 def OMPC_DeviceType : Clause<"device_type"> {}
 def OMPC_Match : Clause<"match"> {}
+def OMPC_AdjustArgs : Clause<"adjust_args"> { }
 def OMPC_Depobj : Clause<"depobj"> {
   let clangClass = "OMPDepobjClause";
   let isImplicit = true;
@@ -1518,6 +1519,9 @@
   let allowedClauses = [
 VersionedClause
   ];
+  let allowedExclusiveClauses = [
+VersionedClause
+  ];
 }
 def OMP_MasterTaskloop : Directive<"master taskloop"> {
   let allowedClauses = [
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1422,6 +1422,7 @@
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
 CHECK_SIMPLE_CLAUSE(When, OMPC_when)
+CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/test/OpenMP/declare_variant_messages.cpp
===
--- clang/test/OpenMP/declare_variant_messages.cpp
+++ clang/test/OpenMP/declare_variant_messages.cpp
@@ -28,7 +28,7 @@
 #pragma omp declare variant(foofoo ) match(implementation = {}) // expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} expected-note {{the ignored selector spans until here}}
 #pragma omp declare variant(foofoo ) match(implementation = {vvv, vvv}) // expected-warning {{'vvv' is not a valid context selector for the context set 'implementation'; selector ignored}} expected-warning {{'vvv' is not a valid context selector for the context set 'implementation'; selector ignored}} expected-note {{context selector options are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} expected-note {{the ignored selector spans until here}} expected-note {{context selector options are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} expected-note {{the ignored selector spans until here}}
 #pragma omp declare variant(foofoo ) match(implementation = {vvv} implementation) // expected-error {{expected ')'}} expected-warning {{'vvv' is not a valid context selector for the context set 'implementation'; selector ignored}} expected-note {{context selector options are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} expected-note {{the ignored selector spans until here}} expected-note {{to match this '('}}
-#pragma omp declare variant(foofoo ) match(implementation = {vvv}) implementation // expected-warning {{'vvv' is not a valid context selector for the context set 'implementation'; selector ignored}} expected-note {{context selector options are: 'vendor' 'extension' 'unified_address' 'unified_shared_memory' 'reverse_offload' 'dynamic_allocators' 'atomic_default_mem_order'}} expected-note {{the ignored selector spans until here}}
+#pragma omp declare variant(foofoo ) match(implementation = {vvv}) implementation // 

[clang] fb4c451 - [OPENMP51]Initial parsing/sema for adjust_args clause for 'declare variant'

2021-10-13 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-10-13T09:34:09-07:00
New Revision: fb4c451001d06c600394382e2c6ad6872f78f646

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

LOG: [OPENMP51]Initial parsing/sema for adjust_args clause for 'declare variant'

Adds initial parsing and sema for the 'adjust_args' clause.

Note that an AST clause is not created as it instead adds its expressions
to the OMPDeclareVariantAttr.

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

Added: 
clang/test/OpenMP/declare_variant_clauses_ast_print.cpp
clang/test/OpenMP/declare_variant_clauses_messages.cpp

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/AttrImpl.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/OpenMP/declare_variant_messages.c
clang/test/OpenMP/declare_variant_messages.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 6d31b2906bc58..e94466bd6121a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3690,6 +3690,8 @@ def OMPDeclareVariant : InheritableAttr {
   let Args = [
 ExprArgument<"VariantFuncRef">,
 OMPTraitInfoArgument<"TraitInfos">,
+VariadicExprArgument<"AdjustArgsNothing">,
+VariadicExprArgument<"AdjustArgsNeedDevicePtr">
   ];
   let AdditionalMembers = [{
 OMPTraitInfo () { return *traitInfos; }

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index f42c55be63f93..e82eafba99546 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1357,7 +1357,8 @@ def err_omp_mapper_illegal_identifier : Error<
 def err_omp_mapper_expected_declarator : Error<
   "expected declarator on 'omp declare mapper' directive">;
 def err_omp_declare_variant_wrong_clause : Error<
-  "expected '%0' clause on 'omp declare variant' directive">;
+  "expected %select{'match'|'match' or 'adjust_args'}0 clause on "
+  "'omp declare variant' directive">;
 def err_omp_declare_variant_duplicate_nested_trait : Error<
   "nested OpenMP context selector contains duplicated trait '%0'"
   " in selector '%1' and set '%2' with 
diff erent score">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c5b3f2c5cca64..1634c23db3d26 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10817,6 +10817,10 @@ def err_omp_unroll_full_variable_trip_count : Error<
 def note_omp_directive_here : Note<"'%0' directive found here">;
 def err_omp_instantiation_not_supported
 : Error<"instantiation of '%0' not supported yet">;
+def err_omp_adjust_arg_multiple_clauses : Error<
+  "'adjust_arg' argument %0 used in multiple clauses">;
+def err_omp_clause_requires_dispatch_construct : Error<
+  "'%0' clause requires 'dispatch' context selector">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 4c014766180c5..a19daf91578ed 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -59,6 +59,9 @@
 #ifndef OPENMP_REDUCTION_MODIFIER
 #define OPENMP_REDUCTION_MODIFIER(Name)
 #endif
+#ifndef OPENMP_ADJUST_ARGS_KIND
+#define OPENMP_ADJUST_ARGS_KIND(Name)
+#endif
 
 // Static attributes for 'schedule' clause.
 OPENMP_SCHEDULE_KIND(static)
@@ -149,6 +152,11 @@ OPENMP_REDUCTION_MODIFIER(default)
 OPENMP_REDUCTION_MODIFIER(inscan)
 OPENMP_REDUCTION_MODIFIER(task)
 
+// Adjust-op kinds for the 'adjust_args' clause.
+OPENMP_ADJUST_ARGS_KIND(nothing)
+OPENMP_ADJUST_ARGS_KIND(need_device_ptr)
+
+#undef OPENMP_ADJUST_ARGS_KIND
 #undef OPENMP_REDUCTION_MODIFIER
 #undef OPENMP_DEVICE_MODIFIER
 #undef OPENMP_ORDER_KIND

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index dbb3a223dc40f..c90bd429d87c8 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -167,6 +167,13 @@ enum OpenMPReductionClauseModifier {
   OMPC_REDUCTION_unknown,
 };
 
+/// OpenMP adjust-op kinds for 'adjust_args' 

[PATCH] D111625: [clang-tidy] bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader

2021-10-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D111625#3061736 , @Sockke wrote:

> In D111625#3060978 , @aaron.ballman 
> wrote:
>
>> LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do 
>> so, but given the number of quality submissions you've had, I'm wondering if 
>> you'd like to obtain commit access of your own? 
>> (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the 
>> details of what that entails.)
>
> Thanks a lot! It's my pleasure to obtain commit access of my own. I will send 
> the application as required later. Before that, I would appreciate it if you 
> could commit it on my behalf. Thanks again! 
> Name: liuke
> Email: liuke.ge...@bytedance.com

Sounds great! I've commit on your behalf in 
ea72b55b5c7c281cb21bb7bd50e6e039ca63dfe8 
, thank 
you for the fix!


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

https://reviews.llvm.org/D111625

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


[clang-tools-extra] ea72b55 - bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader

2021-10-13 Thread Aaron Ballman via cfe-commits

Author: liuke
Date: 2021-10-13T12:31:02-04:00
New Revision: ea72b55b5c7c281cb21bb7bd50e6e039ca63dfe8

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

LOG: bugprone-argument-comment: SourceLocation valid judgment avoid emitting 
coredump in isInSystemHeader

If the Node has an invalid location, it will trigger assert in
isInSystemHeader(...).

void test() {
  __builtin_va_list __args;
  // __builtin_va_list has no defination in any source file and its
  // CXXConstructorDecl has invalid sourcelocation
}
coredump with "Assertion `Loc.isValid() && "Can't get file
characteristic of invalid loc!"' failed." in
getFileCharacteristic(SourceLocation).

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index c36fb60b6d3d6..3836e4cf3990d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -24,6 +24,8 @@ AST_MATCHER(Decl, isFromStdNamespaceOrSystemHeader) {
   if (const auto *D = Node.getDeclContext()->getEnclosingNamespaceContext())
 if (D->isStdNamespace())
   return true;
+  if (Node.getLocation().isInvalid())
+return false;
   return Node.getASTContext().getSourceManager().isInSystemHeader(
   Node.getLocation());
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp
index cb4eac84c6916..22dcd74b5c4fd 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp
@@ -151,3 +151,8 @@ void test() {
   my_system_header_function(/*not_arg=*/1);
 }
 } // namespace system_header
+
+void testInvalidSlocCxxConstructExpr() {
+  __builtin_va_list __args;
+  // __builtin_va_list has no defination in any source file
+} 



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


[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

2021-10-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

we need a codegen test for the case




Comment at: clang/lib/Sema/SemaExpr.cpp:6550
 // type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
   continue;

we still need to keep this condition so it should be:


```
if ((ArgAS != LangAS::Default &&
getASTContext().getTargetAddressSpace(ArgAS) !=
getASTContext().getTargetAddressSpace(ParamAS))
   || ParamAS == LangAS::Default)
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111734

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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 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.

Looks great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111707

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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-10-13 Thread Andrew Somerville via Phabricator via cfe-commits
catskul added inline comments.



Comment at: include/clang/Format/Format.h:793
+  /// \endcode
+  bool DanglingParenthesis;
+

seesemichaelj wrote:
> catskul wrote:
> > stringham wrote:
> > > djasper wrote:
> > > > stringham wrote:
> > > > > djasper wrote:
> > > > > > I don't think this is a name that anyone will intuitively 
> > > > > > understand. I understand that the naming is hard here. One thing I 
> > > > > > am wondering is whether this might ever make sense unless 
> > > > > > AlignAfterOpenBracket is set to AlwaysBreak?
> > > > > > 
> > > > > > Unless that option is set, we could have both in the same file:
> > > > > > 
> > > > > >   someFunction(,
> > > > > >);
> > > > > > 
> > > > > > and
> > > > > > 
> > > > > >   someFunction(
> > > > > >   , 
> > > > > >   );
> > > > > > 
> > > > > > Is that intended, i.e. are you actively using that? Answering this 
> > > > > > is important, because it influence whether or not we actually need 
> > > > > > to add another style option and even how to implement this.
> > > > > The name was based on the configuration option that scalafmt has for 
> > > > > their automatic scala formatter, they also have an option to have the 
> > > > > closing paren on its own line and they call it `danglingParentheses`. 
> > > > > I don't love the name and am open to other options.
> > > > > 
> > > > > That's a good point about AlignAfterOpenBracket being set to 
> > > > > AlwaysBreak. In our usage we have that option set, and I'm also 
> > > > > unsure if it makes sense without AlwaysBreak.
> > > > Hm. I am not sure either. What do you think of extending the 
> > > > BracketAlignmentStyle enum with an AlwaysBreakWithDanglingParenthesis? 
> > > > Or AlwaysBreakAndWrapRParen?
> > > Sorry for the delay in the reply!
> > > 
> > > That seems like a reasonable solution to me. I believe the structure of 
> > > the patch would be the same, just changing out the configuration option.
> > > 
> > > Can you point me to where I should look to figure out how to run the unit 
> > > tests and let me know if there are other changes you would recommend 
> > > besides updating configuration options?
> > @djasper I made the changes to @stringham's diff to implement your request 
> > to replace the `bool` with new item of `BracketAlignmentStyle` `enum`, and 
> > wondered if it might be backing us into a corner. 
> > 
> > As strange as some of these may be I've seen a few similar to:
> > 
> > ```
> > return_t myfunc(int x,
> > int y,
> > int z
> > );
> > ```
> > ```
> > return_t myfunc(int x,
> > int somelongy,
> > int z );
> > ```
> > ```
> > return_t myfunc(
> >  int x,
> >  int y,
> >  int z
> >  );
> > ```
> > and even my least favorite
> > ```
> > return_t myfunc(
> > int x,
> > int y,
> > int z
> > );
> > ```
> > 
> > Without advocating for supporting all such styles it would seem desireable 
> > to avoid an NxM enum of two, at least theoretically, independent style 
> > parameters. With that in mind should I instead create a different parameter 
> > `AlignClosingBracket` with a respective `enum` which includes 
> > `AfterFinalParameter` by default, and `NextLineWhenMultiline` to handle the 
> > variations this diff was opened for?
> > 
> > On the other hand, I can just stick with adding a new variation to 
> > `BracketAlignmentStyle` and deal with potential variations in the future if 
> > they're requested.
> > 
> @catskul, are we waiting for a response from @djasper (or other maintainer) 
> concerning your last question about whether or not to keep 
> `BracketAligngmentStyle` or to use a new parameter `AlignClosingBracket` that 
> you proposed? I'm just throwing my hand in the pile seeing what I can do to 
> help push this issue towards landing without creating duplicate work (or just 
> forking your code and compiling it for myself selfishly haha).
> 
> From what information I can gather, it sounds like you have a solution 
> @catskul that meets the requested changes by @djasper, and if those changes 
> are still desired provided your last comment here, a revision could be posted 
> for review (after rebase, tests pass, etc).
> 
> Am I understanding correctly here?
@seesemichaelj (@det87) Yes, though this diff belongs to @stringham I just 
jumped in to try to respond to @djasper's comments and keep the ball rolling.

I can post my changes that @blandcr and @jakar already found*, but would want 
to get the answer regarding `AlignClosingBracket` before putting any more 
energy into this as it's expensive to get spun back up and build all of this 
each time (I don't think I still have the build env around).

The second hurdle is that if I post a new diff I'm not sure if I'm adopting 
this whole thing and/or violating ettiquette, which I don't feel like I have 
the 

[PATCH] D110913: [analyzer][solver] Handle simplification to ConcreteInt

2021-10-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:392-397
+/// Try to simplify a given symbolic expression based on the constraints in
+/// State. This is needed because the Environment bindings are not getting
+/// updated when a new constraint is added to the State. If the symbol is
+/// simplified to a non-symbol (e.g. to a constant) then the original symbol
+/// is returned.
 SymbolRef simplify(ProgramStateRef State, SymbolRef Sym);

steakhal wrote:
> Okay, I like it!
> However, it's still not entirely clear to me *when* to use which.
> Could you clarify that aspect too?
> Sorry for being picky but I'm not an expert on this part of the code and if 
> it's not clear to me, it probably won't be clear to newcomers either.
Okay, I've added the following comment (though this feels a bit too mouthful 
for me):
```
/// ... We use this function in the family of assumeSymNE/EQ/LT/../GE
/// functions where we can work only with symbols. Use the other function
/// (simplifyToSVal) if you are interested in a simplification that may yield
/// a concrete constant value.
```



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2110
+
+SymbolRef SimplifiedMemberSym = nullptr;
+SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);

steakhal wrote:
> By initializing it here, it will be much cleaner:
> 1) It's not mutated, thus it can be `const`
> 2) We can spare the `else` branch.
> 
> Also consider marking the rest of the variables `const`, so that the lack of 
> constness would actually suggest mutability.
Good point! I've made the suggested change.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2112
+SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);
+if (const auto CI = SimplifiedMemberVal.getAs()) {
+  const llvm::APSInt  = CI->getValue();

steakhal wrote:
> I think a comment would be appreciated describing that we only look for 
> infeasibility here, nothing else.
> Thus, the //fallthrough// in the feasible case is intentional.
Ok, I've added a comment for that.



Comment at: clang/test/Analysis/solver-sym-simplification-concreteint.c:17
+return;
+  clang_analyzer_warnIfReached(); // expected-no-diagnostics
+

steakhal wrote:
> Consider following the convention and using the `// no-warning` comment 
> instead.
> I'm also requesting an additional test case, exercising the fallthrough 
> behavior I stated in an earlier comment.
Okay, makes sense. I've added a new test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110913

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


[PATCH] D110913: [analyzer][solver] Handle simplification to ConcreteInt

2021-10-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 379434.
martong marked 5 inline comments as done.
martong added a comment.

- Use getAsSymbol to initialize the simplified member symbol
- Add some more explanation to ento::simplify
- Add a comment about checking only feasiblity
- Add a new test case for the "fallthrough"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110913

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/solver-sym-simplification-concreteint.c

Index: clang/test/Analysis/solver-sym-simplification-concreteint.c
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-concreteint.c
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
+
+void test_simplification_to_concrete_int_infeasible(int b, int c) {
+  if (c + b != 0) // c + b == 0
+return;
+  if (b != 1) // b == 1  --> c + 1 == 0
+return;
+  if (c != 1) // c == 1  --> 1 + 1 == 0 contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_to_concrete_int_feasible(int b, int c) {
+  if (c + b != 0)
+return;
+  // c + b == 0
+  if (b != 1)
+return;
+  // b == 1   -->  c + 1 == 0
+  if (c != -1)
+return;
+  // c == -1  --> -1 + 1 == 0 OK
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_eval(c == -1);   // expected-warning{{TRUE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
Index: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -226,9 +226,13 @@
   }
 }
 
-SymbolRef simplify(ProgramStateRef State, SymbolRef Sym) {
+SVal simplifyToSVal(ProgramStateRef State, SymbolRef Sym) {
   SValBuilder  = State->getStateManager().getSValBuilder();
-  SVal SimplifiedVal = SVB.simplifySVal(State, SVB.makeSymbolVal(Sym));
+  return SVB.simplifySVal(State, SVB.makeSymbolVal(Sym));
+}
+
+SymbolRef simplify(ProgramStateRef State, SymbolRef Sym) {
+  SVal SimplifiedVal = simplifyToSVal(State, Sym);
   if (SymbolRef SimplifiedSym = SimplifiedVal.getAsSymbol())
 return SimplifiedSym;
   return Sym;
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2106,7 +2106,20 @@
ProgramStateRef State, EquivalenceClass Class) {
   SymbolSet ClassMembers = Class.getClassMembers(State);
   for (const SymbolRef  : ClassMembers) {
-SymbolRef SimplifiedMemberSym = ento::simplify(State, MemberSym);
+
+const SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);
+const SymbolRef SimplifiedMemberSym = SimplifiedMemberVal.getAsSymbol();
+
+// The symbol is collapsed to a constant, check if the current State is
+// still feasible.
+if (const auto CI = SimplifiedMemberVal.getAs()) {
+  const llvm::APSInt  = CI->getValue();
+  const RangeSet *ClassConstraint = getConstraint(State, Class);
+  // We have found a contradiction.
+  if (ClassConstraint && !ClassConstraint->contains(SV))
+return nullptr;
+}
+
 if (SimplifiedMemberSym && MemberSym != SimplifiedMemberSym) {
   // The simplified symbol should be the member of the original Class,
   // however, it might be in another existing class at the moment. We
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -389,11 +389,22 @@
   static void computeAdjustment(SymbolRef , llvm::APSInt );
 };
 
-/// Try to simplify a given symbolic expression's associated value based on the
-/// constraints in State. This is needed because the Environment bindings are
-/// not getting updated when a new constraint is added to the State.
+/// Try to simplify a given symbolic expression based on the constraints in
+/// State. This is 

[PATCH] D111560: [clang][modules] Cache loads of modules imported by PCH

2021-10-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D111560#3059128 , @dexonsmith 
wrote:

> LGTM. It'd be nice to split out the move of `ReadModuleNames` into an NFC 
> prep patch for a cleaner commit history before pushing, but up to you.

Committed in prep patch: aae776a5341ccf90a2c0a4e2e952ae4ec5ffb422 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111560

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


[PATCH] D111560: [clang][modules] Cache loads of modules imported by PCH

2021-10-13 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08c8016cfb2a: [clang][modules] Cache loads of modules 
imported by PCH (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D111560?vs=378945=379431#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111560

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/Modules/Inputs/pch-shared-module/mod.h
  clang/test/Modules/Inputs/pch-shared-module/module.modulemap
  clang/test/Modules/Inputs/pch-shared-module/pch.h
  clang/test/Modules/pch-shared-module.c

Index: clang/test/Modules/pch-shared-module.c
===
--- /dev/null
+++ clang/test/Modules/pch-shared-module.c
@@ -0,0 +1,14 @@
+// rm -rf %t && mkdir %t
+
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=mod %S/Inputs/pch-shared-module/module.modulemap -o %t/mod.pcm
+
+// RUN: %clang_cc1 -fmodules -emit-pch %S/Inputs/pch-shared-module/pch.h -o %t/pch.h.gch \
+// RUN:   -fmodule-file=%t/mod.pcm -fmodule-map-file=%S/Inputs/pch-shared-module/module.modulemap
+
+// Check that `mod.pcm` is loaded correctly, even though it's imported by the PCH as well.
+// RUN: %clang_cc1 -fmodules -fsyntax-only %s -include-pch %t/pch.h.gch -I %S/Inputs/pch-shared-module \
+// RUN:   -fmodule-file=%t/mod.pcm -fmodule-map-file=%S/Inputs/pch-shared-module/module.modulemap -verify
+
+#include "mod.h"
+
+// expected-no-diagnostics
Index: clang/test/Modules/Inputs/pch-shared-module/pch.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/pch-shared-module/pch.h
@@ -0,0 +1 @@
+#include "mod.h"
Index: clang/test/Modules/Inputs/pch-shared-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/pch-shared-module/module.modulemap
@@ -0,0 +1 @@
+module mod { header "mod.h" }
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -229,8 +229,7 @@
 // CHECK-TU-WITH-COMMON-NEXT:   "command-line": [
 // CHECK-TU-WITH-COMMON-NEXT: "-fno-implicit-modules",
 // CHECK-TU-WITH-COMMON-NEXT: "-fno-implicit-module-maps",
-// FIXME: Figure out why we need `=ModCommon2` here for Clang to pick up the PCM.
-// CHECK-TU-WITH-COMMON-NEXT: "-fmodule-file=ModCommon2=[[PREFIX]]/build/{{.*}}/ModCommon2-{{.*}}.pcm",
+// CHECK-TU-WITH-COMMON-NEXT: "-fmodule-file=[[PREFIX]]/build/{{.*}}/ModCommon2-{{.*}}.pcm",
 // CHECK-TU-WITH-COMMON-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
 // CHECK-TU-WITH-COMMON-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_TU_WITH_COMMON]]/ModTUWithCommon-{{.*}}.pcm",
 // CHECK-TU-WITH-COMMON-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -38,7 +38,7 @@
   };
 
   for (const PrebuiltModuleDep  : PrebuiltModuleDeps) {
-Args.push_back("-fmodule-file=" + PMD.ModuleName + "=" + PMD.PCMFile);
+Args.push_back("-fmodule-file=" + PMD.PCMFile);
 Args.push_back("-fmodule-map-file=" + PMD.ModuleMapFile);
   }
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -564,18 +564,17 @@
 // We mark these as known and redirect any attempt to load that module to
 // the files we were handed.
 struct ReadModuleNames : ASTReaderListener {
-  CompilerInstance 
+  Preprocessor 
   llvm::SmallVector LoadedModules;
 
-  ReadModuleNames(CompilerInstance ) : CI(CI) {}
+  ReadModuleNames(Preprocessor ) : PP(PP) {}
 
   void ReadModuleName(StringRef ModuleName) override {
-LoadedModules.push_back(
-CI.getPreprocessor().getIdentifierInfo(ModuleName));
+LoadedModules.push_back(PP.getIdentifierInfo(ModuleName));
   }
 
   void registerAll() {
-ModuleMap  = CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
+ModuleMap  = PP.getHeaderSearchInfo().getModuleMap();
 for (auto *II : LoadedModules)
   MM.cacheModuleLoad(*II, MM.findModule(II->getName()));
 LoadedModules.clear();
@@ -583,10 +582,8 @@
 
   void markAllUnavailable() {
 for (auto *II : LoadedModules) {
-  if (Module *M = CI.getPreprocessor()
-  .getHeaderSearchInfo()
-  .getModuleMap()

[clang] 08c8016 - [clang][modules] Cache loads of modules imported by PCH

2021-10-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-10-13T18:09:52+02:00
New Revision: 08c8016cfb2af9463514709271ae8c4ad6b19377

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

LOG: [clang][modules] Cache loads of modules imported by PCH

During explicit modular build, PCM files are typically specified via the 
`-fmodule-file=` command-line option. Early during the compilation, Clang 
uses the `ASTReader` to read their contents and caches the result so that the 
module isn't loaded implicitly later on. A listener is attached to the 
`ASTReader` to collect names of the modules read from the PCM files. However, 
if the PCM has already been loaded previously via PCH:
1. the `ASTReader` doesn't do anything for the second time,
2. the listener is not invoked at all,
3. the module load result is not cached,
4. the compilation fails when attempting to load the module implicitly later on.

This patch solves this problem by attaching the listener to the `ASTReader` for 
PCH reading as well.

Reviewed By: dexonsmith

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

Added: 
clang/test/Modules/Inputs/pch-shared-module/mod.h
clang/test/Modules/Inputs/pch-shared-module/module.modulemap
clang/test/Modules/Inputs/pch-shared-module/pch.h
clang/test/Modules/pch-shared-module.c

Modified: 
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/test/ClangScanDeps/modules-pch.c

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 634b120284b66..0e43fa404da70 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -564,18 +564,17 @@ namespace {
 // We mark these as known and redirect any attempt to load that module to
 // the files we were handed.
 struct ReadModuleNames : ASTReaderListener {
-  CompilerInstance 
+  Preprocessor 
   llvm::SmallVector LoadedModules;
 
-  ReadModuleNames(CompilerInstance ) : CI(CI) {}
+  ReadModuleNames(Preprocessor ) : PP(PP) {}
 
   void ReadModuleName(StringRef ModuleName) override {
-LoadedModules.push_back(
-CI.getPreprocessor().getIdentifierInfo(ModuleName));
+LoadedModules.push_back(PP.getIdentifierInfo(ModuleName));
   }
 
   void registerAll() {
-ModuleMap  = CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
+ModuleMap  = PP.getHeaderSearchInfo().getModuleMap();
 for (auto *II : LoadedModules)
   MM.cacheModuleLoad(*II, MM.findModule(II->getName()));
 LoadedModules.clear();
@@ -583,10 +582,8 @@ struct ReadModuleNames : ASTReaderListener {
 
   void markAllUnavailable() {
 for (auto *II : LoadedModules) {
-  if (Module *M = CI.getPreprocessor()
-  .getHeaderSearchInfo()
-  .getModuleMap()
-  .findModule(II->getName())) {
+  if (Module *M = PP.getHeaderSearchInfo().getModuleMap().findModule(
+  II->getName())) {
 M->HasIncompatibleModuleFile = true;
 
 // Mark module as available if the only reason it was unavailable
@@ -651,6 +648,11 @@ IntrusiveRefCntPtr 
CompilerInstance::createPCHExternalASTSource(
   for (auto  : DependencyCollectors)
 Listener->attachToASTReader(*Reader);
 
+  auto Listener = std::make_unique(PP);
+  auto  = *Listener;
+  ASTReader::ListenerScope ReadModuleNamesListener(*Reader,
+   std::move(Listener));
+
   switch (Reader->ReadAST(Path,
   Preamble ? serialization::MK_Preamble
: serialization::MK_PCH,
@@ -660,6 +662,7 @@ IntrusiveRefCntPtr 
CompilerInstance::createPCHExternalASTSource(
 // Set the predefines buffer as suggested by the PCH reader. Typically, the
 // predefines buffer will be empty.
 PP.setPredefines(Reader->getSuggestedPredefines());
+ListenerRef.registerAll();
 return Reader;
 
   case ASTReader::Failure:
@@ -675,6 +678,7 @@ IntrusiveRefCntPtr 
CompilerInstance::createPCHExternalASTSource(
 break;
   }
 
+  ListenerRef.markAllUnavailable();
   Context.setExternalSource(nullptr);
   return nullptr;
 }
@@ -1693,7 +1697,7 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) 
{
   SourceLocation())
 <= DiagnosticsEngine::Warning;
 
-  auto Listener = std::make_unique(*this);
+  auto Listener = std::make_unique(*PP);
   auto  = *Listener;
   ASTReader::ListenerScope ReadModuleNamesListener(*TheASTReader,
std::move(Listener));

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 

[clang] aae776a - [clang] NFC: Move class to make it reusable

2021-10-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-10-13T18:09:52+02:00
New Revision: aae776a5341ccf90a2c0a4e2e952ae4ec5ffb422

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

LOG: [clang] NFC: Move class to make it reusable

This is a prep patch for D111560.

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 3e0a0f312c55c..634b120284b66 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -559,6 +559,54 @@ void CompilerInstance::createASTContext() {
 
 // ExternalASTSource
 
+namespace {
+// Helper to recursively read the module names for all modules we're adding.
+// We mark these as known and redirect any attempt to load that module to
+// the files we were handed.
+struct ReadModuleNames : ASTReaderListener {
+  CompilerInstance 
+  llvm::SmallVector LoadedModules;
+
+  ReadModuleNames(CompilerInstance ) : CI(CI) {}
+
+  void ReadModuleName(StringRef ModuleName) override {
+LoadedModules.push_back(
+CI.getPreprocessor().getIdentifierInfo(ModuleName));
+  }
+
+  void registerAll() {
+ModuleMap  = CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
+for (auto *II : LoadedModules)
+  MM.cacheModuleLoad(*II, MM.findModule(II->getName()));
+LoadedModules.clear();
+  }
+
+  void markAllUnavailable() {
+for (auto *II : LoadedModules) {
+  if (Module *M = CI.getPreprocessor()
+  .getHeaderSearchInfo()
+  .getModuleMap()
+  .findModule(II->getName())) {
+M->HasIncompatibleModuleFile = true;
+
+// Mark module as available if the only reason it was unavailable
+// was missing headers.
+SmallVector Stack;
+Stack.push_back(M);
+while (!Stack.empty()) {
+  Module *Current = Stack.pop_back_val();
+  if (Current->IsUnimportable) continue;
+  Current->IsAvailable = true;
+  Stack.insert(Stack.end(),
+   Current->submodule_begin(), Current->submodule_end());
+}
+  }
+}
+LoadedModules.clear();
+  }
+};
+} // namespace
+
 void CompilerInstance::createPCHExternalASTSource(
 StringRef Path, DisableValidationForModuleKind DisableValidation,
 bool AllowPCHWithCompilerErrors, void *DeserializationListener,
@@ -1634,52 +1682,6 @@ bool CompilerInstance::loadModuleFile(StringRef 
FileName) {
*FrontendTimerGroup);
   llvm::TimeRegion TimeLoading(FrontendTimerGroup ?  : nullptr);
 
-  // Helper to recursively read the module names for all modules we're adding.
-  // We mark these as known and redirect any attempt to load that module to
-  // the files we were handed.
-  struct ReadModuleNames : ASTReaderListener {
-CompilerInstance 
-llvm::SmallVector LoadedModules;
-
-ReadModuleNames(CompilerInstance ) : CI(CI) {}
-
-void ReadModuleName(StringRef ModuleName) override {
-  LoadedModules.push_back(
-  CI.getPreprocessor().getIdentifierInfo(ModuleName));
-}
-
-void registerAll() {
-  ModuleMap  = 
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
-  for (auto *II : LoadedModules)
-MM.cacheModuleLoad(*II, MM.findModule(II->getName()));
-  LoadedModules.clear();
-}
-
-void markAllUnavailable() {
-  for (auto *II : LoadedModules) {
-if (Module *M = CI.getPreprocessor()
-.getHeaderSearchInfo()
-.getModuleMap()
-.findModule(II->getName())) {
-  M->HasIncompatibleModuleFile = true;
-
-  // Mark module as available if the only reason it was unavailable
-  // was missing headers.
-  SmallVector Stack;
-  Stack.push_back(M);
-  while (!Stack.empty()) {
-Module *Current = Stack.pop_back_val();
-if (Current->IsUnimportable) continue;
-Current->IsAvailable = true;
-Stack.insert(Stack.end(),
- Current->submodule_begin(), Current->submodule_end());
-  }
-}
-  }
-  LoadedModules.clear();
-}
-  };
-
   // If we don't already have an ASTReader, create one now.
   if (!TheASTReader)
 createASTReader();



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


[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-13 Thread gehry via Phabricator via cfe-commits
Sockke marked 12 inline comments as done.
Sockke added a comment.

Kindly ping.


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

https://reviews.llvm.org/D107450

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


[PATCH] D111625: [clang-tidy] bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader

2021-10-13 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

In D111625#3060978 , @aaron.ballman 
wrote:

> LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do so, 
> but given the number of quality submissions you've had, I'm wondering if 
> you'd like to obtain commit access of your own? 
> (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the 
> details of what that entails.)

Thanks a lot! It's my pleasure to obtain commit access of my own. I will send 
the application as required later. Before that, I would appreciate it if you 
could commit it on my behalf. Thanks again! 
Name: liuke
Email: liuke.ge...@bytedance.com


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

https://reviews.llvm.org/D111625

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


[PATCH] D111543: [clang][modules] Stop creating `IdentifierInfo` for names of explicit modules

2021-10-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 379424.
jansvoboda11 added a comment.

Use clearer wording in member name & documentation, use `std::string` instead 
of `StringRef` for storing module name to solve lifetime issues (surfaced in 
CI).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111543

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Modules/Inputs/module-name-used-by-objc-bridge/Interface.h
  clang/test/Modules/Inputs/module-name-used-by-objc-bridge/InterfaceBridge.h
  clang/test/Modules/Inputs/module-name-used-by-objc-bridge/module.modulemap
  clang/test/Modules/module-name-used-by-objc-bridge.m

Index: clang/test/Modules/module-name-used-by-objc-bridge.m
===
--- /dev/null
+++ clang/test/Modules/module-name-used-by-objc-bridge.m
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir %t
+
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=InterfaceBridge \
+// RUN:   %S/Inputs/module-name-used-by-objc-bridge/module.modulemap -o %t/InterfaceBridge.pcm
+
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=Interface \
+// RUN:   %S/Inputs/module-name-used-by-objc-bridge/module.modulemap -o %t/Interface.pcm
+
+// Check that the `-fmodule-file==` form succeeds:
+// RUN: %clang_cc1 -fmodules -fsyntax-only %s -I %S/Inputs/module-name-used-by-objc-bridge \
+// RUN:   -fmodule-file=InterfaceBridge=%t/InterfaceBridge.pcm -fmodule-file=Interface=%t/Interface.pcm \
+// RUN:   -fmodule-map-file=%S/Inputs/module-name-used-by-objc-bridge/module.modulemap -verify
+
+// Check that the `-fmodule-file=` form succeeds:
+// RUN: %clang_cc1 -fmodules -fsyntax-only %s -I %S/Inputs/module-name-used-by-objc-bridge \
+// RUN:   -fmodule-file=%t/InterfaceBridge.pcm -fmodule-file=%t/Interface.pcm \
+// RUN:   -fmodule-map-file=%S/Inputs/module-name-used-by-objc-bridge/module.modulemap -verify
+
+#import "InterfaceBridge.h"
+#import "Interface.h"
+
+@interface Interface (User)
+@end
+
+// expected-no-diagnostics
Index: clang/test/Modules/Inputs/module-name-used-by-objc-bridge/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/module-name-used-by-objc-bridge/module.modulemap
@@ -0,0 +1,7 @@
+module InterfaceBridge {
+  header "InterfaceBridge.h"
+}
+
+module Interface {
+  header "Interface.h"
+}
Index: clang/test/Modules/Inputs/module-name-used-by-objc-bridge/InterfaceBridge.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/module-name-used-by-objc-bridge/InterfaceBridge.h
@@ -0,0 +1 @@
+typedef struct __attribute__((objc_bridge(Interface))) Foo *Bar;
Index: clang/test/Modules/Inputs/module-name-used-by-objc-bridge/Interface.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/module-name-used-by-objc-bridge/Interface.h
@@ -0,0 +1,2 @@
+@interface Interface
+@end
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1639,28 +1639,27 @@
   // the files we were handed.
   struct ReadModuleNames : ASTReaderListener {
 CompilerInstance 
-llvm::SmallVector LoadedModules;
+llvm::SmallVector LoadedModules;
 
 ReadModuleNames(CompilerInstance ) : CI(CI) {}
 
 void ReadModuleName(StringRef ModuleName) override {
-  LoadedModules.push_back(
-  CI.getPreprocessor().getIdentifierInfo(ModuleName));
+  LoadedModules.push_back(ModuleName.str());
 }
 
 void registerAll() {
   ModuleMap  = CI.getPreprocessor().getHeaderSearchInfo().getModuleMap();
-  for (auto *II : LoadedModules)
-MM.cacheModuleLoad(*II, MM.findModule(II->getName()));
+  for (const std::string  : LoadedModules)
+MM.cacheExplicitModuleLoad(LoadedModule, MM.findModule(LoadedModule));
   LoadedModules.clear();
 }
 
 void markAllUnavailable() {
-  for (auto *II : LoadedModules) {
+  for (const std::string  : LoadedModules) {
 if (Module *M = CI.getPreprocessor()
 .getHeaderSearchInfo()
 .getModuleMap()
-.findModule(II->getName())) {
+.findModule(LoadedModule)) {
   M->HasIncompatibleModuleFile = true;
 
   // Mark module as available if the only reason it was unavailable
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -105,6 +105,10 @@
   /// nullptr is stored for modules that are known to fail to load.
   llvm::DenseMap 

[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

2021-10-13 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 379419.
gandhi21299 added a comment.

removed irrelevant lines in the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111734

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6547,7 +6547,9 @@
 
 // Only allow implicit casting from a non-default address space pointee
 // type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+if (ArgAS != LangAS::Default &&
+getASTContext().getTargetAddressSpace(ArgAS) !=
+getASTContext().getTargetAddressSpace(ParamAS))
   continue;
 
 // First, ensure that the Arg is an RValue.


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6547,7 +6547,9 @@
 
 // Only allow implicit casting from a non-default address space pointee
 // type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+if (ArgAS != LangAS::Default &&
+getASTContext().getTargetAddressSpace(ArgAS) !=
+getASTContext().getTargetAddressSpace(ParamAS))
   continue;
 
 // First, ensure that the Arg is an RValue.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

2021-10-13 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added a reviewer: yaxunl.
gandhi21299 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow (implicit) address space casting between LLVM-equivalent
target address spaces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111734

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(0))) float *GP;
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6547,7 +6547,9 @@
 
 // Only allow implicit casting from a non-default address space pointee
 // type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+if (ArgAS != LangAS::Default &&
+getASTContext().getTargetAddressSpace(ArgAS) !=
+getASTContext().getTargetAddressSpace(ParamAS))
   continue;
 
 // First, ensure that the Arg is an RValue.


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(0))) float *GP;
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6547,7 +6547,9 @@
 
 // Only allow implicit casting from a non-default address space pointee
 // type to a default address space pointee type
-if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+if (ArgAS != LangAS::Default &&
+getASTContext().getTargetAddressSpace(ArgAS) !=
+getASTContext().getTargetAddressSpace(ParamAS))
   continue;
 
 // First, ensure that the Arg is an RValue.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102923: [clang][lex] Remark on search path usage

2021-10-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 closed this revision.
jansvoboda11 added a comment.

Fixed in 28fa77feeb7db46abea1a6699d7a88a02d8dab46 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102923

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


[PATCH] D111728: [clang][deps] NFC: Rename building CompilerInvocation

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

The dependency scanner works with multiple instances of 
`Compiler{Instance,Invocation}`. From names of the variables/members, their 
purpose is not obvious.

This patch gives descriptive name to the generated `CompilerInvocation` that 
can be used to derive the command-line to build a modular dependency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111728

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


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -362,7 +362,7 @@
 SmallString<256> ExplicitPCMPath(
 !ModuleFilesDir.empty()
 ? ModuleFilesDir
-: MD.Invocation.getHeaderSearchOpts().ModuleCachePath);
+: MD.BuildInvocation.getHeaderSearchOpts().ModuleCachePath);
 llvm::sys::path::append(ExplicitPCMPath, MD.ID.ContextHash, Filename);
 return std::string(ExplicitPCMPath);
   }
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -79,7 +79,7 @@
 std::vector ModuleDeps::getCanonicalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  CompilerInvocation CI(Invocation);
+  CompilerInvocation CI(BuildInvocation);
   FrontendOptions  = CI.getFrontendOpts();
 
   InputKind ModuleMapInputKind(FrontendOpts.DashX.getLanguage(),
@@ -96,7 +96,7 @@
 
 std::vector
 ModuleDeps::getCanonicalCommandLineWithoutModulePaths() const {
-  return serializeCompilerInvocation(Invocation);
+  return serializeCompilerInvocation(BuildInvocation);
 }
 
 void dependencies::detail::collectPCMAndModuleMapPaths(
@@ -255,13 +255,13 @@
   llvm::DenseSet SeenModules;
   addAllSubmodulePrebuiltDeps(M, MD, SeenModules);
 
-  MD.Invocation = MDC.makeInvocationForModuleBuildWithoutPaths(
-  MD, [&](CompilerInvocation ) {
+  MD.BuildInvocation = MDC.makeInvocationForModuleBuildWithoutPaths(
+  MD, [&](CompilerInvocation ) {
 if (MDC.OptimizeArgs)
-  optimizeHeaderSearchOpts(CI.getHeaderSearchOpts(),
+  optimizeHeaderSearchOpts(BuildInvocation.getHeaderSearchOpts(),
*MDC.ScanInstance.getASTReader(), *MF);
   });
-  MD.ID.ContextHash = MD.Invocation.getModuleHash();
+  MD.ID.ContextHash = MD.BuildInvocation.getModuleHash();
 
   llvm::DenseSet AddedModules;
   addAllSubmoduleDeps(M, MD, AddedModules);
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -101,7 +101,7 @@
   bool ImportedByMainFile = false;
 
   /// Compiler invocation that can be used to build this module (without 
paths).
-  CompilerInvocation Invocation;
+  CompilerInvocation BuildInvocation;
 
   /// Gets the canonical command line suitable for passing to clang.
   ///


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -362,7 +362,7 @@
 SmallString<256> ExplicitPCMPath(
 !ModuleFilesDir.empty()
 ? ModuleFilesDir
-: MD.Invocation.getHeaderSearchOpts().ModuleCachePath);
+: MD.BuildInvocation.getHeaderSearchOpts().ModuleCachePath);
 llvm::sys::path::append(ExplicitPCMPath, MD.ID.ContextHash, Filename);
 return std::string(ExplicitPCMPath);
   }
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -79,7 +79,7 @@
 std::vector ModuleDeps::getCanonicalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  CompilerInvocation CI(Invocation);
+  CompilerInvocation CI(BuildInvocation);
   FrontendOptions  = CI.getFrontendOpts();
 
   InputKind ModuleMapInputKind(FrontendOpts.DashX.getLanguage(),
@@ -96,7 +96,7 @@
 
 std::vector
 ModuleDeps::getCanonicalCommandLineWithoutModulePaths() const {
-  return serializeCompilerInvocation(Invocation);
+  return 

[PATCH] D111726: [HIP] Fix test rcom-detect.hip

2021-10-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

This patches fixes https://bugs.llvm.org/show_bug.cgi?id=51404

Some builds use custom resource directory for clang, therefore the test
cannot assume default resource directory for clang. Use -resource-dir
to force it.


https://reviews.llvm.org/D111726

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -42,6 +42,7 @@
 // RUN: cp -r %S/Inputs/rocm-spack %T
 // RUN: ln -fs %clang 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN:   
-resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 
--print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
@@ -83,7 +84,7 @@
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -42,6 +42,7 @@
 // RUN: cp -r %S/Inputs/rocm-spack %T
 // RUN: ln -fs %clang %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
+// RUN:   -resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
@@ -83,7 +84,7 @@
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
-// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111725: [clang][deps] NFC: Rename scanning CompilerInstance

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

The dependency scanner works with multiple instances of 
`Compiler{Instance,Invocation}`. From names of the variables/members, their 
purpose is not obvious.

This patch gives a distinct name to the `CompilerInstance` that's used to run 
the implicit build during dependency scan.

Depends on D111724 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111725

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

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -129,15 +129,15 @@
FileID PrevFID) {
   if (Reason != PPCallbacks::EnterFile)
 return;
-  
+
   // This has to be delayed as the context hash can change at the start of
   // `CompilerInstance::ExecuteAction`.
   if (MDC.ContextHash.empty()) {
-MDC.ContextHash = MDC.Instance.getInvocation().getModuleHash();
+MDC.ContextHash = MDC.ScanInstance.getInvocation().getModuleHash();
 MDC.Consumer.handleContextHash(MDC.ContextHash);
   }
 
-  SourceManager  = MDC.Instance.getSourceManager();
+  SourceManager  = MDC.ScanInstance.getSourceManager();
 
   // Dependency generation really does want to go all the way to the
   // file entry for a source location to find out what is depended on.
@@ -180,13 +180,14 @@
 }
 
 void ModuleDepCollectorPP::EndOfMainFile() {
-  FileID MainFileID = MDC.Instance.getSourceManager().getMainFileID();
-  MDC.MainFile = std::string(
-  MDC.Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
+  FileID MainFileID = MDC.ScanInstance.getSourceManager().getMainFileID();
+  MDC.MainFile = std::string(MDC.ScanInstance.getSourceManager()
+ .getFileEntryForID(MainFileID)
+ ->getName());
 
-  if (!MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude.empty())
+  if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
 MDC.FileDeps.push_back(
-MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude);
+MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
 
   for (const Module *M : DirectModularDeps) {
 // A top-level module might not be actually imported as a module when
@@ -225,15 +226,16 @@
   MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
   MD.IsSystem = M->IsSystem;
 
-  const FileEntry *ModuleMap = MDC.Instance.getPreprocessor()
+  const FileEntry *ModuleMap = MDC.ScanInstance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getModuleMapFileForUniquing(M);
   MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
 
   serialization::ModuleFile *MF =
-  MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
-  MDC.Instance.getASTReader()->visitInputFiles(
+  MDC.ScanInstance.getASTReader()->getModuleManager().lookup(
+  M->getASTFile());
+  MDC.ScanInstance.getASTReader()->visitInputFiles(
   *MF, true, true, [&](const serialization::InputFile , bool isSystem) {
 // __inferred_module.map is the result of the way in which an implicit
 // module build handles inferred modules. It adds an overlay VFS with
@@ -257,7 +259,7 @@
   MD, [&](CompilerInvocation ) {
 if (MDC.OptimizeArgs)
   optimizeHeaderSearchOpts(CI.getHeaderSearchOpts(),
-   *MDC.Instance.getASTReader(), *MF);
+   *MDC.ScanInstance.getASTReader(), *MF);
   });
   MD.ID.ContextHash = MD.Invocation.getModuleHash();
 
@@ -309,9 +311,10 @@
 }
 
 ModuleDepCollector::ModuleDepCollector(
-std::unique_ptr Opts, CompilerInstance ,
-DependencyConsumer , CompilerInvocation &, bool OptimizeArgs)
-: Instance(I), Consumer(C), Opts(std::move(Opts)),
+std::unique_ptr Opts,
+CompilerInstance , DependencyConsumer ,
+CompilerInvocation &, bool OptimizeArgs)
+: ScanInstance(ScanInstance), Consumer(C), Opts(std::move(Opts)),
   OriginalInvocation(std::move(OriginalCI)), OptimizeArgs(OptimizeArgs) {}
 
 void ModuleDepCollector::attachToPreprocessor(Preprocessor ) {
@@ -323,7 +326,7 @@
 bool ModuleDepCollector::isPrebuiltModule(const Module *M) {
   std::string Name(M->getTopLevelModuleName());
   const auto  =
-  Instance.getHeaderSearchOpts().PrebuiltModuleFiles;

[PATCH] D111724: [clang][deps] NFC: Remove redundant CompilerInstance reference

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

The `ModuleDepCollectorPP` class holds a reference to `ModuleDepCollector` as 
well as `ModuleDepCollector`'s `CompilerInstance`. The fact that these refer to 
the same object is non-obvious.

This patch removes the `CompilerInvocation` reference from 
`ModuleDepCollectorPP` and accesses it through `ModuleDepCollector` instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111724

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


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -133,11 +133,11 @@
   // This has to be delayed as the context hash can change at the start of
   // `CompilerInstance::ExecuteAction`.
   if (MDC.ContextHash.empty()) {
-MDC.ContextHash = Instance.getInvocation().getModuleHash();
+MDC.ContextHash = MDC.Instance.getInvocation().getModuleHash();
 MDC.Consumer.handleContextHash(MDC.ContextHash);
   }
 
-  SourceManager  = Instance.getSourceManager();
+  SourceManager  = MDC.Instance.getSourceManager();
 
   // Dependency generation really does want to go all the way to the
   // file entry for a source location to find out what is depended on.
@@ -180,12 +180,13 @@
 }
 
 void ModuleDepCollectorPP::EndOfMainFile() {
-  FileID MainFileID = Instance.getSourceManager().getMainFileID();
+  FileID MainFileID = MDC.Instance.getSourceManager().getMainFileID();
   MDC.MainFile = std::string(
-  Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
+  
MDC.Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
 
-  if (!Instance.getPreprocessorOpts().ImplicitPCHInclude.empty())
-MDC.FileDeps.push_back(Instance.getPreprocessorOpts().ImplicitPCHInclude);
+  if (!MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude.empty())
+MDC.FileDeps.push_back(
+MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude);
 
   for (const Module *M : DirectModularDeps) {
 // A top-level module might not be actually imported as a module when
@@ -224,7 +225,7 @@
   MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
   MD.IsSystem = M->IsSystem;
 
-  const FileEntry *ModuleMap = Instance.getPreprocessor()
+  const FileEntry *ModuleMap = MDC.Instance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getModuleMapFileForUniquing(M);
@@ -314,7 +315,7 @@
   OriginalInvocation(std::move(OriginalCI)), OptimizeArgs(OptimizeArgs) {}
 
 void ModuleDepCollector::attachToPreprocessor(Preprocessor ) {
-  PP.addPPCallbacks(std::make_unique(Instance, *this));
+  PP.addPPCallbacks(std::make_unique(*this));
 }
 
 void ModuleDepCollector::attachToASTReader(ASTReader ) {}
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -141,8 +141,7 @@
 /// \c DependencyConsumer of the parent \c ModuleDepCollector.
 class ModuleDepCollectorPP final : public PPCallbacks {
 public:
-  ModuleDepCollectorPP(CompilerInstance , ModuleDepCollector )
-  : Instance(I), MDC(MDC) {}
+  ModuleDepCollectorPP(ModuleDepCollector ) : MDC(MDC) {}
 
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
@@ -159,8 +158,6 @@
   void EndOfMainFile() override;
 
 private:
-  /// The compiler instance for the current translation unit.
-  CompilerInstance 
   /// The parent dependency collector.
   ModuleDepCollector 
   /// Working set of direct modular dependencies.


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -133,11 +133,11 @@
   // This has to be delayed as the context hash can change at the start of
   // `CompilerInstance::ExecuteAction`.
   if (MDC.ContextHash.empty()) {
-MDC.ContextHash = Instance.getInvocation().getModuleHash();
+MDC.ContextHash = MDC.Instance.getInvocation().getModuleHash();
 MDC.Consumer.handleContextHash(MDC.ContextHash);
   }
 
-  SourceManager  = Instance.getSourceManager();
+  SourceManager  = MDC.Instance.getSourceManager();
 
   // Dependency generation really does want 

[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-10-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I would like to explain the position of the OpenCL tooling community and the 
directions we would like to take with SPIR-V support in LLVM. We believe that 
SPIR-V triple and target should be added explicitly to LLVM/Clang for the 
following reasons:

- It would be better in the future to get away from the use of SPIR because 
SPIR has been discontinued by the Khronos Group and ever since it has evolved 
in various ways that are not documented anywhere to our knowledge. The use of 
SPIR for SPIR-V has largely been a workaround due to the failure to add SPIR-V 
target natively in Clang/LLVM. We would like to be able to deprecate or even 
remove SPIR in the future if the community is happy to switch to SPIR-V fully. 
Therefore we believe that it is better for the LLVM project not to create any 
new uses of it but instead teach the developer community to use SPIR-V target 
straight away.
- We believe that adding SPIR-V explicitly will better align with the 
conventional architecture of Clang/LLVM where each distinct target has its 
corresponding triple/target representation. It will also eliminate confusion in 
the developer community as both SPIR and SPIR-V exist in the specification as 
completely different formats and both are supported in tooling.
- With wider adoption of SPIR-V support in LLVM (i.e. backend or even MLIR) 
adding a new triple seems to be inevitable so it is better to add it straight 
away in order to avoid rewriting code later on or force application developers 
to switch to a different interface.
- We would like to improve and optimize the design of the LLVM stack for SPIR-V 
- for example, we are planning to change the design of the OpenCL builtins for 
SPIR-V that we won't be able to change for SPIR as it is used by other tools 
(for example clspv) differently. We can't force vendors to change their 
implementations because of our goals. This would be impractical considering how 
long SPIR was used in tools around OpenCL and possibly other languages too.

Note that we are aware that switching to SPIR-V target would require some 
changes in tools including SPIRV-LLVM Translator that we find fully justifiable 
and we, therefore, don't have any objections to adding such changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


[PATCH] D111720: [clang][deps] Ensure reported context hash is strict

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

One of main goals of the dependency scanner is to be strict about module 
compatibility. This is achieved through strict context hash. This patch ensures 
that strict context hash is enabled not only during the scan itself (and its 
minimized implicit build), but also when actually reporting the dependency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111720

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-context-hash/a/dep.h
  clang/test/ClangScanDeps/Inputs/modules-context-hash/b/dep.h
  clang/test/ClangScanDeps/Inputs/modules-context-hash/cdb.json.template
  clang/test/ClangScanDeps/Inputs/modules-context-hash/mod.h
  clang/test/ClangScanDeps/Inputs/modules-context-hash/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules-context-hash/tu.c
  clang/test/ClangScanDeps/modules-context-hash.c

Index: clang/test/ClangScanDeps/modules-context-hash.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-context-hash.c
@@ -0,0 +1,89 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp -r %S/Inputs/modules-context-hash/* %t
+
+// Check that the scanner reports the same module as distinct dependencies when
+// a single translation unit gets compiled with multiple command-lines that
+// produce different **strict** context hashes.
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb.json.template > %t/cdb.json
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 >> %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK
+
+// CHECK:  -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK:  "-emit-module"
+// CHECK:  "-I"
+// CHECK:  "[[PREFIX]]/a"
+// CHECK:  "-fmodule-name=mod"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_A:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/a/dep.h",
+// CHECK-NEXT: "[[PREFIX]]/mod.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "mod"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK:  "-emit-module"
+// CHECK:  "-I"
+// CHECK:  "[[PREFIX]]/b"
+// CHECK:  "-fmodule-name=mod"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_B:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/b/dep.h",
+// CHECK-NEXT: "[[PREFIX]]/mod.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "{{.*}}",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_A]]",
+// CHECK-NEXT:   "module-name": "mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fno-implicit-modules",
+// CHECK-NEXT: "-fno-implicit-module-maps"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/tu.c"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/tu.c"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "{{.*}}",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_B]]",
+// CHECK-NEXT:   "module-name": "mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fno-implicit-modules",
+// CHECK-NEXT: "-fno-implicit-module-maps"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/tu.c"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/tu.c"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/modules-context-hash/tu.c
===
--- /dev/null
+++ 

[PATCH] D71016: [SYCL] Implement OpenCL kernel function generation

2021-10-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

FWIW, it seems like precommit CI is failing with problems in `x64 windows > 
Clang.SemaSYCL::accessors-targets.cpp` (which is largely hidden by the spam 
from the CI pipeline, unfortunately). Also, you should address the tidy 
warnings.




Comment at: clang/include/clang/Sema/Sema.h:12793
+  /// Contains generated OpenCL kernel functions for SYCL.
+  SmallVector SYCLKernels;
+

Is 4 accurate? I would assume that 1 is more accurate as most people aren't 
going to be using SYCL at all.



Comment at: clang/include/clang/Sema/Sema.h:12798
+  /// Access to SYCL kernels.
+  SmallVectorImpl () { return SYCLKernels; }
+

ABataev wrote:
> `ArrayRef getSYCLKernels()`
Also, this needs a const-correct overload (or surface only the const correct 
version, if possible).



Comment at: clang/lib/AST/ASTContext.cpp:10722
+  // If SYCL, only kernels are required.
+  if (LangOpts.SYCLIsDevice && !(D->hasAttr()))
+return false;





Comment at: clang/lib/Sema/SemaSYCL.cpp:45
+  /// accessor class.
+  static bool isSyclAccessorType(const QualType );
+

bader wrote:
> erichkeane wrote:
> > Isn't there a big rewrite going on downstream of these with 
> > `sycl_special_class`?  Why are we trying to upstream this before that 
> > happens?
> > Isn't there a big rewrite going on downstream of these with 
> > `sycl_special_class`?  
> 
> Yes.
> 
> > Why are we trying to upstream this before that happens?
> 
> The downstream work was initiated by this comment: 
> https://reviews.llvm.org/D71016#inline-644645.
> This patch was uploaded for review here before refactoring work has started.
So should this patch be abandoned until that refactoring work completes, to 
avoid churn?



Comment at: clang/lib/Sema/SemaSYCL.cpp:100
+if (Ref && Ref == MappingPair.first) {
+  auto NewDecl = MappingPair.second;
+  return DeclRefExpr::Create(

Please spell out the type as it's not spelled out in the initialization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71016

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


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-13 Thread Kamau Bridgeman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89ec99c77894: [PowerPC][Builtin] Allowing __rlwnm to accept 
a variable as a shift parameter (authored by kamaub).

Changed prior to commit:
  https://reviews.llvm.org/D111229?vs=379149=379375#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
@@ -56,6 +56,22 @@
   unsigned int res = __builtin_ppc_rlwnm(ui, 31, 0x1FF);
 }
 
+void test_builtin_ppc_rlwnm2(unsigned int shift) {
+  // CHECK-LABEL: test_builtin_ppc_rlwnm2
+  // CHECK:   %shift.addr = alloca i32, align 4
+  // CHECK-NEXT:  %res = alloca i32, align 4
+  // CHECK-NEXT:  store i32 %shift, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RA:%[0-9]+]] = load i32, i32* @ui, align 4
+  // CHECK-NEXT:  [[RB:%[0-9]+]] = load i32, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RC:%[0-9]+]] = call i32 @llvm.fshl.i32(i32 [[RA]], i32 
[[RA]], i32 [[RB]])
+  // CHECK-NEXT:  [[RD:%[0-9]+]] = and i32 [[RC]], 511
+  // CHECK-NEXT:  store i32 [[RD]], i32* %res, align 4
+  // CHECK-NEXT:  ret void
+
+  /*mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);
+}
+
 // CHECK-LABEL: @testrotatel4(
 // CHECK: [[TMP:%.*]] = call i32 @llvm.fshl.i32(i32 {{%.*}}, i32 
{{%.*}}, i32 {{%.*}})
 // CHECK-NEXT:ret i32 [[TMP]]
Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -41,10 +41,8 @@
 }
 
 void test_builtin_ppc_rlwnm() {
-  unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
-  res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask);  // 
expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error 
{{argument 2 value should represent a contiguous bit field}}
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load


Index: clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
@@ -56,6 +56,22 @@
   unsigned int res = __builtin_ppc_rlwnm(ui, 31, 0x1FF);
 }
 
+void test_builtin_ppc_rlwnm2(unsigned int shift) {
+  // CHECK-LABEL: test_builtin_ppc_rlwnm2
+  // CHECK:   %shift.addr = alloca i32, align 4
+  // CHECK-NEXT:  %res = alloca i32, align 4
+  // CHECK-NEXT:  store i32 %shift, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RA:%[0-9]+]] = load i32, i32* @ui, align 4
+  // CHECK-NEXT:  [[RB:%[0-9]+]] = load i32, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RC:%[0-9]+]] = call i32 @llvm.fshl.i32(i32 [[RA]], i32 [[RA]], i32 [[RB]])
+  // CHECK-NEXT:  [[RD:%[0-9]+]] = and i32 [[RC]], 511
+  // CHECK-NEXT:  store i32 [[RD]], i32* %res, align 4
+  // CHECK-NEXT:  ret void
+
+  /*mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);
+}
+
 // 

[clang] 89ec99c - [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-13 Thread Kamau Bridgeman via cfe-commits

Author: Kamau Bridgeman
Date: 2021-10-13T09:40:06-05:00
New Revision: 89ec99c778943151213118f096e8008197c9ba10

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

LOG: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift 
parameter

The builtin __rlwnm is currently constrained to accept only constants
for the shift parameter but the instructions emitted for it have no such
constraint, this patch allows the builtins to accept variable shift.

Reviewed By: NeHuang, amyk

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-xlcompat-error.c
clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 3fa5729fc7d03..f82d455506860 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@ BUILTIN(__builtin_ppc_maddhd, "LLiLLiLLiLLi", "")
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4d84606290b4e..090fcd985df07 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo 
, unsigned BuiltinID,
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-error.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-error.c
index 9fc218b1de413..5f57d7575c859 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -41,10 +41,8 @@ void test_builtin_ppc_rlwimi() {
 }
 
 void test_builtin_ppc_rlwnm() {
-  unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
-  res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask);  // 
expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error 
{{argument 2 value should represent a contiguous bit field}}
 }
 

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
index 5ca7706f422ff..73c2d2cb8aee2 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
@@ -56,6 +56,22 @@ void test_builtin_ppc_rlwnm() {
   unsigned int res = __builtin_ppc_rlwnm(ui, 31, 0x1FF);
 }
 
+void test_builtin_ppc_rlwnm2(unsigned int shift) {
+  // CHECK-LABEL: test_builtin_ppc_rlwnm2
+  // CHECK:   %shift.addr = alloca i32, align 4
+  // CHECK-NEXT:  %res = alloca i32, align 4
+  // CHECK-NEXT:  store i32 %shift, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RA:%[0-9]+]] = load i32, i32* @ui, align 4
+  // CHECK-NEXT:  [[RB:%[0-9]+]] = load i32, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RC:%[0-9]+]] = call i32 @llvm.fshl.i32(i32 [[RA]], i32 
[[RA]], i32 [[RB]])
+  // CHECK-NEXT:  [[RD:%[0-9]+]] = and i32 [[RC]], 511
+  // CHECK-NEXT:  store i32 [[RD]], i32* %res, align 4
+  // CHECK-NEXT:  ret void
+
+  /*mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);
+}
+
 // CHECK-LABEL: @testrotatel4(
 // CHECK: [[TMP:%.*]] = call i32 @llvm.fshl.i32(i32 {{%.*}}, i32 
{{%.*}}, i32 {{%.*}})
 // CHECK-NEXT:ret i32 [[TMP]]



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


[PATCH] D71016: [SYCL] Implement OpenCL kernel function generation

2021-10-13 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/Sema/SemaSYCL.cpp:45
+  /// accessor class.
+  static bool isSyclAccessorType(const QualType );
+

erichkeane wrote:
> Isn't there a big rewrite going on downstream of these with 
> `sycl_special_class`?  Why are we trying to upstream this before that happens?
> Isn't there a big rewrite going on downstream of these with 
> `sycl_special_class`?  

Yes.

> Why are we trying to upstream this before that happens?

The downstream work was initiated by this comment: 
https://reviews.llvm.org/D71016#inline-644645.
This patch was uploaded for review here before refactoring work has started.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71016

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


[PATCH] D111698: [clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

2021-10-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG with the new test




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:124
 const auto  = SM.getSLocEntry(FID).getExpansion();
-add(Exp.getSpellingLoc());
+// For nested macro expansions, the spelling location can be within a
+// temporary buffer that Clang creates (scratch space or ScratchBuffer).

This is about token pasting, nested macro expansions are neither necessary nor 
sufficient.



Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:198
+  auto HeaderID = Includes.getID(*Entry);
+  EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(HeaderID));
+  EXPECT_THAT(getUnused(Includes, ReferencedFiles), ::testing::IsEmpty());

Nit: I think this should be asserting on FileIDs (i.e. before translation). 
It's narrower, and the contract is that findReferecedFiles should filter them 
out already.



Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:198
+  auto HeaderID = Includes.getID(*Entry);
+  EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(HeaderID));
+  EXPECT_THAT(getUnused(Includes, ReferencedFiles), ::testing::IsEmpty());

sammccall wrote:
> Nit: I think this should be asserting on FileIDs (i.e. before translation). 
> It's narrower, and the contract is that findReferecedFiles should filter them 
> out already.
Comment: no "" FID



Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:199
+  EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(HeaderID));
+  EXPECT_THAT(getUnused(Includes, ReferencedFiles), ::testing::IsEmpty());
+}

Comment: should not crash due to "files" missing from include structure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111698

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


[PATCH] D111698: [clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

2021-10-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:170
 
+TEST(IncludeCleaner, ScratchBuffer) {
+  TestTU TU;

sammccall wrote:
> this doesn't seem to test very much, a comment should indicate that this is 
> guarding against a crash.
> 
> Ideally we'd (also?) have a test that calls findReferencedFiles and actually 
> assert which IDs we get, rather than run some big blob of code and hope not 
> to crash.
Good point, I just ran into this for D111711:

foo.h
```
void foo();
```

foo.cpp
```
void foo() {}
```

`computeUnusedIncludes()` does not return `foo.h` but it wasn't processed (e.g. 
its ID was never in the `ReferencedFiles` in the first place) :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111698

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


[PATCH] D111711: [clangd] IncludeCleaner: ReferencedLocationCrawler should handle FunctionDecls

2021-10-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 379367.
kbobyrev added a comment.

Make the logic correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111711

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,15 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
+  {
+  "inline void ^foo() {}",
+  "void bar() { foo(); }",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,11 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+add(FD);
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,15 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
+  {
+  "inline void ^foo() {}",
+  "void bar() { foo(); }",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,11 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+add(FD);
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111698: [clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

2021-10-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 379366.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111698

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -167,6 +167,38 @@
   UnorderedElementsAre("\"unused.h\"", "\"dir/unused.h\""));
 }
 
+TEST(IncludeCleaner, ScratchBuffer) {
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  TU.Code = R"cpp(
+#include "macro_spelling_in_scratch_buffer.h"
+
+using flags::FLAGS_FOO;
+)cpp";
+  // The pasting operator in combination with DEFINE_FLAG will create
+  // ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
+  // FileEntry.
+  TU.AdditionalFiles["macro_spelling_in_scratch_buffer.h"] = R"cpp(
+#define DEFINE_FLAG(X) \
+namespace flags { \
+int FLAGS_##X; \
+} \
+
+DEFINE_FLAG(FOO)
+)cpp";
+  ParsedAST AST = TU.build();
+  auto  = AST.getSourceManager();
+  auto  = AST.getIncludeStructure();
+  auto ReferencedFiles = translateToHeaderIDs(
+  findReferencedFiles(findReferencedLocations(AST), SM), Includes, SM);
+  auto Entry = SM.getFileManager().getFile(
+  testPath("macro_spelling_in_scratch_buffer.h"));
+  ASSERT_TRUE(Entry);
+  auto HeaderID = Includes.getID(*Entry);
+  EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(HeaderID));
+  EXPECT_THAT(getUnused(Includes, ReferencedFiles), ::testing::IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -121,7 +121,11 @@
 if (!Macros.insert(FID).second)
   return;
 const auto  = SM.getSLocEntry(FID).getExpansion();
-add(Exp.getSpellingLoc());
+// For nested macro expansions, the spelling location can be within a
+// temporary buffer that Clang creates (scratch space or ScratchBuffer).
+// That is not a real file we can include.
+if (!SM.isWrittenInScratchSpace(Exp.getSpellingLoc()))
+  add(Exp.getSpellingLoc());
 add(Exp.getExpansionLocStart());
 add(Exp.getExpansionLocEnd());
   }


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -167,6 +167,38 @@
   UnorderedElementsAre("\"unused.h\"", "\"dir/unused.h\""));
 }
 
+TEST(IncludeCleaner, ScratchBuffer) {
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  TU.Code = R"cpp(
+#include "macro_spelling_in_scratch_buffer.h"
+
+using flags::FLAGS_FOO;
+)cpp";
+  // The pasting operator in combination with DEFINE_FLAG will create
+  // ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
+  // FileEntry.
+  TU.AdditionalFiles["macro_spelling_in_scratch_buffer.h"] = R"cpp(
+#define DEFINE_FLAG(X) \
+namespace flags { \
+int FLAGS_##X; \
+} \
+
+DEFINE_FLAG(FOO)
+)cpp";
+  ParsedAST AST = TU.build();
+  auto  = AST.getSourceManager();
+  auto  = AST.getIncludeStructure();
+  auto ReferencedFiles = translateToHeaderIDs(
+  findReferencedFiles(findReferencedLocations(AST), SM), Includes, SM);
+  auto Entry = SM.getFileManager().getFile(
+  testPath("macro_spelling_in_scratch_buffer.h"));
+  ASSERT_TRUE(Entry);
+  auto HeaderID = Includes.getID(*Entry);
+  EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(HeaderID));
+  EXPECT_THAT(getUnused(Includes, ReferencedFiles), ::testing::IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -121,7 +121,11 @@
 if (!Macros.insert(FID).second)
   return;
 const auto  = SM.getSLocEntry(FID).getExpansion();
-add(Exp.getSpellingLoc());
+// For nested macro expansions, the spelling location can be within a
+// temporary buffer that Clang creates (scratch space or ScratchBuffer).
+// That is not a real file we can include.
+if (!SM.isWrittenInScratchSpace(Exp.getSpellingLoc()))
+  add(Exp.getSpellingLoc());
 add(Exp.getExpansionLocStart());
 add(Exp.getExpansionLocEnd());
   }
___
cfe-commits mailing list

[PATCH] D71016: [SYCL] Implement OpenCL kernel function generation

2021-10-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaSYCL.cpp:45
+  /// accessor class.
+  static bool isSyclAccessorType(const QualType );
+

Isn't there a big rewrite going on downstream of these with 
`sycl_special_class`?  Why are we trying to upstream this before that happens?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71016

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


[PATCH] D111711: [clangd] IncludeCleaner: ReferencedLocationCrawler should handle FunctionDecls

2021-10-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111711

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,11 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,11 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+add(FD->getDefinition());
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,11 @@
   "struct ^X { ^X(int) {} int ^foo(); };",
   "auto x = X(42); auto y = x.foo();",
   },
+  // Function
+  {
+  "void ^foo();",
+  "void foo() {}",
+  },
   // Static function
   {
   "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,11 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+add(FD->getDefinition());
+return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
 add(CCE->getConstructor());
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111708: [libTooling] Add "switch"-like Stencil combinator

2021-10-13 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
ymandel requested review of this revision.
Herald added a project: clang.

Adds `selectBound`, a `Stencil` combinator that allows the user to supply 
multiple alternative cases, discriminated by bound node IDs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111708

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -201,6 +201,58 @@
   testExpr(Id, "3;", ifBound("other", cat("5"), cat("7")), "7");
 }
 
+static auto selectMatcher() {
+  // The `anything` matcher is not bound, to test for none of the cases
+  // matching.
+  return expr(anyOf(integerLiteral().bind("int"), cxxBoolLiteral().bind("bool"),
+floatLiteral().bind("float"), anything()));
+}
+
+static auto selectStencil() {
+  return selectBound({
+  {"int", cat("I")},
+  {"bool", cat("B")},
+  {"bool", cat("redundant")},
+  {"float", cat("F")},
+  });
+}
+
+TEST_F(StencilTest, SelectBoundChooseDetectedMatch) {
+  std::string Input = "3;";
+  auto StmtMatch = matchStmt(Input, selectMatcher());
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(selectStencil()->eval(StmtMatch->Result),
+   HasValue(std::string("I")));
+}
+
+TEST_F(StencilTest, SelectBoundChooseFirst) {
+  std::string Input = "true;";
+  auto StmtMatch = matchStmt(Input, selectMatcher());
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(selectStencil()->eval(StmtMatch->Result),
+   HasValue(std::string("B")));
+}
+
+TEST_F(StencilTest, SelectBoundDiesOnExhaustedCases) {
+  std::string Input = "\"string\";";
+  auto StmtMatch = matchStmt(Input, selectMatcher());
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT_EXPECTED(
+  selectStencil()->eval(StmtMatch->Result),
+  Failed(testing::Property(
+  ::getMessage,
+  AllOf(HasSubstr("selectBound failed"), HasSubstr("no default");
+}
+
+TEST_F(StencilTest, SelectBoundSucceedsWithDefault) {
+  std::string Input = "\"string\";";
+  auto StmtMatch = matchStmt(Input, selectMatcher());
+  ASSERT_TRUE(StmtMatch);
+  auto Stencil = selectBound({{"int", cat("I")}}, cat("D"));
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
+   HasValue(std::string("D")));
+}
+
 TEST_F(StencilTest, ExpressionOpNoParens) {
   StringRef Id = "id";
   testExpr(Id, "3;", expression(Id), "3");
@@ -674,6 +726,28 @@
   EXPECT_EQ(S->toString(), Expected);
 }
 
+TEST(StencilToStringTest, SelectBoundOp) {
+  auto S = selectBound({
+  {"int", cat("I")},
+  {"float", cat("F")},
+  });
+  StringRef Expected = R"repr(selectBound({{"int", "I"}, {"float", "F"}}))repr";
+  EXPECT_EQ(S->toString(), Expected);
+}
+
+TEST(StencilToStringTest, SelectBoundOpWithOneCase) {
+  auto S = selectBound({{"int", cat("I")}});
+  StringRef Expected = R"repr(selectBound({{"int", "I"}}))repr";
+  EXPECT_EQ(S->toString(), Expected);
+}
+
+TEST(StencilToStringTest, SelectBoundOpWithDefault) {
+  auto S = selectBound({{"int", cat("I")}, {"float", cat("F")}}, cat("D"));
+  StringRef Expected =
+  R"cc(selectBound({{"int", "I"}, {"float", "F"}}, "D"))cc";
+  EXPECT_EQ(S->toString(), Expected);
+}
+
 TEST(StencilToStringTest, RunOp) {
   auto F1 = [](const MatchResult ) { return "foo"; };
   auto S1 = run(F1);
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -27,14 +27,15 @@
 using namespace clang;
 using namespace transformer;
 
+using ast_matchers::BoundNodes;
 using ast_matchers::MatchFinder;
 using llvm::errc;
 using llvm::Error;
 using llvm::Expected;
 using llvm::StringError;
 
-static llvm::Expected
-getNode(const ast_matchers::BoundNodes , StringRef Id) {
+static llvm::Expected getNode(const BoundNodes ,
+StringRef Id) {
   auto  = Nodes.getMap();
   auto It = NodesMap.find(Id);
   if (It == NodesMap.end())
@@ -366,6 +367,73 @@
   }
 };
 
+class SelectBoundStencil : public clang::transformer::StencilInterface {
+  static bool containsNoNullStencils(
+  const std::vector> ) {
+for (const auto  : Cases)
+  if (S.second == nullptr)
+return false;
+return true;
+  }
+
+public:
+  SelectBoundStencil(std::vector> Cases,
+ Stencil Default)
+  : CaseStencils(std::move(Cases)), DefaultStencil(std::move(Default)) {
+assert(containsNoNullStencils(CaseStencils) &&
+   "cases of selectBound may not be null");
+  }
+  ~SelectBoundStencil() override{};
+
+  llvm::Error eval(const MatchFinder::MatchResult ,
+   

[PATCH] D111698: [clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

2021-10-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:124
 const auto  = SM.getSLocEntry(FID).getExpansion();
-add(Exp.getSpellingLoc());
+if (!SM.isWrittenInScratchSpace(Exp.getSpellingLoc()))
+  add(Exp.getSpellingLoc());

Add a comment



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:126
+  add(Exp.getSpellingLoc());
 add(Exp.getExpansionLocStart());
 add(Exp.getExpansionLocEnd());

I'm not 100% sure these should be unconditional. It's *probably* right, but...
Can you add a test of the form:

```
#define ab x
#define concat(x, y) x##y
int foo(a, b);
```

and verify that we get the expected set of file IDs when seeding with the 
location of the VarDecl `x`?



Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:170
 
+TEST(IncludeCleaner, ScratchBuffer) {
+  TestTU TU;

this doesn't seem to test very much, a comment should indicate that this is 
guarding against a crash.

Ideally we'd (also?) have a test that calls findReferencedFiles and actually 
assert which IDs we get, rather than run some big blob of code and hope not to 
crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111698

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


[libunwind] df3de76 - [libc++abi] Change LIBCXXABI_NO_TIMER to LIBCXXABI_USE_TIMER

2021-10-13 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-10-13T08:02:31-04:00
New Revision: df3de7647e034797ae3c965d6737bc0a4bc7a779

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

LOG: [libc++abi] Change LIBCXXABI_NO_TIMER to LIBCXXABI_USE_TIMER

Instead of always defining LIBCXXABI_NO_TIMER to run the tests, only
define LIBCXXABI_USE_TIMER when we want to enable the timer. This makes
the libc++abi testing configuration simpler.

As a fly-by fix, remove the unused LIBUNWIND_NO_TIMER macro from libunwind.

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

Added: 


Modified: 
libcxxabi/test/libcxxabi/test/config.py
libcxxabi/test/support/timer.h
libunwind/test/libunwind/test/config.py

Removed: 




diff  --git a/libcxxabi/test/libcxxabi/test/config.py 
b/libcxxabi/test/libcxxabi/test/config.py
index 843441fbebb8a..5855240a4b24c 100644
--- a/libcxxabi/test/libcxxabi/test/config.py
+++ b/libcxxabi/test/libcxxabi/test/config.py
@@ -44,7 +44,6 @@ def configure_features(self):
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += [
-'-DLIBCXXABI_NO_TIMER',
 '-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS',
 ]
 if self.get_lit_bool('enable_exceptions', True):

diff  --git a/libcxxabi/test/support/timer.h b/libcxxabi/test/support/timer.h
index 7109627f62ad0..27dc5f6a6d032 100644
--- a/libcxxabi/test/support/timer.h
+++ b/libcxxabi/test/support/timer.h
@@ -9,8 +9,8 @@
 #ifndef TIMER_H
 #define TIMER_H
 
-// Define LIBCXXABI_NO_TIMER to disable testing with a timer.
-#ifndef LIBCXXABI_NO_TIMER
+// Define LIBCXXABI_USE_TIMER to enable testing with a timer.
+#if defined(LIBCXXABI_USE_TIMER)
 
 #include 
 #include 
@@ -38,7 +38,7 @@ class timer
 TimePoint m_start;
 };
 
-#else /* LIBCXXABI_NO_TIMER */
+#else /* LIBCXXABI_USE_TIMER */
 
 class timer
 {
@@ -49,6 +49,6 @@ class timer
 ~timer() {}
 };
 
-#endif /* LIBCXXABI_NO_TIMER */
+#endif /* LIBCXXABI_USE_TIMER */
 
 #endif /* TIMER_H */

diff  --git a/libunwind/test/libunwind/test/config.py 
b/libunwind/test/libunwind/test/config.py
index 2aa3b82578371..87a810b49d8a5 100644
--- a/libunwind/test/libunwind/test/config.py
+++ b/libunwind/test/libunwind/test/config.py
@@ -39,7 +39,6 @@ def configure_features(self):
 self.config.available_features.add('libunwind-arm-ehabi')
 
 def configure_compile_flags(self):
-self.cxx.compile_flags += ['-DLIBUNWIND_NO_TIMER']
 # Stack unwinding tests need unwinding tables and these are not
 # generated by default on all Targets.
 self.cxx.compile_flags += ['-funwind-tables']



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


[PATCH] D111625: [clang-tidy] bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader

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

LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do so, 
but given the number of quality submissions you've had, I'm wondering if you'd 
like to obtain commit access of your own? 
(https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the 
details of what that entails.)


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

https://reviews.llvm.org/D111625

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


[clang] b8ff780 - [clang][NFC] Correct doc markup

2021-10-13 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-10-13T04:20:15-07:00
New Revision: b8ff780f205022d354b7604ebf1307e696804ac7

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

LOG: [clang][NFC] Correct doc markup

Spotted when implementing an extension.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 5fe47199dcd21..74f8f3dc35510 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3145,7 +3145,7 @@ the same purpose. The preprocessor symbols ``__SEG_FS`` 
and ``__SEG_GS``
 indicate their support.
 
 PowerPC Language Extensions
---
+---
 
 Set the Floating Point Rounding Mode
 



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


[PATCH] D111707: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

2021-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: MaskRay, rnk.
Herald added a subscriber: kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: clang.

This doesn't practically affect the code generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111707

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/pic.c


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 void MSVCToolChain::AddCudaIncludeArgs(const ArgList ,


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 

[PATCH] D111648: [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args.

2021-10-13 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfba563e92b64: [clangd] TargetFinder: Fix assert-crash on 
TemplateExpansion args. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111648

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -341,6 +341,15 @@
   EXPECT_DECLS("TemplateSpecializationTypeLoc", "template  class T");
   Flags.clear();
 
+  Code = R"cpp(
+  template class ...T>
+  class C {
+C<[[T...]]> foo;
+};
+  )cpp";
+  EXPECT_DECLS("TemplateArgumentLoc", {"template  class ...T"});
+  Flags.clear();
+
   Code = R"cpp(
 struct S{};
 S X;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -507,7 +507,8 @@
 // DeclRefExpr).
 if (Arg.getKind() == TemplateArgument::Template ||
 Arg.getKind() == TemplateArgument::TemplateExpansion) {
-  if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
+  if (TemplateDecl *TD =
+  Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
 report(TD, Flags);
   }
 }


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -341,6 +341,15 @@
   EXPECT_DECLS("TemplateSpecializationTypeLoc", "template  class T");
   Flags.clear();
 
+  Code = R"cpp(
+  template class ...T>
+  class C {
+C<[[T...]]> foo;
+};
+  )cpp";
+  EXPECT_DECLS("TemplateArgumentLoc", {"template  class ...T"});
+  Flags.clear();
+
   Code = R"cpp(
 struct S{};
 S X;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -507,7 +507,8 @@
 // DeclRefExpr).
 if (Arg.getKind() == TemplateArgument::Template ||
 Arg.getKind() == TemplateArgument::TemplateExpansion) {
-  if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
+  if (TemplateDecl *TD =
+  Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
 report(TD, Flags);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] fba563e - [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args.

2021-10-13 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-10-13T13:15:36+02:00
New Revision: fba563e92b6412f49e7e49299d3d27f04f2e1400

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

LOG: [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args.

Previously we would call getAsTemplate() when kind == TemplateExpansion,
which triggers an assertion. The call is now replaced with
getAsTemplateOrTemplatePattern(), which is exactly the same as
getAsTemplate(), except it allows calls when kind == TemplateExpansion.

No change in behavior for no-assert builds.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 8419043f4462a..82e4dfeccf43d 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -507,7 +507,8 @@ struct TargetFinder {
 // DeclRefExpr).
 if (Arg.getKind() == TemplateArgument::Template ||
 Arg.getKind() == TemplateArgument::TemplateExpansion) {
-  if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
+  if (TemplateDecl *TD =
+  Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
 report(TD, Flags);
   }
 }

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 14cb15a7644b0..9620db9838ae2 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -341,6 +341,15 @@ TEST_F(TargetDeclTest, Types) {
   EXPECT_DECLS("TemplateSpecializationTypeLoc", "template  class T");
   Flags.clear();
 
+  Code = R"cpp(
+  template class ...T>
+  class C {
+C<[[T...]]> foo;
+};
+  )cpp";
+  EXPECT_DECLS("TemplateArgumentLoc", {"template  class ...T"});
+  Flags.clear();
+
   Code = R"cpp(
 struct S{};
 S X;



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-10-13 Thread Det via Phabricator via cfe-commits
Det87 added a comment.

@catskul yeah, are we waiting for a response, or is this good to go?

Tagging everybody who might know something. @seesemichaelj @djasper @jakar 
@blandcr @MyDeveloperDay @bbassi


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

https://reviews.llvm.org/D33029

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


[clang] d45526e - [doc][clang] correct version for p0388 implementation

2021-10-13 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-10-13T04:12:07-07:00
New Revision: d45526e6c34a82376f05b702a2969b4c4970cb1c

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

LOG: [doc][clang] correct version for p0388 implementation

The p0388 patch series took so long, the clang version was incorrect,
and I failed to realize that.

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 4b628e1f62fe2..9c3688d1dd6c3 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1238,7 +1238,7 @@ C++20 implementation status
 
   Permit conversions to arrays of unknown bound
   https://wg21.link/p0388r4;>P0388R4
-  Clang 13
+  Clang 14
 
 
   constinit



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


[PATCH] D102650: Old work on P0388. For reference in D102645. Not for review / commit.

2021-10-13 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan abandoned this revision.
urnathan added a comment.

Implemented as part of D102645 , thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102650

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


[PATCH] D102650: Old work on P0388. For reference in D102645. Not for review / commit.

2021-10-13 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan commandeered this revision.
urnathan edited reviewers, added: rsmith; removed: urnathan.
urnathan added a comment.

Taking control to close it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102650

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


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-10-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D109144#3050945 , @linjamaki wrote:

>> What I have in mind is to continue using SPIR target for now (until SPIR-V 
>> back-end is added).
>
>> For instance, SYCL compiler emits code for SPIR target and code format is 
>> configured via flag.
>>
>> `-emit-llvm` changes output file format for regular C++ compilation flow:
>>
>>   clang++ a.cpp -c -o a.o  # object format by default 
>>   clang++ a.cpp -c -emit-llvm -o a.bc  # LLVM IR format with 
>> `-emit-llvm`
>>
>> Similar approach for HIP device compilation flow:
>>
>>   clang++ -target spir -x hip a.cpp -cuda-device-only -o a.spv   
>>   # SPIR-V format by default
>>   clang++ -target spir -x hip a.cpp -cuda-device-only -emit-llvm -o a.bc 
>>   # LLVM IR (aka SPIR) format with `-emit-llvm` if needed
>>
>> I think this was proposed in RFC. @linjamaki, am I right?
>
> In the RFC we proposed a HIP compilation flow for producing and **embedding** 
> SPIR-V binary into the host executable. What was not stated in the RFC 
> clearly is that the process is supposed to be carried out without the need 
> for clients to issue explicit commands for producing SPIR-V binaries and then 
> to link them into the final executable separately. D110622 
>  has test cases as examples for this.

Can you explain what does this mean

> without the need for clients to issue explicit commands for producing SPIR-V 
> binaries

? In the tests I can see the following `--offload=spirv64` which does feel like 
it is specified explicitly that the target is SPIR-V...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


  1   2   >