[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-15 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

> The fact that we're running the optimization pipeline in these tests might be 
> to blame. Might also be that riscv_vector.h is currently about 71000 lines 
> which probably isn't quick to parse.

I found removing all overloaded api definition functions in `riscv_vector.h` 
could save the time more than 100%  (run llvm-lit with one file `vloxei.c`, 
cost `3.57s`-> `1.56s`) 
I'm not sure how to improve the `riscv_vector.h`, is it possible to generate a 
PCH for `riscv_vector.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-15 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

In D99741#2690156 , @craig.topper 
wrote:

> In D99741#2690124 , @thakis wrote:
>
>> One of the ten commits that landed here 
>> (https://github.com/llvm/llvm-project/compare/a3bfddbb6a27...59d5b8c27b43), 
>> this being one of them, slowed down check-clang by over 20%: 
>> https://bugs.llvm.org/show_bug.cgi?id=49962
>>
>> Since recovering test runtime regressions is very difficult, it's probably a 
>> good idea to revert this first and then reland in smaller chunks to see 
>> which of the commits causes the problem (?)
>
> The fact that we're running the optimization pipeline in these tests might be 
> to blame. Might also be that riscv_vector.h is currently about 71000 lines 
> which probably isn't quick to parse.

I hacked the `RISCVVEmitter.cpp` file to emit a `riscv_vector_testing.h` that 
wraps all the definitions with macros like `RVV_TEST_vadd` and 
`RVV_TEST_vadd_mask` (I used the `IRName` as it was easier for the experiment).

The testing header looks like this

  #if defined(RVV_TEST_vadd)
   
  __rvv_overloaded vint8m1_t vadd(vint8m1_t op0, vint8m1_t op1, size_t op2){
   
return vadd_vv_i8m1(op0, op1, op2); 
   
  } 
   
  #endif // RVV_TEST_vadd   
   

   
  #if defined(RVV_TEST_vadd_mask)   
   
  __rvv_overloaded vint8m1_t vadd(vbool8_t op0, vint8m1_t op1, vint8m1_t op2, 
vint8m1_t op3, size_t op4){
return vadd_vv_i8m1_m(op0, op1, op2, op3, op4); 
   
  } 
   
  #endif // RVV_TEST_vadd_mask  
   

In a release build (in a machine that is not very fast) looks like this:

  $ ./bin/llvm-lit --time-test -sv 
../llvm-src/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c 
../llvm-src/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd_fast.c 
  llvm-lit: 
/home/rferrer/fio/upstream/llvm-src/llvm/utils/lit/lit/llvm/config.py:428: 
note: using clang: /home/rferrer/fio/upstream/llvm-build-release/bin/clang
  Slowest Tests:
  --
  8.91s: Clang :: CodeGen/RISCV/rvv-intrinsics/vadd.c
  2.11s: Clang :: CodeGen/RISCV/rvv-intrinsics/vadd_fast.c

Where `vadd.c` is the current file and `vadd_fast.c` is the same as vadd.c with 
this change

  --- vadd.c2021-04-15 06:51:30.554996630 +
  +++ vadd_fast.c   2021-04-15 07:00:38.684074973 +
  @@ -8,7 +8,9 @@
   // RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck 
--check-prefix=ASM --allow-empty %s
   
   // ASM-NOT: warning
  -#include 
  +#define RVV_TEST_vadd
  +#define RVV_TEST_vadd_mask
  +#include 
   
   // CHECK-RV32-LABEL: @test_vadd_vv_i8mf8(
   // CHECK-RV32-NEXT:  entry:

This seems to suggest that making sure the tested header contains only the 
necessary will speed the testing up significantly.

We would want to make sure `riscv_vector.h` and `riscv_vector_testing.h` are 
equivalent when all the macros are enabled. I guess such a test is feasible if 
we preprocess the testing header with all the `RVV_TEST_nnn` macros enabled and 
then we do some form of textual comparison (which will likely have to ignore 
whitespace). This way we can test `riscv_vector.h` using its proxy 
`riscv_vector_testing.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-15 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

I've left a PoC of my approach here https://reviews.llvm.org/D100529 in case we 
can use that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D100530: [AST][Introspection] Add a check to detect if introspection is supported.

2021-04-15 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: steveire.
Herald added a subscriber: mgorny.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This could probably be made into a compile time constant, but that would 
involve generating a second inc file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100530

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -46,6 +46,8 @@
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
 TEST(Introspection, SourceLocations_Stmt) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST = buildASTFromCode("void foo() {} void bar() { foo(); }", "foo.cpp",
   std::make_shared());
   auto &Ctx = AST->getASTContext();
@@ -62,11 +64,6 @@
 
   auto Result = NodeIntrospection::GetLocations(FooCall);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty())
-  {
-return;
-  }
-
   auto ExpectedLocations =
 FormatExpected(Result.LocationAccessors);
 
@@ -84,6 +81,8 @@
 }
 
 TEST(Introspection, SourceLocations_Decl) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 namespace ns1 {
@@ -118,10 +117,6 @@
 
   auto Result = NodeIntrospection::GetLocations(MethodDecl);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -148,6 +143,8 @@
 }
 
 TEST(Introspection, SourceLocations_NNS) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 namespace ns
@@ -171,10 +168,6 @@
 
   auto Result = NodeIntrospection::GetLocations(NNS);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -194,6 +187,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_Type) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -219,10 +214,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -236,6 +227,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_Decl) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -258,10 +251,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -275,6 +264,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_Nullptr) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -297,10 +288,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -314,6 +301,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_Integral) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -335,10 +324,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -352,6 +337,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_Template) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST =
   buildASTFromCode(R"cpp(
 template class A;
@@ -374,10 +361,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-return;
-  }
-
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
@@ -393,6 +376,8 @@
 }
 
 TEST(Introspection, SourceLocations_TA_TemplateExpansion) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
   auto AST = buildASTFromCodeWithArgs(
   R"cpp(
 template class ...> class B { };
@@ -414,10 +399,6 @@
 
   auto Result = NodeIntrospection::GetLocations(TA);
 
-  if (Result.LocationAcces

[PATCH] D100531: [clang][deps] Simplify function discovering .pcm and .modulemap files

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

This patch simplifies (and renames) the `appendCommonModuleArguments` function.

It no longer tries to construct the command line for explicitly building 
modules. Instead, it only performs the DFS traversal of modular dependencies 
and queries the callbacks to collect paths to `.pcm` and `.modulemap` files.

This makes it more flexible and usable in two contexts:

- Generating additional command line arguments for the main TU in modular 
build. The `std::vector` output parameters can be used to manually 
generate appropriate command line flags.
- Generate full command line for a module. The output parameters can be the 
corresponding parts of `CompilerInvocation`. (In a follow-up patch.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100531

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp

Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -142,8 +142,8 @@
 // CHECK-NEXT: "-fno-implicit-modules",
 // CHECK-NEXT: "-fno-implicit-module-maps",
 // CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
-// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header1-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "file-deps": [
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -25,17 +25,26 @@
   // TODO: Build full command line. That also means capturing the original
   //   command line into NonPathCommandLine.
 
-  dependencies::detail::appendCommonModuleArguments(
-  ClangModuleDeps, LookupPCMPath, LookupModuleDeps, Ret);
+  Ret.push_back("-fno-implicit-modules");
+  Ret.push_back("-fno-implicit-module-maps");
+
+  std::vector PCMPaths;
+  std::vector ModMapPaths;
+  dependencies::detail::collectPCMAndModuleMapPaths(
+  ClangModuleDeps, LookupPCMPath, LookupModuleDeps, PCMPaths, ModMapPaths);
+  for (const std::string &PCMPath : PCMPaths)
+Ret.push_back("-fmodule-file=" + PCMPath);
+  for (const std::string &ModMapPath : ModMapPaths)
+Ret.push_back("-fmodule-map-file=" + ModMapPath);
 
   return Ret;
 }
 
-void dependencies::detail::appendCommonModuleArguments(
+void dependencies::detail::collectPCMAndModuleMapPaths(
 llvm::ArrayRef Modules,
 std::function LookupPCMPath,
 std::function LookupModuleDeps,
-std::vector &Result) {
+std::vector &PCMPaths, std::vector &ModMapPaths) {
   llvm::StringSet<> AlreadyAdded;
 
   std::function)> AddArgs =
@@ -46,15 +55,12 @@
   const ModuleDeps &M = LookupModuleDeps(MID);
   // Depth first traversal.
   AddArgs(M.ClangModuleDeps);
-  Result.push_back(("-fmodule-file=" + LookupPCMPath(MID)).str());
-  if (!M.ClangModuleMapFile.empty()) {
-Result.push_back("-fmodule-map-file=" + M.ClangModuleMapFile);
-  }
+  PCMPaths.push_back(LookupPCMPath(MID).str());
+  if (!M.ClangModuleMapFile.empty())
+ModMapPaths.push_back(M.ClangModuleMapFile);
 }
   };
 
-  Result.push_back("-fno-implicit-modules");
-  Result.push_back("-fno-implicit-module-maps");
   AddArgs(Modules);
 }
 
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -18,8 +18,17 @@
 std::function LookupModuleDeps) const {
   std::vector Ret = AdditionalNonPathCommandLine;
 
-  dependencies::detail::appendCommonModuleArguments(
-  ClangModuleDeps, LookupPCMPath, LookupModuleDeps, Ret);
+  Ret.push_back("-fno-implicit-modules");
+  Ret.push_back("-fno-implicit-module-maps");
+
+  std::vector PCMPaths;
+  std::vector ModMapPaths;
+  dependencies::detail::collectPCMAndModuleMapPaths(
+  ClangModuleDeps, LookupPCMPath, LookupModuleDeps, PCMPaths, ModMapPaths);
+  for (const std::string &PCMPath : PCMPaths)
+Ret.

[PATCH] D100484: add test case for ignoring -flto=auto and -flto=jobserver

2021-04-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.

LGTM, thanks!


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

https://reviews.llvm.org/D100484

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


[PATCH] D99501: ignore -flto= options recognized by GCC

2021-04-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D99501#2689090 , @tejohnson wrote:

> Just approved the test case patch. Sorry I missed the lack of test on this!

Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99501

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


[clang] ee570e2 - [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.

2021-04-15 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-04-15T11:02:14+03:00
New Revision: ee570e215353625a867fcbfd8c3089e9e0f8660d

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

LOG: [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. 
NFC.

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

Added: 


Modified: 
clang/test/CodeGen/ms_abi_aarch64.c

Removed: 




diff  --git a/clang/test/CodeGen/ms_abi_aarch64.c 
b/clang/test/CodeGen/ms_abi_aarch64.c
index 52685618176b..8526ce934ef5 100644
--- a/clang/test/CodeGen/ms_abi_aarch64.c
+++ b/clang/test/CodeGen/ms_abi_aarch64.c
@@ -18,8 +18,7 @@ void f3(void) {
   // LINUX: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
-  // LINUX: call void @f2()
-  // WIN64: call void @f2()
+  // COMMON: call void @f2()
 }
 // LINUX: declare win64cc void @f1()
 // LINUX: declare void @f2()
@@ -32,28 +31,19 @@ void __attribute__((ms_abi)) f4(int a, ...) {
   // WIN64-LABEL: define dso_local void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);
-  // LINUX: %[[AP:.*]] = alloca i8*
-  // LINUX: call void @llvm.va_start
-  // WIN64: %[[AP:.*]] = alloca i8*
-  // WIN64: call void @llvm.va_start
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
   int b = __builtin_va_arg(ap, int);
-  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
-  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32*
   __builtin_ms_va_list ap2;
   __builtin_ms_va_copy(ap2, ap);
-  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
-  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
   __builtin_ms_va_end(ap);
-  // LINUX: call void @llvm.va_end
-  // WIN64: call void @llvm.va_end
+  // COMMON: call void @llvm.va_end
 }
 
 void __attribute__((ms_abi)) f4_2(int a, ...) {



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


[PATCH] D100468: [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.

2021-04-15 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee570e215353: [clang] [test] Share patterns in 
CodeGen/ms_abi_aarch64.c between cases. NFC. (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100468

Files:
  clang/test/CodeGen/ms_abi_aarch64.c


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -18,8 +18,7 @@
   // LINUX: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
-  // LINUX: call void @f2()
-  // WIN64: call void @f2()
+  // COMMON: call void @f2()
 }
 // LINUX: declare win64cc void @f1()
 // LINUX: declare void @f2()
@@ -32,28 +31,19 @@
   // WIN64-LABEL: define dso_local void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);
-  // LINUX: %[[AP:.*]] = alloca i8*
-  // LINUX: call void @llvm.va_start
-  // WIN64: %[[AP:.*]] = alloca i8*
-  // WIN64: call void @llvm.va_start
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
   int b = __builtin_va_arg(ap, int);
-  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
-  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], 
i64 8
-  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* 
%[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32*
   __builtin_ms_va_list ap2;
   __builtin_ms_va_copy(ap2, ap);
-  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
-  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
   __builtin_ms_va_end(ap);
-  // LINUX: call void @llvm.va_end
-  // WIN64: call void @llvm.va_end
+  // COMMON: call void @llvm.va_end
 }
 
 void __attribute__((ms_abi)) f4_2(int a, ...) {


Index: clang/test/CodeGen/ms_abi_aarch64.c
===
--- clang/test/CodeGen/ms_abi_aarch64.c
+++ clang/test/CodeGen/ms_abi_aarch64.c
@@ -18,8 +18,7 @@
   // LINUX: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
-  // LINUX: call void @f2()
-  // WIN64: call void @f2()
+  // COMMON: call void @f2()
 }
 // LINUX: declare win64cc void @f1()
 // LINUX: declare void @f2()
@@ -32,28 +31,19 @@
   // WIN64-LABEL: define dso_local void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);
-  // LINUX: %[[AP:.*]] = alloca i8*
-  // LINUX: call void @llvm.va_start
-  // WIN64: %[[AP:.*]] = alloca i8*
-  // WIN64: call void @llvm.va_start
+  // COMMON: %[[AP:.*]] = alloca i8*
+  // COMMON: call void @llvm.va_start
   int b = __builtin_va_arg(ap, int);
-  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
-  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
-  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
-  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
-  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32*
   __builtin_ms_va_list ap2;
   __builtin_ms_va_copy(ap2, ap);
-  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
-  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
-  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
   __builtin_ms_va_end(ap);
-  // LINUX: call void @llvm.va_end
-  // WIN64: call void @llvm.va_end
+  // COMMON: call void @llvm.va_end
 }
 
 void __attribute__((ms_abi)) f4_2(int a, ...) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91054: [Clang][OpenMP] Frontend work for sections - D89671

2021-04-15 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 337654.
AMDChirag added a comment.
Herald added a subscriber: jfb.

Fixed cancel construct and applied updates to its test cases

The test cases are updated so that the IR generated with and without IRBuilder 
are considered as they are different.

The cancel codegenerator with IRBuilder causes the IR to be created in the form:

  ...
  %29 = call i32 @__kmpc_cancel(%struct.ident_t* @1, i32 
%omp_global_thread_num9, i32 3)
  %30 = icmp eq i32 %29, 0
  ...

Whereas, without IRBuilder, the IR created is in the form:

  ...
  %20 = call i32 @__kmpc_cancel(%struct.ident_t* @1, i32 %0, i32 3)
  %21 = icmp ne i32 %20, 0
  ...

In essence, the output is logically same, but semantically different, hence the 
requirement of updating test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91054

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/cancel_codegen.cpp

Index: clang/test/OpenMP/cancel_codegen.cpp
===
--- clang/test/OpenMP/cancel_codegen.cpp
+++ clang/test/OpenMP/cancel_codegen.cpp
@@ -1,28 +1,27 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,CHECK
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,CHECK
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=OMP
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t.0 %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t.0 -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefix=OMP
 
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,IRBUILDER
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=OMP_IRB
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t.1 %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -std=c++11 -include-pch %t.1 -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefix=OMP_IRB
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=OMP_SIMD
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t.2 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t.2 -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefix=OMP_SIMD
 
-// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,CHECK
-// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,CHECK
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=OMP
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit

[PATCH] D100533: [clang][deps] Always generate full command lines

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

This patch removes the `-full-command-line` option from `clang-scan-deps`. It's 
only used with `-format=experimental-full`, where omitting the command lines 
doesn't make much sense. There are no tests without `-full-command-line`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100533

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

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -131,11 +131,6 @@
 llvm::cl::init(ScanningOutputFormat::Make),
 llvm::cl::cat(DependencyScannerCategory));
 
-static llvm::cl::opt FullCommandLine(
-"full-command-line",
-llvm::cl::desc("Include the full command lines to use to build modules"),
-llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
-
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -258,12 +253,11 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-if (FullCommandLine)
-  ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
-  [&](ModuleID MID) { return lookupPCMPath(MID); },
-  [&](ModuleID MID) -> const ModuleDeps & {
-return lookupModuleDeps(MID);
-  });
+ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
+[&](ModuleID MID) { return lookupPCMPath(MID); },
+[&](ModuleID MID) -> const ModuleDeps & {
+  return lookupModuleDeps(MID);
+});
 
 Inputs.push_back(std::move(ID));
   }
@@ -294,14 +288,11 @@
   {"file-deps", toJSONSorted(MD.FileDeps)},
   {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)},
   {"clang-modulemap-file", MD.ClangModuleMapFile},
-  {"command-line",
-   FullCommandLine
-   ? MD.getFullCommandLine(
- [&](ModuleID MID) { return lookupPCMPath(MID); },
- [&](ModuleID MID) -> const ModuleDeps & {
-   return lookupModuleDeps(MID);
- })
-   : MD.NonPathCommandLine},
+  {"command-line", MD.getFullCommandLine(
+   [&](ModuleID MID) { return lookupPCMPath(MID); },
+   [&](ModuleID MID) -> const ModuleDeps & {
+ return lookupModuleDeps(MID);
+   })},
   };
   OutModules.push_back(std::move(O));
 }
Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -10,8 +10,8 @@
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
 //
 // RUN: echo %t.dir > %t.result
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -full-command-line \
-// RUN:   -mode preprocess-minimized-sources -format experimental-full >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources >> %t.result
 // RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
 
 // FIXME: Backslash issues.
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -20,13 +20,13 @@
 std::vector ModuleDeps::getFullCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = NonPathCommandLine;
-
   // TODO: Build full command line. That also means capturing the original
   //   command line into NonPathCommandLine.
 
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -67,12 +67,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial comman

[PATCH] D100534: [clang][deps] Generate the full command-line for modules

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

This patch uses the new `CompilerInvocation::generateCC1CommandLine` to 
generate the full canonical command line for modular dependencies, instead of 
only appending additional arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100534

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp

Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -31,11 +31,11 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps",
-// CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
-// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
-// CHECK-NEXT:   ],
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
+// CHECK:  "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
@@ -47,9 +47,9 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps"
-// CHECK-NEXT:   ],
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H2:[A-Z0-9]+]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
@@ -61,9 +61,9 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps"
-// CHECK-NEXT:   ],
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h",
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -12,32 +12,60 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "llvm/Support/StringSaver.h"
 
 using namespace clang;
 using namespace tooling;
 using namespace dependencies;
 
+static CompilerInvocation
+getFullCommandLineCompilerInvocation(const ModuleDeps &Deps) {
+  CompilerInvocation CI = Deps.Invocation;
+
+  // Remove options incompatible with explicit module build.
+  CI.getFrontendOpts().Inputs.clear();
+  CI.getFrontendOpts().OutputFile.clear();
+
+  CI.getFrontendOpts().ProgramAction = frontend::GenerateModule;
+  CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
+  CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
+
+  CI.getLangOpts()->ImplicitModules = false;
+  CI.getHeaderSearchOpts().ImplicitModuleMaps = false;
+
+  return CI;
+}
+
+static std::vector
+serializeCompilerInvocation(CompilerInvocation &CI) {
+  // Set up string allocator.
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Strings(Alloc);
+  auto SA = [&Strings](const Twine &Arg) { return Strings.save(Arg).data(); };
+  SmallVector Args;
+
+  // Synthesize full command line from the CompilerInvocation.
+  CI.generateCC1CommandLine(Args, SA);
+
+  // Convert arguments to the return type.
+  std::vector Ret;
+  Ret.reserve(Args.size());
+  for (const char *Arg : Args)
+Ret.emplace_back(Arg);
+
+  return Ret;
+}
+
 std::vector ModuleDeps::getFullCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  // TODO: Build full command line. That also means capturing the original
-  //   command line into NonPathCommandLine.
-
-  std::vector Ret{
-  

[PATCH] D100536: [clang][deps] NFC: Remove unused FullDependencies member

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

This patch removes the `FullDependencies::AdditionalNonPathCommandLine` member, 
as it's value-initialized and never mutated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100536

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


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -16,10 +16,10 @@
 std::vector FullDependencies::getAdditionalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = AdditionalNonPathCommandLine;
-
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -38,13 +38,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
   /// Gets the full addtional command line suitable for appending to the
   /// original command line to pass to clang.
   ///


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -16,10 +16,10 @@
 std::vector FullDependencies::getAdditionalCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  std::vector Ret = AdditionalNonPathCommandLine;
-
-  Ret.push_back("-fno-implicit-modules");
-  Ret.push_back("-fno-implicit-module-maps");
+  std::vector Ret{
+  "-fno-implicit-modules",
+  "-fno-implicit-module-maps",
+  };
 
   std::vector PCMPaths;
   std::vector ModMapPaths;
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -38,13 +38,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
   /// Gets the full addtional command line suitable for appending to the
   /// original command line to pass to clang.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06eff02 - [clang][deps] NFC: Improve documentation

2021-04-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-15T10:31:09+02:00
New Revision: 06eff02ba18b02bff3a8d5759cc4a5ee043e4112

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

LOG: [clang][deps] NFC: Improve documentation

Fix typos and simplify wording

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index b4fa27f531e32..09c385783c52c 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -45,14 +45,14 @@ struct FullDependencies {
   /// appending to the original command line to pass to clang.
   std::vector AdditionalNonPathCommandLine;
 
-  /// Gets the full addtional command line suitable for appending to the
-  /// original command line to pass to clang.
+  /// Get additional arguments suitable for appending to the original Clang
+  /// command line.
   ///
-  /// \param LookupPCMPath this function is called to fill in `-fmodule-file=`
+  /// \param LookupPCMPath This function is called to fill in `-fmodule-file=`
   ///  flags and for the `-o` flag. It needs to return a
   ///  path for where the PCM for the given module is to
   ///  be located.
-  /// \param LookupModuleDeps this fucntion is called to collect the full
+  /// \param LookupModuleDeps This function is called to collect the full
   /// transitive set of dependencies for this
   /// compilation.
   std::vector getAdditionalCommandLine(
@@ -82,15 +82,14 @@ class DependencyScanningTool {
   getDependencyFile(const tooling::CompilationDatabase &Compilations,
 StringRef CWD);
 
-  /// Collect the full module depenedency graph for the input, ignoring any
+  /// Collect the full module dependency graph for the input, ignoring any
   /// modules which have already been seen.
   ///
-  /// \param AlreadySeen this is used to not report modules that have 
previously
-  ///been reported. Use the same `llvm::StringSet<>` for 
all
-  ///calls to `getFullDependencies` for a single
-  ///`DependencyScanningTool` for a single build. Use a
-  ///
diff erent one for 
diff erent tools, and clear it between
-  ///builds.
+  /// \param AlreadySeen This stores modules which have previously been
+  ///reported. Use the same instance for all calls to this
+  ///function for a single \c DependencyScanningTool in a
+  ///single build. Use a 
diff erent one for 
diff erent tools,
+  ///and clear it between builds.
   ///
   /// \returns a \c StringError with the diagnostic output if clang errors
   /// occurred, \c FullDependencies otherwise.



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


[PATCH] D100209: [OpenCL] Do not add builtins with unavailable types

2021-04-15 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 337663.
svenvh added a comment.

Adding some more comments / explanation.


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

https://reviews.llvm.org/D100209

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -727,34 +727,45 @@
 
   // Switch cases for generic types.
   for (const auto *GenType : Records.getAllDerivedDefinitions("GenericType")) {
-OS << "case OCLT_" << GenType->getValueAsString("Name") << ":\n";
-OS << "  QT.append({";
+OS << "case OCLT_" << GenType->getValueAsString("Name") << ": {\n";
 
 // Build the Cartesian product of (vector sizes) x (types).  Only insert
 // the plain scalar types for now; other type information such as vector
 // size and type qualifiers will be added after the switch statement.
-for (unsigned I = 0; I < GenType->getValueAsDef("VectorList")
- ->getValueAsListOfInts("List")
- .size();
- I++) {
-  for (const auto *T :
-   GenType->getValueAsDef("TypeList")->getValueAsListOfDefs("List")) {
-OS << T->getValueAsDef("QTExpr")->getValueAsString("TypeExpr") << ", ";
+std::vector BaseTypes =
+GenType->getValueAsDef("TypeList")->getValueAsListOfDefs("List");
+
+// Collect all QualTypes for a single vector size into TypeList.
+OS << "  SmallVector TypeList;\n";
+for (const auto *T : BaseTypes) {
+  StringRef Ext =
+  T->getValueAsDef("Extension")->getValueAsString("ExtName");
+  if (!Ext.empty()) {
+OS << "  if (S.getPreprocessor().isMacroDefined(\"" << Ext
+   << "\")) {\n  ";
+  }
+  OS << "  TypeList.push_back("
+ << T->getValueAsDef("QTExpr")->getValueAsString("TypeExpr") << ");\n";
+  if (!Ext.empty()) {
+OS << "  }\n";
   }
 }
-OS << "});\n";
-// GenTypeNumTypes is the number of types in the GenType
-// (e.g. float/double/half).
-OS << "  GenTypeNumTypes = "
-   << GenType->getValueAsDef("TypeList")->getValueAsListOfDefs("List")
-  .size()
-   << ";\n";
+OS << "  GenTypeNumTypes = TypeList.size();\n";
+
+// Duplicate the TypeList for every vector size.
+std::vector VectorList =
+GenType->getValueAsDef("VectorList")->getValueAsListOfInts("List");
+OS << "  QT.reserve(" << VectorList.size() * BaseTypes.size() << ");\n"
+   << "  for (unsigned I = 0; I < " << VectorList.size() << "; I++) {\n"
+   << "QT.append(TypeList);\n"
+   << "  }\n";
+
 // GenVectorSizes is the list of vector sizes for this GenType.
-// QT contains GenTypeNumTypes * #GenVectorSizes elements.
 OS << "  GenVectorSizes = List"
<< GenType->getValueAsDef("VectorList")->getValueAsString("Name")
-   << ";\n";
-OS << "  break;\n";
+   << ";\n"
+   << "  break;\n"
+   << "}\n";
   }
 
   // Switch cases for non generic, non image types (int, int4, float, ...).
@@ -777,9 +788,20 @@
 if (QT->getValueAsBit("IsAbstract") == 1)
   continue;
 // Emit the cases for non generic, non image types.
-OS << "case OCLT_" << T->getValueAsString("Name") << ":\n"
-   << "  QT.push_back(" << QT->getValueAsString("TypeExpr") << ");\n"
-   << "  break;\n";
+OS << "case OCLT_" << T->getValueAsString("Name") << ":\n";
+
+StringRef Ext = T->getValueAsDef("Extension")->getValueAsString("ExtName");
+// If this type depends on an extension, ensure the extension macro is
+// defined.
+if (!Ext.empty()) {
+  OS << "  if (S.getPreprocessor().isMacroDefined(\"" << Ext
+ << "\")) {\n  ";
+}
+OS << "  QT.push_back(" << QT->getValueAsString("TypeExpr") << ");\n";
+if (!Ext.empty()) {
+  OS << "  }\n";
+}
+OS << "  break;\n";
   }
 
   // End of switch statement.
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finc

[PATCH] D100209: [OpenCL] Do not add builtins with unavailable types

2021-04-15 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/lib/Sema/OpenCLBuiltins.td:54
+// Extension associated to a type.
+class TypeExtension : AbstractExtension<_Ext>;
+

Anastasia wrote:
> svenvh wrote:
> > Anastasia wrote:
> > > I am trying to understand why would we need a special abstraction for the 
> > > type? Would it not be easier if we just guard the BIFs by the extensions 
> > > that allow the use of the type? 
> > > 
> > > We would need to separate the definitions of course but this can be more 
> > > helpful in order to understand what overloads are available conditionally?
> > Yes, it is possible to achieve the same with the current 
> > `FunctionExtension` class.
> > 
> > However, that would require a lot of duplication in the Builtin 
> > descriptions, as for example many math builtins have overloads for `half` 
> > and `double` that will have to be conditionalized.  The purpose of 
> > `TypeExtension` is precisely to avoid separating and duplicating the 
> > definitions.  For example, `acos` is currently more or less defined as:
> > 
> > ```
> > def FGenTypeN : GenericType<"FGenTypeN", TypeList<[Float, Double, Half]>, 
> > VecAndScalar>;
> > def : Builtin<"acos", [FGenTypeN, FGenTypeN], Attr.Const>;
> > ```
> > with `double` and `half` conditionalization conveniently handled in a 
> > single place through a `TypeExtension`.
> > 
> > If we would only use `FunctionExtension`s, the definition would become more 
> > like the following:
> > ```
> > def FGenTypeN : GenericType<"FGenTypeN", TypeList<[Float]>, VecAndScalar>;
> > def : Builtin<"acos", [FGenTypeN, FGenTypeN], Attr.Const>;
> > 
> > let Extension = Fp64 in {
> >   def DGenTypeN : GenericType<"DGenTypeN", TypeList<[Double]>, 
> > VecAndScalar>;
> >   def : Builtin<"acos", [DGenTypeN, DGenTypeN], Attr.Const>;
> > }
> > 
> > let Extension = Fp16 in {
> >   def HGenTypeN : GenericType<"HGenTypeN", TypeList<[Half]>, VecAndScalar>;
> >   def : Builtin<"acos", [HGenTypeN, HGenTypeN], Attr.Const>;
> > }
> > ```
> > 
> > I personally don't think there is value in adding these explicit guards for 
> > every conditional builtin, as the duplication makes the definitions harder 
> > to maintain.  In addition, I expect it would also increase the size of the 
> > generated tables, as the `GenericType`s have to be split up (though I have 
> > not measured this).
> Ok I see. Yeah it looks quite a lot of duplication indeed for some types. 
> However, this patch provides extra flexibility and doesn't enforce to use the 
> new approach evrywhere so I think it is very reasonable.
> 
> Could you just provide a bit more documentation and especially the difference 
> to the other approach here?
> 
> Do you think it is work extending the online documentation for that too?
> Do you think it is work extending the online documentation for that too?

Yes we should, but it is perhaps worth waiting until we have clarified the 
design wrt feature optionality.


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

https://reviews.llvm.org/D100209

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.

I've built this, checked it behaves as expected, checked clang does something 
reasonable when the executable is missing. All looks good to me, explicitly 
accepting.

We may need an internal call with Greg to work out how to unblock this given 
his objections above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S updated this revision to Diff 337665.
Max_S added a comment.

Moved the test to their own section and fixed the formatting issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,47 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsArrays) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1254,15 +1254,14 @@
   if (PreviousLine && RootToken.isAccessSpecifier()) {
 switch (Style.EmptyLineBeforeAccessModifier) {
 case FormatStyle::ELBAMS_Never:
-  if (RootToken.NewlinesBefore > 1)
+  if (Newlines > 1)
 Newlines = 1;
   break;
 case FormatStyle::ELBAMS_Leave:
   Newlines = std::max(RootToken.NewlinesBefore, 1u);
   break;
 case FormatStyle::ELBAMS_LogicalBlock:
-  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
-  RootToken.NewlinesBefore <= 1)
+  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) && Newlines <= 
1)
 Newlines = 2;
   break;
 case FormatStyle::ELBAMS_Always: {
@@ -1271,8 +1270,7 @@
 previousToken = PreviousLine->Last->getPreviousNonComment();
   else
 previousToken = PreviousLine->Last;
-  if ((!previousToken || !previousToken->is(tok::l_brace)) &&
-  RootToken.NewlinesBefore <= 1)
+  if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 
1)
 Newlines = 2;
 } break;
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,47 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsArrays) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp

[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

Just wanted to ask if there is something missing for the merge?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-15 Thread Yifeng Dong via Phabricator via cfe-commits
dongAxis1944 added a comment.

@jmorse I am not familiar with CHECK-DAG. And @probinson 's suggestion might be 
useful, any ideas?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100298

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


[PATCH] D100388: [BROKEN][clang] Try to fix thunk function types

2021-04-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 337679.
lebedev.ri marked 10 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100388

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/ABI.h
  clang/include/clang/Basic/Thunk.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
  clang/test/CodeGenCXX/thunk-returning-memptr.cpp
  clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
  clang/test/CodeGenCXX/thunk-wrong-this.cpp

Index: clang/test/CodeGenCXX/thunk-wrong-this.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunk-wrong-this.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+class Base1 {
+  virtual void Foo1();
+};
+
+class Base2 {
+  virtual void Foo2();
+};
+
+class alignas(16) Obj : public Base1, public Base2 {
+  void Foo1() override;
+  void Foo2() override;
+  ~Obj();
+};
+
+void Obj::Foo1() {}
+void Obj::Foo2() {}
+
+// CHECK: define dso_local void @_ZThn8_N3Obj4Foo2Ev(%class.Base2.2* nonnull dereferenceable(8) %this.coerce) #1 align 2 {
+// CHECK: tail call void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull dereferenceable(16) %2)
Index: clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+struct A {};
+struct alignas(32) B : virtual A {
+  char c[32];
+};
+struct Pad {
+  char c[7];
+};
+struct C : B, Pad, virtual A {};
+
+struct X {
+  virtual A &f();
+};
+struct U {
+  virtual ~U();
+};
+C c;
+struct Y : U, X {
+  virtual B &f() override { return c; }
+};
+
+Y y;
+
+// CHECK: define linkonce_odr nonnull align 1 dereferenceable(1) %struct.A.8* @_ZTchn8_v0_n24_N1Y1fEv(%struct.X.7* nonnull dereferenceable(8) %this.coerce) #1 comdat align 2 {
Index: clang/test/CodeGenCXX/thunk-returning-memptr.cpp
===
--- clang/test/CodeGenCXX/thunk-returning-memptr.cpp
+++ clang/test/CodeGenCXX/thunk-returning-memptr.cpp
@@ -23,5 +23,5 @@
 // Because of the tail call, the return value cannot be copied into a local
 // alloca. (PR39901)
 
-// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret({ i32, i32 }) align 4 %agg.result, %struct.C* {{[^,]*}} %this)
+// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret({ i32, i32 }) align 4 %agg.result, %struct.B* {{[^,]*}} %this.coerce)
 // CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret({ i32, i32 }) align 4 %agg.result
Index: clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
===
--- clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
+++ clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
@@ -29,5 +29,5 @@
 
 // Thunks should be marked as "linkonce ODR" not "weak".
 //
-// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
 // CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1C1fEv
+// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2163,8 +2163,10 @@
   void StartThunk(llvm::Function *Fn, GlobalDecl GD,
   const CGFunctionInfo &FnInfo, bool IsUnprototyped);
 
-  void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
- const ThunkInfo *Thunk, bool IsUnprototyped);
+  void EmitCallAndReturnForThunk(const CGFunctionInfo &CallInfo,
+ llvm::FunctionCallee Callee,
+ GlobalDecl CalleeGD, const ThunkInfo *Thunk,
+ bool IsUnprototyped);
 
   void FinishThunk();
 
@@ -2173,7 +2175,7 @@
  llvm::FunctionCallee Callee);
 
   /// Generate a thunk for the given method.
-  void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
+  void generateThunk(llvm::Function *ThunkFn, const CGFunctionInfo &ThunkFnInfo,
  GlobalDecl GD, const ThunkInfo &Thunk,
  bool IsUnprototyped);
 
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -289,7 +289,9 @@
   FinishFunction();
 }
 
-void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
+void CodeGenFunction::EmitCallAndReturnForThunk(c

[PATCH] D100388: [BROKEN][clang] Try to fix thunk function types

2021-04-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri abandoned this revision.
lebedev.ri added a comment.

You know, somehow i don't think me wasting 30 more hours on this to 
experimentally find a working permutation is productive.




Comment at: clang/include/clang/Basic/Thunk.h:157
+
+  /// Holds a pointer to the overridee(!) method this thunk is for,
+  /// if needed by the ABI to distinguish different thunks with equal

rsmith wrote:
> Isn't this the same as `BaseMethod.getDecl()`? (I'd expect "overridee" and 
> "overridden" to be synonymous, contrasting with the "overrider" which would 
> be the derived-class function.)
Oh, hmm. That makes more sense indeed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100388

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-04-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I think you can land it. The issues seem indeed unrelated.
You might want to rebase and retest before landing to be sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp:1
+//===--- ImplementAbstract.cpp ---*- 
C++-*-===//
+//

sammccall wrote:
> I'd consider calling this OverrideVirtual.cpp. I think we'll want to support 
> method-by-method triggering in future, and it would share most of the 
> implementation.
> 
> (We don't have the infrastructure today, but there are certainly more cases 
> where we want to offer alternate tweaks from the same "class". @kadircet 
> maybe this is relevant to bazel build fixing?)
>(We don't have the infrastructure today, but there are certainly more cases 
>where we want to offer alternate tweaks from the same "class". @kadircet maybe 
>this is relevant to bazel build fixing?)

Yes we should hopefully have support for those in the near future!



Comment at: clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp:25
+// FIXME: Have some way to control this, maybe in the config?
+constexpr bool DefineMethods = true;
+using MethodAndAccess =

sammccall wrote:
> I know you just added this, but I think it's better to declare only, and hope 
> to compose with a "define method" code action.
> 
> Reasons:
>  - It's a lot of work to provide sensible defaults: `return {}` is clever, 
> but unidiomatic for many return types.
>  - We can't produce bodies for all return types (e.g. classes with no easy 
> constructor). So we'll produce a bunch of methods that don't compile, which 
> is distracting.
>  - Inserting a dummy body that *does* compile places a burden on the user to 
> keep track of it.
>  - Inserting *in-line* definitions doesn't really save much typing or much 
> thinking
>  - code actions are a pretty simple interaction with few "options". Offering 
> every permutation is unrealistic, and config doesn't seem like an ergonomic 
> alternative. Our best hope IMO is combining sequential code actions.
>  - keeps the scope small, smaller code actions are easier to maintain
> 
> @kadircet do you find this compelling? (Don't want Nathan caught in the 
> middle :-))
I agree 100%.

In addition to all of those, getting linker errors for missing bodies is a lot 
better than debugging arbitrary runtime misbehaviour due to a defaulted return 
type.

As a future note on the `define method` code action, i think rather than trying 
to generate a compiling definition we should construct a body like:
`return /*magic*/;` to ensure user gets some diagnostics (at least for non-void 
functions), that they can use to jump later on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94942

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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

What's your logic for these being Arm only?

I looked up the ones that were added:

  vadd_p8
  vadd_p16
  vadd_p64
  vaddq_p8
  vaddq_p16
  vaddq_p64
  vaddq_p128

E.g. 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics?search=vadd_p8

It says that this is enabled for `v7/A32/A64`. However the pseudocode does use 
`CheckFPAdvSIMDEnabled64` which might imply AArch64 only. There is a 
`AArch32.CheckAdvSIMDOrFPEnabled` for AArch32 but looking at `vabdq_u32` which 
is Arm and AArch64, it also uses `CheckFPAdvSIMDEnabled64` so clearly that 
doesn't mean much.

The weird thing is that the header already guards this with `__aarch64__` so 
that must be based on some other property than simply being in these tables. 
(GCC agrees)

How did you find this? Presumably you couldn't use them from C, even without 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100499

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


[clang] 56cb214 - add test case for ignoring -flto=auto and -flto=jobserver

2021-04-15 Thread Sylvestre Ledru via cfe-commits

Author: Matthias Klose
Date: 2021-04-15T12:19:14+02:00
New Revision: 56cb214b38a70c0fc824ab096e500d78c72b44ef

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

LOG: add test case for ignoring -flto=auto and -flto=jobserver

as requested in https://reviews.llvm.org/D99501, test that the two new options 
are ignored.

Reviewed By: tejohnson, fhahn

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

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 3ea9410adbead..9da9f5eac6324 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -279,6 +279,7 @@
 // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks  \
 // RUN: -fno-inline-small-functions -finline-small-functions  \
 // RUN: -fno-fat-lto-objects -ffat-lto-objects\
+// RUN: -flto=auto -flto=jobserver\
 // RUN: -fno-merge-constants -fmerge-constants\
 // RUN: -fno-caller-saves -fcaller-saves  \
 // RUN: -fno-reorder-blocks -freorder-blocks  \



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


[PATCH] D100484: add test case for ignoring -flto=auto and -flto=jobserver

2021-04-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56cb214b38a7: add test case for ignoring -flto=auto and 
-flto=jobserver (authored by doko, committed by sylvestre.ledru).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100484

Files:
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -279,6 +279,7 @@
 // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks  \
 // RUN: -fno-inline-small-functions -finline-small-functions  \
 // RUN: -fno-fat-lto-objects -ffat-lto-objects\
+// RUN: -flto=auto -flto=jobserver\
 // RUN: -fno-merge-constants -fmerge-constants\
 // RUN: -fno-caller-saves -fcaller-saves  \
 // RUN: -fno-reorder-blocks -freorder-blocks  \


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -279,6 +279,7 @@
 // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks  \
 // RUN: -fno-inline-small-functions -finline-small-functions  \
 // RUN: -fno-fat-lto-objects -ffat-lto-objects\
+// RUN: -flto=auto -flto=jobserver\
 // RUN: -fno-merge-constants -fmerge-constants\
 // RUN: -fno-caller-saves -fcaller-saves  \
 // RUN: -fno-reorder-blocks -freorder-blocks  \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

Thank you for the answer. It did not know that I have to land it myself.

Now I read up on https://llvm.org/docs/Phabricator.html

Tried to land via 'arc land' but I do not have the access rights.

So: Can someone please land the change for me. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

No remarks from me. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

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


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S updated this revision to Diff 337691.
Max_S edited the summary of this revision.
Max_S added a comment.

Added changelog entry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,47 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsArrays) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1254,15 +1254,14 @@
   if (PreviousLine && RootToken.isAccessSpecifier()) {
 switch (Style.EmptyLineBeforeAccessModifier) {
 case FormatStyle::ELBAMS_Never:
-  if (RootToken.NewlinesBefore > 1)
+  if (Newlines > 1)
 Newlines = 1;
   break;
 case FormatStyle::ELBAMS_Leave:
   Newlines = std::max(RootToken.NewlinesBefore, 1u);
   break;
 case FormatStyle::ELBAMS_LogicalBlock:
-  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
-  RootToken.NewlinesBefore <= 1)
+  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) && Newlines <= 
1)
 Newlines = 2;
   break;
 case FormatStyle::ELBAMS_Always: {
@@ -1271,8 +1270,7 @@
 previousToken = PreviousLine->Last->getPreviousNonComment();
   else
 previousToken = PreviousLine->Last;
-  if ((!previousToken || !previousToken->is(tok::l_brace)) &&
-  RootToken.NewlinesBefore <= 1)
+  if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 
1)
 Newlines = 2;
 } break;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -216,6 +216,10 @@
 - Support for Whitesmiths has been improved, with fixes for ``namespace`` 
blocks
   and ``case`` blocks and labels.
 
+- Checks for newlines in option ``EmptyLineBeforeAccessModifier`` are now based
+  on the formatted new lines and not on the new lines in the file. (Fixes
+  https://llvm.org/PR41870.)
+
 libclang
 
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,47 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "p

[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

I do not have the access rights to the llvm git repo. Can you please land it 
for me.

Thanks and thank you for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-04-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I'll land it for you. Could you please provide "Name Surname " for 
commit attribution unless the info associated with your phabricator user is 
okay?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-04-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

Thank you for landing it. The information should be ok. But anyway: Max 
Sagebaum 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-15 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:8673
+// reference if an implementation supports them in kernel parameters.
+if (!PointeeType->isAtomicType() && !PointeeType->isVoidType() &&
+!PointeeType->isStandardLayoutType())

I am wondering if this should be made conditional on C++ mode?  Or is there no 
possible way that this new `return InvalidKernelParam` can be triggered from 
OpenCL C mode?


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

https://reviews.llvm.org/D100471

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


Re: [clang] 5ad15f4 - Require commas between double square bracket attributes.

2021-04-15 Thread Aaron Ballman via cfe-commits
On Thu, Apr 15, 2021 at 12:15 AM  wrote:
>
> Hi Aaron,
>
> Your change is causing the compiler to go into an infinite loop in one of our 
> internal tests. I have put details up in PR49966, can you please take a look?

Absolutely, thank you for the report!

~Aaron

>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Aaron 
> Ballman via cfe-commits
> Sent: Tuesday, April 13, 2021 3:43
> To: cfe-commits@lists.llvm.org
> Subject: [clang] 5ad15f4 - Require commas between double square bracket 
> attributes.
>
>
> Author: Aaron Ballman
> Date: 2021-04-13T06:43:01-04:00
> New Revision: 5ad15f4d1c6f56d25904265023d123a7d0b9d59d
>
> URL: 
> https://github.com/llvm/llvm-project/commit/5ad15f4d1c6f56d25904265023d123a7d0b9d59d
> DIFF: 
> https://github.com/llvm/llvm-project/commit/5ad15f4d1c6f56d25904265023d123a7d0b9d59d.diff
>
> LOG: Require commas between double square bracket attributes.
>
> Clang currently has a bug where it allows you to write [[foo bar]] and both 
> attributes are silently accepted. This patch corrects the comma parsing rules 
> for such attributes and handles the test case fallout, as a few tests were 
> accidentally doing this.
>
> Added:
>
>
> Modified:
> clang/lib/Parse/ParseDeclCXX.cpp
> clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
> clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp
> clang/test/Parser/c2x-attributes.c
> clang/test/Parser/cxx-attributes.cpp
> clang/test/Parser/pragma-attribute.cpp
> clang/test/Sema/c2x-maybe_unused-errors.c
> clang/test/Sema/c2x-nodiscard.c
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
> b/clang/lib/Parse/ParseDeclCXX.cpp
> index 498036368c19..e1d29f555f42 100644
> --- a/clang/lib/Parse/ParseDeclCXX.cpp
> +++ b/clang/lib/Parse/ParseDeclCXX.cpp
> @@ -4213,10 +4213,21 @@ void 
> Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
>
>llvm::SmallDenseMap SeenAttrs;
>
> +  bool AttrParsed = false;
>while (Tok.isNot(tok::r_square)) {
> -// attribute not present
> -if (TryConsumeToken(tok::comma))
> -  continue;
> +if (AttrParsed) {
> +  // If we parsed an attribute, a comma is required before parsing any
> +  // additional attributes.
> +  if (ExpectAndConsume(tok::comma)) {
> +SkipUntil(tok::r_square, StopAtSemi | StopBeforeMatch);
> +continue;
> +  }
> +  AttrParsed = false;
> +}
> +
> +// Eat all remaining superfluous commas before parsing the next 
> attribute.
> +while (TryConsumeToken(tok::comma))
> +  ;
>
>  SourceLocation ScopeLoc, AttrLoc;
>  IdentifierInfo *ScopeName = nullptr, *AttrName = nullptr; @@ -4250,7 
> +4261,6 @@ void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
>  }
>
>  bool StandardAttr = IsBuiltInOrStandardCXX11Attribute(AttrName, 
> ScopeName);
> -bool AttrParsed = false;
>
>  if (StandardAttr &&
>  !SeenAttrs.insert(std::make_pair(AttrName, AttrLoc)).second) @@ 
> -4262,12 +4272,14 @@ void 
> Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
>AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, attrs, endLoc,
> ScopeName, ScopeLoc);
>
> -if (!AttrParsed)
> +if (!AttrParsed) {
>attrs.addNew(
>AttrName,
>SourceRange(ScopeLoc.isValid() ? ScopeLoc : AttrLoc, AttrLoc),
>ScopeName, ScopeLoc, nullptr, 0,
>getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11 : 
> ParsedAttr::AS_C2x);
> +  AttrParsed = true;
> +}
>
>  if (TryConsumeToken(tok::ellipsis))
>Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
>
> diff  --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp 
> b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
> index 45911958af74..982f18f1e8cd 100644
> --- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
> +++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
> @@ -1,7 +1,7 @@
>  // RUN: %clang_cc1 -fsyntax-only -std=c++2a -verify %s
>
>  struct [[nodiscard]] S1 {}; // ok
> -struct [[nodiscard nodiscard]] S2 {}; // expected-error {{attribute 
> 'nodiscard' cannot appear multiple times in an attribute specifier}}
> +struct [[nodiscard, nodiscard]] S2 {}; // expected-error {{attribute
> +'nodiscard' cannot appear multiple times in an attribute specifier}}
>  struct [[nodiscard("Wrong")]] S3 {};
>
>  [[nodiscard]] int f();
>
> diff  --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp 
> b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp
> index 8da2ca7d6d86..6c9b8a75cb04 100644
> --- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp
> +++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -fsyntax-only -Wunused -std=c++1z -verify %s
>
>  struct [[maybe_unused]] S1 {};

[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

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


[PATCH] D100548: [AST] Fix location call storage with common last-invocation

2021-04-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: njames93.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also fix the formatter to use the front element of a chained call
instead of the back element.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100548

Files:
  clang/lib/Tooling/NodeIntrospection.cpp
  clang/unittests/Introspection/IntrospectionTest.cpp


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -45,6 +45,31 @@
 
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
+TEST(Introspection, SourceLocations_CallContainer) {
+  SourceLocationMap slm;
+  SharedLocationCall Prefix;
+  slm.insert(std::make_pair(
+  SourceLocation(),
+  llvm::makeIntrusiveRefCnt(Prefix, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 1u);
+
+  auto callTypeLoc =
+  llvm::makeIntrusiveRefCnt(Prefix, "getTypeLoc");
+  slm.insert(std::make_pair(
+  SourceLocation(),
+  llvm::makeIntrusiveRefCnt(callTypeLoc, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 2u);
+}
+
+TEST(Introspection, SourceLocations_CallChainFormatting) {
+  SharedLocationCall Prefix;
+  auto chainedCall = llvm::makeIntrusiveRefCnt(
+  llvm::makeIntrusiveRefCnt(Prefix, "getTypeLoc"),
+  "getSourceRange");
+  EXPECT_EQ(LocationCallFormatterCpp::format(chainedCall.get()),
+"getTypeLoc().getSourceRange()");
+}
+
 TEST(Introspection, SourceLocations_Stmt) {
   auto AST = buildASTFromCode("void foo() {} void bar() { foo(); }", "foo.cpp",
   std::make_shared());
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -30,7 +30,7 @@
 (VecCall->name() + "()" + (VecCall->returnsPointer() ? "->" : "."))
 .str();
   }
-  result += (vec.back()->name() + "()").str();
+  result += (vec.front()->name() + "()").str();
   return result;
 }
 
@@ -51,13 +51,15 @@
   else if (LHS.first.getEnd() != RHS.first.getEnd())
 return false;
 
-  return LHS.second->name() < RHS.second->name();
+  return LocationCallFormatterCpp::format(LHS.second.get()) <
+ LocationCallFormatterCpp::format(RHS.second.get());
 }
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
   if (LHS.first == RHS.first)
-return LHS.second->name() < RHS.second->name();
+return LocationCallFormatterCpp::format(LHS.second.get()) <
+   LocationCallFormatterCpp::format(RHS.second.get());
   return LHS.first < RHS.first;
 }
 } // namespace internal


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -45,6 +45,31 @@
 
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
+TEST(Introspection, SourceLocations_CallContainer) {
+  SourceLocationMap slm;
+  SharedLocationCall Prefix;
+  slm.insert(std::make_pair(
+  SourceLocation(),
+  llvm::makeIntrusiveRefCnt(Prefix, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 1u);
+
+  auto callTypeLoc =
+  llvm::makeIntrusiveRefCnt(Prefix, "getTypeLoc");
+  slm.insert(std::make_pair(
+  SourceLocation(),
+  llvm::makeIntrusiveRefCnt(callTypeLoc, "getSourceRange")));
+  EXPECT_EQ(slm.size(), 2u);
+}
+
+TEST(Introspection, SourceLocations_CallChainFormatting) {
+  SharedLocationCall Prefix;
+  auto chainedCall = llvm::makeIntrusiveRefCnt(
+  llvm::makeIntrusiveRefCnt(Prefix, "getTypeLoc"),
+  "getSourceRange");
+  EXPECT_EQ(LocationCallFormatterCpp::format(chainedCall.get()),
+"getTypeLoc().getSourceRange()");
+}
+
 TEST(Introspection, SourceLocations_Stmt) {
   auto AST = buildASTFromCode("void foo() {} void bar() { foo(); }", "foo.cpp",
   std::make_shared());
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -30,7 +30,7 @@
 (VecCall->name() + "()" + (VecCall->returnsPointer() ? "->" : "."))
 .str();
   }
-  result += (vec.back()->name() + "()").str();
+  result += (vec.front()->name() + "()").str();
   return result;
 }
 
@@ -51,13 +51,15 @@
   else if (LHS.first.getEnd() != RHS.first.getEnd())
 return false;
 
-  return LHS.second->name() < RHS.second->name();
+  return LocationCallFormatterCpp::format(LHS.second.get()) <
+ LocationCallFormatterCpp::format(RHS.second.get());
 }
 bool RangeLessThan::operator()(
 std::p

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

2021-04-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I left a couple of comments inline on the command-line parsing aspect of the 
patch. For more info, check 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option.




Comment at: clang/include/clang/Driver/Options.td:2658
+  Flags<[CC1Option, NoDriverOption]>,
+  MarshallingInfoString, [{""}]>;
 

This argument is not necessary, `MarshallingInfoString` defaults to an empty 
string by default.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1926
 
+  if (Args.hasArg(OPT_fstack_usage))
+NeedLocTracking = true;

Since `OPT_fstack_usage` has already been parsed into `Opts.StackUsage` at this 
point, it would make more sense to check that instead.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1930
+  if (Arg *A = Args.getLastArg(OPT_fstack_usage_EQ))
+Opts.StackUsageOutput = std::string(A->getValue());
+

This has already been parsed through 
`MarshallingInfoString>`, no need to duplicate 
it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D100516: [AST] Add TypeLoc support to node introspection

2021-04-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 337720.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100516

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -26,16 +26,15 @@
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
 
-template
-std::map
+template 
+std::vector>
 FormatExpected(const MapType &Accessors) {
-  std::map Result;
+  std::vector> Result;
   llvm::transform(llvm::make_filter_range(Accessors,
   [](const auto &Accessor) {
 return Accessor.first.isValid();
   }),
-  std::inserter(Result, Result.end()),
-  [](const auto &Accessor) {
+  std::back_inserter(Result), [](const auto &Accessor) {
 return std::make_pair(
 LocationCallFormatterCpp::format(Accessor.second.get()),
 Accessor.first);
@@ -45,6 +44,31 @@
 
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
+#define STRING_LOCATION_STDPAIR(INSTANCE, LOC) \
+  std::make_pair(std::string(#LOC), INSTANCE->LOC)
+
+/**
+  A test formatter for a hypothetical language which needs
+  neither casts nor '->'.
+*/
+class LocationCallFormatterSimple {
+public:
+  static std::string format(LocationCall *Call) {
+std::vector vec;
+while (Call) {
+  if (!Call->isCast())
+vec.push_back(Call);
+  Call = Call->on();
+}
+std::string result;
+for (auto *VecCall : llvm::reverse(llvm::makeArrayRef(vec).drop_front())) {
+  result += (VecCall->name() + "().").str();
+}
+result += (vec.front()->name() + "()").str();
+return result;
+  }
+};
+
 TEST(Introspection, SourceLocations_CallContainer) {
   SourceLocationMap slm;
   SharedLocationCall Prefix;
@@ -150,26 +174,75 @@
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
-  EXPECT_THAT(ExpectedLocations,
-  UnorderedElementsAre(
-  STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getLocation()),
-  STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
+  llvm::sort(ExpectedLocations);
+
+  // clang-format off
+  EXPECT_EQ(
+  ExpectedLocations,
+  (std::vector>{
+STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getBodyRBrace()),
+STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl,
+  getTypeSourceInfo()->getTypeLoc().getAs().getLParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl,
+  getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeBegin()),
+STRING_LOCATION_STDPAIR(MethodDecl,
+  getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeEnd()),
+STRING_LOCATION_STDPAIR(MethodDecl,
+  getTypeSourceInfo()->getTypeLoc().getAs().getRParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl,
+  getTypeSourceInfo()->getTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(
+MethodDecl,
+getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(
+MethodDecl,
+getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(
+MethodDecl,
+getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getAs().getTemplateNameLoc()),
+STRING_LOCATION_STDPAIR(
+MethodDecl,
+getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(
+MethodDecl,
+getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSpecEndLoc()),
+STRING_LOCATIO

[PATCH] D100415: [Coroutines] Split coroutine during CoroEarly into an init and ramp function

2021-04-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

It looks like this code may trigger assertion in `CoroInstr.h` for 
`CoroIdInst::setCoroutineSelf`.

Also, since this patch would enlarge the coroutine frame, it may affect the 
performance naturally. I **believe**  it wouldn't really matter. I just find 
that we need coroutine benchmarks which seems missing now. It is really needed 
when we talk about the performance for coroutine. Although our intuition tell 
us it should be ok, we still need some data to approve us instead of imaging. I 
am not asking for benchmark or score for this patch. I just find there is no 
benchmark we can evaluate the performance for coroutine. I believe it would be 
a future direction.

Then, since there is hidden chance to decrease the performance, I wonder is it 
better to give an option to control how coroutine handle the parameters. We can 
use strategy in this patch by default. An option could help us in tuning the 
performance in the future.

I would try to look into the details for the code.




Comment at: clang/lib/CodeGen/CGCoroutine.cpp:619
+EmitBlock(InitBB);
+SmallVector FrameAllocas;
 // Create parameter copies. We do it before creating a promise, since an

Did this vector have been used?



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:638
+  llvm::ConstantAsMetadata::get(Builder.getInt32(ID++)),
+  }));
   // TODO: if(CoroParam(...)) need to surround ctor and dtor

I wonder if it is better to document the metadata `coroutine_frame_alloca` in 
somewhere like the metadata `tbaa`.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:646
 
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::coro_init_end));
+Builder.CreateBr(InitReadyBB);

It calls `coro.init.end` without calling `coro.init` in the front which looks 
odd.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:153
 
+static void splitRampFunction(Function &F) {
+  Module *M = F.getParent();

We need comment for the intention of the function.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:156
+  LLVMContext &C = M->getContext();
+  {
+CoroBeginInst *CoroBegin = cast(

It looks odd for several `{}` in Function to avoid name collision.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:172
+  auto *SlotID = cast(MD->getOperand(1))->getValue();
+  auto *VoidPt =
+  new BitCastInst(AI, llvm::Type::getInt8PtrTy(C), "", InsertPoint);

```
- VoidPt
+ VoidPtr
```



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:176
+  Intrinsic::getDeclaration(M, Intrinsic::coro_frame_get),
+  {CoroBegin, VoidPt, IsPromise, SlotID}, "", InsertPoint);
+  auto *NewPtr = new BitCastInst(FrameGet, AI->getType(), "", InsertPoint);

We need to document the semantics for `coro.frame.get`



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:193
+F.getName() + ".ramp");
+NewF->addFnAttr(Attribute::NoInline);
+M->getFunctionList().push_back(NewF);

Noticed that this patch deletes `F.addFnAttr(CORO_PRESPLIT_ATTR, 
UNPREPARED_FOR_SPLIT);` below, is it conflicting with `D100282 `. I want to 
know if we still ned to add `Noinline` attribute once `D100282 ` checked in.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:218
+II->replaceAllUsesWith(
+llvm::ConstantInt::get(llvm::Type::getInt1Ty(C), 0));
+break;

Why do we need to replace `coro.alloc` with 0 now?
Replace `coro.alloc` with 0 implies we should allocate the frame in the stack. 
I think we can't know how should we allocate the frame now.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:333
   CF->setArgOperand(0, CoroId);
+splitRampFunction(F);
+  }

Should we give a another name for `splitRampFunction`? It may be surprising to 
see `split` in Coro-early pass instead of Coro-split pass.
BTW, how do you think about create the ramp function in the CodeGen process of 
frontend?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100415

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


[PATCH] D100372: [Clang][ARM] Define __VFP_FP__ macro unconditionally

2021-04-15 Thread Victor Campos via Phabricator via cfe-commits
vhscampos updated this revision to Diff 337723.
vhscampos added a comment.

Add a clarifying comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100372

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -141,6 +141,11 @@
 // CHECK-V7S-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 // CHECK-V7S: #define __ARM_FP 0xe
 
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=soft -x c 
-E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=softfp -x 
c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=hard -x c 
-E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// CHECK-VFP-FP: #define __VFP_FP__ 1
+
 // RUN: %clang -target armv8a -mfloat-abi=hard -x c -E -dM %s | FileCheck 
-match-full-lines --check-prefix=CHECK-V8-BAREHF %s
 // CHECK-V8-BAREHF: #define __ARMEL__ 1
 // CHECK-V8-BAREHF: #define __ARM_ARCH 8
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -755,8 +755,12 @@
   // Note, this is always on in gcc, even though it doesn't make sense.
   Builder.defineMacro("__APCS_32__");
 
+  // __VFP_FP__ means that the floating-point format is VFP, not that a 
hardware
+  // FPU is present. Moreover, the VFP format is the only one supported by
+  // clang. For these reasons, this macro is always defined.
+  Builder.defineMacro("__VFP_FP__");
+
   if (FPUModeIsVFP((FPUMode)FPU)) {
-Builder.defineMacro("__VFP_FP__");
 if (FPU & VFP2FPU)
   Builder.defineMacro("__ARM_VFPV2__");
 if (FPU & VFP3FPU)


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -141,6 +141,11 @@
 // CHECK-V7S-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 // CHECK-V7S: #define __ARM_FP 0xe
 
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=soft -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=softfp -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mfloat-abi=hard -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-VFP-FP %s
+// CHECK-VFP-FP: #define __VFP_FP__ 1
+
 // RUN: %clang -target armv8a -mfloat-abi=hard -x c -E -dM %s | FileCheck -match-full-lines --check-prefix=CHECK-V8-BAREHF %s
 // CHECK-V8-BAREHF: #define __ARMEL__ 1
 // CHECK-V8-BAREHF: #define __ARM_ARCH 8
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -755,8 +755,12 @@
   // Note, this is always on in gcc, even though it doesn't make sense.
   Builder.defineMacro("__APCS_32__");
 
+  // __VFP_FP__ means that the floating-point format is VFP, not that a hardware
+  // FPU is present. Moreover, the VFP format is the only one supported by
+  // clang. For these reasons, this macro is always defined.
+  Builder.defineMacro("__VFP_FP__");
+
   if (FPUModeIsVFP((FPUMode)FPU)) {
-Builder.defineMacro("__VFP_FP__");
 if (FPU & VFP2FPU)
   Builder.defineMacro("__ARM_VFPV2__");
 if (FPU & VFP3FPU)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100552: [HIP] Diagnose compiling kernel without offload arch

2021-04-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, tpr, nhaehnle, jvesely.
Herald added a reviewer: aaron.ballman.
yaxunl requested review of this revision.

AMDGPU does not have a common processor (GPU arch). A HIP kernel
must be compiled with a specified processor to be able to be launched
on that processor.

However we cannot simply diagnose missing --offload-arch in clang
driver since a valid HIP program can contain no kernel, which can be
compiled without specifying offload arch and executed on machines
without AMDGPU.

Therefore only HIP programs containing kernels should be diagnosed
when compiled without offload arch.

This patch changes clang driver so that when offload arch is not specified
for HIP, no target CPU is specified for clang -cc1. If HIP program contains
kernel, FE will diagnose it as a fatal error so that the diagnostics will be
emitted only once.  This way, we allow HIP programs without kernels to
be compiled without offload arch whereas forbid HIP programs with
kernels to be compiled without offload arch.


https://reviews.llvm.org/D100552

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/CodeGenCUDA/kernel-amdgcn.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/kernel-dbg-info.cu
  clang/test/CodeGenCUDA/lambda-reference-var.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenCUDA/static-device-var-no-rdc.cu
  clang/test/CodeGenCUDA/static-device-var-rdc.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/hip-default-gpu-arch.hip
  clang/test/SemaCUDA/kernel-no-gpu.cu

Index: clang/test/SemaCUDA/kernel-no-gpu.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/kernel-no-gpu.cu
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fcuda-is-device -verify=hip -x hip %s
+// RUN: %clang_cc1 -fcuda-is-device -verify=cuda %s
+// cuda-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+__global__ void kern1() {}
+// hip-error@-1 {{compile HIP kernel without specifying offload arch is not allowed}}
+
+// Make sure the error is emitted once.
+__global__ void kern2() {}
Index: clang/test/Driver/hip-default-gpu-arch.hip
===
--- clang/test/Driver/hip-default-gpu-arch.hip
+++ clang/test/Driver/hip-default-gpu-arch.hip
@@ -4,4 +4,5 @@
 
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s
 
-// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"
+// CHECK-NOT: {{.*}}clang{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu"
+// CHECK: {{.*}}clang{{.*}}"-triple" "amdgcn-amd-amdhsa"
Index: clang/test/Driver/cuda-flush-denormals-to-zero.cu
===
--- clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -26,8 +26,11 @@
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c -march=haswell --cuda-gpu-arch=gfx803 -nocudainc -nogpulib %s 2>&1 | FileCheck -check-prefix=FTZ %s
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c -march=haswell --cuda-gpu-arch=gfx900 -nocudainc -nogpulib %s 2>&1 | FileCheck -check-prefix=NOFTZ %s
 
-// Test no subtarget, which should get the denormal setting of the default gfx803
-// RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c -march=haswell -nocudainc -nogpulib %s 2>&1 | FileCheck -check-prefix=FTZ %s
+// Test no subtarget, which should get the denormal setting of the default
+// CPU of AMDGPU target, which is 'none'.
+// RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c \
+// RUN:   -march=haswell -nocudainc -nogpulib %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOFTZ %s
 
 // Test multiple offload archs with different defaults.
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c -march=haswell --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 -nocudainc -nogpulib %s 2>&1 | FileCheck -check-prefix=MIXED-DEFAULT-MODE %s
Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
 // RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-pc-windows-msvc -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=MSVC
-// RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-am

[PATCH] D100423: [AST] Add a print method to Introspection LocationCall

2021-04-15 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 337724.
njames93 added a comment.

Tweak implementaion to make the print a static method of FormatterCpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100423

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/NodeIntrospection.cpp
  clang/unittests/Introspection/IntrospectionTest.cpp


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -36,9 +36,9 @@
   }),
   std::inserter(Result, Result.end()),
   [](const auto &Accessor) {
-return std::make_pair(
-
LocationCallFormatterCpp::format(Accessor.second.get()),
-Accessor.first);
+return std::make_pair(LocationCallFormatterCpp::format(
+  *Accessor.second.get()),
+  Accessor.first);
   });
   return Result;
 }
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -13,25 +13,40 @@
 #include "clang/Tooling/NodeIntrospection.h"
 
 #include "clang/AST/AST.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 
 namespace tooling {
 
-std::string LocationCallFormatterCpp::format(LocationCall *Call) {
-  SmallVector vec;
-  while (Call) {
-vec.push_back(Call);
-Call = Call->on();
+void LocationCallFormatterCpp::print(const LocationCall &Call,
+ llvm::raw_ostream &OS) {
+  if (const LocationCall *On = Call.on()) {
+print(*On, OS);
+if (On->returnsPointer())
+  OS << "->";
+else
+  OS << '.';
   }
-  std::string result;
-  for (auto *VecCall : llvm::reverse(llvm::makeArrayRef(vec).drop_front())) {
-result +=
-(VecCall->name() + "()" + (VecCall->returnsPointer() ? "->" : "."))
-.str();
+
+  OS << Call.name();
+  if (Call.args().empty()) {
+OS << "()";
+return;
+  }
+  OS << '(' << Call.args().front();
+  for (const std::string &Arg : Call.args().drop_front()) {
+OS << ", " << Arg;
   }
-  result += (vec.back()->name() + "()").str();
-  return result;
+  OS << ')';
+}
+
+std::string LocationCallFormatterCpp::format(const LocationCall &Call) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  print(Call, OS);
+  OS.flush();
+  return Result;
 }
 
 namespace internal {
Index: clang/include/clang/Tooling/NodeIntrospection.h
===
--- clang/include/clang/Tooling/NodeIntrospection.h
+++ clang/include/clang/Tooling/NodeIntrospection.h
@@ -58,7 +58,8 @@
 
 class LocationCallFormatterCpp {
 public:
-  static std::string format(LocationCall *Call);
+  static void print(const LocationCall &Call, llvm::raw_ostream &OS);
+  static std::string format(const LocationCall &Call);
 };
 
 namespace internal {


Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -36,9 +36,9 @@
   }),
   std::inserter(Result, Result.end()),
   [](const auto &Accessor) {
-return std::make_pair(
-LocationCallFormatterCpp::format(Accessor.second.get()),
-Accessor.first);
+return std::make_pair(LocationCallFormatterCpp::format(
+  *Accessor.second.get()),
+  Accessor.first);
   });
   return Result;
 }
Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -13,25 +13,40 @@
 #include "clang/Tooling/NodeIntrospection.h"
 
 #include "clang/AST/AST.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 
 namespace tooling {
 
-std::string LocationCallFormatterCpp::format(LocationCall *Call) {
-  SmallVector vec;
-  while (Call) {
-vec.push_back(Call);
-Call = Call->on();
+void LocationCallFormatterCpp::print(const LocationCall &Call,
+ llvm::raw_ostream &OS) {
+  if (const LocationCall *On = Call.on()) {
+print(*On, OS);
+if (On->returnsPointer())
+  OS << "->";
+else
+  OS << '.';
   }
-  std::string result;
-  for (auto *Vec

[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3853-3855
+  if (const auto *FilterClause = S.getSingleClause()) {
+Filter = FilterClause->getThreadID();
+  }

No need for braces here



Comment at: clang/test/OpenMP/masked_codegen.cpp:87
+#pragma omp parallel
+#pragma omp masked
+  // TERM_DEBUG-NOT: __kmpc_global_thread_num

Add a test with `filter` clauses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers added inline comments.



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})

What happens when /opt/rocm is not available?   Again, we need a 
cross-architecture mechanism to identify the offload-arch. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})

gregrodgers wrote:
> What happens when /opt/rocm is not available?   Again, we need a 
> cross-architecture mechanism to identify the offload-arch. 
Exactly the same as the amdgpu plugin. The cmake detection is char for char 
identical. This will look in CMAKE_INSTALL_PREFIX, which is where I install 
these libs when using trunk, and falls back to /opt/rocm which seems to be 
convenient for some users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100231: [NewPM] Cleanup IR printing instrumentation

2021-04-15 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser accepted this revision.
jamieschmeiser 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/D100231/new/

https://reviews.llvm.org/D100231

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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337731.
mibintc added a comment.

I removed the diagnostic from InGroup, that's the only change from 
previous revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-x86-interrupt.c


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function 
with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,8 +293,8 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
   " with attribute 'no_caller_saved_registers'">;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,8 +293,8 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
   " with attribute 'no_caller_saved_registers'">;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's VFP registers">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] ecf93a7 - [clangd] Only allow remote index to be enabled from user config.

2021-04-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-04-15T14:51:23+02:00
New Revision: ecf93a716c9ecf2e38898547df90323e239a623c

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

LOG: [clangd] Only allow remote index to be enabled from user config.

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigProvider.cpp
clang-tools-extra/clangd/ConfigProvider.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index a5745727dca78..31beb6ac10cb2 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -101,6 +101,7 @@ struct FragmentCompiler {
   llvm::SourceMgr *SourceMgr;
   // Normalized Fragment::SourceInfo::Directory.
   std::string FragmentDirectory;
+  bool Trusted = false;
 
   llvm::Optional
   compileRegex(const Located &Text,
@@ -183,6 +184,7 @@ struct FragmentCompiler {
   }
 
   void compile(Fragment &&F) {
+Trusted = F.Source.Trusted;
 if (!F.Source.Directory.empty()) {
   FragmentDirectory = 
llvm::sys::path::convert_to_slash(F.Source.Directory);
   if (FragmentDirectory.back() != '/')
@@ -320,6 +322,13 @@ struct FragmentCompiler {
 
   void compile(Fragment::IndexBlock::ExternalBlock &&External,
llvm::SMRange BlockRange) {
+if (External.Server && !Trusted) {
+  diag(Error,
+   "Remote index may not be specified by untrusted configuration. "
+   "Copy this into user config to use it.",
+   External.Server->Range);
+  return;
+}
 #ifndef CLANGD_ENABLE_REMOTE
 if (External.Server) {
   elog("Clangd isn't compiled with remote index support, ignoring Server: "
@@ -510,8 +519,8 @@ CompiledFragment Fragment::compile(DiagnosticCallback D) && 
{
   trace::Span Tracer("ConfigCompile");
   SPAN_ATTACH(Tracer, "ConfigFile", ConfigFile);
   auto Result = std::make_shared();
-  vlog("Config fragment: compiling {0}:{1} -> {2}", ConfigFile, LineCol.first,
-   Result.get());
+  vlog("Config fragment: compiling {0}:{1} -> {2} (trusted={3})", ConfigFile,
+   LineCol.first, Result.get(), Source.Trusted);
 
   FragmentCompiler{*Result, D, Source.Manager.get()}.compile(std::move(*this));
   // Return as cheaply-copyable wrapper.

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 6b58b88dfd490..8e4110e6dba13 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -94,6 +94,9 @@ struct Fragment {
 /// Absolute path to directory the fragment is associated with. Relative
 /// paths mentioned in the fragment are resolved against this.
 std::string Directory;
+/// Whether this fragment is allowed to make critical security/privacy
+/// decisions.
+bool Trusted = false;
   };
   SourceInfo Source;
 

diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp 
b/clang-tools-extra/clangd/ConfigProvider.cpp
index 3b705d8f4a82d..2b8e406b60d5e 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -36,7 +36,7 @@ class FileConfigCache : public FileCache {
   : FileCache(Path), Directory(Directory) {}
 
   void get(const ThreadsafeFS &TFS, DiagnosticCallback DC,
-   std::chrono::steady_clock::time_point FreshTime,
+   std::chrono::steady_clock::time_point FreshTime, bool Trusted,
std::vector &Out) const {
 read(
 TFS, FreshTime,
@@ -45,6 +45,7 @@ class FileConfigCache : public FileCache {
   if (Data)
 for (auto &Fragment : Fragment::parseYAML(*Data, path(), DC)) {
   Fragment.Source.Directory = Directory;
+  Fragment.Source.Trusted = Trusted;
   CachedValue.push_back(std::move(Fragment).compile(DC));
 }
 },
@@ -54,35 +55,38 @@ class FileConfigCache : public FileCache {
 
 std::unique_ptr Provider::fromYAMLFile(llvm::StringRef AbsPath,
  llvm::StringRef Directory,
- const ThreadsafeFS &FS) {
+ const ThreadsafeFS &FS,
+ bool Trusted) {
   class AbsFileProvider : public Provider {
 mutable FileConfigCache Cache; // threadsafe
 const ThreadsafeFS &FS;
+bool Trusted;
 
 std::vector
 getFragments(const Params &P, DiagnosticCallback DC) const override {
   std:

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})

JonChesterfield wrote:
> gregrodgers wrote:
> > What happens when /opt/rocm is not available?   Again, we need a 
> > cross-architecture mechanism to identify the offload-arch. 
> Exactly the same as the amdgpu plugin. The cmake detection is char for char 
> identical. This will look in CMAKE_INSTALL_PREFIX, which is where I install 
> these libs when using trunk, and falls back to /opt/rocm which seems to be 
> convenient for some users.
Which may need revising at some point - I like installing hsa as if it was an 
llvm subcomponent, but other people might want a different convention. As long 
as we remember to change this file + amdgpu's cmake at the same time, all good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100209: [OpenCL] Do not add builtins with unavailable types

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

LGTM! Thanks!


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

https://reviews.llvm.org/D100209

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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:299
+  " with attribute 'no_caller_saved_registers'">,
+   InGroup;
 def warn_arm_interrupt_calling_convention : Warning<

rsmith wrote:
> Please don't add warnings directly to `-Wextra`; this should have its own 
> flag so that people who want to do this can turn the warning off without 
> turning off all of `-Wextra`.
Thanks, I had thought about removing InGroup before uploading to review 
but hurrying at the end of my work day and forgot. I was expecting the lit test 
to fail and I'd have to add Wextra onto the RUN line but I didn't need to do 
that, the diagnostic was produced without enabling.  Anyway I got rid of it 
like you asked.

BTW the only other diagnostic in this file marked Wextra is the arm diagnostic. 
That was added in https://reviews.llvm.org/D28820 
"warn_arm_interrupt_calling_convention"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers accepted this revision.
gregrodgers added a comment.
This revision is now accepted and ready to land.

I am removing my objection with the understanding that we will either replace 
or enhance amdgpu-arch with the cross-architecture tool offload-arch as 
described in my comments above.   Also, this patch changes amd toolchains to 
use amdgpu-arch.   So it will not interfere with how I expect the 
cross-architecture tool to be used to greatly simplify openmp command line 
arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

LGTM from my side. I will leave final approval to Sven.




Comment at: clang/lib/Sema/SemaDecl.cpp:8673
+// reference if an implementation supports them in kernel parameters.
+if (!PointeeType->isAtomicType() && !PointeeType->isVoidType() &&
+!PointeeType->isStandardLayoutType())

svenvh wrote:
> I am wondering if this should be made conditional on C++ mode?  Or is there 
> no possible way that this new `return InvalidKernelParam` can be triggered 
> from OpenCL C mode?
I think it shouldn't because C types are POD types which is a superset of 
standard layout types.



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

https://reviews.llvm.org/D100471

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


[PATCH] D100423: [AST] Add a print method to Introspection LocationCall

2021-04-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100423

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


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

2021-04-15 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

My main idea was to provide an interface which will not make users to specify 
`-cl-ext=+__opencl_c_fp64,+cl_khr_fp64`/ 
`-cl-ext=-__opencl_c_fp64,-cl_khr_fp64` if they need to enable/disable 
functionality in OpenCL C 3.0 because I believe that is not a right thing to 
do: why anyone should care about those extensions if there are features 
already? Also, this may lead to confusions since, for example, 
`__opencl_c_subgroups` and `cl_khr_subgroups `are not the same (subgroup 
independent forward progress is required in extension while it is optional in 
OpenCL C 3.0, thus implementation may support the extension but not the 
feature).

To be clear: I'm OK with providing a validation of correct option settings 
(`__opencl_c_fp64/cl_khr_fp64` and 
`__opencl_c_3d_image_writes/cl_khr_3d_image_writes` should both be set to the 
same value). Also, it makes sense to unify a check within header and clang to 
the only macro, I'm OK with that too. But I would prefer to keep the option 
interface without redundant mentioning of extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-15 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

Great! And thanks for fixing misprint :)




Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:507
+if (VersionIDs[I] >= MinVersion && VersionIDs[I] < MaxVersion) {
+  Encoded |= 1 << I;
+}

nit: Encoded |= clang::encodeOpenCLVersion(VersionIDs[I]);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100558: [flang][driver] Add support for `-fget-definition`

2021-04-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added subscribers: jansvoboda11, dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds `-fget-definition` to `flang-new`. The semantics of this
option are identical in both drivers. The error message in the
"throwaway" driver is updated so that it matches the one from
`flang-new` (which is auto-generated and cannot be changed easily).

Tests are updated accordingly. A dedicated test for error handling was
added: get-definition.f90 (for the sake of simplicity,
getdefinition01.f90 no longer tests for errors).

The `ParseFrontendArgs` function is updated so that it can return
errors. This change is required in order to report invalid values
following `-fget-definition`.

The actual implementation of `GetDefinitionAction::ExecuteAction()` was
extracted from f18.cpp (i.e. the bit that deals with
`-fget-definition`).

Depends on: https://reviews.llvm.org/D100556


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100558

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/get-definition.f90
  flang/test/Semantics/getdefinition01.f90
  flang/test/Semantics/getdefinition02.f
  flang/test/Semantics/getdefinition03-a.f90
  flang/test/Semantics/getdefinition04.f90
  flang/test/Semantics/getdefinition05.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -658,8 +658,8 @@
 }
 arguments[i] = std::strtol(args.front().c_str(), &endptr, 10);
 if (*endptr != '\0') {
-  llvm::errs() << "Invalid argument to -fget-definitions: "
-   << args.front() << '\n';
+  llvm::errs() << "error: invalid value '" << args.front()
+   << "' in 'fget-definition'" << '\n';
   return EXIT_FAILURE;
 }
 args.pop_front();
Index: flang/test/Semantics/getdefinition05.f90
===
--- flang/test/Semantics/getdefinition05.f90
+++ flang/test/Semantics/getdefinition05.f90
@@ -12,8 +12,8 @@
 end program
 
 !! Inner x
-! RUN: %f18 -fget-definition 9 5 6 -fsyntax-only %s | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 9 5 6 %s | FileCheck --check-prefix=CHECK1 %s
 ! CHECK1: x:{{.*}}getdefinition05.f90, 7, 16-17
 !! Outer y
-! RUN: %f18 -fget-definition 11 7 8 -fsyntax-only %s | FileCheck --check-prefix=CHECK2 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 11 7 8 %s | FileCheck --check-prefix=CHECK2 %s
 ! CHECK2: y:{{.*}}getdefinition05.f90, 5, 14-15
Index: flang/test/Semantics/getdefinition04.f90
===
--- flang/test/Semantics/getdefinition04.f90
+++ flang/test/Semantics/getdefinition04.f90
@@ -6,5 +6,5 @@
   x = y
 end program
 
-! RUN: %f18 -fget-definition 6 3 4 -fsyntax-only %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 6 3 4 %s | FileCheck %s
 ! CHECK: x:{{.*}}getdefinition04.f90, 3, 14-15
Index: flang/test/Semantics/getdefinition03-a.f90
===
--- flang/test/Semantics/getdefinition03-a.f90
+++ flang/test/Semantics/getdefinition03-a.f90
@@ -7,7 +7,7 @@
  x = f
 end program
 
-! RUN: %f18 -fget-definition 7 6 7 -fsyntax-only %s | FileCheck --check-prefix=CHECK1 %s
-! RUN: %f18 -fget-definition 7 2 3 -fsyntax-only %s | FileCheck --check-prefix=CHECK2 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 6 7 %s | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 2 3 %s | FileCheck --check-prefix=CHECK2 %s
 ! CHECK1: f:{{.*}}getdefinition03-b.f90, 2, 12-13
 ! CHECK2: x:{{.*}}getdefinition03-a.f90, 6, 13-14
Index: flang/test/Semantics/getdefinition02.f
===
--- flang/test/Semantics/getdefinition02.f
+++ flang/test/Semantics/getdefinition02.f
@@ -17,9 +17,9 @@
   end module
 
 ! RUN and CHECK lines here as test is sensitive to line numbers
-! RUN: %f18 -fget-definition 7 9 10 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK1 %s
-! RUN: %f18 -fget-definition 8 26 29 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK2 %s
-! RUN: %f18 -fget-definition 15 9 10 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK3 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 9 10 %s 2>&1 | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 8 26 29 %s 2>&1 | FileCheck --check-prefix

[PATCH] D100558: [flang][driver] Add support for `-fget-definition`

2021-04-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 337747.
awarzynski added a comment.

Rebase on top of D100556 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100558

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/get-definition.f90
  flang/test/Semantics/getdefinition01.f90
  flang/test/Semantics/getdefinition02.f
  flang/test/Semantics/getdefinition03-a.f90
  flang/test/Semantics/getdefinition04.f90
  flang/test/Semantics/getdefinition05.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -658,8 +658,8 @@
 }
 arguments[i] = std::strtol(args.front().c_str(), &endptr, 10);
 if (*endptr != '\0') {
-  llvm::errs() << "Invalid argument to -fget-definitions: "
-   << args.front() << '\n';
+  llvm::errs() << "error: invalid value '" << args.front()
+   << "' in 'fget-definition'" << '\n';
   return EXIT_FAILURE;
 }
 args.pop_front();
Index: flang/test/Semantics/getdefinition05.f90
===
--- flang/test/Semantics/getdefinition05.f90
+++ flang/test/Semantics/getdefinition05.f90
@@ -12,8 +12,8 @@
 end program
 
 !! Inner x
-! RUN: %f18 -fget-definition 9 5 6 -fsyntax-only %s | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 9 5 6 %s | FileCheck --check-prefix=CHECK1 %s
 ! CHECK1: x:{{.*}}getdefinition05.f90, 7, 16-17
 !! Outer y
-! RUN: %f18 -fget-definition 11 7 8 -fsyntax-only %s | FileCheck --check-prefix=CHECK2 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 11 7 8 %s | FileCheck --check-prefix=CHECK2 %s
 ! CHECK2: y:{{.*}}getdefinition05.f90, 5, 14-15
Index: flang/test/Semantics/getdefinition04.f90
===
--- flang/test/Semantics/getdefinition04.f90
+++ flang/test/Semantics/getdefinition04.f90
@@ -6,5 +6,5 @@
   x = y
 end program
 
-! RUN: %f18 -fget-definition 6 3 4 -fsyntax-only %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 6 3 4 %s | FileCheck %s
 ! CHECK: x:{{.*}}getdefinition04.f90, 3, 14-15
Index: flang/test/Semantics/getdefinition03-a.f90
===
--- flang/test/Semantics/getdefinition03-a.f90
+++ flang/test/Semantics/getdefinition03-a.f90
@@ -7,7 +7,7 @@
  x = f
 end program
 
-! RUN: %f18 -fget-definition 7 6 7 -fsyntax-only %s | FileCheck --check-prefix=CHECK1 %s
-! RUN: %f18 -fget-definition 7 2 3 -fsyntax-only %s | FileCheck --check-prefix=CHECK2 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 6 7 %s | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 2 3 %s | FileCheck --check-prefix=CHECK2 %s
 ! CHECK1: f:{{.*}}getdefinition03-b.f90, 2, 12-13
 ! CHECK2: x:{{.*}}getdefinition03-a.f90, 6, 13-14
Index: flang/test/Semantics/getdefinition02.f
===
--- flang/test/Semantics/getdefinition02.f
+++ flang/test/Semantics/getdefinition02.f
@@ -17,9 +17,9 @@
   end module
 
 ! RUN and CHECK lines here as test is sensitive to line numbers
-! RUN: %f18 -fget-definition 7 9 10 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK1 %s
-! RUN: %f18 -fget-definition 8 26 29 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK2 %s
-! RUN: %f18 -fget-definition 15 9 10 -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK3 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 7 9 10 %s 2>&1 | FileCheck --check-prefix=CHECK1 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 8 26 29 %s 2>&1 | FileCheck --check-prefix=CHECK2 %s
+! RUN: %flang_fc1 -fsyntax-only -fget-definition 15 9 10 %s 2>&1 | FileCheck --check-prefix=CHECK3 %s
 ! CHECK1: x:{{.*}}getdefinition02.f, 5, 27-28
 ! CHECK2: yyy:{{.*}}getdefinition02.f, 5, 30-33
 ! CHECK3: x:{{.*}}getdefinition02.f, 14, 30-31
Index: flang/test/Semantics/getdefinition01.f90
===
--- flang/test/Semantics/getdefinition01.f90
+++ flang/test/Semantics/getdefinition01.f90
@@ -16,12 +16,9 @@
 end module
 
 ! RUN and CHECK lines at the bottom as this test is sensitive to line numbers
-! RUN: %f18 -fget-definition 6 17 18 -fsyntax-only %s | FileCheck --check-prefix=CHECK1 %s
-! RUN: %f18 -fget-definition 7 20 23 -fsyntax-only %s | FileCheck --check-prefix=CHECK2 %s
-! RUN: %f18 -fget-definition 14 3 4 -fsyntax-only %s | FileCheck -

[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-15 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:507
+if (VersionIDs[I] >= MinVersion && VersionIDs[I] < MaxVersion) {
+  Encoded |= 1 << I;
+}

azabaznov wrote:
> nit: Encoded |= clang::encodeOpenCLVersion(VersionIDs[I]);
I wish I could use `encodeOpenCLVersion` indeed, but the Clang headers are not 
available in TableGen (see comment on line 493).  I couldn't think of a better 
solution unfortunately, but let me know if you have any suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-15 Thread Jonathan Crowther via Phabricator via cfe-commits
Jonathan.Crowther updated this revision to Diff 337764.
Jonathan.Crowther added a comment.

No updates, just want to kick off the CI again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

Files:
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/AsmParser/Parser.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Testing/Support/SupportHelpers.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -343,7 +343,7 @@
   Triple TheTriple(TripleName);
 
   ErrorOr> BufferPtr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (std::error_code EC = BufferPtr.getError()) {
 WithColor::error(errs(), ProgName)
 << InputFilename << ": " << EC.message() << '\n';
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -182,7 +182,7 @@
 static Expected> readInputFile(StringRef FilePath) {
   // Read in file.
   ErrorOr> BufOrError =
-  MemoryBuffer::getFileOrSTDIN(FilePath);
+  MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true);
   if (!BufOrError)
 return createStringError(BufOrError.getError(), "Could not open `%s`",
  FilePath.data());
Index: llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===
--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -334,7 +334,7 @@
 Expected
 InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 InstructionBenchmark Benchmark;
@@ -351,7 +351,7 @@
 Expected>
 InstructionBenchmark::readYamls(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 std::vector Benchmarks;
Index: llvm/lib/Testing/Support/SupportHelpers.cpp
===
--- llvm/lib/Testing/Support/SupportHelpers.cpp
+++ llvm/lib/Testing/Support/SupportHelpers.cpp
@@ -40,7 +40,7 @@
 
   EXPECT_TRUE(Found) << "Unit test source directory file does not exist.";
 
-  auto File = MemoryBuffer::getFile(InputFilePath);
+  auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true);
 
   EXPECT_TRUE(static_cast(File))
   << "Could not open unit test source directory file.";
Index: llvm/lib/ProfileData/SampleProfReader.cpp
===
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -1575,7 +1575,7 @@
 /// \returns an error code indicating the status of the buffer.
 static ErrorOr>
 setupMemoryBuffer(const Twine &Filename) {
-  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return EC;
   auto Buffer = std::move(BufferOrErr.get());
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -41,7 +41,7 @@
 static Expected>
 setupMemoryBuffer(const Twine &Path) {
   ErrorOr> BufferOrErr =
-  MemoryBuffer::getFileOrSTDIN(Path);
+  MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return errorCodeToError(EC);
   return std::move(BufferOrErr.get());
Index: llvm/lib/CodeGen/MIRParser/MIRParser.cpp
===
--- llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -984,7 +984,7 @@
 std::unique_ptr llvm::createMIRParserFromFile(
 StringRef Filename, SMDiagnostic &Error, LLVMContext &Context,
 std::function ProcessIRFunction) {
-  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::err

[PATCH] D100482: [PowerPC] Provide MMA builtins for compatability

2021-04-15 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 337765.
saghir added a comment.

Fixed spelling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100482

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-pair-mma-types.cpp
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
  llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
  llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
  llvm/test/CodeGen/PowerPC/mma-outer-product.ll
  llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
  llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
===
--- llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
+++ llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
@@ -51,6 +51,42 @@
   ret void
 }
 
+; assemble_pair
+declare <256 x i1> @llvm.ppc.mma.assemble.pair(<16 x i8>, <16 x i8>)
+define void @ass_pair1(<256 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: ass_pair1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:stxv v2, 16(r3)
+; CHECK-NEXT:stxv v3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: ass_pair1:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:vmr v3, v2
+; CHECK-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-NOMMA-NEXT:stxv v3, 0(r3)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: ass_pair1:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: ass_pair1:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:vmr v3, v2
+; CHECK-BE-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NOMMA-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = tail call <256 x i1> @llvm.ppc.mma.assemble.pair(<16 x i8> %vc, <16 x i8> %vc)
+  store <256 x i1> %0, <256 x i1>* %ptr, align 32
+  ret void
+}
+
 ; disassemble_pair
 declare { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1>)
 define void @disass_pair(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
@@ -95,6 +131,50 @@
   ret void
 }
 
+; disassemble_pair
+declare { <16 x i8>, <16 x i8> } @llvm.ppc.mma.disassemble.pair(<256 x i1>)
+define void @disass_pair1(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
+; CHECK-LABEL: disass_pair1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxv vs1, 0(r3)
+; CHECK-NEXT:lxv vs0, 16(r3)
+; CHECK-NEXT:stxv vs1, 0(r4)
+; CHECK-NEXT:stxv vs0, 0(r5)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: disass_pair1:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:lxv vs1, 0(r3)
+; CHECK-NOMMA-NEXT:lxv vs0, 16(r3)
+; CHECK-NOMMA-NEXT:stxv vs1, 0(r4)
+; CHECK-NOMMA-NEXT:stxv vs0, 0(r5)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: disass_pair1:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: disass_pair1:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NOMMA-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NOMMA-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NOMMA-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = load <256 x i1>, <256 x i1>* %ptr1, align 32
+  %1 = tail call { <16 x i8>, <16 x i8> } @llvm.ppc.mma.disassemble.pair(<256 x i1> %0)
+  %2 = extractvalue { <16 x i8>, <16 x i8> } %1, 0
+  %3 = extractvalue { <16 x i8>, <16 x i8> } %1, 1
+  store <16 x i8> %2, <16 x i8>* %ptr2, align 16
+  store <16 x i8> %3, <16 x i8>* %ptr3, align 16
+  ret void
+}
+
 define void @test_ldst_1(<256 x i1>* %vpp, <256 x i1>* %vp2) {
 ; CHECK-LABEL: test_ldst_1:
 ; CHECK:   # %bb.0: # %entry
@@ -127,8 +207,42 @@
   ret void
 }
 
+define void @test_ldst_1a(<256 x i1>* %vpp, <256 x i1>* %vp2) {
+; CHECK-LABEL: test_ldst_1a:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxvp vsp0, 0(r3)
+; CHECK-NEXT:stxvp vsp0, 0(r4)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: test_ldst_1a:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:lxvp vsp0, 0(r3)
+; CHECK-NOMMA-NEXT:stxvp vsp0, 0(r4)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: test_ldst_1a:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxvp vsp0, 0(r3)
+; CHECK-BE-NEXT:stxvp vsp0, 0(r4)
+; CHECK-BE-NEXT:blr
+;

[PATCH] D95976: [OpenMP] Simplify offloading parallel call codegen

2021-04-15 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

Hi @Meinersbur (got word you are a windows user), @jdoerfert, could I ask your 
help in detecting why the clang tests on windows are failing? There are two 
failures I'm spotting, one is that calls to llvm.nvvm intrinsics seem 
transposed (https://reviews.llvm.org/harbormaster/unit/view/552591/) and 
another that attribute regexes are not recognized 
(https://reviews.llvm.org/harbormaster/unit/view/552593/ at 
nvptx_target_codegen.cpp:723:17). Maybe there is something else I'm missing and 
I'd appreciate the extra eyeballing on the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95976

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


[clang] ad2d6bb - Fix potential infinite loop with malformed attribute syntax

2021-04-15 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-15T10:47:32-04:00
New Revision: ad2d6bbb1435cef0a048c9aed3dcf9617640f222

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

LOG: Fix potential infinite loop with malformed attribute syntax

Double square bracket attribute arguments can be arbitrarily complex,
and the attribute argument parsing logic recovers by skipping tokens.
As a fallback recovery mechanism, parse recovery stops before reading a
semicolon. This could lead to an infinite loop in the attribute list
parsing logic.

Added: 


Modified: 
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/c2x-attributes.c
clang/test/Parser/cxx-attributes.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index bc59b41782577..af3d0df53e91b 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4214,7 +4214,7 @@ void 
Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
   llvm::SmallDenseMap SeenAttrs;
 
   bool AttrParsed = false;
-  while (Tok.isNot(tok::r_square)) {
+  while (!Tok.isOneOf(tok::r_square, tok::semi)) {
 if (AttrParsed) {
   // If we parsed an attribute, a comma is required before parsing any
   // additional attributes.
@@ -4279,6 +4279,13 @@ void 
Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
 << AttrName;
   }
 
+  // If we hit an error and recovered by parsing up to a semicolon, eat the
+  // semicolon and don't issue further diagnostics about missing brackets.
+  if (Tok.is(tok::semi)) {
+ConsumeToken();
+return;
+  }
+
   SourceLocation CloseLoc = Tok.getLocation();
   if (ExpectAndConsume(tok::r_square))
 SkipUntil(tok::r_square);

diff  --git a/clang/test/Parser/c2x-attributes.c 
b/clang/test/Parser/c2x-attributes.c
index 48bb19707dd10..d75e9e2d29768 100644
--- a/clang/test/Parser/c2x-attributes.c
+++ b/clang/test/Parser/c2x-attributes.c
@@ -16,6 +16,7 @@ enum { [[]] Six }; // expected-error {{expected identifier}}
 // FIXME: this diagnostic can be improved.
 enum E3 [[]] { Seven }; // expected-error {{expected identifier or '('}}
 
+[[deprecated([""])]] int WrongArgs; // expected-error {{expected expression}}
 [[,]] int Commas1; // ok
 [[,, maybe_unused]] int Commas2; // ok
 [[maybe_unused,,,]] int Commas3; // ok

diff  --git a/clang/test/Parser/cxx-attributes.cpp 
b/clang/test/Parser/cxx-attributes.cpp
index 2b874e4aca7fd..d445e42bfe08e 100644
--- a/clang/test/Parser/cxx-attributes.cpp
+++ b/clang/test/Parser/cxx-attributes.cpp
@@ -35,6 +35,7 @@ void fn() {
   pi = &i[0];
 }
 
+[[deprecated([""])]] int WrongArgs; // expected-error {{expected variable name 
or 'this' in lambda capture list}}
 [[,]] int Commas1; // ok
 [[,, maybe_unused]] int Commas2; // ok
 [[maybe_unused,,,]] int Commas3; // ok



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


[PATCH] D100415: [Coroutines] Split coroutine during CoroEarly into an init and ramp function

2021-04-15 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

@ChuanqiXu Thank you for the detailed review! Really appreciate it.
I agree we should create a coroutine benchmark at some point, ideally some 
realistic production-code driven benchmark. We can work on that in the future. 
For this patch, it's probably not worth it to hide it behind an option, for two 
reasons: 1) it would be extremely complicated, 2) most parameters would end up 
on the frame anyway 3) this patch actually doesn't force parameters to be put 
on the frame. Before frame creation, all the parameters are put back to 
allocas, the current alloca analysis and optimization still applies to them. So 
some parameters may actually end up not put on the frame. So I wouldn't expect 
this to increase frame size in most cases.

I will add documentation latter once the we all agree on the high-level 
idea/direction of this patch.




Comment at: clang/lib/CodeGen/CGCoroutine.cpp:646
 
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::coro_init_end));
+Builder.CreateBr(InitReadyBB);

ChuanqiXu wrote:
> It calls `coro.init.end` without calling `coro.init` in the front which looks 
> odd.
This path is conditionally guarded by `coro.init` alrady.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:193
+F.getName() + ".ramp");
+NewF->addFnAttr(Attribute::NoInline);
+M->getFunctionList().push_back(NewF);

ChuanqiXu wrote:
> Noticed that this patch deletes `F.addFnAttr(CORO_PRESPLIT_ATTR, 
> UNPREPARED_FOR_SPLIT);` below, is it conflicting with `D100282 `. I want to 
> know if we still ned to add `Noinline` attribute once `D100282 ` checked in.
Good question. For now they are somewhat redundant. We probably don't need to 
add NoInline here.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:218
+II->replaceAllUsesWith(
+llvm::ConstantInt::get(llvm::Type::getInt1Ty(C), 0));
+break;

ChuanqiXu wrote:
> Why do we need to replace `coro.alloc` with 0 now?
> Replace `coro.alloc` with 0 implies we should allocate the frame in the 
> stack. I think we can't know how should we allocate the frame now.
This is replacing it in the NewF (the cloned new ramp function). We only need 
to allocate the frame once, which will be done in the init function. So in the 
ramp function we can always skip it.



Comment at: llvm/lib/Transforms/Coroutines/CoroEarly.cpp:333
   CF->setArgOperand(0, CoroId);
+splitRampFunction(F);
+  }

ChuanqiXu wrote:
> Should we give a another name for `splitRampFunction`? It may be surprising 
> to see `split` in Coro-early pass instead of Coro-split pass.
> BTW, how do you think about create the ramp function in the CodeGen process 
> of frontend?
I thought about doing it in CodeGen. But it's really complicated to split 
functions in CodeGen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100415

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


[PATCH] D100507: [Clang][Docs] Claim the atomic compare

2021-04-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100507

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


[clang] 2a95cb5 - [Clang][Docs] Claim the atomic compare

2021-04-15 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-04-15T11:10:15-04:00
New Revision: 2a95cb5858f8bc0fed3956f72bd51bf6a948e660

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

LOG: [Clang][Docs] Claim the atomic compare

I'm working on the implementation of OpenMP 5.1 feature `atomic compare`.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 6a4cdf210131e..74d9a0858e27b 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -264,7 +264,9 @@ want to help with the implementation.
 
+--+--+--+---+
 |Category  | Feature   
   | Status   | Reviews 
  |
 
+==+==+==+===+
-| atomic extension | 'compare' and 'fail' clauses on atomic 
construct | :none:`unclaimed`|  
 |
+| atomic extension | 'compare' clause on atomic construct  
   | :good:`worked on`| 
  |
++--+--+--+---+
+| atomic extension | 'fail' clause on atomic construct 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | base language| C++ attribute specifier syntax
   | :part:`worked on`| 
  |
 
+--+--+--+---+



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


[PATCH] D100507: [Clang][Docs] Claim the atomic compare

2021-04-15 Thread Shilei Tian via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a95cb5858f8: [Clang][Docs] Claim the atomic compare 
(authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100507

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -264,7 +264,9 @@
 
+--+--+--+---+
 |Category  | Feature   
   | Status   | Reviews 
  |
 
+==+==+==+===+
-| atomic extension | 'compare' and 'fail' clauses on atomic 
construct | :none:`unclaimed`|  
 |
+| atomic extension | 'compare' clause on atomic construct  
   | :good:`worked on`| 
  |
++--+--+--+---+
+| atomic extension | 'fail' clause on atomic construct 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | base language| C++ attribute specifier syntax
   | :part:`worked on`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -264,7 +264,9 @@
 +--+--+--+---+
 |Category  | Feature  | Status   | Reviews   |
 +==+==+==+===+
-| atomic extension | 'compare' and 'fail' clauses on atomic construct | :none:`unclaimed`|   |
+| atomic extension | 'compare' clause on atomic construct | :good:`worked on`|   |
++--+--+--+---+
+| atomic extension | 'fail' clause on atomic construct| :none:`unclaimed`|   |
 +--+--+--+---+
 | base language| C++ attribute specifier syntax   | :part:`worked on`|   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added a reviewer: dblaikie.
yonghong-song added projects: debug-info, clang.
yonghong-song requested review of this revision.
Herald added a subscriber: cfe-commits.

Commit e3d8ee35e4ad 
 ("reland 
"[DebugInfo] Support to emit debugInfo
for extern variables"") added support to emit debugInfo for
extern variables if requested by the target. Currently, only
BPF target enables this feature by default.

As BPF ecosystem grows, callback function started to get
support, e.g., recently bpf_for_each_map_elem() is introduced
(https://lwn.net/Articles/846504/) with a callback function as an
argument. In the future we may have something like below as
a demonstration of use case :

  extern int do_work(int);
  long bpf_helper(void *callback_fn, void *callback_ctx, ...);
  long prog_main() {
  struct { ... } ctx = { ... };
  return bpf_helper(&do_work, &ctx, ...);
  }

Basically bpf helper may have a callback function and the
callback function is defined in another file. In this case,
we would like to know the debuginfo types for do_work(), so
the verifier can proper verify the safety of bpf_helper() call.
The do_work() might be a function from another file or from
the kernel.

For the following example,

  extern int do_work(int);
  long bpf_helper(void *callback_fn);
  long prog() {
  return bpf_helper(&do_work);
  }

Currently, there is no debuginfo generated for extern function do_work().
In the IR, we have,

  ...
  define dso_local i64 @prog() local_unnamed_addr #0 !dbg !7 {
  entry:
%call = tail call i64 @bpf_helper(i8* bitcast (i32 (i32)* @do_work to i8*)) 
#2, !dbg !11
ret i64 %call, !dbg !12
  }
  ...
  declare dso_local i32 @do_work(i32) #1
  ...

This patch added support for the above callback function use case, and
the generated IR looks like below:

  ...
  declare !dbg !17 dso_local i32 @do_work(i32) #1
  ...
  !17 = !DISubprogram(name: "do_work", scope: !1, file: !1, line: 1, type: !18, 
flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
  !18 = !DISubroutineType(types: !19)
  !19 = !{!20, !20}
  !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100567

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/debug-info-extern-callback.c


Index: clang/test/CodeGen/debug-info-extern-callback.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-callback.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+
+extern int do_work(int);
+long bpf_helper(void *callback_fn);
+long prog() {
+   return bpf_helper(&do_work);
+}
+
+// CHECK: declare !dbg ![[FUNC:[0-9]+]] i32 @do_work(i32)
+// CHECK: ![[FUNC]] = !DISubprogram(name: "do_work"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2833,8 +2833,19 @@
 return LV;
   }
 
-  if (const auto *FD = dyn_cast(ND))
-return EmitFunctionDeclLValue(*this, E, FD);
+  if (const auto *FD = dyn_cast(ND)) {
+LValue LV = EmitFunctionDeclLValue(*this, E, FD);
+
+// Emit debuginfo for the function declaration if the target wants to.
+if (getContext().getTargetInfo().allowDebugInfoForExternalVar()) {
+  CGDebugInfo *DI = CGM.getModuleDebugInfo();
+  auto *Fn = dyn_cast(LV.getPointer(*this));
+  if (DI && Fn)
+DI->EmitFunctionDecl(FD, FD->getLocation(), T, Fn);
+}
+
+return LV;
+  }
 
   // FIXME: While we're emitting a binding from an enclosing scope, all other
   // DeclRefExprs we see should be implicitly treated as if they also refer to


Index: clang/test/CodeGen/debug-info-extern-callback.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-callback.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+extern int do_work(int);
+long bpf_helper(void *callback_fn);
+long prog() {
+	return bpf_helper(&do_work);
+}
+
+// CHECK: declare !dbg ![[FUNC:[0-9]+]] i32 @do_work(i32)
+// CHECK: ![[FUNC]] = !DISubprogram(name: "do_work"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2833,8 +2833,19 @@
 return LV;
   }
 
-  if (const auto *FD = dyn_cast(ND))
-return EmitFunctionDeclLValue(*this, E, FD);
+  if (const auto *FD = dyn_cast(ND)) {
+LValue LV = EmitFunctionDeclLValue(*this, E, FD);
+
+// Emit debuginfo for the function declaration if the target wants to.
+if (getContext().getTargetInfo().allowDebugInfoForExternalVar()) {
+

[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-15 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast accepted this revision.
ast added a comment.
This revision is now accepted and ready to land.

Makes sense to me. Only BPF target will notice this difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100567

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


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

2021-04-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 337778.
pzheng added a comment.

Address @jansvoboda11's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1163,6 +1163,42 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
+  if (!MF.getTarget().Options.EmitStackUsage)
+return;
+
+  const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+  if (OutputFilename.empty()) {
+SmallString<128> Val = MF.getFunction().getParent()->getName();
+
+llvm::sys::path::replace_extension(Val, "su");
+OutputFilename = std::string(Val.str());
+  }
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ":" << DSP->getLine();
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
   MachineModuleInfo &MMI = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1447,6 +1483,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -130,7 +130,7 @@
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
   DisableIntegratedAS(false), RelaxELFRelocations(false),
-  FunctionSections(false), DataSections(false),
+  FunctionSections(false), DataSections(false), EmitStackUsage(false),
   IgnoreXCOFFVisibility(false), XCOFFTracebackTable(true),
   UniqueSectionNames(true), UniqueBasicBlockSectionNames(false),
   TrapUnreachable(false), NoTrapAfterNoreturn(false), TLSSize(0),
@@ -249,6 +249,9 @@
 /// Emit data into separate sections.
 unsigned DataSections : 1;
 
+/// Emit .su file containing information on function stack sizes.
+unsigned EmitStackUsage : 1;
+
 /// Do not emit visibility attribute for xcoff.
 unsigned IgnoreXCOFFVisibility : 1;
 
@@ -341,6 +344,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file). If empty, the name of the
+/// source file should be used to name the stack usage file (e.g., foo.su
+/// for foo.c)
+std::string StackUsageOutput = "";
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -175,6 +175,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream = nullptr;
+
   static char ID;
 
 protected:
@@ -351,6 +354,8 @@
 
   void emitStackSizeSection(const MachineFunction &MF);
 
+  void emitStackUsage(const MachineFunction &MF);
+
   void emitBBAddrMapSection(const MachineFunction &MF);
 
   void emitPseudoProbe(const MachineInstr &MI);
Index: clang/test/Driver/stack-usag

[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

The corresponding clang patch is here: https://reviews.llvm.org/D100567


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100567

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


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

2021-04-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng marked 3 inline comments as done.
pzheng added a comment.

Thanks for your feedback, @jansvoboda11!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:296-298
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
   " with attribute 'no_caller_saved_registers'">;

You still need to add the diagnostic to a diagnostic group, otherwise users 
don't have a way to selectively disable the diagnostic.

Feel free to pick a different group for the -W flag; I just took a stab at a 
possible name.

This should fix the failing CI pipelines too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

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


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

2021-04-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

It would be great to also update release notes for clang to inform users about 
this new feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})

JonChesterfield wrote:
> JonChesterfield wrote:
> > gregrodgers wrote:
> > > What happens when /opt/rocm is not available?   Again, we need a 
> > > cross-architecture mechanism to identify the offload-arch. 
> > Exactly the same as the amdgpu plugin. The cmake detection is char for char 
> > identical. This will look in CMAKE_INSTALL_PREFIX, which is where I install 
> > these libs when using trunk, and falls back to /opt/rocm which seems to be 
> > convenient for some users.
> Which may need revising at some point - I like installing hsa as if it was an 
> llvm subcomponent, but other people might want a different convention. As 
> long as we remember to change this file + amdgpu's cmake at the same time, 
> all good.
/opt/tocm will not work with the side-by-side ROCm installation which installs 
ROCm in directories with the version number. Should there be the ability to 
configure this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100187: [OPENMP]Fix PR49115: Incorrect results for scan directive.

2021-04-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 accepted this revision.
jyu2 added a comment.
This revision is now accepted and ready to land.

The change looks good to me.  I am new to this.  You may want to give more time 
for others


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100187

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


[PATCH] D100552: [HIP] Diagnose compiling kernel without offload arch

2021-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Drive-by comment on the diagnostic wording.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8260
+def err_hip_kern_without_gpu : Error<
+  "compile HIP kernel without specifying offload arch is not allowed">,
+  DefaultFatal;




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

https://reviews.llvm.org/D100552

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-15 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:8673
+// reference if an implementation supports them in kernel parameters.
+if (!PointeeType->isAtomicType() && !PointeeType->isVoidType() &&
+!PointeeType->isStandardLayoutType())

Anastasia wrote:
> svenvh wrote:
> > I am wondering if this should be made conditional on C++ mode?  Or is there 
> > no possible way that this new `return InvalidKernelParam` can be triggered 
> > from OpenCL C mode?
> I think it shouldn't because C types are POD types which is a superset of 
> standard layout types.
> 
I believe these rules are correct, but just in case they are not, I will make 
it conditional on C++ mode to not accidentally break OpenCL C.


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

https://reviews.llvm.org/D100471

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})

t-tye wrote:
> JonChesterfield wrote:
> > JonChesterfield wrote:
> > > gregrodgers wrote:
> > > > What happens when /opt/rocm is not available?   Again, we need a 
> > > > cross-architecture mechanism to identify the offload-arch. 
> > > Exactly the same as the amdgpu plugin. The cmake detection is char for 
> > > char identical. This will look in CMAKE_INSTALL_PREFIX, which is where I 
> > > install these libs when using trunk, and falls back to /opt/rocm which 
> > > seems to be convenient for some users.
> > Which may need revising at some point - I like installing hsa as if it was 
> > an llvm subcomponent, but other people might want a different convention. 
> > As long as we remember to change this file + amdgpu's cmake at the same 
> > time, all good.
> /opt/tocm will not work with the side-by-side ROCm installation which 
> installs ROCm in directories with the version number. Should there be the 
> ability to configure this?
If /opt/rocm isn't a safe out of the box option for finding rocm, let's remove 
that from here and the amdgpu plugin. Pre-existing hazard so doesn't need to 
block this patch.

I'm installing roct and rocr to the same CMAKE_INSTALL_PREFIX as llvm which is 
why the first clause works out.

How are the rocm components meant to find the corresponding pieces? If there's 
a rocm cmake install dir variable we could add that to the hints.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337789.
mibintc marked an inline comment as done.
mibintc added a comment.

I added the InGroup rule for the new warning diagnostic like Aaron requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-x86-interrupt.c


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function 
with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's VFP registers">,
InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

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


[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-15 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse updated this revision to Diff 337793.
jmorse added a comment.

Right you are -- another thing I didn't clock was that this test was running 
all of the LLVM passes (generating many instances of the coroutine function). 
Latest revision disables those passes so that there are only DILocalVariables 
for the un-coro-split function. I've confirmed this fails before the fix landed 
and passes afterwards.


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

https://reviews.llvm.org/D100298

Files:
  clang/test/CodeGenCoroutines/coro-dwarf.cpp


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 
-debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:-emit-llvm -o - %s | \
+// RUN:FileCheck %s --implicit-check-not=DILocalVariable
 
 namespace std::experimental {
 template  struct coroutine_traits;
@@ -64,14 +67,6 @@
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: 
"_Z6f_coroi8MoveOnly11MoveAndCopy"
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:-emit-llvm -o - %s | \
+// RUN:FileCheck %s --implicit-check-not=DILocalVariable
 
 namespace std::experimental {
 template  struct coroutine_traits;
@@ -64,14 +67,6 @@
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy"
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
 // CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-15 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 337797.
cchen added a comment.

Update test and fix code format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/masked_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1788,6 +1788,88 @@
   EXPECT_EQ(MasterEndCI->getArgOperand(1), MasterEntryCI->getArgOperand(1));
 }
 
+TEST_F(OpenMPIRBuilderTest, MaskedDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = nullptr;
+
+  BasicBlock *EntryBB = nullptr;
+  BasicBlock *ExitBB = nullptr;
+  BasicBlock *ThenBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+if (AllocaIP.isSet())
+  Builder.restoreIP(AllocaIP);
+else
+  Builder.SetInsertPoint(&*(F->getEntryBlock().getFirstInsertionPt()));
+PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+Builder.CreateStore(F->arg_begin(), PrivAI);
+
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+
+Builder.restoreIP(CodeGenIP);
+
+// collect some info for checks later
+ExitBB = FiniBB.getUniqueSuccessor();
+ThenBB = Builder.GetInsertBlock();
+EntryBB = ThenBB->getUniquePredecessor();
+
+// simple instructions for body
+Value *PrivLoad =
+Builder.CreateLoad(PrivAI->getAllocatedType(), PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Constant *Filter = ConstantInt::get(Type::getInt32Ty(M->getContext()), 0);
+  Builder.restoreIP(
+  OMPBuilder.createMasked(Builder, BodyGenCB, FiniCB, Filter));
+  Value *EntryBBTI = EntryBB->getTerminator();
+  EXPECT_NE(EntryBBTI, nullptr);
+  EXPECT_TRUE(isa(EntryBBTI));
+  BranchInst *EntryBr = cast(EntryBB->getTerminator());
+  EXPECT_TRUE(EntryBr->isConditional());
+  EXPECT_EQ(EntryBr->getSuccessor(0), ThenBB);
+  EXPECT_EQ(ThenBB->getUniqueSuccessor(), ExitBB);
+  EXPECT_EQ(EntryBr->getSuccessor(1), ExitBB);
+
+  CmpInst *CondInst = cast(EntryBr->getCondition());
+  EXPECT_TRUE(isa(CondInst->getOperand(0)));
+
+  CallInst *MaskedEntryCI = cast(CondInst->getOperand(0));
+  EXPECT_EQ(MaskedEntryCI->getNumArgOperands(), 3U);
+  EXPECT_EQ(MaskedEntryCI->getCalledFunction()->getName(), "__kmpc_masked");
+  EXPECT_TRUE(isa(MaskedEntryCI->getArgOperand(0)));
+
+  CallInst *MaskedEndCI = nullptr;
+  for (auto &FI : *ThenBB) {
+Instruction *cur = &FI;
+if (isa(cur)) {
+  MaskedEndCI = cast(cur);
+  if (MaskedEndCI->getCalledFunction()->getName() == "__kmpc_end_masked")
+break;
+  MaskedEndCI = nullptr;
+}
+  }
+  EXPECT_NE(MaskedEndCI, nullptr);
+  EXPECT_EQ(MaskedEndCI->getNumArgOperands(), 2U);
+  EXPECT_TRUE(isa(MaskedEndCI->getArgOperand(0)));
+  EXPECT_EQ(MaskedEndCI->getArgOperand(1), MaskedEntryCI->getArgOperand(1));
+}
+
 TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -901,6 +901,30 @@
   /*Conditional*/ true, /*hasFinalize*/ true);
 }
 
+OpenMPIRBuilder::InsertPointTy
+OpenMPIRBuilder::createMasked(const LocationDescription &Loc,
+  BodyGenCallbackTy BodyGenCB,
+  FinalizeCallbackTy FiniCB, Value *Filter) {
+  if (!updateToLocation(Loc))
+return Loc.IP;
+
+  Directive OMPD = Directive::OMPD_masked;
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *ThreadId = getOrCreateThreadID(Ident);
+  Value *Args[] = {Ident, ThreadId, Filter};
+  Value *ArgsEnd[] = {Ident, ThreadId};
+
+  Function *EntryRTLFn = getOrCreateRuntimeFuncti

[clang] 99eca1b - [Driver] Enable kernel address and memory sanitizers on FreeBSD

2021-04-15 Thread Alex Richardson via cfe-commits

Author: Mark Johnston
Date: 2021-04-15T17:49:00+01:00
New Revision: 99eca1bd9c7ac8de4caba0733c3079ff93b65deb

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

LOG: [Driver] Enable kernel address and memory sanitizers on FreeBSD

Test Plan: using kernel ASAN and MSAN implementations in FreeBSD

Reviewed By: emaste, dim, arichardson

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index c508af655ac2c..f8c6a81bf3bc0 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -467,6 +467,7 @@ bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) 
const { return true; }
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsMIPS64 = getTriple().isMIPS64();
@@ -485,8 +486,13 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const {
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
-  if (IsX86_64)
+  if (IsAArch64 || IsX86_64) {
+Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelMemory;
+  }
+  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
+  }
   return Res;
 }
 

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 5686d58d8e2f2..7febfd02a1ad7 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -695,7 +695,13 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-address %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-address %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// KERNEL-ADDRESS-FREEBSD: "-fsanitize=kernel-address"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-memory %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// KERNEL-MEMORY-FREEBSD: "-fsanitize=kernel-memory"
 
 // * NetBSD; please keep ordered as in Sanitizers.def *
 



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


[PATCH] D98286: [Driver] Enable kernel address and memory sanitizers on FreeBSD

2021-04-15 Thread Alexander Richardson 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 rG99eca1bd9c7a: [Driver] Enable kernel address and memory 
sanitizers on FreeBSD (authored by markj, committed by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98286

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -695,7 +695,13 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-address %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-address %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// KERNEL-ADDRESS-FREEBSD: "-fsanitize=kernel-address"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-memory %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// KERNEL-MEMORY-FREEBSD: "-fsanitize=kernel-memory"
 
 // * NetBSD; please keep ordered as in Sanitizers.def *
 
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -467,6 +467,7 @@
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsMIPS64 = getTriple().isMIPS64();
@@ -485,8 +486,13 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
-  if (IsX86_64)
+  if (IsAArch64 || IsX86_64) {
+Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelMemory;
+  }
+  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
+  }
   return Res;
 }
 


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -695,7 +695,13 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-address %s -### 2>&1 | FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-address %s -### 2>&1 | FileCheck %s -check-prefix=KERNEL-ADDRESS-FREEBSD
+// KERNEL-ADDRESS-FREEBSD: "-fsanitize=kernel-address"
 
+// RUN: %clang -target x86_64--freebsd -fsanitize=kernel-memory %s -### 2>&1 | FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// RUN: %clang -target aarch64--freebsd -fsanitize=kernel-memory %s -### 2>&1 | FileCheck %s -check-prefix=KERNEL-MEMORY-FREEBSD
+// KERNEL-MEMORY-FREEBSD: "-fsanitize=kernel-memory"
 
 // * NetBSD; please keep ordered as in Sanitizers.def *
 
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -467,6 +467,7 @@
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsMIPS64 = getTriple().isMIPS64();
@@ -485,8 +486,13 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
-  if (IsX86_64)
+  if (IsAArch64 || IsX86_64) {
+Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelMemory;
+  }
+  if (IsX86_64) {
 Res |= SanitizerKind::Memory;
+  }
   return Res;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c8f0a7c - [NewPM] Cleanup IR printing instrumentation

2021-04-15 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-04-15T09:50:55-07:00
New Revision: c8f0a7c215ab4c08ed2f5ac53f080adbb54714ab

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

LOG: [NewPM] Cleanup IR printing instrumentation

Being lazy with printing the banner seems hard to reason with, we should print 
it
unconditionally first (it could also lead to duplicate banners if we
have multiple functions in -filter-print-funcs).

The printIR() functions were doing too many things. I separated out the
call from PrintPassInstrumentation since we were essentially doing two
completely separate things in printIR() from different callers.

There were multiple ways to generate the name of some IR. That's all
been moved to getIRName(). The printing of the IR name was also
inconsistent, now it's always "IR Dump on $foo" where "$foo" is the
name. For a function, it's the function name. For a loop, it's what's
printed by Loop::print(), which is more detailed. For an SCC, it's the
list of functions in parentheses. For a module it's "[module]", to
differentiate between a possible SCC with a function called "module".

To preserve D74814, we have to check if we're going to print anything at
all first. This is unfortunate, but I would consider this a special
case that shouldn't be handled in the core logic.

Reviewed By: jamieschmeiser

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

Added: 


Modified: 
clang/test/CodeGen/sanitizer-module-constructor.c
clang/test/Misc/printer.c
llvm/include/llvm/Analysis/LoopInfo.h
llvm/include/llvm/Analysis/LoopInfoImpl.h
llvm/lib/Analysis/LoopInfo.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
llvm/test/Other/ChangePrinters/print-changed-diff.ll
llvm/test/Other/change-printer.ll
llvm/test/Other/loop-deletion-printer.ll
llvm/test/Other/loop-pass-printer.ll
llvm/test/Other/module-pass-printer.ll
llvm/test/Other/opt-bisect-new-pass-manager.ll
llvm/test/Other/print-module-scope.ll
llvm/test/Other/scc-deleted-printer.ll
llvm/test/Other/scc-pass-printer.ll
llvm/test/ThinLTO/X86/printer.ll

Removed: 




diff  --git a/clang/test/CodeGen/sanitizer-module-constructor.c 
b/clang/test/CodeGen/sanitizer-module-constructor.c
index 3e29a923a9f16..108cdcb892a68 100644
--- a/clang/test/CodeGen/sanitizer-module-constructor.c
+++ b/clang/test/CodeGen/sanitizer-module-constructor.c
@@ -16,6 +16,6 @@ static void f(b g) {
 }
 void h() { f(e); }
 
-// CHECK: Running pass: {{.*}}SanitizerPass on 
{{.*}}sanitizer-module-constructor.c
+// CHECK: Running pass: {{.*}}SanitizerPass
 // CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor
 // CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor

diff  --git a/clang/test/Misc/printer.c b/clang/test/Misc/printer.c
index 085e02cbe5cee..339dda4b4e566 100644
--- a/clang/test/Misc/printer.c
+++ b/clang/test/Misc/printer.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-before-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE
 // RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER
-// CHECK-BEFORE: *** IR Dump Before AlwaysInlinerPass ***
-// CHECK-AFTER: *** IR Dump After AlwaysInlinerPass ***
+// CHECK-BEFORE: *** IR Dump Before AlwaysInlinerPass
+// CHECK-AFTER: *** IR Dump After AlwaysInlinerPass
 void foo() {}

diff  --git a/llvm/include/llvm/Analysis/LoopInfo.h 
b/llvm/include/llvm/Analysis/LoopInfo.h
index c2c68004a9f9c..2fdab3ac6dd80 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -479,7 +479,8 @@ template  class LoopBase {
   bool isAnnotatedParallel() const { return false; }
 
   /// Print loop with all the BBs inside it.
-  void print(raw_ostream &OS, unsigned Depth = 0, bool Verbose = false) const;
+  void print(raw_ostream &OS, bool Verbose = false, bool PrintNested = true,
+ unsigned Depth = 0) const;
 
 protected:
   friend class LoopInfoBase;

diff  --git a/llvm/include/llvm/Analysis/LoopInfoImpl.h 
b/llvm/include/llvm/Analysis/LoopInfoImpl.h
index ca44d03f57cb3..2cc9afb7c2cd8 100644
--- a/llvm/include/llvm/Analysis/LoopInfoImpl.h
+++ b/llvm/include/llvm/Analysis/LoopInfoImpl.h
@@ -381,8 +381,8 @@ void LoopBase::verifyLoopNest(
 }
 
 template 
-void LoopBase::print(raw_ostream &OS, unsigned Depth,
-bool Verbose) const {
+void LoopBase::print(raw_ostream &OS, bool Verbose,
+bool PrintNested, unsigned Depth) const {
   OS.indent(Depth * 2);
   if (static_cast(this)->isAnnotatedParallel())
 OS << "Parallel ";
@@ -407,10 

[PATCH] D100231: [NewPM] Cleanup IR printing instrumentation

2021-04-15 Thread Arthur Eubanks 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 rGc8f0a7c215ab: [NewPM] Cleanup IR printing instrumentation 
(authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100231

Files:
  clang/test/CodeGen/sanitizer-module-constructor.c
  clang/test/Misc/printer.c
  llvm/include/llvm/Analysis/LoopInfo.h
  llvm/include/llvm/Analysis/LoopInfoImpl.h
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
  llvm/test/Other/ChangePrinters/print-changed-diff.ll
  llvm/test/Other/change-printer.ll
  llvm/test/Other/loop-deletion-printer.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/module-pass-printer.ll
  llvm/test/Other/opt-bisect-new-pass-manager.ll
  llvm/test/Other/print-module-scope.ll
  llvm/test/Other/scc-deleted-printer.ll
  llvm/test/Other/scc-pass-printer.ll
  llvm/test/ThinLTO/X86/printer.ll

Index: llvm/test/ThinLTO/X86/printer.ll
===
--- llvm/test/ThinLTO/X86/printer.ll
+++ llvm/test/ThinLTO/X86/printer.ll
@@ -1,8 +1,8 @@
 ; RUN: llvm-as %s -o %t.bc
 ; RUN: llvm-lto2 run -r=%t.bc,foo,pxl -use-new-pm --print-before-all %t.bc -o %t2 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE
 ; RUN: llvm-lto2 run -r=%t.bc,foo,pxl -use-new-pm --print-after-all %t.bc -o %t3 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER
-; CHECK-BEFORE: *** IR Dump Before GlobalDCEPass ***
-; CHECK-AFTER: *** IR Dump After GlobalDCEPass ***
+; CHECK-BEFORE: *** IR Dump Before GlobalDCEPass
+; CHECK-AFTER: *** IR Dump After GlobalDCEPass
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Other/scc-pass-printer.ll
===
--- llvm/test/Other/scc-pass-printer.ll
+++ llvm/test/Other/scc-pass-printer.ll
@@ -20,12 +20,12 @@
 ; LEGACY: define void @tester()
 ; LEGACY-NEXT:  call void @foo()
 
-; INL:  IR Dump After InlinerPass *** (scc: (foo, bar))
+; INL:  IR Dump After InlinerPass on (foo, bar) ***
 ; INL:  define void @foo()
 ; INL-NEXT:   call void @bar()
 ; INL:  define void @bar()
 ; INL-NEXT:   call void @foo()
-; INL:  IR Dump After InlinerPass *** (scc: (tester))
+; INL:  IR Dump After InlinerPass on (tester) ***
 ; INL:  define void @tester()
 ; INL-NEXT:   call void @foo()
 
@@ -35,7 +35,7 @@
 ; LEGACY-MOD:  define void @foo()
 ; LEGACY-MOD:  define void @bar()
 
-; INL-MOD-LABEL:*** IR Dump After InlinerPass *** (scc: (foo, bar))
+; INL-MOD-LABEL:*** IR Dump After InlinerPass on (foo, bar) ***
 ; INL-MOD-NEXT: ModuleID =
 ; INL-MOD-NEXT: source_filename =
 ; INL-MOD: define void @tester()
@@ -44,7 +44,7 @@
 ; INL-MOD-NEXT:  call void @bar()
 ; INL-MOD: define void @bar()
 ; INL-MOD-NEXT:   call void @foo()
-; INL-MOD-LABEL:*** IR Dump After InlinerPass *** (scc: (tester))
+; INL-MOD-LABEL:*** IR Dump After InlinerPass on (tester) ***
 ; INL-MOD-NEXT: ModuleID =
 ; INL-MOD-NEXT: source_filename =
 ; INL-MOD: define void @tester()
Index: llvm/test/Other/scc-deleted-printer.ll
===
--- llvm/test/Other/scc-deleted-printer.ll
+++ llvm/test/Other/scc-deleted-printer.ll
@@ -3,15 +3,15 @@
 ; RUN: opt < %s 2>&1 -disable-output \
 ; RUN: 	   -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s -check-prefix=INL-MOD
 
-; INL: IR Dump Before {{InlinerPass .*scc: .tester, foo}}
+; INL: IR Dump Before InlinerPass on (tester, foo)
 ; INL-NOT: IR Dump After {{InlinerPass}}
-; INL: IR Dump Before {{InlinerPass .*scc: .tester}}
-; INL: IR Dump After {{InlinerPass .*scc: .tester}}
+; INL: IR Dump Before InlinerPass on (tester)
+; INL: IR Dump After InlinerPass on (tester)
 
-; INL-MOD: IR Dump Before {{InlinerPass .*scc: .tester, foo}}
-; INL-MOD: IR Dump After {{InlinerPass .*invalidated: .*scc: .tester, foo}}
-; INL-MOD: IR Dump Before {{InlinerPass .*scc: .tester}}
-; INL-MOD: IR Dump After {{InlinerPass .*scc: .tester}}
+; INL-MOD: IR Dump Before InlinerPass on (tester, foo)
+; INL-MOD: IR Dump After InlinerPass on (tester, foo) (invalidated)
+; INL-MOD: IR Dump Before InlinerPass on (tester)
+; INL-MOD: IR Dump After InlinerPass on (tester)
 
 
 define void @tester() noinline {
Index: llvm/test/Other/print-module-scope.ll
===
--- llvm/test/Other/print-module-scope.ll
+++ llvm/test/Other/print-module-scope.ll
@@ -16,22 +16,18 @@
 ; RUN: 	   -passes=simplify-cfg -print-after-all -filter-print-funcs=foo -print-module-scope \
 ; RUN:	   | FileCheck %s -check-prefix=FOO
 
-; CFG:  IR Dump After {{Simplify the CFG|SimplifyCFGPass}}
-; CFG-SAME:   function: foo
+; CFG:  IR Dump

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

2021-04-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 337802.
pzheng added a comment.

Mention the flag in release notes based on @xbolva00's comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1163,6 +1163,42 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
+  if (!MF.getTarget().Options.EmitStackUsage)
+return;
+
+  const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+  if (OutputFilename.empty()) {
+SmallString<128> Val = MF.getFunction().getParent()->getName();
+
+llvm::sys::path::replace_extension(Val, "su");
+OutputFilename = std::string(Val.str());
+  }
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ":" << DSP->getLine();
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
   MachineModuleInfo &MMI = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1447,6 +1483,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -130,7 +130,7 @@
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
   DisableIntegratedAS(false), RelaxELFRelocations(false),
-  FunctionSections(false), DataSections(false),
+  FunctionSections(false), DataSections(false), EmitStackUsage(false),
   IgnoreXCOFFVisibility(false), XCOFFTracebackTable(true),
   UniqueSectionNames(true), UniqueBasicBlockSectionNames(false),
   TrapUnreachable(false), NoTrapAfterNoreturn(false), TLSSize(0),
@@ -249,6 +249,9 @@
 /// Emit data into separate sections.
 unsigned DataSections : 1;
 
+/// Emit .su file containing information on function stack sizes.
+unsigned EmitStackUsage : 1;
+
 /// Do not emit visibility attribute for xcoff.
 unsigned IgnoreXCOFFVisibility : 1;
 
@@ -341,6 +344,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file). If empty, the name of the
+/// source file should be used to name the stack usage file (e.g., foo.su
+/// for foo.c)
+std::string StackUsageOutput = "";
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -175,6 +175,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream = nullptr;
+
   static char ID;
 
 protected:
@@ -351,6 +354,8 @@
 
   void emitStackSizeSection(const MachineFunction &MF);
 
+  void emitStackUsage(const MachineFunction &MF);
+
   void emitBBAddrMapSection(const MachineFunction &MF);
 
   void emitPseudoProbe(

[PATCH] D100467: [clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions

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

lgtm, micro readability suggestion




Comment at: clang/lib/CodeGen/TargetInfo.cpp:5691
+  // no special handling of HFAs/HVAs.
+  if (isHomogeneousAggregate(Ty, Base, Members) && (!IsWin64 || !IsVariadic)) {
 return ABIArgInfo::getDirect(

nit: I feel like this would be more readable and short-circuit better:
  bool IsWinVariadic = IsWin64 && IsVariadic;
  if (!IsWinVariadic && isHomogeneousAggregate(...)) {


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100467

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


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

2021-04-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>> ::  

gcc also supports "bounded" - do you plan to somehow handle it? 
(https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options), 
eg: parser.c:918:5:parse_statement  48  dynamic,bounded




Comment at: clang/test/CodeGen/stack-usage.c:7
+// RUN: FileCheck %s < %T/b.su
+// RUN: %clang_cc1 -triple arm-unknown -fstack-usage -fstack-usage=%T/c.su 
-emit-obj %s -o %T/c.o
+// RUN: FileCheck %s < %T/c.su

-fstack-usage=file.su is Clang only, right? Tried with GCC, gcc error: 
unrecognized command-line option ‘-fstack-usage=xxx’,

Do we need to also specify extra -fstack-usage if -fstack-usage=file.su  is 
used? Seems quite redudant and -fstack-usage=file.su alone should be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[clang] 938b863 - [clang][patch] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-04-15T13:11:33-04:00
New Revision: 938b863bb53f033c916d4e8d9a18cbd063656011

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

LOG: [clang][patch] Modify diagnostic level from err to warn: 
anyx86_interrupt_regsave

Reviewed By: Aaron Ballman

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/attr-x86-interrupt.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index afef86ab5890..c84fd4da0fd4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@ def err_anyx86_interrupt_attribute : Error<
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2ea5775eaaa0..38c25ca65374 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }

diff  --git a/clang/test/Sema/attr-x86-interrupt.c 
b/clang/test/Sema/attr-x86-interrupt.c
index 952433e2cb8a..564704a56477 100644
--- a/clang/test/Sema/attr-x86-interrupt.c
+++ b/clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@ typedef unsigned int Arg2Type;
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function 
with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {



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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG938b863bb53f: [clang][patch] Modify diagnostic level from 
err to warn… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100511

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-x86-interrupt.c


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function 
with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's VFP registers">,
InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2021-04-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D45639#2383754 , @smeenai wrote:

> Just following up on this, cos I'm curious :) I have 12.1 now, and I still 
> only see the C++ headers in the toolchain and not in any of the SDKs.

Look in Xcode 12.5 beta 3, you should see libc++ headers in the SDK. You'll 
also see headers alongside Clang, however those are not being used. They are 
just there for some internal reasons but eventually we'll have only one copy of 
the headers, and they'll be in the SDK.

As I explained in https://reviews.llvm.org/D45639#2360267, I think this is the 
right way forward. We want LLVM Clang to prefer the libc++.dylib (and headers) 
shipped in the toolchain if those are present, since that's the most consistent 
approach.

Just one question: with this patch, do we prefer the library in the SDK or the 
one in the toolchain if both are present? Can we get into trouble if we have 
both paths on the `-L` list? I'm trying to think of subtle issues like:

  /lib/libc++.a
  /lib/libc++.dylib

Which one would we pick here?


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

https://reviews.llvm.org/D45639

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


[PATCH] D98995: [CGAtomic] Lift stronger requirements on cmpxch and add support for acquire failure mode

2021-04-15 Thread Julian Lettner via Phabricator via cfe-commits
yln added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:444-447
+// Prior to c++17, "the failure argument shall be no stronger than the
+// success argument". This condition has been lifted and the only
+// precondition is 31.7.2.18. Effectively treat this as a DR and skip
+// language version checks.

Should the following assert in `AtomicCmpXchgInst::Init()` have been changed as 
well?
```
assert(!isStrongerThan(FailureOrdering, SuccessOrdering) &&
   "AtomicCmpXchg failure argument shall be no stronger than the success "
   "argument");
```
https://github.com/llvm/llvm-project/blob/dad5caa59e6b2bde8d6cf5b64a972c393c526c82/llvm/lib/IR/Instructions.cpp#L1561

I am observing a crash on an internal code base most likely caused by this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98995

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


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

2021-04-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng added a comment.

In D100509#2692127 , @xbolva00 wrote:

>>> ::  
>
> gcc also supports "bounded" - do you plan to somehow handle it? 
> (https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options),
>  eg: parser.c:918:5:parse_statement  48  dynamic,bounded

I actually tried some test cases using GCC and never got it to output 
"dynamic,bounded." So, not sure how (or when) GCC actually determines a 
function is dynamic, but bounded. Any idea?




Comment at: clang/test/CodeGen/stack-usage.c:7
+// RUN: FileCheck %s < %T/b.su
+// RUN: %clang_cc1 -triple arm-unknown -fstack-usage -fstack-usage=%T/c.su 
-emit-obj %s -o %T/c.o
+// RUN: FileCheck %s < %T/c.su

xbolva00 wrote:
> -fstack-usage=file.su is Clang only, right? Tried with GCC, gcc error: 
> unrecognized command-line option ‘-fstack-usage=xxx’,
> 
> Do we need to also specify extra -fstack-usage if -fstack-usage=file.su  is 
> used? Seems quite redudant and -fstack-usage=file.su alone should be enough.
Yes, -fstack-usage=file.su is Clang only and it is only a cc1 option, **not ** 
a driver option. The main reason why I added both flags is to distinguish 
between the case where the user specified "-o" and the case where "-o" is not 
specified.

If only -fstack-usage is passed to cc1, we know the user did not pass "-o" on 
the command line and the name (with the extension removed) of the source file 
should be used to name the .su file. For example, with "clang -fstack-usage -c 
foo.c", foo.su is generated.

If both -fstack-usage and -fstack-usage= are present, we know the user 
specified "-o" and the name of the .su file should be based on that name 
instead. For example, with "clang -fstack-usage -c foo.c -o bar.o", bar.su is 
generated instead of foo.su.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

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


[PATCH] D100502: Allow lib64 in driver test

2021-04-15 Thread Troy Johnson via Phabricator via cfe-commits
troyj updated this revision to Diff 337827.
troyj added a comment.

Correct + to *.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100502

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
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
 // 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
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
 // 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] D98783: [CUDA][HIP] Remove unused addr space casts

2021-04-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D98783#2657656 , @rjmccall wrote:

> In D98783#2642269 , @tra wrote:
>
>> We may want to add someone with more expertise with the IR as a reviewer. 
>> I'd like an educated opinion on whether the invisible dangling IR is 
>> something that needs fixing in general or if it's OK to just clean it up in 
>> this particular case. Or both.
>>
>> @rjmccall, @rsmith -- do you have any suggestions -- either on the subject 
>> of the invisible dangling IR or on who may be the right person to talk to?
>
> If Clang is creating constants unnecessarily, we should try to avoid that on 
> general compile time / memory usage grounds unless doing so is a serious 
> problem.  But I don't think it should be our responsibility to GC unused 
> constant expressions in order to make DCE work.
>
> It's extremely common to create `bitcast` global constants.  So the fact that 
> this happens with `addrspacecast`s but hasn't been a persistent problem with 
> `bitcast`s makes more suspect that DCE actually tries to handle this, but 
> something about what it's doing isn't aware of `addrspacecast`.  And indeed, 
> LLVM's GlobalDCE seems to call a method called `removeDeadConstantUsers()` 
> before concluding that a constant can't be thrown away.  So either you're 
> using a different transform that needs to do the same thing, or something is 
> stopping `removeDeadConstantUsers()` from eliminating this `addrspacecast`.

You are right. GlobalDCE is able to remove the dead addr space casts added by 
clang. The reason why the useless global variables are not internalized is that 
the internalization pass is done before GlobalDCE, whereas the internalization 
pass only internalizes useless global variables. To be able to internalize 
global variables with dead users, I need to add another GlobalDCE before 
internalization pass.


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

https://reviews.llvm.org/D98783

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


[PATCH] D98783: [AMDGPU] Add GlobalDCE before internalization pass

2021-04-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 337825.
yaxunl retitled this revision from "[CUDA][HIP] Remove unused addr space casts" 
to "[AMDGPU] Add GlobalDCE before internalization pass".
yaxunl edited the summary of this revision.
yaxunl added a reviewer: rampitec.
yaxunl added a comment.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, 
dstuttard, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.

Add GlobalDCE before internalization pass.


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

https://reviews.llvm.org/D98783

Files:
  clang/test/CodeGenCUDA/unused-global-var.cu
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -578,6 +578,9 @@
 PM.addPass(AMDGPUPrintfRuntimeBindingPass());
 
 if (InternalizeSymbols) {
+  // Global variables may have dead uses which need to be removed.
+  // Otherwise these useless global variables will not get 
internalized.
+  PM.addPass(GlobalDCEPass());
   PM.addPass(InternalizePass(mustPreserveGV));
 }
 PM.addPass(AMDGPUPropagateAttributesLatePass(*this));
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -0,0 +1,50 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -std=c++11 -O3 -mllvm -amdgpu-internalize-symbols -emit-llvm -o - \
+// RUN:   -target-cpu gfx906 | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// AMDGPU internalize unused global variables for whole-program compilation
+// (-fno-gpu-rdc for each TU, or -fgpu-rdc for LTO), which are then
+// eliminated by global DCE. If there are invisible unused address space casts
+// for global variables, the internalization and elimination of unused global
+// variales will be hindered. This test makes sure no such address space
+// casts.
+
+// Check unused device/constant variables are eliminated.
+
+// CHECK-NOT: @v1
+__device__ int v1;
+
+// CHECK-NOT: @v2
+__constant__ int v2;
+
+// CHECK-NOT: @_ZL2v3
+constexpr int v3 = 1;
+
+// Check managed variables are always kept.
+
+// CHECK: @v4
+__managed__ int v4;
+
+// Check used device/constant variables are not eliminated.
+// CHECK: @u1
+__device__ int u1;
+
+// CHECK: @u2
+__constant__ int u2;
+
+// Check u3 is kept because its address is taken.
+// CHECK: @_ZL2u3
+constexpr int u3 = 2;
+
+// Check u4 is not kept because it is not ODR-use.
+// CHECK-NOT: @_ZL2u4
+constexpr int u4 = 3;
+
+__device__ int fun1(const int& x);
+
+__global__ void kern1(int *x) {
+  *x = u1 + u2 + fun1(u3) + u4;
+}


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -578,6 +578,9 @@
 PM.addPass(AMDGPUPrintfRuntimeBindingPass());
 
 if (InternalizeSymbols) {
+  // Global variables may have dead uses which need to be removed.
+  // Otherwise these useless global variables will not get internalized.
+  PM.addPass(GlobalDCEPass());
   PM.addPass(InternalizePass(mustPreserveGV));
 }
 PM.addPass(AMDGPUPropagateAttributesLatePass(*this));
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -0,0 +1,50 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
+// RUN:   -std=c++11 -O3 -mllvm -amdgpu-internalize-symbols -emit-llvm -o - \
+// RUN:   -target-cpu gfx906 | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// AMDGPU internalize unused global variables for whole-program compilation
+// (-fno-gpu-rdc for each TU, or -fgpu-rdc for LTO), which are then
+// eliminated by global DCE. If there are invisible unused address space casts
+// for global variables, the internalization and elimination of unused global
+// variales will be hindered. This test makes sure no such address space
+// casts.
+
+// Check unused device/constant variables are eliminated.
+
+// CHECK-NOT: @v1
+__device__ int v1;
+
+// CHECK-NOT: @v2
+__constant__ int v2;
+
+// CHECK-NOT: @_ZL2v3
+constexpr int v3 = 1;
+
+// Check managed variables are always kept.
+
+// CHECK: @v4
+__managed__ int v4;
+
+// Check used device/constant variables are not eliminated.
+// CHECK: @u1
+__device__ int u1;
+
+// CHECK: @u2
+__constant__ int u2;
+
+// Check u3 is kept because its address is taken.
+// CHECK: @_ZL2u3
+constexpr int u3 = 2;
+
+// Check u4 is not kept because 

  1   2   3   >