Re: [PATCH] D74384: Use std::foo_t rather than std::foo in LLVM.

2020-02-10 Thread Kadir Çetinkaya via cfe-commits
> I joined the group; what do I do to get tests run for this?

you need to upload a diff to trigger the bots


> > Hope someone can verify the build on Windows.
> Do you think I should go on IRC and ask?

Not much help before committing, but for post-commit there is
http://45.33.8.238/.
Doesn't contain all different configurations but they are fast, so you can
revert swiftly at leat

On Tue, Feb 11, 2020 at 8:25 AM Justin Lebar via Phabricator <
revi...@reviews.llvm.org> wrote:

> jlebar added a comment.
>
> > Such changes can be risky.
>
> Heh, well said.  I feel good about it because I found two or three real
> bugs in clang/llvm as a result of this cleanup.  But still, we've got to
> land it safely...
>
> I joined the group; what do I do to get tests run for this?
>
> > Hope someone can verify the build on Windows.
>
> Do you think I should go on IRC and ask?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D74384/new/
>
> https://reviews.llvm.org/D74384
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73842: [xray][clang] Always add xray-skip-entry/exit and xray-ignore-loops attrs

2020-02-10 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque updated this revision to Diff 243749.
ianlevesque added a comment.

Now with 100% more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73842

Files:
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp
  clang/test/CodeGen/xray-ignore-loops.cpp
  clang/test/Driver/XRay/xray-ignore-loops-flags.cpp

Index: clang/test/Driver/XRay/xray-ignore-loops-flags.cpp
===
--- /dev/null
+++ clang/test/Driver/XRay/xray-ignore-loops-flags.cpp
@@ -0,0 +1,10 @@
+// This test ensures that when we invoke the clang compiler, that the -cc1
+// options include the -fxray-ignore-loops flag we provide in the
+// invocation.
+//
+// RUN: %clang -fxray-instrument -fxray-ignore-loops -target x86_64-linux- -### \
+// RUN: -x c++ -std=c++11 -emit-llvm -c -o - %s 2>&1 \
+// RUN: | FileCheck %s
+// CHECK:  -fxray-ignore-loops
+//
+// REQUIRES: x86_64 || x86_64h
\ No newline at end of file
Index: clang/test/CodeGen/xray-ignore-loops.cpp
===
--- clang/test/CodeGen/xray-ignore-loops.cpp
+++ clang/test/CodeGen/xray-ignore-loops.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fxray-instrument -fxray-ignore-loops -x c++ -std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang -fxray-instrument -fxray-ignore-loops -x c++ -std=c++11 -S -emit-llvm -o - %s -target x86_64-unknown-linux-gnu | FileCheck %s
 
 int foo() {
   return 1;
 }
 
-// CHECK: define i32 @_Z3foov() #[[ATTRS:[0-9]+]] {
+// CHECK: define{{.*}} i32 @_Z3foov() #[[ATTRS:[0-9]+]] {
 // CHECK-DAG: attributes #[[ATTRS]] = {{.*}} "xray-ignore-loops" {{.*}}
Index: clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fxray-instrument \
+// RUN: -fxray-instrumentation-bundle=function-entry -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,NOCUSTOM,NOTYPED,SKIPEXIT %s
+// RUN: %clang_cc1 -fxray-instrument \
+// RUN: -fxray-instrumentation-bundle=function-exit -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,NOCUSTOM,NOTYPED,SKIPENTRY %s
+// RUN: %clang_cc1 -fxray-instrument \
+// RUN: -fxray-instrumentation-bundle=function-entry,function-exit -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,FUNCTION,NOCUSTOM,NOTYPED %s
+
+// CHECK: define void @_Z13justAFunctionv() #[[ATTR:[0-9]+]] {
+void justAFunction() {
+}
+
+// SKIPENTRY: attributes #[[ATTR]] = {{.*}} "xray-skip-entry" {{.*}}
+// SKIPEXIT: attributes #[[ATTR]] = {{.*}} "xray-skip-exit" {{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1099,8 +1099,7 @@
   Args.hasArg(OPT_fxray_always_emit_typedevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
-  Opts.XRayIgnoreLoops =
-  Args.hasArg(OPT_fxray_ignore_loops, OPT_fno_xray_ignore_loops, false);
+  Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops);
 
   auto XRayInstrBundles =
   Args.getAllArgValues(OPT_fxray_instrumentation_bundle);
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -101,6 +101,10 @@
 options::OPT_fnoxray_link_deps, true))
 XRayRT = false;
 
+  if (Args.hasFlag(options::OPT_fxray_ignore_loops,
+   options::OPT_fno_xray_ignore_loops, false))
+XRayIgnoreLoops = true;
+
   auto Bundles =
   Args.getAllArgValues(options::OPT_fxray_instrumentation_bundle);
   if (Bundles.empty())
@@ -197,6 +201,9 @@
   if (XRayAlwaysEmitTypedEvents)
 CmdArgs.push_back("-fxray-always-emit-typedevents");
 
+  if (XRayIgnoreLoops)
+CmdArgs.push_back("-fxray-ignore-loops");
+
   CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
Twine(InstructionThreshold)));
 
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -814,23 +814,25 @@
   if (ShouldXRayInstrumentFunction())
 

[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

2020-02-10 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:114
+
+// Add some known attributes to the outlined function.
+Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);

This comment seems misplaced now.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:654-655
+Instruction *PreFiniTI = PRegPreFiniBB->getTerminator();
+OuterFn->dump();
+PreFiniTI->dump();
+assert(PreFiniTI->getNumSuccessors() == 1 &&

I think you forgot to wrap these in a `LLVM_DEBUG`



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:663
 
-  return AfterIP;
+InsertPointTy ExitIP(UI->getParent(), UI->getParent()->end());
+UI->eraseFromParent();

This used to be called `AfterIP`. Probably the exact name is not that important 
but the unit tests still use `AfterIP` so I'd suggest to keep both names in 
sync.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74372



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


[PATCH] D74384: Use std::foo_t rather than std::foo in LLVM.

2020-02-10 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> Such changes can be risky.

Heh, well said.  I feel good about it because I found two or three real bugs in 
clang/llvm as a result of this cleanup.  But still, we've got to land it 
safely...

I joined the group; what do I do to get tests run for this?

> Hope someone can verify the build on Windows.

Do you think I should go on IRC and ask?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74384



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


[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-02-10 Thread Huihui Zhang via Phabricator via cfe-commits
huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, apazos, spatel, huntergr, 
willlovett.
huihuiz added a project: LLVM.
Herald added subscribers: cfe-commits, psnobl, rkruppe, hiraditya, tschuett.
Herald added a project: clang.

Support ConstantInt::get() and Constant::getAllOnesValue() for scalable
vector type, this requires ConstantVector::getSplat() to take in 'ElementCount',
instead of 'unsigned' number of element count.

This change is needed for D73753 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74386

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Analysis/Utils/Local.h
  llvm/include/llvm/IR/Constants.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/FuzzMutate/OperationsTest.cpp
  llvm/unittests/IR/VerifierTest.cpp

Index: llvm/unittests/IR/VerifierTest.cpp
===
--- llvm/unittests/IR/VerifierTest.cpp
+++ llvm/unittests/IR/VerifierTest.cpp
@@ -57,7 +57,7 @@
   ConstantInt *CI = ConstantInt::get(ITy, 0);
 
   // Valid type : freeze(<2 x i32>)
-  Constant *CV = ConstantVector::getSplat(2, CI);
+  Constant *CV = ConstantVector::getSplat({2, false}, CI);
   FreezeInst *FI_vec = new FreezeInst(CV);
   FI_vec->insertBefore(RI);
 
Index: llvm/unittests/FuzzMutate/OperationsTest.cpp
===
--- llvm/unittests/FuzzMutate/OperationsTest.cpp
+++ llvm/unittests/FuzzMutate/OperationsTest.cpp
@@ -92,8 +92,8 @@
   ConstantStruct::get(StructType::create(Ctx, "OpaqueStruct"));
   Constant *a =
   ConstantArray::get(ArrayType::get(i32->getType(), 2), {i32, i32});
-  Constant *v8i8 = ConstantVector::getSplat(8, i8);
-  Constant *v4f16 = ConstantVector::getSplat(4, f16);
+  Constant *v8i8 = ConstantVector::getSplat({8, false}, i8);
+  Constant *v4f16 = ConstantVector::getSplat({4, false}, f16);
   Constant *p0i32 =
   ConstantPointerNull::get(PointerType::get(i32->getType(), 0));
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1726,9 +1726,10 @@
   // FIXME: If the step is non-constant, we create the vector splat with
   //IRBuilder. IRBuilder can constant-fold the multiply, but it doesn't
   //handle a constant vector splat.
-  Value *SplatVF = isa(Mul)
-   ? ConstantVector::getSplat(VF, cast(Mul))
-   : Builder.CreateVectorSplat(VF, Mul);
+  Value *SplatVF =
+  isa(Mul)
+  ? ConstantVector::getSplat({VF, false}, cast(Mul))
+  : Builder.CreateVectorSplat(VF, Mul);
   Builder.restoreIP(CurrIP);
 
   // We may need to add the step a number of times, depending on the unroll
@@ -3738,7 +3739,7 @@
   // incoming scalar reduction.
   VectorStart = ReductionStartValue;
 } else {
-  Identity = ConstantVector::getSplat(VF, Iden);
+  Identity = ConstantVector::getSplat({VF, false}, Iden);
 
   // This vector is the Identity vector where the first element is the
   // incoming scalar reduction.
Index: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -761,7 +761,7 @@
   APInt Bits = APInt::getHighBitsSet(TypeBits, TypeBits - Op1Val);
   Constant *Mask = ConstantInt::get(I.getContext(), Bits);
   if (VectorType *VT = dyn_cast(X->getType()))
-Mask = ConstantVector::getSplat(VT->getNumElements(), Mask);
+Mask = ConstantVector::getSplat(VT->getElementCount(), Mask);
   return BinaryOperator::CreateAnd(X, Mask);
 }
 
@@ -796,7 +796,7 @@
   APInt Bits = APInt::getHighBitsSet(TypeBits, TypeBits - Op1Val);
   Constant *Mask = ConstantInt::get(I.getContext(), Bits);
   if (VectorType *VT = dyn_cast(X->getType()))
-Mask = ConstantVector::getSplat(VT->getNumElements(), Mask);
+Mask = ConstantVector::getSplat(VT->getElementCount(), Mask);
   return BinaryOperator::CreateAnd(X, Mask);
 }
 
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -5365,8 +5365,10 @@
   if (ScalarC && ScalarM) {
 // We allow undefs in matching, but this transform 

[clang] 42ca012 - remove outdated comparison with other open-source c++ compilers

2020-02-10 Thread John Regehr via cfe-commits

Author: John Regehr
Date: 2020-02-11T00:05:16-07:00
New Revision: 42ca012befa546d6cddde2155242ca85e155eda4

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

LOG: remove outdated comparison with other open-source c++ compilers

Added: 


Modified: 
clang/www/features.html
clang/www/index.html
clang/www/menu.html.incl

Removed: 
clang/www/comparison.html



diff  --git a/clang/www/comparison.html b/clang/www/comparison.html
deleted file mode 100755
index 876179c7dec3..
--- a/clang/www/comparison.html
+++ /dev/null
@@ -1,190 +0,0 @@
-http://www.w3.org/TR/html4/strict.dtd;>
-
-
-
-  
-  Comparing Clang to other open source compilers
-  
-  
-
-
-  
-  
-Clang vs Other Open Source Compilers
-
-Building an entirely new compiler front-end is a big task, and it isn't
-   always clear to people why we decided to do this.  Here we compare Clang
-   and its goals to other open source compiler front-ends that are
-   available.  We restrict the discussion to very specific objective points
-   to avoid controversy where possible.  Also, software is infinitely
-   mutable, so we don't talk about little details that can be fixed with
-   a reasonable amount of effort: we'll talk about issues that are
-   
diff icult to fix for architectural or political reasons.
-
-The goal of this list is to describe how 
diff erences in goals lead to
-   
diff erent strengths and weaknesses, not to make some compiler look bad.
-   This will hopefully help you to evaluate whether using Clang is a good
-   idea for your personal goals.  Because we don't know specifically what
-   you want to do, we describe the features of these compilers in
-   terms of our goals: if you are only interested in static
-   analysis, you may not care that something lacks codegen support, for
-   example.
-
-Please email cfe-dev if you think we 
should add another compiler to this
-   list or if you think some characterization is unfair here.
-
-
-Clang vs GCC (GNU Compiler Collection)
-Clang vs Elsa (Elkhound-based C++ Parser)
-Clang vs PCC (Portable C Compiler)
-
-
-
-

-Clang vs GCC (GNU Compiler Collection)
-

-
-Pro's of GCC vs Clang:
-
-
-GCC supports languages that Clang does not aim to, such as Java, Ada,
-FORTRAN, Go, etc.
-GCC supports more targets than LLVM.
-GCC supports many language extensions, some of which are not 
implemented
-by Clang. For instance, in C mode, GCC supports
-https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html;>nested
-functions and has an
-https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html;>extension
-allowing VLAs in structs.
-
-
-Pro's of Clang vs GCC:
-
-
-The Clang ASTs and design are intended to be easily understandable by
-anyone who is familiar with the languages involved and who has a basic
-understanding of how a compiler works.  GCC has a very old codebase
-which presents a steep learning curve to new developers.
-Clang is designed as an API from its inception, allowing it to be 
reused
-by source analysis tools, refactoring, IDEs (etc) as well as for code
-generation.  GCC is built as a monolithic static compiler, which makes
-it extremely 
diff icult to use as an API and integrate into other tools.
-Further, its historic design and https://gcc.gnu.org/ml/gcc/2007-11/msg00460.html;>current
-https://gcc.gnu.org/ml/gcc/2004-12/msg00888.html;>policy
-makes it 
diff icult to decouple the front-end from the rest of the
-compiler. 
-Various GCC design decisions make it very 
diff icult to reuse: its build
-system is 
diff icult to modify, you can't link multiple targets into one
-binary, you can't link multiple front-ends into one binary, it uses a
-custom garbage collector, uses global variables extensively, is not
-reentrant or multi-threadable, etc.  Clang has none of these problems.
-
-Clang does not implicitly simplify code as it parses it like GCC does.
-Doing so causes many problems for source analysis tools: as one simple
-example, if you write "x-x" in your source code, the GCC AST will
-contain "0", with no mention of 'x'.  This is extremely bad for a
-refactoring tool that wants to rename 'x'.
-Clang can serialize its AST out to disk and read it back into another
-program, which is useful for whole program analysis.  GCC does not have
-this.  GCC's PCH mechanism (which is just a dump of the compiler
-memory image) is related, but is architecturally only
-able to read the dump back 

[PATCH] D74385: [ARCMT][NFC] Reduce #include dependencies

2020-02-10 Thread Nicolás Alvarez via Phabricator via cfe-commits
nicolas17 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Replace some #includes in ARCMigrate source files with more specific includes 
and forward declarations. This reduces the number of files that need to be 
rebuilt when a header changes (and saves like 1 second of build time). For 
example, several files no longer need to be rebuilt when the list of static 
analyzer checkers(!) changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74385

Files:
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/ARCMigrate/Internals.h
  clang/lib/ARCMigrate/Transforms.cpp


Index: clang/lib/ARCMigrate/Transforms.cpp
===
--- clang/lib/ARCMigrate/Transforms.cpp
+++ clang/lib/ARCMigrate/Transforms.cpp
@@ -8,6 +8,7 @@
 
 #include "Transforms.h"
 #include "Internals.h"
+#include "clang/ARCMigrate/ARCMT.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Analysis/DomainSpecific/CocoaConventions.h"
Index: clang/lib/ARCMigrate/Internals.h
===
--- clang/lib/ARCMigrate/Internals.h
+++ clang/lib/ARCMigrate/Internals.h
@@ -9,13 +9,15 @@
 #ifndef LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
 #define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
 
-#include "clang/ARCMigrate/ARCMT.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Frontend/MigratorOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include 
 
 namespace clang {
+  class ASTContext;
   class Sema;
   class Stmt;
 
Index: clang/lib/ARCMigrate/ARCMT.cpp
===
--- clang/lib/ARCMigrate/ARCMT.cpp
+++ clang/lib/ARCMigrate/ARCMT.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Internals.h"
+#include "clang/ARCMigrate/ARCMT.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Frontend/ASTUnit.h"


Index: clang/lib/ARCMigrate/Transforms.cpp
===
--- clang/lib/ARCMigrate/Transforms.cpp
+++ clang/lib/ARCMigrate/Transforms.cpp
@@ -8,6 +8,7 @@
 
 #include "Transforms.h"
 #include "Internals.h"
+#include "clang/ARCMigrate/ARCMT.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Analysis/DomainSpecific/CocoaConventions.h"
Index: clang/lib/ARCMigrate/Internals.h
===
--- clang/lib/ARCMigrate/Internals.h
+++ clang/lib/ARCMigrate/Internals.h
@@ -9,13 +9,15 @@
 #ifndef LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
 #define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
 
-#include "clang/ARCMigrate/ARCMT.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Frontend/MigratorOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include 
 
 namespace clang {
+  class ASTContext;
   class Sema;
   class Stmt;
 
Index: clang/lib/ARCMigrate/ARCMT.cpp
===
--- clang/lib/ARCMigrate/ARCMT.cpp
+++ clang/lib/ARCMigrate/ARCMT.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Internals.h"
+#include "clang/ARCMigrate/ARCMT.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Frontend/ASTUnit.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74384: Use std::foo_t rather than std::foo in LLVM.

2020-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

You may join https://reviews.llvm.org/project/view/78/ and let the bot test 
Linux for you..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74384



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


[PATCH] D74384: Use std::foo_t rather than std::foo in LLVM.

2020-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Such changes can be risky. Hope someone can verify the build on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74384



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D71600#1868284 , @efriedma wrote:

> On master, atomic.c is not built by default.  It's only built if you 
> explicitly request it with something like the CMake flag 
> -DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=Off .  If you're not doing that, any 
> change to atomic.c has no effect.


I see. In FreeBSD src/base, LLVM isn't using the standard cmake scripts, so we 
explicitly add atomic.c to the build, we don't set this flag (I did this: 
https://reviews.freebsd.org/D22549#change-3IJWKySKm5fg). However it's a good 
point, we must check if COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN is used for 
something else, and we should probably add the flag when building ports 
packages (devel/llvm*).  Thank you for pointing that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D71600#1867320 , @adalava wrote:

> > For compiler-rt, are you really disabling 
> > COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN?  Are you sure you understand the 
> > implications of that?
>
> I didn't  understood "disable COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN", it's not 
> intentional. 
>  If it's the change around atomic.c:131, what I expect is make IS_LOCK_FREE_8 
> return false. I don't want it to make to __c11_atomic_is_lock_free(8) as it 
> generates code that should be linked with a libatomic at run time.


On master, atomic.c is not built by default.  It's only built if you explicitly 
request it with something like the CMake flag 
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=Off .  If you're not doing that, any 
change to atomic.c has no effect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

atomic.c is disabled by default for a good reason: it doesn't work correctly in 
general.  In particular, if an atomic variable is shared across two shared 
libraries, the two libraries will use different locks, and therefore the 
operation won't be atomic.

It might make sense to provide a shared library compiler-rt-atomic or something 
like that for targets that want it, but someone would have to implement it.  
(Or maybe on ELF targets we could make the symbols unique by messing with the 
linkage... but that might cause other issues.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[PATCH] D73865: [CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition

2020-02-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

What is the motivation for adding a best effort `-fsemantic-interposition`? Was 
there anything wrong with our previously unstated project policy of ignoring 
this complexity and surviving without this mode? Less modes -> less conditional 
soup...




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:852
 
   // A definition cannot be preempted from an executable.
   if (!GV->isDeclarationForLinker())

We now come here for shared objects in most cases: most definitions are assumed 
to be dso_local and most declarations are assumed to be in another DSO. Please 
update the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73865



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


[PATCH] D73865: [CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition

2020-02-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.
Herald added a subscriber: miyuki.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:871
 if (!Var->isThreadLocal() &&
-(RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
+(RM == llvm::Reloc::Static || (LOpts.PIE && 
CGOpts.PIECopyRelocations)))
   return true;

in `clang/lib/Driver/ToolChains/Clang.cpp` we have

```
  if (Args.hasFlag(options::OPT_fsemantic_interposition,
   options::OPT_fno_semantic_interposition, false) &&
  RelocationModel != llvm::Reloc::Static && !IsPIE)
CmdArgs.push_back("-fsemantic-interposition");
```

reading that diff makes me wonder if that's the right place to put that test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73865



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> In D68049#1865967 , @MaskRay wrote:
>  If you don't mind, I can push a Diff to this Differential which will address 
> these review comments.

I can't because I can't figure out the patch relationship...

First, this patch does not build on its own. I try applying D68063 
 first, then this patch. It still does not 
compile..

  clang/lib/CodeGen/BackendUtil.cpp:484:11: error: no member named 'propeller' 
in namespace 'llvm'
  llvm::propeller::getBBSectionsList(CodeGenOpts.BBSections,

Chatted with shenhan and xur offline. I tend to agree that 
-fbasicblock-sections=label can improve profile accuracy. It'd be nice to make 
that feature separate,
even if there is still a debate on whether the rest of Propeller is done in a 
maintainable way.

I think the patch series should probably be structured this way:

1. LLVM CodeGen: enables basic block sections.
2. clang Driver/Frontend/CodeGen: pass basic block sections options to LLVM.

3. LLVM CodeGen: which enables the rest of Propeller options.
4. lld: a file similar to lld/ELF/LTO.cpp . It should be a thin wrapper of 
Propeller features. It should not do hacky diassembly tasks.
5. clang Driver/Frontend/CodeGen: passes compiler/linker options to 3 and 4

Making 1 and 2 separate can help move forward the patch series. 1 and 2 should 
not reference `llvm::propeller`.


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

https://reviews.llvm.org/D68049



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


[PATCH] D72241: [clang-tidy] new altera single work item barrier check

2020-02-10 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 243717.
ffrankies marked 3 inline comments as done.
ffrankies added a comment.

Implemented requested changes by @Eugene.Zelenko

- Changed `auto` to `const auto *`
- Changed `if(IsNDRange == true)` to `if(IsNDRange)`
- Highlighted 1600 with single back-quotes
- Added link to https://reviews.llvm.org/D66564 as a dependency in Summary (is 
there someplace else I can refer to that as a dependency?)


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

https://reviews.llvm.org/D72241

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/altera/AlteraTidyModule.cpp
  clang-tidy/altera/CMakeLists.txt
  clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
  clang-tidy/altera/SingleWorkItemBarrierCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/altera-single-work-item-barrier.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/checkers/altera-single-work-item-barrier.cpp

Index: test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
===
--- /dev/null
+++ test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
@@ -0,0 +1,294 @@
+// RUN: %check_clang_tidy -check-suffix=OLD %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLD
+// RUN: %check_clang_tidy -check-suffix=NEW %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEW
+// RUN: %check_clang_tidy -check-suffix=AOCOLD %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DAOCOLD
+// RUN: %check_clang_tidy -check-suffix=AOCNEW %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DAOCNEW
+
+#ifdef OLD
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-OLD: :[[@LINE-7]]:15: warning: Kernel function 'error_barrier_no_id' does not call get_global_id or get_local_id and will be treated as single-work-item.{{[[:space:]]}}Barrier call at {{(\/)?([^\/\0]+(\/)?)+}}:[[@LINE-1]]:3 may error out [altera-single-work-item-barrier]
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void __kernel success_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+
+void success_nokernel_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void success_nokernel_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void success_nokernel_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void success_nokernel_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+#endif
+
+#ifdef NEW
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-NEW: :[[@LINE-7]]:15: warning: Kernel function 'error_barrier_no_id' does not call get_global_id or get_local_id and will be treated as single-work-item.{{[[:space:]]}}Barrier call at {{(\/)?([^\/\0]+(\/)?)+}}:[[@LINE-1]]:3 may error out [altera-single-work-item-barrier]
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void __kernel success_barrier_both_ids(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+
+void success_nokernel_barrier_no_id(__global int * foo, int size) {
+  for (int j 

[PATCH] D74374: [clang-tidy] Added check to disable bugprone-infinite-loop on known false condition

2020-02-10 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 edited the summary of this revision.
njames93 added reviewers: aaron.ballman, alexfh, hokein, gribozavr2, JonasToth.
njames93 added a project: clang-tools-extra.

Addresses bugprone-infinite-loop false positive with CATCH2 
 by disabling the check on loops 
where the condition is known to always eval as false, in other words not a loop.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74374

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -354,3 +354,12 @@
 (*p)++;
   } while (i < Limit);
 }
+
+void evaluatable(bool CondVar) {
+  for (; false && CondVar;) {
+  }
+  while (false && CondVar) {
+  }
+  do {
+  } while (false && CondVar);
+}
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -152,6 +152,13 @@
   return Result;
 }
 
+static bool isKnownFalse(const Expr , const ASTContext ) {
+  bool Result = false;
+  if (Cond.EvaluateAsBooleanCondition(Result, Ctx))
+return !Result;
+  return false;
+}
+
 void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
   const auto LoopCondition = allOf(
   hasCondition(
@@ -170,6 +177,9 @@
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
+  if (isKnownFalse(*Cond, *Result.Context))
+return;
+
   bool ShouldHaveConditionVariables = true;
   if (const auto *While = dyn_cast(LoopStmt)) {
 if (const VarDecl *LoopVarDecl = While->getConditionVariable()) {


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -354,3 +354,12 @@
 (*p)++;
   } while (i < Limit);
 }
+
+void evaluatable(bool CondVar) {
+  for (; false && CondVar;) {
+  }
+  while (false && CondVar) {
+  }
+  do {
+  } while (false && CondVar);
+}
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -152,6 +152,13 @@
   return Result;
 }
 
+static bool isKnownFalse(const Expr , const ASTContext ) {
+  bool Result = false;
+  if (Cond.EvaluateAsBooleanCondition(Result, Ctx))
+return !Result;
+  return false;
+}
+
 void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
   const auto LoopCondition = allOf(
   hasCondition(
@@ -170,6 +177,9 @@
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
+  if (isKnownFalse(*Cond, *Result.Context))
+return;
+
   bool ShouldHaveConditionVariables = true;
   if (const auto *While = dyn_cast(LoopStmt)) {
 if (const VarDecl *LoopVarDecl = While->getConditionVariable()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

2020-02-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: rogfer01, ABataev, JonChesterfield, 
kiranchandramohan, fghanim.
Herald added subscribers: cfe-commits, guansong, bollu, hiraditya.
Herald added projects: clang, LLVM.

In order to fix PR44560 and to prepare for loop transformations we now
finalize a function late, which will also do the outlining late. The
logic is as before but the actual outlining step happens now after the
function was fully constructed. Once we have loop transformations we
can apply them in the finalize step before the outlining.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74372

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -96,7 +96,7 @@
   EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
 
   Builder.CreateUnreachable();
-  EXPECT_FALSE(verifyModule(*M));
+  EXPECT_FALSE(verifyModule(*M, ()));
 }
 
 TEST_F(OpenMPIRBuilderTest, CreateCancel) {
@@ -151,7 +151,7 @@
   OMPBuilder.popFinalizationCB();
 
   Builder.CreateUnreachable();
-  EXPECT_FALSE(verifyModule(*M));
+  EXPECT_FALSE(verifyModule(*M, ()));
 }
 
 TEST_F(OpenMPIRBuilderTest, CreateCancelIfCond) {
@@ -212,7 +212,7 @@
   OMPBuilder.popFinalizationCB();
 
   Builder.CreateUnreachable();
-  EXPECT_FALSE(verifyModule(*M));
+  EXPECT_FALSE(verifyModule(*M, ()));
 }
 
 TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) {
@@ -267,7 +267,7 @@
   OMPBuilder.popFinalizationCB();
 
   Builder.CreateUnreachable();
-  EXPECT_FALSE(verifyModule(*M));
+  EXPECT_FALSE(verifyModule(*M, ()));
 }
 
 TEST_F(OpenMPIRBuilderTest, DbgLoc) {
@@ -362,9 +362,9 @@
 
   auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
 
-  IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
-  Loc, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr, OMP_PROC_BIND_default, false);
-
+  IRBuilder<>::InsertPoint AfterIP =
+  OMPBuilder.CreateParallel(Loc, BodyGenCB, PrivCB, FiniCB, nullptr,
+nullptr, OMP_PROC_BIND_default, false);
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 1U);
   EXPECT_EQ(NumFinalizationPoints, 1U);
@@ -372,10 +372,12 @@
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
 
+  OMPBuilder.finalize();
+
   EXPECT_NE(PrivAI, nullptr);
   Function *OutlinedFn = PrivAI->getFunction();
   EXPECT_NE(F, OutlinedFn);
-  EXPECT_FALSE(verifyModule(*M));
+  EXPECT_FALSE(verifyModule(*M, ()));
   EXPECT_TRUE(OutlinedFn->hasFnAttribute(Attribute::NoUnwind));
   EXPECT_TRUE(OutlinedFn->hasFnAttribute(Attribute::NoRecurse));
   EXPECT_TRUE(OutlinedFn->hasParamAttribute(0, Attribute::NoAlias));
@@ -470,6 +472,7 @@
 
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
+  OMPBuilder.finalize();
 
   EXPECT_NE(PrivAI, nullptr);
   Function *OutlinedFn = PrivAI->getFunction();
@@ -595,6 +598,7 @@
 
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
+  OMPBuilder.finalize();
 
   EXPECT_FALSE(verifyModule(*M, ()));
 
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -93,6 +93,56 @@
 
 void OpenMPIRBuilder::initialize() { initializeTypes(M); }
 
+void OpenMPIRBuilder::finalize() {
+  for (OutlineInfo  : OutlineInfos) {
+assert(!OI.Blocks.empty() &&
+   "Outlined regions should have at least a single block!");
+BasicBlock *RegEntryBB = OI.Blocks.front();
+Function *OuterFn = RegEntryBB->getParent();
+CodeExtractorAnalysisCache CEAC(*OuterFn);
+CodeExtractor Extractor(OI.Blocks, /* DominatorTree */ nullptr,
+/* AggregateArgs */ false,
+/* BlockFrequencyInfo */ nullptr,
+/* BranchProbabilityInfo */ nullptr,
+/* AssumptionCache */ nullptr,
+/* AllowVarArgs */ true,
+/* AllowAlloca */ true,
+/* Suffix */ ".omp_par");
+
+LLVM_DEBUG(dbgs() << "Before outlining: " << *OuterFn << "\n");
+
+// Add some known attributes to the outlined function.
+Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
+
+LLVM_DEBUG(dbgs() << "After  outlining: " << *OuterFn << "\n");
+LLVM_DEBUG(dbgs() << "   Outlined function: " << *OutlinedFn << "\n");
+
+// For compability with the clang CG we move the outlined function after the
+// one with the parallel region.
+OutlinedFn->removeFromParent();
+M.getFunctionList().insertAfter(OuterFn->getIterator(), 

[clang-tools-extra] 784d441 - Fix Sphinx failure on ReadabilityQualifiedAuto docs

2020-02-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-02-11T02:03:37Z
New Revision: 784d4417453e2bb792e29f5dad462f7fcebab6d1

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

LOG: Fix Sphinx failure on ReadabilityQualifiedAuto docs

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
index 351b333b6dce..413640fb7ca7 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -36,19 +36,19 @@ Note ``const`` ``volatile`` qualified types will retain 
their ``const`` and
 
 .. code-block:: c++
 
-   const auto Foo = cast(Baz1);
-   const auto Bar = cast(Baz2);
-   volatile auto FooBar = cast(Baz3);
-   auto BarFoo = cast(Baz4);
+  const auto Foo = cast(Baz1);
+  const auto Bar = cast(Baz2);
+  volatile auto FooBar = cast(Baz3);
+  auto BarFoo = cast(Baz4);
 
 Would be transformed into:
 
 .. code-block:: c++
 
-   auto *const Foo = cast(Baz1);
-   const auto *const Bar = cast(Baz2);
-   auto *volatile FooBar = cast(Baz3);
-   auto *BarFoo = cast(Baz4);
+  auto *const Foo = cast(Baz1);
+  const auto *const Bar = cast(Baz2);
+  auto *volatile FooBar = cast(Baz3);
+  auto *BarFoo = cast(Baz4);
 
 Options
 ---
@@ -65,7 +65,7 @@ Options
auto *Foo2 = cast(Bar2);
auto  = cast(Bar3);
 
-   If AddConstToQualified is set to `0`,  it will be transformed into:
+If AddConstToQualified is set to `0`,  it will be transformed into:
 
 .. code-block:: c++
 
@@ -73,7 +73,7 @@ Options
auto *Foo2 = cast(Bar2);
auto  = cast(Bar3);
 
-   Otherwise it will be transformed into:
+Otherwise it will be transformed into:
 
 .. code-block:: c++
 
@@ -81,4 +81,4 @@ Options
const auto *Foo2 = cast(Bar2);
const auto  = cast(Bar3);
 
-   Note in the LLVM alias, the default value is `0`.
+Note in the LLVM alias, the default value is `0`.



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


[PATCH] D74371: [DirectoryWatcher] Fix misuse of FSEvents API and data race

2020-02-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74371



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


[PATCH] D74371: [DirectoryWatcher] Fix misuse of FSEvents API and data race

2020-02-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jkorous, akyrtzi.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

I observed two bugs in the DirectoryWatcher on macOS

  

1. We were calling FSEventStreamStop and FSEventStreamInvalidate before we 
called FSEventStreamStart and FSEventStreamSetDispatchQueue, if the 
DirectoryWatcher was destroyed before the initial async work was done. This 
violates the requirements of the FSEvents API.

2. Calls to Receiver could race between the initial work and the invalidation 
during destruction.

The second issue is easier to see when using TSan.

  

rdar://59215667


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74371

Files:
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -449,3 +449,42 @@
 
   checkEventualResultWithTimeout(TestConsumer);
 }
+
+TEST(DirectoryWatcherTest, InvalidatedWatcherAsync) {
+  DirectoryWatcherTestFixture fixture;
+  fixture.addFile("a");
+
+  // This test is checking that we get the initial notification for 'a' before
+  // the final 'invalidated'. Strictly speaking, we do not care whether 'a' is
+  // processed or not, only that it is neither racing with, nor after
+  // 'invalidated'. In practice, it is always processed in our implementations.
+  VerifyingConsumer TestConsumer{
+  {{EventKind::Modified, "a"}},
+  {{EventKind::WatcherGotInvalidated, ""}},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"}},
+  };
+
+  // A counter that can help detect data races on the event receiver,
+  // particularly if used with TSan. Expected count will be 2 or 3 depending on
+  // whether we get the kernel event or not (see comment above).
+  unsigned Count = 0;
+  {
+llvm::Expected> DW =
+DirectoryWatcher::create(
+fixture.TestWatchedDir,
+[,
+ ](llvm::ArrayRef Events,
+ bool IsInitial) {
+  Count += 1;
+  TestConsumer.consume(Events, IsInitial);
+},
+/*waitForInitialSync=*/false);
+ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
+  } // DW is destructed here.
+
+  checkEventualResultWithTimeout(TestConsumer);
+  ASSERT_TRUE(Count == 2u || Count == 3u);
+}
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -43,24 +43,32 @@
 class DirectoryWatcherMac : public clang::DirectoryWatcher {
 public:
   DirectoryWatcherMac(
-  FSEventStreamRef EventStream,
+  dispatch_queue_t Queue, FSEventStreamRef EventStream,
   std::function, bool)>
   Receiver,
   llvm::StringRef WatchedDirPath)
-  : EventStream(EventStream), Receiver(Receiver),
+  : Queue(Queue), EventStream(EventStream), Receiver(Receiver),
 WatchedDirPath(WatchedDirPath) {}
 
   ~DirectoryWatcherMac() override {
-stopFSEventStream(EventStream);
-EventStream = nullptr;
-// Now it's safe to use Receiver as the only other concurrent use would have
-// been in EventStream processing.
-Receiver(DirectoryWatcher::Event(
- DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""),
- false);
+// FSEventStreamStop and Invalidate must be called after Start and
+// SetDispatchQueue to follow FSEvents API contract. The call to Receiver
+// also uses Queue to not race with the initial scan.
+dispatch_sync(Queue, ^{
+  stopFSEventStream(EventStream);
+  EventStream = nullptr;
+  Receiver(
+  DirectoryWatcher::Event(
+  DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""),
+  false);
+});
+
+// Balance initial creation.
+dispatch_release(Queue);
   }
 
 private:
+  dispatch_queue_t Queue;
   FSEventStreamRef EventStream;
   std::function, bool)> Receiver;
   const std::string WatchedDirPath;
@@ -217,7 +225,7 @@
   assert(EventStream && "EventStream expected to be non-null");
 
   std::unique_ptr Result =
-  std::make_unique(EventStream, Receiver, Path);
+  std::make_unique(Queue, EventStream, Receiver, Path);
 
   // We need to copy the data so the lifetime is ok after a const copy is made
   // for the block.
@@ -230,10 +238,6 @@
 // inital scan and handling events ONLY AFTER the scan finishes.
 FSEventStreamSetDispatchQueue(EventStream, Queue);
 

[PATCH] D74361: [Clang] Uninitialize attribute on global variables

2020-02-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

FWIW, this would really help us to create an OpenMP device (=GPU) runtime 
written almost entirely in OpenMP, C++, and very few clang builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D74361: [Clang] Uninitialize attribute on global variables

2020-02-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: kcc, rjmccall, rsmith, glider, vitalybuka, 
pcc, eugenis, vlad.tsyrklevich, jdoerfert, gregrodgers.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[Clang] Uninitialize attribute on global variables

Extends D54604  to permit [[uninitialized]] on 
global and static variables

Initializing global variables is very cheap on hosted implementations. The
C semantics of zero initializing globals work very well there. It is not
necessarily cheap on freestanding implementations. Where there is no loader
available, code must be emitted near the start point to write the appropriate
values into memory.

At present, external variables can be declared in C++ and definitions provided
in assembly (or IR) to achive this effect. This patch removes a restriction on
the existing attribute in order to remove this reason for writing assembly for
performance sensitive freestanding implementations.

A close analogue in tree is LDS memory for amdgcn, where the kernel is
responsible for initializing the memory after it starts executing on the gpu.
Uninitalized variables in LDS are observably cheaper than zero initialized.

Patch follows the cuda __shared__ variable implementation which also produces
undef global variables, and reuses the [[uninitialized]] attribute from auto
variable initialisation. I think the existing docs are still appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74361

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCXX/attribute_uninitialized.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-uninitialized.c

Index: clang/test/Sema/attr-uninitialized.c
===
--- clang/test/Sema/attr-uninitialized.c
+++ clang/test/Sema/attr-uninitialized.c
@@ -6,16 +6,11 @@
 
 void bad() {
   int im_bad __attribute((uninitialized("zero")));  // expected-error {{'uninitialized' attribute takes no arguments}}
-  static int im_baaad __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
 }
 
-extern int come_on __attribute((uninitialized));// expected-warning {{'uninitialized' attribute only applies to local variables}}
-int you_know __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to local variables}}
-static int and_the_whole_world_has_to __attribute((uninitialized)); // expected-warning {{'uninitialized' attribute only applies to local variables}}
-
-void answer_right_now() __attribute((uninitialized)) {}// expected-warning {{'uninitialized' attribute only applies to local variables}}
-void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {} // expected-warning {{'uninitialized' attribute only applies to local variables}}
+void answer_right_now() __attribute((uninitialized)) {}// expected-warning {{'uninitialized' attribute only applies to variables}}
+void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {}
 
 struct TheWordIsOut {
-  __attribute((uninitialized)) int youre_doin_wrong; // expected-warning {{'uninitialized' attribute only applies to local variables}}
-} __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to local variables}}
+  __attribute((uninitialized)) int youre_doin_wrong; // expected-warning {{'uninitialized' attribute only applies to variables}}
+} __attribute((uninitialized));  // expected-warning {{'uninitialized' attribute only applies to variables}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -148,6 +148,7 @@
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
+// CHECK-NEXT: Uninitialized (SubjectMatchRule_variable)
 // CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/attribute_uninitialized.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attribute_uninitialized.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZZ4funcvE4data = internal global i32 undef
+int* func(void)
+{
+  

[PATCH] D44609: [clang-format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-02-10 Thread Francois JEAN via Phabricator via cfe-commits
Wawha added a comment.

Hi @MyDeveloperDay
Is the last change ok? That is the next step to be able to validate this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b81ebfe7eba: [ubsan] Null-check and adjust TypeLoc before 
using it (authored by vsk).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void @__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8b81ebf - [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via cfe-commits

Author: Vedant Kumar
Date: 2020-02-10T14:10:06-08:00
New Revision: 8b81ebfe7eba089ed2016d523cc5ee9d05e957a7

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

LOG: [ubsan] Null-check and adjust TypeLoc before using it

Null-check and adjut a TypeLoc before casting it to a FunctionTypeLoc.
This fixes a crash in -fsanitize=nullability-return, and also makes the
location of the nonnull type available when the return type is adjusted.

rdar://59263039

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

Added: 
clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm

Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9ef2a3b3d099..e6cb4a1fd93f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@ void CodeGenFunction::EmitReturnValueCheck(llvm::Value 
*RV) {
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;

diff  --git a/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm 
b/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
new file mode 100644
index ..23025c9eb845
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end



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


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 243672.
vsk retitled this revision from "[ubsan] Null-check TypeLoc before using it" to 
"[ubsan] Null-check and adjust TypeLoc before using it".
vsk edited the summary of this revision.
vsk added a comment.

- Check adjusted return type per Erik's offline feedback.


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

https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void 
@__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
===
--- /dev/null
+++ clang/test/CodeGenObjCXX/ubsan-nullability-return-notypeloc.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
+
+// CHECK-LABEL: define i8* @_Z3foov()
+// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
+// CHECK: icmp ne i8* [[CALL]]
+// CHECK: call void @__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
+
+struct S {
+  using PtrTy = id;
+};
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
+  extern S::PtrTy helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAsAdjusted())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74355: [ubsan] Null-check and adjust TypeLoc before using it

2020-02-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D74355



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


[PATCH] D74355: [ubsan] Null-check TypeLoc before using it

2020-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: erik.pilkington, delcypher.
Herald added a subscriber: dexonsmith.

Null-check a TypeLoc before casting it to a FunctionTypeLoc. This fixes
a crash in -fsanitize=nullability-return.

rdar://59263039


https://reviews.llvm.org/D74355

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m


Index: clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple 
x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK-LABEL: define i8* @foo()
+// CHECK: call i8* @helper()
+// CHECK-NEXT: ret i8*
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) id foo(void) {
+  extern id helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAs())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;


Index: clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
+
+// CHECK-LABEL: define i8* @foo()
+// CHECK: call i8* @helper()
+// CHECK-NEXT: ret i8*
+
+#pragma clang assume_nonnull begin
+__attribute__((ns_returns_retained)) id foo(void) {
+  extern id helper(void);
+  return helper();
+}
+#pragma clang assume_nonnull end
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3060,7 +3060,7 @@
   } else {
 if (auto *DD = dyn_cast(CurCodeDecl))
   if (auto *TSI = DD->getTypeSourceInfo())
-if (auto FTL = TSI->getTypeLoc().castAs())
+if (auto FTL = TSI->getTypeLoc().getAs())
   AttrLoc = FTL.getReturnLoc().findNullabilityLoc();
 CheckKind = SanitizerKind::NullabilityReturn;
 Handler = SanitizerHandler::NullabilityReturn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67588: Add builtin trait for add/remove cv (and similar)

2020-02-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

LGTM other than the inline comments.
I'll take a second pass at this once they're addressed.

Let's land the patch this week!




Comment at: clang/include/clang/Sema/DeclSpec.h:419
   static bool isTypeRep(TST T) {
 return (T == TST_typename || T == TST_typeofType ||
 T == TST_underlyingType || T == TST_atomic||

Is the block of values for these identifiers contiguous? Can we work towards 
writing this as `min <= x <= max`?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1094
 return DeclSpec::TST_removeReferenceType;
+  case tok::kw___remove_cv:
+return DeclSpec::TST_removeCV;

It would be really cool if we could simplify these conversions to 
`static_cast(Tok.getKind() - base);`

That said, it's probably easier to land this patch as is.



Comment at: clang/lib/Sema/SemaType.cpp:8475
+  }
+  case UnaryTransformType::AddCV: {
+QualType Underlying = BaseType.withConst().withVolatile();

I don't know that we need `add_foo`, because if I want to optimize my 
type-trait, I'll just write `T const`.

Adding code to clang has a maintenance cost; and that's non-trivial. The 
`remove_foo` traits add a lot of value, and that justifies the cost.




Comment at: clang/test/SemaCXX/add_cv.cpp:43
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&

Clang tests normally test:

(A) The diagnostics that emit when people seriously misuse.
(B) Just some failures.



Comment at: 
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_cv.sh.cpp:2
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.

I think we probably want to keep the libc++ changes in a separate patch.


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

https://reviews.llvm.org/D67588



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


[clang] 9559834 - [OPENMP50]Add support for 'release' clause.

2020-02-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-10T16:01:41-05:00
New Revision: 9559834a5c1286db4e5bc1f5de047bfd67868f4a

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

LOG: [OPENMP50]Add support for 'release' clause.

Added full support for 'release' clause in flush|atomic directives.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/test/OpenMP/atomic_read_codegen.c
clang/test/OpenMP/atomic_update_codegen.cpp
clang/test/OpenMP/atomic_write_codegen.c
clang/test/OpenMP/flush_ast_print.cpp
clang/test/OpenMP/flush_codegen.cpp
clang/test/OpenMP/flush_messages.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index b9c4389ddd63..19a84bd00a36 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1955,6 +1955,46 @@ class OMPAcquireClause final : public OMPClause {
   }
 };
 
+/// This represents 'release' clause in the '#pragma omp atomic|flush'
+/// directives.
+///
+/// \code
+/// #pragma omp flush release
+/// \endcode
+/// In this example directive '#pragma omp flush' has 'release' clause.
+class OMPReleaseClause final : public OMPClause {
+public:
+  /// Build 'release' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_release, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPReleaseClause()
+  : OMPClause(OMPC_release, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_release;
+  }
+};
+
 /// This represents clause 'private' in the '#pragma omp ...' directives.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 916fac717dd4..4ef9528dcf5b 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3131,6 +3131,11 @@ bool 
RecursiveASTVisitor::VisitOMPAcquireClause(OMPAcquireClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPReleaseClause(OMPReleaseClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
   return true;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index cc983f750711..450075f2e927 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9696,7 +9696,7 @@ def note_omp_atomic_capture: Note<
 def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update' or 'capture' clause">;
 def err_omp_several_mem_order_clauses : Error<
-  "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 
|}1'acq_rel' or 'acquire' clause">;
+  "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 
|}1'acq_rel', 'acquire' or 'release' clause">;
 def note_omp_previous_mem_order_clause : Note<
   "'%0' clause used here">;
 def err_omp_target_contains_not_only_teams : Error<

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 346c0f54971d..19fcf7cfac58 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -259,6 +259,7 @@ OPENMP_CLAUSE(capture, OMPCaptureClause)
 OPENMP_CLAUSE(seq_cst, OMPSeqCstClause)
 

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2020-02-10 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

>> Your error looks correct to me -- "self" in a classmethod is not an 
>> instance, but the class itself. And while instances of X implement 
>> "Delegate", the Class does not.
> 
> Got it, thanks! We might need to add a flag to allow the old behavior 
> temporarily to accommodate our codebase while it's being updated.

Adding an explicit cast would be the simplest way to allow your code to 
continue being broken in the same way it was previously broken.  E.g.

  // TODO: fix the types here -- self is _not_ actually an id!
  y.d = static_cast>(self);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[PATCH] D73755: [objc_direct] Small updates to help with adoption.

2020-02-10 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 243649.
MadCoder added a comment.

  Add some errors when direct properties are marked @dynamic.


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

https://reviews.llvm.org/D73755

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/test/FixIt/fixit-objc-direct.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/category-direct-properties.m
  clang/test/SemaObjC/method-direct.m

Index: clang/test/SemaObjC/method-direct.m
===
--- clang/test/SemaObjC/method-direct.m
+++ clang/test/SemaObjC/method-direct.m
@@ -18,6 +18,7 @@
 + (void)classRootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
 - (void)otherRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherRootDirect' declared here}}
 + (void)otherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherClassRootDirect' declared here}}
++ (void)otherOtherClassRootDirect __attribute__((objc_direct)); // expected-note {{direct method 'otherOtherClassRootDirect' declared here}}
 - (void)notDirectInIface; // expected-note {{previous declaration is here}}
 + (void)classNotDirectInIface;// expected-note {{previous declaration is here}}
 @end
@@ -48,11 +49,6 @@
 + (void)classRootCategoryDirect2 __attribute__((objc_direct)); // expected-note {{previous declaration is here}}
 @end
 
-__attribute__((objc_root_class, objc_direct_members)) // expected-error {{'objc_direct_members' attribute only applies to Objective-C implementation declarations and Objective-C containers}}
-@interface SubDirectFail : Root
-- (instancetype)init;
-@end
-
 @interface Sub : Root 
 /* invalid overrides with directs */
 - (void)rootRegular __attribute__((objc_direct));   // expected-error {{methods that override superclass methods cannot be direct}}
@@ -94,6 +90,8 @@
 + (void)otherClassRootDirect {
   [self someRootDirectMethod]; // expected-error {{messaging a Class with a method that is possibly direct}}
 }
++ (void)otherOtherClassRootDirect {
+}
 - (void)rootExtensionDirect {
 }
 + (void)classRootExtensionDirect {
@@ -135,6 +133,9 @@
 - (void)someValidSubMethod {
   [super otherRootDirect]; // expected-error {{messaging super with a direct method}}
 }
++ (void)someValidSubMethod {
+  [super otherOtherClassRootDirect]; // expected-error {{messaging super with a direct method}}
+}
 @end
 
 extern void callMethod(id obj, Class cls);
Index: clang/test/SemaObjC/category-direct-properties.m
===
--- /dev/null
+++ clang/test/SemaObjC/category-direct-properties.m
@@ -0,0 +1,273 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wselector-type-mismatch %s
+
+__attribute__((objc_root_class))
+@interface Inteface_Implementation
+@property(nonatomic, readonly) int normal_normal;
+@property(nonatomic, readonly, direct) int direct_normal;
+@property(nonatomic, readonly) int normal_direct; // expected-note {{previous declaration is here}}
+@property(nonatomic, readonly, direct) int direct_direct;
+@end
+
+@implementation Inteface_Implementation
+- (int)normal_normal {
+  return 42;
+}
+- (int)direct_normal {
+  return 42;
+}
+- (int)normal_direct __attribute__((objc_direct)) { // expected-error {{direct method implementation was previously declared not direct}}
+  return 42;
+}
+- (int)direct_direct __attribute__((objc_direct)) {
+  return 42;
+}
+@end
+
+__attribute__((objc_root_class))
+@interface Inteface_Extension
+@property(nonatomic, readonly) int normal_normal;
+@property(nonatomic, readonly, direct) int direct_normal;
+@property(nonatomic, readonly) int normal_direct;
+@property(nonatomic, readonly, direct) int direct_direct;
+@end
+
+@interface Inteface_Extension ()
+@property(nonatomic, readwrite) int normal_normal;
+@property(nonatomic, readwrite) int direct_normal;
+@property(nonatomic, readwrite, direct) int normal_direct;
+@property(nonatomic, readwrite, direct) int direct_direct;
+@end
+
+@implementation Inteface_Extension
+@end
+
+__attribute__((objc_root_class))
+@interface Extension_Implementation
+@end
+
+@interface Extension_Implementation ()
+@property(nonatomic, readwrite) int normal_normal;
+@property(nonatomic, readwrite, direct) int direct_normal;
+@property(nonatomic, readwrite) int normal_direct; // expected-note {{previous declaration is here}}
+@property(nonatomic, readwrite, direct) int direct_direct;
+@end
+
+@implementation Extension_Implementation
+- (int)normal_normal {
+  return 42;
+}
+- (int)direct_normal {
+  return 42;
+}
+- (int)normal_direct __attribute__((objc_direct)) { // expected-error {{direct method 

Re: [clang-tools-extra] 8a68c40 - [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-02-10 Thread Nico Weber via cfe-commits
This broke sphinx:
http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/54402/steps/docs-clang-tools-html/logs/stdio

Please take a look!

On Sun, Feb 2, 2020 at 4:27 PM Nathan James via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Nathan James
> Date: 2020-02-02T21:27:25Z
> New Revision: 8a68c40a1bf256523993ee97b39f79001eaade91
>
> URL:
> https://github.com/llvm/llvm-project/commit/8a68c40a1bf256523993ee97b39f79001eaade91
> DIFF:
> https://github.com/llvm/llvm-project/commit/8a68c40a1bf256523993ee97b39f79001eaade91.diff
>
> LOG: [clang-tidy] Added option for disabling const qualifiers in
> readability-qualified-auto
>
> Summary: Adds an option called `AddConstToQualified` to
> readability-qualified-auto to toggle adding const to the auto typed
> pointers and references. By default its enabled but in the LLVM module its
> disabled.
>
> Reviewers: aaron.ballman, alexfh, JonasToth, hokein, sammccall
>
> Reviewed By: aaron.ballman
>
> Subscribers: Quuxplusone, merge_guards_bot, lebedev.ri, xazax.hun,
> cfe-commits
>
> Tags: #clang, #clang-tools-extra
>
> Differential Revision: https://reviews.llvm.org/D73548
>
> Added:
> clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
>
> Modified:
> clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h
> clang-tools-extra/docs/ReleaseNotes.rst
> clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> index 5ae927c2cf5a..2aaf07639267 100644
> --- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> +++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
> @@ -36,6 +36,12 @@ class LLVMModule : public ClangTidyModule {
>  "llvm-qualified-auto");
>  CheckFactories.registerCheck("llvm-twine-local");
>}
> +
> +  ClangTidyOptions getModuleOptions() override {
> +ClangTidyOptions Options;
> +Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
> +return Options;
> +  }
>  };
>
>  // Register the LLVMTidyModule using this statically initialized variable.
>
> diff  --git
> a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> index 1d0b85b9c4ce..79885dbe4b43 100644
> --- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> +++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
> @@ -102,6 +102,10 @@ bool isAutoPointerConst(QualType QType) {
>
>  } // namespace
>
> +void QualifiedAutoCheck::storeOptions(ClangTidyOptions::OptionMap ) {
> +  Options.store(Opts, "AddConstToQualified", AddConstToQualified);
> +}
> +
>  void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
>if (!getLangOpts().CPlusPlus11)
>  return; // Auto deduction not used in 'C or C++03 and earlier', so
> don't
> @@ -142,6 +146,8 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder
> *Finder) {
>hasAnyTemplateArgument(IsBoundToType),
>"auto"),
>this);
> +  if (!AddConstToQualified)
> +return;
>Finder->addMatcher(ExplicitSingleVarDecl(
>   hasType(pointerType(pointee(autoType(,
> "auto_ptr"),
>   this);
> @@ -177,11 +183,9 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult ) {
>  bool IsLocalVolatile = Var->getType().isLocalVolatileQualified();
>  bool IsLocalRestrict = Var->getType().isLocalRestrictQualified();
>
> -if (CheckQualifier(IsLocalConst, Qualifier::Const))
> -  return;
> -if (CheckQualifier(IsLocalVolatile, Qualifier::Volatile))
> -  return;
> -if (CheckQualifier(IsLocalRestrict, Qualifier::Restrict))
> +if (CheckQualifier(IsLocalConst, Qualifier::Const) ||
> +CheckQualifier(IsLocalVolatile, Qualifier::Volatile) ||
> +CheckQualifier(IsLocalRestrict, Qualifier::Restrict))
>return;
>
>  // Check for bridging the gap between the asterisk and name.
> @@ -214,8 +218,7 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult ) {
>  << (IsLocalRestrict ? "__restrict " : "") << Var->getName() <<
> ReplStr;
>
>  for (SourceRange  : RemoveQualifiersRange) {
> -  Diag << FixItHint::CreateRemoval(
> -  CharSourceRange::getCharRange(Range.getBegin(),
> Range.getEnd()));
> +  Diag <<
> FixItHint::CreateRemoval(CharSourceRange::getCharRange(Range));
>  }
>
>  Diag << FixItHint::CreateReplacement(FixItRange, ReplStr);
> @@ -247,22 +250,17 @@ void QualifiedAutoCheck::check(const
> MatchFinder::MatchResult ) {
>  return;
>  }
>
> -CharSourceRange FixItRange;
> 

[clang-tools-extra] efcf643 - Reland "[clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS""

2020-02-10 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-02-10T12:17:02-08:00
New Revision: efcf6430009cc5bcc2024ecec1c4e4bbb328d037

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

LOG: Reland "[clangd][test] Disable a particular testcase in 
FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS""

The test got re-enabled after d54d71b67e60 landed.

However it seems that the order is still not deterministic as it
currently passes with -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF but randomly
fails with expensive checks ON.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 1d2ea0f1c0b2..be4b37c8f453 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -823,6 +823,10 @@ TEST_F(FindExplicitReferencesTest, All) {
 "1: targets = {vector}\n"
 "2: targets = {x}\n"},
// Handle UnresolvedLookupExpr.
+   // FIXME
+   // This case fails when expensive checks are enabled.
+   // Seems like the order of ns1::func and ns2::func isn't defined.
+   #ifndef EXPENSIVE_CHECKS
{R"cpp(
 namespace ns1 { void func(char*); }
 namespace ns2 { void func(int*); }
@@ -836,6 +840,7 @@ TEST_F(FindExplicitReferencesTest, All) {
 )cpp",
 "0: targets = {ns1::func, ns2::func}\n"
 "1: targets = {t}\n"},
+#endif
// Handle UnresolvedMemberExpr.
{R"cpp(
 struct X {



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


[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

(I'll try to actually review this later but I left a comment below)




Comment at: 
clang/test/Driver/clang-offload-bundler-missing-size-section.cpp:1-44
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=o 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t_host.o,%t_device.o -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_device.o | FileCheck %s
+// CHECK:11
+

ABataev wrote:
> Very strange test. It should not contain standard includes. Also, it should 
> not be an executable test, you have to check for the driver output or 
> something similar
We have executable tests in the OpenMP target offloading part, if it cannot 
live with clang it can live there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2020-02-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D67983#1863981 , @jyknight wrote:

> In D67983#1863019 , @arphaman wrote:
>
> > @jyknight @rjmccall I'm not sure this change is 100% fine. For example, the 
> > following code no longer compiles with ARC:
> >
> >   @protocol Delegate
> >   @end
> >  
> >   @interface X 
> >  
> >   @end
> >  
> >   @interface Y
> >   @property id d;
> >   @end
> >  
> >   @implementation X
> >  
> >   + (void)foo:(Y *)y with:(X*)x {
> >y.d = self; // error: assigning to 'id' from incompatible type 
> > 'const Class'
> >y.d = x; // fine
> >   }
> >  
> >   @end
> >
>
>
> Your error looks correct to me -- "self" in a classmethod is not an instance, 
> but the class itself. And while instances of X implement "Delegate", the 
> Class does not.


Got it, thanks! We might need to add a flag to allow the old behavior 
temporarily to accommodate our codebase while it's being updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[clang] 04a830f - [OPENMP50]Support for acquire clause.

2020-02-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-10T14:51:46-05:00
New Revision: 04a830f80af97d1b2d2d652984635a774b23ebda

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

LOG: [OPENMP50]Support for acquire clause.

Added full support for acquire clause in flush|atomic directives.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/test/OpenMP/atomic_read_codegen.c
clang/test/OpenMP/atomic_update_codegen.cpp
clang/test/OpenMP/atomic_write_codegen.c
clang/test/OpenMP/flush_ast_print.cpp
clang/test/OpenMP/flush_codegen.cpp
clang/test/OpenMP/flush_messages.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index f0dddf729309..b9c4389ddd63 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1882,7 +1882,7 @@ class OMPSeqCstClause : public OMPClause {
 /// #pragma omp flush acq_rel
 /// \endcode
 /// In this example directive '#pragma omp flush' has 'acq_rel' clause.
-class OMPAcqRelClause : public OMPClause {
+class OMPAcqRelClause final : public OMPClause {
 public:
   /// Build 'ack_rel' clause.
   ///
@@ -1915,6 +1915,46 @@ class OMPAcqRelClause : public OMPClause {
   }
 };
 
+/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
+/// directives.
+///
+/// \code
+/// #pragma omp flush acquire
+/// \endcode
+/// In this example directive '#pragma omp flush' has 'acquire' clause.
+class OMPAcquireClause final : public OMPClause {
+public:
+  /// Build 'acquire' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_acquire, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPAcquireClause()
+  : OMPClause(OMPC_acquire, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_acquire;
+  }
+};
+
 /// This represents clause 'private' in the '#pragma omp ...' directives.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index d8e6fb6e0254..916fac717dd4 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3126,6 +3126,11 @@ bool 
RecursiveASTVisitor::VisitOMPAcqRelClause(OMPAcqRelClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPAcquireClause(OMPAcquireClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
   return true;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5cfd32c57c61..cc983f750711 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9695,9 +9695,9 @@ def note_omp_atomic_capture: Note<
   "%select{expected assignment expression|expected compound statement|expected 
exactly two expression statements|expected in right hand side of the first 
expression}0">;
 def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update' or 'capture' clause">;
-def err_omp_atomic_several_mem_order_clauses : Error<
-  "directive '#pragma omp atomic' cannot contain more than one 'seq_cst' or 
'acq_rel' clause">;
-def note_omp_atomic_previous_clause : Note<
+def err_omp_several_mem_order_clauses : Error<
+  "directive '#pragma omp %0' cannot contain more 

Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-10 Thread Nico Weber via cfe-commits
On Sun, Feb 9, 2020 at 2:34 PM Richard Smith  wrote:

> On Sun, 9 Feb 2020, 01:09 Nico Weber via cfe-commits, <
> cfe-commits@lists.llvm.org> wrote:
>
>> Our code fails to build with "destructor cannot be declared using a type
>> alias" after this, without us changing language mode or anything.
>>
>> Is that intended?
>>
>
> Can you provide a sketch of what you were doing? There are certainly cases
> where I'd expect that now --  where you find a typedef through in "bad"
> (extension) place and find a non-typedef elsewhere.
>

namespace perfetto {
class ConsumerEndpoint { . // 1
 public:
  virtual ~ConsumerEndpoint();
};
class TracingService {
 public:
  using ProducerEndpoint = perfetto::ProducerEndpoint;
  using ConsumerEndpoint = perfetto::ConsumerEndpoint;
};
TracingService::ConsumerEndpoint::~ConsumerEndpoint() = default;
}

1:
https://cs.chromium.org/chromium/src/third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h?sq=package:chromium=0=55

2:
https://cs.chromium.org/chromium/src/third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h?q=using%5C+ConsumerEndpoint=package:chromium=0=234

3:
https://android-review.googlesource.com/c/platform/external/perfetto/+/1229901/1/src/tracing/core/virtual_destructors.cc
lhs

Upon closer look, that was the only instance we had.

Can this be a default-error-mapped warning so that projects have some
>> incremental transition path for this?
>>
>
> That seems reasonable, yes.
>
> On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-02-07T18:40:41-08:00
>>> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>>>
>>> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>>>
>>> Also add extension warnings for the cases that are disallowed by the
>>> current rules for destructor name lookup, refactor and simplify the
>>> lookup code, and improve the diagnostic quality when lookup fails.
>>>
>>> The special case we previously supported for converting
>>> p->N::S::~S() from naming a class template into naming a
>>> specialization thereof is subsumed by a more general rule here (which is
>>> also consistent with Clang's historical behavior and that of other
>>> compilers): if we can't find a suitable S in N, also look in N::S.
>>>
>>> The extension warnings are off by default, except for a warning when
>>> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
>>> That seems sufficiently heinous to warn on by default, especially since
>>> we can't support it for a dependent nested-name-specifier.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/include/clang/Basic/DiagnosticGroups.td
>>> clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> clang/lib/AST/NestedNameSpecifier.cpp
>>> clang/lib/Sema/DeclSpec.cpp
>>> clang/lib/Sema/SemaExprCXX.cpp
>>> clang/test/CXX/class/class.mem/p13.cpp
>>> clang/test/CXX/drs/dr2xx.cpp
>>> clang/test/CXX/drs/dr3xx.cpp
>>> clang/test/FixIt/fixit.cpp
>>> clang/test/Parser/cxx-decl.cpp
>>> clang/test/SemaCXX/constructor.cpp
>>> clang/test/SemaCXX/destructor.cpp
>>> clang/test/SemaCXX/pseudo-destructors.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
>>> b/clang/include/clang/Basic/DiagnosticGroups.td
>>> index a2bc29986a07..8c54723cdbab 100644
>>> --- a/clang/include/clang/Basic/DiagnosticGroups.td
>>> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
>>> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>>>  // designators (including the warning controlled by -Wc++2a-designator).
>>>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>>>  def GNUDesignator : DiagGroup<"gnu-designator">;
>>> +def DtorName : DiagGroup<"dtor-name">;
>>>
>>>  def DynamicExceptionSpec
>>>  : DiagGroup<"dynamic-exception-spec",
>>> [DeprecatedDynamicExceptionSpec]>;
>>>
>>> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> index 9de60d3a8d27..82861f0d5d72 100644
>>> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>>> @@ -1911,17 +1911,33 @@ def err_destructor_with_params :
>>> Error<"destructor cannot have any parameters">;
>>>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>>>  def err_destructor_typedef_name : Error<
>>>"destructor cannot be declared using a %select{typedef|type alias}1
>>> %0 of the class name">;
>>> +def err_undeclared_destructor_name : Error<
>>> +  "undeclared identifier %0 in destructor 

[PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

For the record: tests have been updated, option handling cleaned up and 
expansive check failure fixed in commit 
e67cbac81211d40332a79d98c9d5953624cc1202 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[clang] 3185c30 - Prefer __vector over vector keyword for altivec

2020-02-10 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-10T20:23:26+01:00
New Revision: 3185c30c54d0af5bffbff3bcfd721668d086ff10

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

LOG: Prefer __vector over vector keyword for altivec

`vector' uses the keyword-and-predefine mode from gcc, while __vector is
reliably supported.

As a side effect, it also makes the code consistent in its usage of __vector.

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

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 9034726560dc..a51745697b11 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.



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


[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3185c30c54d0: Prefer __vector over vector keyword for 
altivec (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D74129?vs=242902=243641#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2552,8 +2552,8 @@
 '/', '/', '/', '/',  '/', '/', '/', '/',
 '/', '/', '/', '/',  '/', '/', '/', '/'
   };
-  while (CurPtr+16 <= BufferEnd &&
- !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))
+  while (CurPtr + 16 <= BufferEnd &&
+ !vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes))
 CurPtr += 16;
 #else
   // Scan for '/' quickly.  Many block comments are very large.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

> Do you know why it's started failing now?

Not quite, probably a gcc update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129



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


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dgoldman marked an inline comment as done.
Closed by commit rG6ff0228c6df3: [clang] Add `forceReload` clangd extension to 
textDocument/didChange (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -616,6 +616,53 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  ParseInputs Inputs = getInputs(Source, SourceContents);
+
+  // Update the source contents, which should trigger an initial build with
+  // the header file missing.
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+EXPECT_THAT(
+Diags,
+ElementsAre(
+Field(::Message, "'foo.h' file not found"),
+Field(::Message, "use of undeclared identifier 'a'")));
+  });
+
+  // Add the header file. We need to recreate the inputs since we changed a
+  // file from underneath the test FS.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+  Inputs = getInputs(Source, SourceContents);
+
+  // The addition of the missing header file shouldn't trigger a rebuild since
+  // we don't track missing files.
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
+
+  // Forcing the reload should should cause a rebuild which no longer has any
+  // errors.
+  Inputs.ForceRebuild = true;
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+EXPECT_THAT(Diags, IsEmpty());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +769,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +794,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ 

[clang-tools-extra] 6ff0228 - [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2020-02-10T14:02:02-05:00
New Revision: 6ff0228c6df37e052fa6e8e3927e83b289402cf6

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

LOG: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

Summary:
- This option forces a preamble rebuild to handle the odd case
  of a missing header file being added

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, 
kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 880359f21dda..93609a8852db 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -647,7 +647,7 @@ void ClangdLSPServer::onDocumentDidChange(
 return;
   }
 
-  Server->addDocument(File, *Contents, WantDiags);
+  Server->addDocument(File, *Contents, WantDiags, Params.forceRebuild);
 }
 
 void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams ) {

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 3e22a4dfe667..48cf921ff18c 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -170,7 +170,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
,
 }
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
-   WantDiagnostics WantDiags) {
+   WantDiagnostics WantDiags, bool ForceRebuild) {
   auto FS = FSProvider.getFileSystem();
 
   ParseOptions Opts;
@@ -184,6 +184,7 @@ void ClangdServer::addDocument(PathRef File, 
llvm::StringRef Contents,
   ParseInputs Inputs;
   Inputs.FS = FS;
   Inputs.Contents = std::string(Contents);
+  Inputs.ForceRebuild = ForceRebuild;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
   bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 3c3505295a75..5156520e2d07 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -172,7 +172,8 @@ class ClangdServer {
   /// separate thread. When the parsing is complete, DiagConsumer passed in
   /// constructor will receive onDiagnosticsReady callback.
   void addDocument(PathRef File, StringRef Contents,
-   WantDiagnostics WD = WantDiagnostics::Auto);
+   WantDiagnostics WD = WantDiagnostics::Auto,
+   bool ForceRebuild = false);
 
   /// Get the contents of \p File, which should have been added.
   llvm::StringRef getDocument(PathRef File) const;

diff  --git a/clang-tools-extra/clangd/Compiler.h 
b/clang-tools-extra/clangd/Compiler.h
index 51414c37fc04..356293b158f8 100644
--- a/clang-tools-extra/clangd/Compiler.h
+++ b/clang-tools-extra/clangd/Compiler.h
@@ -45,6 +45,9 @@ struct ParseInputs {
   tooling::CompileCommand CompileCommand;
   IntrusiveRefCntPtr FS;
   std::string Contents;
+  // Prevent reuse of the cached preamble/AST. Slow! Useful to workaround
+  // clangd's assumption that missing header files will stay missing.
+  bool ForceRebuild = false;
   // Used to recover from diagnostics (e.g. find missing includes for symbol).
   const SymbolIndex *Index = nullptr;
   ParseOptions Opts;

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index aabf0fa11d45..d607ffbbc815 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@ bool fromJSON(const llvm::json::Value , 
DidCloseTextDocumentParams ) {
 
 bool fromJSON(const llvm::json::Value , DidChangeTextDocumentParams ) 
{
   llvm::json::ObjectMapper O(Params);
-  return O && O.map("textDocument", R.textDocument) &&
+  if (!O)
+return false;
+  O.map("forceRebuild", R.forceRebuild);  // Optional clangd extension.
+  return O.map("textDocument", R.textDocument) &&
  O.map("contentChanges", R.contentChanges) &&
  O.map("wantDiagnostics", R.wantDiagnostics);
 }

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 255629f0a0ec..3275cbbd17b1 100644
--- 

[clang] b50431d - fix some typos to cycle bots

2020-02-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-02-10T13:51:23-05:00
New Revision: b50431defbaf80c254244cefdce3813576633ae5

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

LOG: fix some typos to cycle bots

Added: 


Modified: 
clang/docs/Block-ABI-Apple.rst
clang/docs/LanguageExtensions.rst
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index 0cc14a35b033..d038cdfe9bd2 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -63,7 +63,7 @@ The following flags bits are in use thusly for a possible 
ABI.2010.3.16:
 enum {
 // Set to true on blocks that have captures (and thus are not true
 // global blocks) but are known not to escape for various other
-// reasons. For backward compatiblity with old runtimes, whenever
+// reasons. For backward compatibility with old runtimes, whenever
 // BLOCK_IS_NOESCAPE is set, BLOCK_IS_GLOBAL is set too. Copying a
 // non-escaping block returns the original block and releasing such a
 // block is a no-op, which is exactly how global blocks are handled.

diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 9af49e3a60d7..adef8bb433a1 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2145,7 +2145,7 @@ Checked Arithmetic Builtins
 ---
 
 Clang provides a set of builtins that implement checked arithmetic for security
-critical applications in a manner that is fast and easily expressable in C. As
+critical applications in a manner that is fast and easily expressible in C. As
 an example of their usage:
 
 .. code-block:: c
@@ -2538,7 +2538,7 @@ pointers and integers.
 These builtins can be used to avoid relying on implementation-defined behavior
 of arithmetic on integers derived from pointers.
 Additionally, these builtins retain type information and, unlike bitwise
-arithmentic, they can perform semantic checking on the alignment value.
+arithmetic, they can perform semantic checking on the alignment value.
 
 **Syntax**:
 

diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 1575e4faaa01..0e9c364fbf6b 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -107,14 +107,14 @@ relies on padding and the ability to map a file over the 
existing memory
 mapping which is generally only available on POSIX systems and isn't suitable
 for other platforms.
 
-On Fuchsia, we rely on the the ability to relocate counters at runtime using a
+On Fuchsia, we rely on the ability to relocate counters at runtime using a
 level of indirection. On every counter access, we add a bias to the counter
 address. This bias is stored in ``__llvm_profile_counter_bias`` symbol that's
 provided by the profile runtime and is initially set to zero, meaning no
-relocation. The runtime can map the profile into memory at abitrary location,
+relocation. The runtime can map the profile into memory at arbitrary locations,
 and set bias to the offset between the original and the new counter location,
 at which point every subsequent counter access will be to the new location,
-which allows updating profile directly akin to the continous mode.
+which allows updating profile directly akin to the continuous mode.
 
 The advantage of this approach is that doesn't require any special OS support.
 The disadvantage is the extra overhead due to additional instructions required



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-02-10 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb created this revision.
broadwaylamb added reviewers: vvereschaka, aorlov, andreil99.
Herald added subscribers: cfe-commits, ldionne, kristof.beyls, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: clang.

D69169 , which was necessary for running 
libc++ tests on remote host, got reverted. I couldn't think of a less invasive 
way to achieve this behavior but specify libc++abi paths in our cache file.

I was wondering though if the assumptions I made in this patch regarding 
directory layout always hold.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 2 inline comments as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:630
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {

sammccall wrote:
> this still feels just a bit obfuscated, what about more directly:
> 
> ```
> ParseInputs I = getInputs(Source, SourceContents);
> updateWithDiags(..., I, [] { ... });
> Files[Header] = ...;
> updateWithDiags(...);
> I.ForceRebuild = true;
> updateWithDiags(...);
> ```
still needed to recreate ParseInputs but done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 243619.
dgoldman added a comment.

- Minor test fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -616,6 +616,53 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  ParseInputs Inputs = getInputs(Source, SourceContents);
+
+  // Update the source contents, which should trigger an initial build with
+  // the header file missing.
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+EXPECT_THAT(
+Diags,
+ElementsAre(
+Field(::Message, "'foo.h' file not found"),
+Field(::Message, "use of undeclared identifier 'a'")));
+  });
+
+  // Add the header file. We need to recreate the inputs since we changed a
+  // file from underneath the test FS.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+  Inputs = getInputs(Source, SourceContents);
+
+  // The addition of the missing header file shouldn't trigger a rebuild since
+  // we don't track missing files.
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
+
+  // Forcing the reload should should cause a rebuild which no longer has any
+  // errors.
+  Inputs.ForceRebuild = true;
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+EXPECT_THAT(Diags, IsEmpty());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +769,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +794,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@
 
 bool fromJSON(const llvm::json::Value , DidChangeTextDocumentParams ) {
   

[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 243614.
tmsriram marked 3 inline comments as done.
tmsriram added a comment.

Removed getBBSectionsList (moved to LLVM) and address other reviewer comments.


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

https://reviews.llvm.org/D68049

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/basicblock-sections.c

Index: clang/test/CodeGen/basicblock-sections.c
===
--- /dev/null
+++ clang/test/CodeGen/basicblock-sections.c
@@ -0,0 +1,47 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -fbasicblock-sections=none -o - < %s | FileCheck %s --check-prefix=PLAIN
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=labels -o - < %s | FileCheck %s --check-prefix=BB_LABELS
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=%S/basicblock-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -funique-bb-section-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+int world(int a) {
+  if (a > 10)
+return 10;
+  else if (a > 5)
+return 5;
+  else
+return 0;
+}
+
+int another(int a) {
+  if (a > 10)
+return 20;
+  return 0;
+}
+
+// PLAIN-NOT: section
+// PLAIN: world
+//
+// BB_LABELS-NOT: section
+// BB_LABELS: world
+// BB_LABELS-LABEL: a.BB.world
+// BB_LABELS-LABEL: aa.BB.world
+// BB_LABEL-LABEL: a.BB.another
+//
+// BB_WORLD: .section .text.world,"ax",@progbits
+// BB_WORLD: world
+// BB_WORLD: .section .text.world,"ax",@progbits,unique
+// BB_WORLD: a.BB.world
+// BB_WORLD: .section .text.another,"ax",@progbits
+// BB_ALL: .section .text.another,"ax",@progbits,unique
+// BB_ALL: a.BB.another
+// BB_LIST-NOT: .section .text.another,"ax",@progbits,unique
+// BB_LIST: another
+// BB_LIST-NOT: a.BB.another
+//
+// UNIQUE: .section .text.world.a.BB.world
+// UNIQUE: .section .text.another.a.BB.another
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -962,10 +962,24 @@
   Opts.TrapFuncName = std::string(Args.getLastArgValue(OPT_ftrap_function_EQ));
   Opts.UseInitArray = !Args.hasArg(OPT_fno_use_init_array);
 
-  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
+  Opts.BBSections =
+  std::string(Args.getLastArgValue(OPT_fbasicblock_sections_EQ, "none"));
+  if (Opts.BBSections != "all" && Opts.BBSections != "labels" &&
+  Opts.BBSections != "none" && !llvm::sys::fs::exists(Opts.BBSections)) {
+Diags.Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fbasicblock_sections_EQ)->getAsString(Args)
+<< Opts.BBSections;
+  }
+
+  // Basic Block Sections implies Function Sections.
+  Opts.FunctionSections =
+  Args.hasArg(OPT_ffunction_sections) ||
+  (Opts.BBSections != "none" && Opts.BBSections != "labels");
+
   Opts.DataSections = Args.hasArg(OPT_fdata_sections);
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);
+  Opts.UniqueBBSectionNames = Args.hasArg(OPT_funique_bb_section_names);
 
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4202,8 +4202,11 @@
 options::OPT_fno_function_sections,
 options::OPT_fdata_sections,
 options::OPT_fno_data_sections,
+options::OPT_fbasicblock_sections_EQ,
 options::OPT_funique_section_names,
 options::OPT_fno_unique_section_names,
+options::OPT_funique_bb_section_names,
+options::OPT_fno_unique_bb_section_names,
 options::OPT_mrestrict_it,
 options::OPT_mno_restrict_it,
 options::OPT_mstackrealign,
@@ -4758,6 +4761,11 @@
 CmdArgs.push_back("-ffunction-sections");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fbasicblock_sections_EQ)) {
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-fbasicblock-sections=") + A->getValue()));
+  }
+
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,

[PATCH] D68049: Propeller: Clang options for basic block sections

2020-02-10 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added a comment.

In D68049#1865967 , @MaskRay wrote:

> If you don't mind, I can push a Diff to this Differential which will address 
> these review comments.


Let me update this patch asap as we refactored getBBSectionsList into llvm as 
it is shared by llc, clang and lld.


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

https://reviews.llvm.org/D68049



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-10 Thread Aaron Ballman via cfe-commits
On Mon, Feb 10, 2020 at 10:06 AM John Marshall
 wrote:
>
> Thanks Aaron (and Hubert).
>
> I've attached an updated patch that now includes new test cases alongside 
> some existing "too few / too many" test cases in test/Sema/exprs.c. This 
> splits the function declaration over two lines so it can use -verify to 
> validate the source location's line (but not column). If you'd prefer a 
> FileCheck approach to get the column too, I'm happy to do that but please 
> advise whether it would be best to create a new test/Sema/foo.c file for 
> these tests or to add to one of the existing test files.
>
> Verified that without the patch, the notes are on the "MY_EXPORT void" line 
> and the test cases fail. All tests still pass after this, after adjusting one 
> existing FileCheck-based test case that also happens to exercise the patch's 
> change.

Thank you for the patch -- I think it is fine to not check the column
for the cases you've added, so this iteration LGTM. I'm happy to
commit this on your behalf, but it will have to wait until next week
because I'm out at wg21 meetings this week. If no one else commits
this before I get home, I'll handle it then.

~Aaron

>
> John
>
>
> On 7 Feb 2020, at 15:40, Aaron Ballman wrote:
> > Thank you for the patch -- I think the changes look reasonable, but it
> > should come with some test cases as well. Source location stuff is a
> > bit onerous to try to test, but I think the best approach would be to
> > add a new test that uses FileCheck instead of -verify so that you can
> > validate the source location's line and column are as expected in the
> > note. Once you have such a test (and have verified that no other tests
> > fail with your changes), I'm happy to commit on your behalf.
> >
> > ~Aaron
> >
> > On Fri, Feb 7, 2020 at 10:23 AM Hubert Tong
> >  wrote:
> >>
> >> I think this looks okay. I think Richard or Aaron might be able to provide 
> >> a more informed opinion.
> >>
> >> -- HT
>
>
> commit cbd4a4a155b40dc77c2ed82f397fe303dfc10837
> Author: John Marshall 
> AuthorDate: Mon Jan 20 14:58:14 2020 +
> Commit: John Marshall 
> CommitDate: Mon Feb 10 14:30:58 2020 +
>
> Use getLocation() in "too few/too many arguments" diagnostic
>
> Use the more accurate location when emitting the location of the
> function being called's prototype in diagnostics emitted when calling
> a function with an incorrect number of arguments.
>
> In particular, avoids showing a trace of irrelevant macro expansions
> for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.
>
> Add test cases alongside other "too few/too many arguments" tests.
> Adjust column position in incidentally related FileCheck-based test.
>
> diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> index ffe72c98356..b9d7024f083 100644
> --- a/clang/lib/Sema/SemaExpr.cpp
> +++ b/clang/lib/Sema/SemaExpr.cpp
> @@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
>
>// Emit the location of the prototype.
>if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
>
>return true;
>  }
> @@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
>
>// Emit the location of the prototype.
>if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
>
>// This deletes the extra arguments.
>Call->shrinkNumArgs(NumParams);
> diff --git a/clang/test/Misc/serialized-diags.c 
> b/clang/test/Misc/serialized-diags.c
> index e401477a2eb..2f4b86fb42f 100644
> --- a/clang/test/Misc/serialized-diags.c
> +++ b/clang/test/Misc/serialized-diags.c
> @@ -56,7 +56,7 @@ void rdar11040133() {
>  // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
> {{.*[/\\]}}serialized-diags.c:22:18
>  // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
> 'false' []
>  // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
> {{.*[/\\]}}serialized-diags.c:20:16
> -// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
> +// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
>  // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer 
> to pointer conversion initializing 'char *' with an expression of type 'int' 
> [-Wint-conversion]
>  // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 
> {{.*[/\\]}}serialized-diags.h:5:17
>  // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from 
> {{.*[/\\]}}serialized-diags.c:26: []
> diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
> index 760c45e02f3..4e144041aca 100644
> --- a/clang/test/Sema/exprs.c
> +++ 

[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

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

LG, thanks! Just a nit about further simplifying the test, up to you.




Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:630
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {

this still feels just a bit obfuscated, what about more directly:

```
ParseInputs I = getInputs(Source, SourceContents);
updateWithDiags(..., I, [] { ... });
Files[Header] = ...;
updateWithDiags(...);
I.ForceRebuild = true;
updateWithDiags(...);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 243595.
dgoldman marked 3 inline comments as done.
dgoldman added a comment.

- Fixes for tests and InputFiles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -616,6 +616,52 @@
   ASSERT_FALSE(DoUpdate(OtherSourceContents));
 }
 
+TEST_F(TUSchedulerTests, ForceRebuild) {
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+
+  auto Source = testPath("foo.cpp");
+  auto Header = testPath("foo.h");
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+)cpp";
+
+  auto DoUpdate = [&](std::string Contents, bool ForceRebuild,
+  llvm::unique_function)> CB) {
+ParseInputs Inputs = getInputs(Source, std::string(Contents));
+Inputs.ForceRebuild = ForceRebuild;
+updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes, std::move(CB));
+  };
+
+  // Update the source contents, which should trigger an initial build with
+  // the header file missing.
+  DoUpdate(SourceContents, /*ForceRebuild*/false, [](std::vector Diags) {
+  EXPECT_THAT(
+  Diags,
+  ElementsAre(
+  Field(::Message, "'foo.h' file not found"),
+  Field(::Message, "use of undeclared identifier 'a'")));
+  });
+
+  // Add the header file.
+  Files[Header] = "int a;";
+  Timestamps[Header] = time_t(1);
+
+  // The addition of the missing header file shouldn't trigger a rebuild since
+  // we don't track missing files.
+  DoUpdate(SourceContents, /*ForceRebuild*/false, [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
+
+  // Forcing the reload should should cause a rebuild which no longer has any
+  // errors.
+  DoUpdate(SourceContents, /*ForceRebuild*/true, [](std::vector Diags) {
+EXPECT_THAT(Diags, IsEmpty());
+  });
+
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+}
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
 
@@ -722,7 +768,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
@@ -746,7 +793,8 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  WantDiagnostics::Yes, [&](std::vector D) {
+  WantDiagnostics::Yes,
+  [&](std::vector D) {
 Diagnostics = std::move(D);
 Ready.notify();
   });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -436,7 +436,8 @@
 }
 
 std::shared_ptr OldPreamble =
-getPossiblyStalePreamble();
+Inputs.ForceRebuild ? std::shared_ptr()
+: getPossiblyStalePreamble();
 std::shared_ptr NewPreamble = buildPreamble(
 FileName, *Invocation, OldPreamble, OldCommand, Inputs,
 StorePreambleInMemory,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -652,6 +652,12 @@
   /// either they will be provided for this version or some subsequent one.
   /// This is a clangd extension.
   llvm::Optional wantDiagnostics;
+
+  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
+  /// This is useful to defeat clangd's assumption that missing headers will
+  /// stay missing.
+  /// This is a clangd extension.
+  bool forceRebuild = false;
 };
 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -430,7 +430,10 @@
 
 bool fromJSON(const llvm::json::Value , 

[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus closed this revision.
Szelethus added a comment.

Cheers!


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

https://reviews.llvm.org/D73966



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D71600#1867135 , @efriedma wrote:

> For the clang change, we should do something like D72579 
> , not explicitly check for a specific target 
> in target-independent code.


right, I'll retest everything using D72579 .

> For compiler-rt, are you really disabling COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN? 
>  Are you sure you understand the implications of that?

I didn't  understood "disable COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN", it's not 
intentional. 
If it's the change around atomic.c:131, what I expect is make IS_LOCK_FREE_8 
return false. I don't want it to make to __c11_atomic_is_lock_free(8) as it 
generates code that should be linked with a libatomic at run time.

> I'm also curious: what part of clang is calling __atomic_is_lock_free?  I 
> can't find any code in LLVM that calls it.

hm, I'm afraid I was not clear in this. When generating FreeBSD images, the 
libc cross-compiled by unpatched clang gets an entry to external call to 
__c11_atomic_is_lock_free(). Then, in the resulting system (new sysroot) I get 
this problem (libatomic dependency) when trying to build clang itself.
While testing with D72579  I'll try reproduce 
it again and will post more info here since I don't have the build logs anymore 
(I investigated it ~6 months ago).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These are in some sense the inverse of vmovl[bt]q: they take a vector
of n wide elements and truncate each to half its width. So they only
write half a vector's worth of output data, and therefore they also
take an 'inactive' parameter to provide the other half of the data in
the output vector. So vmovnb overwrites the even lanes of 'inactive'
with the narrowed values from the main input, and vmovnt overwrites
the odd lanes.

LLVM had existing codegen which generates these MVE instructions in
response to IR that takes two vectors of wide elements, or two vectors
of narrow ones. But in this case, we have one vector of each. So my
clang codegen strategy is to narrow the input vector of wide elements
by simply reinterpreting it as the output type, and then we have two
narrow vectors and can represent the operation as a vector shuffle
that interleaves lanes from both of them.

Even so, not all the cases I needed ended up being selected as a
single MVE instruction, so I've added a couple more patterns that spot
combinations of the 'MVEvmovn' and 'ARMvrev32' SDNodes which can be
generated as a VMOVN instruction with operands swapped.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovnbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = bitcast <16 x i8> %0 to <8 x i16>
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovnbq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnb.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = bitcast <8 x i16> %0 to <4 x i32>
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> %a to <8 x i16>
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmovntq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <8 x i16> %a to <4 x i32>
+  %1 = shufflevector <4 x i32> %0, <4 x i32> %b, <8 x i32> 
+  %2 = trunc <8 x i32> %1 to <8 x i16>
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vmovntq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovnt.i16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <16 x i8> 

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These intrinsics take a vector of 2n elements, and return a vector of
n wider elements obtained by sign- or zero-extending every other
element of the input vector. They're represented in IR as a
shufflevector that extracts the odd or even elements of the input,
followed by a sext or zext.

Existing LLVM codegen already matches this pattern and generates the
VMOVLB instruction (which widens the even-index input lanes). But no
existing isel rule was generating VMOVLT, so I've added some. However,
the new rules currently only work in little-endian MVE, because the
pattern they expect from isel lowering includes a bitconvert which
doesn't have the right semantics in big-endian.

The output of one existing codegen test is improved by those new
rules.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74336

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
  llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Index: llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
===
--- llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
+++ llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
@@ -15,8 +15,7 @@
 define arm_aapcs_vfpcc <4 x i32> @sext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: sext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -38,8 +37,7 @@
 define arm_aapcs_vfpcc <4 x i32> @zext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: zext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -61,8 +59,7 @@
 define arm_aapcs_vfpcc <8 x i16> @sext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: sext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:vmovlt.s8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
@@ -84,8 +81,7 @@
 define arm_aapcs_vfpcc <8 x i16> @zext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: zext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:vmovlt.u8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
@@ -0,0 +1,90 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_u8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovlbq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = zext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_u16(<8 x i16> %a) {
+; CHECK-LABEL: test_vmovlbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = zext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vmovltq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmovlt.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = shufflevector 

[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me, just a nit about one of the comments.

Thanks for making this easier to review by splitting it up!




Comment at: llvm/include/llvm/Support/Process.h:205
+
+  /// When integrated-cc1 is disabled, terminate the current program.
+  /// When integrated-cc1 is enabled, terminates execution of the current

Could the comment be phrased in terms of CrashRecoveryContext instead of 
integrated-cc1, which is a Clang thing?


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

https://reviews.llvm.org/D73742



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


[PATCH] D74331: [ARM,MVE] Add intrinsics for abs, neg and not operations.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This commit adds the unpredicated intrinsics for the unary operations
vabsq (absolute value), vnegq (arithmetic negation), vmvnq (bitwise
complement), vqabsq and vqnegq (saturating versions of abs and neg for
signed integers, in the sense that they give INT_MAX if an input lane
is INT_MIN).

This is done entirely in clang: all of these operations have existing
isel patterns and existing tests for them on the LLVM side, so I've
just made clang emit the same IR that those patterns already match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74331

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Index: clang/test/CodeGen/arm-mve-intrinsics/absneg.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -0,0 +1,338 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabsq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabsq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.fabs.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vabsq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <16 x i8> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <16 x i8> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> [[TMP1]], <16 x i8> [[A]]
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+//
+int8x16_t test_vabsq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <8 x i16> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <8 x i16> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[TMP1]], <8 x i16> [[A]]
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+int16x8_t test_vabsq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <4 x i32> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <4 x i32> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[TMP1]], <4 x i32> [[A]]
+// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+//
+int32x4_t test_vabsq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vmvnq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vmvnq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <4 x i32> [[A:%.*]], 
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vmvnq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u8(
+// CHECK-NEXT:  

[PATCH] D74335: [ARM,MVE] Add intrinsics vclzq and vclsq.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

vclzq maps nicely to the existing target-independent @llvm.ctlz IR
intrinsic. But vclsq ('count leading sign bits') has no corresponding
target-independent intrinsic, so I've made up @llvm.arm.mve.vcls.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74335

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vclz.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vclsq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vclsq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8> %a)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vclsq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vclsq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vclsq_s32(<4 x i32> %a) {
+; CHECK-LABEL: test_vclsq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32> %a)
+  ret <4 x i32> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8>)
+declare <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16>)
+declare <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -2076,6 +2076,13 @@
 (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
   def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
 (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
+
+  def : Pat<(v16i8 ( int_arm_mve_vcls (v16i8 MQPR:$val1))),
+(v16i8 ( MVE_VCLSs8 (v16i8 MQPR:$val1)))>;
+  def : Pat<(v4i32 ( int_arm_mve_vcls (v4i32 MQPR:$val1))),
+(v4i32 ( MVE_VCLSs32 (v4i32 MQPR:$val1)))>;
+  def : Pat<(v8i16 ( int_arm_mve_vcls (v8i16 MQPR:$val1))),
+(v8i16 ( MVE_VCLSs16 (v8i16 MQPR:$val1)))>;
 }
 
 class MVE_VABSNEG_int size, bit negate,
Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1161,5 +1161,7 @@
 
 def int_arm_mve_vrintn: Intrinsic<
   [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+def int_arm_mve_vcls: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
 
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vclz.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vclz.c
@@ -0,0 +1,132 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vclzq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vclzq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vclzq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x 

[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This adds the unpredicated forms of six different MVE intrinsics which
all round a vector of floating-point numbers to integer values,
leaving them still in FP format, differing only in rounding mode and
exception settings.

Five of them map to existing target-independent intrinsics in LLVM IR,
such as @llvm.trunc and @llvm.rint. The sixth, mapping to the `vrintn`
instruction, is done by inventing a target-specific intrinsic.

(`vrintn` behaves the same as `vrintx` in terms of the output value:
the side effects on the FPSCR flags are the only difference between
the two. But ACLE specifies separate user-callable intrinsics for the
two, so the side effects matter enough to make sure we generate the
right one of the two instructions in each case.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74333

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vrndnq_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vrndnq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half> %a)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vrndnq_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vrndnq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float> %a)
+  ret <4 x float> %0
+}
+
+declare <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half>)
+declare <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3179,6 +3179,10 @@
 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
   def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
+  def : Pat<(v4f32 (int_arm_mve_vrintn (v4f32 MQPR:$val1))),
+(v4f32 (MVE_VRINTf32N (v4f32 MQPR:$val1)))>;
+  def : Pat<(v8f16 (int_arm_mve_vrintn (v8f16 MQPR:$val1))),
+(v8f16 (MVE_VRINTf16N (v8f16 MQPR:$val1)))>;
 }
 
 class MVEFloatArithNeon, llvm_anyvector_ty>;
+
+def int_arm_mve_vrintn: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
@@ -0,0 +1,173 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrndaq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.round.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndaq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndaq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndaq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.floor.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndmq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return 

[PATCH] D74332: [ARM,MVE] Add intrinsics for int <-> float conversion.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This adds the unpredicated versions of the family of vcvtq intrinsics
that convert between a vector of floats and a vector of the same size
of integer. These are represented in IR using the standard fptosi,
fptoui, sitofp and uitofp operations, which existing LLVM codegen
already handles.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74332

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
@@ -4,6 +4,102 @@
 
 #include 
 
+// CHECK-LABEL: @test_vcvtq_f16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f16_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_u32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_s16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vcvtq_s16_f16(float16x8_t a)
+{
+return vcvtq_s16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_s32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vcvtq_s32_f32(float32x4_t a)
+{
+return vcvtq_s32_f32(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vcvtq_u16_f16(float16x8_t a)
+{
+return vcvtq_u16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vcvtq_u32_f32(float32x4_t a)
+{
+return vcvtq_u32_f32(a);
+}
+
 // CHECK-LABEL: @test_vcvttq_f16_f32(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vcvt.narrow(<8 x half> [[A:%.*]], <4 x float> [[B:%.*]], i32 1)
Index: clang/include/clang/Basic/arm_mve_defs.td
===
--- clang/include/clang/Basic/arm_mve_defs.td
+++ clang/include/clang/Basic/arm_mve_defs.td
@@ -121,6 +121,10 @@
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
+def sitofp: IRBuilder<"CreateSIToFP">;
+def uitofp: IRBuilder<"CreateUIToFP">;
+def fptosi: IRBuilder<"CreateFPToSI">;
+def fptoui: IRBuilder<"CreateFPToUI">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.
Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -332,6 +332,23 @@
   } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
+multiclass float_int_conversions {
+  defvar FVector = VecOf;
+  defvar IVector = VecOf;
+
+  let params = [IScalar], pnt = PNT_2Type in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # FScalar>;
+  let params = [FScalar], pnt = PNT_None in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # IScalar>;
+}
+
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : 

[PATCH] D74334: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

These intrinsics just reorder the lanes of a vector, so the natural IR
representation is as a shufflevector operation. Existing LLVM codegen
already recognizes those particular shufflevectors and generates the
MVE VREV instruction.

This commit adds the unpredicated forms only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74334

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vrev.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vrev.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrev.c
@@ -0,0 +1,215 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrev16q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev16q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev16q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev16q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev32q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev32q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev32q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vrev32q_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x half> [[A:%.*]], <8 x half> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrev32q_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev64q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev64q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 

[libunwind] 14798b4 - unwind: rename `__personality_routine` to `_Unwind_Personality_Fn`

2020-02-10 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-02-10T08:52:31-08:00
New Revision: 14798b44658c8b30b44afae20d0f391e88eb5bec

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

LOG: unwind: rename `__personality_routine` to `_Unwind_Personality_Fn`

This patch renames `__personality_routine` to `_Unwind_Personality_Fn`
in `unwind.h`. Both `unwind.h` from clang and GCC headers use this name
instead of `__personality_routine`. With this patch one is also able to
build libc++abi with libunwind support on Windows.

Patch by Markus Böck!

Added: 


Modified: 
libunwind/include/unwind.h
libunwind/src/Unwind-EHABI.cpp
libunwind/src/Unwind-seh.cpp
libunwind/src/Unwind-sjlj.c
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/src/UnwindLevel1.c

Removed: 




diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index b6cc70498b37..1d3444cd83b4 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -111,10 +111,9 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 
-typedef _Unwind_Reason_Code (*__personality_routine)
-  (_Unwind_State state,
-   _Unwind_Exception* exceptionObject,
-   struct _Unwind_Context* context);
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
+_Unwind_State state, _Unwind_Exception *exceptionObject,
+struct _Unwind_Context *context);
 #else
 struct _Unwind_Context;   // opaque
 struct _Unwind_Exception; // forward declaration
@@ -150,12 +149,9 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
  struct _Unwind_Context* context,
  void* stop_parameter );
 
-typedef _Unwind_Reason_Code (*__personality_routine)
-  (int version,
-   _Unwind_Action actions,
-   uint64_t exceptionClass,
-   _Unwind_Exception* exceptionObject,
-   struct _Unwind_Context* context);
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
+int version, _Unwind_Action actions, uint64_t exceptionClass,
+_Unwind_Exception *exceptionObject, struct _Unwind_Context *context);
 #endif
 
 #ifdef __cplusplus
@@ -387,10 +383,9 @@ typedef struct _DISPATCHER_CONTEXT DISPATCHER_CONTEXT;
 #endif
 // This is the common wrapper for GCC-style personality functions with SEH.
 extern EXCEPTION_DISPOSITION _GCC_specific_handler(EXCEPTION_RECORD *exc,
-   void *frame,
-   CONTEXT *ctx,
+   void *frame, CONTEXT *ctx,
DISPATCHER_CONTEXT *disp,
-   __personality_routine pers);
+   _Unwind_Personality_Fn 
pers);
 #endif
 
 #ifdef __cplusplus

diff  --git a/libunwind/src/Unwind-EHABI.cpp b/libunwind/src/Unwind-EHABI.cpp
index a23ba2cc7e0e..a8a64cbfd7e5 100644
--- a/libunwind/src/Unwind-EHABI.cpp
+++ b/libunwind/src/Unwind-EHABI.cpp
@@ -481,8 +481,8 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, 
_Unwind_Exception *except
 // If there is a personality routine, ask it if it will want to stop at
 // this frame.
 if (frameInfo.handler != 0) {
-  __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  _Unwind_Personality_Fn p =
+  (_Unwind_Personality_Fn)(long)(frameInfo.handler);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): calling personality function %p",
   static_cast(exception_object),
@@ -597,8 +597,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, 
unw_cursor_t *cursor
 
 // If there is a personality routine, tell it we are unwinding.
 if (frameInfo.handler != 0) {
-  __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  _Unwind_Personality_Fn p =
+  (_Unwind_Personality_Fn)(long)(frameInfo.handler);
   struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor);
   // EHABI #7.2
   exception_object->pr_cache.fnstart = frameInfo.start_ip;

diff  --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp
index 7647f2e0db0b..403ab2d77110 100644
--- a/libunwind/src/Unwind-seh.cpp
+++ b/libunwind/src/Unwind-seh.cpp
@@ -69,7 +69,7 @@ static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
 ///  b) Initiate a collided unwind to halt unwinding.
 _LIBUNWIND_EXPORT EXCEPTION_DISPOSITION
 _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
-  DISPATCHER_CONTEXT *disp, __personality_routine pers) {
+  DISPATCHER_CONTEXT *disp, _Unwind_Personality_Fn pers) {
   unw_cursor_t 

[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2020-02-10 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM - the PS4 behavior was confirmed off-list.


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

https://reviews.llvm.org/D69979



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-02-10 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D72675#1829866 , @hfinkel wrote:

> > I'm not sure whether this is deliberate (but it seems weird) or just a bug. 
> > I can ask the GCC developers ...
>
> Please do. If there's a rationale, we should know.


Sorry for the delay ... I've raised that question on the GCC list, and the 
opinion seems to be that the current behavior is indeed a bug -- however 
there's still discussion ongoing on what the proper fix ought to be.  I'll 
report back once we've agreed on a solution on the GCC side ...


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

https://reviews.llvm.org/D72675



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:731
+  }
+  return C.getNoteTag([Text, Name](BugReport ) -> std::string {
+  SmallString<256> Msg;

Szelethus wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > Szelethus wrote:
> > > > NoQ wrote:
> > > > > baloghadamsoftware wrote:
> > > > > > NoQ wrote:
> > > > > > > You'll need to check whether the container is actually of 
> > > > > > > interest to the bug report. We don't want notes to be added about 
> > > > > > > changes to irrelevant containers.
> > > > > > > 
> > > > > > > You can use a combination of "Report `BR` was emitted by one of 
> > > > > > > the iterator checkers" and "The memory region of the container is 
> > > > > > > marked as interesting" (while also actually marking it as 
> > > > > > > interesting in the checker).
> > > > > > > 
> > > > > > > Ideally we should instead make a new generic storage inside the 
> > > > > > > `BugReport` object, in order to pass down the interesting 
> > > > > > > information from the call site of `emitReport` ("Hi, i'm an 
> > > > > > > iterator checker who emitted this report and i'm interested in 
> > > > > > > changes made to the size of this container").
> > > > > > Are you sure in this? I already wondered how it works so I added a 
> > > > > > test that checks one container and changes another one and there 
> > > > > > were no note tags displayed for the one we did not check but 
> > > > > > change. See the last test.
> > > > > That's because you didn't do
> > > > > ```lang=c++
> > > > >   V2.cbegin();
> > > > >   V2.cend();
> > > > > ```
> > > > > in the beginning.
> > > > A similar conversation sparked up recently in between @boga95, 
> > > > @steakhal and me regarding reporting taintedness. Bug reports are fine 
> > > > up to the point where (in reverse) the first propagation happens, but 
> > > > finding out which value tainted the one that caused the report isn't 
> > > > handled at the moment. One idea was to mark the initial (again, in 
> > > > reverse) value as interesting, create a `NoteTag` at the point of 
> > > > propagation, where we should know which value was the cause of the 
> > > > spread, mark that interesting as well, etc.
> > > > 
> > > > If `NoteTag`s only emit a message when the concerning value is 
> > > > interesting, this should theoretically solve that problem. I guess you 
> > > > could say that we're propagating interestingness in reverse.
> > > > 
> > > > I'm not immediately sure if this idea was ever mentioned or implemented 
> > > > here.
> > > Yes, that's the intended solution to such problems. 
> > > `trackExpressionValue` works similarly, just with assignments instead of 
> > > taint propagations. And in both cases note tags are a much more 
> > > straightforward solution to the problem.
> > Yes, you are right. My problem now is that how to mark interesting when 
> > debugging? I I filter for interesting containers only, I lose my ability to 
> > debug. Should I create a debug function just for marking a container as 
> > interesting. Or is there such function already?
> I'm not immediately sure how interetingness ties into debugging, what 
> specific scenario are you thinking about?
In the test of the modeling checker we use debug checkers. They should be able 
to mark the container interesting to be able to test the not tags. I managed to 
solve problem, even in a somewhat unorthodox way.


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

https://reviews.llvm.org/D73720



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 243571.
baloghadamsoftware added a comment.

Only track the right container. Furthermore, minor updates according to the 
comments.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -analyzer-output=text -verify
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -analyzer-output=text -verify
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -20,14 +20,16 @@
   V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
-  clang_analyzer_express(clang_analyzer_container_begin(V)); //expected-warning{{$V.begin()}}
+  clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
 }
 
 void end(const std::vector ) {
   V.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
-  clang_analyzer_express(clang_analyzer_container_end(V)); //expected-warning{{$V.end()}}
+  clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end()}}
+   // expected-note@-1{{$V.end()}}
 }
 
 
@@ -48,8 +50,10 @@
   long B2 = clang_analyzer_container_begin(V2);
   long E2 = clang_analyzer_container_end(V2);
   V1 = std::move(V2);
-  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); //expected-warning{{TRUE}}
-  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); // expected-warning{{TRUE}}
+ // expected-note@-1{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); // expected-warning{{TRUE}}
+   // expected-note@-1{{TRUE}}
 }
 
 
@@ -63,6 +67,8 @@
 /// Design decision: extends containers to the ->RIGHT-> (i.e. the
 /// past-the-end position of the container is incremented).
 
+void clang_analyzer_dump(void*);
+
 void push_back(std::vector , int n) {
   V.cbegin();
   V.cend();
@@ -70,10 +76,13 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.push_back(n);
+  V.push_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+  // expected-note@-1{{Container 'V' extended to the right by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
   clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end() + 1}}
+   // expected-note@-1{{$V.end() + 1}}
 }
 
 /// emplace_back()
@@ -88,10 +97,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.emplace_back(n);
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+ // expected-note@-1{{Container 'V' extended to the right by 

[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Partial linking may lead to some incorrect results with global constructors. 
How are you going to handle this?




Comment at: 
clang/test/Driver/clang-offload-bundler-missing-size-section.cpp:1-44
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=o 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t_host.o,%t_device.o -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_device.o | FileCheck %s
+// CHECK:11
+

Very strange test. It should not contain standard includes. Also, it should not 
be an executable test, you have to check for the driver output or something 
similar



Comment at: clang/test/Driver/clang-offload-bundler-oo.cpp:1-18
+// REQUIRES: x86-registered-target
+// RUN: %clangxx -c %s -o %t_fat.o
+// RUN: %clangxx %t_fat.o -o %t.exe
+// RUN: clang-offload-bundler -type=oo 
-targets=host-x86_64-unknown-linux-gnu,openmp-x86_64-pc-linux-gnu 
-outputs=%t.o,%t_list.txt -inputs=%t_fat.o -unbundle
+// RUN: %t.exe %t_list.txt | FileCheck %s
+// CHECK:11
+// CHECK:222

Same about this test



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:84
"  o   - object\n"
+   "  oo  - object; output file is a list of unbundled 
objects\n"
"  gch - precompiled-header\n"

Hmm, are you going to introduce a new kind of output? It really requires RFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5086b3803ac: [analyzer] StdLibraryFunctionsChecker 
refactor: remove macros (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVector;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
   /// obviously uint32_t should be enough for all practical purposes.
-  typedef uint32_t ArgNoTy;
-  static const ArgNoTy Ret = std::numeric_limits::max();
+  typedef uint32_t 

[PATCH] D72876: Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-02-10 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0151ddc2e834: Create a clang-tidy check to warn when 
-dealloc is implemented inside an ObjC… (authored by mwyman, committed by 
benhamilton).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72876

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
  clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
  clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s objc-dealloc-in-category %t
+
+@interface NSObject
+// Used to quash warning about missing base class.
+- (void)dealloc;
+@end
+
+@interface Foo : NSObject
+@end
+
+@implementation Foo
+- (void)dealloc {
+  // No warning should be generated here.
+}
+@end
+
+@interface Bar : NSObject
+@end
+
+@interface Bar (BarCategory)
+@end
+
+@implementation Bar (BarCategory)
++ (void)dealloc {
+  // Should not trigger on class methods.
+}
+
+- (void)dealloc {
+  // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: category 'BarCategory' should not implement -dealloc [objc-dealloc-in-category]
+}
+@end
+
+@interface Baz : NSObject
+@end
+
+@implementation Baz
+- (void)dealloc {
+  // Should not trigger on implementation in the class itself, even with
+  // it declared in the category (below).
+}
+@end
+
+@interface Baz (BazCategory)
+// A declaration in a category @interface does not by itself provide an
+// overriding implementation, and should not generate a warning.
+- (void)dealloc;
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-dealloc-in-category
+
+objc-dealloc-in-category
+
+
+Finds implementations of ``-dealloc`` in Objective-C categories. The category
+implementation will override any ``-dealloc`` in the class implementation,
+potentially causing issues.
+
+Classes implement ``-dealloc`` to perform important actions to deallocate
+an object. If a category on the class implements ``-dealloc``, it will
+override the class's implementation and unexpected deallocation behavior
+may occur.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -232,6 +232,7 @@
`mpi-buffer-deref `_, "Yes"
`mpi-type-mismatch `_, "Yes"
`objc-avoid-nserror-init `_,
+   `objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
`objc-missing-hash `_,
`objc-property-declaration `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -81,13 +81,18 @@
   ` check.
 
   Checks for usages of identifiers reserved for use by the implementation.
-  
+
 - New :doc:`cert-oop57-cpp
   ` check.
-  
+
   Flags use of the `C` standard library functions ``memset``, ``memcpy`` and
   ``memcmp`` and similar derivatives on non-trivial types.
 
+- New :doc:`objc-dealloc-in-category
+  ` check.
+
+  Finds implementations of -dealloc in Objective-C categories.
+
 New check aliases
 ^
 
@@ -111,8 +116,8 @@
 
 - Improved :doc:`readability-redundant-string-init
   ` check now supports a
-  `StringNames` option enabling its application to custom string classes. The 
-  check now detects in class initializers and constructor initializers which 
+  `StringNames` option enabling its application to custom string classes. The
+  check now detects in class initializers and constructor initializers which
   are deemed to be redundant.
 
 Renamed checks
Index: clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "AvoidNSErrorInitCheck.h"
+#include "DeallocInCategoryCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "MissingHashCheck.h"
 #include 

[clang-tools-extra] 0151ddc - Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-02-10 Thread Ben Hamilton via cfe-commits

Author: Michael Wyman
Date: 2020-02-10T08:56:28-07:00
New Revision: 0151ddc2e834ab4949789cbed4e03a958284cd54

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

LOG: Create a clang-tidy check to warn when -dealloc is implemented inside an 
ObjC class category.

Summary: Such implementations may override the class's own implementation, and 
even be a danger in case someone later comes and adds one to the class itself. 
Most times this has been encountered have been a mistake.

Reviewers: stephanemoore, benhamilton, dmaclach

Reviewed By: stephanemoore, benhamilton, dmaclach

Subscribers: dmaclach, mgorny, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 
clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst
clang-tools-extra/test/clang-tidy/checkers/objc-dealloc-in-category.m

Modified: 
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/ObjCTidyModule.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/objc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
index 68dda6530f7f..1e39e02e7b92 100644
--- a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
   AvoidNSErrorInitCheck.cpp
+  DeallocInCategoryCheck.cpp
   ForbiddenSubclassingCheck.cpp
   MissingHashCheck.cpp
   ObjCTidyModule.cpp

diff  --git a/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp 
b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
new file mode 100644
index ..468065742670
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp
@@ -0,0 +1,46 @@
+//===--- DeallocInCategoryCheck.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 "DeallocInCategoryCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void DeallocInCategoryCheck::registerMatchers(MatchFinder *Finder) {
+  // This check should only be applied to Objective-C sources.
+  if (!getLangOpts().ObjC)
+return;
+
+  // Non-NSObject/NSProxy-derived objects may not have -dealloc as a special
+  // method. However, it seems highly unrealistic to expect many 
false-positives
+  // by warning on -dealloc in categories on classes without one of those
+  // base classes.
+  Finder->addMatcher(
+  objcMethodDecl(isInstanceMethod(), hasName("dealloc"),
+ hasDeclContext(objcCategoryImplDecl().bind("impl")))
+  .bind("dealloc"),
+  this);
+}
+
+void DeallocInCategoryCheck::check(const MatchFinder::MatchResult ) {
+  const auto *DeallocDecl = Result.Nodes.getNodeAs("dealloc");
+  const auto *CID = Result.Nodes.getNodeAs("impl");
+  assert(DeallocDecl != nullptr);
+  diag(DeallocDecl->getLocation(), "category %0 should not implement -dealloc")
+  << CID;
+}
+
+} // namespace objc
+} // namespace tidy
+} // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h 
b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
new file mode 100644
index ..f8e1f70e216b
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.h
@@ -0,0 +1,36 @@
+//===--- DeallocInCategoryCheck.h - clang-tidy --*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_DEALLOCINCATEGORYCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_DEALLOCINCATEGORYCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds implementations of -dealloc in Objective-C categories. The category
+/// implementation will override any dealloc in the class implementation,
+/// potentially causing issues.
+///
+/// 

[clang] f5086b3 - [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-02-10T16:45:33+01:00
New Revision: f5086b3803ac2f908a734bbb2c7a50018fb3cd8c

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

LOG: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

Reviewers: NoQ

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 2cdee8da375e..e8668775ab85 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero 
value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@ class StdLibraryFunctionsChecker : public 
Checker {
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this 
function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef 

[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma requested changes to this revision.
efriedma added a comment.
This revision now requires changes to proceed.

For the clang change, we should do something like D72579 
, not explicitly check for a specific target 
in target-independent code.

For compiler-rt, are you really disabling COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN?  
Are you sure you understand the implications of that?

I'm also curious: what part of clang is calling __atomic_is_lock_free?  I can't 
find any code in LLVM that calls it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600



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


[clang] 5731b66 - Revert "[OpenMP] Fix unused variable"

2020-02-10 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-10T16:34:59+01:00
New Revision: 5731b6672ded5615f5489c892d7cdc9f4cf1836a

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

LOG: Revert "[OpenMP] Fix unused variable"

This breaks under asan, see 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/38597/steps/check-clang%20asan/logs/stdio

This reverts commit bb5045429545f47a76980864322a637c31594c7f.

Revert "[FIX] Ordering problem accidentally introduced with D72304"

This reverts commit 08c0a06d8f375e48d4acebac886bfdf19a2276ed.

Revert "[OpenMP][OMPIRBuilder] Add Directives (master and critical) to 
OMPBuilder."

This reverts commit e8a436c5ea26f69378e4c1cf3ddb5b647b201e0f.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/critical_codegen.cpp
clang/test/OpenMP/master_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPConstants.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b1fc6bb62adb..cd5f7c05 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3143,147 +3143,11 @@ static void emitMaster(CodeGenFunction , const 
OMPExecutableDirective ) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective ) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const CapturedStmt *CS = S.getInnermostCapturedStmt();
-const Stmt *MasterRegionBodyStmt = CS->getCapturedStmt();
-
-// TODO: Replace with a generic helper function for finalization
-auto FiniCB = [this](InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
-  assert(DestBB && "Finalization block should have one successor!");
-
-  // erase and replace with cleanup branch.
-  IPBB->getTerminator()->eraseFromParent();
-  Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = getJumpDestInCurrentScope(DestBB);
-  EmitBranchThroughCleanup(Dest);
-};
-
-// TODO: Replace with a generic helper function for emitting body
-auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock ) {
-  // Alloca insertion block should be in the entry block of the containing
-  // function So it expects an empty AllocaIP in which case will reuse the
-  // old alloca insertion point, or a new AllocaIP in the same block as the
-  // old one
-  assert((!AllocaIP.isSet() ||
-  AllocaInsertPt->getParent() == AllocaIP.getBlock()) &&
- "Insertion point should be in the entry block of containing "
- "function!");
-  auto OldAllocaIP = AllocaInsertPt;
-  if (AllocaIP.isSet())
-AllocaInsertPt = &*AllocaIP.getPoint();
-  auto OldReturnBlock = ReturnBlock;
-  ReturnBlock = getJumpDestInCurrentScope();
-
-  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
-  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
-CodeGenIPBBTI->eraseFromParent();
-
-  Builder.SetInsertPoint(CodeGenIPBB);
-
-  EmitStmt(MasterRegionBodyStmt);
-
-  if (Builder.saveIP().isSet())
-Builder.CreateBr();
-
-  AllocaInsertPt = OldAllocaIP;
-  ReturnBlock = OldReturnBlock;
-};
-CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
-CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, );
-Builder.restoreIP(OMPBuilder->CreateMaster(Builder, BodyGenCB, FiniCB));
-
-return;
-  }
   OMPLexicalScope Scope(*this, S, OMPD_unknown);
   emitMaster(*this, S);
 }
 
 void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective ) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const CapturedStmt *CS = S.getInnermostCapturedStmt();
-const Stmt *CriticalRegionBodyStmt = CS->getCapturedStmt();
-const Expr *Hint = nullptr;
-if (const auto *HintClause = S.getSingleClause())
-  Hint = HintClause->getHint();
-
-// TODO: This is slightly 
diff erent from what's currently being done in
- 

[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-02-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

this breaks under asan 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/38597/steps/check-clang%20asan/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304



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


[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2020-02-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 243553.
arsenm added a comment.

Rebase and fix check prefix name


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

https://reviews.llvm.org/D69979

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/test/Driver/default-denormal-fp-math.c

Index: clang/test/Driver/default-denormal-fp-math.c
===
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,19 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// crtfastmath enables ftz and daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s
+
+// crt not linked in with nostartfiles
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math -nostartfiles --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// If there's no crtfastmath, don't assume ftz/daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=/dev/null -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s
+
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-PRESERVESIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
   // capable of unit splitting.
   bool canSplitThinLTOUnit() const override { return false; }
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList ,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -300,7 +300,7 @@
 
 if (!Args.hasArg(options::OPT_nostartfiles)) {
   // Add crtfastmath.o if available and fast math is enabled.
-  TC.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
+  TC.addFastMathRuntimeIfAvailable(Args, CmdArgs);
 
   CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
 }
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -46,6 +46,11 @@
 
   std::vector ExtraOpts;
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList ,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType = nullptr) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -988,3 +988,22 @@
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
+
+llvm::DenormalMode Linux::getDefaultDenormalModeForType(
+  const llvm::opt::ArgList ,
+  Action::OffloadKind DeviceOffloadKind,
+  const llvm::fltSemantics *FPType) const {
+  switch (getTriple().getArch()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64: {
+std::string Unused;
+// DAZ and FTZ are turned on in crtfastmath.o
+if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
+isFastMathRuntimeAvailable(DriverArgs, Unused))
+  return llvm::DenormalMode::getPreserveSign();
+return llvm::DenormalMode::getIEEE();
+  }
+  default:
+return llvm::DenormalMode::getIEEE();
+  }
+}
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -502,7 +502,7 @@
 }
 
 // Add crtfastmath.o if available and fast math is enabled.
-ToolChain.AddFastMathRuntimeIfAvailable(Args, 

[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for the review guys!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:537-551
+  // The format is as follows:
   //{ "function name",
-  //  { spec:
+  //  { variant0:
   //{ argument types list, ... },
-  //return type, purity, { range set list:
+  //return type, purity, { specification list:
   //  { range list:
   //{ argument index, within or out of, {{from, to}, ...} },

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > I suspect that this comment would need a lot more updates.
> > Could you please elaborate? Do you mean to add comments e.g. to 
> > `ArgumentCondition` and the rest below? Or to rewrite the above comment?
> Actually let's ditch it entirely. It was worth it when it was all macros, so 
> that it was apparent how macros expanded, but now it's pretty 
> self-explanatory all the way.
> 
> Otherwise i was thinking about making this a pattern that the user can 
> copy-paste and fill in. Like, maybe, include all the constructors explicitly 
> (`Summary`, `ArgTypes`, etc.).
Ok, I ditched it.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:598
+  Summaries{
+  Summary(ArgTypes{IntTy}, RetType(IntTy), EvalCallAsPure)
+  // Boils down to isupper() or islower() or isdigit().

NoQ wrote:
> Just curious, can `RetType` also use curly braces?
Yes. I've changed it to use the curly braces with `RetType` too, now the format 
is more consistent with `ArgTypes`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-02-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 243552.
martong marked 7 inline comments as done.
martong added a comment.

- Ditch comment about (macro) format
- Use {} with RetType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -9,7 +9,7 @@
 // This checker improves modeling of a few simple library functions.
 // It does not generate warnings.
 //
-// This checker provides a specification format - `FunctionSummaryTy' - and
+// This checker provides a specification format - `Summary' - and
 // contains descriptions of some library functions in this format. Each
 // specification contains a list of branches for splitting the program state
 // upon call, and range constraints on argument and return-value symbols that
@@ -21,7 +21,7 @@
 // consider standard C function `ispunct(int x)', which returns a non-zero value
 // iff `x' is a punctuation character, that is, when `x' is in range
 //   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
-// `FunctionSummaryTy' provides only two branches for this function. However,
+// `Summary' provides only two branches for this function. However,
 // any attempt to describe this range with if-statements in the body farm
 // would result in many more branches. Because each branch needs to be analyzed
 // independently, this significantly reduces performance. Additionally,
@@ -30,13 +30,13 @@
 // which may lead to false positives because considering this particular path
 // was not consciously intended, and therefore it might have been unreachable.
 //
-// This checker uses eval::Call for modeling "pure" functions, for which
-// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
-// invalidation passes. Conflicts with other checkers are unlikely because
-// if the function has no other effects, other checkers would probably never
-// want to improve upon the modeling done by this checker.
+// This checker uses eval::Call for modeling pure functions (functions without
+// side effets), for which their `Summary' is a precise model. This avoids
+// unnecessary invalidation passes. Conflicts with other checkers are unlikely
+// because if the function has no other effects, other checkers would probably
+// never want to improve upon the modeling done by this checker.
 //
-// Non-"pure" functions, for which only partial improvement over the default
+// Non-pure functions, for which only partial improvement over the default
 // behavior is expected, are modeled via check::PostCall, non-intrusively.
 //
 // The following standard C functions are currently supported:
@@ -64,49 +64,48 @@
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
-  struct FunctionSummaryTy;
+  struct Summary;
 
   /// Specify how much the analyzer engine should entrust modeling this function
   /// to us. If he doesn't, he performs additional invalidations.
-  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+  enum InvalidationKind { NoEvalCall, EvalCallAsPure };
 
-  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// A pair of ValueRangeKind and IntRangeVector would describe a range
   /// imposed on a particular argument or return value symbol.
   ///
   /// Given a range, should the argument stay inside or outside this range?
   /// The special `ComparesToArgument' value indicates that we should
   /// impose a constraint that involves other argument or return value symbols.
-  enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
+  enum ValueRangeKind { OutOfRange, WithinRange, ComparesToArgument };
 
   // The universal integral type to use in value range descriptions.
   // Unsigned to make sure overflows are well-defined.
-  typedef uint64_t RangeIntTy;
+  typedef uint64_t RangeInt;
 
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVector;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
   /// obviously uint32_t should be enough for all practical purposes.
-  typedef uint32_t ArgNoTy;
-  static const ArgNoTy Ret = std::numeric_limits::max();
+  typedef uint32_t ArgNo;
+  static const 

Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-10 Thread John Marshall via cfe-commits
Thanks Aaron (and Hubert).

I've attached an updated patch that now includes new test cases alongside some 
existing "too few / too many" test cases in test/Sema/exprs.c. This splits the 
function declaration over two lines so it can use -verify to validate the 
source location's line (but not column). If you'd prefer a FileCheck approach 
to get the column too, I'm happy to do that but please advise whether it would 
be best to create a new test/Sema/foo.c file for these tests or to add to one 
of the existing test files.

Verified that without the patch, the notes are on the "MY_EXPORT void" line and 
the test cases fail. All tests still pass after this, after adjusting one 
existing FileCheck-based test case that also happens to exercise the patch's 
change.

John


On 7 Feb 2020, at 15:40, Aaron Ballman wrote:
> Thank you for the patch -- I think the changes look reasonable, but it
> should come with some test cases as well. Source location stuff is a
> bit onerous to try to test, but I think the best approach would be to
> add a new test that uses FileCheck instead of -verify so that you can
> validate the source location's line and column are as expected in the
> note. Once you have such a test (and have verified that no other tests
> fail with your changes), I'm happy to commit on your behalf.
> 
> ~Aaron
> 
> On Fri, Feb 7, 2020 at 10:23 AM Hubert Tong
>  wrote:
>> 
>> I think this looks okay. I think Richard or Aaron might be able to provide a 
>> more informed opinion.
>> 
>> -- HT


commit cbd4a4a155b40dc77c2ed82f397fe303dfc10837
Author: John Marshall 
AuthorDate: Mon Jan 20 14:58:14 2020 +
Commit: John Marshall 
CommitDate: Mon Feb 10 14:30:58 2020 +

Use getLocation() in "too few/too many arguments" diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

Add test cases alongside other "too few/too many arguments" tests.
Adjust column position in incidentally related FileCheck-based test.

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ffe72c98356..b9d7024f083 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);
diff --git a/clang/test/Misc/serialized-diags.c 
b/clang/test/Misc/serialized-diags.c
index e401477a2eb..2f4b86fb42f 100644
--- a/clang/test/Misc/serialized-diags.c
+++ b/clang/test/Misc/serialized-diags.c
@@ -56,7 +56,7 @@ void rdar11040133() {
 // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
{{.*[/\\]}}serialized-diags.c:22:18
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
'false' []
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
{{.*[/\\]}}serialized-diags.c:20:16
-// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
 // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to 
pointer conversion initializing 'char *' with an expression of type 'int' 
[-Wint-conversion]
 // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 
{{.*[/\\]}}serialized-diags.h:5:17
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from 
{{.*[/\\]}}serialized-diags.c:26: []
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 760c45e02f3..4e144041aca 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/test/Sema/exprs.c
@@ -163,12 +163,15 @@ void test17(int x) {
   x = sizeof(x/0);  // no warning.
 }
 
-// PR6501 & PR11857
+// PR6501, PR11857, and PR23564
 void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
 void test18_b(int); // expected-note {{'test18_b' declared here}}
 void test18_c(int a, int b); // expected-note 2 {{'test18_c' declared here}}
 void test18_d(int a, ...); // expected-note {{'test18_d' declared here}}
 void test18_e(int a, int b, ...); // expected-note {{'test18_e' declared here}}
+#define MY_EXPORT 

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

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> @erichkeane Thanks for filing the bugzilla bug. I was having some problems 
> with my bugzilla login myself and wasn't able to do so. I'll track progress 
> if this bug and decide shortly if my feature should imply no-integraed-cc1. 
> Thanks Guys.

I think that bug was for the problem of high memory usage when doing multiple 
compilations in one clang invocation.

I've filed https://bugs.llvm.org/show_bug.cgi?id=44865 for the interface stubs 
vs asan issue to keep track of it easier. Please cc yourselves and track 
progress there.


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] D74070: [Clang] Don't let gen crash diagnostics fail when '#pragma clang __debug crash' is used

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74070#1863989 , @aganea wrote:

> Relanded as rG75f09b54429bee17a96e2ba7a2ac0f0a8a7f7e74 
> .


Pushed that to 10.x as 0e1c734fa5b88ec7efc2bcf8d45ed58f6ba48b91 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74070



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


[PATCH] D74076: [Clang][Driver] Remove -M group options before generating crash diagnostics

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74076#1863987 , @aganea wrote:

> Relanded as rG75f09b54429bee17a96e2ba7a2ac0f0a8a7f7e74 
> 


Pushed that to 10.x as 0e1c734fa5b88ec7efc2bcf8d45ed58f6ba48b91 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74076



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


[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

LGTM, thanks again!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:537-551
+  // The format is as follows:
   //{ "function name",
-  //  { spec:
+  //  { variant0:
   //{ argument types list, ... },
-  //return type, purity, { range set list:
+  //return type, purity, { specification list:
   //  { range list:
   //{ argument index, within or out of, {{from, to}, ...} },

martong wrote:
> NoQ wrote:
> > I suspect that this comment would need a lot more updates.
> Could you please elaborate? Do you mean to add comments e.g. to 
> `ArgumentCondition` and the rest below? Or to rewrite the above comment?
Actually let's ditch it entirely. It was worth it when it was all macros, so 
that it was apparent how macros expanded, but now it's pretty self-explanatory 
all the way.

Otherwise i was thinking about making this a pattern that the user can 
copy-paste and fill in. Like, maybe, include all the constructors explicitly 
(`Summary`, `ArgTypes`, etc.).



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:598
+  Summaries{
+  Summary(ArgTypes{IntTy}, RetType(IntTy), EvalCallAsPure)
+  // Boils down to isupper() or islower() or isdigit().

Just curious, can `RetType` also use curly braces?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-02-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 243545.
njames93 added a comment.

- Relaxed corresponding header
- Added support for tag types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-missing-header-file-declaration.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/misc-missing-header-file-declaration.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/wrong_header.h
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration-any-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp
@@ -0,0 +1,102 @@
+// RUN: %check_clang_tidy %s misc-missing-header-file-declaration %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN: [{key: misc-missing-header-file-declaration.CheckCorrespondingHeaders, value: 1}]}' \
+// RUN: -- -I%S/Inputs/misc-missing-header-file-declaration
+
+#include "misc-missing-header-file-declaration.h"
+#include "wrong_header.h"
+
+// These declarations should be ignored by the check as they are in the same
+// file.
+extern bool DeclInSource;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInSource' is declared as extern in a source file
+extern void declInSource();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInSource' is declared as extern in a source file
+
+// These declarations should be ignored by the check as they are in the same
+// file, however there is a corresponding decl in the header that will prevent
+// a failing check.
+extern bool DeclInBoth;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Variable 'DeclInBoth' is declared as extern in a source file
+extern void declInBoth();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Function 'declInBoth' is declared as extern in a source file
+
+// No external linkage so no warning
+static bool StaticOK = false;
+constexpr bool ConstexprOK = false;
+inline void inlineOK() {}
+static void staticOK() {}
+constexpr bool constexprOK() { return true; }
+
+// External linkage but decl in header so no warning
+bool DeclInHeader = false;
+bool DeclInBoth = false;
+void declInHeader() {}
+void declInBoth() {}
+
+//Decls don't appear in corresponding header so issue a warning
+bool DeclInSource = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInSource' is defined with external linkage
+bool NoDecl = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'NoDecl' is defined with external linkage
+void declInSource() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInSource' is defined with external linkage
+void noDecl() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'noDecl' is defined with external linkage
+
+bool DeclInWrongHeader = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'DeclInWrongHeader' is defined with external linkage
+void declInWrongHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'declInWrongHeader' is defined with external linkage
+
+// Decls in an anonymous namespace don't have external linkage, so no warning
+// should be emitted
+namespace {
+bool AnonNS = false;
+void anonNS() {}
+} // namespace
+
+// Ensure in namespace definitions are correctly resolved
+namespace ns1 {
+bool NS = false;
+void nS() {}
+} // namespace ns1
+
+// Ensure out of namespace definitions are correctly resolved
+bool /*namespace*/ ns2::NS = false;
+void /*namespace*/ ns2::nS() {}
+
+// Static class members declared in the header shouldn't be warned on.
+int /*struct*/ Foo::Bar = 0;
+
+// main is special, don't warn for it.
+int main() {
+}
+
+template 
+void templateFuncNoHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'templateFuncNoHeader' is defined with external linkage
+
+// Warn on explicit instantiations
+template <>
+void templateFuncNoHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'templateFuncNoHeader' is defined with external linkage
+
+static void foo() {
+  // We don't want warnings for these implicit instantations
+  templateFuncNoHeader();
+  templateFuncNoHeader();
+}
+
+struct SNoHeader {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Struct 'SNoHeader' is defined with external linkage
+
+namespace {

[PATCH] D74063: [Clang] Remove #pragma clang __debug handle_crash

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Cherry-picked to 10.x in 793d643f6d69e6908a6ece4aacb07b6573e33e18 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74063



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


[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Pushed to 10.x in 64515b35844b925bdb76821d03ad4d7ddebe06e7 
. Thanks!


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

https://reviews.llvm.org/D73966



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


[clang] fcea7fb - CWG2445: For function template partial ordering, take reversal of

2020-02-10 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-10T06:07:48-08:00
New Revision: fcea7fbdba1bdf26e2a858a6be2865e6267da023

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

LOG: CWG2445: For function template partial ordering, take reversal of
function arguments into account when forming P/A pairs.

Added: 


Modified: 
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/operator-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 1394c6236965..a274102ceb11 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -850,6 +850,8 @@ class Sema;
   return static_cast(RewriteKind);
 }
 
+bool isReversed() const { return getRewriteKind() & CRK_Reversed; }
+
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3e6856048725..d664e4822e14 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7964,12 +7964,10 @@ class Sema final {
 SourceLocation ReturnLoc,
 Expr *, AutoType *AT);
 
-  FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
-   FunctionTemplateDecl *FT2,
-   SourceLocation Loc,
-   TemplatePartialOrderingContext TPOC,
-   unsigned NumCallArguments1,
-   unsigned NumCallArguments2);
+  FunctionTemplateDecl *getMoreSpecializedTemplate(
+  FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc,
+  TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
+  unsigned NumCallArguments2, bool Reversed = false);
   UnresolvedSetIterator
   getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
  TemplateSpecCandidateSet ,

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 858e7ae34a7f..003d9bb3a97d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -8392,7 +8392,7 @@ class BuiltinOperatorOverloadBuilder {
   // We interpret "same parameter-type-list" as applying to the
   // "synthesized candidate, with the order of the two parameters
   // reversed", not to the original function.
-  bool Reversed = C->RewriteKind & CRK_Reversed;
+  bool Reversed = C->isReversed();
   QualType FirstParamType = C->Function->getParamDecl(Reversed ? 1 : 0)
 ->getType()
 .getUnqualifiedType();
@@ -9478,7 +9478,7 @@ bool clang::isBetterOverloadCandidate(
 
 case ImplicitConversionSequence::Worse:
   if (Cand1.Function && Cand1.Function == Cand2.Function &&
-  (Cand2.RewriteKind & CRK_Reversed) != 0) {
+  Cand2.isReversed()) {
 // Work around large-scale breakage caused by considering reversed
 // forms of operator== in C++20:
 //
@@ -9566,14 +9566,13 @@ bool clang::isBetterOverloadCandidate(
   //  according to the partial ordering rules described in 14.5.5.2, or,
   //  if not that,
   if (Cand1IsSpecialization && Cand2IsSpecialization) {
-if (FunctionTemplateDecl *BetterTemplate
-  = S.getMoreSpecializedTemplate(Cand1.Function->getPrimaryTemplate(),
- Cand2.Function->getPrimaryTemplate(),
- Loc,
-   isa(Cand1.Function)? TPOC_Conversion
- : TPOC_Call,
- Cand1.ExplicitCallArguments,
- Cand2.ExplicitCallArguments))
+if (FunctionTemplateDecl *BetterTemplate = S.getMoreSpecializedTemplate(
+Cand1.Function->getPrimaryTemplate(),
+Cand2.Function->getPrimaryTemplate(), Loc,
+isa(Cand1.Function) ? TPOC_Conversion
+   : TPOC_Call,
+Cand1.ExplicitCallArguments, Cand2.ExplicitCallArguments,
+Cand1.isReversed() ^ Cand2.isReversed()))
   return BetterTemplate == Cand1.Function->getPrimaryTemplate();
   }
 
@@ -11298,7 +11297,7 @@ 

[PATCH] D73897: [analyzer] StdLibraryFunctionsChecker refactor: remove macros

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added a comment.
Herald added a subscriber: steakhal.

Ping @NoQ




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:42-49
 // The following standard C functions are currently supported:
 //
 //   fgetc  getline   isdigit   isupper
 //   fread  isalnum   isgraph   isxdigit
 //   fwrite isalpha   islower   read
 //   getc   isascii   isprint   write
 //   getcharisblank   ispunct

Szelethus wrote:
> martong wrote:
> > Szelethus wrote:
> > > I would prefer to just have a checker option that could print out the 
> > > currently modeled function rather than these lines of a recipe for 
> > > outdated comments.
> > Yes I agree, especially because I am planning to add a plethora of new 
> > functions in the future. I think that would be the appropriate time to 
> > implement the checker option.
> Totally agreed! Thank you for the cleanup!
No, thanks for the review! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73897



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


[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

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

I missed out on the transition to github, so I suspect that the commit access 
will only be extended to it after tagging rc2. I think it would be better if 
you committed this on my behalf, thanks! :)


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

https://reviews.llvm.org/D73966



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


[PATCH] D74216: [clang-rename] Fix the missing template constructors.

2020-02-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:144
+  template
+  [[Foo]]();
+

nit: Maybe also add `^` to this one and the one below?



Comment at: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp:140
+if (RecordDecl->hasUserDeclaredConstructor())
+  for (const auto *MD : RecordDecl->decls())
+if (const auto *FTD = dyn_cast(MD))

nit: The naming is slightly confusing, this probably suggests MethodDecl 
instance, but it's not spelled anywhere and may be better to call it just `D`.



Comment at: clang/test/clang-rename/TemplateCtor.cpp:1
+class Foo { // CHECK: class Bar {
+public:

Nit: not sure if the new file is necessary, maybe just put this under 
.../Ctor.cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74216



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


[PATCH] D71600: PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

2020-02-10 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava updated this revision to Diff 243520.
adalava added a comment.

fix typo found by @dim


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71600

Files:
  clang/lib/AST/ExprConstant.cpp
  compiler-rt/lib/builtins/atomic.c


Index: compiler-rt/lib/builtins/atomic.c
===
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -119,13 +119,20 @@
   return locks + (hash & SPINLOCK_MASK);
 }
 
-/// Macros for determining whether a size is lock free.  Clang can not yet
-/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are
-/// not lock free.
+/// Macros for determining whether a size is lock free.
 #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1)
 #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2)
 #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4)
+
+/// 32 bit PowerPC doesn't support 8-byte lock_free atomics
+#if !defined(__powerpc64__) && defined(__powerpc__)
+#define IS_LOCK_FREE_8 0
+#else
 #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8)
+#endif
+
+/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume
+/// 16-byte values are not lock free.
 #define IS_LOCK_FREE_16 0
 
 /// Macro that calls the compiler-generated lock-free versions of functions
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11206,6 +11206,15 @@
   }
 }
 
+// Avoid emitting call for runtime decision on PowerPC 32-bit
+// The lock free possibilities on this platform are covered by the lines 
+// above and we know in advance other cases require lock.
+// This may need to be restricted to specific operating systems in the 
future,
+// as some (perhaps AIX) might provide libatomic and prefer to use it 
instead
+if (Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) {
+return Success(0, E);
+}
+
 return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
 Success(0, E) : Error(E);
   }


Index: compiler-rt/lib/builtins/atomic.c
===
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -119,13 +119,20 @@
   return locks + (hash & SPINLOCK_MASK);
 }
 
-/// Macros for determining whether a size is lock free.  Clang can not yet
-/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are
-/// not lock free.
+/// Macros for determining whether a size is lock free.
 #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1)
 #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2)
 #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4)
+
+/// 32 bit PowerPC doesn't support 8-byte lock_free atomics
+#if !defined(__powerpc64__) && defined(__powerpc__)
+#define IS_LOCK_FREE_8 0
+#else
 #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8)
+#endif
+
+/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume
+/// 16-byte values are not lock free.
 #define IS_LOCK_FREE_16 0
 
 /// Macro that calls the compiler-generated lock-free versions of functions
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11206,6 +11206,15 @@
   }
 }
 
+// Avoid emitting call for runtime decision on PowerPC 32-bit
+// The lock free possibilities on this platform are covered by the lines 
+// above and we know in advance other cases require lock.
+// This may need to be restricted to specific operating systems in the future,
+// as some (perhaps AIX) might provide libatomic and prefer to use it instead
+if (Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) {
+return Success(0, E);
+}
+
 return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
 Success(0, E) : Error(E);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-10 Thread Gabor Marton via Phabricator via cfe-commits
martong planned changes to this revision.
martong added a subscriber: steakhal.
martong added a comment.

Based on our verbal discussion with @Szelethus and @steakhal and based on the 
mailing archives 
, I am going 
to do the following changes:

- Add a new checker that is implemented in the `StdLibraryFunctionsChecker` 
class.
- This new checker if switched on is responsible for emitting the warning. Even 
if this is turned off, the sink node is generated if the argument violates the 
given condition.
- This means, the new checker has the sole responsibility of emitting the 
warning, but nothing more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D73966: [analyzer] Add 10.0.0 release notes.

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: steakhal.

Looks good to me. Thanks for writing release notes!

If you have commit access, go ahead and push directly to the branch, otherwise 
let me know and I'll be happy to do it for you.


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

https://reviews.llvm.org/D73966



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


[PATCH] D73636: [AArch64][SVE] SVE2 intrinsics for complex integer arithmetic

2020-02-10 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92a78750929b: [AArch64][SVE] SVE2 intrinsics for complex 
integer arithmetic (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D73636?vs=242683=243511#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73636

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
@@ -0,0 +1,106 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SADDLBT
+;
+
+define  @saddlbt_b( %a,  %b) {
+; CHECK-LABEL: saddlbt_b:
+; CHECK: saddlbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_h( %a,  %b) {
+; CHECK-LABEL: saddlbt_h:
+; CHECK: saddlbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_s( %a,  %b) {
+; CHECK-LABEL: saddlbt_s:
+; CHECK: saddlbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SSUBLBT
+;
+
+define  @ssublbt_b( %a,  %b) {
+; CHECK-LABEL: ssublbt_b:
+; CHECK: ssublbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_h( %a,  %b) {
+; CHECK-LABEL: ssublbt_h:
+; CHECK: ssublbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_s( %a,  %b) {
+; CHECK-LABEL: ssublbt_s:
+; CHECK: ssublbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SSUBLTB
+;
+
+define  @ssubltb_b( %a,  %b) {
+; CHECK-LABEL: ssubltb_b:
+; CHECK: ssubltb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssubltb_h( %a,  %b) {
+; CHECK-LABEL: ssubltb_h:
+; CHECK: ssubltb z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssubltb_s( %a,  %b) {
+; CHECK-LABEL: ssubltb_s:
+; CHECK: ssubltb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.saddlbt.nxv8i16(, )
+declare  @llvm.aarch64.sve.saddlbt.nxv4i32(, )
+declare  @llvm.aarch64.sve.saddlbt.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.ssublbt.nxv8i16(, )
+declare  @llvm.aarch64.sve.ssublbt.nxv4i32(, )
+declare  @llvm.aarch64.sve.ssublbt.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.ssubltb.nxv8i16(, )
+declare  @llvm.aarch64.sve.ssubltb.nxv4i32(, )
+declare  @llvm.aarch64.sve.ssubltb.nxv2i64(, )
Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
@@ -0,0 +1,267 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; CADD
+;
+
+define  @cadd_b( %a,  %b) {
+; CHECK-LABEL: cadd_b:
+; CHECK: cadd z0.b, z0.b, z1.b, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cadd.x.nxv16i8( %a,
+   %b,
+  i32 90)
+  ret  %out
+}
+
+define  @cadd_h( %a,  %b) {
+; CHECK-LABEL: cadd_h:
+; CHECK: cadd z0.h, z0.h, z1.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cadd.x.nxv8i16( %a,
+   %b,
+  i32 90)
+  ret  %out
+}
+
+define  @cadd_s( %a,  %b) {
+; CHECK-LABEL: cadd_s:
+; CHECK: cadd z0.s, z0.s, z1.s, #270
+; CHECK-NEXT: ret
+  %out = call  

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-02-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

Looking good to me as-is.

- Current naming is okay. But what do you think about reducing name of 
//quarter// intrinsics: `__builtin_msa_ldr_w` instead of 
`__builtin_msa_ldrq_w`? Will it clash with any future intrinsics' names?
- There is almost no documentation on target specific intrinsics. Some articles 
like Using ARM NEON instructions in big endian mode 
 cover specific use cases. It's up to 
you to write an article for these new intrinsics.


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

https://reviews.llvm.org/D73644



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


[PATCH] D73261: [dwarf5] Support DebugInfo for constexpr for C++ variables and functions

2020-02-10 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 243509.
awpandey added a comment.
Herald added a subscriber: ormris.

@probinson I have reimplemented the feature by using DIFlags.


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

https://reviews.llvm.org/D73261

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/constExpr.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/constExpr.ll

Index: llvm/test/DebugInfo/X86/constExpr.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/constExpr.ll
@@ -0,0 +1,118 @@
+; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; CHECK: .debug_info contents:
+
+; CHECK: DW_TAG_variable
+; CHECK-NEXT: DW_AT_name {{.*}} "bar"
+; CHECK: DW_AT_const_expr {{.*}} (true)
+
+; CHECK: DW_TAG_subprogram
+; CHECK: DW_AT_const_expr {{.*}} (true)
+; CHECK: DW_AT_linkage_name {{.*}} "_Z3funi"
+
+
+; C++ source to regenerate:
+
+;constexpr int bar = 10;
+;
+;constexpr int fun(int x) { return x * 2; }
+;
+;int main(int argc, char **argv) {
+;  int foo = bar;
+;  constexpr int baz = 10;
+;  int constVal = fun(10);
+;  return 0;
+;}
+
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+$_Z3funi = comdat any
+; Function Attrs: noinline norecurse optnone uwtable
+
+define dso_local i32 @main(i32 %argc, i8** %argv) #0 !dbg !13 {
+entry:
+  %retval = alloca i32, align 4
+  %argc.addr = alloca i32, align 4
+  %argv.addr = alloca i8**, align 8
+  %foo = alloca i32, align 4
+  %baz = alloca i32, align 4
+  %constVal = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  store i32 %argc, i32* %argc.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !19, metadata !DIExpression()), !dbg !20
+  store i8** %argv, i8*** %argv.addr, align 8
+  call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !21, metadata !DIExpression()), !dbg !22
+  call void @llvm.dbg.declare(metadata i32* %foo, metadata !23, metadata !DIExpression()), !dbg !24
+  store i32 10, i32* %foo, align 4, !dbg !24
+  call void @llvm.dbg.declare(metadata i32* %baz, metadata !25, metadata !DIExpression()), !dbg !26
+  store i32 10, i32* %baz, align 4, !dbg !26
+  call void @llvm.dbg.declare(metadata i32* %constVal, metadata !27, metadata !DIExpression()), !dbg !28
+  %call = call i32 @_Z3funi(i32 10), !dbg !29
+  store i32 %call, i32* %constVal, align 4, !dbg !28
+  ret i32 0, !dbg !30
+}
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local i32 @_Z3funi(i32 %x) #2 comdat !dbg !31 {
+entry:
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !34, metadata !DIExpression()), !dbg !35
+  %0 = load i32, i32* %x.addr, align 4, !dbg !36
+  %mul = mul nsw i32 %0, 2, !dbg !37
+  ret i32 %mul, !dbg !38
+}
+
+attributes #0 = { noinline norecurse optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+attributes #2 = { noinline nounwind optnone uwtable  }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/dir/test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 10, DW_OP_stack_value))
+!5 = distinct !DIGlobalVariable(name: "bar", scope: !0, file: !6, line: 13, type: !7, isLocal: true, isDefinition: true, flags: DIFlagConstExpr)
+!6 = !DIFile(filename: "/dir/test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "b973c468913ba52f145c9b21705fe0e0")
+!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
+!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!9 = !{i32 7, !"Dwarf Version", i32 5}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{i32 1, !"wchar_size", i32 4}
+!12 = !{!"clang version 11.0.0 "}
+!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line: 

[PATCH] D74129: Prefer __vector over vector keyword for altivec use

2020-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

It looks like the current code goes way back, to https://llvm.org/r39093 Do you 
know why it's started failing now?

Consistency is nice though, so I don't see any downside to this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74129



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


  1   2   >