[PATCH] D81131: [DebugInfo] Fix assertion for extern void type

2020-06-03 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added a reviewer: dblaikie.
yonghong-song added a project: debug-info.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Commit d77ae1552fc2 
 
("[DebugInfo] Support to emit debugInfo
for extern variables") added support to emit debuginfo
for extern variables.

But if the extern variable has "void" type, the compilation will
fail.

  -bash-4.4$ cat t.c 
  extern void bla;
  void *test() {
void *x = 
return x;
  }
  -bash-4.4$ clang -target bpf -g -O2 -S t.c 
  missing global variable type
  !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
  isLocal: false, isDefinition: false)
  ... 
  fatal error: error in backend: Broken module found, compilation aborted!
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace,
  preprocessed source, and associated run script.
  Stack dump:
  ... 

The IR requires a DIGlobalVariable must have a valid type and the 
"void" type does not generate any type, hence the above fatal error.

Note that if the extern variable is defined as "const void", the 
compilation will succeed.

  -bash-4.4$ cat t.c
  extern const void bla;
  const void *test() {
const void *x = 
return x;
  }
  -bash-4.4$ clang -target bpf -g -O2 -S t.c
  -bash-4.4$ cat t.ll
  ...
  !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
  type: !6, isLocal: false, isDefinition: false)
  !6 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)
  ...

It might be the expected behavior not to generate debuginfo for 
extern "void" variables. But the fatal error (with assert on) is not 
nice.

The patch simply skipped the debuginfo if the extern variable has 
"void" type. This might be not be the right way to do it. Maybe
we should error out during parsing or sematic analysis stage.
Or maybe we should allow DIGlobalVariable with extern void type.
Your advice/suggestion for the next step is appreciated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81131

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4198,16 +4198,23 @@
 }
 
 void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) {
-  if (CGDebugInfo *DI = getModuleDebugInfo())
-if (getCodeGenOpts().hasReducedDebugInfo()) {
-  QualType ASTTy = D->getType();
-  llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
-  llvm::PointerType *PTy =
-  llvm::PointerType::get(Ty, 
getContext().getTargetAddressSpace(ASTTy));
-  llvm::Constant *GV = GetOrCreateLLVMGlobal(D->getName(), PTy, D);
-  DI->EmitExternalVariable(
-  cast(GV->stripPointerCasts()), D);
-}
+  if (CGDebugInfo *DI = getModuleDebugInfo()) {
+if (!getCodeGenOpts().hasReducedDebugInfo())
+  return;
+
+// The DIGlobalVariable must have a type, skip the generation
+// if the underlying type is void without any qualifiers.
+QualType ASTTy = D->getType();
+if (!ASTTy.hasQualifiers() && ASTTy.getTypePtr()->isVoidType())
+  return;
+
+llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
+llvm::PointerType *PTy =
+llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy));
+llvm::Constant *GV = GetOrCreateLLVMGlobal(D->getName(), PTy, D);
+DI->EmitExternalVariable(
+cast(GV->stripPointerCasts()), D);
+  }
 }
 
 static bool isVarDeclStrongDefinition(const ASTContext ,


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4198,16 +4198,23 @@
 }
 
 void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) {
-  if (CGDebugInfo *DI = getModuleDebugInfo())
-if (getCodeGenOpts().hasReducedDebugInfo()) {
-  QualType ASTTy = D->getType();
-  llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
-  llvm::PointerType *PTy =
-  llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy));
-  llvm::Constant *GV = GetOrCreateLLVMGlobal(D->getName(), PTy, D);
-  DI->EmitExternalVariable(
-  cast(GV->stripPointerCasts()), D);
-}
+  if (CGDebugInfo *DI = getModuleDebugInfo()) {
+if (!getCodeGenOpts().hasReducedDebugInfo())
+  return;
+
+// The DIGlobalVariable must have a type, skip the generation
+// if the underlying type is void without any qualifiers.
+QualType ASTTy = D->getType();
+if (!ASTTy.hasQualifiers() && ASTTy.getTypePtr()->isVoidType())
+  return;
+
+llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
+

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 5 inline comments as done.
aganea added a comment.

In D80833#2071863 , @hans wrote:

> In D80833#2071818 , @aganea wrote:
>
> > I didn't change the PWD/CWD stored in `LF_BUILDINFO`, it has already been 
> > done by Reid a while ago: D53179  (it 
> > already stores absolute paths)
>
>
> That's surprising to me. Nico is the real export on reproducible builds, but 
> we generally try very hard to make builds reproducible independent of source 
> and build dir. Maybe there should be a flag controlling this? /Brepro?


Ah, you must be using `-fdebug-compilation-dir` on Chromium I suppose, to make 
paths relative in .OBJs. Otherwise the default is the full path to PWD/CWD. 
Added a test for that.

In D80833#2071969 , @thakis wrote:

> We don't store physical absolute paths in pdbs if you hold things right. Look 
> for /pdbsourcepath: in 
> http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html . 
> rnk's change seems to store the main TU's dir as cwd, which likely either 
> takes the dir from the main TU as passed (ie if you pass an erlative path, it 
> stores that), or it honors /pdbsourcepath:. If that's fine as-is, that's ok. 
> It's different from what `pwd` returns though I think. (imagine you're in 
> c:\foo and you build bar\baz.cc. the cwd in the pdb will be c:\foo\bar but 
> the command will be relative to c:\foo if I understand things right? I might 
> not though.)


Without `-fdebug-compilation-dir`, the **full path **is stored in 
`LF_BUILDINFO` (see `CodeGenOpts::DebugCompilationDir` and 
`CGDebugInfo::getCurrentDirname()`)
With `-fdebug-compilation-dir .`, the PWD/CWD becomes relative ('.') and I've 
added code in LLD to call `pdbMakeAbsolute` on it, like for other PDB strings.
Now `/pdbsourcepath` works as well (all this is covered in 
lld/test/COFF/pdb-relative-source-lines.test).
However if you're in `c:\foo` and you do `clang-cl /c bar\baz.cc`, then 
`bar\baz.cc` will be stored as-it-is in `LF_BUILDINFO` (the PWD/CWD and the 
main filename are stored separately)

The only absolute paths that remain are: a. the compiler path 
(`D:\llvm-project\buildninjaDebMSVC\bin\clang-cl.exe` in the yaml below) and b. 
the `-internal-isystem` paths. However that is not an issue on our end, as 
we're building with `-nostdinc` + nuget packages installed in a fixed dir on 
all users' machines. Not sure how that works for you?




Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:835
+static std::string renderCommandLine(ArrayRef CommandLineArgs,
+ StringRef MainFile) {
+  std::string FlatCmdLine;

aganea wrote:
> hans wrote:
> > Don't we already have code somewhere that can do this quoting? E.g. the 
> > code that prints the cc1 args for "clang -v"?
> Yes, the code below was copy-pasted from `Command::printArg`. But that's in 
> Clang. Should I make that code common somewhere in `llvm/lib/Support`?
Replaced by `llvm::sys::flattenWindowsCommandLine`. I can't find any equivalent 
for Linux, I hope just aggregating the arguments with spaces in between is fine?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 268359.
aganea added a comment.
Herald added subscribers: jfb, dexonsmith.

- Using `sys::flattenWindowsCommandLine` instead of previous quoting function, 
as suggested by @hans
- Added Clang tests for `-fdebug-compilation-dir .`
- Added LLD support for making an absolute path out of `LF_BUILDINFO`'s 
CurrentDirectory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  clang/tools/driver/cc1_main.cpp
  clang/tools/driver/driver.cpp
  lld/COFF/PDB.cpp
  lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
  lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
  lld/test/COFF/pdb-relative-source-lines.test
  llvm/include/llvm/ADT/StringExtras.h
  llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
  llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp

Index: llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
@@ -58,3 +58,8 @@
 uint32_t TypeTableCollection::size() { return Records.size(); }
 
 uint32_t TypeTableCollection::capacity() { return Records.size(); }
+
+bool TypeTableCollection::replaceType(TypeIndex , CVType Data,
+  bool Stabilize) {
+  llvm_unreachable("Method cannot be called");
+}
Index: llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
===
--- llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
+++ llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
@@ -123,3 +123,30 @@
 TI = insertRecordBytes(C.RecordData);
   return TI;
 }
+
+bool MergingTypeTableBuilder::replaceType(TypeIndex , CVType Data,
+  bool Stabilize) {
+  assert(Index.toArrayIndex() < SeenRecords.size() &&
+ "This function cannot be used to insert records!");
+
+  ArrayRef Record = Data.data();
+  assert(Record.size() < UINT32_MAX && "Record too big");
+  assert(Record.size() % 4 == 0 &&
+ "The type record size is not a multiple of 4 bytes which will cause "
+ "misalignment in the output TPI stream!");
+
+  LocallyHashedType WeakHash{hash_value(Record), Record};
+  auto Result = HashedRecords.try_emplace(WeakHash, Index.toArrayIndex());
+  if (!Result.second) {
+Index = Result.first->second;
+return false; // The record is already there, at a different location
+  }
+
+  if (Stabilize) {
+Record = stabilize(RecordStorage, Record);
+Result.first->first.RecordData = Record;
+  }
+
+  SeenRecords[Index.toArrayIndex()] = Record;
+  return true;
+}
Index: llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
===
--- llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
+++ llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
@@ -277,3 +277,8 @@
 ++RI;
   }
 }
+
+bool LazyRandomTypeCollection::replaceType(TypeIndex , CVType Data,
+   bool Stabilize) {
+  llvm_unreachable("Method cannot be called");
+}
Index: llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
===
--- llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
+++ llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
@@ -84,6 +84,13 @@
   SeenRecords.clear();
 }
 
+static inline ArrayRef stabilize(BumpPtrAllocator ,
+  ArrayRef Data) {
+  uint8_t *Stable = Alloc.Allocate(Data.size());
+  memcpy(Stable, Data.data(), Data.size());
+  return makeArrayRef(Stable, Data.size());
+}
+
 TypeIndex GlobalTypeTableBuilder::insertRecordBytes(ArrayRef Record) {
   GloballyHashedType GHT =
   GloballyHashedType::hashType(Record, SeenHashes, SeenHashes);
@@ -104,3 +111,30 @@
 TI = insertRecordBytes(C.RecordData);
   return TI;
 }
+
+bool 

[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-03 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

This patch implement the logic not operation of vector type. it keeps same 
behavior as gcc does (only allows in C++).  I'll update the wrong testcases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80979



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


[PATCH] D80492: Avoid linking libdl unless needed

2020-06-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Thanks - I'll look into a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80492



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


Re: [PATCH] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.

2020-06-03 Thread Sean Silva via cfe-commits
Can we revert this?

In our downstream project we were bitten by this:
https://github.com/google/mlir-npcomp/commit/cd7258dbd48bd9254c6741cab2d3f4e36cbd3c84

It seems that now by default anybody that depends on LLVM with CMake will
globally get a `-w` passed to their compiler. That doesn't seem like good
behavior.

-- Sean Silva

On Wed, Apr 12, 2017 at 1:56 PM Vassil Vassilev via Phabricator via
llvm-commits  wrote:

> v.g.vassilev closed this revision.
> v.g.vassilev added a comment.
>
> Landed in r300100.
>
>
> https://reviews.llvm.org/D31702
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-06-03 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

It looks fine to me but I'm not clang expert.  Can anyone review this or 
introduce us reviewers?  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79411



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


[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-03 Thread JunMa via Phabricator via cfe-commits
junparser marked 3 inline comments as done.
junparser added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2746
+  if (E->getType()->isVectorType() &&
+  E->getType()->castAs()->getVectorKind() ==
+  VectorType::GenericVector) {

erichkeane wrote:
> Why limit this to just the base vector type?  Doesn't this remove the 
> ext-vector implementation?
> 
> 
the kind of ext-vector is  GenericVector as well. so it also includes 
ext-vector.



Comment at: clang/lib/Sema/SemaExpr.cpp:14442
+  break;
+} else if (Context.getLangOpts().CPlusPlus && resultType->isVectorType()) {
+  const VectorType *VTy = resultType->castAs();

erichkeane wrote:
> Why C++ only?  It seems if we're doing this, it should be for all language 
> modes.
Here we keep the behavior  as same as gcc since ! of vector only allows with 
C++ in gcc



Comment at: clang/test/CodeGen/vector.c:90
+// CHECK: define i32 @lax_vector_logic_not1(i32 {{.*}}, i32 {{.*}})
+// CHECK: icmp ne i32
+

erichkeane wrote:
> Can you clarify what this is doing here?  It doesn't seem clear to me what 
> the output of this is.
> 
> Additionally, what about FP types?  What do we expect this to emit?
sorry for the confusing. it seems i add the wrong code which test the != rather 
than !.  I'll add the new testcases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80979



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


[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/docs/CodingStandards.rst:1576
+
+When writing the body of an `if`, `else`, or loop statement, omit the braces 
to avoid
+unnecessary and otherwise meaningless code. However, braces should be used

There seems to be some duplication because the "old" version of the write-up is 
still here.


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

https://reviews.llvm.org/D80947



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


[PATCH] D80996: [AMDGPU][OpenMP] Fix duplicate copies of arguments in commands

2020-06-03 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:389
 
-  for (Arg *A : Args) {
-DAL->append(A);
+  if (DeviceOffloadKind != Action::OFK_OpenMP) {
+for (Arg *A : Args) {

pdhaliwal wrote:
> arsenm wrote:
> > Needs a comment? I don't understand why openmp is any different here
> `HostTC.TranslateArgs` (HostTC = Generic_GCC, Line#383) returns `DAL` which  
> contains `Args` when offloadkind is OFK_OpenMP (for all other cases, it 
> returns nullptr). Thus, Line#{390,391} is just duplicating the arguments 
> which are propagating to the opt, llc, etc. commands.
> Ref: https://clang.llvm.org/doxygen/Gnu_8cpp_source.html#l02966
I think @arsenm was asking for a comment in the code itself.

Also, I am not sufficiently familiar with the design here, but why is the HIP 
driver checking for OpenMP offloading? Is the offloaded region treated as HIP 
code? It seems a bit strange that we are mixing two different things in the 
same driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80996



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


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

2020-06-03 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG049d860707ef: [CUDA][HIP] Fix constexpr variables for C++17 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79237

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCUDA/constexpr-variables.cu
  clang/test/SemaCUDA/constexpr-variables.cu

Index: clang/test/SemaCUDA/constexpr-variables.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/constexpr-variables.cu
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -o - -triple nvptx64-nvidia-cuda \
+// RUN:   -fcuda-is-device -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - -triple nvptx64-nvidia-cuda \
+// RUN:   -fcuda-is-device -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -o - \
+// RUN:   -triple x86_64-unknown-linux-gnu -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - \
+// RUN:   -triple x86_64-unknown-linux-gnu -verify -fsyntax-only
+#include "Inputs/cuda.h"
+
+template
+__host__ __device__ void foo(const T **a) {
+  // expected-note@-1 {{declared here}}
+  static const T b = sizeof(a);
+  static constexpr T c = sizeof(a);
+  const T d = sizeof(a);
+  constexpr T e = sizeof(a);
+  constexpr T f = **a;
+  // expected-error@-1 {{constexpr variable 'f' must be initialized by a constant expression}}
+  // expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
+  a[0] = 
+  a[1] = 
+  a[2] = 
+  a[3] = 
+}
+
+__device__ void device_fun(const int **a) {
+  // expected-note@-1 {{declared here}}
+  constexpr int b = sizeof(a);
+  static constexpr int c = sizeof(a);
+  constexpr int d = **a;
+  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
+  // expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
+  a[0] = 
+  a[1] = 
+  foo(a);
+  // expected-note@-1 {{in instantiation of function template specialization 'foo' requested here}}
+}
+
+void host_fun(const int **a) {
+  // expected-note@-1 {{declared here}}
+  constexpr int b = sizeof(a);
+  static constexpr int c = sizeof(a);
+  constexpr int d = **a;
+  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
+  // expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
+  a[0] = 
+  a[1] = 
+  foo(a);
+}
+
+__host__ __device__ void host_device_fun(const int **a) {
+  // expected-note@-1 {{declared here}}
+  constexpr int b = sizeof(a);
+  static constexpr int c = sizeof(a);
+  constexpr int d = **a;
+  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
+  // expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
+  a[0] = 
+  a[1] = 
+  foo(a);
+}
+
+template 
+struct A {
+  explicit A() = default;
+};
+template 
+constexpr A a{};
+
+struct B {
+  static constexpr bool value = true;
+};
+
+template
+struct C {
+  static constexpr bool value = T::value;
+};
+
+__constant__ const bool  = C::value;
Index: clang/test/CodeGenCUDA/constexpr-variables.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/constexpr-variables.cu
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=CXX14 %s
+// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=CXX17 %s
+
+#include "Inputs/cuda.h"
+
+// COM: @_ZL1a = internal {{.*}}constant i32 7
+constexpr int a = 7;
+__constant__ const int _a = a;
+
+namespace B {
+ // COM: @_ZN1BL1bE = internal {{.*}}constant i32 9
+  constexpr int b = 9;
+}
+__constant__ const int _B_b = B::b;
+
+struct Q {
+  // CXX14: @_ZN1Q2k2E = {{.*}}externally_initialized constant i32 6
+  // CXX17: @_ZN1Q2k2E = internal {{.*}}constant i32 6
+  // CXX14: @_ZN1Q2k1E = available_externally {{.*}}constant i32 5
+  // CXX17: @_ZN1Q2k1E = linkonce_odr {{.*}}constant i32 5
+  static constexpr int k1 = 5;
+  static constexpr int k2 = 6;
+};
+constexpr int Q::k2;
+
+__constant__ const int _Q_k1 = Q::k1;
+__constant__ const int _Q_k2 = Q::k2;
+
+template struct X {
+  // CXX14: @_ZN1XIiE1aE = available_externally {{.*}}constant i32 123
+  // CXX17: @_ZN1XIiE1aE = linkonce_odr {{.*}}constant i32 123
+  static constexpr int a = 123;
+};
+__constant__ const int _X_a = X::a;
+
+template  struct A {
+  // CXX14: @_ZN1AIiLi1ELi2EE1xE = available_externally {{.*}}constant i32 2
+  // CXX17: @_ZN1AIiLi1ELi2EE1xE = linkonce_odr {{.*}}constant i32 2
+  

[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Write some codegen tests please, I'd like to have a better idea of what you 
want ! to do here.  Additionally, I'm not sure as to the limits you've placed 
on this patch.  Please justifiy them.C




Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2746
+  if (E->getType()->isVectorType() &&
+  E->getType()->castAs()->getVectorKind() ==
+  VectorType::GenericVector) {

Why limit this to just the base vector type?  Doesn't this remove the 
ext-vector implementation?





Comment at: clang/lib/Sema/SemaExpr.cpp:14442
+  break;
+} else if (Context.getLangOpts().CPlusPlus && resultType->isVectorType()) {
+  const VectorType *VTy = resultType->castAs();

Why C++ only?  It seems if we're doing this, it should be for all language 
modes.



Comment at: clang/test/CodeGen/vector.c:90
+// CHECK: define i32 @lax_vector_logic_not1(i32 {{.*}}, i32 {{.*}})
+// CHECK: icmp ne i32
+

Can you clarify what this is doing here?  It doesn't seem clear to me what the 
output of this is.

Additionally, what about FP types?  What do we expect this to emit?



Comment at: clang/test/CodeGen/vector.c:98
+// CHECK: define void @lax_vector_logic_not2(<2 x i32>* {{.*sret.*}}, i64 
{{.*}}, i64 {{.*}})
+// CHECK: icmp ne <2 x i32>

Why is the IR so different between int and long long (here and the above test)? 
 It would seem to me the IR should be basically identical, perhaps with a cast 
somewhere, but not completely different IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80979



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


[clang] 049d860 - [CUDA][HIP] Fix constexpr variables for C++17

2020-06-03 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-03T21:56:52-04:00
New Revision: 049d860707ef22978b9379fee6dce38c66a22671

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

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

constexpr variables are compile time constants and implicitly const, therefore
they are safe to emit on both device and host side. Besides, in many cases
they are intended for both device and host, therefore it makes sense
to emit them on both device and host sides if necessary.

In most cases constexpr variables are used as rvalue and the variables
themselves do not need to be emitted. However if their address is taken,
then they need to be emitted.

For C++14, clang is able to handle that since clang emits them with
available_externally linkage together with the initializer.

However for C++17, the constexpr static data member of a class or template class
become inline variables implicitly. Therefore they become definitions with
linkonce_odr or weak_odr linkages. As such, they can not have 
available_externally
linkage.

This patch fixes that by adding implicit constant attribute to
file scope constexpr variables and constexpr static data members
in device compilation.

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

Added: 
clang/test/CodeGenCUDA/constexpr-variables.cu
clang/test/SemaCUDA/constexpr-variables.cu

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8409abc4caab..c8c0a6a6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11724,6 +11724,10 @@ class Sema final {
   void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
const LookupResult );
 
+  /// May add implicit CUDAConstantAttr attribute to VD, depending on VD
+  /// and current compilation settings.
+  void MaybeAddCUDAConstantAttr(VarDecl *VD);
+
 public:
   /// Check whether we're allowed to call Callee from the current context.
   ///

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 73d190891b0f..5d6c15196750 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -513,9 +513,14 @@ void Sema::checkAllowedCUDAInitializer(VarDecl *VD) {
 // constructor according to CUDA rules. This deviates from NVCC,
 // but allows us to handle things like constexpr constructors.
 if (!AllowedInit &&
-(VD->hasAttr() || VD->hasAttr()))
-  AllowedInit = VD->getInit()->isConstantInitializer(
-  Context, VD->getType()->isReferenceType());
+(VD->hasAttr() || VD->hasAttr())) {
+  auto *Init = VD->getInit();
+  AllowedInit =
+  ((VD->getType()->isDependentType() || Init->isValueDependent()) &&
+   VD->isConstexpr()) ||
+  Init->isConstantInitializer(Context,
+  VD->getType()->isReferenceType());
+}
 
 // Also make sure that destructor, if there is one, is empty.
 if (AllowedInit)
@@ -612,6 +617,13 @@ void Sema::maybeAddCUDAHostDeviceAttrs(FunctionDecl *NewD,
   NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
 }
 
+void Sema::MaybeAddCUDAConstantAttr(VarDecl *VD) {
+  if (getLangOpts().CUDAIsDevice && VD->isConstexpr() &&
+  (VD->isFileVarDecl() || VD->isStaticDataMember())) {
+VD->addAttr(CUDAConstantAttr::CreateImplicit(getASTContext()));
+  }
+}
+
 Sema::DeviceDiagBuilder Sema::CUDADiagIfDeviceCode(SourceLocation Loc,
unsigned DiagID) {
   assert(getLangOpts().CUDA && "Should only be called during CUDA 
compilation");

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 76754adbf20b..aec3d551701b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7100,6 +7100,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
 
   case CSK_constexpr:
 NewVD->setConstexpr(true);
+MaybeAddCUDAConstantAttr(NewVD);
 // C++1z [dcl.spec.constexpr]p1:
 //   A static data member declared with the constexpr specifier is
 //   implicitly an inline variable.

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 327022218e01..519d9128037d 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4841,6 +4841,7 @@ void Sema::BuildVariableInstantiation(
   NewVar->setCXXForRangeDecl(OldVar->isCXXForRangeDecl());
   NewVar->setObjCForDecl(OldVar->isObjCForDecl());
   NewVar->setConstexpr(OldVar->isConstexpr());
+  

[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-03 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

@erichkeane @aaron.ballman , kindly ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80979



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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-06-03 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1783
+
+  bool IsSideEntry() const { return SideEntry; }
+  void setSideEntry() { SideEntry = true; }

I think this should be isSideEntry to be consistent.



Comment at: clang/lib/CodeGen/CGException.cpp:603-609
+  // For IsEHa catch(...) must handle HW exception
+  // Adjective = HT_IsStdDotDot (0x40), only catch C++ exceptions
+  // Also mark scope with SehTryBegin
+  if (getLangOpts().EHAsynch) {
+TypeInfo.Flags = 0;
+EmitRuntimeCallOrInvoke(getSehTryBeginFn(CGM));
+  }

I think this logic should move into MicrosoftCXXABI::getCatchAllTypeInfo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344



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


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

2020-06-03 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/include/clang/Frontend/CompilerInvocation.h:248
+  /// \returns - True if parsing was successful, false otherwise
+  bool parseSimpleArgs(const llvm::opt::ArgList ,
+   DiagnosticsEngine );

Is there a reason for this to be a member of `CompilerInvocation`? The rest of 
the argument parsing functions are static file local functions.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3658
  MissingArgCount, IncludedFlagsBitmask);
+
   LangOptions  = *Res.getLangOpts();

Put formatting fixups in a separate commit.



Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:41
+TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineFlag) {
+  const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", 
"-"};
+

This reminded me that some of the -cc1 arguments are positional such as 
`-xc++`. I think we'll need custom handling for `INPUT` arguments, although we 
don't need them (or want them) for the modules use case. Do you have any 
thoughts on how to handle them? I don't think answering that should block the 
initial patch though.



Comment at: llvm/include/llvm/Option/OptParser.td:153
+}
+class MarshallingFlagRequired
+  : MarshallingFlag {

I'm not sure Required is a great name here. I initially read that as the option 
was required, not that it should always be emitted.



Comment at: llvm/include/llvm/Option/OptParser.td:167-171
+class MarshallingEnum enumvalues>
+  : OptionMarshallingInfo<"enum", keypath> {
+  code DefaultValue = defaultvalue;
+  listEnumValues = enumvalues;
+}

I noticed that this isn't being used for the enum case you added 
(`-mrelocation-model`). Do you intend to use it? You should either use it in 
this patch or remove it until it actually is used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-06-03 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 268335.
stuij added a comment.

Addressed review comments. Notably what to do in combination with 
-mfloat-abi=soft.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypeCache.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-bf16-softfloat.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/Sema/arm-bf16-forbidden-ops.c
  clang/test/Sema/arm-bf16-forbidden-ops.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -608,6 +608,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
+  fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
+  bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
+}
Index: clang/test/Sema/arm-bf16-forbidden-ops.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bf16-forbidden-ops.cpp
@@ -0,0 +1,71 @@
+// 

[PATCH] D59520: [WebAssembly] Address review comments on r352930

2020-06-03 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked 3 inline comments as done.
sunfish added a comment.

I apologize again for the major delay. I've now updated the patch and addressed 
all of your comments.




Comment at: clang/lib/Sema/SemaDecl.cpp:2594-2597
+  else if (const auto *IMA = dyn_cast(Attr))
+NewAttr = S.mergeImportModuleAttr(D, *IMA);
+  else if (const auto *INA = dyn_cast(Attr))
+NewAttr = S.mergeImportNameAttr(D, *INA);

aaron.ballman wrote:
> You should probably have some tests for the redeclaration behavior somewhere. 
> The way you usually do this is to declare the function with the attribute, 
> then declare the function again without the attribute but see that it is in 
> fact inherited. We sometimes use AST dumping tests for this.
I've now added tests for this as you suggested.



Comment at: clang/test/Sema/attr-wasm.c:11
+
+__attribute__((import_name("foo"))) void name_e() {} //FIXME-expected-error 
{{import name cannot be applied to a function with a definition}}
+

aaron.ballman wrote:
> Are you intending to fix this as part of the patch?
I've made a few attempts at fixing this, but I'm not very familiar with these 
parts of clang, and I've been unable to find another attribute with a similar 
diagnostic.

The `weak_import` attribute seems like it should be one, with its 
`warn_attribute_invalid_on_definition` warning, and  there's code in clang to 
issue that warning for both functions and variables, however the function 
version of the diagnostic doesn't seem to work, and only the variable version 
has tests.

So for now I've just removed these tests, to at least unblock the rest of this 
patch. If anyone knows how to implement these diagnostics, I'd be interested.



Comment at: clang/test/Sema/attr-wasm.c:15
+
+void name_z() __attribute__((import_name("bar"))); //expected-warning {{import 
name does not match previous declaration}}
+

aaron.ballman wrote:
> Uncertain how important you think this may be: should we include the import 
> names in this diagnostic? e.g., `import name (%0) does not match the import 
> name (%1) of the previous declaration` or somesuch? I don't know how often 
> users will hide these attributes behind macros, which is the case I was 
> worried might be confusing.
I've now updated the patch to provide a more informative message, following 
your suggestion here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: RaviNarayanaswamy.
jdoerfert added a comment.

I was hoping @dreachem and maybe @RaviNarayanaswamy would look at this.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7630
+// OMPC_MAP_MODIFIER_last is used to identify data members used in
+// used_device_adddr clause.
+bool IsMemberPointerOrAddr =

jdoerfert wrote:
> I'm not a fan of this implicit encoding. Can't we add a new map type or 
> modifier?
Better, thanks. The comment change is probably not needed anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2020-06-03 Thread Dan Gohman via Phabricator via cfe-commits
sunfish updated this revision to Diff 268329.
sunfish added a comment.

- Add tests for redeclaration behavior
- Remove disabled tests (previously marked with FIXMEs)
- Made the mismatch warning more informative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-wasm-attr-export.c
  clang/test/AST/ast-dump-wasm-attr-import.c
  clang/test/Sema/attr-wasm.c

Index: clang/test/Sema/attr-wasm.c
===
--- /dev/null
+++ clang/test/Sema/attr-wasm.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+
+void name_a() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}}
+
+int name_b __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}}
+
+void name_c() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}}
+
+void name_d() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}}
+
+void name_z() __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}}
+
+void name_z() __attribute__((import_name("bar"))); //expected-warning {{import name (bar) does not match the import name (foo) of the previous declaration}}
+
+void module_a() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}}
+
+int module_b __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}}
+
+void module_c() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_d() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_z() __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}}
+
+void module_z() __attribute__((import_module("bar"))); //expected-warning {{import module (bar) does not match the import module (foo) of the previous declaration}}
+
+void both() __attribute__((import_name("foo"), import_module("bar")));
Index: clang/test/AST/ast-dump-wasm-attr-import.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-wasm-attr-import.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s
+
+// Test that functions can be redeclared and they retain their attributes.
+
+__attribute__((import_name("import_red"), import_module("mod"))) void red(void);
+__attribute__((import_name("import_orange"), import_module("mod"))) void orange(void);
+__attribute__((import_name("import_yellow"), import_module("mod"))) void yellow(void);
+
+void red(void);
+void orange(void);
+void yellow(void);
+
+void calls(void) {
+red();
+orange();
+yellow();
+}
+
+// CHECK: |-FunctionDecl {{.+}} used red 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_red"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_orange"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_yellow"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod"
+// CHECK: |-FunctionDecl {{.+}} used red 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_red"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
+// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_orange"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
+// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)'
+// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_yellow"
+// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod"
Index: clang/test/AST/ast-dump-wasm-attr-export.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-wasm-attr-export.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s
+
+// Test that functions can be redeclared and they retain their attributes.
+
+__attribute__((export_name("export_red"))) void red(void) {}
+__attribute__((export_name("export_orange"))) void orange(void) {}
+__attribute__((export_name("export_yellow"))) void yellow(void) {}
+
+void red(void);
+void orange(void);
+void yellow(void);

[PATCH] D80941: [PowerPC][Power10] Implement Count Leading/Trailing Zeroes Builtins under bit Mask in LLVM/Clang

2020-06-03 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 268331.
amyk retitled this revision from "[PowerPC][Power10] Implement Count 
Leading/Trailing Zeroes Builtins in LLVM/Clang" to "[PowerPC][Power10] 
Implement Count Leading/Trailing Zeroes Builtins under bit Mask in LLVM/Clang".
amyk added a comment.

Addressed review comment of lowering the function prototypes to use 
`@llvm.ct[t|l]z` and `and`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80941

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10.c
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,3 +15,15 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: vclzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0x84]
+# CHECK-LE: vclzdm 1, 2, 3# encoding: [0x84,0x1f,0x22,0x10]
+vclzdm 1, 2, 3
+# CHECK-BE: vctzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0xc4]
+# CHECK-LE: vctzdm 1, 2, 3# encoding: [0xc4,0x1f,0x22,0x10]
+vctzdm 1, 2, 3
+# CHECK-BE: cntlzdm 1, 3, 2   # encoding: [0x7c,0x61,0x10,0x76]
+# CHECK-LE: cntlzdm 1, 3, 2   # encoding: [0x76,0x10,0x61,0x7c]
+cntlzdm 1, 3, 2
+# CHECK-BE: cnttzdm 1, 3, 2   # encoding: [0x7c,0x61,0x14,0x76]
+# CHECK-LE: cnttzdm 1, 3, 2   # encoding: [0x76,0x14,0x61,0x7c]
+cnttzdm 1, 3, 2
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -12,3 +12,15 @@
 
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
+
+# CHECK: vclzdm 1, 2, 3
+0x10 0x22 0x1f 0x84
+
+# CHECK: vctzdm 1, 2, 3
+0x10 0x22 0x1f 0xc4
+
+# CHECK: cntlzdm 1, 3, 2
+0x7c 0x61 0x10 0x76
+
+# CHECK: cnttzdm 1, 3, 2
+0x7c 0x61 0x14 0x76
Index: llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
===
--- llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
+++ llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
@@ -10,6 +10,12 @@
 declare i64 @llvm.ppc.pdepd(i64, i64)
 declare i64 @llvm.ppc.pextd(i64, i64)
 
+; Count leading/trailing zero with mask builtins lowered to use the following:
+declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1 immarg)
+declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1 immarg)
+declare i64 @llvm.ctlz.i64(i64, i1 immarg)
+declare i64 @llvm.cttz.i64(i64, i1 immarg)
+
 define <2 x i64> @test_vpdepd(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vpdepd:
 ; CHECK:   # %bb.0: # %entry
@@ -49,3 +55,47 @@
   %tmp = tail call i64 @llvm.ppc.pextd(i64 %a, i64 %b)
   ret i64 %tmp
 }
+
+define <2 x i64> @test_vclzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vclzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vclzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %0 = and <2 x i64> %a, %b
+  %1 = tail call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %0, i1 false)
+  ret <2 x i64> %1
+}
+
+define <2 x i64> @test_vctzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vctzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vctzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %0 = and <2 x i64> %a, %b
+  %1 = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %0, i1 false)
+  ret <2 x i64> %1
+}
+
+define i64 @test_cntlzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cntlzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cntlzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %0 = and i64 %a, %b
+  %1 = tail call i64 @llvm.ctlz.i64(i64 %0, i1 false)
+  ret i64 %1
+}
+
+define i64 @test_cnttzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cnttzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cnttzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %0 = and i64 %a, %b
+  %1 = tail call i64 @llvm.cttz.i64(i64 %0, i1 false)
+  ret i64 %1
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -516,4 +516,18 @@
def PEXTD : XForm_6<31, 188, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
"pextd $rA, $rS, $rB", IIC_IntGeneral,
[(set i64:$rA, (int_ppc_pextd i64:$rS, i64:$rB))]>;

[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Thx for the explanation. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79948



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


[PATCH] D81122: Reland: Use -fdebug-compilation-dir to form absolute paths in coverage mappings

2020-06-03 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added reviewers: arphaman, vsk, rnk, cfe-commits, kastiglione.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added projects: clang, LLVM.

This reverts commit 62808631acceaa8b78f8ab9b407eb6b943ff5f77.

This was previously reverted because llvm-cov's -path-equivalence usage
wasn't working as expected. This does work with
`-path-equivalence=,/bar` when used with `-fdebug-compilation-dir .`

More discussion: https://lists.llvm.org/pipermail/cfe-dev/2020-June/065668.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81122

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/test/CoverageMapping/debug-dir.cpp
  llvm/docs/CommandGuide/llvm-cov.rst

Index: llvm/docs/CommandGuide/llvm-cov.rst
===
--- llvm/docs/CommandGuide/llvm-cov.rst
+++ llvm/docs/CommandGuide/llvm-cov.rst
@@ -314,7 +314,9 @@
 
  Map the paths in the coverage data to local source file paths. This allows you
  to generate the coverage data on one machine, and then use llvm-cov on a
- different machine where you have the same files on a different path.
+ different machine where you have the same files on a different path. When
+ using this option with '-fdebug-compilation-dir .' pass nothing for the 'from'
+ value.
 
 .. program:: llvm-cov report
 
Index: clang/test/CoverageMapping/debug-dir.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/debug-dir.cpp
@@ -0,0 +1,16 @@
+// %s expands to an absolute path, so to test relative paths we need to create a
+// clean directory, put the source there, and cd into it.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/foo/bar/baz
+// RUN: cp %s %t/foo/bar/baz/debug-dir.cpp
+// RUN: cd %t/foo/bar
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name debug-dir.cpp baz/debug-dir.cpp  -o - | FileCheck -check-prefix=ABSOLUTE %s
+//
+// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\01.*foo.*bar.*baz.*debug-dir\.cpp}}
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name debug-dir.cpp baz/debug-dir.cpp -fdebug-compilation-dir . -o - | FileCheck -check-prefix=RELATIVE %s
+//
+// RELATIVE: @__llvm_coverage_mapping = {{.*"\\01[^/]*baz.*debug-dir\.cpp}}
+
+void f1() {}
Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -60,14 +60,16 @@
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
+  SmallString<256> CWD;
+
+  std::string normalizeFilename(StringRef Filename);
 
   /// Emit a function record.
   void emitFunctionMappingRecord(const FunctionInfo ,
  uint64_t FilenamesRef);
 
 public:
-  CoverageMappingModuleGen(CodeGenModule , CoverageSourceInfo )
-  : CGM(CGM), SourceInfo(SourceInfo) {}
+  CoverageMappingModuleGen(CodeGenModule , CoverageSourceInfo );
 
   CoverageSourceInfo () const {
 return SourceInfo;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1279,13 +1279,6 @@
   }
 };
 
-std::string normalizeFilename(StringRef Filename) {
-  llvm::SmallString<256> Path(Filename);
-  llvm::sys::fs::make_absolute(Path);
-  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  return std::string(Path);
-}
-
 } // end anonymous namespace
 
 static void dump(llvm::raw_ostream , StringRef FunctionName,
@@ -1318,6 +1311,24 @@
   }
 }
 
+CoverageMappingModuleGen::CoverageMappingModuleGen(
+CodeGenModule , CoverageSourceInfo )
+: CGM(CGM), SourceInfo(SourceInfo) {
+  // Honor -fdebug-compilation-dir in paths in coverage data. Otherwise, use the
+  // regular working directory when normalizing paths.
+  if (!CGM.getCodeGenOpts().DebugCompilationDir.empty())
+CWD = CGM.getCodeGenOpts().DebugCompilationDir;
+  else
+llvm::sys::fs::current_path(CWD);
+}
+
+std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(CWD, Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  return Path.str().str();
+}
+
 static std::string getInstrProfSection(const CodeGenModule ,
llvm::InstrProfSectKind SK) {
   return llvm::getInstrProfSectionName(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81115: [PowerPC] Do not check for non-Darwin in PowerPC target cpu handling

2020-06-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Calling it the "Darwin factor" gives it a certain je ne sais quoi. :)




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:298
+// each architecture. (except on AIX)
 if (TargetCPUName.empty()) {
   if (T.isOSAIX())

I think we can reduce the nesting while keeping the NRVO and reorder the checks 
to prefer the more likely (for non-AIX) case of `ppc64le`:
```
if (!TargetCPUName.empty())
  return TargetCPUName;

if (T.isOSAIX())
  TargetCPUName = "pwr4";
else if (T.getArch() == llvm::Triple::ppc64le)
  TargetCPUName = "ppc64le";
else if (T.getArch() == llvm::Triple::ppc64)
  TargetCPUName = "ppc64";
else
  TargetCPUName = "ppc";

return TargetCPUName;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81115



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


[PATCH] D81041: Use existing path sep style in clang::FileManager::FixupRelativePath

2020-06-03 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau abandoned this revision.
ctetreau added a comment.

After some further investigation, I have come to believe that the root cause of 
the issue I am seeing is on line 783 of clang/lib/Lex/HeaderSearch.cpp. A path 
is constructed using string concatenation (dir + '/' + file), which is 
obviously not robust to the various issues in path construction. A fix had been 
committed and reverted back in 2015. Upon restoring the fix, I see that it 
causes several other test failures. Unfortunately, I do not have the bandwidth 
to fully resolve this issue myself, so I have opened a bug for it: 
https://bugs.llvm.org/show_bug.cgi?id=46187

While I still believe the issues I mentioned upthread should probably be 
addressed, they are much less pressing having discovered the root cause of my 
particular issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81041



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


[clang-tools-extra] 49cbe56 - [clangd] Fix forgotten propagation of AsnycPreamble flag

2020-06-03 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-03T23:56:49+02:00
New Revision: 49cbe56a657b91e612f8305e7f8f9119ffe84378

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

LOG: [clangd] Fix forgotten propagation of AsnycPreamble flag

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index eec3a830f6e7..c43f125d50d7 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -764,6 +764,8 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   // Shall we allow to customize the file limit?
   RenameOpts.AllowCrossFile = CrossFileRename;
 
+  Opts.AsyncPreambleBuilds = AsyncPreamble;
+
   ClangdLSPServer LSPServer(
   *TransportLayer, FSProvider, CCOpts, RenameOpts, CompileCommandsDirPath,
   /*UseDirBasedCDB=*/CompileArgsFrom == FilesystemCompileArgs,



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 268299.
ABataev added a comment.

Rebase + fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730

Files:
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer
+// 96 = 0x60 = OMP_MAP_TARGET_PARAM | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 96, i64 96, i64 96, i64 96, i64 96]
+// 32 = 0x20 = OMP_MAP_TARGET_PARAM
+// 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 32, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720]
+struct S {
+  int a = 0;
+  int *ptr = 
+  int  = a;
+  int arr[4];
+  S() {}
+  void foo() {
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a])
+++a, ++*ptr, ++ref, ++arr[0];
+  }
+};
+
+int main() {
+  float a = 0;
+  float *ptr = 
+  float  = a;
+  float arr[4];
+  float vla[(int)a];
+  S s;
+  s.foo();
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0])
+  ++a, ++*ptr, ++ref, ++arr[0], ++vla[0];
+  return a;
+}
+
+// CHECK-LABEL: @main()
+// CHECK: [[A_ADDR:%.+]] = alloca float,
+// CHECK: [[PTR_ADDR:%.+]] = alloca float*,
+// CHECK: [[REF_ADDR:%.+]] = alloca float*,
+// CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float],
+// CHECK: [[BPTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[PTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}},
+// CHECK: [[PTR:%.+]] = load float*, float** [[PTR_ADDR]],
+// CHECK: [[REF:%.+]] = load float*, float** [[REF_ADDR]],
+// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[ARR_ADDR]], i64 0, i64 0
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 0
+// CHECK: [[BPTR0_A_ADDR:%.+]] = bitcast i8** [[BPTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[BPTR0_A_ADDR]],
+// CHECK: [[PTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 0
+// CHECK: [[PTR0_A_ADDR:%.+]] = bitcast i8** [[PTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[PTR0_A_ADDR]],
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 1
+// CHECK: [[BPTR1_PTR_ADDR:%.+]] = bitcast i8** [[BPTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[BPTR1_PTR_ADDR]],
+// CHECK: [[PTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 1
+// CHECK: [[PTR1_PTR_ADDR:%.+]] = bitcast i8** [[PTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[PTR1_PTR_ADDR]],
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 2
+// CHECK: [[BPTR2_REF_ADDR:%.+]] = bitcast i8** [[BPTR2]] to float**
+// CHECK: store float* [[REF]], float** [[BPTR2_REF_ADDR]],
+// CHECK: [[PTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 2
+// CHECK: [[PTR2_REF_ADDR:%.+]] = bitcast i8** [[PTR2]] to float**
+// CHECK: store float* [[REF]], float** [[PTR2_REF_ADDR]],
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds 

[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-06-03 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe636e6b79ac0: [clang-tidy]: Added 
modernize-replace-disallow-copy-and-assign-macro (authored by kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=DEFAULT %s \
+// RUN:   modernize-replace-disallow-copy-and-assign-macro %t
+
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=DIFFERENT-NAME %s \
+// RUN:  modernize-replace-disallow-copy-and-assign-macro %t \
+// RUN:  -config="{CheckOptions: [ \
+// RUN:   {key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN:value: MY_MACRO_NAME}]}"
+
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=FINALIZE %s \
+// RUN:  modernize-replace-disallow-copy-and-assign-macro %t \
+// RUN:  -config="{CheckOptions: [ \
+// RUN:   {key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN:value: DISALLOW_COPY_AND_ASSIGN_FINALIZE}]}"
+
+// RUN: clang-tidy %s -checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:{key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN: value: DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS}]}" | count 0
+
+// RUN: clang-tidy %s -checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:{key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN: value: DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION}]}" | count 0
+
+// Note: the last two tests expect no diagnostics, but FileCheck cannot handle
+// that, hence the use of | count 0.
+
+#define DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+class TestClass1 {
+private:
+  DISALLOW_COPY_AND_ASSIGN(TestClass1);
+};
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-DEFAULT:  {{^}}  TestClass1(const TestClass1 &) = delete;{{$}}
+// CHECK-FIXES-DEFAULT-NEXT: {{^}}  const TestClass1 =(const TestClass1 &) = delete;{{$}}
+
+#define MY_MACRO_NAME(TypeName)
+
+class TestClass2 {
+private:
+  MY_MACRO_NAME(TestClass2);
+};
+// CHECK-MESSAGES-DIFFERENT-NAME: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'MY_MACRO_NAME' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-DIFFERENT-NAME:  {{^}}  TestClass2(const TestClass2 &) = delete;{{$}}
+// CHECK-FIXES-DIFFERENT-NAME-NEXT: {{^}}  const TestClass2 =(const TestClass2 &) = delete;{{$}}
+
+#define DISALLOW_COPY_AND_ASSIGN_FINALIZE(TypeName) \
+  TypeName(const TypeName &) = delete;  \
+  const TypeName =(const TypeName &) = delete;
+
+class TestClass3 {
+private:
+  // Notice, that the macro allows to be used without a semicolon because the
+  // macro definition already contains one above. Therefore our replacement must
+  // contain a semicolon at the end.
+  DISALLOW_COPY_AND_ASSIGN_FINALIZE(TestClass3)
+};
+// CHECK-MESSAGES-FINALIZE: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN_FINALIZE' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-FINALIZE:  {{^}}  TestClass3(const TestClass3 &) = delete;{{$}}
+// CHECK-FIXES-FINALIZE-NEXT: {{^}}  const TestClass3 =(const TestClass3 &) = delete;{{$}}
+
+#define DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS(A, B)
+
+class TestClass4 {
+private:
+  DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS(TestClass4, TestClass4);
+};
+// CHECK-MESSAGES-MORE-ARGUMENTS-NOT: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS'
+
+#define DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION(A)
+#define TESTCLASS TestClass5
+
+class TestClass5 {
+private:
+  DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION(TESTCLASS);
+};
+// 

[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-03 Thread sunfishcode via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd496437a0bfd: [WebAssembly] Add support for 
-mexec-model=reactor (authored by sunfishcode).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -107,3 +107,14 @@
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
+
+// Basic exec-model tests.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=command 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=reactor 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
+// CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -69,8 +69,26 @@
   Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  const char *Crt1 = "crt1.o";
+  const char *Entry = NULL;
+  if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
+StringRef CM = A->getValue();
+if (CM == "command") {
+  // Use default values.
+} else if (CM == "reactor") {
+  Crt1 = "crt1-reactor.o";
+  Entry = "_initialize";
+} else {
+  ToolChain.getDriver().Diag(diag::err_drv_invalid_argument_to_option)
+  << CM << A->getOption().getName();
+}
+  }
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
+  if (Entry) {
+CmdArgs.push_back(Args.MakeArgString("--entry"));
+CmdArgs.push_back(Args.MakeArgString(Entry));
+  }
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -171,6 +171,10 @@
Group, DocName<"PowerPC">;
 def m_wasm_Features_Group : OptionGroup<"">,
 Group, DocName<"WebAssembly">;
+// The features added by this group will not be added to target features.
+// These are explicitly handled.
+def m_wasm_Features_Driver_Group : OptionGroup<"">,
+   Group, DocName<"WebAssembly 
Driver">;
 def m_x86_Features_Group : OptionGroup<"">,
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
@@ -2456,6 +2460,9 @@
 def mno_tail_call : Flag<["-"], "mno-tail-call">, Group;
 def mreference_types : Flag<["-"], "mreference-types">, 
Group;
 def mno_reference_types : Flag<["-"], "mno-reference-types">, 
Group;
+def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group,
+ Values<"command,reactor">,
+ HelpText<"Execution model (WebAssembly only)">;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -3051,6 +3051,12 @@
 
 .. option:: -munimplemented-simd128, -mno-unimplemented-simd128
 
+.. option:: -mexec-model=
+
+Select between "command" and "reactor" executable models. Commands have a main
+function which scopes the lifetime of the program. Reactors are activated and
+remain active until explicitly terminated.
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -107,3 +107,14 @@
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: 

[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-06-03 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D79961#2065605 , @alanphipps wrote:

> It looks like clang/test/Profile/Inputs/c-general.profdata.v5 is being read 
> as v6 rather than v5.  Can you double check?


Yep, I'll have a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79961



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


[PATCH] D80492: Avoid linking libdl unless needed

2020-06-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

FYI as reported on IRC, this likely breaks standalone build of clang

   standalone builds of clang are still supported right ? commit 
0073c293a401774ac96b4b3d27f05e13f379f98e seems to break them, since HAVE_LIBDL 
is not defined (it requires config-ix include from llvm) causing linking 
libclang.so to fail with undefined reference to dladdr due to missing -ldl
   assuming the versions match, sounds like a bug
   LebedevRI: by adding "-DHAVE_LIBDL -DCMAKE_DL_LIBS=dl" to cmake I 
was able to build standalone clang; so it is a bug

Would be good to either have a fix or a revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80492



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D80735#2071897 , @jhuber6 wrote:

> I'm just investigating migrating D80222  
> away from the static methods. When I try to just add an OpenMPIRBuilder type 
> and initialize it I get failures on the tests. I'm just adding in the module 
> as you have 
>  `CGOpenMPRuntime.h`
>
>   llvm::OpenMPIRBuilder InternalOMPBuilder;
>   
>
> `CGOpenMPRuntime.cpp`
>
>   CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule , StringRef 
> FirstSeparator,
>StringRef Separator)
>   : CGM(CGM), FirstSeparator(FirstSeparator), Separator(Separator),
> InternalOMPBuilder(CGM.getModule()), OffloadEntriesInfoManager(CGM) {
> InternalOMPBuilder.initialize();
>
>
> But it causes most of the tests to fail even without using the IRBuilder 
> object.


That is interesting but hard to diagnose. Btw. if you use the OMPIRBuilder it 
could be that the missing insertion point is the problem, see the changes I 
made to IRBuilder(Base). If not, we need to look at the test failures more 
closely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:14900
 }
-continue;
   }

jdoerfert wrote:
> Why would we continue after this error?
The function, that uses VLAs, might be processed in Sema, but not actually used 
(and, thus, is not emitted and the error message won't be generated). Need to 
continue the normal processing as if the error is not emitted. If we leave 
`continue` in the old place, the list of the reduction variables might be empty 
and in this case, the reduction clause won't be built. The `scan` directive 
then diagnoses that it does not see a single reduction clause with the `inscan` 
modifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79948



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


[PATCH] D80917: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:202
+  const unsigned *GridValues;
+  const uint64_t *LongGridValues;
 

I would recommend adding a descriptive comment, even though that seems not to 
be the norm here.
Why do we split these into "normal" and "long" grid values again?

`= nullptr` and an assert in the getters?



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h:20
+
+namespace GPU {
+

I would recommend `omp` not `GPU`, or `omp` before `gpu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80917



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


[clang] dd863cc - [X86] Separate X86_CPU_TYPE_COMPAT_WITH_ALIAS from X86_CPU_TYPE_COMPAT. NFC

2020-06-03 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-03T14:13:12-07:00
New Revision: dd863ccae1346a44e4380fb17d22ae7041fee898

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

LOG: [X86] Separate X86_CPU_TYPE_COMPAT_WITH_ALIAS from X86_CPU_TYPE_COMPAT. NFC

Add a separate X86_CPU_TYPE_COMPAT_ALIAS that carries alias string
and the enum from X86_CPU_TYPE_COMPAT.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/Support/X86TargetParser.def

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index e47cb178792b..b87490a6a858 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1605,8 +1605,7 @@ void X86TargetInfo::getCPUSpecificCPUDispatchFeatures(
 bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const {
   return llvm::StringSwitch(FeatureStr)
 #define X86_VENDOR(ENUM, STRING) .Case(STRING, true)
-#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) 
\
-  .Cases(STR, ALIAS, true)
+#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, ALIAS) .Case(ALIAS, true)
 #define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true)
 #define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true)
 #include "llvm/Support/X86TargetParser.def"

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 948d31312bd8..a73245ad829c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -11375,8 +11375,8 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
   std::tie(Index, Value) = StringSwitch>(CPUStr)
 #define X86_VENDOR(ENUM, STRING)   
\
   .Case(STRING, {0u, static_cast(llvm::X86::ENUM)})
-#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) 
\
-  .Cases(STR, ALIAS, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, ALIAS) \
+  .Case(ALIAS, {1u, static_cast(llvm::X86::ENUM)})
 #define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)   
\
   .Case(STR, {1u, static_cast(llvm::X86::ENUM)})
 #define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR)
\

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def 
b/llvm/include/llvm/Support/X86TargetParser.def
index c826f590b71f..aef189a562a5 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -19,12 +19,6 @@ X86_VENDOR(VENDOR_INTEL, "intel")
 X86_VENDOR(VENDOR_AMD,   "amd")
 #undef X86_VENDOR
 
-// This macro is used to implement CPU types that have an alias. As of now
-// there is only ever one alias.
-#ifndef X86_CPU_TYPE_COMPAT_WITH_ALIAS
-#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) 
X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)
-#endif
-
 // This macro is used for cpu types present in compiler-rt/libgcc.
 #ifndef X86_CPU_TYPE_COMPAT
 #define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) X86_CPU_TYPE(ARCHNAME, ENUM)
@@ -33,42 +27,54 @@ X86_VENDOR(VENDOR_AMD,   "amd")
 #ifndef X86_CPU_TYPE
 #define X86_CPU_TYPE(ARCHNAME, ENUM)
 #endif
+
+#ifndef X86_CPU_TYPE_COMPAT_ALIAS
+#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, STR)
+#endif
+
 // The first part of this list must match what is implemented in libgcc and
 // compilert-rt. Clang uses this to know how to implement __builtin_cpu_is.
-X86_CPU_TYPE_COMPAT_WITH_ALIAS("bonnell",   INTEL_BONNELL,   
"bonnell", "atom")
-X86_CPU_TYPE_COMPAT   ("core2", INTEL_CORE2, "core2")
-X86_CPU_TYPE_COMPAT   ("nehalem",   INTEL_COREI7,"corei7")
-X86_CPU_TYPE_COMPAT_WITH_ALIAS("amdfam10",  AMDFAM10H,   
"amdfam10h", "amdfam10")
-X86_CPU_TYPE_COMPAT_WITH_ALIAS("bdver1",AMDFAM15H,   
"amdfam15h", "amdfam15")
-X86_CPU_TYPE_COMPAT_WITH_ALIAS("silvermont",INTEL_SILVERMONT,
"silvermont", "slm")
-X86_CPU_TYPE_COMPAT   ("knl",   INTEL_KNL,   "knl")
-X86_CPU_TYPE_COMPAT   ("btver1",AMD_BTVER1,  "btver1")
-X86_CPU_TYPE_COMPAT   ("btver2",AMD_BTVER2,  "btver2")
-X86_CPU_TYPE_COMPAT   ("znver1",AMDFAM17H,   
"amdfam17h")
-X86_CPU_TYPE_COMPAT   ("knm",   INTEL_KNM,   "knm")
-X86_CPU_TYPE_COMPAT   ("goldmont",  INTEL_GOLDMONT,  
"goldmont")
-X86_CPU_TYPE_COMPAT   ("goldmont-plus", INTEL_GOLDMONT_PLUS, 
"goldmont-plus")
-X86_CPU_TYPE_COMPAT   ("tremont",   INTEL_TREMONT,   "tremont")
+X86_CPU_TYPE_COMPAT("bonnell",   INTEL_BONNELL,   "bonnell")
+X86_CPU_TYPE_COMPAT("core2", INTEL_CORE2, "core2")
+X86_CPU_TYPE_COMPAT("nehalem",   

[clang] d496437 - [WebAssembly] Add support for -mexec-model=reactor

2020-06-03 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2020-06-03T14:02:47-07:00
New Revision: d496437a0bfd6d135343026cdb7b6a69cb6af536

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

LOG: [WebAssembly] Add support for -mexec-model=reactor

This adds a -mexec-model= command-line flag. The default value is "command"
which is no change from the current behavior. The other option is "reactor"
which enables the WASI Reactor ABI:

https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 4fde6034975e..1ebcab1651d0 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3051,6 +3051,12 @@ WebAssembly
 
 .. option:: -munimplemented-simd128, -mno-unimplemented-simd128
 
+.. option:: -mexec-model=
+
+Select between "command" and "reactor" executable models. Commands have a main
+function which scopes the lifetime of the program. Reactors are activated and
+remain active until explicitly terminated.
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 05a9121592ef..add71fb7dfd7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -171,6 +171,10 @@ def m_ppc_Features_Group : OptionGroup<"">,
Group, DocName<"PowerPC">;
 def m_wasm_Features_Group : OptionGroup<"">,
 Group, DocName<"WebAssembly">;
+// The features added by this group will not be added to target features.
+// These are explicitly handled.
+def m_wasm_Features_Driver_Group : OptionGroup<"">,
+   Group, DocName<"WebAssembly 
Driver">;
 def m_x86_Features_Group : OptionGroup<"">,
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
@@ -2456,6 +2460,9 @@ def mtail_call : Flag<["-"], "mtail-call">, 
Group;
 def mno_tail_call : Flag<["-"], "mno-tail-call">, Group;
 def mreference_types : Flag<["-"], "mreference-types">, 
Group;
 def mno_reference_types : Flag<["-"], "mno-reference-types">, 
Group;
+def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group,
+ Values<"command,reactor">,
+ HelpText<"Execution model (WebAssembly only)">;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,

diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 461ec75d17f6..48f9a9b603db 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -69,8 +69,26 @@ void wasm::Linker::ConstructJob(Compilation , const 
JobAction ,
   Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  const char *Crt1 = "crt1.o";
+  const char *Entry = NULL;
+  if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
+StringRef CM = A->getValue();
+if (CM == "command") {
+  // Use default values.
+} else if (CM == "reactor") {
+  Crt1 = "crt1-reactor.o";
+  Entry = "_initialize";
+} else {
+  ToolChain.getDriver().Diag(diag::err_drv_invalid_argument_to_option)
+  << CM << A->getOption().getName();
+}
+  }
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
+  if (Entry) {
+CmdArgs.push_back(Args.MakeArgString("--entry"));
+CmdArgs.push_back(Args.MakeArgString(Entry));
+  }
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index 343c1b001ef8..8300a81614e3 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -107,3 +107,14 @@
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
+
+// Basic exec-model tests.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=command 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
+// CHECK-COMMAND: clang{{.*}}" "-cc1" 

[clang-tools-extra] e636e6b - [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-06-03 Thread Konrad Kleine via cfe-commits

Author: Konrad Kleine
Date: 2020-06-03T16:56:03-04:00
New Revision: e636e6b79ac06b13059e46b49acb4d9de204c75b

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

LOG: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

Summary:
This check finds macro expansions of `DISALLOW_COPY_AND_ASSIGN(Type)` and
replaces them with a deleted copy constructor and a deleted assignment operator.

Before the `delete` keyword was introduced in C++11 it was common practice to
declare a copy constructor and an assignment operator as a private members. This
effectively makes them unusable to the public API of a class.

With the advent of the `delete` keyword in C++11 we can abandon the
`private` access of the copy constructor and the assignment operator and
delete the methods entirely.

Migration example:

```
lang=dif
class Foo {
  private:
  -  DISALLOW_COPY_AND_ASSIGN(Foo);
  +  Foo(const Foo &) = delete;
  +  const Foo =(const Foo &) = delete;
  };
```

Reviewers: alexfh, hokein, aaron.ballman, njames93

Reviewed By: njames93

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst

clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index 8fcbfbe40b23..c74c4051ade7 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -19,6 +19,7 @@ add_clang_library(clangTidyModernizeModule
   RawStringLiteralCheck.cpp
   RedundantVoidArgCheck.cpp
   ReplaceAutoPtrCheck.cpp
+  ReplaceDisallowCopyAndAssignMacroCheck.cpp
   ReplaceRandomShuffleCheck.cpp
   ReturnBracedInitListCheck.cpp
   ShrinkToFitCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index 6280f9c991e8..d9ccd2cd0ad7 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -21,6 +21,7 @@
 #include "RawStringLiteralCheck.h"
 #include "RedundantVoidArgCheck.h"
 #include "ReplaceAutoPtrCheck.h"
+#include "ReplaceDisallowCopyAndAssignMacroCheck.h"
 #include "ReplaceRandomShuffleCheck.h"
 #include "ReturnBracedInitListCheck.h"
 #include "ShrinkToFitCheck.h"
@@ -67,6 +68,8 @@ class ModernizeModule : public ClangTidyModule {
 "modernize-redundant-void-arg");
 CheckFactories.registerCheck(
 "modernize-replace-auto-ptr");
+CheckFactories.registerCheck(
+"modernize-replace-disallow-copy-and-assign-macro");
 CheckFactories.registerCheck(
 "modernize-replace-random-shuffle");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
 
b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
new file mode 100644
index ..2219a3c477b3
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
@@ -0,0 +1,90 @@
+//===--- ReplaceDisallowCopyAndAssignMacroCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceDisallowCopyAndAssignMacroCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/MacroArgs.h"
+#include "llvm/Support/FormatVariadic.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+namespace {
+
+class ReplaceDisallowCopyAndAssignMacroCallbacks : public PPCallbacks {
+public:
+  explicit ReplaceDisallowCopyAndAssignMacroCallbacks(
+  ReplaceDisallowCopyAndAssignMacroCheck , Preprocessor )
+  : Check(Check), PP(PP) {}
+
+  void MacroExpands(const Token , const MacroDefinition ,
+SourceRange Range, const MacroArgs *Args) override {
+

[PATCH] D80439: Replace separator in OpenMP variant name mangling.

2020-06-03 Thread Shilei Tian via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bd7e4188a09: Replace separator in OpenMP variant name 
mangling. (authored by LukasSommerTu, committed by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80439

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/OpenMPClause.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp

Index: clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='call i32 {@_Z3bazv|@_Z3barv}'
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='call i32 {@_Z3bazv|@_Z3barv}'
+// expected-no-diagnostics
+
+// CHECK-DAG: @_Z3barv
+// CHECK-DAG: @_Z3bazv
+// CHECK-DAG: @"_Z54bar$ompvariant$S2$s8$Pnvptx$Pnvptx64$S3$s10$Pmatch_anyv"
+// CHECK-DAG: @"_Z54baz$ompvariant$S2$s8$Pnvptx$Pnvptx64$S3$s10$Pmatch_anyv"
+// CHECK-DAG: call i32 @"_Z54bar$ompvariant$S2$s8$Pnvptx$Pnvptx64$S3$s10$Pmatch_anyv"()
+// CHECK-DAG: call i32 @"_Z54baz$ompvariant$S2$s8$Pnvptx$Pnvptx64$S3$s10$Pmatch_anyv"()
+
+#ifndef HEADER
+#define HEADER
+
+#pragma omp declare target
+
+int bar() { return 1; }
+
+int baz() { return 5; }
+
+#pragma omp begin declare variant match(device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
+
+int bar() { return 2; }
+
+int baz() { return 6; }
+
+#pragma omp end declare variant
+
+#pragma omp end declare target
+
+int main() {
+  int res;
+#pragma omp target map(from \
+   : res)
+  res = bar() + baz();
+  return res;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/AST/OpenMPClause.cpp
===
--- clang/lib/AST/OpenMPClause.cpp
+++ clang/lib/AST/OpenMPClause.cpp
@@ -2167,22 +2167,21 @@
   std::string MangledName;
   llvm::raw_string_ostream OS(MangledName);
   for (const OMPTraitSet  : Sets) {
-OS << '.' << 'S' << unsigned(Set.Kind);
+OS << '$' << 'S' << unsigned(Set.Kind);
 for (const OMPTraitSelector  : Set.Selectors) {
 
   bool AllowsTraitScore = false;
   bool RequiresProperty = false;
   isValidTraitSelectorForTraitSet(
   Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
-  OS << '.' << 's' << unsigned(Selector.Kind);
+  OS << '$' << 's' << unsigned(Selector.Kind);
 
   if (!RequiresProperty ||
   Selector.Kind == TraitSelector::user_condition)
 continue;
 
   for (const OMPTraitProperty  : Selector.Properties)
-OS << '.' << 'P'
-   << getOpenMPContextTraitPropertyName(Property.Kind);
+OS << '$' << 'P' << getOpenMPContextTraitPropertyName(Property.Kind);
 }
   }
   return OS.str();
@@ -2191,7 +2190,7 @@
 OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
   unsigned long U;
   do {
-if (!MangledName.consume_front(".S"))
+if (!MangledName.consume_front("$S"))
   break;
 if (MangledName.consumeInteger(10, U))
   break;
@@ -2199,7 +2198,7 @@
 OMPTraitSet  = Sets.back();
 Set.Kind = TraitSet(U);
 do {
-  if (!MangledName.consume_front(".s"))
+  if (!MangledName.consume_front("$s"))
 break;
   if (MangledName.consumeInteger(10, U))
 break;
@@ -2207,11 +2206,11 @@
   OMPTraitSelector  = Set.Selectors.back();
   Selector.Kind = TraitSelector(U);
   do {
-if (!MangledName.consume_front(".P"))
+if (!MangledName.consume_front("$P"))
   break;
 Selector.Properties.push_back(OMPTraitProperty());
 OMPTraitProperty  = Selector.Properties.back();
-std::pair PropRestPair = MangledName.split('.');
+std::pair PropRestPair = MangledName.split('$');
 Property.Kind =
 getOpenMPContextTraitPropertyKind(Set.Kind, PropRestPair.first);
 MangledName = PropRestPair.second;
Index: clang/include/clang/AST/Decl.h

[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Looks good, puzzled about the one changed mentioned below.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:14900
 }
-continue;
   }

Why would we continue after this error?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79948



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


[PATCH] D81117: Fix path separator issue on Windows

2020-06-03 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The following 3 tests fail on Windows:
Clang :: ClangScanDeps/header_stat_before_open.m
Clang :: ClangScanDeps/static-analyzer.c
Clang :: ClangScanDeps/vfsoverlay.cpp

The issue is that bad filenames are being constructed. This change uses
llvm::sys::path::append to concatenate file paths rather than string
append with a '/' thrown in the middle.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81117

Files:
  clang/lib/Lex/HeaderSearch.cpp


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -780,10 +780,8 @@
   const FileEntry *Includer = IncluderAndDir.first;
 
   // Concatenate the requested file onto the directory.
-  // FIXME: Portability.  Filename concatenation should be in sys::Path.
   TmpDir = IncluderAndDir.second->getName();
-  TmpDir.push_back('/');
-  TmpDir.append(Filename.begin(), Filename.end());
+  llvm::sys::path::append(TmpDir, Filename);
 
   // FIXME: We don't cache the result of getFileInfo across the call to
   // getFileAndSuggestModule, because it's a reference to an element of


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -780,10 +780,8 @@
   const FileEntry *Includer = IncluderAndDir.first;
 
   // Concatenate the requested file onto the directory.
-  // FIXME: Portability.  Filename concatenation should be in sys::Path.
   TmpDir = IncluderAndDir.second->getName();
-  TmpDir.push_back('/');
-  TmpDir.append(Filename.begin(), Filename.end());
+  llvm::sys::path::append(TmpDir, Filename);
 
   // FIXME: We don't cache the result of getFileInfo across the call to
   // getFileAndSuggestModule, because it's a reference to an element of
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bd7e41 - Replace separator in OpenMP variant name mangling.

2020-06-03 Thread Shilei Tian via cfe-commits

Author: Lukas Sommer
Date: 2020-06-03T16:36:32-04:00
New Revision: 8bd7e4188a096b063065aac70ce39129c479f124

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

LOG: Replace separator in OpenMP variant name mangling.

Summary:
Nvidia PTX does not allow `.` to appear in identifiers, so OpenMP variant 
mangling now uses `$` to separate segments of the mangled name for variants of 
functions declared via `declare variant`.

Reviewers: jdoerfert, Hahnfeld

Reviewed By: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits

Tags: #openmp, #clang

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

Added: 
clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp

Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/OpenMPClause.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 185ba2f4b4c1..6c39f6aab1b9 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4560,7 +4560,7 @@ inline bool IsEnumDeclScoped(EnumDecl *ED) {
 /// The new name looks likes this:
 ///   + OpenMPVariantManglingSeparatorStr + 
 static constexpr StringRef getOpenMPVariantManglingSeparatorStr() {
-  return ".ompvariant";
+  return "$ompvariant";
 }
 
 } // namespace clang

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index fa1c80fc6bbf..bcbe916820dc 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -2167,22 +2167,21 @@ std::string OMPTraitInfo::getMangledName() const {
   std::string MangledName;
   llvm::raw_string_ostream OS(MangledName);
   for (const OMPTraitSet  : Sets) {
-OS << '.' << 'S' << unsigned(Set.Kind);
+OS << '$' << 'S' << unsigned(Set.Kind);
 for (const OMPTraitSelector  : Set.Selectors) {
 
   bool AllowsTraitScore = false;
   bool RequiresProperty = false;
   isValidTraitSelectorForTraitSet(
   Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
-  OS << '.' << 's' << unsigned(Selector.Kind);
+  OS << '$' << 's' << unsigned(Selector.Kind);
 
   if (!RequiresProperty ||
   Selector.Kind == TraitSelector::user_condition)
 continue;
 
   for (const OMPTraitProperty  : Selector.Properties)
-OS << '.' << 'P'
-   << getOpenMPContextTraitPropertyName(Property.Kind);
+OS << '$' << 'P' << getOpenMPContextTraitPropertyName(Property.Kind);
 }
   }
   return OS.str();
@@ -2191,7 +2190,7 @@ std::string OMPTraitInfo::getMangledName() const {
 OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
   unsigned long U;
   do {
-if (!MangledName.consume_front(".S"))
+if (!MangledName.consume_front("$S"))
   break;
 if (MangledName.consumeInteger(10, U))
   break;
@@ -2199,7 +2198,7 @@ OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
 OMPTraitSet  = Sets.back();
 Set.Kind = TraitSet(U);
 do {
-  if (!MangledName.consume_front(".s"))
+  if (!MangledName.consume_front("$s"))
 break;
   if (MangledName.consumeInteger(10, U))
 break;
@@ -2207,11 +2206,11 @@ OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
   OMPTraitSelector  = Set.Selectors.back();
   Selector.Kind = TraitSelector(U);
   do {
-if (!MangledName.consume_front(".P"))
+if (!MangledName.consume_front("$P"))
   break;
 Selector.Properties.push_back(OMPTraitProperty());
 OMPTraitProperty  = Selector.Properties.back();
-std::pair PropRestPair = MangledName.split('.');
+std::pair PropRestPair = MangledName.split('$');
 Property.Kind =
 getOpenMPContextTraitPropertyKind(Set.Kind, PropRestPair.first);
 MangledName = PropRestPair.second;

diff  --git a/clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp 
b/clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
new file mode 100644
index ..6a9ce799d01e
--- /dev/null
+++ b/clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc 
-fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 | FileCheck 
%s --implicit-check-not='call i32 {@_Z3bazv|@_Z3barv}'
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ 

[PATCH] D80940: [clang-format] [PR46159] Linux kernel 'C' code uses 'try' as a variable name, allow clang-format to handle such cases

2020-06-03 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a0484f04b62: [clang-format] [PR46159] Linux kernel 
C code uses try as a variable name… (authored by 
MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80940

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2664,6 +2664,18 @@
   verifyIncompleteFormat("try {} catch (");
 }
 
+TEST_F(FormatTest, FormatTryAsAVariable) {
+  verifyFormat("int try;");
+  verifyFormat("int try, size;");
+  verifyFormat("try = foo();");
+  verifyFormat("if (try < size) {\n  return true;\n}");
+
+  verifyFormat("int catch;");
+  verifyFormat("int catch, size;");
+  verifyFormat("catch = foo();");
+  verifyFormat("if (catch < size) {\n  return true;\n}");
+}
+
 TEST_F(FormatTest, FormatSEHTryCatch) {
   verifyFormat("__try {\n"
"  int a = b * c;\n"
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,6 +56,7 @@
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
   bool tryMergeForEach();
+  bool tryTransformTryUsageForC();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,6 +76,8 @@
 return;
   if (tryMergeForEach())
 return;
+  if (Style.isCpp() && tryTransformTryUsageForC())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -383,6 +385,26 @@
   return true;
 }
 
+bool FormatTokenLexer::tryTransformTryUsageForC() {
+  if (Tokens.size() < 2)
+return false;
+  auto  = *(Tokens.end() - 2);
+  if (!Try->is(tok::kw_try))
+return false;
+  auto  = *(Tokens.end() - 1);
+  if (Next->isOneOf(tok::l_brace, tok::colon))
+return false;
+
+  if (Tokens.size() > 2) {
+auto  = *(Tokens.end() - 3);
+if (At->is(tok::at))
+  return false;
+  }
+
+  Try->Tok.setKind(tok::identifier);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2664,6 +2664,18 @@
   verifyIncompleteFormat("try {} catch (");
 }
 
+TEST_F(FormatTest, FormatTryAsAVariable) {
+  verifyFormat("int try;");
+  verifyFormat("int try, size;");
+  verifyFormat("try = foo();");
+  verifyFormat("if (try < size) {\n  return true;\n}");
+
+  verifyFormat("int catch;");
+  verifyFormat("int catch, size;");
+  verifyFormat("catch = foo();");
+  verifyFormat("if (catch < size) {\n  return true;\n}");
+}
+
 TEST_F(FormatTest, FormatSEHTryCatch) {
   verifyFormat("__try {\n"
"  int a = b * c;\n"
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,6 +56,7 @@
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
   bool tryMergeForEach();
+  bool tryTransformTryUsageForC();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,6 +76,8 @@
 return;
   if (tryMergeForEach())
 return;
+  if (Style.isCpp() && tryTransformTryUsageForC())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -383,6 +385,26 @@
   return true;
 }
 
+bool FormatTokenLexer::tryTransformTryUsageForC() {
+  if (Tokens.size() < 2)
+return false;
+  auto  = *(Tokens.end() - 2);
+  if (!Try->is(tok::kw_try))
+return false;
+  auto  = *(Tokens.end() - 1);
+  if (Next->isOneOf(tok::l_brace, tok::colon))
+return false;
+
+  if (Tokens.size() > 2) {
+auto  = *(Tokens.end() - 3);
+if (At->is(tok::at))
+  return false;
+  }
+
+  Try->Tok.setKind(tok::identifier);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D80933: [clang-format] [PR46157] Wrong spacing of negative literals with use of operator

2020-06-03 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6de794e2074b: [clang-format] [PR46157] Wrong spacing of 
negative literals with use of operator (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80933

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16429,6 +16429,17 @@
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) {
+  FormatStyle Style = getLLVMStyle();
+  // PR46157
+  verifyFormat("foo(operator+, -42);", Style);
+  verifyFormat("foo(operator++, -42);", Style);
+  verifyFormat("foo(operator--, -42);", Style);
+  verifyFormat("foo(-42, operator--);", Style);
+  verifyFormat("foo(-42, operator, );", Style);
+  verifyFormat("foo(operator, , -42);", Style);
+}
+
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
   // These tests are not in NamespaceFixer because that doesn't
   // test its interaction with line wrapping
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -978,16 +978,18 @@
 if (CurrentToken->isOneOf(tok::star, tok::amp))
   CurrentToken->setType(TT_PointerOrReference);
 consumeToken();
+if (CurrentToken && CurrentToken->is(tok::comma) &&
+CurrentToken->Previous->isNot(tok::kw_operator))
+  break;
 if (CurrentToken && CurrentToken->Previous->isOneOf(
 TT_BinaryOperator, TT_UnaryOperator, 
tok::comma,
 tok::star, tok::arrow, tok::amp, tok::ampamp))
   CurrentToken->Previous->setType(TT_OverloadedOperator);
   }
-  if (CurrentToken) {
+  if (CurrentToken && CurrentToken->is(tok::l_paren))
 CurrentToken->setType(TT_OverloadedOperatorLParen);
-if (CurrentToken->Previous->is(TT_BinaryOperator))
-  CurrentToken->Previous->setType(TT_OverloadedOperator);
-  }
+  if (CurrentToken && CurrentToken->Previous->is(TT_BinaryOperator))
+CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
   if (Tok->is(TT_CSharpNullConditionalLSquare)) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16429,6 +16429,17 @@
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) {
+  FormatStyle Style = getLLVMStyle();
+  // PR46157
+  verifyFormat("foo(operator+, -42);", Style);
+  verifyFormat("foo(operator++, -42);", Style);
+  verifyFormat("foo(operator--, -42);", Style);
+  verifyFormat("foo(-42, operator--);", Style);
+  verifyFormat("foo(-42, operator, );", Style);
+  verifyFormat("foo(operator, , -42);", Style);
+}
+
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
   // These tests are not in NamespaceFixer because that doesn't
   // test its interaction with line wrapping
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -978,16 +978,18 @@
 if (CurrentToken->isOneOf(tok::star, tok::amp))
   CurrentToken->setType(TT_PointerOrReference);
 consumeToken();
+if (CurrentToken && CurrentToken->is(tok::comma) &&
+CurrentToken->Previous->isNot(tok::kw_operator))
+  break;
 if (CurrentToken && CurrentToken->Previous->isOneOf(
 TT_BinaryOperator, TT_UnaryOperator, tok::comma,
 tok::star, tok::arrow, tok::amp, tok::ampamp))
   CurrentToken->Previous->setType(TT_OverloadedOperator);
   }
-  if (CurrentToken) {
+  if (CurrentToken && CurrentToken->is(tok::l_paren))
 CurrentToken->setType(TT_OverloadedOperatorLParen);
-if (CurrentToken->Previous->is(TT_BinaryOperator))
-  CurrentToken->Previous->setType(TT_OverloadedOperator);
-  }
+  if (CurrentToken && CurrentToken->Previous->is(TT_BinaryOperator))
+CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
   if (Tok->is(TT_CSharpNullConditionalLSquare)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-06-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1962-1964
+  QualType TransformElaboratedType(TypeLocBuilder , ElaboratedTypeLoc TL) {
+return TransformType(TLB, TL.getNamedTypeLoc());
+  }

rsmith wrote:
> Removing the qualifier seems like it might work out OK in practice, given 
> that we've already resolved the name to a specific declaration, but removing 
> the elaborated type keyword (eg, `struct X` -> `X`) seems wrong to me.
> 
> If the problem is that expanding the typedef is breaking the invariants of 
> `NestedNameSpecifier`, I'd be concerned that there are other cases where 
> we're breaking those invariants in addition to this one. For example, do we 
> have the same problem with `DependentNameType`?
> 
> Perhaps we should be special-casing transform of nested name specifiers 
> instead. In your example below, it would seem more correct to transform 
> `typename STy::Child` -> `typename PR46111::template S::Child`. But that 
> doesn't work in general; consider `typedef struct PR46111::S STy;` for 
> example.
> 
> One possible option would be to change `TransformTypedefType` to wrap its 
> resulting type in a `TypeofType` type. That would give us a consistent 
> transformation pattern: `typename STy::Child` -> `typename 
> __typeof()::Child`. But it's a bit hacky. It would be 
> cleaner in some sense for `TransformTypedefType` to actually produce a new 
> `TypedefDecl` (as if by instantiating the member typedef), and to produce a 
> new `TypedefType` referring to the transformed typedef declaration.
> 
> Out of the available options, transforming the typedef declaration is, I 
> think, my favored choice so far. (In the absence of a better `DeclContext` 
> for it, I think we could set its `DeclContext` to be the 
> `CXXDeductionGuideDecl`. That would at least have the right template 
> parameters etc. in scope. We'll need to delay parenting it until after we 
> create the deduction guide, perhaps by initially creating it as a child of 
> the TUDecl then reparenting it, like we do for function parameters.)
> If the problem is that expanding the typedef is breaking the invariants of 
> NestedNameSpecifier, I'd be concerned that there are other cases where we're 
> breaking those invariants in addition to this one. For example, do we have 
> the same problem with DependentNameType?

I'm not sure, this is the only one I saw with my reproducer.  I've tried to get 
DependentNameType to cause an issue, but I cannot come up with a reproducer 
that has this issue, which is likely due to my lack of knowledge on deduction 
guides.

>It would be cleaner in some sense for TransformTypedefType to actually produce 
>a new TypedefDecl (as if by instantiating the member typedef), and to produce 
>a new TypedefType referring to the transformed typedef declaration.

I'll look into this.  It doesn't SOUND too difficult to deal with the parent 
management, though I'm having trouble figuring out how to get this to 
transform, nor which TypeSouceInfo to use to construct it.

Presumably, it should be an anonymous typdef with empty location data, but the 
rest isn't particularly clear.  If you have suggestions, I'd definitely 
appreciate them, otherwise I'll continue trying to get a functional patch 
together.





Repository:
  rC Clang

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

https://reviews.llvm.org/D80743



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


[PATCH] D80835: [AIX] Change the default target CPU to power4 for AIX on Power

2020-06-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked an inline comment as done.
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:301
+TargetCPUName = "pwr4";
+  else if (!T.isOSDarwin()) {
+if (T.getArch() == llvm::Triple::ppc64)

hubert.reinterpretcast wrote:
> A separate patch may be in order for changing this to take the non-Darwin 
> path without checking.
A separate patch created here, https://reviews.llvm.org/D81115.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80835



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


[PATCH] D79781: [OpenCL] Add cl_khr_extended_subgroup extensions

2020-06-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D79781#2070998 , @PiotrFusik wrote:

> > Great! Thanks! Feel free to go ahead and commit this!
>
> Thanks. Can someone commit this for me, please? Also to 10.0 if possible?


Ok, I can commit this. I am afraid the window for 10.0 is closed. It is still 
possible however to backport patches to 10.0.1. But this normally applies to 
bug fixes and not to new functionality. New functionality normally goes through 
regular development cycles to make sure there is enough time to discover and 
fix bugs.

> 
> 
>> Can you please add a link to the bug describing incorrect optimization to 
>> this review once you create it.
> 
> Sure. Now I'm waiting for my Bugzilla account to be created.




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

https://reviews.llvm.org/D79781



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


[PATCH] D80897: [OpenMP] Initial support for std::complex in target regions

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_complex_builtins.h:42
+#define _LOGBf _LOGBd
+#else
+#define _ISNANd isnan

This will actually not work right now as we do not overload 
isinf/isnan/isfinite properly in C++ mode. I first have to find a solution for 
that mess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80897



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


[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-03 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM. Combined with D79526  it appears to work 
for tensorflow build.


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

https://reviews.llvm.org/D80450



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


[PATCH] D81115: [PowerPC] Do not check for non-Darwin in PowerPC target cpu handling

2020-06-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
Herald added subscribers: cfe-commits, steven.zhang, shchenz, nemanjai.
Herald added a project: clang.
stevewan added reviewers: hubert.reinterpretcast, daltenty.
Herald added a subscriber: wuzish.

Since Darwin on PowerPC is no longer supported, we'll take the Darwin factor 
out from the code that determines the default target cpu on PowerPC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81115

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,18 +294,16 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
+// each architecture. (except on AIX)
 if (TargetCPUName.empty()) {
   if (T.isOSAIX())
 TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
+  else if (T.getArch() == llvm::Triple::ppc64)
+TargetCPUName = "ppc64";
+  else if (T.getArch() == llvm::Triple::ppc64le)
+TargetCPUName = "ppc64le";
+  else
+TargetCPUName = "ppc";
 }
 return TargetCPUName;
   }


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,18 +294,16 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
+// each architecture. (except on AIX)
 if (TargetCPUName.empty()) {
   if (T.isOSAIX())
 TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
+  else if (T.getArch() == llvm::Triple::ppc64)
+TargetCPUName = "ppc64";
+  else if (T.getArch() == llvm::Triple::ppc64le)
+TargetCPUName = "ppc64le";
+  else
+TargetCPUName = "ppc";
 }
 return TargetCPUName;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia requested changes to this revision.
Anastasia added a comment.
This revision now requires changes to proceed.

In D80932#2071321 , @bader wrote:

> In D80932#2068863 , @Anastasia wrote:
>
> >
>
>
>
>
> > Why? Can you explain what you are trying to achieve with this?
>
> I think @asavonic can provide more detailed answer, but IIRC we spent a lot 
> time trying to marry template meta-programming with OpenCL address space 
> deductions, but even simplest template functions from C++ standard library 
> breaks compilation. It's important to note one important difference in design 
> goals for SYCL and C++ for OpenCL. SYCL aims to enable compilation of regular 
> C++ as much as possible where as one of the C++ for OpenCL goals is to keep 
> compatibility with OpenCL C. These two goals might lead to different design 
> decisions.


I don't see a contradiction in those goals. We plan to support C++ libraries 
with C++ for OpenCL of course with functionality that is accepted by conformant 
OpenCL implementations. For example, libraries that use virtual functions 
leading to function pointers are not going to work portably in OpenCL devices. 
If SYCL aims to compile to conformant OpenCL devices then it should not be very 
different I imagine?

C++ for OpenCL and address spaces in C++ in general is still WIP and it is not 
impossible that there are parts that don't work as expected yet. Have you made 
an analysis of issues that you found with the templates and whether it is 
something that can't work conceptually or is just missing from implementation? 
Do you have a list of those issues somewhere?

>   As we still wanted to re-use OpenCL address spaces for mapping explicitly 
> annotated pointers to SPIR-V address spaces we decided to adopt alternative 
> approach (inspired by OpenMP and CUDA modes) with using C++ Sema + additional 
> semantic for non-standard attributes (like address spaces - e.g. 
> https://reviews.llvm.org/D80317) and types. Address space deduction required 
> by SPIR-V specification is implemented CodeGen module and it takes < 200 
> lines in a few files.

Address spaces in OpenCL follow certain concept and if you believe it doesn't 
suit your goals then the right thing to do is to start from describing and 
discussing your design.

> 
> 
>> Default address space is normally an address space of automatic storage i.e. 
>> private in OpenCL. If you look at the address space map of targets most of 
>> them map default and private address spaces to the same value. Converting 
>> between private and other named address space is not allowed in OpenCL see 
>> section 6.5. I don't believe this change is doing anything legitimate.
> 
> AFAIK, OpenCL compiler deduce address space at Sema for all types of storage 
> and even automatic (https://godbolt.org/z/-5QoBd).

This is not the only example for an automatic storage.

> This change is legitimate for OpenCL because OpenCL doesn't use default 
> address space and therefore it should be a non-functional change for OpenCL 
> mode. I had to move on check from the OpenCL C++ test because this changes 
> exposes a bug in the compiler (https://bugs.llvm.org/show_bug.cgi?id=45472), 
> but other than that all existing OpenCL tests pass.

Default address space is a Clang concept that is generally used for an 
automatic storage. This is how embedded C defines it that has been used by 
Clang. OpenCL implementation has always used default for private and the 
decision to add private explicitly was made only about 2 years ago. OpenCL 
compiler infers address spaces for most of cases listed in the specification, 
however, there are cases that are not covered by the spec. There has not been 
any plan to forbid or remove the use of default addr space from the OpenCL 
implementation. And I don't think considering how long it was used historically 
it would be easy to do so.

> In SYCL mode we use default address space and apply conversion rules defined 
> for generic address space, which is casting from generic to non-generic 
> address space is allowed if memory is allocated in the same address space, 
> otherwise behavior is undefined. In most cases, users don't need to worry 
> about annotating pointers manually. They access memory through accessors 
> which are annotated using template parameters, so template meta-programming 
> will prevent invalid conversion. There is also an options to get a raw 
> pointer and/or annotate a pointer using multi_ptr class, but in this case 
> it's user's responsibility to make sure that conversion is valid. This might 
> be required only in cases when compiler is not able to automatically optimize 
> memory accesses to generic address space.
> 
> I was going to upstream CodeGen part with mapping "default address space" to 
> LLVM address space in a separate patch. In the nutshell we would like to map 
> the default address space to LLVM 

[clang] 6a0484f - [clang-format] [PR46159] Linux kernel 'C' code uses 'try' as a variable name, allow clang-format to handle such cases

2020-06-03 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-06-03T20:44:45+01:00
New Revision: 6a0484f04b628870fb7cd0757a72d73294ff5346

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

LOG: [clang-format] [PR46159] Linux kernel 'C' code uses 'try' as a variable 
name, allow clang-format to handle such cases

Reviewed By: curdeius

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

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index b6cbebdcbe7f..f64ab389d02f 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -76,6 +76,8 @@ void FormatTokenLexer::tryMergePreviousTokens() {
 return;
   if (tryMergeForEach())
 return;
+  if (Style.isCpp() && tryTransformTryUsageForC())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -383,6 +385,26 @@ bool FormatTokenLexer::tryMergeForEach() {
   return true;
 }
 
+bool FormatTokenLexer::tryTransformTryUsageForC() {
+  if (Tokens.size() < 2)
+return false;
+  auto  = *(Tokens.end() - 2);
+  if (!Try->is(tok::kw_try))
+return false;
+  auto  = *(Tokens.end() - 1);
+  if (Next->isOneOf(tok::l_brace, tok::colon))
+return false;
+
+  if (Tokens.size() > 2) {
+auto  = *(Tokens.end() - 3);
+if (At->is(tok::at))
+  return false;
+  }
+
+  Try->Tok.setKind(tok::identifier);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)

diff  --git a/clang/lib/Format/FormatTokenLexer.h 
b/clang/lib/Format/FormatTokenLexer.h
index be11020270a3..219cd46f98ed 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -56,6 +56,7 @@ class FormatTokenLexer {
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
   bool tryMergeForEach();
+  bool tryTransformTryUsageForC();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index eea0b364d97c..004ae412ea6d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2664,6 +2664,18 @@ TEST_F(FormatTest, FormatTryCatch) {
   verifyIncompleteFormat("try {} catch (");
 }
 
+TEST_F(FormatTest, FormatTryAsAVariable) {
+  verifyFormat("int try;");
+  verifyFormat("int try, size;");
+  verifyFormat("try = foo();");
+  verifyFormat("if (try < size) {\n  return true;\n}");
+
+  verifyFormat("int catch;");
+  verifyFormat("int catch, size;");
+  verifyFormat("catch = foo();");
+  verifyFormat("if (catch < size) {\n  return true;\n}");
+}
+
 TEST_F(FormatTest, FormatSEHTryCatch) {
   verifyFormat("__try {\n"
"  int a = b * c;\n"



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


[clang] 6de794e - [clang-format] [PR46157] Wrong spacing of negative literals with use of operator

2020-06-03 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-06-03T20:44:45+01:00
New Revision: 6de794e2074b8d0ceb6215f808fb788555fc683d

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

LOG: [clang-format] [PR46157] Wrong spacing of negative literals with use of 
operator

Summary:
see https://bugs.llvm.org/show_bug.cgi?id=46157

Reviewed By: curdeius

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 2a2c4d754732..9f2580367d0f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -978,16 +978,18 @@ class AnnotatingParser {
 if (CurrentToken->isOneOf(tok::star, tok::amp))
   CurrentToken->setType(TT_PointerOrReference);
 consumeToken();
+if (CurrentToken && CurrentToken->is(tok::comma) &&
+CurrentToken->Previous->isNot(tok::kw_operator))
+  break;
 if (CurrentToken && CurrentToken->Previous->isOneOf(
 TT_BinaryOperator, TT_UnaryOperator, 
tok::comma,
 tok::star, tok::arrow, tok::amp, tok::ampamp))
   CurrentToken->Previous->setType(TT_OverloadedOperator);
   }
-  if (CurrentToken) {
+  if (CurrentToken && CurrentToken->is(tok::l_paren))
 CurrentToken->setType(TT_OverloadedOperatorLParen);
-if (CurrentToken->Previous->is(TT_BinaryOperator))
-  CurrentToken->Previous->setType(TT_OverloadedOperator);
-  }
+  if (CurrentToken && CurrentToken->Previous->is(TT_BinaryOperator))
+CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
   if (Tok->is(TT_CSharpNullConditionalLSquare)) {

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 004ae412ea6d..2befa3456ce0 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -16429,6 +16429,17 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
+TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) {
+  FormatStyle Style = getLLVMStyle();
+  // PR46157
+  verifyFormat("foo(operator+, -42);", Style);
+  verifyFormat("foo(operator++, -42);", Style);
+  verifyFormat("foo(operator--, -42);", Style);
+  verifyFormat("foo(-42, operator--);", Style);
+  verifyFormat("foo(-42, operator, );", Style);
+  verifyFormat("foo(operator, , -42);", Style);
+}
+
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
   // These tests are not in NamespaceFixer because that doesn't
   // test its interaction with line wrapping



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


[PATCH] D80655: Define __SPIR__ macro for spir/spir64 targets.

2020-06-03 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a1b07506c1f: Define __SPIR__ macro for spir/spir64 targets. 
(authored by vzakhari).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80655

Files:
  clang/lib/Basic/Targets/SPIR.cpp
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -173,7 +173,17 @@
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
-// CHECK-SPIR: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __SPIR__ 1
+// CHECK-SPIR-DAG: #define __SPIR32__ 1
+// CHECK-SPIR-NOT: #define __SPIR64__ 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64
+// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR64-DAG: #define __SPIR__ 1
+// CHECK-SPIR64-DAG: #define __SPIR64__ 1
+// CHECK-SPIR64-NOT: #define __SPIR32__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP
Index: clang/lib/Basic/Targets/SPIR.cpp
===
--- clang/lib/Basic/Targets/SPIR.cpp
+++ clang/lib/Basic/Targets/SPIR.cpp
@@ -23,10 +23,12 @@
 
 void SPIR32TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR32", Opts);
 }
 
 void SPIR64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR64", Opts);
 }


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -173,7 +173,17 @@
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
-// CHECK-SPIR: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __SPIR__ 1
+// CHECK-SPIR-DAG: #define __SPIR32__ 1
+// CHECK-SPIR-NOT: #define __SPIR64__ 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64
+// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR64-DAG: #define __SPIR__ 1
+// CHECK-SPIR64-DAG: #define __SPIR64__ 1
+// CHECK-SPIR64-NOT: #define __SPIR32__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP
Index: clang/lib/Basic/Targets/SPIR.cpp
===
--- clang/lib/Basic/Targets/SPIR.cpp
+++ clang/lib/Basic/Targets/SPIR.cpp
@@ -23,10 +23,12 @@
 
 void SPIR32TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR32", Opts);
 }
 
 void SPIR64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR64", Opts);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-03 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D80383#2068596 , @dang wrote:

> I made the decision to make all relative offsets relative to the start of the 
> AST block rather than their own sub-block or a neighboring block, in order to 
> prevent adding complexity in `ASTReader`. My reasoning that it would be best 
> if the reader didn't have to keep track of a bunch of offsets inside the 
> bitcode at all times, but that it could just remember the offset of the AST 
> block once and always use that for relative offsets. I agree that 
> conceptually making the sub-blocks relocatable too would have been nice, but 
> I figured it wasn't worth the extra complexity in the reader.


I think the extra complexity is small and worth it. The default abbreviation is 
7-VBR, which is cheaper for small offsets. I doubt we'll bother to come back 
and fix this later, so might as well get it right now.




Comment at: clang/include/clang/Basic/Module.h:60
 
+  static Expected Create(StringRef Bytes) {
+if (Bytes.size() != 20)

Can you make this `create`? I think new code we prefer `lowerCamelCase` for 
method names.



Comment at: clang/include/clang/Basic/Module.h:66-72
+for (unsigned I = 0; I != 5; ++I) {
+  const unsigned BitOff = I * 4;
+  Signature[I] = ((uint32_t)Bytes[BitOff + 0] << 24) |
+ ((uint32_t)Bytes[BitOff + 1] << 16) |
+ ((uint32_t)Bytes[BitOff + 2] << 8) |
+ ((uint32_t)Bytes[BitOff + 3]);
+}

This code looks correct, and it's better factored out like this, but I still 
don't understand why we convert to 32-bit numbers. Have you looked at the code 
simplification from storing this as an array of 8-bit numbers?



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:396-400
   /// Record code for the signature that identifiers this AST file.
   SIGNATURE = 1,
 
+  /// Record code for the signature of the AST block.
+  AST_SIGNATURE,

dang wrote:
> dang wrote:
> > dexonsmith wrote:
> > > These names and descriptions hard hard to differentiate. Is there another 
> > > way of naming these that will be more clear?
> > > 
> > > (One idea I had is to create `CONTROL_BLOCK_HASH` and `AST_BLOCK_HASH` 
> > > and then `SIGNATURE` could just be their hash-combine, but maybe you have 
> > > another idea.)
> > I kept the same hasher when computing both of these which mitigates the 
> > cost. I don't see the need for also emitting a hash for the control block, 
> > there are some optional records that are not in both the AST block and the 
> > control block anyway.
> I also think that the `AST_BLOCK_HASH` and the `SIGNATURE` are enough 
> information already. In most cases you can deduce if the control block was 
> different by just checking if the signatures were different and the ASTs the 
> same.
Thanks for updating to `AST_BLOCK_HASH`, I think that addressed the concern I 
had.

However, having thought further about it, I don't think it makes sense to 
create a new record type. I suggest just having a convention of writing the 
hashes out in a particular order.
- First record is the overall signature.
- Second record is the AST block hash.
- In the future, we can add a third record for the control block hash.

In which case, the (single) record name should be something generic like 
`SIGNATURE` or `SHA1_HASH`.

Note: I doubt there would be additional cost to computing the AST and control 
block hashes separately, but I agree there isn't a compelling use for the 
control block hash currently (although it would be nice to confirm properties 
like if the `CONTROL_BLOCK_HASH` were typically stable when sources changed).

Note: I don't think the content of the "hashed" control block vs. unhashed 
control block have been carefully considered from first principles. At some 
point we might do that. I expect there are currently things that change the 
control block that would not invalidate it for importers.



Comment at: clang/lib/Serialization/ASTWriter.cpp:1061
 
-  return Signature;
+  return std::make_pair(ASTSignature, Signature);
 }

dexonsmith wrote:
> Alternately, you could change `ASTFileSignature` to have three fields:
> - ControlBlockHash
> - ASTBlockHash
> - Signature
> 
> (You could construct the signature by taking the SHA1 of the two block 
> hashes.)
Have you considered changing `ASTFileSignature` to have multiple fields, one 
for the signature and another for the AST block hash? Working with pairs and 
tuples is always awkward.



Comment at: clang/lib/Serialization/ASTWriter.cpp:1084
   PP.getHeaderSearchInfo().getHeaderSearchOpts().ModulesHashContent) {
-Signature = createSignature(StringRef(Buffer.begin(), 
StartOfUnhashedControl));
+Record.append(ASTSignature.begin(), ASTSignature.end());
+

[PATCH] D80876: [clang] Default to windows response files when running on windows

2020-06-03 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D80876#2070233 , @mstorsjo wrote:

> In D80876#2069970 , @sbc100 wrote:
>
> > Do you know how gcc handles this case when running on mingw?
>
>
> It uses the gnu/unix quoting style - so that's the case for wanting clang to 
> preserve compatibility with that behaviour.


Is there any case where gcc on windows will use the windows quoting style?

If the answer is no, and I assume GNU ar is the same, then perhaps the solution 
is revert https://reviews.llvm.org/D69665 instead and have all the llvm tools 
except clang-cl default to the GNU style.

> The fact that any clang can be used for any target, blurs the distinction, as 
> an msys2/mingw based clang both can be used for targeting wasm (where the 
> build tools might expect to use windows style quoting) and for general mingw 
> target things (where the build tools out of tradition expects to use unix 
> style quoting in rsp files).




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80876



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


[PATCH] D78637: [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed erroneously.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78637



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added reviewers: kkwli0, dreachem.
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7630
+// OMPC_MAP_MODIFIER_last is used to identify data members used in
+// used_device_adddr clause.
+bool IsMemberPointerOrAddr =

I'm not a fan of this implicit encoding. Can't we add a new map type or 
modifier?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730



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


[PATCH] D80936: [OPENMP]Fix PR46146: Do not consider globalized variables as NRVO candidates.

2020-06-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM, thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80936



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


[clang] 3a1b075 - Define __SPIR__ macro for spir/spir64 targets.

2020-06-03 Thread Vyacheslav Zakharin via cfe-commits

Author: Vyacheslav Zakharin
Date: 2020-06-03T12:36:21-07:00
New Revision: 3a1b07506c1fc6e6aee528289341aa0d0d806814

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

LOG: Define __SPIR__ macro for spir/spir64 targets.

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

Added: 


Modified: 
clang/lib/Basic/Targets/SPIR.cpp
clang/test/Preprocessor/predefined-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/SPIR.cpp 
b/clang/lib/Basic/Targets/SPIR.cpp
index a9b815d13bc1..9b7aab85314a 100644
--- a/clang/lib/Basic/Targets/SPIR.cpp
+++ b/clang/lib/Basic/Targets/SPIR.cpp
@@ -23,10 +23,12 @@ void SPIRTargetInfo::getTargetDefines(const LangOptions 
,
 
 void SPIR32TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR32", Opts);
 }
 
 void SPIR64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR64", Opts);
 }

diff  --git a/clang/test/Preprocessor/predefined-macros.c 
b/clang/test/Preprocessor/predefined-macros.c
index def105f4c52e..083f0e539d88 100644
--- a/clang/test/Preprocessor/predefined-macros.c
+++ b/clang/test/Preprocessor/predefined-macros.c
@@ -173,7 +173,17 @@
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
-// CHECK-SPIR: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR-DAG: #define __SPIR__ 1
+// CHECK-SPIR-DAG: #define __SPIR32__ 1
+// CHECK-SPIR-NOT: #define __SPIR64__ 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64
+// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1
+// CHECK-SPIR64-DAG: #define __SPIR__ 1
+// CHECK-SPIR64-DAG: #define __SPIR64__ 1
+// CHECK-SPIR64-NOT: #define __SPIR32__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

We don't store physical absolute paths in pdbs if you hold things right. Look 
for /pdbsourcepath: in 
http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html . 
rnk's change seems to store the main TU's dir as cwd, which likely either takes 
the dir from the main TU as passed (ie if you pass an erlative path, it stores 
that), or it honors /pdbsourcepath:. If that's fine as-is, that's ok. It's 
different from what `pwd` returns though I think. (imagine you're in c:\foo and 
you build bar\baz.cc. the cwd in the pdb will be c:\foo\bar but the command 
will be relative to c:\foo if I understand things right? I might not though.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D80917: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:290
   assert(DataLayout->getAllocaAddrSpace() == Private);
+  GridValues = &(llvm::GPU::AMDGPUGpuGridValues[0]);
+  LongGridValues = &(llvm::GPU::AMDGPUGpuLongGridValues[0]);

Don't need parentheses



Comment at: clang/lib/Basic/Targets/NVPTX.cpp:66
   AddrSpaceMap = 
+  GridValues = &(llvm::GPU::NVPTXGpuGridValues[0]);
+  LongGridValues = &(llvm::GPU::NVPTXGpuLongGridValues[0]);

Don't need parentheses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80917



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


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-06-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1962-1964
+  QualType TransformElaboratedType(TypeLocBuilder , ElaboratedTypeLoc TL) {
+return TransformType(TLB, TL.getNamedTypeLoc());
+  }

Removing the qualifier seems like it might work out OK in practice, given that 
we've already resolved the name to a specific declaration, but removing the 
elaborated type keyword (eg, `struct X` -> `X`) seems wrong to me.

If the problem is that expanding the typedef is breaking the invariants of 
`NestedNameSpecifier`, I'd be concerned that there are other cases where we're 
breaking those invariants in addition to this one. For example, do we have the 
same problem with `DependentNameType`?

Perhaps we should be special-casing transform of nested name specifiers 
instead. In your example below, it would seem more correct to transform 
`typename STy::Child` -> `typename PR46111::template S::Child`. But that 
doesn't work in general; consider `typedef struct PR46111::S STy;` for 
example.

One possible option would be to change `TransformTypedefType` to wrap its 
resulting type in a `TypeofType` type. That would give us a consistent 
transformation pattern: `typename STy::Child` -> `typename 
__typeof()::Child`. But it's a bit hacky. It would be 
cleaner in some sense for `TransformTypedefType` to actually produce a new 
`TypedefDecl` (as if by instantiating the member typedef), and to produce a new 
`TypedefType` referring to the transformed typedef declaration.

Out of the available options, transforming the typedef declaration is, I think, 
my favored choice so far. (In the absence of a better `DeclContext` for it, I 
think we could set its `DeclContext` to be the `CXXDeductionGuideDecl`. That 
would at least have the right template parameters etc. in scope. We'll need to 
delay parenting it until after we create the deduction guide, perhaps by 
initially creating it as a child of the TUDecl then reparenting it, like we do 
for function parameters.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D80743



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

I'm just investigating migrating D80222  away 
from the static methods. When I try to just add an OpenMPIRBuilder type and 
initialize it I get failures on the tests. I'm just adding in the module as you 
have 
`CGOpenMPRuntime.h`

  llvm::OpenMPIRBuilder InternalOMPBuilder;

`CGOpenMPRuntime.cpp`

  CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule , StringRef FirstSeparator,
   StringRef Separator)
  : CGM(CGM), FirstSeparator(FirstSeparator), Separator(Separator),
InternalOMPBuilder(CGM.getModule()), OffloadEntriesInfoManager(CGM) {
InternalOMPBuilder.initialize();

But it causes most of the tests to fail even without using the IRBuilder object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[PATCH] D80917: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 2

2020-06-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 268264.
saiislam added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

1. Added wave32 as an additional alternate wave size.
2. Replaced long long with uint64_t and int with unsigned.
3. Removed unnecessary casts.
4. Moved OpenMPGridValues.h to Frontend/OpenMP.
5. Refactored OpenMPGridValues.h as OMPGridValues.h to follow style of 
neighboring files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80917

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- /dev/null
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -0,0 +1,140 @@
+//--- OMPGridValues.h - Language-specific address spaces --*- C++ -*-//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief Provides definitions for Target specific Grid Values
+///
+//===--===//
+
+#ifndef LLVM_OPENMP_GRIDVALUES_H
+#define LLVM_OPENMP_GRIDVALUES_H
+
+namespace llvm {
+
+namespace GPU {
+
+/// \brief Defines various target-specific GPU grid values that must be
+///consistent between host RTL (plugin), device RTL, and clang.
+///We can change grid values for a "fat" binary so that different
+///passes get the correct values when generating code for a
+///multi-target binary. Both amdgcn and nvptx values are stored in
+///this file. In the future, should there be differences between GPUs
+///of the same architecture, then simply make a different array and
+///use the new array name.
+///
+/// Example usage in clang:
+///   const unsigned slot_size = ctx.GetTargetInfo().getGridValue(GV_Warp_Size);
+///
+/// Example usage in libomptarget/deviceRTLs:
+///   #include "OMPGridValues.h"
+///   #ifdef __AMDGPU__
+/// #define GRIDVAL AMDGPUGpuGridValues
+///   #else
+/// #define GRIDVAL NVPTXGpuGridValues
+///   #endif
+///   ... Then use this reference for GV_Warp_Size in the deviceRTL source.
+///   GRIDVAL[GV_Warp_Size]
+///
+/// Example usage in libomptarget hsa plugin:
+///   #include "OMPGridValues.h"
+///   #define GRIDVAL AMDGPUGpuGridValues
+///   ... Then use this reference to access GV_Warp_Size in the hsa plugin.
+///   GRIDVAL[GV_Warp_Size]
+///
+/// Example usage in libomptarget cuda plugin:
+///#include "OMPGridValues.h"
+///#define GRIDVAL NVPTXGpuGridValues
+///   ... Then use this reference to access GV_Warp_Size in the cuda plugin.
+///GRIDVAL[GV_Warp_Size]
+///
+enum GVIDX {
+  /// The maximum number of workers in a kernel.
+  /// (THREAD_ABSOLUTE_LIMIT) - (GV_Warp_Size), might be issue for blockDim.z
+  GV_Threads,
+  /// The size reserved for data in a shared memory slot.
+  GV_Slot_Size,
+  /// The default value of maximum number of threads in a worker warp.
+  GV_Warp_Size,
+  /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
+  /// for NVPTX.
+  GV_Warp_Size_32,
+  /// The number of bits required to represent the max number of threads in warp
+  GV_Warp_Size_Log2,
+  /// GV_Warp_Size * GV_Slot_Size,
+  GV_Warp_Slot_Size,
+  /// the maximum number of teams.
+  GV_Max_Teams,
+  /// Global Memory Alignment
+  GV_Mem_Align,
+  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
+  GV_Warp_Size_Log2_Mask,
+  // An alternative to the heavy data sharing infrastructure that uses global
+  // memory is one that uses device __shared__ memory.  The amount of such space
+  // (in bytes) reserved by the OpenMP runtime is noted here.
+  GV_SimpleBufferSize,
+  // The absolute maximum team size for a working group
+  GV_Max_WG_Size,
+  // The default maximum team size for a working group
+  GV_Default_WG_Size,
+  // This is GV_Max_WG_Size / GV_WarpSize. 32 for Nvidia and 16 for AMD.
+  GV_Max_Warp_Number
+};
+
+enum GVLIDX {
+  /// The slot size that should be reserved for a working warp.
+  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
+  GV_Warp_Size_Log2_MaskL
+};
+
+/// For AMDGPU GPUs
+static constexpr unsigned AMDGPUGpuGridValues[] = {
+448,  // GV_Threads   FIXME:  How can we make this bigger?
+256,  // GV_Slot_Size
+64,   // GV_Warp_Size
+32,   // GV_Warp_Size_32
+6,// GV_Warp_Size_Log2
+64 * 256, // GV_Warp_Slot_Size
+128,  // GV_Max_Teams
+256,  // GV_Mem_Align
+63,   // GV_Warp_Size_Log2_Mask
+896,  // GV_SimpleBufferSize
+1024, // 

[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2020-06-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D80833#2071818 , @aganea wrote:

> I didn't change the PWD/CWD stored in `LF_BUILDINFO`, it has already been 
> done by Reid a while ago: D53179  (it 
> already stores absolute paths)


That's surprising to me. Nico is the real export on reproducible builds, but we 
generally try very hard to make builds reproducible independent of source and 
build dir. Maybe there should be a flag controlling this? /Brepro?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D80835: [AIX] Change the default target CPU to power4 for AIX on Power

2020-06-03 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba4afe6f7a84: [AIX] Change the default target CPU to power4 
for AIX on Power (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80835

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- /dev/null
+++ clang/test/Driver/aix-mcpu-default.c
@@ -0,0 +1,16 @@
+// Check that the target cpu defaults to power4 on AIX.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
+// CHECK-MCPU-DEFAULT-NOT: warning:
+// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+
+// Check that the user is able to overwrite the default with '-mcpu'.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-mcpu=pwr6 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-USER %s
+// CHECK-MCPU-USER-NOT: warning:
+// CHECK-MCPU-USER: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-USER: "-target-cpu" "pwr6"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,14 +294,18 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on Darwin)
-if (TargetCPUName.empty() && !T.isOSDarwin()) {
-  if (T.getArch() == llvm::Triple::ppc64)
-TargetCPUName = "ppc64";
-  else if (T.getArch() == llvm::Triple::ppc64le)
-TargetCPUName = "ppc64le";
-  else
-TargetCPUName = "ppc";
+// each architecture. (except on AIX or Darwin)
+if (TargetCPUName.empty()) {
+  if (T.isOSAIX())
+TargetCPUName = "pwr4";
+  else if (!T.isOSDarwin()) {
+if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else
+  TargetCPUName = "ppc";
+  }
 }
 return TargetCPUName;
   }


Index: clang/test/Driver/aix-mcpu-default.c
===
--- /dev/null
+++ clang/test/Driver/aix-mcpu-default.c
@@ -0,0 +1,16 @@
+// Check that the target cpu defaults to power4 on AIX.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
+// CHECK-MCPU-DEFAULT-NOT: warning:
+// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+
+// Check that the user is able to overwrite the default with '-mcpu'.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-mcpu=pwr6 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-USER %s
+// CHECK-MCPU-USER-NOT: warning:
+// CHECK-MCPU-USER: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-USER: "-target-cpu" "pwr6"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,14 +294,18 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on Darwin)
-if (TargetCPUName.empty() && !T.isOSDarwin()) {
-  if (T.getArch() == llvm::Triple::ppc64)
-TargetCPUName = "ppc64";
-  else if (T.getArch() == llvm::Triple::ppc64le)
-TargetCPUName = "ppc64le";
-  else
-TargetCPUName = "ppc";
+// each architecture. (except on AIX or Darwin)
+if (TargetCPUName.empty()) {
+  if (T.isOSAIX())
+TargetCPUName = "pwr4";
+  else if (!T.isOSDarwin()) {
+if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else
+  TargetCPUName = "ppc";
+  }
 }
 return TargetCPUName;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79744: clang: Add address space to indirect abi info and use it for kernels

2020-06-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D79744#2069962 , @jdoerfert wrote:

> In D79744#2069786 , @arsenm wrote:
>
> > In D79744#2069774 , @arsenm wrote:
> >
> > > I think this is converging to adding a new IR attribute that essentially 
> > > just provides the pointee type for ABI purposes.
> >
>


If you don't feel like you can rely on the dereferenceable attributes, then I 
guess so, yes.


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

https://reviews.llvm.org/D79744



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


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-06-03 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 268256.
njames93 added a comment.

- Detect va_list type VarDecls to warn on


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -39,13 +39,22 @@
 #include 
 void my_printf(const char* format, ...) {
   va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
   va_start(ap, format);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions
   va_list n;
-  va_copy(n, ap); // Don't warn, va_copy is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  va_copy(n, ap);
   int i = va_arg(ap, int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead
-  va_end(ap); // Don't warn, va_end is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  va_end(ap);
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -9,6 +9,7 @@
 #include "ProTypeVarargCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -18,11 +19,62 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+// clang-format off
+"__builtin_isgreater", 
+"__builtin_isgreaterequal", 
+"__builtin_isless",
+"__builtin_islessequal", 
+"__builtin_islessgreater", 
+"__builtin_isunordered",
+"__builtin_fpclassify", 
+"__builtin_isfinite", 
+"__builtin_isinf",
+"__builtin_isinf_sign", 
+"__builtin_isnan", 
+"__builtin_isnormal",
+"__builtin_signbit", 
+"__builtin_constant_p", 
+"__builtin_classify_type",
+"__builtin_va_start",
+"__builtin_assume_aligned", // Documented as variadic to support default 
+// parameters.
+"__builtin_prefetch",   // Documented as variadic to support default
+// parameters.
+"__builtin_shufflevector",  // Documented as variadic but with a defined
+// number of args based on vector size.
+"__builtin_convertvector", 
+"__builtin_call_with_static_chain",
+"__builtin_annotation", 
+"__builtin_add_overflow", 
+"__builtin_sub_overflow",
+"__builtin_mul_overflow", 
+"__builtin_preserve_access_index",
+"__builtin_nontemporal_store", 
+"__builtin_nontemporal_load",
+"__builtin_ms_va_start",
+// clang-format on
+};
+
+namespace {
+AST_MATCHER(QualType, isVAList) {
+  ASTContext  = Finder->getASTContext();
+  QualType Desugar = Node.getDesugaredType(Context);
+  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
+ Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+}
+} // namespace
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
+
+  Finder->addMatcher(varDecl(hasType(isVAList())).bind("va_list"), this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {
@@ -54,7 +106,7 @@
 
   if (const auto *Matched = Result.Nodes.getNodeAs("va_use")) {
 diag(Matched->getExprLoc(),
- "do not use va_start/va_arg to define c-style vararg 

[PATCH] D79052: [clang codegen] Fix alignment of "Address" for incomplete array pointer.

2020-06-03 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79052



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added a comment.

I didn't change the PWD/CWD stored in `LF_BUILDINFO`, it has already been done 
by Reid a while ago: D53179  (it already 
stores absolute paths)

However absolute paths are stored by design, if we want to reproduce the build 
locally. I can't see how this feature could be useful if we didn't store 
absolute paths. The user could have many different branches of the same game 
synced locally (we're using perforce).

We could somehow defer the full path calculation to link-time if we didn't want 
full paths in the .OBJs. But each `LF_BUILDINFO` in the final .PDB needs to 
store full local paths.
Please let me know what direction should be taken.

This is what I have now:

  > cat b.cpp
  int f() { return 42; }
  
  # With Microsoft cl.exe (VS2019):
  
  > cl b.cpp /c /Z7
  > llvm-pdbutil dump -all b.obj | grep LF_BUILDINFO -A 5 -B 6
  0x1007 | LF_STRING_ID [size = 248] ID: , String: -c -Z7 -MT 
-I"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\ATLMFC\include" 
-I"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\include" -I"C:\Program
  0x1008 | LF_STRING_ID [size = 268] ID: , String:  Files 
(x86)\Windows Kits\NETFXSDK\4.8\include\um" -I"C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\ucrt" -I"C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\shared" -I"C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\um"
  0x1009 | LF_SUBSTR_LIST [size = 16]
   0x1007: `-c -Z7 -MT -I"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\ATLMFC\include" 
-I"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\include" -I"C:\Program`
   0x1008: ` Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" 
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" 
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" 
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um"`
  0x100A | LF_STRING_ID [size = 160] ID: 0x1009, String:  -I"C:\Program Files 
(x86)\Windows Kits\10\include\10.0.18362.0\winrt" -I"C:\Program Files 
(x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" -TP -X
  0x100B | LF_BUILDINFO [size = 28]
   0x1003: `D:\llvm-project`
   0x1004: `C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\cl.exe`
   0x1005: `b.cpp`
   0x1006: `D:\llvm-project\vc140.pdb`
   0x100A: ` -I"C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\winrt" -I"C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\cppwinrt" -TP -X`
  
  # With Clang:
  
  > clang-cl b.cpp /c /Z7
  > llvm-pdbutil dump -all b.obj | grep LF_BUILDINFO -A 5
  0x1007 | LF_BUILDINFO [size = 28]
   0x1003: `D:\llvm-project`
   0x1005: `D:\llvm-project\buildninjaDebMSVC\bin\clang-cl.exe`
   0x1004: `b.cpp`
   : ``
   0x1006: `-cc1 -triple x86_64-pc-windows-msvc19.26.28806 -emit-obj 
-mrelax-all -mincremental-linker-compatible -disable-free -main-file-name 
-mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none 
-relaxed-aliasing -fmath-errno -fno-rounding-math -mconstructor-aliases 
-munwind-tables -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -D_MT 
-flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames 
-stack-protector 2 -fms-volatile -fdiagnostics-format msvc -gcodeview 
-debug-info-kind=limited -resource-dir 
"D:\llvm-project\buildninjaDebMSVC\lib\clang\11.0.0" -internal-isystem 
"D:\llvm-project\buildninjaDebMSVC\lib\clang\11.0.0\include" -internal-isystem 
"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\ATLMFC\include" 
-internal-isystem "C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\include" -internal-isystem 
"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" -internal-isystem 
"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" 
-internal-isystem "C:\Program Files (x86)\Windows 
Kits\10\include\10.0.18362.0\shared" -internal-isystem "C:\Program Files 
(x86)\Windows Kits\10\include\10.0.18362.0\um" -internal-isystem "C:\Program 
Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" -internal-isystem 
"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" 
-fdeprecated-macro -fdebug-compilation-dir "D:\llvm-project" -ferror-limit 19 
-fmessage-length=120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.26.28806 -std=c++14 -fdelayed-template-parsing 
-fcolor-diagnostics -faddrsig -o b.obj -x c++ `




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:8
+// CHECK: 
+// 

[PATCH] D80940: [clang-format] [PR46159] Linux kernel 'C' code uses 'try' as a variable name, allow clang-format to handle such cases

2020-06-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D80940#2071247 , @curdeius wrote:

> LGTM.
>
> For a second, I thought that you could simplify the code by removing this 
> @try condition (and calling the function 
> `FormatTokenLexer::tryTransformTryUsageForC()` only if `isCppOnly`, but given 
> that Objective is a superset of C, it's probably safer to keep it the way 
> it's done now.


this is the premise of D80079: [clang-format] [NFC]  isCpp() is inconsistently 
used to mean both C++ and Objective C, add language specific isXXX() functions 
 but as we now are learning isCpp() is what is 
says on the tin!


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

https://reviews.llvm.org/D80940



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


[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

2020-06-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> IMO this *is* actually a good heuristic: `<<` between string literals 
> indicates some intent to break, and when the stream is entirely literals the 
> formatting is good.

I take your point, how do you feel about an option even if the default was 
"BreakBetweenStrings"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[clang] 5f47865 - [doc] Fix use of ` where `` was intended in attribute docs.

2020-06-03 Thread via cfe-commits

Author: Richard Smith
Date: 2020-06-03T10:52:55-07:00
New Revision: 5f478651eb31ac81acf9a521c3d44c5e1c4af49a

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

LOG: [doc] Fix use of ` where `` was intended in attribute docs.

`...` is rST syntax for hyperlinks etc. ``...`` should be used for code 
snippets.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8a5b9b8402f4..32ea9fcbf44e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -324,7 +324,7 @@ function marked with the ``sycl_kernel`` attribute:
   compiler uses function object type fields to generate OpenCL kernel
   parameters.
 - The function must return void. The compiler reuses the body of marked 
functions to
-  generate the OpenCL kernel body, and the OpenCL kernel must return `void`.
+  generate the OpenCL kernel body, and the OpenCL kernel must return ``void``.
 
 The SYCL kernel in the previous code sample meets these expectations.
   }];
@@ -1177,7 +1177,7 @@ def ObjCRuntimeNameDocs : Documentation {
 let Category = DocCatDecl;
 let Content = [{
 By default, the Objective-C interface or protocol identifier is used
-in the metadata name for that object. The `objc_runtime_name`
+in the metadata name for that object. The ``objc_runtime_name``
 attribute allows annotated interfaces or protocols to use the
 specified string argument in the object's metadata name instead of the
 default name.
@@ -1581,7 +1581,7 @@ expression are discarded under suspicious circumstances. 
A diagnostic is
 generated when a function or its return type is marked with ``[[nodiscard]]``
 (or ``__attribute__((warn_unused_result))``) and the function call appears as a
 potentially-evaluated discarded-value expression that is not explicitly cast to
-`void`.
+``void``.
 
 A string literal may optionally be provided to the attribute, which will be
 reproduced in any resulting diagnostics. Redeclarations using 
diff erent forms
@@ -1785,7 +1785,7 @@ Clang supports the GNU style 
``__attribute__((micromips))`` and
 may be attached to a function definition and instructs the backend to generate
 or not to generate microMIPS code for that function.
 
-These attributes override the `-mmicromips` and `-mno-micromips` options
+These attributes override the ``-mmicromips`` and ``-mno-micromips`` options
 on the command line.
   }];
 }
@@ -2782,11 +2782,13 @@ The ``trivial_abi`` attribute can be applied to a C++ 
class, struct, or union.
 It instructs the compiler to pass and return the type using the C ABI for the
 underlying type when the type would otherwise be considered non-trivial for the
 purpose of calls.
-A class annotated with `trivial_abi` can have non-trivial destructors or 
copy/move constructors without automatically becoming non-trivial for the 
purposes of calls. For example:
+A class annotated with ``trivial_abi`` can have non-trivial destructors or
+copy/move constructors without automatically becoming non-trivial for the
+purposes of calls. For example:
 
   .. code-block:: c++
 
-// A is trivial for the purposes of calls because `trivial_abi` makes the
+// A is trivial for the purposes of calls because ``trivial_abi`` makes the
 // user-provided special functions trivial.
 struct __attribute__((trivial_abi)) A {
   ~A();
@@ -3314,15 +3316,15 @@ def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
   let Content = [{
-The `declare simd` construct can be applied to a function to enable the 
creation
+The ``declare simd`` construct can be applied to a function to enable the 
creation
 of one or more versions that can process multiple arguments using SIMD
-instructions from a single invocation in a SIMD loop. The `declare simd`
-directive is a declarative directive. There may be multiple `declare simd`
-directives for a function. The use of a `declare simd` construct on a function
+instructions from a single invocation in a SIMD loop. The ``declare simd``
+directive is a declarative directive. There may be multiple ``declare simd``
+directives for a function. The use of a ``declare simd`` construct on a 
function
 enables the creation of SIMD versions of the associated function that can be
 used to process multiple arguments from a single invocation from a SIMD loop
 concurrently.
-The syntax of the `declare simd` construct is as follows:
+The syntax of the ``declare simd`` construct is as follows:
 
   .. code-block:: none
 
@@ -3349,7 +3351,7 @@ def OMPDeclareTargetDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare target";
   let 

[clang] ba4afe6 - [AIX] Change the default target CPU to power4 for AIX on Power

2020-06-03 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2020-06-03T13:50:26-04:00
New Revision: ba4afe6f7a8453b24ee0b664e40d157d15a54034

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

LOG: [AIX] Change the default target CPU to power4 for AIX on Power

Summary: This patch changes the AIX default target CPU to power4 since this is 
the the lowest arch for the lowest OS level supported.

Reviewers: hubert.reinterpretcast, cebowleratibm, daltenty

Reviewed By: hubert.reinterpretcast

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/aix-mcpu-default.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b2c984912154..0ddbfac81b33 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,14 +294,18 @@ std::string tools::getCPUName(const ArgList , const 
llvm::Triple ,
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on Darwin)
-if (TargetCPUName.empty() && !T.isOSDarwin()) {
-  if (T.getArch() == llvm::Triple::ppc64)
-TargetCPUName = "ppc64";
-  else if (T.getArch() == llvm::Triple::ppc64le)
-TargetCPUName = "ppc64le";
-  else
-TargetCPUName = "ppc";
+// each architecture. (except on AIX or Darwin)
+if (TargetCPUName.empty()) {
+  if (T.isOSAIX())
+TargetCPUName = "pwr4";
+  else if (!T.isOSDarwin()) {
+if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else
+  TargetCPUName = "ppc";
+  }
 }
 return TargetCPUName;
   }

diff  --git a/clang/test/Driver/aix-mcpu-default.c 
b/clang/test/Driver/aix-mcpu-default.c
new file mode 100644
index ..10636abad304
--- /dev/null
+++ b/clang/test/Driver/aix-mcpu-default.c
@@ -0,0 +1,16 @@
+// Check that the target cpu defaults to power4 on AIX.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
+// CHECK-MCPU-DEFAULT-NOT: warning:
+// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+
+// Check that the user is able to overwrite the default with '-mcpu'.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-mcpu=pwr6 \
+// RUN:-target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-USER %s
+// CHECK-MCPU-USER-NOT: warning:
+// CHECK-MCPU-USER: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-USER: "-target-cpu" "pwr6"



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


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

2020-06-03 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Tested with tensorflow build. The patch- does not seem to break anything now.


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

https://reviews.llvm.org/D79237



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


[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

2020-06-03 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

Sorry for breaking the build and thanks for the fixes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77572



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


[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

2020-06-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Bumping for review.  Are there other trusted reviewers we could add the to 
review to help?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D80450#2071696 , @tra wrote:

> In D80450#2055463 , @tra wrote:
>
> > Is this patch supposed to be used with D79526 
> >  or instead of it?
>
>
> ^^^ I don't think this has been answered. I would like to test this change 
> before it lands.


sorry I missed that. Yes this patch is used on top of D79526 
.


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

https://reviews.llvm.org/D80450



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


[PATCH] D79587: [CodeGen][SVE] Legalisation of extends with scalable types

2020-06-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 268246.
kmclaughlin added a comment.

- Use APInt::trunc to truncate the constant in performSVEAndCombine


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

https://reviews.llvm.org/D79587

Files:
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/test/CodeGen/AArch64/sve-sext-zext.ll

Index: llvm/test/CodeGen/AArch64/sve-sext-zext.ll
===
--- llvm/test/CodeGen/AArch64/sve-sext-zext.ll
+++ llvm/test/CodeGen/AArch64/sve-sext-zext.ll
@@ -186,3 +186,143 @@
   %r = zext  %a to 
   ret  %r
 }
+
+; Extending to illegal types
+
+define  @sext_b_to_h( %a) {
+; CHECK-LABEL: sext_b_to_h:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.h, z0.b
+; CHECK-NEXT:sunpkhi z1.h, z0.b
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_h_to_s( %a) {
+; CHECK-LABEL: sext_h_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.s, z0.h
+; CHECK-NEXT:sunpkhi z1.s, z0.h
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_s_to_d( %a) {
+; CHECK-LABEL: sext_s_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z2.d, z0.s
+; CHECK-NEXT:sunpkhi z1.d, z0.s
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_b_to_s( %a) {
+; CHECK-LABEL: sext_b_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z1.h, z0.b
+; CHECK-NEXT:sunpkhi z3.h, z0.b
+; CHECK-NEXT:sunpklo z0.s, z1.h
+; CHECK-NEXT:sunpkhi z1.s, z1.h
+; CHECK-NEXT:sunpklo z2.s, z3.h
+; CHECK-NEXT:sunpkhi z3.s, z3.h
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @sext_b_to_d( %a) {
+; CHECK-LABEL: sext_b_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sunpklo z1.h, z0.b
+; CHECK-NEXT:sunpkhi z0.h, z0.b
+; CHECK-NEXT:sunpklo z2.s, z1.h
+; CHECK-NEXT:sunpkhi z3.s, z1.h
+; CHECK-NEXT:sunpklo z5.s, z0.h
+; CHECK-NEXT:sunpkhi z7.s, z0.h
+; CHECK-NEXT:sunpklo z0.d, z2.s
+; CHECK-NEXT:sunpkhi z1.d, z2.s
+; CHECK-NEXT:sunpklo z2.d, z3.s
+; CHECK-NEXT:sunpkhi z3.d, z3.s
+; CHECK-NEXT:sunpklo z4.d, z5.s
+; CHECK-NEXT:sunpkhi z5.d, z5.s
+; CHECK-NEXT:sunpklo z6.d, z7.s
+; CHECK-NEXT:sunpkhi z7.d, z7.s
+; CHECK-NEXT:ret
+  %ext = sext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_h( %a) {
+; CHECK-LABEL: zext_b_to_h:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.h, z0.b
+; CHECK-NEXT:uunpkhi z1.h, z0.b
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_h_to_s( %a) {
+; CHECK-LABEL: zext_h_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.s, z0.h
+; CHECK-NEXT:uunpkhi z1.s, z0.h
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_s_to_d( %a) {
+; CHECK-LABEL: zext_s_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z2.d, z0.s
+; CHECK-NEXT:uunpkhi z1.d, z0.s
+; CHECK-NEXT:mov z0.d, z2.d
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_s( %a) {
+; CHECK-LABEL: zext_b_to_s:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z1.h, z0.b
+; CHECK-NEXT:uunpkhi z3.h, z0.b
+; CHECK-NEXT:uunpklo z0.s, z1.h
+; CHECK-NEXT:uunpkhi z1.s, z1.h
+; CHECK-NEXT:uunpklo z2.s, z3.h
+; CHECK-NEXT:uunpkhi z3.s, z3.h
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
+
+define  @zext_b_to_d( %a) {
+; CHECK-LABEL: zext_b_to_d:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uunpklo z1.h, z0.b
+; CHECK-NEXT:uunpkhi z0.h, z0.b
+; CHECK-NEXT:uunpklo z2.s, z1.h
+; CHECK-NEXT:uunpkhi z3.s, z1.h
+; CHECK-NEXT:uunpklo z5.s, z0.h
+; CHECK-NEXT:uunpkhi z7.s, z0.h
+; CHECK-NEXT:uunpklo z0.d, z2.s
+; CHECK-NEXT:uunpkhi z1.d, z2.s
+; CHECK-NEXT:uunpklo z2.d, z3.s
+; CHECK-NEXT:uunpkhi z3.d, z3.s
+; CHECK-NEXT:uunpklo z4.d, z5.s
+; CHECK-NEXT:uunpkhi z5.d, z5.s
+; CHECK-NEXT:uunpklo z6.d, z7.s
+; CHECK-NEXT:uunpkhi z7.d, z7.s
+; CHECK-NEXT:ret
+  %ext = zext  %a to 
+  ret  %ext
+}
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -888,6 +888,9 @@
 
   void ReplaceNodeResults(SDNode *N, SmallVectorImpl ,
   SelectionDAG ) const override;
+  void ReplaceExtractSubVectorResults(SDNode *N,
+  SmallVectorImpl ,
+  SelectionDAG ) const;
 
   bool 

[PATCH] D81041: Use existing path sep style in clang::FileManager::FixupRelativePath

2020-06-03 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added a comment.

@amccarth

The assert that I am getting is at line 1701 of VirtualFileSystem.cpp:

  assert(!isTraversalComponent(*Start) &&
   !isTraversalComponent(From->getName()) &&
   "Paths should not contain traversal components");

path is 
`C:/[path]/[to]/[build]/tools/clang/test/ClangScanDeps/Output/vfsoverlay.cpp.tmp.dir\\.`
 (notice the trailing windows path separator)

The path is canonicalized on line 1688 of VirtualFileSystem.cpp in lookupPath. 
The canonicalization fails to remove the trailing '.' because it detects (using 
the same method I am using in my patch) that the file path has posix separators 
and it sees "vfsoverlay.cpp.tmp.dir\\." as one path component. Perhaps the real 
fix is to make canonicalize handle mixed separators? I'm guessing that 
canonicalize is implemented as it is for performance reasons? This comment in 
the body of canonicalize "Explicitly specifying the path style prevents the 
direction of the slashes from changing" leads me to believe that it is 
desirable that the path separators not be changed, so a new implementation 
would need to walk the entire string and fail if mixed separators are 
encountered, or llvm::sys::path::remove_dots needs to also be changed to have a 
mixed-separators version.

The test clang::test/ClangScanDeps/vfsoverlay.cpp causes this on my machine. It 
is unfortunate that for reasons beyond my comprehensions, I often get test 
failures on my machine that are not caught by the builders, so I have no idea 
why the builders don't see this. Perhaps they aren't running this test?

Regardless, I think that using even a flawed method to detect what the default 
path separator should be might be better than just assuming native. Either it 
will be correct, or the path already had mixed separators, and it doesn't 
actually matter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81041



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


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-06-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I've got nothing to say here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D80743



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


[clang] bee2c27 - [doc] Fix typo.

2020-06-03 Thread via cfe-commits

Author: Richard Smith
Date: 2020-06-03T09:56:38-07:00
New Revision: bee2c2708f3e38261825439bc8b0fbe8b795854d

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

LOG: [doc] Fix typo.

The absence of a space here caused this codeblock to be missing from the 
rendered output.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 5222c92c42a0..8a5b9b8402f4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4359,7 +4359,7 @@ with this attribute. This is because previously 
constructed subobjects need to
 be destroyed if an exception gets thrown before the initialization of the
 complete object is complete. For instance:
 
-.. code-block::c++
+.. code-block:: c++
 
   void f() {
 try {



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


[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 268242.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79948

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/for_scan_codegen.cpp
  clang/test/OpenMP/scan_messages.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2376,6 +2376,17 @@
   for (auto *E : C->reduction_ops()) {
 Visitor->AddStmt(E);
   }
+  if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
+for (auto *E : C->copy_ops()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_temps()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_elems()) {
+  Visitor->AddStmt(E);
+}
+  }
 }
 void OMPClauseEnqueue::VisitOMPTaskReductionClause(
 const OMPTaskReductionClause *C) {
Index: clang/test/OpenMP/scan_messages.cpp
===
--- clang/test/OpenMP/scan_messages.cpp
+++ clang/test/OpenMP/scan_messages.cpp
@@ -19,32 +19,32 @@
 #pragma omp for simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
 if (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 if (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   while (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   do
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc)
   ;
-#pragma omp simd reduction(inscan, +: argc)
+#pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
   for (int i = 0; i < 10; ++i)
   do {
-#pragma omp scan inclusive(argc)
+#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
   } while (argc);
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   switch (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 switch (argc)
 case 1:
 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
@@ -52,21 +52,21 @@
   case 1: {
 

[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D80450#2055463 , @tra wrote:

> Is this patch supposed to be used with D79526 
>  or instead of it?


^^^ I don't think this has been answered. I would like to test this change 
before it lands.


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

https://reviews.llvm.org/D80450



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-06-03 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D69825#2070926 , @hans wrote:

> In D69825#2063979 , @dim wrote:
>
> > FWIW, this change causes 
> > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246630, see in particular 
> > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246630#c18.
> >
> > For some reason, not spawning a new process for the cc1 stage can lead to 
> > non-reproducible output. The exact cause is not known yet.
>
>
> Can you share the preprocessed source and compiler command-line for printf.c, 
> either on the bug or here?


See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246630#c26, and I've also 
uploaded the repro files to 
https://www.andric.com/freebsd/clang/bug246630-repro.tar.xz.

Running rGa3220dffcb1 
 under 
valgrind (on Linux) shows:

  ==120363== Conditional jump or move depends on uninitialised value(s)
  ==120363==at 0x1634474: llvm::ConstantExpr::getGetElementPtr(llvm::Type*, 
llvm::Constant*, llvm::ArrayRef, bool, llvm::Optional, llvm::Type*) (Constants.cpp:2191)
  ==120363==by 0x112D6D9: getGetElementPtr (Constants.h:1163)
  ==120363==by 0x112D6D9: (anonymous 
namespace)::SymbolicallyEvaluateGEP(llvm::GEPOperator const*, 
llvm::ArrayRef, llvm::DataLayout const&, 
llvm::TargetLibraryInfo const*) (ConstantFolding.cpp:1005)
  ==120363==by 0x112DF70: (anonymous 
namespace)::ConstantFoldInstOperandsImpl(llvm::Value const*, unsigned int, 
llvm::ArrayRef, llvm::DataLayout const&, 
llvm::TargetLibraryInfo const*) (ConstantFolding.cpp:1039)
  ==120363==by 0x112C165: (anonymous 
namespace)::ConstantFoldConstantImpl(llvm::Constant const*, llvm::DataLayout 
const&, llvm::TargetLibraryInfo const*, llvm::SmallDenseMap, 
llvm::detail::DenseMapPair >&) [clone 
.part.0] (ConstantFolding.cpp:1114)
  ==120363==by 0x112C5CF: llvm::ConstantFoldConstant(llvm::Constant const*, 
llvm::DataLayout const&, llvm::TargetLibraryInfo const*) 
(ConstantFolding.cpp:1194)
  ==120363==by 0x188F410: prepareICWorklistFromFunction 
(InstructionCombining.cpp:3584)
  ==120363==by 0x188F410: combineInstructionsOverFunction(llvm::Function&, 
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, 
llvm::TargetLibraryInfo&, llvm::DominatorTree&, 
llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, 
llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*) 
(InstructionCombining.cpp:3703)
  ==120363==by 0x189205F: runOnFunction (InstructionCombining.cpp:3789)
  ==120363==by 0x189205F: 
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) 
(InstructionCombining.cpp:3768)
  ==120363==by 0x16F4352: 
llvm::FPPassManager::runOnFunction(llvm::Function&) (LegacyPassManager.cpp:1482)
  ==120363==by 0x16F4DE8: llvm::FPPassManager::runOnModule(llvm::Module&) 
(LegacyPassManager.cpp:1518)
  ==120363==by 0x16F51A2: runOnModule (LegacyPassManager.cpp:1583)
  ==120363==by 0x16F51A2: llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(LegacyPassManager.cpp:1695)
  ==120363==by 0x1FF4CFE: EmitAssembly (BackendUtil.cpp:954)
  ==120363==by 0x1FF4CFE: 
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions 
const&, clang::CodeGenOptions const&, clang::TargetOptions const&, 
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, 
clang::BackendAction, std::unique_ptr >) (BackendUtil.cpp:1677)
  ==120363==by 0x2C471A8: 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
(CodeGenAction.cpp:335)
  ==120363==  Uninitialised value was created by a stack allocation
  ==120363==at 0x112C653: (anonymous 
namespace)::SymbolicallyEvaluateGEP(llvm::GEPOperator const*, 
llvm::ArrayRef, llvm::DataLayout const&, 
llvm::TargetLibraryInfo const*) (ConstantFolding.cpp:832)

Trying to reduce this now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69825



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


[PATCH] D81072: [analyzer] ObjCAutoreleaseWriteChecker: Support explicit autoreleasepools.

2020-06-03 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7113271528a4: [analyzer] ObjCAutoreleaseWriteChecker: 
Support explicit autoreleasepools. (authored by Paul Pelzl 
ppe...@apple.com, committed by dergachev.a).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81072

Files:
  clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
  clang/test/Analysis/autoreleasewritechecker_test.m

Index: clang/test/Analysis/autoreleasewritechecker_test.m
===
--- clang/test/Analysis/autoreleasewritechecker_test.m
+++ clang/test/Analysis/autoreleasewritechecker_test.m
@@ -83,6 +83,10 @@
 - (BOOL) writeToErrorInBlockMultipleTimes:(NSError *__autoreleasing *)error;
 - (BOOL) writeToError:(NSError *__autoreleasing *)error;
 - (BOOL) writeToErrorWithDispatchGroup:(NSError *__autoreleasing *)error;
+- (BOOL)writeToErrorInAutoreleasePool:(NSError *__autoreleasing *)error;
+- (BOOL)writeToStrongErrorInAutoreleasePool:(NSError *__strong *)error;
+- (BOOL)writeToLocalErrorInAutoreleasePool:(NSError *__autoreleasing *)error;
+- (BOOL)writeToErrorInAutoreleasePoolMultipleTimes:(NSError *__autoreleasing *)error;
 @end
 
 @implementation I
@@ -162,6 +166,58 @@
 return 0;
 }
 
+- (BOOL)writeToErrorInAutoreleasePool:(NSError *__autoreleasing *)error {
+  @autoreleasepool {
+if (error) {
+  *error = [NSError errorWithDomain:1]; // expected-warning{{Write to autoreleasing out parameter inside locally-scoped autorelease pool; consider writing first to a strong local variable declared outside of the autorelease pool}}
+}
+  }
+
+  return 0;
+}
+
+- (BOOL)writeToStrongErrorInAutoreleasePool:(NSError *__strong *)error {
+  @autoreleasepool {
+if (error) {
+  *error = [NSError errorWithDomain:1]; // no-warning
+}
+  }
+
+  return 0;
+}
+
+- (BOOL)writeToLocalErrorInAutoreleasePool:(NSError *__autoreleasing *)error {
+  NSError *localError;
+  @autoreleasepool {
+localError = [NSError errorWithDomain:1]; // no-warning
+  }
+
+  if (error) {
+*error = localError; // no-warning
+  }
+
+  return 0;
+}
+
+- (BOOL)writeToErrorInAutoreleasePoolMultipleTimes:(NSError *__autoreleasing *)error {
+  @autoreleasepool {
+if (error) {
+  *error = [NSError errorWithDomain:1]; // expected-warning{{Write to autoreleasing out parameter inside locally-scoped autorelease pool; consider writing first to a strong local variable declared outside of the autorelease pool}}
+}
+  }
+  if (error) {
+*error = [NSError errorWithDomain:1]; // no-warning
+  }
+  @autoreleasepool {
+if (error) {
+  *error = [NSError errorWithDomain:1]; // expected-warning{{Write to autoreleasing out parameter inside locally-scoped autorelease pool; consider writing first to a strong local variable declared outside of the autorelease pool}}
+  *error = [NSError errorWithDomain:1]; // expected-warning{{Write to autoreleasing out parameter inside locally-scoped autorelease pool; consider writing first to a strong local variable declared outside of the autorelease pool}}
+}
+  }
+
+  return 0;
+}
+
 - (BOOL) writeToError:(NSError *__autoreleasing *)error {
 *error = [NSError errorWithDomain:1]; // no-warning
 return 0;
@@ -181,6 +237,15 @@
   return 0;
 }
 
+BOOL writeIntoErrorInAutoreleasePoolFromCFunc(NSError *__autoreleasing *error) {
+  @autoreleasepool {
+if (error) {
+  *error = [NSError errorWithDomain:1]; // expected-warning{{Write to autoreleasing out parameter inside locally-scoped autorelease pool; consider writing first to a strong local variable declared outside of the autorelease pool}}
+}
+  }
+  return 0;
+}
+
 BOOL writeToErrorNoWarning(NSError *__autoreleasing* error) {
   *error = [NSError errorWithDomain:1]; // no-warning
   return 0;
Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
@@ -30,6 +30,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "llvm/ADT/Twine.h"
@@ -44,6 +45,7 @@
 const char *CapturedBind = "capturedbind";
 const char *ParamBind = "parambind";
 const char *IsMethodBind = "ismethodbind";
+const char *IsARPBind = "isautoreleasepoolbind";
 
 class ObjCAutoreleaseWriteChecker : public Checker {
 public:
@@ -128,21 +130,39 @@
   SourceRange Range = 

[PATCH] D81071: [analyzer] Add initial support for ObjCIndirectCopyRestoreExpr.

2020-06-03 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe94192198f8a: [analyzer] Add support for 
ObjCIndirectCopyRestoreExpr. (authored by Paul Pelzl ppe...@apple.com, 
committed by dergachev.a).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81071

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/objc-indirect-copy-restore.m

Index: clang/test/Analysis/objc-indirect-copy-restore.m
===
--- /dev/null
+++ clang/test/Analysis/objc-indirect-copy-restore.m
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -fobjc-arc -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+
+@protocol NSObject
++ (nonnull instancetype)alloc;
+- (nonnull instancetype)init;
+@end
+@interface NSObject  {}
+@end
+
+@interface NSError : NSObject {
+@public
+  int x;
+}
+@end
+
+
+@interface SomeClass : NSObject
++ (int)doSomethingWithError:(NSError *__autoreleasing *)error;
+@end
+
+@implementation SomeClass
++ (int)doSomethingWithError:(NSError *__autoreleasing *)error {
+if (error) {
+NSError *e = [[NSError alloc] init];
+assert(e);
+e->x = 5;
+*error = e;
+clang_analyzer_eval(*error != 0); // expected-warning{{TRUE}}
+}
+return 0;
+}
+@end
+
+void testStrongOutParam(void) {
+  NSError *error;
+  clang_analyzer_eval(error != 0); // expected-warning{{FALSE}}
+  int ok = [SomeClass doSomethingWithError:];
+  clang_analyzer_eval(ok); // expected-warning{{FALSE}}
+  clang_analyzer_eval(error != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(error->x == 5); // expected-warning{{TRUE}}
+}
+
+void testAutoreleasingOutParam(void) {
+  NSError *__autoreleasing error;
+  clang_analyzer_eval(error != 0); // expected-warning{{FALSE}}
+  int ok = [SomeClass doSomethingWithError:];
+  clang_analyzer_eval(ok); // expected-warning{{FALSE}}
+  clang_analyzer_eval(error != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(error->x == 5); // expected-warning{{TRUE}}
+}
+
+void testNilOutParam(void) {
+int ok = [SomeClass doSomethingWithError:(void *)0];
+clang_analyzer_eval(ok);  // expected-warning{{FALSE}}
+}
+
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1210,7 +1210,6 @@
 
   switch (S->getStmtClass()) {
 // C++, OpenMP and ARC stuff we don't support yet.
-case Expr::ObjCIndirectCopyRestoreExprClass:
 case Stmt::CXXDependentScopeMemberExprClass:
 case Stmt::CXXTryStmtClass:
 case Stmt::CXXTypeidExprClass:
@@ -1870,6 +1869,21 @@
   Bldr.addNodes(Dst);
   break;
 }
+
+case Expr::ObjCIndirectCopyRestoreExprClass: {
+  // ObjCIndirectCopyRestoreExpr implies passing a temporary for
+  // correctness of lifetime management.  Due to limited analysis
+  // of ARC, this is implemented as direct arg passing.
+  Bldr.takeNodes(Pred);
+  ProgramStateRef state = Pred->getState();
+  const auto *OIE = cast(S);
+  const Expr *E = OIE->getSubExpr();
+  SVal V = state->getSVal(E, Pred->getLocationContext());
+  Bldr.generateNode(S, Pred,
+  state->BindExpr(S, Pred->getLocationContext(), V));
+  Bldr.addNodes(Dst);
+  break;
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-03 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang marked 4 inline comments as done.
LukeZhuang added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:1818-1819
+llvm::APFloat Probability = Eval.Val.getFloat();
+if (!(Probability >= llvm::APFloat(0.0) ||
+  Probability <= llvm::APFloat(1.0))) {
+  Diag(ProbArg->getLocStart(), diag::err_probability_out_of_range)

lebedev.ri wrote:
> This doesn't look right to me, but maybe i'm misreading something?
> Assuming the `!` is intentional to avoid some fp weirdness (if not, simplify 
> this)
> shouldn't this be an `&&`, not `||`?
> 
> Consider:
> `Probability = -1`
> ```
> if (!(-1 >= llvm::APFloat(0.0) ||
>   -1 <= llvm::APFloat(1.0))) {
> ```
> ```
> if (!(false ||
>   true) {
> ```
> ```
> if (false) {
> ```
> so i'd think `Probability = -1` would not get diagnosed?
Yes, you're right.. Because of version problem, I still use converting to 
double in my local build, and miscopy this when upstreaming. Thank you for 
point it out.



Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:19-20
+  dummy = __builtin_expect_with_probability(x > 0, 1, 0.9);
+  dummy = __builtin_expect_with_probability(x > 0, 1, 1.1); // expected-error 
{{probability of __builtin_expect_with_probability is outside the range [0.0, 
1.0]}}
+  dummy = __builtin_expect_with_probability(x > 0, 1, -1); // expected-error 
{{probability of __builtin_expect_with_probability is outside the range [0.0, 
1.0]}}
+  dummy = __builtin_expect_with_probability(x > 0, 1, p); // expected-error 
{{probability of __builtin_expect_with_probability must be constant 
floating-point expression}} expected-note {{read of non-constexpr variable 'p' 
is not allowed in a constant expression}}

lebedev.ri wrote:
> Do these tests actually pass?
It pass it for now. Again my local build still use converting to double to 
compare and passed the test, but I miscopied it when upstream the change. Thank 
you!


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

https://reviews.llvm.org/D79830



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-03 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang updated this revision to Diff 268226.
LukeZhuang added a comment.

**updated 06/03/2020**:
(1) fix bug of range checking in SemaChecking


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

https://reviews.llvm.org/D79830

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

Index: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
===
--- llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -55,13 +55,32 @@
 "unlikely-branch-weight", cl::Hidden, cl::init(1),
 cl::desc("Weight of the branch unlikely to be taken (default = 1)"));
 
+std::pair setBranchWeight(Intrinsic::ID IntrinsicID,
+  CallInst *CI, int BranchCount) {
+  if (IntrinsicID == Intrinsic::expect) {
+// __builtin_expect
+return {LikelyBranchWeight, UnlikelyBranchWeight};
+  } else {
+// __builtin_expect_with_probability
+assert(CI->getNumOperands() >= 3 &&
+   "expect with probability must have 3 arguments");
+ConstantFP *Confidence = dyn_cast(CI->getArgOperand(2));
+double TrueProb = Confidence->getValueAPF().convertToDouble();
+double FalseProb = (1.0 - TrueProb) / (BranchCount - 1);
+uint32_t LikelyBW = ceil((TrueProb * (double)(INT32_MAX - 1)) + 1.0);
+uint32_t UnlikelyBW = ceil((FalseProb * (double)(INT32_MAX - 1)) + 1.0);
+return {LikelyBW, UnlikelyBW};
+  }
+}
+
 static bool handleSwitchExpect(SwitchInst ) {
   CallInst *CI = dyn_cast(SI.getCondition());
   if (!CI)
 return false;
 
   Function *Fn = CI->getCalledFunction();
-  if (!Fn || Fn->getIntrinsicID() != Intrinsic::expect)
+  if (!Fn || (Fn->getIntrinsicID() != Intrinsic::expect &&
+  Fn->getIntrinsicID() != Intrinsic::expect_with_probability))
 return false;
 
   Value *ArgValue = CI->getArgOperand(0);
@@ -71,15 +90,20 @@
 
   SwitchInst::CaseHandle Case = *SI.findCaseValue(ExpectedValue);
   unsigned n = SI.getNumCases(); // +1 for default case.
-  SmallVector Weights(n + 1, UnlikelyBranchWeight);
+  std::pair WeightNums =
+  setBranchWeight(Fn->getIntrinsicID(), CI, n + 1);
+  uint32_t LikelyBranchWeightVal = WeightNums.first;
+  uint32_t UnlikelyBranchWeightVal = WeightNums.second;
+
+  SmallVector Weights(n + 1, UnlikelyBranchWeightVal);
 
   uint64_t Index = (Case == *SI.case_default()) ? 0 : Case.getCaseIndex() + 1;
-  Weights[Index] = LikelyBranchWeight;
+  Weights[Index] = LikelyBranchWeightVal;
 
-  SI.setMetadata(
-  LLVMContext::MD_misexpect,
-  MDBuilder(CI->getContext())
-  .createMisExpect(Index, LikelyBranchWeight, UnlikelyBranchWeight));
+  SI.setMetadata(LLVMContext::MD_misexpect,
+ MDBuilder(CI->getContext())
+ .createMisExpect(Index, LikelyBranchWeightVal,
+  UnlikelyBranchWeightVal));
 
   SI.setCondition(ArgValue);
   misexpect::checkFrontendInstrumentation(SI);
@@ -223,15 +247,19 @@
 return true;
   return false;
 };
+std::pair WeightNums = setBranchWeight(
+Expect->getCalledFunction()->getIntrinsicID(), Expect, 2);
+uint32_t LikelyBranchWeightVal = WeightNums.first;
+uint32_t UnlikelyBranchWeightVal = WeightNums.second;
 
 if (IsOpndComingFromSuccessor(BI->getSuccessor(1)))
-  BI->setMetadata(
-  LLVMContext::MD_prof,
-  MDB.createBranchWeights(LikelyBranchWeight, UnlikelyBranchWeight));
+  BI->setMetadata(LLVMContext::MD_prof,
+  MDB.createBranchWeights(LikelyBranchWeightVal,
+  UnlikelyBranchWeightVal));
 else if (IsOpndComingFromSuccessor(BI->getSuccessor(0)))
-  BI->setMetadata(
-  LLVMContext::MD_prof,
-  MDB.createBranchWeights(UnlikelyBranchWeight, LikelyBranchWeight));
+  BI->setMetadata(LLVMContext::MD_prof,
+  MDB.createBranchWeights(UnlikelyBranchWeightVal,
+  LikelyBranchWeightVal));
   }
 }
 
@@ -277,7 +305,8 @@
   }
 
   Function *Fn = CI->getCalledFunction();
-  if (!Fn || Fn->getIntrinsicID() != Intrinsic::expect)
+  if (!Fn || (Fn->getIntrinsicID() != Intrinsic::expect &&
+  Fn->getIntrinsicID() != Intrinsic::expect_with_probability))
 return false;
 
   Value *ArgValue = CI->getArgOperand(0);
@@ -289,13 +318,22 @@
   MDNode *Node;
   MDNode *ExpNode;
 
+  std::pair WeightNums =
+   

[PATCH] D81107: Make syntax tree test print the line number when it fails

2020-06-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: hlopko.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The syntax tree test uses a helper function that executes all testing
assertions. When an assertion fails, the only line number that gets
printed to the log refers to the helper function. After this change, we
would also get the line number of the EXPECT_TRUE macro invocation
(unfortunately, the line number of the last token of it, not the first
one, but there's not much I can do about it).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81107

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -209,15 +209,22 @@
 return Root;
   }
 
-  void expectTreeDumpEqual(StringRef Code, StringRef Tree) {
+  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree) {
 SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-SCOPED_TRACE(Code);
 
 auto *Root = buildTree(Code, GetParam());
-EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
-<< "Source file has syntax errors, they were printed to the test log";
+if (Diags->getClient()->getNumErrors() != 0) {
+  return ::testing::AssertionFailure()
+ << "Source file has syntax errors, they were printed to the test "
+"log";
+}
 std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+// EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(Tree.trim().str(), Actual);
+if (Actual != Tree.trim().str()) {
+  return ::testing::AssertionFailure();
+}
+return ::testing::AssertionSuccess();
   }
 
   // Adds a file to the test VFS.
@@ -266,11 +273,11 @@
 };
 
 TEST_P(SyntaxTreeTest, Simple) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {}
 void foo() {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -293,15 +300,15 @@
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleVariable) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a;
 int b = 42;
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -317,14 +324,14 @@
   | `-UnknownExpression
   |   `-42
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleFunction) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void foo(int a, int b) {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -346,17 +353,17 @@
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -397,11 +404,11 @@
 | |-{
 | `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   for (;;)  {}
@@ -428,21 +435,21 @@
 |   |-{
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   int a[3];
   for (int x : a)
 ;
 }
-  )cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -479,12 +486,17 @@
 | `-EmptyStatement
 |   `-;
 `-}
-   )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  expectTreeDumpEqual("void test() { int a = 10; }",
-  R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  int a = 10;
+}
+)cpp",
+  R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
@@ -505,11 +517,11 @@
 | | `-10
 | `-;
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   switch (1) {
@@ -549,11 +561,11 @@
 |   | `-;
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, While) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   while (1) { continue; break; }
@@ -586,15 +598,20 @@
 |   | `-;
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UnhandledStatement) {
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  expectTreeDumpEqual("int main() { foo: return 100; }",
-  R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int main() {
+  foo: return 100;
+}
+)cpp",
+   

[PATCH] D80752: [AArch64]: BFloat MatMul Intrinsics

2020-06-03 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c:2
+// RUN: %clang_cc1 -triple aarch64-arm-none-eabi \
+// RUN:   -O2 -target-feature +neon -target-feature +bf16 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s

Is it possible to avoid running the whole -O2 pipeline and instead run, say,

```
%clang_cc1 -triple aarch64-arm-none-eabi -target-feature +neon -target-feature 
+bf16 \
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | 
FileCheck %s
```

Also, I suggest auto-generating the checks using 
`llvm/utils/update_cc_test_checks.py`.  Sorry, I should have mentioned it in 
the previous review iteration.



Comment at: clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c:10
+// CHECK-NEXT  %0 = bitcast <4 x bfloat> %a to <8 x i8>
+// CHECK-NEXT  %1 = bitcast <4 x bfloat> %b to <8 x i8>
+// CHECK-NEXT  %vbfdot1.i = tail call <2 x float> 
@llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %0, <8 x i8> %1)

`CHECK-NEXT:`


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

https://reviews.llvm.org/D80752



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


[clang] e941921 - [analyzer] Add support for ObjCIndirectCopyRestoreExpr.

2020-06-03 Thread Artem Dergachev via cfe-commits

Author: Paul Pelzl
Date: 2020-06-03T19:06:04+03:00
New Revision: e94192198f8a949c7880620b06e9ef85d87ad4b3

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

LOG: [analyzer] Add support for ObjCIndirectCopyRestoreExpr.

Idiomatic objc using ARC will generate this expression regularly due to
NSError out-param passing.  Providing an implementation for this
expression allows the analyzer to explore many more codepaths in ARC
projects.

The current implementation is not perfect but the differences are hopefully
subtle enough to not cause much problems.

rdar://63918914

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

Added: 
clang/test/Analysis/objc-indirect-copy-restore.m

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 81caf0f47553..265dcd134213 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1210,7 +1210,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 
   switch (S->getStmtClass()) {
 // C++, OpenMP and ARC stuff we don't support yet.
-case Expr::ObjCIndirectCopyRestoreExprClass:
 case Stmt::CXXDependentScopeMemberExprClass:
 case Stmt::CXXTryStmtClass:
 case Stmt::CXXTypeidExprClass:
@@ -1870,6 +1869,21 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
   Bldr.addNodes(Dst);
   break;
 }
+
+case Expr::ObjCIndirectCopyRestoreExprClass: {
+  // ObjCIndirectCopyRestoreExpr implies passing a temporary for
+  // correctness of lifetime management.  Due to limited analysis
+  // of ARC, this is implemented as direct arg passing.
+  Bldr.takeNodes(Pred);
+  ProgramStateRef state = Pred->getState();
+  const auto *OIE = cast(S);
+  const Expr *E = OIE->getSubExpr();
+  SVal V = state->getSVal(E, Pred->getLocationContext());
+  Bldr.generateNode(S, Pred,
+  state->BindExpr(S, Pred->getLocationContext(), V));
+  Bldr.addNodes(Dst);
+  break;
+}
   }
 }
 

diff  --git a/clang/test/Analysis/objc-indirect-copy-restore.m 
b/clang/test/Analysis/objc-indirect-copy-restore.m
new file mode 100644
index ..4881d218f31b
--- /dev/null
+++ b/clang/test/Analysis/objc-indirect-copy-restore.m
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -fobjc-arc 
-analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+
+@protocol NSObject
++ (nonnull instancetype)alloc;
+- (nonnull instancetype)init;
+@end
+@interface NSObject  {}
+@end
+
+@interface NSError : NSObject {
+@public
+  int x;
+}
+@end
+
+
+@interface SomeClass : NSObject
++ (int)doSomethingWithError:(NSError *__autoreleasing *)error;
+@end
+
+@implementation SomeClass
++ (int)doSomethingWithError:(NSError *__autoreleasing *)error {
+if (error) {
+NSError *e = [[NSError alloc] init];
+assert(e);
+e->x = 5;
+*error = e;
+clang_analyzer_eval(*error != 0); // expected-warning{{TRUE}}
+}
+return 0;
+}
+@end
+
+void testStrongOutParam(void) {
+  NSError *error;
+  clang_analyzer_eval(error != 0); // expected-warning{{FALSE}}
+  int ok = [SomeClass doSomethingWithError:];
+  clang_analyzer_eval(ok); // expected-warning{{FALSE}}
+  clang_analyzer_eval(error != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(error->x == 5); // expected-warning{{TRUE}}
+}
+
+void testAutoreleasingOutParam(void) {
+  NSError *__autoreleasing error;
+  clang_analyzer_eval(error != 0); // expected-warning{{FALSE}}
+  int ok = [SomeClass doSomethingWithError:];
+  clang_analyzer_eval(ok); // expected-warning{{FALSE}}
+  clang_analyzer_eval(error != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(error->x == 5); // expected-warning{{TRUE}}
+}
+
+void testNilOutParam(void) {
+int ok = [SomeClass doSomethingWithError:(void *)0];
+clang_analyzer_eval(ok);  // expected-warning{{FALSE}}
+}
+



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


[clang] 7113271 - [analyzer] ObjCAutoreleaseWriteChecker: Support explicit autoreleasepools.

2020-06-03 Thread Artem Dergachev via cfe-commits

Author: Paul Pelzl
Date: 2020-06-03T19:06:04+03:00
New Revision: 7113271528a4c6efc8b57f25ead28f65b5e48757

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

LOG: [analyzer] ObjCAutoreleaseWriteChecker: Support explicit autoreleasepools.

The checker currently supports only a whitelist of block-enumeration
methods which are known to internally clear an autorelease pool.
Extend this checker to detect writes within the scope of explicit
@autoreleasepool statements.

rdar://2530

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
clang/test/Analysis/autoreleasewritechecker_test.m

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
index f36e971bb8ba..7fd6e2abef4c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
@@ -30,6 +30,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "llvm/ADT/Twine.h"
@@ -44,6 +45,7 @@ const char *ProblematicWriteBind = "problematicwrite";
 const char *CapturedBind = "capturedbind";
 const char *ParamBind = "parambind";
 const char *IsMethodBind = "ismethodbind";
+const char *IsARPBind = "isautoreleasepoolbind";
 
 class ObjCAutoreleaseWriteChecker : public Checker {
 public:
@@ -128,21 +130,39 @@ static void emitDiagnostics(BoundNodes , const Decl 
*D, BugReporter ,
   SourceRange Range = MarkedStmt->getSourceRange();
   PathDiagnosticLocation Location = PathDiagnosticLocation::createBegin(
   MarkedStmt, BR.getSourceManager(), ADC);
+
   bool IsMethod = Match.getNodeAs(IsMethodBind) != nullptr;
-  const char *Name = IsMethod ? "method" : "function";
-
-  BR.EmitBasicReport(
-  ADC->getDecl(), Checker,
-  /*Name=*/(llvm::Twine(ActionMsg)
-+ " autoreleasing out parameter inside autorelease 
pool").str(),
-  /*BugCategory=*/"Memory",
-  (llvm::Twine(ActionMsg) + " autoreleasing out parameter " +
-   (IsCapture ? "'" + PVD->getName() + "'" + " " : "") + "inside " +
-   "autorelease pool that may exit before " + Name + " returns; consider "
-   "writing first to a strong local variable declared outside of the 
block")
-  .str(),
-  Location,
-  Range);
+  const char *FunctionDescription = IsMethod ? "method" : "function";
+  bool IsARP = Match.getNodeAs(IsARPBind) != nullptr;
+
+  llvm::SmallString<128> BugNameBuf;
+  llvm::raw_svector_ostream BugName(BugNameBuf);
+  BugName << ActionMsg
+  << " autoreleasing out parameter inside autorelease pool";
+
+  llvm::SmallString<128> BugMessageBuf;
+  llvm::raw_svector_ostream BugMessage(BugMessageBuf);
+  BugMessage << ActionMsg << " autoreleasing out parameter ";
+  if (IsCapture)
+BugMessage << "'" + PVD->getName() + "' ";
+
+  BugMessage << "inside ";
+  if (IsARP)
+BugMessage << "locally-scoped autorelease pool;";
+  else
+BugMessage << "autorelease pool that may exit before "
+   << FunctionDescription << " returns;";
+
+  BugMessage << " consider writing first to a strong local variable"
+" declared outside ";
+  if (IsARP)
+BugMessage << "of the autorelease pool";
+  else
+BugMessage << "of the block";
+
+  BR.EmitBasicReport(ADC->getDecl(), Checker, BugName.str(),
+ categories::MemoryRefCount, BugMessage.str(), Location,
+ Range);
 }
 
 void ObjCAutoreleaseWriteChecker::checkASTCodeBody(const Decl *D,
@@ -188,9 +208,16 @@ void ObjCAutoreleaseWriteChecker::checkASTCodeBody(const 
Decl *D,
WritesOrCapturesInBlockM))
   ));
 
-  auto HasParamAndWritesInMarkedFuncM = allOf(
-  hasAnyParameter(DoublePointerParamM),
-  forEachDescendant(BlockPassedToMarkedFuncM));
+  // WritesIntoM happens inside an explicit @autoreleasepool.
+  auto WritesOrCapturesInPoolM =
+  autoreleasePoolStmt(
+  forEachDescendant(stmt(anyOf(WritesIntoM, CapturedInParamM
+  .bind(IsARPBind);
+
+  auto HasParamAndWritesInMarkedFuncM =
+  allOf(hasAnyParameter(DoublePointerParamM),
+anyOf(forEachDescendant(BlockPassedToMarkedFuncM),
+  forEachDescendant(WritesOrCapturesInPoolM)));
 
   auto MatcherM = decl(anyOf(
   objcMethodDecl(HasParamAndWritesInMarkedFuncM).bind(IsMethodBind),


[PATCH] D81061: [Analyzer][VLASizeChecker] Fix problem with zero index assumption.

2020-06-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 268216.
balazske added a comment.

Improved assumption on array size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81061

Files:
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/test/Analysis/vla.c


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * 
sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// Analyzer doesn't handle more than simple symbolic expressions correct.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -122,11 +122,19 @@
   return State;
 
 if (const llvm::APSInt *IndexLVal = SVB.getKnownValue(State, IndexLength)) 
{
+  uint64_t IndexL = IndexLVal->getZExtValue();
+  if (IndexL == 0) {
+// Despite the previous assumption for positive size,
+// this value might be non-positive (probably caused by other bugs).
+// At least check for zero again.
+// Assume that this is a more exact fact than the previous assumptions
+// (in checkVLAIndexSize), so report error too.
+reportBug(VLA_Zero, SizeE, State, C);
+return nullptr;
+  }
   // Check if the array size will overflow.
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
-  uint64_t IndexL = IndexLVal->getZExtValue();
-  assert(IndexL > 0 && "Index length should have been checked for zero.");
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
   } else {
@@ -166,35 +174,21 @@
 return nullptr;
   }
 
-  // Check if the size is zero.
+  QualType SizeTy = SizeE->getType();
   DefinedSVal SizeD = SizeV.castAs();
-
-  ProgramStateRef StateNotZero, StateZero;
-  std::tie(StateNotZero, StateZero) = State->assume(SizeD);
-
-  if (StateZero && !StateNotZero) {
-reportBug(VLA_Zero, SizeE, StateZero, C);
-return nullptr;
-  }
-
-  // From this point on, assume that the size is not zero.
-  State = StateNotZero;
-
-  // Check if the size is negative.
   SValBuilder  = C.getSValBuilder();
-
-  QualType SizeTy = SizeE->getType();
   DefinedOrUnknownSVal Zero = SVB.makeZeroVal(SizeTy);
 
-  SVal LessThanZeroVal = SVB.evalBinOp(State, BO_LT, SizeD, Zero, SizeTy);
-  if (Optional LessThanZeroDVal =
-  LessThanZeroVal.getAs()) {
-ConstraintManager  = C.getConstraintManager();
-ProgramStateRef StatePos, StateNeg;
+  // Check if the size is zero or negative.
+  SVal PositiveVal = SVB.evalBinOp(State, BO_GT, SizeD, Zero, SizeTy);
+  if (Optional PositiveDVal = PositiveVal.getAs()) {
+ProgramStateRef StatePos, StateNotPos;
 
-std::tie(StateNeg, StatePos) = CM.assumeDual(State, *LessThanZeroDVal);
-if (StateNeg && !StatePos) {
-  reportBug(VLA_Negative, SizeE, State, C);
+std::tie(StatePos, StateNotPos) = State->assume(*PositiveDVal);
+if (StateNotPos && !StatePos) {
+  ConditionTruthVal IsZeroSize = StateNotPos->isNull(SizeD);
+  reportBug(IsZeroSize.isConstrainedTrue() ? VLA_Zero : VLA_Negative, 
SizeE,
+State, C);
   return nullptr;
 }
 State = StatePos;


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// Analyzer doesn't handle more than simple symbolic expressions correct.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -122,11 +122,19 @@
   return State;
 
 if (const llvm::APSInt *IndexLVal = SVB.getKnownValue(State, IndexLength)) {
+  uint64_t IndexL = IndexLVal->getZExtValue();
+  if (IndexL == 0) {
+// Despite the previous assumption for positive size,
+// this value might be non-positive (probably caused by other bugs).
+// At least check for 

[PATCH] D81041: Use existing path sep style in clang::FileManager::FixupRelativePath

2020-06-03 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

Please make sure all of the clang VFS tests still pass before submitted this.  
VFS paths are inherently problematic with `llvm::sys::path` because they can 
legitimately be in a hybrid of Windows and Posix styles.  Guessing the style 
from the first separator you see can be misleading, but I don't know whether 
that's ever wrong in this path.

Exactly which assertion is firing?  Is it possible it's the assertion that's 
wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81041



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 268219.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730

Files:
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer
+// 96 = 0x60 = OMP_MAP_TARGET_PARAM | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 96, i64 96, i64 96, i64 96, i64 96]
+// 32 = 0x20 = OMP_MAP_TARGET_PARAM
+// 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 32, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720]
+struct S {
+  int a = 0;
+  int *ptr= 
+  int  = a;
+  int arr[4];
+  S() {}
+  void foo() {
+#pragma omp target data use_device_addr(a, ptr[3:4], ref, ptr[0], arr[:a])
+  ++a, ++*ptr, ++ref, ++arr[0];
+  }
+};
+
+int main() {
+  float a = 0;
+  float *ptr= 
+  float  = a;
+  float arr[4];
+  float vla[(int)a];
+  S s;
+  s.foo();
+#pragma omp target data use_device_addr(a, ptr[3:4], ref, ptr[0], arr[:(int)a], vla[0])
+  ++a, ++*ptr, ++ref, ++arr[0], ++vla[0];
+  return a;
+}
+
+// CHECK-LABEL: @main()
+// CHECK: [[A_ADDR:%.+]] = alloca float,
+// CHECK: [[PTR_ADDR:%.+]] = alloca float*,
+// CHECK: [[REF_ADDR:%.+]] = alloca float*,
+// CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float],
+// CHECK: [[BPTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[PTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}},
+// CHECK: [[PTR:%.+]] = load float*, float** [[PTR_ADDR]],
+// CHECK: [[REF:%.+]] = load float*, float** [[REF_ADDR]],
+// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[ARR_ADDR]], i64 0, i64 0
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 0
+// CHECK: [[BPTR0_A_ADDR:%.+]] = bitcast i8** [[BPTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[BPTR0_A_ADDR]],
+// CHECK: [[PTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 0
+// CHECK: [[PTR0_A_ADDR:%.+]] = bitcast i8** [[PTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[PTR0_A_ADDR]],
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 1
+// CHECK: [[BPTR1_PTR_ADDR:%.+]] = bitcast i8** [[BPTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[BPTR1_PTR_ADDR]],
+// CHECK: [[PTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 1
+// CHECK: [[PTR1_PTR_ADDR:%.+]] = bitcast i8** [[PTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[PTR1_PTR_ADDR]],
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 2
+// CHECK: [[BPTR2_REF_ADDR:%.+]] = bitcast i8** [[BPTR2]] to float**
+// CHECK: store float* [[REF]], float** [[BPTR2_REF_ADDR]],
+// CHECK: [[PTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 2
+// CHECK: [[PTR2_REF_ADDR:%.+]] = bitcast i8** [[PTR2]] to float**
+// CHECK: store float* [[REF]], float** [[PTR2_REF_ADDR]],
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [5 x i8*], [5 x 

[PATCH] D81061: [Analyzer][VLASizeChecker] Fix problem with zero index assumption.

2020-06-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:127-129
+// Despite the previous assumptions for non-zero and positiveness,
+// this value might be zero or negative.
+// At least check for zero again.

NoQ wrote:
> If we aim for a better fix, can we reduce the number of assumptions we make 
> from 2 to 1? Like, it's ok if it's imperfect; 1 imperfect assumption is 
> better than 2 imperfect assumptions.
> 
> The mental model i'm following here is that every path-sensitive bug can be 
> thought of as a single formula over symbolic expressions. Eg., division by 
> zero is the formula `"$denominator == 0" is definitely true`, double close is 
> `"is_closed($file_being_closed)"`, division by tainted value is 
> `"$denominator == 0" is possibly true AND "is_tainted($denominator)"`. I'd 
> like you to write down the single formula that represents your bug and 
> perform a single assume() over that and use the result of such assume as an 
> ultimate source of truth. If such assume is not working correctly, let's 
> think how to fix the assume rather than pile up more assumes in every checker 
> to manually cross-check each other.
Based on this the assumptions could be really simplified. Now the check is made 
only for positive array size.
One question is if it is good to leave the assert here. This condition shows 
internal inconsistency, it may be better to abort the checker instead of making 
probably bad state changes (in the bad case array extent was changed to a 
nonzero but probably negative value range).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81061



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-03 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In D80833#2069874 , @thakis wrote:

> The change description says something about PWD


I believe that was a typo for CWD.

> Please don't add code that stores absolute paths, but at the moment this 
> doesn't do that as far as I can tell :)

Ah, but the summary suggests that it is:

> The LF_BUILDINFO therefore stores a full path to the compiler

From what I see, it's storing Args[0], which is usually the program name as 
specified on the command line.  If a build system is using full paths in the 
commands, I think they will be stored.




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:8
+// CHECK: 
+// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
+// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]

PWD?  Did you mean CWD (current working directory)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


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

2020-06-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske abandoned this revision.
balazske added a comment.

Yes, closing it. (Will change `StreamErrorState` probably to bitfield later.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


  1   2   3   >