[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-21 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3523
+else
+  Opts.CXXABI = TargetCXXABI::getKind(CXXABI);
+  }

The original command-line arguments must be generated from this in 
`GenerateLangArgs`. See 
https://clang.llvm.org/docs/InternalsManual.html#compiler-invocation for more 
details.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D100839: [analyzer] Adjust the reported variable name in retain count checker

2021-04-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This is a major improvement. `MallocChecker` will have to catch up on that. 
Hopefully through increased code re-use.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:651
+
+  return Result;
+}

I feel semi-irrational urge to add comments whenever NRVO is employed.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:967-968
+
+  // While looking for the last var bindings, we can still find
+  // `AllocFirstBinding` to be one of them.  In situations like this,
+  // it would still be the easiest case to explain to our users.

Given that the current state doesn't satisfy the requirement on line 945, this 
can happen for two reasons:
1. The symbol was there when the variable died so we simply tracked it back to 
the last moment of time the variable was alive.
2. The symbol was there but was overwritten later (and then the variable may 
have also, but haven't necessarily, died).

Case 2 is bad because we're back in business for reporting the wrong variable; 
it's still more rare than before the patch but i think the problem remains. 
Something like this should probably demonstrate it:

```lang=c++
void foo() {
  Object *Original = allocate(...);
  Original = allocate();
  Original->release();
}
```

A potential solution may be to add a check in `getAllVarBindingsForSymbol` that 
the first node in which we find our symbol corresponds to a `*PurgeDeadSymbols` 
program point. It's a straightforward way to find out whether we're in case 1 
or in case 2.



Comment at: 
clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist:5993
+ message
+ Object leaked: object allocated and stored into 'New' 
is not referenced later in this execution path and has a retain count of 
+1
+

This patch seems to add 3 entirely new warnings here. Why do they suddenly 
start showing up? Are they good?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100839

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


[PATCH] D100929: [Clang] Allow the combination of loader_uninitialized and address spaces

2021-04-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, aaron.ballman.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added a project: clang.

When an object is allocated in a non-default address space we do not
need to check for a constructor if it is not initialized and has a
trivial constructor (which we won't call then).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100929

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/attr-loader-uninitialized.c
  clang/test/OpenMP/declare_target_codegen.cpp


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -37,6 +37,7 @@
 // CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
+// CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef
 // CHECK-DAG: @b ={{ hidden | }}global i32 15,
 // CHECK-DAG: @d ={{ hidden | }}global i32 0,
 // CHECK-DAG: @c = external global i32,
@@ -264,6 +265,15 @@
 // DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
 #endif // OMP5
 
+struct PAIR {
+  int a;
+  int b;
+};
+
+#pragma omp declare target
+PAIR pair __attribute__((address_space(3), loader_uninitialized));
+#pragma omp end declare target
+
 #endif // HEADER
 
 #ifdef LOAD
Index: clang/test/CodeGen/attr-loader-uninitialized.c
===
--- clang/test/CodeGen/attr-loader-uninitialized.c
+++ clang/test/CodeGen/attr-loader-uninitialized.c
@@ -18,7 +18,19 @@
 } s;
 
 // CHECK: @i ={{.*}} global %struct.s undef
+// CHECK: @j1 ={{.*}}addrspace(1) global %struct.s undef
+// CHECK: @j2 ={{.*}}addrspace(2) global %struct.s undef
+// CHECK: @j3 ={{.*}}addrspace(3) global %struct.s undef
+// CHECK: @j4 ={{.*}}addrspace(4) global %struct.s undef
+// CHECK: @j5 ={{.*}}addrspace(5) global %struct.s undef
+// CHECK: @j99 ={{.*}}addrspace(99) global %struct.s undef
 s i __attribute__((loader_uninitialized));
+s j1 __attribute__((loader_uninitialized, address_space(1)));
+s j2 __attribute__((loader_uninitialized, address_space(2)));
+s j3 __attribute__((loader_uninitialized, address_space(3)));
+s j4 __attribute__((loader_uninitialized, address_space(4)));
+s j5 __attribute__((loader_uninitialized, address_space(5)));
+s j99 __attribute__((loader_uninitialized, address_space(99)));
 
 // CHECK: @private_extern_ok = hidden global i32 undef
 __private_extern__ int private_extern_ok __attribute__((loader_uninitialized));
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12623,6 +12623,8 @@
   return;
 }
   }
+  // The declaration is unitialized, no need for further checks.
+  return;
 }
 
 VarDecl::DefinitionKind DefKind = Var->isThisDeclarationADefinition();


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -37,6 +37,7 @@
 // CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null
 // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23,
+// CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef
 // CHECK-DAG: @b ={{ hidden | }}global i32 15,
 // CHECK-DAG: @d ={{ hidden | }}global i32 0,
 // CHECK-DAG: @c = external global i32,
@@ -264,6 +265,15 @@
 // DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}}
 #endif // OMP5
 
+struct PAIR {
+  int a;
+  int b;
+};
+
+#pragma omp declare target
+PAIR pair __attribute__((address_space(3), loader_uninitialized));
+#pragma omp end declare target
+
 #endif // HEADER
 
 #ifdef LOAD
Index: clang/test/CodeGen/attr-loader-uninitialized.c
===
--- clang/test/CodeGen/attr-loader-uninitialized.c
+++ clang/test/CodeGen/attr-loader-uninitialized.c
@@ -18,7 +18,19 @@
 } s;
 
 // CHECK: @i ={{.*}} global %struct.s undef
+// CHECK: @j1 ={{.*}}addrspace(1) global %struct.s undef
+// CHECK: @j2 ={{.*}}addrspace(2) global %struct.s undef
+// CHECK: @j3 ={{.*}}addrspace(3) global %struct.s undef
+// CHECK: @j4 ={{.*}}addrspace(4) global %struct.s undef
+// CHECK: @j5 ={{.*}}addrspace(5) global %struct.s undef
+// CHECK: @j99 ={{.*}}addrspace(99) global %struct.s undef
 s i __attribute__((loader_uninitialized));
+s j1 __attribute__((loader_uninitialized, address_space(1)));
+s j2 __attribute__((loader_uninitialized, address_space(2)));
+s j3 __attribute__((loader_uninitialized, address_space(3)));
+s j4 __attribute__((loader_uninitialized, address_space(4)));
+s j5 _

[PATCH] D100930: [Clang] Add clang attribute `clang_builtin_alias`.

2021-04-21 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, frasercrmck, rogfer01, khchen, 
aaron.ballman.
Herald added subscribers: StephenFan, jdoerfert, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

In some cases, we want to provide the alias name for the clang builtins.
For example, the arguments must be constant integers for some RISC-V builtins.
If we use wrapper functions, we could not constrain the arguments be constant
integer. This attribute is used to achieve the purpose.

Besides this, use `clang_builtin_alias` is more efficient than using
wrapper functions. We use this attribute to deal with test time issue
reported in https://bugs.llvm.org/show_bug.cgi?id=49962.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100930

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -885,7 +885,7 @@
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream &OS) const {
   bool UseAliasAttr = !isMask() && !isOperandReordered();
   if (UseAliasAttr) {
-OS << "__attribute__((__clang_riscv_builtin_alias(";
+OS << "__attribute__((clang_builtin_alias(";
 OS << "__builtin_rvv_" << getName() << ")))\n";
   }
   OS << OutputType->getTypeStr() << " " << getMangledName() << "(";
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -142,7 +142,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
-// CHECK-NEXT: RISCVBuiltinAlias (SubjectMatchRule_function)
+// CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
===
--- clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
@@ -10,7 +10,7 @@
 static inline __attribute__((__always_inline__, __nodebug__))
 
 __rvv_generic
-__attribute__((__clang_riscv_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
 vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
 
 // CHECK-LABEL: @test(
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
===
--- clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
@@ -9,7 +9,7 @@
 static inline __attribute__((__always_inline__, __nodebug__))
 
 __rvv_generic
-__attribute__((__clang_riscv_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
 vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
 
 // CHECK: passing 'vint8m2_t' (aka '__rvv_int8m2_t') to parameter of incompatible type 'vint8m1_t'
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5147,7 +5147,7 @@
   D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident));
 }
 
-static bool RISCVVAliasValid(unsigned BuiltinID, StringRef AliasName) {
+static bool AliasValid(unsigned BuiltinID, StringRef AliasName) {
   switch (BuiltinID) {
   default:
 return false;
@@ -5158,7 +5158,7 @@
   }
 }
 
-static void handleRISCVBuiltinAliasAttr(Sema &S, Decl *D,
+static void handleBuiltinAliasAttr(Sema &S, Decl *D,
 const ParsedAttr &AL) {
   if (!AL.isArgIdent(0)) {
 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
@@ -5170,12 +5170,12 @@
   unsigned BuiltinID = Ident->getBuiltinID();
   StringRef AliasName = cas

[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-04-21 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls added inline comments.



Comment at: clang/test/Driver/stack-protector-guard.c:26
 
-// RUN: not %clang -target aarch64-linux-gnu -mstack-protector-guard-offset=10 
%s 2>&1 | \
+// RUN: not %clang -target arm-linux-gnuebi -mstack-protector-guard-offset=10 
%s 2>&1 | \
 // RUN:   FileCheck -check-prefix=INVALID-ARCH3 %s

I guess you meant to type "-target arm-linux-gnueabi"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D100611: [RISCV] Add new attribute __clang_riscv_builtin_alias for intrinsics.

2021-04-21 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

@aaron.ballman, could we discuss the generalization in 
https://reviews.llvm.org/D100930?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

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


[clang] 0ad50bf - Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

2021-04-21 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-04-21T08:05:38Z
New Revision: 0ad50bf27f892873427bd372a8e7d2e9b234586d

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

LOG: Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

This reverts commit 3194761d2763a471dc6426a3e77c1445cb9ded3b.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/tools/CMakeLists.txt

Removed: 
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_different
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_fail
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx906
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx908_gfx908
clang/test/Driver/amdgpu-openmp-system-arch-fail.c
clang/test/Driver/amdgpu-openmp-system-arch.c
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index a2ffe1378cb6d..5e580cc4fbb7a 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -67,8 +67,6 @@ def err_drv_no_hip_runtime : Error<
   "cannot find HIP runtime. Provide its path via --rocm-path, or pass "
   "-nogpuinc to build without HIP runtime.">;
 
-def err_drv_undetermined_amdgpu_arch : Error<
-  "Cannot determine AMDGPU architecture: %0. Consider passing it via 
--march.">;
 def err_drv_cuda_version_unsupported : Error<
   "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
   "but installation at %3 is %4. Use --cuda-path to specify a 
diff erent CUDA "

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dbdb6c6dab3ac..f93b8a2496e07 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -924,8 +924,6 @@ def rocm_path_EQ : Joined<["--"], "rocm-path=">, 
Group,
   HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
 def hip_path_EQ : Joined<["--"], "hip-path=">, Group,
   HelpText<"HIP runtime installation path, used for finding HIP version and 
adding HIP include path.">;
-def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, Group,
-  HelpText<"Tool used for detecting AMD GPU arch in the system.">;
 def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, 
Group,
   HelpText<"ROCm device library path. Alternative to rocm-path.">;
 def : Joined<["--"], "hip-device-lib-path=">, Alias;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 328753b21f8ea..dc9c9751c851d 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -12,16 +12,9 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
-#include 
-
-#define AMDGPU_ARCH_PROGRAM_NAME "amdgpu-arch"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -722,78 +715,6 @@ void AMDGPUToolChain::checkTargetID(
   }
 }
 
-llvm::Error
-AMDGPUToolChain::detectSystemGPUs(const ArgList &Args,
-  SmallVector &GPUArchs) const 
{
-  std::string Program;
-  if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
-Program = A->getValue();
-  else
-Program = GetProgramPath(AMDGPU_ARCH_PROGRAM_NAME);
-  llvm::SmallString<64> OutputFile;
-  llvm::sys::fs::createTemporaryFile("print-system-gpus", "" /* No Suffix */,
- OutputFile);
-  llvm::FileRemover OutputRemover(OutputFile.c_str());
-  llvm::Optional Redirects[] = {
-  {""},
-  StringRef(OutputFile),
-  {""},
-  };
-
-  std::string ErrorMessage;
-  if (int Result = llvm::sys::ExecuteAndWait(
-  Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
-  /*MemoryLimit*/ 0, &ErrorMessage)) {
-if (Result > 0) {
-  ErrorMessage = "Exited with error code " + std::to_string(Result);
-} else if (Result == -1) {
-  ErrorMessage = "Execute failed: " + ErrorMessage;
-} else {
-  ErrorMessage = "Crashed: " + ErrorMessage;
-}
-
-return llvm::createStringError(std::error_code(),
-   Program + ": " + Erro

[PATCH] D100852: [analyzer] Track leaking object through stores

2021-04-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think this is already way better than before. I see that `OSDynamicCast` 
isn't supported yet and we seem to hit the same wall as D97183 
 because inter-operation between 
`trackExpressionValue` and the checkers isn't implemented yet.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:636
 if (isa(R))
-  Result.push_back(R);
+  Result.emplace_back(R, Val);
 

Because we already know that `Val.getAsLocSymbol()` is equal to `Sym`, we can 
be certain that `Val` is either a `&SymRegion{Sym}` (i.e., literally this 
symbol in its pristine representation) or, in some rare cases, a `LocAsInteger` 
over that (which is a case i'm not sure we even want to handle). I dunno if we 
really need to return it here. Maybe it's easier to re-construct it in place as 
`SValBuilder.makeLoc(Sym)`.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:978
+
+if (auto KV = AllVarBindings[0].second.getAs())
+  // Because 'AllocBindingToReport' is not the the same as

In particular, this check is always true and you can use `castAs`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100852

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


[PATCH] D100933: [clang] Recognize ppc32 as valid mcpu value

2021-04-21 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy created this revision.
LemonBoy added a reviewer: PowerPC.
Herald added subscribers: shchenz, kbarton, nemanjai.
LemonBoy requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `ppc32` cpu model was introduced a while ago in 
a9321059b912155cd81cf0776d54a7d6838ef7ab as an independent copy of the `ppc` 
one but was never wired into clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100933

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Misc/target-invalid-cpu-note.c


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -117,8 +117,8 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, powerpc64,
-// PPC-SAME: ppc64, powerpc64le, ppc64le, future
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, ppc32,
+// PPC-SAME: powerpc64, ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -553,17 +553,17 @@
 }
 
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
-{"generic"}, {"440"}, {"450"},   {"601"}, {"602"},
-{"603"}, {"603e"},{"603ev"}, {"604"}, {"604e"},
-{"620"}, {"630"}, {"g3"},{"7400"},{"g4"},
-{"7450"},{"g4+"}, {"750"},   {"8548"},{"970"},
-{"g5"},  {"a2"},  {"e500"},  {"e500mc"},  {"e5500"},
-{"power3"},  {"pwr3"},{"power4"},{"pwr4"},{"power5"},
-{"pwr5"},{"power5x"}, {"pwr5x"}, {"power6"},  {"pwr6"},
-{"power6x"}, {"pwr6x"},   {"power7"},{"pwr7"},{"power8"},
-{"pwr8"},{"power9"},  {"pwr9"},  {"power10"}, {"pwr10"},
-{"powerpc"}, {"ppc"}, {"powerpc64"}, {"ppc64"},   {"powerpc64le"},
-{"ppc64le"}, {"future"}};
+{"generic"}, {"440"}, {"450"},{"601"},   {"602"},
+{"603"}, {"603e"},{"603ev"},  {"604"},   {"604e"},
+{"620"}, {"630"}, {"g3"}, {"7400"},  {"g4"},
+{"7450"},{"g4+"}, {"750"},{"8548"},  {"970"},
+{"g5"},  {"a2"},  {"e500"},   {"e500mc"},{"e5500"},
+{"power3"},  {"pwr3"},{"power4"}, {"pwr4"},  {"power5"},
+{"pwr5"},{"power5x"}, {"pwr5x"},  {"power6"},{"pwr6"},
+{"power6x"}, {"pwr6x"},   {"power7"}, {"pwr7"},  {"power8"},
+{"pwr8"},{"power9"},  {"pwr9"},   {"power10"},   {"pwr10"},
+{"powerpc"}, {"ppc"}, {"ppc32"},  {"powerpc64"}, {"ppc64"},
+{"powerpc64le"}, {"ppc64le"}, {"future"}};
 
 bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -117,8 +117,8 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, powerpc64,
-// PPC-SAME: ppc64, powerpc64le, ppc64le, future
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, ppc32,
+// PPC-SAME: powerpc64, ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -553,17 +553,17 @@
 }
 
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
-{"generic"}, {"440"}, {"450"},   {"601"}, {"602"},
-{"603"}, {"603e"},{"603ev"}, {"604"}, {"604e"},
-{"620"}, {"630"}, {"g3"},{"7400"},{"g4"},
-{"7450"},{"g4+"}, {"750"},   {"8548"},{"970"},
-{"g5"},  {"a2"},  {"e500"},  {"e500mc"},  {"e5500"},
-{"power3"},  {"pwr3"},{"power4"},{"pwr4"},   

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

2021-04-21 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 enabled explicitly building inferred modules.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 
authored by @Bigcheese with libclang changes omitted and adapted to use the new 
full canonical command-line `clang-scan-deps` produces since D100534 
.

Contains the following changes:

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

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

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

Index: clang/test/ClangScanDeps/modules-inferred.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred.m
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%S/Inputs/frameworks|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: echo -%t.dir > %t.result
+// RUN: echo -%S >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources >> %t.result
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
+#include 
+
+inferred a = 0;
+
+// CHECK: -[[PREFIX:.*]]
+// CHECK-NEXT: -[[SOURCEDIR:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK:  "-emit-module",
+// CHECK:  "-fmodule-name=Inferred",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1:[A-Z0-9]+]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "module-name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-

[PATCH] D97361: [clang-tidy] Add readability-redundant-using check

2021-04-21 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97361

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


[PATCH] D100834: Bug 49739 - [Matrix] Support #pragma clang fp

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

In D100834#2702550 , @kpn wrote:

> I don't know the matrix implementation so I can't swear this hits every place 
> needed, but the uses of CGFPOptionsRAII in this patch look correct at least.

Other parts of the extension include `__builtin_matrix_transpose`, indexing 
into a matrix and casting, but I don't think the FMFs are needed there. One 
thing that would be good to also test would be the compound operators, (`-=`, 
`+=`, `*=`). @effective-light it would be great if you could add a test for 
those, then LGTM from my side. If you need someone to commit the change on your 
behalf, please let us know and share the name + email to use for the commit 
authorship.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100834

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


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

2021-04-21 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 339136.
jansvoboda11 added a comment.

Apply clang-format suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

Index: clang/test/ClangScanDeps/modules-inferred.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred.m
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%S/Inputs/frameworks|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: echo -%t.dir > %t.result
+// RUN: echo -%S >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources >> %t.result
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
+#include 
+
+inferred a = 0;
+
+// CHECK: -[[PREFIX:.*]]
+// CHECK-NEXT: -[[SOURCEDIR:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK:  "-emit-module",
+// CHECK:  "-fmodule-name=Inferred",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1:[A-Z0-9]+]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "module-name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// 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]]/Inferred-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT: "-fmodule-map-file=[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/modules-inferred-explicit-build.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred-explicit-build.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%/S/Inputs/frameworks|g" -e "s|-E|-x objective-c -E|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources > %t.db
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp
+// RUN: %clang_cc1 -pedantic -Werror @%t.inferred.rsp
+// RUN: %clang_cc1 -pedantic -Werror @%t.system.rsp
+// RU

[PATCH] D96286: [clangd][NFC] Change TidyProvider cache to use a linked list approach

2021-04-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96286

___
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-21 Thread Victor Campos via Phabricator via cfe-commits
vhscampos added a comment.

Thanks Peter. Since one week has passed, I plan to commit these changes by the 
end of the day if nothing surfaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100372

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


[PATCH] D100830: [RISCV] [1/2] Add IR intrinsic for Zbp extension

2021-04-21 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 339138.
LevyHsu added a comment.

1. llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  - Fix format issue with clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100830

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbp.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbp.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbp-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
  llvm/test/MC/RISCV/rv32b-aliases-valid.s
  llvm/test/MC/RISCV/rv64b-aliases-valid.s

Index: llvm/test/MC/RISCV/rv64b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv64b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv64b-aliases-valid.s
@@ -338,3 +338,27 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: greviw t0, t1, 13
+# CHECK-S-OBJ: greviw t0, t1, 13
+grevw x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorciw t0, t1, 13
+# CHECK-S-OBJ: gorciw t0, t1, 13
+gorcw x5, x6, 13
Index: llvm/test/MC/RISCV/rv32b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv32b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv32b-aliases-valid.s
@@ -242,3 +242,19 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
Index: llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
@@ -0,0 +1,325 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbp -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBP
+
+declare i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+
+define signext i32 @grev32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: grev32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:grevw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grev32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:grevw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.grevi.i32(i32 %a)
+
+define signext i32 @grevi32(i32 signext %a) nounwind {
+; RV64IB-LABEL: grevi32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:greviw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grevi32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:greviw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+
+define signext i32 @gorc32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: gorc32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorcw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorc32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorcw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorci.i32(i32 %a)
+
+define signext i32 @gorci32(i32 signext %a) nounwind {
+; RV64IB-LABEL: gorci32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorciw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorci32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorciw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.shfl.i32(i32 %a, i32 %b)
+
+define signext i32 @shfl32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: shfl32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:shflw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: shfl32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:shflw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp =

[PATCH] D100448: [RISCV][Clang] Add RVV AMO builtins

2021-04-21 Thread ShihPo Hung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11072a0bdbc0: [RISCV][Clang] Add RVV AMO builtins (authored 
by arcbbb).

Changed prior to commit:
  https://reviews.llvm.org/D100448?vs=338419&id=339139#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100448

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoxor.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[clang] 64bc44f - [llvm-rc] Run clang to preprocess input files

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

Author: Martin Storsjö
Date: 2021-04-21T11:50:10+03:00
New Revision: 64bc44f5ddfb6da4b6a8b51ea9a03f8772b3ae95

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

LOG: [llvm-rc] Run clang to preprocess input files

Allow opting out from preprocessing with a command line argument.

Update tests to pass -no-preprocess to make it not try to use clang
(which isn't a build level dependency of llvm-rc), but add a test that
does preprocessing under clang/test/Preprocessor.

Update a few options to allow them both joined (as -DFOO) and separate
(-D BR), as rc.exe allows both forms of them.

With the verbose flag set, this prints the preprocessing command
used (which differs from what rc.exe does).

Tests under llvm/test/tools/llvm-rc only test constructing the
preprocessor commands, while tests under clang/test/Preprocessor test
actually running the preprocessor.

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

Added: 
clang/test/Preprocessor/Inputs/llvm-rc.h
clang/test/Preprocessor/llvm-rc.rc
llvm/test/tools/llvm-rc/preproc.test

Modified: 
clang/test/CMakeLists.txt
clang/test/lit.cfg.py
llvm/test/tools/llvm-rc/absolute.test
llvm/test/tools/llvm-rc/codepage.test
llvm/test/tools/llvm-rc/cpp-output.test
llvm/test/tools/llvm-rc/flags.test
llvm/test/tools/llvm-rc/helpmsg.test
llvm/test/tools/llvm-rc/include-paths.test
llvm/test/tools/llvm-rc/language.test
llvm/test/tools/llvm-rc/memoryflags-stringtable.test
llvm/test/tools/llvm-rc/memoryflags.test
llvm/test/tools/llvm-rc/not-expr.test
llvm/test/tools/llvm-rc/parser-expr.test
llvm/test/tools/llvm-rc/parser.test
llvm/test/tools/llvm-rc/tag-accelerators.test
llvm/test/tools/llvm-rc/tag-dialog.test
llvm/test/tools/llvm-rc/tag-escape.test
llvm/test/tools/llvm-rc/tag-html.test
llvm/test/tools/llvm-rc/tag-icon-cursor.test
llvm/test/tools/llvm-rc/tag-menu.test
llvm/test/tools/llvm-rc/tag-stringtable.test
llvm/test/tools/llvm-rc/tag-user.test
llvm/test/tools/llvm-rc/tag-versioninfo.test
llvm/test/tools/llvm-rc/tokenizer.test
llvm/test/tools/llvm-rc/versioninfo-padding.test
llvm/tools/llvm-rc/Opts.td
llvm/tools/llvm-rc/llvm-rc.cpp

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 562a148260338..1325a0308d69e 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -120,6 +120,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-objcopy
 llvm-objdump
 llvm-profdata
+llvm-rc
 llvm-readelf
 llvm-readobj
 llvm-strip

diff  --git a/clang/test/Preprocessor/Inputs/llvm-rc.h 
b/clang/test/Preprocessor/Inputs/llvm-rc.h
new file mode 100644
index 0..dcc91c20961c4
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/llvm-rc.h
@@ -0,0 +1,7 @@
+#ifndef RC_INVOKED
+#error RC_INVOKED not defined
+#endif
+#ifndef _WIN32
+#error _WIN32 not defined
+#endif
+#define MY_ID 42

diff  --git a/clang/test/Preprocessor/llvm-rc.rc 
b/clang/test/Preprocessor/llvm-rc.rc
new file mode 100644
index 0..689fc87473f92
--- /dev/null
+++ b/clang/test/Preprocessor/llvm-rc.rc
@@ -0,0 +1,8 @@
+// RUN: llvm-rc -i%p/Inputs -Fo%t.res %s
+// RUN: llvm-readobj %t.res | FileCheck %s
+// CHECK: Resource type (int): RCDATA (ID 10)
+// CHECK: Resource name (int): 42
+#include "llvm-rc.h"
+MY_ID RCDATA {
+  "a long string of data"
+}

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 63ba8160c6612..7411e87169435 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -26,7 +26,7 @@
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip',
-   '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', 
'.rs', '.ifs']
+   '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', 
'.rs', '.ifs', '.rc']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent

diff  --git a/llvm/test/tools/llvm-rc/absolute.test 
b/llvm/test/tools/llvm-rc/absolute.test
index fd8b2d68d41e2..fd054536b3bfd 100644
--- a/llvm/test/tools/llvm-rc/absolute.test
+++ b/llvm/test/tools/llvm-rc/absolute.test
@@ -1,7 +1,7 @@
 ; RUN: touch %t.manifest
 ; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
-; RUN: llvm-rc -- %t.rc
+; RUN: llvm-rc -no-preprocess -- %t.rc
 ;; On Windows, try stripping out the drive name from the absolute path,
 ;; and make sure the path still is found.
 ; RUN: cat %t.rc | sed 's/"[a-zA-Z]:/"/' > %t2.rc
-; RUN: llvm-rc -- %t2.rc
+; RUN: llvm-rc -no-preprocess -- %t2.rc

diff  --git a/llvm/test/tools/llvm-rc/codepage.test 
b/llvm/test/tools/llvm-rc/codepage.test

[PATCH] D100755: [llvm-rc] [3/4] Run clang to preprocess input files

2021-04-21 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64bc44f5ddfb: [llvm-rc] Run clang to preprocess input files 
(authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D100755?vs=338969&id=339141#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100755

Files:
  clang/test/CMakeLists.txt
  clang/test/Preprocessor/Inputs/llvm-rc.h
  clang/test/Preprocessor/llvm-rc.rc
  clang/test/lit.cfg.py
  llvm/test/tools/llvm-rc/absolute.test
  llvm/test/tools/llvm-rc/codepage.test
  llvm/test/tools/llvm-rc/cpp-output.test
  llvm/test/tools/llvm-rc/flags.test
  llvm/test/tools/llvm-rc/helpmsg.test
  llvm/test/tools/llvm-rc/include-paths.test
  llvm/test/tools/llvm-rc/language.test
  llvm/test/tools/llvm-rc/memoryflags-stringtable.test
  llvm/test/tools/llvm-rc/memoryflags.test
  llvm/test/tools/llvm-rc/not-expr.test
  llvm/test/tools/llvm-rc/parser-expr.test
  llvm/test/tools/llvm-rc/parser.test
  llvm/test/tools/llvm-rc/preproc.test
  llvm/test/tools/llvm-rc/tag-accelerators.test
  llvm/test/tools/llvm-rc/tag-dialog.test
  llvm/test/tools/llvm-rc/tag-escape.test
  llvm/test/tools/llvm-rc/tag-html.test
  llvm/test/tools/llvm-rc/tag-icon-cursor.test
  llvm/test/tools/llvm-rc/tag-menu.test
  llvm/test/tools/llvm-rc/tag-stringtable.test
  llvm/test/tools/llvm-rc/tag-user.test
  llvm/test/tools/llvm-rc/tag-versioninfo.test
  llvm/test/tools/llvm-rc/tokenizer.test
  llvm/test/tools/llvm-rc/versioninfo-padding.test
  llvm/tools/llvm-rc/Opts.td
  llvm/tools/llvm-rc/llvm-rc.cpp

Index: llvm/tools/llvm-rc/llvm-rc.cpp
===
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -17,17 +17,22 @@
 #include "ResourceScriptStmt.h"
 #include "ResourceScriptToken.h"
 
+#include "llvm/ADT/Triple.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include 
@@ -71,12 +76,114 @@
 };
 
 static ExitOnError ExitOnErr;
+static FileRemover TempPreprocFile;
 
 LLVM_ATTRIBUTE_NORETURN static void fatalError(const Twine &Message) {
   errs() << Message << "\n";
   exit(1);
 }
 
+std::string createTempFile(const Twine &Prefix, StringRef Suffix) {
+  std::error_code EC;
+  SmallString<128> FileName;
+  if ((EC = sys::fs::createTemporaryFile(Prefix, Suffix, FileName)))
+fatalError("Unable to create temp file: " + EC.message());
+  return static_cast(FileName);
+}
+
+ErrorOr findClang(const char *Argv0) {
+  StringRef Parent = llvm::sys::path::parent_path(Argv0);
+  ErrorOr Path = std::error_code();
+  if (!Parent.empty()) {
+// First look for the tool with all potential names in the specific
+// directory of Argv0, if known
+for (const auto *Name : {"clang", "clang-cl"}) {
+  Path = sys::findProgramByName(Name, Parent);
+  if (Path)
+return Path;
+}
+  }
+  // If no parent directory known, or not found there, look everywhere in PATH
+  for (const auto *Name : {"clang", "clang-cl"}) {
+Path = sys::findProgramByName(Name);
+if (Path)
+  return Path;
+  }
+  return Path;
+}
+
+std::string getClangClTriple() {
+  Triple T(sys::getDefaultTargetTriple());
+  T.setOS(llvm::Triple::Win32);
+  T.setVendor(llvm::Triple::PC);
+  T.setEnvironment(llvm::Triple::MSVC);
+  T.setObjectFormat(llvm::Triple::COFF);
+  return T.str();
+}
+
+bool preprocess(StringRef Src, StringRef Dst, opt::InputArgList &InputArgs,
+const char *Argv0) {
+  std::string Clang;
+  if (InputArgs.hasArg(OPT__HASH_HASH_HASH)) {
+Clang = "clang";
+  } else {
+ErrorOr ClangOrErr = findClang(Argv0);
+if (ClangOrErr) {
+  Clang = *ClangOrErr;
+} else {
+  errs() << "llvm-rc: Unable to find clang, skipping preprocessing."
+ << "\n";
+  errs() << "Pass -no-cpp to disable preprocessing. This will be an error "
+"in the future."
+ << "\n";
+  return false;
+}
+  }
+  std::string PreprocTriple = getClangClTriple();
+
+  SmallVector Args = {
+  Clang, "--driver-mode=gcc", "-target", PreprocTriple, "-E",
+  "-xc", "-DRC_INVOKED",  Src,   "-o",  Dst};
+  if (InputArgs.hasArg(OPT_noinclude)) {
+#ifdef _WIN32
+::_putenv("INCLUDE=");
+#else
+::unsetenv("INCLUDE");
+#endif
+  }
+  for (const auto *Arg :
+   InputArgs.filtered(

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/TokenAnnotator.cpp:125
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;

I don't really understand what we are saying here? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

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


[PATCH] D100819: [RISCV] Implement the vneg.v builtin.

2021-04-21 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:1048
+   return Cmp < 0;
+ // Some mask intrinsics use the same IRName as unmasked.
+ // Sort the unmasked intrinsics first.

Does this only affect `vneg` or are there other changes to the tablegenned code 
as a consequence?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100819

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


[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-04-21 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:460-468
+TARGET_BUILTIN(__nvvm_redux_sync_add_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_min_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_max_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_add_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_min_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_max_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_and_b32, "iii", "", SM_80)

tra wrote:
> steffenlarsen wrote:
> > tra wrote:
> > > steffenlarsen wrote:
> > > > tra wrote:
> > > > > Instead of creating one builtin per integer variant, can we use a 
> > > > > more generic builtin `__nvvm_redux_sync_add_i`, similar to how we 
> > > > > handle `__nvvm_atom_add_gen_i` ?
> > > > > 
> > > > What gives me pause is that a for atomic minimum there are both 
> > > > `__nvvm_atom_min_gen_i` and `__nvvm_atom_min_gen_ui` to distinguish 
> > > > between signed and unsigned. What makes the difference?
> > > > 
> > > > That noted, I'll happily rename the builtins to be more in line with 
> > > > the other builtins. `__nvvm_redux_sync_*_i` and 
> > > > `__nvvm_redux_sync_*_ui` maybe?
> > > > What gives me pause is that a for atomic minimum there are both 
> > > > __nvvm_atom_min_gen_i and __nvvm_atom_min_gen_ui to distinguish between 
> > > > signed and unsigned. What makes the difference?
> > > 
> > > Good point. We do not need unsigned variant for `add`.  We do need 
> > > explicit signed and unsigned variants ad LLVM IR integer types do not 
> > > take signedness into account, and the underlying min/max instructions do. 
> > >  Maybe, rename min_i/min_ui -> min/umin as LLVM does with atomics? 
> > > 
> > > We may skip the `_i` suffix on logical ops as they only apply to integers 
> > > anyways.
> > > 
> > Sorry, I completely missed your responses.
> > 
> > > Maybe, rename min_i/min_ui -> min/umin as LLVM does with atomics?
> > 
> > Sounds good to me. Would there also be umax and uadd?
> > 
> > > We may skip the _i suffix on logical ops as they only apply to integers 
> > > anyways.
> > 
> > Absolutely. I'll make that happen! 
> > Would there also be umax and uadd?
> 
> You will need `umax`, but there's no need for `uadd` as 2-complement addition 
> is the same for signed/unsigned.
> 
> E.g `umax(0x, 1) -> 0x`, `max(-1,1) -> 1`, give different 
> answers, but `uadd(0x, 1) -> 0` and `add(-1,1) -> 0`.
Ah, of course. Though I do wonder as to the motivation of having signed and 
unsigned add variants in PTX. I'll drop the unsigned variant.


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

https://reviews.llvm.org/D100124

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


[PATCH] D100852: [analyzer] Track leaking object through stores

2021-04-21 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 339143.
vsavchenko marked an inline comment as done.
vsavchenko added a comment.

Add a comment and replace getAs with castAs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100852

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m

Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -335,8 +335,11 @@
 @implementation LeakReassignmentTests
 +(void)testLeakAliasSimple {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id New = Original;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id New = Original;   // expected-note {{'New' initialized here}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -345,9 +348,12 @@
 
 +(void)testLeakAliasChain {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id Intermediate = Original;
-  id New = Intermediate;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id Intermediate = Original;  // expected-note {{'Intermediate' initialized here}}
+  id New = Intermediate;   // expected-note {{'New' initialized here}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -369,8 +375,12 @@
 
 +(void)testLeakAliasDeathInExpr {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id New = Original;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id New = 0;
+  New = Original; // expected-note {{Value assigned to 'New'}}
   Original = [[MyObj alloc] initZ];
   [self log:New with:[self calculate]];
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -526,19 +526,58 @@
 
 void check_dynamic_cast_null_check() {
   OSArray *arr = OSDynamicCast(OSArray, OSObject::generateObject(1)); // expected-note{{Call to method 'OSObject::generateObject' returns an OSObject}}
-// expected-warning@-1{{Potential leak of an object}}
-// expected-note@-2{{Object leaked}}
-// expected-note@-3{{Assuming dynamic cast returns null due to type mismatch}}
+  // expected-warning@-1{{Potential leak of an object}}
+  // expected-note@-2{{Object leaked}}
+  // expected-note@-3{{Assuming dynamic cast returns null due to type mismatch}}
   if (!arr)
 return;
   arr->release();
 }
 
+void check_dynamic_cast_alias() {
+  OSObject *originalPtr = OSObject::generateObject(1);   // expected-note {{Call to method 'OSObject::generateObject' returns an OSObject}}
+  OSArray *newPtr = OSDynamicCa

[PATCH] D100852: [analyzer] Track leaking object through stores

2021-04-21 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D100852#2704282 , @NoQ wrote:

> I think this is already way better than before. I see that `OSDynamicCast` 
> isn't supported yet and we seem to hit the same wall as D97183 
>  because inter-operation between 
> `trackExpressionValue` and the checkers isn't implemented yet.

Let's say that `OSDynamicCast` isn't **fully** supported.  If we have a chain 
of bindings `var1 -> var2 -> ... -> varN` and `varM -> varM+1` is a dynamic 
cast assignment, we will create a note that `varM+1` is assigned/initialized 
here (as you can see in tests), but not further down the chain. 
`check_dynamic_cast_alias_intermediate` is a good example here.
We still have work to do, but in the most common case where `var1 -> var2` is 
the whole chain, we work as expected.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:636
 if (isa(R))
-  Result.push_back(R);
+  Result.emplace_back(R, Val);
 

NoQ wrote:
> Because we already know that `Val.getAsLocSymbol()` is equal to `Sym`, we can 
> be certain that `Val` is either a `&SymRegion{Sym}` (i.e., literally this 
> symbol in its pristine representation) or, in some rare cases, a 
> `LocAsInteger` over that (which is a case i'm not sure we even want to 
> handle). I dunno if we really need to return it here. Maybe it's easier to 
> re-construct it in place as `SValBuilder.makeLoc(Sym)`.
Oh, that was my original solution, but it doesn't work for dynamic casts.
This check compares symbols, but `FindLastStore` compares `SVal`s.  
`&Derived{&SymRegion}` is not the same as `&SymRegion` and we fail.
So, instead of hacking on the result from `SValBuilder` trying to make 
something that will indeed match the last stored value, I save that last stored 
value here, so we're guaranteed that `FindLastStore` will work as intended.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:978
+
+if (auto KV = AllVarBindings[0].second.getAs())
+  // Because 'AllocBindingToReport' is not the the same as

NoQ wrote:
> In particular, this check is always true and you can use `castAs`.
Yep, makes sense!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100852

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


[PATCH] D100935: [OpenCL] Add missing C++ legacy atomics with generic

2021-04-21 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, olestrohm.
svenvh added a project: clang.
Herald added subscribers: ldrumm, jfb, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D62335 added some C++ for OpenCL specific
builtins to opencl-c.h, but these were not mirrored to the TableGen
builtin functions yet.

The TableGen builtins machinery does not have dedicated version
handling for C++ for OpenCL at the moment: all builtin versioning is
tied to `LangOpts.OpenCLVersion` (i.e., the OpenCL C version).  As a
workaround, to add builtins that are only available in C++ for OpenCL,
we define a function extension guarded by the __cplusplus macro.

Fixes PR50041.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100935

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -122,6 +122,17 @@
 }
 #endif
 
+// Test old atomic overloaded with generic address space in C++ for OpenCL.
+#if __OPENCL_C_VERSION__ >= 200
+void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
+  atomic_add(a, 1);
+#if !defined(__cplusplus)
+  // expected-error@-2{{no matching function for call to 'atomic_add'}}
+  // expected-note@-3 4 {{candidate function not viable}}
+#endif
+}
+#endif
+
 kernel void basic_conversion() {
   float f;
   char2 c2;
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -82,6 +82,9 @@
 def FuncExtKhrMipmapImageWrites  : 
FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
+// Not a real extension, but a workaround to add C++ for OpenCL specific 
builtins.
+def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
+
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : 
FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
@@ -1077,6 +1080,17 @@
 }
   }
 }
+
+let Extension = FuncExtOpenCLCxx in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
+"atomic_min", "atomic_max", "atomic_and",
+"atomic_or", "atomic_xor"] in {
+  def : Builtin, GenericAS>, 
Type]>;
+}
+  }
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -122,6 +122,17 @@
 }
 #endif
 
+// Test old atomic overloaded with generic address space in C++ for OpenCL.
+#if __OPENCL_C_VERSION__ >= 200
+void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
+  atomic_add(a, 1);
+#if !defined(__cplusplus)
+  // expected-error@-2{{no matching function for call to 'atomic_add'}}
+  // expected-note@-3 4 {{candidate function not viable}}
+#endif
+}
+#endif
+
 kernel void basic_conversion() {
   float f;
   char2 c2;
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -82,6 +82,9 @@
 def FuncExtKhrMipmapImageWrites  : FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
+// Not a real extension, but a workaround to add C++ for OpenCL specific builtins.
+def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
+
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
@@ -1077,6 +1080,17 @@
 }
   }
 }
+
+let Extension = FuncExtOpenCLCxx in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
+"atomic_min", "atomic_max", "atomic_and",
+"atomic_or", "atomic_xor"] in {
+  def : Builtin, GenericAS>, Type]>;
+}
+  }
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, MemoryScope]>;
___
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-21 Thread Andrzej Warzynski 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 rGdc256a443a45: [flang][driver] Add support for 
`-fget-definition` (authored by awarzynski).

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 | 

[clang] dc256a4 - [flang][driver] Add support for `-fget-definition`

2021-04-21 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-04-21T09:31:36Z
New Revision: dc256a443a456a8e0e4d72736fee1c9442bcf4bd

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

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

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

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

Added: 
flang/test/Driver/get-definition.f90

Modified: 
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/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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f93b8a2496e07..648cfb0522e14 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4381,6 +4381,9 @@ def J : JoinedOrSeparate<["-"], "J">,
 
//===--===//
 let Flags = [FC1Option, FlangOnlyOption] in {
 
+def fget_definition : MultiArg<["-"], "fget-definition", 3>,
+  HelpText<"Get the symbol definition from   
">,
+  Group;
 def test_io : Flag<["-"], "test-io">, Group,
   HelpText<"Run the InputOuputTest action. Use for development and testing 
only.">;
 def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, 
Group,

diff  --git a/flang/include/flang/Frontend/FrontendActions.h 
b/flang/include/flang/Frontend/FrontendActions.h
index 83e9652153ae3..619e83ad88c77 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -116,6 +116,10 @@ class DebugPreFIRTreeAction : public PrescanAndSemaAction {
   void ExecuteAction() override;
 };
 
+class GetDefinitionAction : public PrescanAndSemaAction {
+  void ExecuteAction() override;
+};
+
 class GetSymbolsSourcesAction : public PrescanAndSemaAction {
   void ExecuteAction() override;
 };

diff  --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 24fbdd3aff2a9..e18fd961a55b0 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -67,6 +67,9 @@ enum ActionKind {
   /// Parse, run semantics and then output the pre-FIR tree
   DebugPreFIRTree,
 
+  /// `-fget-definition`
+  GetDefinition,
+
   /// Parse, run semantics and then dump symbol sources map
   GetSymbolsSources
 
@@ -206,6 +209,14 @@ class FrontendOptions {
   /// compilation.
   unsigned needProvenanceRangeToCharBlockMappings_ : 1;
 
+  /// Input values from `-fget-definition`
+  struct GetDefinitionVals {
+unsigned line;
+unsigned startColumn;
+unsigned endColumn;
+  };
+  GetDefinitionVals getDefVals_;
+
   /// The input files and their types.
   std::vector inputs_;
 

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index a8879294eebf7..c79c2f2a0d939 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -95,12 +95,14 @@ static void setUpFrontendBasedOnAction(FrontendOptions 
&opts) {
   if (opts.programAction_ == DebugDumpParsingLog)
 opts.instrumentedParse_ = true;
 
-  if (opts.programAction_ == DebugDumpProvenance)
+  if (opts.programAction_ == DebugDumpProvenance ||
+  opts.programAction_ == Fortran::frontend::GetDefinition)
 opts.needProvenanceRangeToCharBlockMappings_ = true;
 }
 
-static void ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
+static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
 clang::DiagnosticsEn

[PATCH] D100830: [RISCV] [1/2] Add IR intrinsic for Zbp extension

2021-04-21 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 339150.
LevyHsu added a comment.

Fix format in RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100830

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbp.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbp.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbp-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
  llvm/test/MC/RISCV/rv32b-aliases-valid.s
  llvm/test/MC/RISCV/rv64b-aliases-valid.s

Index: llvm/test/MC/RISCV/rv64b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv64b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv64b-aliases-valid.s
@@ -338,3 +338,27 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: greviw t0, t1, 13
+# CHECK-S-OBJ: greviw t0, t1, 13
+grevw x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorciw t0, t1, 13
+# CHECK-S-OBJ: gorciw t0, t1, 13
+gorcw x5, x6, 13
Index: llvm/test/MC/RISCV/rv32b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv32b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv32b-aliases-valid.s
@@ -242,3 +242,19 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
Index: llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
@@ -0,0 +1,325 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbp -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBP
+
+declare i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+
+define signext i32 @grev32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: grev32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:grevw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grev32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:grevw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.grevi.i32(i32 %a)
+
+define signext i32 @grevi32(i32 signext %a) nounwind {
+; RV64IB-LABEL: grevi32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:greviw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grevi32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:greviw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+
+define signext i32 @gorc32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: gorc32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorcw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorc32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorcw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorci.i32(i32 %a)
+
+define signext i32 @gorci32(i32 signext %a) nounwind {
+; RV64IB-LABEL: gorci32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorciw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorci32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorciw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.shfl.i32(i32 %a, i32 %b)
+
+define signext i32 @shfl32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: shfl32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:shflw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: shfl32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:shflw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.shfl.

[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: mstorsjo, thakis.
Herald added subscribers: dexonsmith, danielkiss, hiraditya, kristof.beyls.
simon_tatham requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

If you gave clang the options `--target=arm-pc-windows-msvc` and
`-march=armv8-a+crypto` together, the crypto extension would not be
enabled in the compilation, and you'd see the following warning
message suggesting that the 'armv8-a' had been ignored:

  clang: warning: ignoring extension 'crypto' because the 'armv7-a' 
architecture does not support it [-Winvalid-command-line-argument]

This happens because Triple::getARMCPUForArch(), for the Win32 OS,
unconditionally returns "cortex-a9" (an Armv7 CPU) regardless of
MArch, which overrides the architecture setting on the command line.

I don't think that the combination of Windows and AArch32 _should_
unconditionally outlaw the use of the crypto extension. MSVC itself
doesn't think so: you can perfectly well compile Thumb crypto code
using its AArch32-targeted compiler.

All the other default CPUs in the same switch statement are
conditional on a particular MArch setting; this is the only one that
returns a particular CPU _regardless_ of MArch. So I've fixed this one
by adding a condition, so that if you ask for an architecture *above*
v7, the default of Cortex-A9 no longer overrides it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100937

Files:
  clang/test/Driver/woa-crypto.c
  llvm/lib/Support/Triple.cpp


Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"


Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 066b8f2 - [llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures

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

Author: Martin Storsjö
Date: 2021-04-21T12:47:33+03:00
New Revision: 066b8f2fc6d584635a017a0a15494ce4460744e3

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

LOG: [llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 
architectures

When llvm-rc invokes clang for preprocessing, it uses a target
triple derived from the default target. The test verifies that
e.g. _WIN32 is defined when preprocessing.

If running clang with e.g. -target ppc64le-windows-msvc, that
particular arch/OS combination isn't hooked up, so _WIN32 doesn't
get defined in that configuration. Therefore, the preprocessing
test fails.

Instead make llvm-rc inspect the architecture of the default target.
If it's one of the known supported architectures, use it as such,
otherwise set a default one (x86_64). (Clang can run preprocessing
with an x86_64 target triple, even if the x86 backend isn't
enabled.)

Also remove superfluous llvm:: specifications on enums in llvm-rc.cpp.

Added: 


Modified: 
clang/test/Preprocessor/llvm-rc.rc
llvm/tools/llvm-rc/llvm-rc.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/llvm-rc.rc 
b/clang/test/Preprocessor/llvm-rc.rc
index 689fc87473f9..799bf347dbee 100644
--- a/clang/test/Preprocessor/llvm-rc.rc
+++ b/clang/test/Preprocessor/llvm-rc.rc
@@ -1,4 +1,4 @@
-// RUN: llvm-rc -i%p/Inputs -Fo%t.res %s
+// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res %s
 // RUN: llvm-readobj %t.res | FileCheck %s
 // CHECK: Resource type (int): RCDATA (ID 10)
 // CHECK: Resource name (int): 42

diff  --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index ab5ecb8fa3fd..b61fba78ad01 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -114,10 +114,25 @@ ErrorOr findClang(const char *Argv0) {
 
 std::string getClangClTriple() {
   Triple T(sys::getDefaultTargetTriple());
-  T.setOS(llvm::Triple::Win32);
-  T.setVendor(llvm::Triple::PC);
-  T.setEnvironment(llvm::Triple::MSVC);
-  T.setObjectFormat(llvm::Triple::COFF);
+  switch (T.getArch()) {
+  case Triple::x86:
+  case Triple::x86_64:
+  case Triple::arm:
+  case Triple::thumb:
+  case Triple::aarch64:
+// These work properly with the clang driver, setting the expected
+// defines such as _WIN32 etc.
+break;
+  default:
+// Other archs aren't set up for use with windows as target OS, (clang
+// doesn't define e.g. _WIN32 etc), so set a reasonable default arch.
+T.setArch(Triple::x86_64);
+break;
+  }
+  T.setOS(Triple::Win32);
+  T.setVendor(Triple::PC);
+  T.setEnvironment(Triple::MSVC);
+  T.setObjectFormat(Triple::COFF);
   return T.str();
 }
 



___
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-21 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.

It's a weird flag, for sure, but if that's the semantics of it, than this 
change LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100372

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


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

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

LGTM, thanks!




Comment at: clang/test/Driver/woa-crypto.c:2
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+

Nitpick: Is it possible to test this part somewhere using the tools in the llvm 
subset of the repo? That'd keep the changes a bit more localized?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

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


[PATCH] D100756: [llvm-rc] [4/4] Add a GNU windres-like frontend to llvm-rc

2021-04-21 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 339158.
mstorsjo added a comment.

Rebased, updated with fixes making the full preprocessing test pass on windows, 
including fixes for the default arch when running on arches that aren't 
normally supported as windows targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100756

Files:
  clang/test/CMakeLists.txt
  clang/test/Preprocessor/Inputs/llvm-windres.h
  clang/test/Preprocessor/llvm-windres.rc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/tools/llvm-rc/codepage.test
  llvm/test/tools/llvm-rc/language.test
  llvm/test/tools/llvm-rc/windres-format.test
  llvm/test/tools/llvm-rc/windres-prefix.test
  llvm/test/tools/llvm-rc/windres-preproc.test
  llvm/test/tools/llvm-rc/windres-target.test
  llvm/test/tools/llvm-rc/windres-version.test
  llvm/tools/llvm-rc/CMakeLists.txt
  llvm/tools/llvm-rc/WindresOpts.td
  llvm/tools/llvm-rc/llvm-rc.cpp

Index: llvm/tools/llvm-rc/llvm-rc.cpp
===
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -18,8 +18,10 @@
 #include "ResourceScriptToken.h"
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/Object/WindowsResource.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
@@ -75,8 +77,39 @@
   RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
 };
 
+enum Windres_ID {
+  WINDRES_INVALID = 0, // This is not a correct option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  WINDRES_##ID,
+#include "WindresOpts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const WINDRES_##NAME[] = VALUE;
+#include "WindresOpts.inc"
+#undef PREFIX
+
+static const opt::OptTable::Info WindresInfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {\
+  WINDRES_##PREFIX, NAME, HELPTEXT,\
+  METAVAR,  WINDRES_##ID, opt::Option::KIND##Class,\
+  PARAM,FLAGS,WINDRES_##GROUP, \
+  WINDRES_##ALIAS,  ALIASARGS,VALUES},
+#include "WindresOpts.inc"
+#undef OPTION
+};
+
+class WindresOptTable : public opt::OptTable {
+public:
+  WindresOptTable() : OptTable(WindresInfoTable, /* IgnoreCase = */ false) {}
+};
+
 static ExitOnError ExitOnErr;
 static FileRemover TempPreprocFile;
+static FileRemover TempResFile;
 
 LLVM_ATTRIBUTE_NORETURN static void fatalError(const Twine &Message) {
   errs() << Message << "\n";
@@ -112,9 +145,8 @@
   return Path;
 }
 
-std::string getClangClTriple() {
-  Triple T(sys::getDefaultTargetTriple());
-  switch (T.getArch()) {
+Triple::ArchType getDefaultArch(Triple::ArchType Arch) {
+  switch (Arch) {
   case Triple::x86:
   case Triple::x86_64:
   case Triple::arm:
@@ -122,13 +154,17 @@
   case Triple::aarch64:
 // These work properly with the clang driver, setting the expected
 // defines such as _WIN32 etc.
-break;
+return Arch;
   default:
 // Other archs aren't set up for use with windows as target OS, (clang
 // doesn't define e.g. _WIN32 etc), so set a reasonable default arch.
-T.setArch(Triple::x86_64);
-break;
+return Triple::x86_64;
   }
+}
+
+std::string getClangClTriple() {
+  Triple T(sys::getDefaultTargetTriple());
+  T.setArch(getDefaultArch(T.getArch()));
   T.setOS(Triple::Win32);
   T.setVendor(Triple::PC);
   T.setEnvironment(Triple::MSVC);
@@ -136,10 +172,44 @@
   return T.str();
 }
 
-bool preprocess(StringRef Src, StringRef Dst, opt::InputArgList &InputArgs,
+std::string getMingwTriple() {
+  Triple T(sys::getDefaultTargetTriple());
+  T.setArch(getDefaultArch(T.getArch()));
+  if (T.isWindowsGNUEnvironment())
+return T.str();
+  // Write out the literal form of the vendor/env here, instead of
+  // constructing them with enum values (which end up with them in
+  // normalized form). The literal form of the triple can matter for
+  // finding include files.
+  return (Twine(T.getArchName()) + "-w64-mingw32").str();
+}
+
+enum Format { Rc, Res, Coff, Unknown };
+
+struct RcOptions {
+  bool Preprocess = true;
+  bool PrintCmdAndExit = false;
+  std::string Triple;
+  std::vector PreprocessCmd;
+  std::vector PreprocessArgs;
+
+  std::string InputFile;
+  Format InputFormat = Rc;
+  std::string OutputFile;
+  Format OutputFormat = Res;
+
+  bool BeVerbose = false;
+  WriterParams Params;
+  bool AppendNull = false;
+  bool IsDryRun = false;
+  // Set the 

[PATCH] D100819: [RISCV] Implement the vneg.v builtin.

2021-04-21 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c:3
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
+// RUN:   -target-feature +experimental-zfh -disable-O0-optnone 
-fallow-half-arguments-and-returns -emit-llvm %s -o - | opt -S -mem2reg | 
FileCheck --check-prefix=CHECK-RV32 %s

nit: The integer intrinsic functions do not need the -target-feature +f, +d and 
+experimental-zfh.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100819

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


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

Yes, it looks easy enough to add something in 
`llvm/unittests/ADT/TripleTest.cpp` to directly test `getARMCPUForArch`.

I'd mildly prefer to do that //as well// as having the test here, because the 
call site in the clang driver is quite complicated. My real aim is that asking 
for `crypto` (or any other Armv8-specific extension) should actually get it; I 
think any accidental regression of that behavior in future is at least as 
likely to arise from changes in `clang/lib/Driver` as `llvm/lib/Support`, so 
I'd like there to be a test that will detect the regression if it occurs for 
//any// reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

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


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D100937#2704530 , @simon_tatham 
wrote:

> Yes, it looks easy enough to add something in 
> `llvm/unittests/ADT/TripleTest.cpp` to directly test `getARMCPUForArch`.
>
> I'd mildly prefer to do that //as well// as having the test here, because the 
> call site in the clang driver is quite complicated. My real aim is that 
> asking for `crypto` (or any other Armv8-specific extension) should actually 
> get it; I think any accidental regression of that behavior in future is at 
> least as likely to arise from changes in `clang/lib/Driver` as 
> `llvm/lib/Support`, so I'd like there to be a test that will detect the 
> regression if it occurs for //any// reason.

Fair enough, that sounds like a reasonable plan to me. Yeah having tests for 
the actual end results is kinda nice instead of just small broken up unit 
tests, especially when it isn't something that shouldn't change spuriously 
(like generated code).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

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


[PATCH] D100935: [OpenCL] Add missing C++ legacy atomics with generic

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

I realized that as they haven't been added to the OpenCL 3 yet it means they 
remain as Clang extension. I am going to document this. We could allow their 
uses in OpenCL C too as an extension though. There were other requests to make 
them available in OpenCL C too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100935

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


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 339161.
simon_tatham added a comment.

Added a unit test on the LLVM side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

Files:
  clang/test/Driver/woa-crypto.c
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp


Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1511,6 +1511,7 @@
   {
 llvm::Triple Triple("arm--win32");
 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
+EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
   }
   // Some alternative architectures
   {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"


Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1511,6 +1511,7 @@
   {
 llvm::Triple Triple("arm--win32");
 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
+EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
   }
   // Some alternative architectures
   {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

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


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

2021-04-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9985
+ "Address space agnostic languages only");
+  LangAS DefaultGlobalAS = getLangASFromTargetAS(
+  CGM.getContext().getTargetAddressSpace(LangAS::sycl_global));

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > bader wrote:
> > > > > Anastasia wrote:
> > > > > > bader wrote:
> > > > > > > Anastasia wrote:
> > > > > > > > bader wrote:
> > > > > > > > > Anastasia wrote:
> > > > > > > > > > bader wrote:
> > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > Since you are using SYCL address space you should 
> > > > > > > > > > > > probably guard this line by SYCL mode...  Btw the same 
> > > > > > > > > > > > seems to apply to the code below as it implements SYCL 
> > > > > > > > > > > > sematics?
> > > > > > > > > > > > 
> > > > > > > > > > > > Can you add spec references here too.
> > > > > > > > > > > > 
> > > > > > > > > > > > Also there seems to be nothing target specific in the 
> > > > > > > > > > > > code here as you are implementing what is specified by 
> > > > > > > > > > > > the language semantics. Should this not be moved to 
> > > > > > > > > > > > `GetGlobalVarAddressSpace` along with the other 
> > > > > > > > > > > > language handling?
> > > > > > > > > > > > 
> > > > > > > > > > > > I am not very familiar with this part of address space 
> > > > > > > > > > > > handling though. I would be more comfortable if 
> > > > > > > > > > > > @rjmccall could take a look too.
> > > > > > > > > > > This code assigns target address space "global variables 
> > > > > > > > > > > w/o address space attribute". 
> > > > > > > > > > > SYCL says it's "implementation defined" (from 
> > > > > > > > > > > https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#subsec:commonAddressSpace):
> > > > > > > > > > > 
> > > > > > > > > > > > Namespace scope
> > > > > > > > > > > > If the type is const, the address space the declaration 
> > > > > > > > > > > > is assigned to is implementation-defined. If the target 
> > > > > > > > > > > > of the SYCL backend can represent the generic address 
> > > > > > > > > > > > space, then the assigned address space must be 
> > > > > > > > > > > > compatible with the generic address space.
> > > > > > > > > > > > Namespace scope non-const declarations cannot be used 
> > > > > > > > > > > > within a kernel, as restricted in Section 5.4. This 
> > > > > > > > > > > > means that non-const global variables cannot be 
> > > > > > > > > > > > accessed by any device kernel or code called by the 
> > > > > > > > > > > > device kernel.
> > > > > > > > > > > 
> > > > > > > > > > > I added clarification that SPIR target allocates global 
> > > > > > > > > > > variables in global address space to 
> > > > > > > > > > > https://reviews.llvm.org/D99488 (see line #248).
> > > > > > > > > > > 
> > > > > > > > > > > @rjmccall, mentioned in the mailing list discussion that 
> > > > > > > > > > > this callbacks were developed for compiling C++ to AMDGPU 
> > > > > > > > > > > target, so this not necessary designed only for SYCL, but 
> > > > > > > > > > > it works for SYCL as well.
> > > > > > > > > > After all what objects are allowed to bind to non-default 
> > > > > > > > > > address space here is defined in SYCL spec even if the 
> > > > > > > > > > exact address spaces are not defined so it is not 
> > > > > > > > > > completely a target-specific behavior.
> > > > > > > > > > 
> > > > > > > > > > My understanding of the API you are extending (judging from 
> > > > > > > > > > its use) is that it allows you to extend the language 
> > > > > > > > > > sematics with some target-specific setup. I.e. you could 
> > > > > > > > > > add extra address spaces to C++ or OpenCL or any other 
> > > > > > > > > > language. But here you are setting the language address 
> > > > > > > > > > spaces instead that are mapped to the target at some point 
> > > > > > > > > > implicitly.
> > > > > > > > > > 
> > > > > > > > > > It seems like this change better fits to 
> > > > > > > > > > `CodeGenModule::GetGlobalVarAddressSpace` that already 
> > > > > > > > > > contains very similar logic?
> > > > > > > > > > 
> > > > > > > > > > Otherwise, it makes more sense to use target address spaces 
> > > > > > > > > > directly instead of SYCL language address spaces. But 
> > > > > > > > > > either way, we should guard it by SYCL mode somehow as we 
> > > > > > > > > > have not established this as a universal logic for SPIR. 
> > > > > > > > > > It seems like this change better fits to 
> > > > > > > > > > `CodeGenModule::GetGlobalVarAddressSpace` that already 
> > > > > > > > > > contains very similar logic?
> > > > > > > > > 
> > > > > > > > > This was the original implementation (see 
> > > > > > > > > https://reviews.llvm.org/D89909?id=299795), but @rjmccall 
> > > > > > > > > suggested to use this callback instead.
> > > > > > > > > 

[clang] 77e170d - [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2021-04-21T11:20:05+01:00
New Revision: 77e170db8678e582af986ffe27e12df196e4357b

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

LOG: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

If you gave clang the options `--target=arm-pc-windows-msvc` and
`-march=armv8-a+crypto` together, the crypto extension would not be
enabled in the compilation, and you'd see the following warning
message suggesting that the 'armv8-a' had been ignored:

  clang: warning: ignoring extension 'crypto' because the 'armv7-a' 
architecture does not support it [-Winvalid-command-line-argument]

This happens because Triple::getARMCPUForArch(), for the Win32 OS,
unconditionally returns "cortex-a9" (an Armv7 CPU) regardless of
MArch, which overrides the architecture setting on the command line.

I don't think that the combination of Windows and AArch32 _should_
unconditionally outlaw the use of the crypto extension. MSVC itself
doesn't think so: you can perfectly well compile Thumb crypto code
using its AArch32-targeted compiler.

All the other default CPUs in the same switch statement are
conditional on a particular MArch setting; this is the only one that
returns a particular CPU _regardless_ of MArch. So I've fixed this one
by adding a condition, so that if you ask for an architecture *above*
v7, the default of Cortex-A9 no longer overrides it.

Reviewed By: mstorsjo

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

Added: 
clang/test/Driver/woa-crypto.c

Modified: 
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp

Removed: 




diff  --git a/clang/test/Driver/woa-crypto.c b/clang/test/Driver/woa-crypto.c
new file mode 100644
index 0..5670f2417b09e
--- /dev/null
+++ b/clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 3c2182ecb09a0..88311546354b6 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const 
{
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:

diff  --git a/llvm/unittests/ADT/TripleTest.cpp 
b/llvm/unittests/ADT/TripleTest.cpp
index 2e3c78aa4f640..eeba4d8895d78 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -1511,6 +1511,7 @@ TEST(TripleTest, getARMCPUForArch) {
   {
 llvm::Triple Triple("arm--win32");
 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
+EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
   }
   // Some alternative architectures
   {



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


[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

2021-04-21 Thread Simon Tatham 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 rG77e170db8678: [ARM][Driver][Windows] Allow command-line 
upgrade to Armv8. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100937

Files:
  clang/test/Driver/woa-crypto.c
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp


Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1511,6 +1511,7 @@
   {
 llvm::Triple Triple("arm--win32");
 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
+EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
   }
   // Some alternative architectures
   {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 
-o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"


Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1511,6 +1511,7 @@
   {
 llvm::Triple Triple("arm--win32");
 EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
+EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
   }
   // Some alternative architectures
   {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE
-return "cortex-a9";
+if (ARM::parseArchVersion(MArch) <= 7)
+  return "cortex-a9";
+break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc   -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100727: [clang-format] Correctly apply AllowShortIfStatementsOnASingleLine: Always to else branch.

2021-04-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

this LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

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


[PATCH] D99840: [clang-format] Correctly attach enum braces with ShortEnums disabled

2021-04-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> I don't think we should change the LLVM style

I'm not 100% convinced we are changing the LLVM style per say.

LLVM always "cuddles" the "{"  and Allow short Enums on a single line is true, 
this means if the "{" is on a new line then I think its actually a bug. 
@curdeius  what say you?

It be interested to know the impact on the LLVM tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99840

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


[clang] 174e796 - [llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options starting with a slash

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

Author: Martin Storsjö
Date: 2021-04-21T13:34:33+03:00
New Revision: 174e796c7d41e720e2a78e3de451b893d9e3a43f

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

LOG: [llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from 
options starting with a slash

This should fix test failures on macOS.

Added: 


Modified: 
clang/test/Preprocessor/llvm-rc.rc

Removed: 




diff  --git a/clang/test/Preprocessor/llvm-rc.rc 
b/clang/test/Preprocessor/llvm-rc.rc
index 799bf347dbee..f08fdd0506bb 100644
--- a/clang/test/Preprocessor/llvm-rc.rc
+++ b/clang/test/Preprocessor/llvm-rc.rc
@@ -1,4 +1,4 @@
-// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res %s
+// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res -- %s
 // RUN: llvm-readobj %t.res | FileCheck %s
 // CHECK: Resource type (int): RCDATA (ID 10)
 // CHECK: Resource name (int): 42



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


[PATCH] D100755: [llvm-rc] [3/4] Run clang to preprocess input files

2021-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Purely FYI: the `--` in the test isn't needed just on macOS but also on Linux 
if your checkout is eg under /usr: http://45.33.8.238/linux/44652/step_7.txt

(clang-cl has some nice diag if the /U flag is an existing file, since that 
happens fairly often. Maybe llvm-rc could have a nicer diag in that case too 
and suggest `--`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100755

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


[PATCH] D100929: [Clang] Allow the combination of loader_uninitialized and address spaces

2021-04-21 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

I misread this as implying loaded_uninitialized for addrspace globals, but 
actually it's a straightforward oversight from the original implementation. 
Thanks!




Comment at: clang/test/CodeGen/attr-loader-uninitialized.c:21
 // CHECK: @i ={{.*}} global %struct.s undef
+// CHECK: @j1 ={{.*}}addrspace(1) global %struct.s undef
+// CHECK: @j2 ={{.*}}addrspace(2) global %struct.s undef

addrspace(0) presumably works the same way. Iirc addrspace(0) is different from 
no addrspace specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100929

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


[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-04-21 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 339169.
steffenlarsen added a comment.

Changes:

- Removed integer type from builtin and intrinsic names.
- Signedness in builtin and intrinsic names moved to operator name, i.e. umin 
and umax.
- Removed redundant addition variant.


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

https://reviews.llvm.org/D100124

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/test/CodeGenCUDA/redux-builtins.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/redux-sync.ll

Index: llvm/test/CodeGen/NVPTX/redux-sync.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/redux-sync.ll
@@ -0,0 +1,65 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+
+declare i32 @llvm.nvvm.redux.sync.umin(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_min_u32
+define i32 @redux_sync_min_u32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.min.u32
+  %val = call i32 @llvm.nvvm.redux.sync.umin(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.umax(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_max_u32
+define i32 @redux_sync_max_u32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.max.u32
+  %val = call i32 @llvm.nvvm.redux.sync.umax(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.add(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_add_s32
+define i32 @redux_sync_add_s32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.add.s32
+  %val = call i32 @llvm.nvvm.redux.sync.add(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.min(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_min_s32
+define i32 @redux_sync_min_s32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.min.s32
+  %val = call i32 @llvm.nvvm.redux.sync.min(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.max(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_max_s32
+define i32 @redux_sync_max_s32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.max.s32
+  %val = call i32 @llvm.nvvm.redux.sync.max(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.and(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_and_b32
+define i32 @redux_sync_and_b32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.and.b32
+  %val = call i32 @llvm.nvvm.redux.sync.and(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.xor(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_xor_b32
+define i32 @redux_sync_xor_b32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.xor.b32
+  %val = call i32 @llvm.nvvm.redux.sync.xor(i32 %src, i32 %mask)
+  ret i32 %val
+}
+
+declare i32 @llvm.nvvm.redux.sync.or(i32, i32)
+; CHECK-LABEL: .func{{.*}}redux_sync_or_b32
+define i32 @redux_sync_or_b32(i32 %src, i32 %mask) {
+  ; CHECK: redux.sync.or.b32
+  %val = call i32 @llvm.nvvm.redux.sync.or(i32 %src, i32 %mask)
+  ret i32 %val
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -274,6 +274,22 @@
 defm MATCH_ALLP_SYNC_64 : MATCH_ALLP_SYNC;
 
+multiclass REDUX_SYNC {
+  def : NVPTXInst<(outs Int32Regs:$dst), (ins Int32Regs:$src, Int32Regs:$mask),
+  "redux.sync." # BinOp # "." # PTXType # " $dst, $src, $mask;",
+  [(set Int32Regs:$dst, (Intrin Int32Regs:$src, Int32Regs:$mask))]>,
+Requires<[hasPTX70, hasSM80]>;
+}
+
+defm REDUX_SYNC_UMIN : REDUX_SYNC<"min", "u32", int_nvvm_redux_sync_umin>;
+defm REDUX_SYNC_UMAX : REDUX_SYNC<"max", "u32", int_nvvm_redux_sync_umax>;
+defm REDUX_SYNC_ADD : REDUX_SYNC<"add", "s32", int_nvvm_redux_sync_add>;
+defm REDUX_SYNC_MIN : REDUX_SYNC<"min", "s32", int_nvvm_redux_sync_min>;
+defm REDUX_SYNC_MAX : REDUX_SYNC<"max", "s32", int_nvvm_redux_sync_max>;
+defm REDUX_SYNC_AND : REDUX_SYNC<"and", "b32", int_nvvm_redux_sync_and>;
+defm REDUX_SYNC_XOR : REDUX_SYNC<"xor", "b32", int_nvvm_redux_sync_xor>;
+defm REDUX_SYNC_OR : REDUX_SYNC<"or", "b32", int_nvvm_redux_sync_or>;
+
 } // isConvergent = true
 
 //---
Index: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
===
--- llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
+++ llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
@@ -144,11 +144,13 @@
 def hasPTX61 : Predicate<"Subtarget->getPTXVersion() >= 61">;
 def hasPTX63 : Predicate<"Subtarget->getPTXVersion() >= 63">;
 def hasPTX64 : Predicate<"Subtarget->getPTXVersion() >= 64">;
+def hasPTX70 : Predicate<"Subtarget->getPTXVersion() >= 70">;
 
 def hasSM30 : Predicate<"Subtarget->getSmVersion() >= 30">;
 def hasSM70 : Predicate<"Subtarget->getSmVersion() >= 70">;
 def hasSM72 : Predicate<"Subtarget->getSmVersion() >= 72">;
 def hasSM75 : Predicate<"Subtarget->getSmVersion() >

[clang] fdcb9c2 - [OpenCL] Refactor shuffle builtin decls

2021-04-21 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-21T11:59:24+01:00
New Revision: fdcb9c272899fc270bd9bd067dc20363f54ff190

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

LOG: [OpenCL] Refactor shuffle builtin decls

The shuffle and shuffle2 builtins relied on processing two TypeLists
for different arguments in sync.  This will no longer work when a type
(e.g. double) in one of the TypeLists is optional.

Rewrite the declarations using explicit types instead of GenericTypes.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 03235985ab42..1f9a7390cd14 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -343,15 +343,10 @@ def MemoryScope   : EnumType<"memory_scope">;
 def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>;
 def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>;
 def Vec1: IntList<"Vec1", [1]>;
-def Vec2: IntList<"Vec2", [2]>;
-def Vec4: IntList<"Vec4", [4]>;
-def Vec8: IntList<"Vec8", [8]>;
-def Vec16   : IntList<"Vec16", [16]>;
 def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
 
 // Type lists.
 def TLAll   : TypeList<[Char,  UChar, Short,  UShort, Int,  UInt, 
Long,  ULong, Float, Double, Half]>;
-def TLAllUnsigned   : TypeList<[UChar, UChar, UShort, UShort, UInt, UInt, 
ULong, ULong, UInt,  ULong,  UShort]>;
 def TLFloat : TypeList<[Float, Double, Half]>;
 def TLSignedInts: TypeList<[Char, Short, Int, Long]>;
 def TLUnsignedInts  : TypeList<[UChar, UShort, UInt, ULong]>;
@@ -1141,21 +1136,33 @@ let MinVersion = CL20 in {
 //
 // OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector 
Functions
 // --- Table 19 ---
-foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-def : Builtin<"shuffle", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
-  GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
-  GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
-  }
-}
-foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-def : Builtin<"shuffle2", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
-   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
-   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
-   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
+foreach VSize1 = [2, 4, 8, 16] in {
+  foreach VSize2 = [2, 4, 8, 16] in {
+foreach VecAndMaskType = [[Char, UChar], [UChar, UChar],
+  [Short, UShort], [UShort, UShort],
+  [Int, UInt], [UInt, UInt],
+  [Long, ULong], [ULong, ULong],
+  [Float, UInt], [Double, ULong], [Half, UShort]] 
in {
+  def : Builtin<"shuffle", [VectorType,
+VectorType,
+VectorType],
+   Attr.Const>;
+}
+  }
+}
+foreach VSize1 = [2, 4, 8, 16] in {
+  foreach VSize2 = [2, 4, 8, 16] in {
+foreach VecAndMaskType = [[Char, UChar], [UChar, UChar],
+  [Short, UShort], [UShort, UShort],
+  [Int, UInt], [UInt, UInt],
+  [Long, ULong], [ULong, ULong],
+  [Float, UInt], [Double, ULong], [Half, UShort]] 
in {
+  def : Builtin<"shuffle2", [VectorType,
+ VectorType,
+ VectorType,
+ VectorType],
+Attr.Const>;
+}
   }
 }
 



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


[clang] e2b3b89 - [OpenCL] Do not add builtins with unavailable types

2021-04-21 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-21T11:59:29+01:00
New Revision: e2b3b89bf1ce74bf889897e0353a3e3fa93e4452

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

LOG: [OpenCL] Do not add builtins with unavailable types

Add functionality to assign extensions to types in OpenCLBuiltins.td
and use that information to filter candidates that should not be
exposed if a type is not available.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 1f9a7390cd148..5a9d9822dbfe3 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -50,6 +50,18 @@ class AbstractExtension {
 // Extension associated to a builtin function.
 class FunctionExtension : AbstractExtension<_Ext>;
 
+// Extension associated to a type.  This enables implicit conditionalization of
+// builtin function overloads containing a type that depends on an extension.
+// During overload resolution, when a builtin function overload contains a type
+// with a TypeExtension, those overloads are skipped when the extension is
+// disabled.
+class TypeExtension : AbstractExtension<_Ext>;
+
+// TypeExtension definitions.
+def NoTypeExt   : TypeExtension<"">;
+def Fp16TypeExt : TypeExtension<"cl_khr_fp16">;
+def Fp64TypeExt : TypeExtension<"cl_khr_fp64">;
+
 // FunctionExtension definitions.
 def FuncExtNone  : FunctionExtension<"">;
 def FuncExtKhrSubgroups  : 
FunctionExtension<"cl_khr_subgroups">;
@@ -119,6 +131,8 @@ class Type {
   string AccessQualifier = "";
   // Address space.
   string AddrSpace = DefaultAS.Name;
+  // Extension that needs to be enabled to expose a builtin that uses this 
type.
+  TypeExtension Extension = NoTypeExt;
 }
 
 // OpenCL vector types (e.g. int2, int3, int16, float8, ...).
@@ -130,6 +144,7 @@ class VectorType : Type<_Ty.Name, 
_Ty.QTExpr> {
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
   let AddrSpace = _Ty.AddrSpace;
+  let Extension = _Ty.Extension;
 }
 
 // OpenCL pointer types (e.g. int*, float*, ...).
@@ -142,6 +157,7 @@ class PointerType :
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
   let AccessQualifier = _Ty.AccessQualifier;
+  let Extension = _Ty.Extension;
 }
 
 // OpenCL const types (e.g. const int).
@@ -153,6 +169,7 @@ class ConstType : Type<_Ty.Name, _Ty.QTExpr> {
   let IsVolatile = _Ty.IsVolatile;
   let AccessQualifier = _Ty.AccessQualifier;
   let AddrSpace = _Ty.AddrSpace;
+  let Extension = _Ty.Extension;
 }
 
 // OpenCL volatile types (e.g. volatile int).
@@ -164,6 +181,7 @@ class VolatileType : Type<_Ty.Name, _Ty.QTExpr> {
   let IsConst = _Ty.IsConst;
   let AccessQualifier = _Ty.AccessQualifier;
   let AddrSpace = _Ty.AddrSpace;
+  let Extension = _Ty.Extension;
 }
 
 // OpenCL image types (e.g. image2d).
@@ -176,6 +194,7 @@ class ImageType :
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
   let AddrSpace = _Ty.AddrSpace;
+  let Extension = _Ty.Extension;
 }
 
 // OpenCL enum type (e.g. memory_scope).
@@ -277,8 +296,12 @@ def UInt  : Type<"uint",  
QualType<"Context.UnsignedIntTy">>;
 def Long  : Type<"long",  QualType<"Context.LongTy">>;
 def ULong : Type<"ulong", QualType<"Context.UnsignedLongTy">>;
 def Float : Type<"float", QualType<"Context.FloatTy">>;
-def Double: Type<"double",QualType<"Context.DoubleTy">>;
-def Half  : Type<"half",  QualType<"Context.HalfTy">>;
+let Extension = Fp64TypeExt in {
+  def Double: Type<"double",QualType<"Context.DoubleTy">>;
+}
+let Extension = Fp16TypeExt in {
+  def Half  : Type<"half",  QualType<"Context.HalfTy">>;
+}
 def Size  : Type<"size_t",QualType<"Context.getSizeType()">>;
 def PtrDiff   : Type<"ptr
diff _t", QualType<"Context.getPointerDiffType()">>;
 def IntPtr: Type<"intptr_t",  QualType<"Context.getIntPtrType()">>;

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 9eba3e812bbf1..db6a01543d76a 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -759,11 +759,20 @@ static void GetOpenCLBuiltinFctOverloads(
   Context.getDefaultCallingConvention(false, false, true));
   PI.Variadic = false;
 
+  // Do not attempt to create any FunctionTypes if there are no return types,
+  // which happens when a type belongs to a disabled extension.
+  if (RetTypes.size() == 0)
+return;
+
   // Create FunctionTypes for each (gen)type.
   for (unsigned IGenType = 0;

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

2021-04-21 Thread Sven van Haastregt 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 rGe2b3b89bf1ce: [OpenCL] Do not add builtins with unavailable 
types (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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++ -fdecla

[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-21 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 339175.
olestrohm added a comment.

Inlined the `thread_local` check and moved `static clk_event_t` into the 
appropriate test.
I did not move the `thread_local` check since NewVD had the wrong value for 
`TSCS`, so D was required.


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

https://reviews.llvm.org/D100860

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/clk_event_t.cl
  clang/test/SemaOpenCL/event_t.cl
  clang/test/SemaOpenCL/sampler_t.cl
  clang/test/SemaOpenCLCXX/template-diagnostics.clcpp

Index: clang/test/SemaOpenCLCXX/template-diagnostics.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-diagnostics.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+template
+T global_variable; //expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+clk_event_t global_event; //expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+template
+void templ() {
+  T loc;
+  //expected-error@-1{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  //expected-error@-2{{declaring variable of type '__private half' is not allowed}}
+  //expected-error@-3{{non-kernel function variable cannot be declared in local address space}}
+}
+
+void foo() {
+  templ(); //expected-note{{in instantiation of function template specialization 'templ<__read_only image1d_t>' requested here}}
+  templ(); //expected-note{{in instantiation of function template specialization 'templ' requested here}}
+  templ<__local event_t>(); //expected-note{{in instantiation of function template specialization 'templ<__local event_t>' requested here}}
+
+  image1d_t img; //expected-error{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  half h; //expected-error{{declaring variable of type '__private half' is not allowed}}
+  __local event_t e; //expected-error{{the event_t type can only be used with __private address space qualifier}}
+
+  (void) global_variable; // expected-note{{in instantiation of variable template specialization 'global_variable' requested here}}
+}
Index: clang/test/SemaOpenCL/sampler_t.cl
===
--- clang/test/SemaOpenCL/sampler_t.cl
+++ clang/test/SemaOpenCL/sampler_t.cl
@@ -48,9 +48,6 @@
 sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
 
 sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires a const or constant address space qualifier}}
-#ifdef CHECK_SAMPLER_VALUE
-// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
-#endif
 
 const sampler_t glb_smp10 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 const constant sampler_t glb_smp11 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: clang/test/SemaOpenCL/event_t.cl
===
--- clang/test/SemaOpenCL/event_t.cl
+++ clang/test/SemaOpenCL/event_t.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 
-event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}} expected-error{{program scope variable must reside in constant address space}}
+event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}}
 
 constant struct evt_s {
   event_t evt; // expected-error {{the 'event_t' type cannot be used to declare a structure or union field}}
@@ -10,7 +10,7 @@
 
 void kernel ker(event_t argevt) { // expected-error {{'__private event_t' cannot be used as the type of a kernel parameter}}
   event_t e;
-  constant event_t const_evt; // expected-error {{the event_t type can only be used with __private address space qualifier}} expected-error{{variable in constant address space must be initialized}}
+  constant event_t const_evt; // expected-error{{the '__constant event_t' type cannot be used to declare a program scope variable}}
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 'event_t'}}
Index: clang/test/SemaOpenCL/clk_event_t.cl
===
--- clang/test/SemaOpenCL/clk_event_t.cl
+++ clang/test/SemaOpenCL/clk_event_t.cl
@@ -12,6 +12,9 @@
   clk_event_t ce2;
   clk_event_t ce3 = CLK_NULL_EVENT;
 
+  // FIXME: Not obvious if this should give an error as if it was in program scope.
+  static clk_event_t ce4;
+
   if (e == ce1) { // expected-error {{invalid operands to binary expression ('__private event_t' and '__private clk_event_t')}}
 return 9;
   }
Index: clang/lib/Sema/SemaDecl.cpp
==

[PATCH] D99812: [PowerPC] [GlobalISel] Implementation of formal arguments lowering in the IRTranslator for the PPC backend

2021-04-21 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:46-58
+/**
+ * @brief Lower incoming arguments into generic MIR, this method is responsible
+ *  for splitting aggregate arguments into multiple single value types as well
+ *  as setting argument flags for each argument. This method depends on a
+ *  calling convention selector to select the correct calling convention based
+ *  on the F.getCallingConv(). Finally, FormalArgHandler takes care of the reg
+ *  assignments.

There's no reason to duplicate the documentation effort from the function this 
is overriding. This will just add bitrotting comments



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:69-71
+  // initialize instruction writer
+  if (!MBB.empty())
+MIRBuilder.setInstr(*MBB.begin());

This is probably duplicated in every target, but I don't think it is necessary 
(or it shouldn't be, the caller should have set the insert point appropriately)



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:73
+
+  // loop over each arg, set flags and split to single value types
+  SmallVector InArgs;

Capitalize



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:99
+/**
+ * @brief generates COPYs of values to registers and G_TRUNCs them whenever
+ *  the bit widths mismatch. Formal arguments lowering depends on this method

Same as above



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:111-138
+  switch (VA.getLocInfo()) {
+  default: {
+// If we are copying the value from a physical register with the
+// size larger than the size of the value itself - build the copy
+// of the phys reg first and then build the truncation of that copy.
+// The example of that would be copying from xmm0 to s32, for which
+// case ValVT == LocVT == MVT::f32. If LocSize and ValSize are not equal

Can you just rely on the default implementation?

I've been working on a patch for a while to try to clean all of this up. 
Essentially what's happening is GlobalISel is using the CCAssignFns in a way 
that's subtly incompatible with how the DAG uses it. All of the code in this 
function ends up hacking around this, and I would at least prefer to keep this 
consolidated in one place to fix.



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:143
+/**
+ * @brief Generate a load instruction to load value from the given address.
+ * @param ValVReg

Same as above



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:168-169
+  // and then truncate it
+  if (VA.getLocInfo() == CCValAssign::SExt or
+  VA.getLocInfo() == CCValAssign::ZExt) {
+Size = 4;

You shouldn't rely on the extension hint to know if the result size is larger, 
it's not necessarily true



Comment at: llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp:174
+  }
+  // otherwise, simply load the address into the destination register
+  else {

Weird comment between the control flow blocks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99812

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


[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz created this revision.
shchenz added reviewers: dblaikie, probinson, aprantl, jsji, Esme, echristo, 
PowerPC.
shchenz added a project: debug-info.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
shchenz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements `-gstrict-dwarf` option.

We had this option in clang code base just not used it.

We plan to verify the DWARF info based on DWARF 3.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100809

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -110,6 +110,18 @@
 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
 
+// For DBX, -g defaults to -gstrict-dwarf.
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STRICT %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STRICT %s
+// RUN: %clang -### -c -g -gno-strict-dwarf %s -target powerpc-ibm-aix-xcoff \
+// RUN: 2>&1 | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -### -c -g -ggdb %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+
 // On the AIX, -g defaults to -gno-column-info.
 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=NOCI %s
@@ -314,6 +326,9 @@
 // G_SCE:  "-debugger-tuning=sce"
 // G_DBX:  "-debugger-tuning=dbx"
 //
+// G_STRICT:  "-gstrict-dwarf"
+// STRICT-NOT:  "-gstrict-dwarf"
+//
 // G_NOTUNING: "-cc1"
 // G_NOTUNING-NOT: "-debugger-tuning="
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3968,7 +3968,14 @@
   DebugInfoKind == codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::NoDebugInfo;
 
-  // We ignore flag -gstrict-dwarf for now.
+  // strict DWARF is set to false by default. But for DBX, we need it to be set
+  // as true by default.
+  if (const Arg *A = Args.getLastArg(options::OPT_gstrict_dwarf))
+(void)checkDebugInfoOption(A, Args, D, TC);
+  if (Args.hasFlag(options::OPT_gstrict_dwarf, options::OPT_gno_strict_dwarf,
+   DebuggerTuning == llvm::DebuggerKind::DBX))
+CmdArgs.push_back("-gstrict-dwarf");
+
   // And we handle flag -grecord-gcc-switches later with DWARFDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2779,8 +2779,10 @@
   Group;
 def : Flag<["-"], "grecord-gcc-switches">, Alias;
 def : Flag<["-"], "gno-record-gcc-switches">, Alias;
-def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group;
-def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group;
+defm strict_dwarf : BoolOption<"g", "strict-dwarf",
+  CodeGenOpts<"DebugStrictDwarf">, DefaultFalse,
+  PosFlag, NegFlag, BothFlags<[CoreOption]>>,
+  Group;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag, PosFlag, BothFlags<[CoreOption]>>,
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -293,6 +293,7 @@
 VALUE_CODEGENOPT(StackProbeSize, 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
 CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
+CODEGENOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF 
info.
 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
   ///< in debug info.
 
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -3546,6 +3546,8 @@
 
 .. option:: -gstrict-dwarf, -gno-strict-dwarf
 
+Use DWARF extensions in later DWARF versions.
+
 .. option:: -gz=, -gz (equivalent to -gz=zlib)
 
 DWARF debug sections compres

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

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2697732 , @dblaikie wrote:

> In D100630#2697728 , @shchenz wrote:
>
>> In D100630#2694681 , @probinson 
>> wrote:
>>
>>> If DBX is going to be really pedantic about not recognizing tags or 
>>> attributes that don't align with the DWARF version, maybe we're better off 
>>> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.
>>
>> Hi @probinson thanks for pointing out the way, agree with this new solution. 
>> After checking the codes, I found there are already `-gstrict-dwarf`, 
>> `-gno-strict-dwarf` options in clang code base, but there seem no users of 
>> them. Do you happen to know the story of these two options? I get a quick 
>> search, no clue yet. Can we reuse these options for the intention here. 
>> Thanks?
>
> I'd suggest checking the history of the commits that added them - but likely 
> they were added for command line compatibility with gcc but I expect they're 
> currently no-ops in Clang. Adding the expected functionality to them seems 
> fine to me.

Yes, it should be for compatibility with gcc. I found same options in gcc. I 
create patch D100809  for this support in 
clang. Could you please help to review? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 338697.
Ericson2314 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -86,10 +88,10 @@
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
 DESTINATION lib/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -275,7 +275,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -83,14 +83,15 @@
 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+get_filename_component(base_includedir "${CMAKE_INSTALL_INCLUDEDIR}" ABSOLUTE BASE_DIR "${POLLY_INSTALL_PREFIX}")
 if (POLLY_BUNDLED_ISL)
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
-"${POLLY_INSTALL_PREFIX}/include/polly"
+"${base_includedir}"
+"${base_includedir}/polly"
 )
 else()
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
+"${base_includedir}"
 ${ISL_INCLUDE_DIRS}
 )
 endif()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -2,7 +2,11 @@
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
+endif()
+
+include(GNUInstallDirs)
 
+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
@@ -122,13 +126,13 @@
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 FILES_MATCHING
 PATTERN "*.h"
 )
 
   install(DIRECTORY ${POLLY_BINARY_DIR}/include/
-  

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

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 338695.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().getDebugStrictDwarf() &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().getDebugStrictDwarf() &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 338755.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=4 -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=3 -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=4 -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=3 -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100826: [Debug-Info][NFC] add -gstrict-dwarf support in backend

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz created this revision.
shchenz added reviewers: dblaikie, probinson, aprantl, jsji, Esme, echristo, 
PowerPC.
shchenz added a project: debug-info.
Herald added a subscriber: hiraditya.
shchenz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

we add `-gstrict-dwarf` support in FE in D100809 
, this patch is to add the same support in 
BE, it contains:
1: supporting passing the strict dwarf flags to `TargetOptions`;
2: adding a debug option `-strict-dwarf` to backend components, like llc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100826

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp


Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -96,6 +96,7 @@
 CGOPT(bool, ValueTrackingVariableLocations)
 CGOPT(bool, ForceDwarfFrameSection)
 CGOPT(bool, XRayOmitFunctionIndex)
+CGOPT(bool, DebugStrictDwarf)
 
 codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 #define CGBINDOPT(NAME)
\
@@ -470,6 +471,11 @@
   cl::init(false));
   CGBINDOPT(XRayOmitFunctionIndex);
 
+  static cl::opt DebugStrictDwarf(
+  "strict-dwarf", cl::desc("use strict dwarf"),
+  cl::init(false));
+  CGBINDOPT(DebugStrictDwarf);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -566,6 +572,7 @@
   Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations();
   Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
   Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
+  Options.DebugStrictDwarf = getDebugStrictDwarf();
 
   Options.MCOptions = mc::InitMCTargetOptionsFromFlags();
 
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -141,6 +141,7 @@
   SupportsDebugEntryValues(false), EnableDebugEntryValues(false),
   PseudoProbeForProfiling(false), 
ValueTrackingVariableLocations(false),
   ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
+  DebugStrictDwarf(false),
   FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
 
 /// DisableFramePointerElim - This returns true if frame pointer 
elimination
@@ -331,6 +332,10 @@
 /// Emit XRay Function Index section
 unsigned XRayOmitFunctionIndex : 1;
 
+/// When set to true, don't use DWARF extensions in later DWARF versions.
+/// By default, it is set to false.
+unsigned DebugStrictDwarf : 1;
+
 /// Stack protector guard offset to use.
 unsigned StackProtectorGuardOffset = -1U;
 
Index: llvm/include/llvm/CodeGen/CommandFlags.h
===
--- llvm/include/llvm/CodeGen/CommandFlags.h
+++ llvm/include/llvm/CodeGen/CommandFlags.h
@@ -140,6 +140,8 @@
 
 bool getXRayOmitFunctionIndex();
 
+bool getDebugStrictDwarf();
+
 /// Create this object with static storage to register codegen-related command
 /// line options.
 struct RegisterCodeGenFlags {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -598,6 +598,7 @@
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
   Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
   Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+  Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;
 
   return true;
 }


Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -96,6 +96,7 @@
 CGOPT(bool, ValueTrackingVariableLocations)
 CGOPT(bool, ForceDwarfFrameSection)
 CGOPT(bool, XRayOmitFunctionIndex)
+CGOPT(bool, DebugStrictDwarf)
 
 codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 #define CGBINDOPT(NAME)\
@@ -470,6 +471,11 @@
   cl::init(false));
   CGBINDOPT(XRayOmitFunctionIndex);
 
+  static cl::opt DebugStrictDwarf(
+  "strict-dwarf", cl::desc("use strict dwarf"),
+  cl::init(false));
+  CGBINDOPT(DebugStrictDwarf);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -566,6 +572,7 @@
   Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations();
   Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
   Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
+  Options.DebugStrictDwarf = getDebugStrictDwarf();
 
   Options.MCOptions = mc::InitMCTarg

[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3549-3550
 
+Use DWARF extensions in later DWARF versions.
+
 .. option:: -gz=, -gz (equivalent to -gz=zlib)

This description is probably backwards/doesn't explicitly clarify which version 
of the flag does which behavior.

I guess the only nearby example is the -gembed-source, which describes the 
effect of -gembed-source, not the effect of -gno-embed-source.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3973-3974
+  // as true by default.
+  if (const Arg *A = Args.getLastArg(options::OPT_gstrict_dwarf))
+(void)checkDebugInfoOption(A, Args, D, TC);
+  if (Args.hasFlag(options::OPT_gstrict_dwarf, options::OPT_gno_strict_dwarf,

@aprantl or anyone else - is this the right use of checkDebugInfoOption? I 
forget what it's for/how it should be used.



Comment at: clang/test/Driver/debug-options.c:329-330
 //
+// G_STRICT:  "-gstrict-dwarf"
+// STRICT-NOT:  "-gstrict-dwarf"
+//

"STRICT" v "G_STRICT" seems confusing to me - how do other flags differentiate 
their positive/negative tests? (looks like GNO_X/GX or GX/NOX, etc - something 
like that'd be good)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100809

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


[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 338752.
shchenz marked 2 inline comments as done.
shchenz added a comment.

address @dblaikie comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100809

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -110,6 +110,18 @@
 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
 
+// For DBX, -g defaults to -gstrict-dwarf.
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -### -c -g -gno-strict-dwarf %s -target powerpc-ibm-aix-xcoff \
+// RUN: 2>&1 | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -### -c -g -ggdb %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOSTRICT %s
+
 // On the AIX, -g defaults to -gno-column-info.
 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=NOCI %s
@@ -314,6 +326,9 @@
 // G_SCE:  "-debugger-tuning=sce"
 // G_DBX:  "-debugger-tuning=dbx"
 //
+// STRICT:  "-gstrict-dwarf"
+// NOSTRICT-NOT:  "-gstrict-dwarf"
+//
 // G_NOTUNING: "-cc1"
 // G_NOTUNING-NOT: "-debugger-tuning="
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3968,7 +3968,14 @@
   DebugInfoKind == codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::NoDebugInfo;
 
-  // We ignore flag -gstrict-dwarf for now.
+  // strict DWARF is set to false by default. But for DBX, we need it to be set
+  // as true by default.
+  if (const Arg *A = Args.getLastArg(options::OPT_gstrict_dwarf))
+(void)checkDebugInfoOption(A, Args, D, TC);
+  if (Args.hasFlag(options::OPT_gstrict_dwarf, options::OPT_gno_strict_dwarf,
+   DebuggerTuning == llvm::DebuggerKind::DBX))
+CmdArgs.push_back("-gstrict-dwarf");
+
   // And we handle flag -grecord-gcc-switches later with DWARFDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2779,8 +2779,10 @@
   Group;
 def : Flag<["-"], "grecord-gcc-switches">, Alias;
 def : Flag<["-"], "gno-record-gcc-switches">, Alias;
-def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group;
-def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group;
+defm strict_dwarf : BoolOption<"g", "strict-dwarf",
+  CodeGenOpts<"DebugStrictDwarf">, DefaultFalse,
+  PosFlag, NegFlag, BothFlags<[CoreOption]>>,
+  Group;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag, PosFlag, BothFlags<[CoreOption]>>,
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -293,6 +293,7 @@
 VALUE_CODEGENOPT(StackProbeSize, 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
 CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
+CODEGENOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF 
info.
 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
   ///< in debug info.
 
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -3546,6 +3546,8 @@
 
 .. option:: -gstrict-dwarf, -gno-strict-dwarf
 
+Don't use DWARF extensions in later DWARF versions for strict DWARF.
+
 .. option:: -gz=, -gz (equivalent to -gz=zlib)
 
 DWARF debug sections compression type


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -110,6 +110,18 @@
 // RUN: %clang -### -c -g %s -t

[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3973-3974
+  // as true by default.
+  if (const Arg *A = Args.getLastArg(options::OPT_gstrict_dwarf))
+(void)checkDebugInfoOption(A, Args, D, TC);
+  if (Args.hasFlag(options::OPT_gstrict_dwarf, options::OPT_gno_strict_dwarf,

dblaikie wrote:
> @aprantl or anyone else - is this the right use of checkDebugInfoOption? I 
> forget what it's for/how it should be used.
See the nearby example for `-gcolumn-info`:
```
  if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
(void)checkDebugInfoOption(A, Args, D, TC)
```



Comment at: clang/test/Driver/debug-options.c:329-330
 //
+// G_STRICT:  "-gstrict-dwarf"
+// STRICT-NOT:  "-gstrict-dwarf"
+//

dblaikie wrote:
> "STRICT" v "G_STRICT" seems confusing to me - how do other flags 
> differentiate their positive/negative tests? (looks like GNO_X/GX or GX/NOX, 
> etc - something like that'd be good)
use the similar way like `GPUB` & `NOPUB`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100809

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


[PATCH] D100826: [Debug-Info][NFC] add -gstrict-dwarf support in backend

2021-04-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

You have a clang-format warning, aside from that LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100826

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


[PATCH] D100826: [Debug-Info][NFC] add -gstrict-dwarf support in backend

2021-04-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Do you know if you're going to be using LTO with DBX? If so, to respect this 
flag, it would need to be added to LLVM IR module metadata (like the Dwarf 
Version and Debug Info Version fields) rather than as an MCOption. (we're 
pretty wishy-washy about what things we decide have to be carried through LTO 
(& thus go in the IR metadata) and what things we're OK saying "eh, this'll be 
set on MCOptions or in a -mllvm flag and you'll have to pass the flag to your 
link step if you want this functionality in an LTO build") - so there's no hard 
line here)

If you stick with the MCOption, it'll need to be plumbed into llc as a flag 
there, and should be tested (might be that the whole functionality of the llc 
flag, MCOption to lower it to, and its use in LLVM's debug info emission should 
go together in one patch - I'm not sure)

A general architectural issue too: I think the other patches that are using 
this functionality for specific features should be abandoned if the following 
alternative is possible: Could the code for adding attributes be modified to 
check the version of the attribute and omit it if the in-use version doesn't 
support the attribute (& strict DWARF is enabled)? (is it only attributes 
you're dealing with, or also tags? I would guess for tags the architectural 
changes might be a bit more difficult, but I think would still be worth 
considering such a general solution)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100826

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


[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Nit on the description, this patch supports -gstrict-dwarf in the frontend.




Comment at: clang/docs/ClangCommandLineReference.rst:3549-3550
 
+Use DWARF extensions in later DWARF versions.
+
 .. option:: -gz=, -gz (equivalent to -gz=zlib)

dblaikie wrote:
> This description is probably backwards/doesn't explicitly clarify which 
> version of the flag does which behavior.
> 
> I guess the only nearby example is the -gembed-source, which describes the 
> effect of -gembed-source, not the effect of -gno-embed-source.
Maybe something like, "Restrict DWARF features to those defined in the 
specified version, avoiding features from later versions."



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3973-3974
+  // as true by default.
+  if (const Arg *A = Args.getLastArg(options::OPT_gstrict_dwarf))
+(void)checkDebugInfoOption(A, Args, D, TC);
+  if (Args.hasFlag(options::OPT_gstrict_dwarf, options::OPT_gno_strict_dwarf,

shchenz wrote:
> dblaikie wrote:
> > @aprantl or anyone else - is this the right use of checkDebugInfoOption? I 
> > forget what it's for/how it should be used.
> See the nearby example for `-gcolumn-info`:
> ```
>   if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
> (void)checkDebugInfoOption(A, Args, D, TC)
> ```
It's a wrapper for ToolChain::supportsDebugInfoOption() and the only 
implementation I see is for Cuda, which has severely limited support for the g 
options.  I think this is correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100809

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


[PATCH] D100809: [Debug-Info] implement -gstrict-dwarf

2021-04-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100809

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


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-21 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

The way I see it, the notion of convergence is relevant only to a certain class 
of targets (usually represented by GPUs) and it only affects certain 
optimizations. Then why not have only these optimizations check `TTI` to see if 
convergence matters? `TTI.hasBranchDivergence()` seems like a sufficient proxy 
for this information.

1. `convergent` becomes the default in LLVM IR, but it does not affect 
optimizations on non-GPU targets.
2. This is not a reinterpretation of the same IR on different targets. The 
notional execution model of LLVM IR will say that all function calls are 
convergent. Targets that only care about one thread at a time represent the 
degenerate case where all executions are convergent anyway.

This recasts the whole question to be one about combining optimizations with 
target-specific information. The only changes required are in transforms that 
check `CallInst::isConvergent()`. These should now also check `TTI`, possibly 
adding a dependency on the `TTI` analysis where it didn't exist earlier.


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

https://reviews.llvm.org/D69498

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


[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-04-21 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-21 Thread Jay Foad via Phabricator via cfe-commits
foad added a comment.

In D69498#2703317 , @sameerds wrote:

> The way I see it, the notion of convergence is relevant only to a certain 
> class of targets (usually represented by GPUs) and it only affects certain 
> optimizations. Then why not have only these optimizations check `TTI` to see 
> if convergence matters? `TTI.hasBranchDivergence()` seems like a sufficient 
> proxy for this information.
>
> 1. `convergent` becomes the default in LLVM IR, but it does not affect 
> optimizations on non-GPU targets.
> 2. This is not a reinterpretation of the same IR on different targets. The 
> notional execution model of LLVM IR will say that all function calls are 
> convergent. Targets that only care about one thread at a time represent the 
> degenerate case where all executions are convergent anyway.
>
> This recasts the whole question to be one about combining optimizations with 
> target-specific information. The only changes required are in transforms that 
> check `CallInst::isConvergent()`. These should now also check `TTI`, possibly 
> adding a dependency on the `TTI` analysis where it didn't exist earlier.

@sameerds I agree with your conclusions but I would describe the situation a 
little differently. As I understand it, the optimizations that check 
isConvergent really only care about moving convergent calls past control flow 
//that might be divergent//. !hasBranchDivergence is a promise that there are 
no possible sources of divergence for a target, so you can run a divergence 
analysis if you like but it will just tell you that everything is uniform, so 
all control flow is uniform, so it's OK to move isConvergent calls around.

In practice the optimizations that check isConvergent don't seem to use 
divergence analysis, they just pessimistically assume that any control flow 
might be divergent (if hasBranchDivergence). But they could and perhaps should 
use divergence analysis, and then it would all just fall out in the wash with 
no need for an explicit hasBranchDivergence test.


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

https://reviews.llvm.org/D69498

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


[PATCH] D100942: [clang][deps] Include "-cc1" in the arguments

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

To simplify tools consuming dependency scanning results, prepend the "-cc1" 
argument by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100942

Files:
  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
@@ -37,6 +37,7 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK:  "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
 // CHECK:  
"-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NOT:  "-fimplicit-module-maps",
@@ -53,6 +54,7 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK-NOT:  "-fimplicit-module-maps",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
@@ -67,6 +69,7 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK-NOT:  "-fimplicit-module-maps",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -43,18 +43,13 @@
   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.
+  // Synthesize full command line from the CompilerInvocation, including 
"-cc1".
+  SmallVector Args{"-cc1"};
   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;
+  return std::vector{Args.begin(), Args.end()};
 }
 
 std::vector ModuleDeps::getFullCommandLine(


Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -37,6 +37,7 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK:  "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
 // CHECK:  "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NOT:  "-fimplicit-module-maps",
@@ -53,6 +54,7 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK-NOT:  "-fimplicit-module-maps",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
@@ -67,6 +69,7 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
 // CHECK-NOT:  "-fimplicit-module-maps",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -43,18 +43,13 @@
   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.
+  // Synthesize full command line from the CompilerInvocation, including "-cc1".
+  SmallVector Args{"-cc1"};
   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;
+ 

[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-21 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

In D69498#2704364 , @foad wrote:

>> This recasts the whole question to be one about combining optimizations with 
>> target-specific information. The only changes required are in transforms 
>> that check `CallInst::isConvergent()`. These should now also check `TTI`, 
>> possibly adding a dependency on the `TTI` analysis where it didn't exist 
>> earlier.
>
> @sameerds I agree with your conclusions but I would describe the situation a 
> little differently. As I understand it, the optimizations that check 
> isConvergent really only care about moving convergent calls past control flow 
> //that might be divergent//. !hasBranchDivergence is a promise that there are 
> no possible sources of divergence for a target, so you can run a divergence 
> analysis if you like but it will just tell you that everything is uniform, so 
> all control flow is uniform, so it's OK to move isConvergent calls around.
>
> In practice the optimizations that check isConvergent don't seem to use 
> divergence analysis, they just pessimistically assume that any control flow 
> might be divergent (if hasBranchDivergence). But they could and perhaps 
> should use divergence analysis, and then it would all just fall out in the 
> wash with no need for an explicit hasBranchDivergence test.

Sure it is formally the same thing. But in practice, the main issue for 
everyone is the effect on compile time for targets that don't care about 
convergence/divergence. For such targets, running even the divergence analysis 
is an unnecessary cost. Any checks for uniform control flow will still be 
hidden under TTI.hasBranchDivergence() for such targets. We see that happening 
already in places where divergence analysis is constructed optionally.


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

https://reviews.llvm.org/D69498

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


[PATCH] D100933: [clang] Recognize ppc32 as valid mcpu value

2021-04-21 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai 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/D100933/new/

https://reviews.llvm.org/D100933

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


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

2021-04-21 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 339187.
jansvoboda11 added a comment.

Rebase on top of D100942 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

Index: clang/test/ClangScanDeps/modules-inferred.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred.m
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%S/Inputs/frameworks|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: echo -%t.dir > %t.result
+// RUN: echo -%S >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources >> %t.result
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
+#include 
+
+inferred a = 0;
+
+// CHECK: -[[PREFIX:.*]]
+// CHECK-NEXT: -[[SOURCEDIR:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
+// CHECK:  "-emit-module",
+// CHECK:  "-fmodule-name=Inferred",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1:[A-Z0-9]+]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "module-name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// 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]]/Inferred-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT: "-fmodule-map-file=[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/modules-inferred-explicit-build.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred-explicit-build.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%/S/Inputs/frameworks|g" -e "s|-E|-x objective-c -E|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources > %t.db
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp
+// RUN: %clang @%t.inferred.rsp -pedantic -Werror
+/

[PATCH] D100276: [clang] p1099 using enum part 1

2021-04-21 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

thanks for the comments.  My plan wrt documentation was to address that (and 
the feature macro) once the patches are in.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:12353
+  ED = R->getAsSingle();
+else if (UD && UD->shadow_size () == 1)
+  ED = dyn_cast(UD->shadow_begin()->getTargetDecl());

bruno wrote:
> -> `UD->shadow_size()`
Hm, I wonder what happened, I was pretty sure I ran git clang-format.


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

https://reviews.llvm.org/D100276

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


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-21 Thread Jay Foad via Phabricator via cfe-commits
foad added a comment.

> But in practice, the main issue for everyone is the effect on compile time 
> for targets that don't care about convergence/divergence. For such targets, 
> running even the divergence analysis is an unnecessary cost.

LegacyDivergenceAnalysis::runOnFunction bails out immediately if 
!hasBranchDivergence.


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

https://reviews.llvm.org/D69498

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


[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-04-21 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 339189.
xbolva00 added a comment.

Added tests


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

https://reviews.llvm.org/D100879

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/alloc-fns-alignment.c


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,22 @@
   // allows it to work on indirect virtual function calls.
   if (AttrOnCallSite && TargetDecl->hasAttr())
 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
+
+  // Add known guaranteed alignment for allocation functions
+  if (unsigned BuiltinID = Fn->getBuiltinID()) {
+switch (BuiltinID) {
+case Builtin::BImalloc:
+case Builtin::BIcalloc:
+case Builtin::BIrealloc:
+case Builtin::BIstrdup:
+case Builtin::BIstrndup:
+  RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
+Context.getTargetInfo().getCharWidth());
+  break;
+default:
+  break;
+}
+  }
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,22 @@
   // allows it to work on indirect virtual function calls.
   if (AttrOnCallSite && TargetDecl->hasAttr())
 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
+

[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

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

In D100879#2703979 , @rjmccall wrote:

> Please addd tests, including tests that we suppress this assumption under 
> e.g. `-fno-builtin-malloc`

Done


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

https://reviews.llvm.org/D100879

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


[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-04-21 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 339191.
xbolva00 added a comment.

Handle also aligned_alloc and memalign.


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

https://reviews.llvm.org/D100879

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/alloc-fns-alignment.c


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,24 @@
   // allows it to work on indirect virtual function calls.
   if (AttrOnCallSite && TargetDecl->hasAttr())
 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
+
+  // Add known guaranteed alignment for allocation functions
+  if (unsigned BuiltinID = Fn->getBuiltinID()) {
+switch (BuiltinID) {
+case Builtin::BIaligned_alloc:
+case Builtin::BIcalloc:
+case Builtin::BImalloc:
+case Builtin::BImemalign:
+case Builtin::BIrealloc:
+case Builtin::BIstrdup:
+case Builtin::BIstrndup:
+  RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
+Context.getTargetInfo().getCharWidth());
+  break;
+default:
+  break;
+}
+  }
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,24 @@
   // allows it to work on indirect virtual function calls.
   if

[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-04-21 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 339192.
xbolva00 added a comment.

Fixed small typo in tests.


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

https://reviews.llvm.org/D100879

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/alloc-fns-alignment.c


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,24 @@
   // allows it to work on indirect virtual function calls.
   if (AttrOnCallSite && TargetDecl->hasAttr())
 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
+
+  // Add known guaranteed alignment for allocation functions
+  if (unsigned BuiltinID = Fn->getBuiltinID()) {
+switch (BuiltinID) {
+case Builtin::BIaligned_alloc:
+case Builtin::BIcalloc:
+case Builtin::BImalloc:
+case Builtin::BImemalign:
+case Builtin::BIrealloc:
+case Builtin::BIstrdup:
+case Builtin::BIstrndup:
+  RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
+Context.getTargetInfo().getCharWidth());
+  break;
+default:
+  break;
+}
+  }
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.


Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN8
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
+
+typedef __SIZE_TYPE__ size_t;
+
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void *malloc_test(size_t n) {
+  return malloc(n);
+}
+
+void *calloc_test(size_t n) {
+  return calloc(1, n);
+}
+
+void *raalloc_test(void *p, size_t n) {
+  return realloc(p, n);
+}
+
+// ALIGN16: align 16 i8* @malloc
+// ALIGN16: align 16 i8* @calloc
+// ALIGN16: align 16 i8* @realloc
+// ALIGN8: align 8 i8* @malloc
+// ALIGN8: align 8 i8* @calloc
+// ALIGN8: align 8 i8* @realloc
+// NOBUILTIN-MALLOC: declare i8* @malloc
+// NOBUILTIN-CALLOC: declare i8* @calloc
+// NOBUILTIN-REALLOC: declare i8* @realloc
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2048,6 +2048,24 @@
   // allows it to work on indirect virtual function calls.
   if (AttrOnCallS

[clang] 8c16c8b - Reland "[clang-scan-deps] Add support for clang-cl"

2021-04-21 Thread Sylvain Audi via cfe-commits

Author: Sylvain Audi
Date: 2021-04-21T07:56:39-04:00
New Revision: 8c16c8b7ef7b1bbb1b24a980f30cf07d249dca5f

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

LOG: Reland "[clang-scan-deps] Add support for clang-cl"

This reverts commit 199c39748292cbc89cd148a0d8364ebb1014ec38.
This time, clang-scan-deps's search for output argument in clang-cl command 
line will now ignore arguments preceded by "-Xclang".
That way, it won't detect a /o argument in "-Xclang -ivfsoverlay -Xclang 
/opt/subpath"

Initial patch description:
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

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

Added: 
clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json

Modified: 
clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
clang/test/ClangScanDeps/Inputs/headerwithdirname.json
clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
clang/test/ClangScanDeps/Inputs/no-werror.json
clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
clang/test/ClangScanDeps/error.cpp
clang/test/ClangScanDeps/has_include_if_elif.cpp
clang/test/ClangScanDeps/header_stat_before_open.m
clang/test/ClangScanDeps/headerwithdirname.cpp
clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
clang/test/ClangScanDeps/modules-full.cpp
clang/test/ClangScanDeps/modules.cpp
clang/test/ClangScanDeps/no-werror.cpp
clang/test/ClangScanDeps/regular_cdb.cpp
clang/test/ClangScanDeps/static-analyzer.c
clang/test/ClangScanDeps/strip_diag_serialize.cpp
clang/test/ClangScanDeps/target-filename.cpp
clang/test/ClangScanDeps/vfsoverlay.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json 
b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
index 36ca006b03297..8fcc7ea34a9bc 100644
--- a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
+++ b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/has_include_if_elif2.cpp -IInputs",
   "file": "DIR/has_include_if_elif2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E /IInputs -- DIR/has_include_if_elif2_clangcl.cpp",
+  "file": "DIR/has_include_if_elif2_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json 
b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
index c5f027e9fd28a..b99b541b12986 100644
--- a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/header_stat_before_open_input.m -iframework 
Inputs/frameworks",
   "file": "DIR/header_stat_before_open_input.m"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E -Xclang -iframework -Xclang Inputs/frameworks -- 
DIR/header_stat_before_open_input_clangcl.m",
+  "file": "DIR/header_stat_before_open_input_clangcl.m"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
index 2ae561935bec3..ac12c92308fda 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /c /IDIR /IDIR/foodir -IInputs -- 
DIR/headerwithdirname_input_clangcl.cpp",
+  "file": "DIR/headerwithdirname_input_clangcl.cpp"
 }
 ]

diff  --git 
a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
index de7759d0b110c..1886328a9c3e9 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IInputs DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /c /IDIR /IInputs -- 
DIR/headerwithdirn

[PATCH] D100872: Use OpenFlags instead of boolean to set a file as text/binary

2021-04-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/include/clang/Frontend/CompilerInstance.h:738-740
+  createOutputFileImpl(StringRef OutputPath, llvm::sys::fs::OpenFlags Flags,
bool RemoveFileOnSignal, bool UseTemporary,
bool CreateMissingDirectories);

rnk wrote:
> I think this is only going to be worth it if we can roll up all of these 
> booleans into a new flags enum for compiler instance. It also prevents 
> introducing a new use of FileSystem.h, which is an expensive header to 
> include.
Sorry, I don't think I completely understand your suggestion. Are you proposing 
that we create a new enum just for CompilerInstance.h for the other booleans 
like RemoveFileOnSignal, UseTemporary, CreateMissingDirectories? And this new 
enum also contain text/binary flags so we don't need to use the enum in 
FileSystem.h? 

For background, I need this specific change to set some more text files with 
OF_Text because my old commit got reverted since it caused CRLF issues on 
Windows https://reviews.llvm.org/D96363.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100872

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


[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-21 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 339197.
olestrohm added a comment.

Ran git-clang-format.


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

https://reviews.llvm.org/D100860

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/clk_event_t.cl
  clang/test/SemaOpenCL/event_t.cl
  clang/test/SemaOpenCL/sampler_t.cl
  clang/test/SemaOpenCLCXX/template-diagnostics.clcpp

Index: clang/test/SemaOpenCLCXX/template-diagnostics.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-diagnostics.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+template
+T global_variable; //expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+clk_event_t global_event; //expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+template
+void templ() {
+  T loc;
+  //expected-error@-1{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  //expected-error@-2{{declaring variable of type '__private half' is not allowed}}
+  //expected-error@-3{{non-kernel function variable cannot be declared in local address space}}
+}
+
+void foo() {
+  templ(); //expected-note{{in instantiation of function template specialization 'templ<__read_only image1d_t>' requested here}}
+  templ(); //expected-note{{in instantiation of function template specialization 'templ' requested here}}
+  templ<__local event_t>(); //expected-note{{in instantiation of function template specialization 'templ<__local event_t>' requested here}}
+
+  image1d_t img; //expected-error{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
+  half h; //expected-error{{declaring variable of type '__private half' is not allowed}}
+  __local event_t e; //expected-error{{the event_t type can only be used with __private address space qualifier}}
+
+  (void) global_variable; // expected-note{{in instantiation of variable template specialization 'global_variable' requested here}}
+}
Index: clang/test/SemaOpenCL/sampler_t.cl
===
--- clang/test/SemaOpenCL/sampler_t.cl
+++ clang/test/SemaOpenCL/sampler_t.cl
@@ -48,9 +48,6 @@
 sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
 
 sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires a const or constant address space qualifier}}
-#ifdef CHECK_SAMPLER_VALUE
-// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
-#endif
 
 const sampler_t glb_smp10 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 const constant sampler_t glb_smp11 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: clang/test/SemaOpenCL/event_t.cl
===
--- clang/test/SemaOpenCL/event_t.cl
+++ clang/test/SemaOpenCL/event_t.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 
-event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}} expected-error{{program scope variable must reside in constant address space}}
+event_t glb_evt; // expected-error {{the '__private event_t' type cannot be used to declare a program scope variable}}
 
 constant struct evt_s {
   event_t evt; // expected-error {{the 'event_t' type cannot be used to declare a structure or union field}}
@@ -10,7 +10,7 @@
 
 void kernel ker(event_t argevt) { // expected-error {{'__private event_t' cannot be used as the type of a kernel parameter}}
   event_t e;
-  constant event_t const_evt; // expected-error {{the event_t type can only be used with __private address space qualifier}} expected-error{{variable in constant address space must be initialized}}
+  constant event_t const_evt; // expected-error{{the '__constant event_t' type cannot be used to declare a program scope variable}}
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 'event_t'}}
Index: clang/test/SemaOpenCL/clk_event_t.cl
===
--- clang/test/SemaOpenCL/clk_event_t.cl
+++ clang/test/SemaOpenCL/clk_event_t.cl
@@ -12,6 +12,9 @@
   clk_event_t ce2;
   clk_event_t ce3 = CLK_NULL_EVENT;
 
+  // FIXME: Not obvious if this should give an error as if it was in program scope.
+  static clk_event_t ce4;
+
   if (e == ce1) { // expected-error {{invalid operands to binary expression ('__private event_t' and '__private clk_event_t')}}
 return 9;
   }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6724,17 +6724,20 @@
 
   llvm_unreachable("Unknown type 

[PATCH] D100782: [PowerPC] Improve f32 to i32 bitcast code gen

2021-04-21 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

This will still produce a redundant `XXSLDWI`:

  vector float test(vector float a, float b) {
a[3] = b;
return a;
  }

when compiled with `-mcpu=pwr9`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100782

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


[clang] 5f02c30 - Fix clang/test/Frontend/plugin-annotate-functions.c

2021-04-21 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2021-04-21T14:00:38+01:00
New Revision: 5f02c308e68d2412e2555017d4dbe3e2cc122913

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

LOG: Fix clang/test/Frontend/plugin-annotate-functions.c

FileCheck now gives an error when there's a check for an undefined
variable, which this test does in one of its NOT checks. Fix this by
being a bit looser in what the test checks.

Added: 


Modified: 
clang/test/Frontend/plugin-annotate-functions.c

Removed: 




diff  --git a/clang/test/Frontend/plugin-annotate-functions.c 
b/clang/test/Frontend/plugin-annotate-functions.c
index b8baf7ce77ee0..43687553678c4 100644
--- a/clang/test/Frontend/plugin-annotate-functions.c
+++ b/clang/test/Frontend/plugin-annotate-functions.c
@@ -14,8 +14,8 @@
 
 // PRAGMA: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] 
c"example_annotation\00"
 // PRAGMA: @llvm.global.annotations = 
{{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
-// NOPRAGMA-NOT: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] 
c"example_annotation\00"
-// NOPRAGMA-NOT: @llvm.global.annotations = 
{{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
+// NOPRAGMA-NOT: {{@.+}} = private unnamed_addr constant [19 x i8] 
c"example_annotation\00"
+// NOPRAGMA-NOT: @llvm.global.annotations = {{.*}}
 void fn1() { }
 void fn2() { }
 



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


[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

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

In D99790#2680857 , @jyknight wrote:

> It seems like there's a bug with vtable thunks getting the wrong information. 
> This appears to be a pre-existing bug, but this change has caused it to start 
> actively breaking code.
>
> Test case:
>
>   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() {}
>
> emits three method definitions:
>
>   define dso_local void @_ZN3Obj4Foo1Ev(%class.Obj* nonnull align 16 
> dereferenceable(16) %0) unnamed_addr #0 align 2 !dbg !7 {
>   define dso_local void @_ZN3Obj4Foo2Ev(%class.Obj* nonnull align 16 
> dereferenceable(16) %0) unnamed_addr #0 align 2 !dbg !25 {
>   define dso_local void @_ZThn8_N3Obj4Foo2Ev(%class.Obj* nonnull align 16 
> dereferenceable(16) %0) unnamed_addr #2 align 2 !dbg !29 {
>
> (See https://godbolt.org/z/MxhYMe1q7, for now at least)
>
> That third method declaration is bogus -- its argument is _not_ an `Obj*` at 
> all! In fact, it's pointing at `Obj + 8` -- at the embedded `Base2` object! 
> As such, `align 16` is incorrect, as is `dereferenceable(16)`. The additional 
> 8 bytes of dereferenceable claim apparently hasn't broken anything 
> noticeable, but the alignment claim is causing actual trouble.
>
> As such, I suggest to revert this change, separately commit a fix to that 
> underlying bug, and then re-submit this change after that.

Can you create a new PR?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[clang] 8e33651 - [clang] Recognize ppc32 as valid mcpu value

2021-04-21 Thread via cfe-commits

Author: LemonBoy
Date: 2021-04-21T15:11:01+02:00
New Revision: 8e336511f18ab56cd0c8d93b5c18219df411963a

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

LOG: [clang] Recognize ppc32 as valid mcpu value

The `ppc32` cpu model was introduced a while ago in 
a9321059b912155cd81cf0776d54a7d6838ef7ab as an independent copy of the `ppc` 
one but was never wired into clang.

Reviewed By: #powerpc, nemanjai

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/Misc/target-invalid-cpu-note.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 0703691f4c5b3..cd8cc1aed39ea 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -553,17 +553,17 @@ ArrayRef 
PPCTargetInfo::getGCCAddlRegNames() const {
 }
 
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
-{"generic"}, {"440"}, {"450"},   {"601"}, {"602"},
-{"603"}, {"603e"},{"603ev"}, {"604"}, {"604e"},
-{"620"}, {"630"}, {"g3"},{"7400"},{"g4"},
-{"7450"},{"g4+"}, {"750"},   {"8548"},{"970"},
-{"g5"},  {"a2"},  {"e500"},  {"e500mc"},  {"e5500"},
-{"power3"},  {"pwr3"},{"power4"},{"pwr4"},{"power5"},
-{"pwr5"},{"power5x"}, {"pwr5x"}, {"power6"},  {"pwr6"},
-{"power6x"}, {"pwr6x"},   {"power7"},{"pwr7"},{"power8"},
-{"pwr8"},{"power9"},  {"pwr9"},  {"power10"}, {"pwr10"},
-{"powerpc"}, {"ppc"}, {"powerpc64"}, {"ppc64"},   {"powerpc64le"},
-{"ppc64le"}, {"future"}};
+{"generic"}, {"440"}, {"450"},{"601"},   {"602"},
+{"603"}, {"603e"},{"603ev"},  {"604"},   {"604e"},
+{"620"}, {"630"}, {"g3"}, {"7400"},  {"g4"},
+{"7450"},{"g4+"}, {"750"},{"8548"},  {"970"},
+{"g5"},  {"a2"},  {"e500"},   {"e500mc"},{"e5500"},
+{"power3"},  {"pwr3"},{"power4"}, {"pwr4"},  {"power5"},
+{"pwr5"},{"power5x"}, {"pwr5x"},  {"power6"},{"pwr6"},
+{"power6x"}, {"pwr6x"},   {"power7"}, {"pwr7"},  {"power8"},
+{"pwr8"},{"power9"},  {"pwr9"},   {"power10"},   {"pwr10"},
+{"powerpc"}, {"ppc"}, {"ppc32"},  {"powerpc64"}, {"ppc64"},
+{"powerpc64le"}, {"ppc64le"}, {"future"}};
 
 bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index b248baabeb635..7f5ebe2879766 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -117,8 +117,8 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, powerpc64,
-// PPC-SAME: ppc64, powerpc64le, ppc64le, future
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, ppc32,
+// PPC-SAME: powerpc64, ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'



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


[PATCH] D100933: [clang] Recognize ppc32 as valid mcpu value

2021-04-21 Thread LemonBoy via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e336511f18a: [clang] Recognize ppc32 as valid mcpu value 
(authored by LemonBoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100933

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Misc/target-invalid-cpu-note.c


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -117,8 +117,8 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, powerpc64,
-// PPC-SAME: ppc64, powerpc64le, ppc64le, future
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, 
powerpc, ppc, ppc32,
+// PPC-SAME: powerpc64, ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -553,17 +553,17 @@
 }
 
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
-{"generic"}, {"440"}, {"450"},   {"601"}, {"602"},
-{"603"}, {"603e"},{"603ev"}, {"604"}, {"604e"},
-{"620"}, {"630"}, {"g3"},{"7400"},{"g4"},
-{"7450"},{"g4+"}, {"750"},   {"8548"},{"970"},
-{"g5"},  {"a2"},  {"e500"},  {"e500mc"},  {"e5500"},
-{"power3"},  {"pwr3"},{"power4"},{"pwr4"},{"power5"},
-{"pwr5"},{"power5x"}, {"pwr5x"}, {"power6"},  {"pwr6"},
-{"power6x"}, {"pwr6x"},   {"power7"},{"pwr7"},{"power8"},
-{"pwr8"},{"power9"},  {"pwr9"},  {"power10"}, {"pwr10"},
-{"powerpc"}, {"ppc"}, {"powerpc64"}, {"ppc64"},   {"powerpc64le"},
-{"ppc64le"}, {"future"}};
+{"generic"}, {"440"}, {"450"},{"601"},   {"602"},
+{"603"}, {"603e"},{"603ev"},  {"604"},   {"604e"},
+{"620"}, {"630"}, {"g3"}, {"7400"},  {"g4"},
+{"7450"},{"g4+"}, {"750"},{"8548"},  {"970"},
+{"g5"},  {"a2"},  {"e500"},   {"e500mc"},{"e5500"},
+{"power3"},  {"pwr3"},{"power4"}, {"pwr4"},  {"power5"},
+{"pwr5"},{"power5x"}, {"pwr5x"},  {"power6"},{"pwr6"},
+{"power6x"}, {"pwr6x"},   {"power7"}, {"pwr7"},  {"power8"},
+{"pwr8"},{"power9"},  {"pwr9"},   {"power10"},   {"pwr10"},
+{"powerpc"}, {"ppc"}, {"ppc32"},  {"powerpc64"}, {"ppc64"},
+{"powerpc64le"}, {"ppc64le"}, {"future"}};
 
 bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -117,8 +117,8 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, powerpc64,
-// PPC-SAME: ppc64, powerpc64le, ppc64le, future
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, ppc32,
+// PPC-SAME: powerpc64, ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -553,17 +553,17 @@
 }
 
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
-{"generic"}, {"440"}, {"450"},   {"601"}, {"602"},
-{"603"}, {"603e"},{"603ev"}, {"604"}, {"604e"},
-{"620"}, {"630"}, {"g3"},{"7400"},{"g4"},
-{"7450"},{"g4+"}, {"750"},   {"8548"},{"970"},
-{"g5"},  {"a2"},  {"e500"},  {"e500mc"},  {"e5500"},
-{"power3"},  {"pwr3"},{"power4"},{"pwr4"},{"power5"},
-{"pwr5"},{"power5x"}, {"pwr5x"}, {"power6"},  {"pwr6"},
-{"power6x"}, {"pwr6x"},   {"power7"},{"pwr7"},{"power8"},
-{"pwr

[clang] a63c9b2 - Do not pass null attributes to BuildAttributedStmt during instantiation

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

Author: Aaron Ballman
Date: 2021-04-21T09:30:56-04:00
New Revision: a63c9b25620c8a4da9fcf1e1e8535d3110819ec0

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

LOG: Do not pass null attributes to BuildAttributedStmt during instantiation

When transforming an attribute during template instantiation, if the
transformation fails, it may result in a null attribute being returned.
This null attribute should not be passed in as one of the attributes
used to create an attributed statement.

If all of the attributes fail to transform, we do not create an
attributed statement at all.

There are no attributes that return null currently, so there is no easy
way to test this currently. However, this fixes a crash caused by
8344675908424ee532d4ae30e5043c5a5834e02c.

Added: 


Modified: 
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index ee661f0fc1ab..5a2013bd53a7 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7325,7 +7325,8 @@ 
TreeTransform::TransformAttributedStmt(AttributedStmt *S,
   for (const auto *I : S->getAttrs()) {
 const Attr *R = getDerived().TransformAttr(I);
 AttrsChanged |= (I != R);
-Attrs.push_back(R);
+if (R)
+  Attrs.push_back(R);
   }
 
   StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
@@ -7335,6 +7336,11 @@ 
TreeTransform::TransformAttributedStmt(AttributedStmt *S,
   if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
 return S;
 
+  // If transforming the attributes failed for all of the attributes in the
+  // statement, don't make an AttributedStmt without attributes.
+  if (Attrs.empty())
+return SubStmt;
+
   return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
 SubStmt.get());
 }



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


[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-21 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, let's just rename `template-diagnostics.clcpp` into something like 
`template-opencl-types.clcpp`.


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

https://reviews.llvm.org/D100860

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


[PATCH] D100953: clang-format: [JS] do not wrap after `asserts`

2021-04-21 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added reviewers: krasimir, h-joo.
mprobst requested review of this revision.
Herald added a project: clang.

`asserts` is a pseudo keyword in TypeScript used in return types.
Wrapping after it triggers automatic semicolon insertion, which
breaks the code semantics/syntax.

`asserts` is different from other pseudo keywords in that it is
specific to TS and only carries meaning in a very specific location.
Thus introducing a token type is probably overkill.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100953

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2589,5 +2589,20 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, NoBreakAfterAsserts) {
+  verifyFormat(
+  "interface Assertable {\n"
+  "  assert(\n"
+  "  callback: Callback):\n"
+  "  asserts this is ExtendedState;\n"
+  "}\n",
+  "interface Assertable {\n"
+  "  assert(callback: Callback): asserts "
+  "this is ExtendedState;\n"
+  "}\n");
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3853,6 +3853,9 @@
  Left.isOneOf(tok::r_square, tok::r_paren)) &&
 Right.isOneOf(tok::l_square, tok::l_paren))
   return false; // Otherwise automatic semicolon insertion would trigger.
+if (NonComment && NonComment->is(tok::identifier) &&
+NonComment->TokenText == "asserts")
+  return false;
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
 if (Left.is(TT_JsTypeColon))


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2589,5 +2589,20 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, NoBreakAfterAsserts) {
+  verifyFormat(
+  "interface Assertable {\n"
+  "  assert(\n"
+  "  callback: Callback):\n"
+  "  asserts this is ExtendedState;\n"
+  "}\n",
+  "interface Assertable {\n"
+  "  assert(callback: Callback): asserts "
+  "this is ExtendedState;\n"
+  "}\n");
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3853,6 +3853,9 @@
  Left.isOneOf(tok::r_square, tok::r_paren)) &&
 Right.isOneOf(tok::l_square, tok::l_paren))
   return false; // Otherwise automatic semicolon insertion would trigger.
+if (NonComment && NonComment->is(tok::identifier) &&
+NonComment->TokenText == "asserts")
+  return false;
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
 if (Left.is(TT_JsTypeColon))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100762: [clang][cli] Extract AST dump format into extra option

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

In D100762#2699350 , @dexonsmith 
wrote:

> In D100762#2699252 , @arichardson 
> wrote:
>
>> I'm not sure it's a good idea to remove the `-ast-dump=json` option. While 
>> this is -cc1 option, there do seem to be external consumers based on a quick 
>> search for "-ast-dump=json". Keeping it would also reduce some of the test 
>> churn.
>
> Maybe `-ast-dump=json` can be changed to an alias for `-ast-dump 
> -ast-dump-format json`.

+1 to this idea




Comment at: clang/test/AST/ast-dump-comment-json.cpp:44
 // CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 72,
+// CHECK-NEXT:   "offset": 89,
 // CHECK-NEXT:   "line": 3,

dexonsmith wrote:
> This is a lot of noise in the tests just from changing `RUN` lines. Maybe 
> these tests shouldn't be checking the `offset:` field.
> 
> I suggest:
> 1. Create (if it doesn't exist) one **small** test that checks that `offset:` 
> works correctly. In the same commit, replace the `offset:` lines in all the 
> other tests to check against `[[0-9+]],` instead of the specific character 
> offset.
> 3. Land this change, which no longer needs to update all the `offset:` fields.
Offsets are pretty important to ensure they're sensible, but we probably don't 
need to check offsets in all tests, so I think this suggestion makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100762

___
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-21 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I was under the impression that `#!/usr/bin/env sh` is a sensible invocation 
for running a shell on various systems. The current theory for this struggling 
with the ppc buildbot is that fedora doesn't support that. Ad hoc searching 
suggests 'sh' is required to exist in /bin on posix-list systems, and the 
TestRunner.sh script under clang tests starts with `#!/bin/sh`

It's still kind of shotgun debugging, but we could change to that `#!` header 
across the tests and ensure they all end with a newline while we're at it.


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] D100955: [-Wcalled-once] Do not run analysis on Obj-C++

2021-04-21 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Objective-C++ is not yet suppoerted.

rdar://76729552


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100955

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaObjCXX/warn-called-once.mm


Index: clang/test/SemaObjCXX/warn-called-once.mm
===
--- clang/test/SemaObjCXX/warn-called-once.mm
+++ clang/test/SemaObjCXX/warn-called-once.mm
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wcompletion-handler %s
 
 // expected-no-diagnostics
 
 class HasCtor {
   HasCtor(void *) {}
 };
+
+void double_call_one_block(void (^completionHandler)(void)) {
+  completionHandler();
+  completionHandler();
+  // no-warning - we don't support C++/Obj-C++ yet
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2403,7 +2403,7 @@
   }
 
   // Check for violations of "called once" parameter properties.
-  if (S.getLangOpts().ObjC &&
+  if (S.getLangOpts().ObjC && !S.getLangOpts().CPlusPlus &&
   shouldAnalyzeCalledOnceParameters(Diags, D->getBeginLoc())) {
 if (AC.getCFG()) {
   CalledOnceCheckReporter Reporter(S, IPData->CalledOnceData);


Index: clang/test/SemaObjCXX/warn-called-once.mm
===
--- clang/test/SemaObjCXX/warn-called-once.mm
+++ clang/test/SemaObjCXX/warn-called-once.mm
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wcompletion-handler %s
 
 // expected-no-diagnostics
 
 class HasCtor {
   HasCtor(void *) {}
 };
+
+void double_call_one_block(void (^completionHandler)(void)) {
+  completionHandler();
+  completionHandler();
+  // no-warning - we don't support C++/Obj-C++ yet
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2403,7 +2403,7 @@
   }
 
   // Check for violations of "called once" parameter properties.
-  if (S.getLangOpts().ObjC &&
+  if (S.getLangOpts().ObjC && !S.getLangOpts().CPlusPlus &&
   shouldAnalyzeCalledOnceParameters(Diags, D->getBeginLoc())) {
 if (AC.getCFG()) {
   CalledOnceCheckReporter Reporter(S, IPData->CalledOnceData);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ee3e016 - [Clang][ARM] Define __VFP_FP__ macro unconditionally

2021-04-21 Thread Victor Campos via cfe-commits

Author: Victor Campos
Date: 2021-04-21T15:03:59+01:00
New Revision: ee3e01627ff876ef2225d691fc4d0a127c4abc78

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

LOG: [Clang][ARM] Define __VFP_FP__ macro unconditionally

Clang only defines __VFP_FP__ when the FPU is enabled. However, gcc
defines it unconditionally.

This patch aligns Clang with gcc.

Reviewed By: peter.smith, rengolin

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index a2c96ad12a76..542c90fe153d 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -755,8 +755,12 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // 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)

diff  --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index 9f375162e6ab..5fd1654c9a98 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/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



___
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-21 Thread Victor Campos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee3e01627ff8: [Clang][ARM] Define __VFP_FP__ macro 
unconditionally (authored by vhscampos).

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] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-21 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim accepted this revision.
protze.joachim added a comment.
This revision is now accepted and ready to land.

The latest changes fix the issue. I tested with x86_64 and nvidia offloading.

The behavior and tests looks good to me, just one comment.




Comment at: 
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers_complex_structure.cpp:123-126
+  assert(outer[1].arr[1].arr[0].data1 == 11 &&
+ outer[1].arr[1].arr[0].data2 == 22 &&
+ outer[1].arr[1].arr[1].data1 == 11 &&
+ outer[1].arr[1].arr[1].data2 == 22);

Do these asserts make sense with the assert in line 104?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100673

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


[clang] ba7a92c - [Support] Don't include VirtualFileSystem.h in CommandLine.h

2021-04-21 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-04-21T10:19:01-04:00
New Revision: ba7a92c01e86b5048a93abe7c26c25b90ea9040a

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

LOG: [Support] Don't include VirtualFileSystem.h in CommandLine.h

CommandLine.h is indirectly included in ~50% of TUs when building
clang, and VirtualFileSystem.h is large.

(Already remarked by jhenderson on D70769.)

No behavior change.

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

Added: 


Modified: 
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
clang/tools/apinotes-test/APINotesTest.cpp
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
llvm/include/llvm/Support/CommandLine.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/lib/Remarks/YAMLRemarkSerializer.cpp
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/WithColor.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/tools/llvm-cov/TestingSupport.cpp
llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/tools/split-file/split-file.cpp
llvm/unittests/Support/CommandLineTest.cpp
llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
llvm/utils/TableGen/GICombinerEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index d7f9039872e6..15c905d712a3 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -15,6 +15,7 @@
 #include "clang/Sema/CodeCompleteOptions.h"
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include 
 #include 
 #include 

diff  --git a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp 
b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
index f1ab2aed54c0..a825370afcf5 100644
--- a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -60,8 +60,8 @@ class ExpandResponseFilesDatabase : public 
CompilationDatabase {
 continue;
   llvm::BumpPtrAllocator Alloc;
   llvm::StringSaver Saver(Alloc);
-  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
-llvm::StringRef(Cmd.Directory));
+  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false,
+llvm::StringRef(Cmd.Directory), *FS);
   // Don't assign directly, Argv aliases CommandLine.
   std::vector ExpandedArgv(Argv.begin(), Argv.end());
   Cmd.CommandLine = std::move(ExpandedArgv);

diff  --git a/clang/tools/apinotes-test/APINotesTest.cpp 
b/clang/tools/apinotes-test/APINotesTest.cpp
index 8794546dd284..feafdde78a2f 100644
--- a/clang/tools/apinotes-test/APINotesTest.cpp
+++ b/clang/tools/apinotes-test/APINotesTest.cpp
@@ -8,6 +8,8 @@
 
 #include "clang/APINotes/APINotesYAMLCompiler.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/WithColor.h"

diff  --git a/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp 
b/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
index 78d96539f47e..fff12716b6f0 100644
--- a/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ b/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ToolOutputFile.h"

diff  --git a/llvm/include/llvm/Support/CommandLine.h 
b/llvm/include/llvm/Support/CommandLine.h
index 0706aa226c0e..bcbc4f993d51 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -31,7 +31,6 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/ra

[PATCH] D100957: [Support] Don't include VirtualFileSystem.h in CommandLine.h

2021-04-21 Thread Nico Weber 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 rGba7a92c01e86: [Support] Don't include 
VirtualFileSystem.h in CommandLine.h (authored by thakis).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D100957?vs=339222&id=339226#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100957

Files:
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/tools/apinotes-test/APINotesTest.cpp
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/Remarks/YAMLRemarkSerializer.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/WithColor.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/llvm-cov/TestingSupport.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-exegesis/llvm-exegesis.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-profgen/PerfReader.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/split-file/split-file.cpp
  llvm/unittests/Support/CommandLineTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
  llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
  llvm/utils/TableGen/GICombinerEmitter.cpp

Index: llvm/utils/TableGen/GICombinerEmitter.cpp
===
--- llvm/utils/TableGen/GICombinerEmitter.cpp
+++ llvm/utils/TableGen/GICombinerEmitter.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/TableGen/Error.h"
Index: llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
===
--- llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
@@ -10,6 +10,7 @@
 #include "X86InstrInfo.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -22,6 +22,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/Support/SourceMgr.h"
 #include "gtest/gtest.h"
 
 namespace llvm {
Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -827,8 +827,8 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
   ASSERT_TRUE(llvm::cl::ExpandResponseFiles(
-  Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true, FS,
-  /*CurrentDir=*/StringRef(TestRoot)));
+  Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true,
+  /*CurrentDir=*/StringRef(TestRoot), FS));
   EXPECT_THAT(Argv, testing::Pointwise(
 StringEquality(),
 {"test/test", "-flag_1", "-option_1", "-option_2",
@@ -889,9 +889,9 @@
 #else
   cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
 #endif
-  ASSERT_FALSE(
-  cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, FS,
-  /*CurrentDir=*/llvm::StringRef(TestRoot)));
+  ASSERT_FALSE(cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false,
+   /*CurrentDir=*/llvm::StringRef(TestRoot),
+   FS));
 
   EXPECT_THAT(Argv,
   testing::Pointwise(StringEquality(),
@@ -929,8 +929,8 @@
   BumpPtrAllocator A;
   StringSaver Saver(A);
   ASSERT_FALSE(cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
-   false, false, FS,
-   /*CurrentDir=*/StringRef(TestRoot)));
+   false, false,
+   /*CurrentDir=*/StringRef(TestRoot), FS));
 
   // ASSERT instead of EXPECT to pre

[PATCH] D100953: clang-format: [JS] do not wrap after `asserts`

2021-04-21 Thread Hana Joo via Phabricator via cfe-commits
h-joo accepted this revision.
h-joo added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3856
   return false; // Otherwise automatic semicolon insertion would trigger.
+if (NonComment && NonComment->is(tok::identifier) &&
+NonComment->TokenText == "asserts")

Not for this PR : The JS specific part of the code is growing, please consider 
splitting it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100953

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


[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-21 Thread Luis Penagos via Phabricator via cfe-commits
penagos added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:125
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;

MyDeveloperDay wrote:
> I don't really understand what we are saying here? 
Effectively we are checking that, barring intervening whitespace, we are 
analyzing 2 consecutive '>' tokens. If so, we treat such sequence as a binary 
op in lieu of a closing template angle bracket. If there's another more 
straightforward way of accomplishing this check, I'm open to that, but this 
seemed to be the most straightforward way at the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

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


  1   2   3   >