[PATCH] D77621: ADT: SmallVector size & capacity use word-size integers when elements are small.

2020-04-22 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 259480.
browneee added a comment.

Switch approach back to std::vector change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77621

Files:
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/PCHContainerOperations.h
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/GlobalModuleIndex.cpp
  clang/lib/Serialization/PCHContainerOperations.cpp
  llvm/include/llvm/Bitcode/BitcodeWriter.h
  llvm/include/llvm/Bitstream/BitstreamWriter.h
  llvm/include/llvm/Remarks/BitstreamRemarkSerializer.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/tools/llvm-cat/llvm-cat.cpp
  llvm/tools/llvm-modextract/llvm-modextract.cpp
  llvm/unittests/Bitstream/BitstreamReaderTest.cpp
  llvm/unittests/Bitstream/BitstreamWriterTest.cpp

Index: llvm/unittests/Bitstream/BitstreamWriterTest.cpp
===
--- llvm/unittests/Bitstream/BitstreamWriterTest.cpp
+++ llvm/unittests/Bitstream/BitstreamWriterTest.cpp
@@ -8,27 +8,31 @@
 
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallString.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+#include 
+
 using namespace llvm;
 
+using ::testing::IsEmpty;
+
 namespace {
 
 TEST(BitstreamWriterTest, emitBlob) {
-  SmallString<64> Buffer;
+  std::vector Buffer;
   BitstreamWriter W(Buffer);
   W.emitBlob("str", /* ShouldEmitSize */ false);
-  EXPECT_EQ(StringRef("str\0", 4), Buffer);
+  EXPECT_EQ(StringRef("str\0", 4), StringRef(Buffer.data(), Buffer.size()));
 }
 
 TEST(BitstreamWriterTest, emitBlobWithSize) {
-  SmallString<64> Buffer;
+  std::vector Buffer;
   {
 BitstreamWriter W(Buffer);
 W.emitBlob("str");
   }
-  SmallString<64> Expected;
+  std::vector Expected;
   {
 BitstreamWriter W(Expected);
 W.EmitVBR(3, 6);
@@ -38,21 +42,21 @@
 W.Emit('r', 8);
 W.Emit(0, 8);
   }
-  EXPECT_EQ(StringRef(Expected), Buffer);
+  EXPECT_EQ(Expected, Buffer);
 }
 
 TEST(BitstreamWriterTest, emitBlobEmpty) {
-  SmallString<64> Buffer;
+  std::vector Buffer;
   BitstreamWriter W(Buffer);
   W.emitBlob("", /* ShouldEmitSize */ false);
-  EXPECT_EQ(StringRef(""), Buffer);
+  EXPECT_THAT(Buffer, IsEmpty());
 }
 
 TEST(BitstreamWriterTest, emitBlob4ByteAligned) {
-  SmallString<64> Buffer;
+  std::vector Buffer;
   BitstreamWriter W(Buffer);
   W.emitBlob("str0", /* ShouldEmitSize */ false);
-  EXPECT_EQ(StringRef("str0"), Buffer);
+  EXPECT_EQ(StringRef("str0"), StringRef(Buffer.data(), Buffer.size()));
 }
 
 } // end namespace
Index: llvm/unittests/Bitstream/BitstreamReaderTest.cpp
===
--- llvm/unittests/Bitstream/BitstreamReaderTest.cpp
+++ llvm/unittests/Bitstream/BitstreamReaderTest.cpp
@@ -11,6 +11,8 @@
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include "gtest/gtest.h"
 
+#include 
+
 using namespace llvm;
 
 namespace {
@@ -96,7 +98,7 @@
 StringRef BlobIn((const char *)BlobData.begin(), BlobSize);
 
 // Write the bitcode.
-SmallVector Buffer;
+std::vector Buffer;
 unsigned AbbrevID;
 {
   BitstreamWriter Stream(Buffer);
@@ -115,7 +117,7 @@
 
 // Stream the buffer into the reader.
 BitstreamCursor Stream(
-ArrayRef((const uint8_t *)Buffer.begin(), Buffer.size()));
+ArrayRef((const uint8_t *)Buffer.data(), Buffer.size()));
 
 // Header.  Included in test so that we can run llvm-bcanalyzer to debug
 // when there are problems.
Index: llvm/tools/llvm-modextract/llvm-modextract.cpp
===
--- llvm/tools/llvm-modextract/llvm-modextract.cpp
+++ llvm/tools/llvm-modextract/llvm-modextract.cpp
@@ -58,12 +58,12 @@
   ExitOnErr(errorCodeToError(EC));
 
   if (BinaryExtract) {
-SmallVector Result;
+std::vector Result;
 BitcodeWriter Writer(Result);
-Result.append(Ms[ModuleIndex].getBuffer().begin(),
+Result.insert(Result.end(), Ms[ModuleIndex].getBuffer().begin(),
   Ms[ModuleIndex].getBuffer().end());
 Writer.copyStrtab(Ms[ModuleIndex].getStrtab());
-Out->os() << Result;
+Out->os().write(Result.data(), Result.size());
 Out->keep();
 return 0;
   }
Index: llvm/tools/llvm-cat/llvm-cat.cpp
===
--- llvm/tools/llvm-cat/llvm-cat.cpp
+++ llvm/tools/llvm-cat/llvm-cat.cpp
@@ -54,7 +54,7 @@
   ExitOnError ExitOnErr("llvm-cat: 

[PATCH] D78693: Make "#pragma clang attribute" support uninitialized attribute.

2020-04-22 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Looks pretty good to me. Not my areas of expertise so I’d like to have others 
look too. Thanks for doing this!




Comment at: clang/test/Parser/pragma-attribute.cpp:190
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::uninitialized]], apply_to = variable) // 
expected-error {{attribute 'uninitialized' can't be applied to 'variable'}}
+#pragma clang attribute pop

Should variable work? Since it’s a superset of local it seems like maybe? But 
then again only local works, so ok not sure. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78693



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


[PATCH] D78694: [clang-format] Fix lambda with ellipsis in return type

2020-04-22 Thread Pochang Chen via Phabricator via cfe-commits
johnchen902 created this revision.
johnchen902 added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
johnchen902 retitled this revision from "[Format] Fix lambda with ellipsis in 
return type" to "[clang-format] Fix lambda with ellipsis in return type".
johnchen902 edited the summary of this revision.
johnchen902 added a reviewer: jkorous.
Herald added a subscriber: dexonsmith.

BTW my actual code that hit this issue is like

  [a, b = std::move(b)](auto &&... c) mutable -> 
std::invoke_result_t { /* omitted */ }

where this explicit return type is required for SFINAE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78694

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14111,6 +14111,8 @@
"-> int {\n"
"  return 1; //\n"
"};");
+  verifyFormat("[]() -> Void {};");
+  verifyFormat("[a, b]() -> Tuple { return {}; };");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1557,6 +1557,7 @@
 case tok::lessequal:
 case tok::question:
 case tok::colon:
+case tok::ellipsis:
 case tok::kw_true:
 case tok::kw_false:
   if (SeenArrow) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14111,6 +14111,8 @@
"-> int {\n"
"  return 1; //\n"
"};");
+  verifyFormat("[]() -> Void {};");
+  verifyFormat("[a, b]() -> Tuple { return {}; };");
 
   // Lambdas with explicit template argument lists.
   verifyFormat(
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1557,6 +1557,7 @@
 case tok::lessequal:
 case tok::question:
 case tok::colon:
+case tok::ellipsis:
 case tok::kw_true:
 case tok::kw_false:
   if (SeenArrow) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78693: Make "#pragma clang attribute" support uninitialized attribute.

2020-04-22 Thread Jian Cai via Phabricator via cfe-commits
jcai19 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When using -ftrivial-auto-var-init=* options to initiate automatic
variables in a file, to disable initialization on some variables,
currently we have to manually annotate the variables with uninitialized
attribute, such as

int dont_initialize_me __attribute((uninitialized));

Making pragma clang attribute to support this attribute would make
annotating variables much easier, and could be particular useful for
bisection efforts, e.g.

void use(void*);

void buggy() {

  int arr[256];
  int boom;
  float bam;
  struct { int oops; } oops;
  union { int oof; float a; } oof;
  
  use();
  use();
  use();
  use();
  use();

}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78693

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/CodeGenCXX/trivial-auto-var-init-attribute.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Parser/pragma-attribute.cpp

Index: clang/test/Parser/pragma-attribute.cpp
===
--- clang/test/Parser/pragma-attribute.cpp
+++ clang/test/Parser/pragma-attribute.cpp
@@ -63,14 +63,14 @@
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = hasType(functionType)) // OK
 
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable( )) // expected-error {{expected ')'}}
-#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable( ) )) // expected-error {{expected an identifier that corresponds to an attribute subject matcher sub-rule; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'}}
-#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable(is ) )) // expected-error {{unknown attribute subject matcher sub-rule 'is'; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'}}
+#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any(variable()))  // expected-error {{expected an identifier that corresponds to an attribute subject matcher sub-rule; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_local', 'is_parameter', 'unless(is_parameter)'}}
+#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any(variable(is)))  // expected-error {{unknown attribute subject matcher sub-rule 'is'; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_local', 'is_parameter', 'unless(is_parameter)'}}
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable(is_parameter, not) )) // expected-error {{expected ')'}} expected-note {{to match this '('}}
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable is_parameter )) // expected-error {{expected ')'}} expected-note {{to match this '('}}
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( variable ( ) // expected-error {{expected ')'}}
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = variable (  // expected-error {{expected ')'}}
-#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( function, variable (is ()) )) // expected-error {{unknown attribute subject matcher sub-rule 'is'; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'}}
-#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( function, variable (42) )) // expected-error {{expected an identifier that corresponds to an attribute subject matcher sub-rule; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'}}
+#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any(function, variable(is(  // expected-error {{unknown attribute subject matcher sub-rule 'is'; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_local', 'is_parameter', 'unless(is_parameter)'}}
+#pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any(function, variable(42)))// expected-error {{expected an identifier that corresponds to an attribute subject matcher sub-rule; 'variable' matcher supports the following sub-rules: 'is_thread_local', 'is_global', 'is_local', 'is_parameter', 'unless(is_parameter)'}}
 #pragma clang attribute push(__attribute__((annotate("test"))), apply_to = any( function, namespace("test") )) // expected-error {{expected an identifier that corresponds to an attribute subject matcher sub-rule; 'namespace' matcher does not support sub-rules}}
 #pragma clang attribute 

[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2020-04-22 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, this change that you submitted in commit 
5daa25fd7a184524759b6ad065a8bd7e95aa149a 
 seems to 
be causing the test "Clang-Unit :: 
Format/./FormatTests.exe/FormatTest.ConfigurableUseOfTab" to randomly fail 
about 50% of the time on Windows.

Take the most recent 5 runs of the 
llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast buildbot. Builds #31973 
,
 31975 

 and 31976 

 all failed because of that test failing.

On my local Windows computer, if I build your commit and run the FormatTest 
unit test multiple times (the same binary without changing anything or 
rebuilding), that above test fails roughly 50% of the time.

Can you take a look to figure out why your change might be causing this 
instability?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50078



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


[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-22 Thread Puyan Lotfi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2aa044ed088a: [NFC] Refactoring PropertyAttributeKind for 
ObjCPropertyDecl and ObjCDeclSpec. (authored by plotfi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclObjCCommon.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/ARCMigrate/TransGCAttrs.cpp
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h

Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -357,7 +357,8 @@
 };
 
 /// Constants for the DW_APPLE_PROPERTY_attributes attribute.
-/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
+/// Keep this list in sync with clang's DeclObjCCommon.h
+/// ObjCPropertyAttribute::Kind!
 enum ApplePropertyAttributes {
 #define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
 #include "llvm/BinaryFormat/Dwarf.def"
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -898,7 +898,8 @@
 HANDLE_DW_CFA_PRED(0x2e, GNU_args_size, SELECT_X86)
 
 // Apple Objective-C Property Attributes.
-// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
+// Keep this list in sync with clang's DeclObjCCommon.h
+// ObjCPropertyAttribute::Kind!
 HANDLE_DW_APPLE_PROPERTY(0x01, readonly)
 HANDLE_DW_APPLE_PROPERTY(0x02, getter)
 HANDLE_DW_APPLE_PROPERTY(0x04, assign)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -22,6 +22,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/StmtVisitor.h"
@@ -8146,11 +8147,10 @@
 
   unsigned Result = CXObjCPropertyAttr_noattr;
   const ObjCPropertyDecl *PD = dyn_cast(getCursorDecl(C));
-  ObjCPropertyDecl::PropertyAttributeKind Attr =
-  PD->getPropertyAttributesAsWritten();
+  ObjCPropertyAttribute::Kind Attr = PD->getPropertyAttributesAsWritten();
 
 #define SET_CXOBJCPROP_ATTR(A) \
-  if (Attr & ObjCPropertyDecl::OBJC_PR_##A)\
+  if (Attr & ObjCPropertyAttribute::kind_##A)  \
   Result |= CXObjCPropertyAttr_##A
   SET_CXOBJCPROP_ATTR(readonly);
   SET_CXOBJCPROP_ATTR(getter);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1280,10 +1280,9 @@
   QualType T = Record.readType();
   TypeSourceInfo *TSI = readTypeSourceInfo();
   D->setType(T, TSI);
-  D->setPropertyAttributes(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  D->setPropertyAttributes((ObjCPropertyAttribute::Kind)Record.readInt());
   D->setPropertyAttributesAsWritten(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttribute::Kind)Record.readInt());
   D->setPropertyImplementation(
   (ObjCPropertyDecl::PropertyControl)Record.readInt());
   DeclarationName GetterName = Record.readDeclarationName();
Index: clang/lib/Sema/SemaPseudoObject.cpp
===
--- clang/lib/Sema/SemaPseudoObject.cpp
+++ clang/lib/Sema/SemaPseudoObject.cpp
@@ -580,7 +580,7 @@
   QualType T;
   if (RefExpr->isExplicitProperty()) {
 const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
-if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
+if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
   return true;
 
 T = 

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

Can you please submit a squashed single commit for review against the master 
branch? All the recent commits seem to be relative to previous commits, and I 
am having trouble looking at the change as a whole.

The commit description needs some fixes:

1. Remove use of Title Case, in places like "using Fence instruction" and "LLVM 
Atomic Memory Ordering" and "as a String". They are simply common nouns, not 
proper nouns. When in doubt, look at the LangRef to see how these words are 
used as common nouns.
2. Don't mention that enum values are okay too. I am sure they will always be 
okay, but it's better to encourage the use of symbols.
3. Don't mention HSA even if the AMDGPU user manual does so.
4. In fact the last two sentences in the description are not strictly necessary 
... they are the logical outcome of the scopes being target-specific strings.
5. Note that the general practice in documentation is to say "AMDGPU" which 
covers the LLVM Target, while "amdgcn" is only used in the code because it is 
one of multiple architectures in the AMDGPU backend.




Comment at: clang/docs/LanguageExtensions.rst:2458
 
+AMDGCN specific builtins
+-

We probably don't need to document the new builtin here. Clearly, we have not 
documented any other AMDGPU builtin, and there is no need to start now. If 
necessary, we can take that up as a separate task covering all builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D77954: [CUDA][HIP] Fix host/device based overload resolution

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 259458.
yaxunl added a comment.

Revised to let host/device take precedence over multiversion, as John suggested.


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

https://reviews.llvm.org/D77954

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu

Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -331,9 +331,6 @@
 // If we have a mix of HD and H-only or D-only candidates in the overload set,
 // normal C++ overload resolution rules apply first.
 template  TemplateReturnTy template_vs_hd_function(T arg)
-#ifdef __CUDA_ARCH__
-//expected-note@-2 {{declared here}}
-#endif
 {
   return TemplateReturnTy();
 }
@@ -342,11 +339,13 @@
 }
 
 __host__ __device__ void test_host_device_calls_hd_template() {
-  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
-  TemplateReturnTy ret2 = template_vs_hd_function(1);
 #ifdef __CUDA_ARCH__
-  // expected-error@-2 {{reference to __host__ function 'template_vs_hd_function' in __host__ __device__ function}}
+  typedef HostDeviceReturnTy ExpectedReturnTy;
+#else
+  typedef TemplateReturnTy ExpectedReturnTy;
 #endif
+  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
+  ExpectedReturnTy ret2 = template_vs_hd_function(1);
 }
 
 __host__ void test_host_calls_hd_template() {
@@ -367,14 +366,14 @@
 __device__ DeviceReturnTy device_only_function(int arg) { return DeviceReturnTy(); }
 __device__ DeviceReturnTy2 device_only_function(float arg) { return DeviceReturnTy2(); }
 #ifndef __CUDA_ARCH__
-  // expected-note@-3 {{'device_only_function' declared here}}
-  // expected-note@-3 {{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
 #endif
 __host__ HostReturnTy host_only_function(int arg) { return HostReturnTy(); }
 __host__ HostReturnTy2 host_only_function(float arg) { return HostReturnTy2(); }
 #ifdef __CUDA_ARCH__
-  // expected-note@-3 {{'host_only_function' declared here}}
-  // expected-note@-3 {{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
 #endif
 
 __host__ __device__ void test_host_device_single_side_overloading() {
@@ -392,6 +391,37 @@
 #endif
 }
 
+// wrong-sided overloading should not cause diagnostic unless it is emitted.
+// This inline function is not emitted.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_no_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+  HostReturnTy ret3 = host_only_function(1);
+  HostReturnTy2 ret4 = host_only_function(1.0f);
+}
+
+// wrong-sided overloading should cause diagnostic if it is emitted.
+// This inline function is emitted since it is called by an emitted function.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+#ifndef __CUDA_ARCH__
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ function}}
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ function}}
+#endif
+  HostReturnTy ret3 = host_only_function(1);
+  HostReturnTy2 ret4 = host_only_function(1.0f);
+#ifdef __CUDA_ARCH__
+  // expected-error@-3 {{reference to __host__ function 'host_only_function' in __host__ __device__ function}}
+  // expected-error@-3 {{reference to __host__ function 'host_only_function' in __host__ __device__ function}}
+#endif
+}
+
+__host__ __device__ void test_host_device_wrong_side_overloading_inline_diag_caller() {
+  test_host_device_wrong_side_overloading_inline_diag();
+  // expected-note@-1 {{called by 'test_host_device_wrong_side_overloading_inline_diag_caller'}}
+}
+
 // Verify that we allow overloading function templates.
 template  __host__ T template_overload(const T ) { return a; };
 template  __device__ T template_overload(const T ) { return a; };
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9374,16 +9374,19 @@
   return Comparison::Equal;
 }
 
-static bool isBetterMultiversionCandidate(const OverloadCandidate ,
-  const OverloadCandidate ) {
+static Comparison
+isBetterMultiversionCandidate(const OverloadCandidate ,
+  const OverloadCandidate ) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function ||
   !Cand2.Function->isMultiVersion())
-return false;
+return 

[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 259452.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Add a negative test for lambda kernel. Add more checks to codegen test.


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

https://reviews.llvm.org/D78655

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/lambda.cu


Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int a;
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){ a = 1;};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function 
or static member function}}
+  lambda_kernel<<<1, 1>>>();
+  return 0;
+}
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] 
c"_Z1gIZ4mainEUlvE_EvT_\00"
+
+// Template instantiation for h.
+// HOST-LABEL: define internal void @_Z1hIZ4mainEUlvE_EvT_
+
+// HOST-LABEL: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+
+// Check lambda is not emitted in host compilation.
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check kernel is calling lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: call void @_ZZ4mainENKUlvE_clEv
+
+// Check lambda is emitted in device compilation and accessind device variable.
+// DEV-LABEL: define internal void @_ZZ4mainENKUlvE_clEv
+// DEV: store i32 1, i32* addrspacecast (i32 addrspace(1)* @a to i32*)
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+auto L = []() {};
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));


Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int a;
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){ a = 1;};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+  lambda_kernel<<<1, 1>>>();
+  return 0;
+}
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] c"_Z1gIZ4mainEUlvE_EvT_\00"
+
+// Template instantiation for h.
+// HOST-LABEL: define internal void @_Z1hIZ4mainEUlvE_EvT_
+
+// HOST-LABEL: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+
+// Check lambda is not emitted in host compilation.
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check kernel is calling lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: call void @_ZZ4mainENKUlvE_clEv
+
+// Check lambda is emitted in device compilation and accessind device variable.
+// DEV-LABEL: define 

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 259450.
asbirlea marked 8 inline comments as done.
asbirlea added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop , LoopAnalysisManager ,
 LoopStandardAnalysisResults ) {
 auto  = AM.getResult(L, AR);
-auto  = FAMP.getManager();
 Function  = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int , int ,
-   int ,
+   int , ModuleAnalysisManager ,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function , FunctionAnalysisManager ) {
 ++RunCount;
 
-const ModuleAnalysisManager  =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto  = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int 
   int 
   int 
+  ModuleAnalysisManager 
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));
 FPM.addPass(TestInvalidationFunctionPass("f"));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
@@ -482,7 +487,7 @@
   {
 FunctionPassManager FPM;
 

[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 259453.
yaxunl added a comment.

clean up test.


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

https://reviews.llvm.org/D78655

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/lambda.cu


Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int a;
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){ a = 1;};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function 
or static member function}}
+  lambda_kernel<<<1, 1>>>();
+  return 0;
+}
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] 
c"_Z1gIZ4mainEUlvE_EvT_\00"
+
+// Template instantiation for h.
+// HOST-LABEL: define internal void @_Z1hIZ4mainEUlvE_EvT_
+
+// HOST-LABEL: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+
+// Check lambda is not emitted in host compilation.
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check kernel is calling lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: call void @_ZZ4mainENKUlvE_clEv
+
+// Check lambda is emitted in device compilation and accessind device variable.
+// DEV-LABEL: define internal void @_ZZ4mainENKUlvE_clEv
+// DEV: store i32 1, i32* addrspacecast (i32 addrspace(1)* @a to i32*)
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));


Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int a;
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){ a = 1;};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+  lambda_kernel<<<1, 1>>>();
+  return 0;
+}
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] c"_Z1gIZ4mainEUlvE_EvT_\00"
+
+// Template instantiation for h.
+// HOST-LABEL: define internal void @_Z1hIZ4mainEUlvE_EvT_
+
+// HOST-LABEL: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+
+// Check lambda is not emitted in host compilation.
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check kernel is calling lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: call void @_ZZ4mainENKUlvE_clEv
+
+// Check lambda is emitted in device compilation and accessind device variable.
+// DEV-LABEL: define internal void @_ZZ4mainENKUlvE_clEv
+// DEV: store i32 1, i32* addrspacecast (i32 addrspace(1)* @a to i32*)

[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D78659#1997528 , @lebedev.ri wrote:

> 1. Tests missing
> 2. Why isn't `noinline` sufficient, why a whole new attribue?




1. Test added.
2. We want to avoid merging multiple call sites of same function, but 
`noinline` cannot achieve this. For example, we don't want to merge calls in `i 
== 5` and `i == 7` cases in the test case.


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

https://reviews.llvm.org/D78659



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


[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Analysis/CGSCCPassManager.h:856-858
+auto *ResultFAMCP =
+(*C, CG);
+ResultFAMCP->updateFAM(FAM);

chandlerc wrote:
> Check that it doesn't hit an assert failure, but I think you can remove this 
> one.
Removing this hits the assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72893



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaCUDA.cpp:722
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));

tra wrote:
> What about `__global__` lambdas? We probably don't want to add HD attributes 
> on them here.
lambda is not allowed to be kernel. I will add a lit test for that.



Comment at: clang/test/CodeGenCUDA/lambda.cu:16-26
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;

tra wrote:
> The test example may not be doing what it's seemingly supposed to be doing:
> https://cppinsights.io/s/3a5c42ff
> 
> `h()` gets a temporary host-side object which keeps the reference to `a` and 
> that reference will actually point to the host-side shadow of the actual 
> device-side `a`. When you get to execute `g` it's `this` may not be very 
> usable on device side and thus `f.operator()` will probably not work.
> 
> Alas, we currently have no diagnostics for that kind of error.
> 
> Change it to a non-capturing lambda, perhaps?
It works.

We need to think about this in device compilation. In device compilation, 
global variable is a device variable, the lambda is a device host function, 
therefore the lambda is accessing the real a, not the shadow.

In the host compilation, the lambda is not really called, therefore it is not 
emitted.

I will update the lit test with these checks.


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

https://reviews.llvm.org/D78655



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


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 259455.

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

https://reviews.llvm.org/D78659

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/attr-nomerge.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1287,6 +1287,14 @@
 if (!TTI.isProfitableToHoist(I1) || !TTI.isProfitableToHoist(I2))
   return Changed;
 
+// If any of the two call sites has nomerge attribute, stop hoisting.
+if (const auto *CB1 = dyn_cast(I1))
+  if (CB1->cannotMerge())
+return Changed;
+if (const auto *CB2 = dyn_cast(I2))
+  if (CB2->cannotMerge())
+return Changed;
+
 if (isa(I1) || isa(I2)) {
   assert (isa(I1) && isa(I2));
   // The debug location is an integral part of a debug info intrinsic
@@ -1472,8 +1480,9 @@
 // Conservatively return false if I is an inline-asm instruction. Sinking
 // and merging inline-asm instructions can potentially create arguments
 // that cannot satisfy the inline-asm constraints.
+// If the instruction has nomerge attribute, return false.
 if (const auto *C = dyn_cast(I))
-  if (C->isInlineAsm())
+  if (C->isInlineAsm() || C->cannotMerge())
 return false;
 
 // Each instruction must have zero or one use.
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1509,6 +1509,7 @@
 /// Return true if this attribute kind only applies to functions.
 static bool isFuncOnlyAttr(Attribute::AttrKind Kind) {
   switch (Kind) {
+  case Attribute::NoMerge:
   case Attribute::NoReturn:
   case Attribute::NoSync:
   case Attribute::WillReturn:
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -368,6 +368,8 @@
 return "noinline";
   if (hasAttribute(Attribute::NonLazyBind))
 return "nonlazybind";
+  if (hasAttribute(Attribute::NoMerge))
+return "nomerge";
   if (hasAttribute(Attribute::NonNull))
 return "nonnull";
   if (hasAttribute(Attribute::NoRedZone))
Index: llvm/include/llvm/IR/InstrTypes.h
===
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1717,6 +1717,9 @@
 addAttribute(AttributeList::FunctionIndex, Attribute::NoDuplicate);
   }
 
+  /// Determine if the invoke cannot be tail merged.
+  bool cannotMerge() const { return hasFnAttr(Attribute::NoMerge); }
+
   /// Determine if the invoke is convergent
   bool isConvergent() const { return hasFnAttr(Attribute::Convergent); }
   void setConvergent() {
Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -97,6 +97,9 @@
 /// Function is called early and/or often, so lazy binding isn't worthwhile.
 def NonLazyBind : EnumAttr<"nonlazybind">;
 
+/// Disable tail merge for this function
+def NoMerge : EnumAttr<"nomerge">;
+
 /// Pointer is known to be not null.
 def NonNull : EnumAttr<"nonnull">;
 
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
@@ -88,6 +88,7 @@
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
 // CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
Index: clang/test/CodeGen/attr-nomerge.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nomerge.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O2 -S -emit-llvm %s -o - | FileCheck %s
+
+void bar() __attribute__((nomerge));
+
+void foo(int i) {
+if (i == 5) {
+bar();
+}
+else if (i == 7) {
+bar();
+}
+bar();
+}
+// CHECK: tail call void
+// CHECK: tail call void
+// CHECK: tail call void
Index: clang/lib/CodeGen/CGCall.cpp

[clang] 391c15f - [NFC] Correct typo in comment after D76038

2020-04-22 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-04-23T02:26:02+02:00
New Revision: 391c15fccdc6b0d33bb651a298c07216e532904e

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

LOG: [NFC] Correct typo in comment after D76038

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 91875377679d..da8b25b497b0 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -871,11 +871,11 @@ class alignas(8) Decl {
 
   /// Returns true if this declaration is lexically inside a function or inside
   /// a variable initializer. It recognizes non-defining declarations as well
-  /// as members of local classes:
+  /// as members of local classes and lambdas:
   /// \code
   /// void foo() { void bar(); }
   /// void foo2() { class ABC { void bar(); }; }
-  /// inline int x = [](){ return 0; };
+  /// inline int x = [](){ return 0; }();
   /// \endcode
   bool isInLocalScope() const;
 



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


[PATCH] D78687: [Fuchsia] Build compiler-rt builtins for 32-bit x86

2020-04-22 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78687



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


[PATCH] D67112: [Sema] Introduce function reference conversion, NFC

2020-04-22 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

@rsmith, what do you think about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67112



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


[PATCH] D78687: [Fuchsia] Build compiler-rt builtins for 32-bit x86

2020-04-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, s.egerton, simoncook, mgorny, dberris.
Herald added a project: clang.

While we don't support 32-bit architectures in Fuchsia, these are needed
in the early boot phase on x86, so we build just these to satisfy that
use case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78687

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/lib/Basic/Targets.cpp


Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -480,6 +480,8 @@
   return new OpenBSDI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -105,15 +105,16 @@
 
 if(FUCHSIA_SDK)
   set(FUCHSIA_aarch64_NAME arm64)
+  set(FUCHSIA_i386_NAME x64)
   set(FUCHSIA_x86_64_NAME x64)
   set(FUCHSIA_riscv64_NAME riscv64)
-  foreach(target x86_64;aarch64;riscv64)
+  foreach(target i386;x86_64;aarch64;riscv64)
 set(FUCHSIA_${target}_COMPILER_FLAGS "-I${FUCHSIA_SDK}/pkg/fdio/include")
 set(FUCHSIA_${target}_LINKER_FLAGS 
"-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib")
 set(FUCHSIA_${target}_SYSROOT 
"${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot")
   endforeach()
 
-  foreach(target x86_64;aarch64;riscv64)
+  foreach(target i386;x86_64;aarch64;riscv64)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")


Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -480,6 +480,8 @@
   return new OpenBSDI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -105,15 +105,16 @@
 
 if(FUCHSIA_SDK)
   set(FUCHSIA_aarch64_NAME arm64)
+  set(FUCHSIA_i386_NAME x64)
   set(FUCHSIA_x86_64_NAME x64)
   set(FUCHSIA_riscv64_NAME riscv64)
-  foreach(target x86_64;aarch64;riscv64)
+  foreach(target i386;x86_64;aarch64;riscv64)
 set(FUCHSIA_${target}_COMPILER_FLAGS "-I${FUCHSIA_SDK}/pkg/fdio/include")
 set(FUCHSIA_${target}_LINKER_FLAGS "-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib")
 set(FUCHSIA_${target}_SYSROOT "${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot")
   endforeach()
 
-  foreach(target x86_64;aarch64;riscv64)
+  foreach(target i386;x86_64;aarch64;riscv64)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78192: Support compiler extensions as a normal component

2020-04-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

I looks to work fine under my Windows and Linux configuration. One Point though:

  llvm-config --libs Extensions

returns

  [...] -lPollyPPCG -lPollyISL -lPolly

I think `-lPolly` must be first to work with bfd.ld order semantics. See 
https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc
 , lld and Microsoft's link.exe don't care less about the order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78192



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


[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion

2020-04-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for the helping get the patch upstreamed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78661



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


[PATCH] D78030: [TimeProfiler] Emit clock synchronization point

2020-04-22 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2899103108d3: [TimeProfiler] Emit clock synchronization 
point (authored by broadwaylamb).

Changed prior to commit:
  https://reviews.llvm.org/D78030?vs=258061=259413#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78030

Files:
  clang/test/Driver/check-time-trace-sections.py
  clang/test/Driver/check-time-trace.cpp
  lld/test/ELF/time-trace.s
  llvm/lib/Support/TimeProfiler.cpp

Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -75,9 +75,9 @@
 
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
-  : StartTime(steady_clock::now()), ProcName(ProcName),
-Pid(sys::Process::getProcessId()), Tid(llvm::get_threadid()),
-TimeTraceGranularity(TimeTraceGranularity) {
+  : BeginningOfTime(system_clock::now()), StartTime(steady_clock::now()),
+ProcName(ProcName), Pid(sys::Process::getProcessId()),
+Tid(llvm::get_threadid()), TimeTraceGranularity(TimeTraceGranularity) {
 llvm::get_thread_name(ThreadName);
   }
 
@@ -234,12 +234,22 @@
 
 J.arrayEnd();
 J.attributeEnd();
+
+// Emit the absolute time when this TimeProfiler started.
+// This can be used to combine the profiling data from
+// multiple processes and preserve actual time intervals.
+J.attribute("beginningOfTime",
+time_point_cast(BeginningOfTime)
+.time_since_epoch()
+.count());
+
 J.objectEnd();
   }
 
   SmallVector Stack;
   SmallVector Entries;
   StringMap CountAndTotalPerName;
+  const time_point BeginningOfTime;
   const TimePointType StartTime;
   const std::string ProcName;
   const sys::Process::Pid Pid;
Index: lld/test/ELF/time-trace.s
===
--- lld/test/ELF/time-trace.s
+++ lld/test/ELF/time-trace.s
@@ -18,7 +18,8 @@
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 
-# CHECK: "traceEvents": [
+# CHECK:  "beginningOfTime": {{[0-9]{16},}}
+# CHECK-NEXT: "traceEvents": [
 
 # Check one event has correct fields
 # CHECK:  "dur":
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -3,18 +3,19 @@
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN:   | FileCheck %s
 
-// CHECK: "traceEvents": [
-// CHECK: "args":
-// CHECK: "detail":
-// CHECK: "dur":
-// CHECK: "name":
+// CHECK:  "beginningOfTime": {{[0-9]{16},}}
+// CHECK-NEXT: "traceEvents": [
+// CHECK:  "args":
+// CHECK:  "detail":
+// CHECK:  "dur":
+// CHECK:  "name":
 // CHECK-NEXT: "ph":
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang{{.*}}"
-// CHECK: "name": "process_name"
-// CHECK: "name": "thread_name"
+// CHECK:  "name": "clang{{.*}}"
+// CHECK:  "name": "process_name"
+// CHECK:  "name": "thread_name"
 
 template 
 struct Struct {
Index: clang/test/Driver/check-time-trace-sections.py
===
--- clang/test/Driver/check-time-trace-sections.py
+++ clang/test/Driver/check-time-trace-sections.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import json, sys
+import json, sys, time
 
 def is_inside(range1, range2):
 a = range1["ts"]; b = a + range1["dur"]
@@ -11,11 +11,22 @@
 b = range1["ts"] + range1["dur"]; c = range2["ts"]
 return b <= c
 
-events = json.loads(sys.stdin.read())["traceEvents"]
+log_contents = json.loads(sys.stdin.read())
+events = log_contents["traceEvents"]
 codegens = [event for event in events if event["name"] == "CodeGen Function"]
 frontends = [event for event in events if event["name"] == "Frontend"]
 backends = [event for event in events if event["name"] == "Backend"]
 
+beginning_of_time = log_contents["beginningOfTime"] / 100
+seconds_since_epoch = time.time()
+
+# Make sure that the 'beginningOfTime' is not earlier than 10 seconds ago
+# and not later than now.
+if beginning_of_time > seconds_since_epoch or \
+seconds_since_epoch - beginning_of_time > 10:
+sys.exit("'beginningOfTime' should represent the absolute time when the "
+ "process has started")
+
 if not all([any([is_inside(codegen, frontend) for frontend in frontends])
 for codegen in codegens]):
 sys.exit("Not all CodeGen sections are inside any Frontend section!")

[PATCH] D78252: [AArch64] FMLA/FMLS patterns improvement.

2020-04-22 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:8058
+  def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn),
+   (AArch64duplane16 (v8f16 V128:$Rm),
+   VectorIndexH:$idx))),

ilinpv wrote:
> ab wrote:
> > Should this be V128_lo?  I don't think this is encodable for Rm in V16-V31  
> > (same in the other indexed f16 variants I think)
> Yep, I double checked encoding, you are right. Thank you very much for this. 
> Fixed in 4eca1c06a4a9183fcf7bb230d894617caf3cf3be
Thanks Pavel!  I think this applies to the `AArch64dup` variants too, which 
does entail adding `FPR16Op_lo` and `FPR16_lo` I imagine, and maybe a couple 
more


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78252



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


[PATCH] D78677: [SveEmitter] Add builtins for gather prefetches

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen added a parent revision: D78674: [SveEmitter] Add builtins for 
contiguous prefetches.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78677

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -599,6 +599,12 @@
 Float = true;
 ElementBitwidth = 64;
 break;
+  case 'Q':
+Constant = true;
+Pointer = true;
+Void = true;
+NumVectors = 0;
+break;
   case 'S':
 Constant = true;
 Pointer = true;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
@@ -116,3 +116,151 @@
   // CHECK: @llvm.aarch64.sve.prf.nxv4i1( %[[PG]], i8* %[[I8_BASE]], i32 0)
   return svprfw_vnum(pg, base, vnum, SV_PLDL1KEEP);
 }
+
+void test_svprfw_gather_u32base(svbool_t pg, svuint32_t bases)
+{
+  // CHECK-LABEL: test_svprfw_gather_u32base
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.scalar.offset.nxv4i32( %[[PG]],  %bases, i64 0, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_u32base(pg, bases, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather(svbool_t pg, svuint32_t bases)
+{
+  // CHECK-LABEL: test_svprfw_gather
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.scalar.offset.nxv4i32( %[[PG]],  %bases, i64 0, i32 0)
+  // CHECK: ret void
+  return svprfw_gather(pg, bases, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_u64base(svbool_t pg, svuint64_t bases)
+{
+  // CHECK-LABEL: test_svprfw_gather_u64base
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.scalar.offset.nxv2i64( %[[PG]],  %bases, i64 0, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_u64base(pg, bases, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_1(svbool_t pg, svuint64_t bases)
+{
+  // CHECK-LABEL: test_svprfw_gather_1
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.scalar.offset.nxv2i64( %[[PG]],  %bases, i64 0, i32 0)
+  // CHECK: ret void
+  return svprfw_gather(pg, bases, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_s32index(svbool_t pg, const void *base, svint32_t indices)
+{
+  // CHECK-LABEL: test_svprfw_gather_s32index
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.sxtw.index.nxv4i32( %[[PG]], i8* %base,  %indices, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_s32index(pg, base, indices, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_index(svbool_t pg, const void *base, svint32_t indices)
+{
+  // CHECK-LABEL: test_svprfw_gather_index
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.sxtw.index.nxv4i32( %[[PG]], i8* %base,  %indices, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_index(pg, base, indices, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_s64index(svbool_t pg, const void *base, svint64_t indices)
+{
+  // CHECK-LABEL: test_svprfw_gather_s64index
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.index.nxv2i64( %[[PG]], i8* %base,  %indices, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_s64index(pg, base, indices, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_index_1(svbool_t pg, const void *base, svint64_t indices)
+{
+  // CHECK-LABEL: test_svprfw_gather_index_1
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: call void @llvm.aarch64.sve.prfw.gather.index.nxv2i64( %[[PG]], i8* %base,  %indices, i32 0)
+  // CHECK: ret void
+  return svprfw_gather_index(pg, base, indices, SV_PLDL1KEEP);
+}
+
+void test_svprfw_gather_u32index(svbool_t pg, const void *base, svuint32_t indices)
+{
+  // CHECK-LABEL: test_svprfw_gather_u32index
+  // CHECK: %[[PG:.*]] = call  

[PATCH] D78674: [SveEmitter] Add builtins for contiguous prefetches

2020-04-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM with a couple minor comments.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7727
+  Value *Offset = Ops.size() > 3 ? Ops[2] : Builder.getInt32(0);
+  BasePtr = Builder.CreateGEP(MemoryTy, BasePtr, Offset);
+

It seems sort of silly to emit a no-op bitcast+gep+bitcast in the `Ops.size() 
<= 3` case, but I guess it doesn't matter much.



Comment at: 
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c:22
+  // expected-error@+1 {{argument value -1 is outside the valid range [0, 13]}}
+  return svprfb(pg, base, -1);
+}

Maybe worth adding a negative test for svprfb_vnum?


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

https://reviews.llvm.org/D78674



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


[PATCH] D78673: [SveEmitter] Use llvm.aarch64.sve.ld1/st1 for contiguous load/store builtins

2020-04-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78673



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


[PATCH] D78642: [clang-format] Handle C# property accessors when parsing lines

2020-04-22 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 259409.
jbcoe added a comment.

Format patch


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

https://reviews.llvm.org/D78642

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,13 +245,11 @@
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host\n"
-   "{ set; get; }");
+   "public string Host { set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host\n"
-   "{ set; get; }");
+   "public string Host { set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -132,6 +132,7 @@
   void parseCSharpGenericTypeConstraint();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
+  bool tryToParsePropertyAccessor();
   void tryToParseJSFunction();
   void addUnwrappedLine();
   bool eof() const;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1334,7 +1334,7 @@
 parseChildBlock();
   break;
 case tok::l_brace:
-  if (!tryToParseBracedList()) {
+  if (!tryToParsePropertyAccessor() && !tryToParseBracedList()) {
 // A block outside of parentheses must be the last part of a
 // structural element.
 // FIXME: Figure out cases where this is not true, and add projections
@@ -1487,6 +1487,75 @@
   } while (!eof());
 }
 
+bool UnwrappedLineParser::tryToParsePropertyAccessor() {
+  assert(FormatTok->is(tok::l_brace));
+  if (!Style.isCSharp())
+return false;
+  // See if it's a property accessor.
+  if (FormatTok->Previous->isNot(tok::identifier))
+return false;
+
+  // Try to parse the property accessor braces and contents:
+  // `{ get; set; } = new MyType(defaultValue);`
+  //  ^
+  //
+  // Record the current tokenPosition so that we can advance and
+  // reset the current token. `Next` is not set yet so we need
+  // another way to advance along the token stream.
+  unsigned int StoredPosition = Tokens->getPosition();
+  FormatToken *Tok = Tokens->getNextToken();
+
+  bool HasGetOrSet = false;
+  while (!eof()) {
+if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
+ tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
+ Keywords.kw_set)) {
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
+HasGetOrSet = true;
+  Tok = Tokens->getNextToken();
+  continue;
+}
+if (Tok->is(tok::r_brace))
+  break;
+Tokens->setPosition(StoredPosition);
+return false;
+  }
+
+  if (!HasGetOrSet) {
+Tokens->setPosition(StoredPosition);
+return false;
+  }
+
+  Tokens->setPosition(StoredPosition);
+  while (FormatTok->isNot(tok::r_brace)) {
+nextToken();
+  }
+
+  // Try to parse (optional) assignment to default value:
+  // `{ get; set; } = new MyType(defaultValue);`
+  //^^^
+  // There may be some very complicated expressions inside default value
+  // assignment, the simple parse block below will not handle them.
+  // The parse block below would need extending to handle opening parens etc.
+  StoredPosition = Tokens->getPosition();
+  Tok = Tokens->getNextToken();
+  bool NextTokenIsEqual = Tok->is(tok::equal);
+  Tokens->setPosition(StoredPosition);
+
+  if (NextTokenIsEqual) {
+do {
+  nextToken();
+  if (FormatTok->is(tok::semi))
+break;
+} while (!eof());
+  }
+
+  // Add an unwrapped line for the whole property accessor.
+  nextToken();
+  addUnwrappedLine();
+  return true;
+}
+
 bool UnwrappedLineParser::tryToParseLambda() {
   if (!Style.isCpp()) {
 nextToken();
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -294,13 +294,6 @@
   }
 }
 
-// Try to merge a CSharp property declaration like `{ get; private set }`.
-if (Style.isCSharp()) {
-  unsigned CSPA = tryMergeCSharpPropertyAccessor(I, E, Limit);
-  if (CSPA > 0)
-return CSPA;
-}
-
 // Try to merge a function 

[clang] 2899103 - [TimeProfiler] Emit clock synchronization point

2020-04-22 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-04-23T01:09:31+03:00
New Revision: 2899103108d38215af8aae377cd0e54794278209

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

LOG: [TimeProfiler] Emit clock synchronization point

Time profiler emits relative timestamps for events (the number of
microseconds passed since the start of the current process).

This patch allows combining events from different processes while
preserving their relative timing by emitting a new attribute
"beginningOfTime". This attribute contains the system time that
corresponds to the zero timestamp of the time profiler.

This has at least two use cases:

- Build systems can use this to merge time traces from multiple compiler
  invocations and generate statistics for the whole build. Tools like
  ClangBuildAnalyzer could also leverage this feature.

- Compilers that use LLVM as their backend by invoking llc/opt in
  a child process. If such a compiler supports generating time traces
  of its own events, it could merge those events with LLVM-specific
  events received from llc/opt, and produce a more complete time trace.

A proof-of-concept script that merges multiple logs that
contain a synchronization point into one log:
https://github.com/broadwaylamb/merge_trace_events

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

Added: 


Modified: 
clang/test/Driver/check-time-trace-sections.py
clang/test/Driver/check-time-trace.cpp
lld/test/ELF/time-trace.s
llvm/lib/Support/TimeProfiler.cpp

Removed: 




diff  --git a/clang/test/Driver/check-time-trace-sections.py 
b/clang/test/Driver/check-time-trace-sections.py
index 7b598537a5b0..7551e5c19be5 100644
--- a/clang/test/Driver/check-time-trace-sections.py
+++ b/clang/test/Driver/check-time-trace-sections.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import json, sys
+import json, sys, time
 
 def is_inside(range1, range2):
 a = range1["ts"]; b = a + range1["dur"]
@@ -11,11 +11,22 @@ def is_before(range1, range2):
 b = range1["ts"] + range1["dur"]; c = range2["ts"]
 return b <= c
 
-events = json.loads(sys.stdin.read())["traceEvents"]
+log_contents = json.loads(sys.stdin.read())
+events = log_contents["traceEvents"]
 codegens = [event for event in events if event["name"] == "CodeGen Function"]
 frontends = [event for event in events if event["name"] == "Frontend"]
 backends = [event for event in events if event["name"] == "Backend"]
 
+beginning_of_time = log_contents["beginningOfTime"] / 100
+seconds_since_epoch = time.time()
+
+# Make sure that the 'beginningOfTime' is not earlier than 10 seconds ago
+# and not later than now.
+if beginning_of_time > seconds_since_epoch or \
+seconds_since_epoch - beginning_of_time > 10:
+sys.exit("'beginningOfTime' should represent the absolute time when the "
+ "process has started")
+
 if not all([any([is_inside(codegen, frontend) for frontend in frontends])
 for codegen in codegens]):
 sys.exit("Not all CodeGen sections are inside any Frontend section!")

diff  --git a/clang/test/Driver/check-time-trace.cpp 
b/clang/test/Driver/check-time-trace.cpp
index 1484462b72bb..1d80748a5233 100644
--- a/clang/test/Driver/check-time-trace.cpp
+++ b/clang/test/Driver/check-time-trace.cpp
@@ -3,18 +3,19 @@
 // RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN:   | FileCheck %s
 
-// CHECK: "traceEvents": [
-// CHECK: "args":
-// CHECK: "detail":
-// CHECK: "dur":
-// CHECK: "name":
+// CHECK:  "beginningOfTime": {{[0-9]{16},}}
+// CHECK-NEXT: "traceEvents": [
+// CHECK:  "args":
+// CHECK:  "detail":
+// CHECK:  "dur":
+// CHECK:  "name":
 // CHECK-NEXT: "ph":
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang{{.*}}"
-// CHECK: "name": "process_name"
-// CHECK: "name": "thread_name"
+// CHECK:  "name": "clang{{.*}}"
+// CHECK:  "name": "process_name"
+// CHECK:  "name": "thread_name"
 
 template 
 struct Struct {

diff  --git a/lld/test/ELF/time-trace.s b/lld/test/ELF/time-trace.s
index 8085a256649e..e1da4c476f40 100644
--- a/lld/test/ELF/time-trace.s
+++ b/lld/test/ELF/time-trace.s
@@ -18,7 +18,8 @@
 # RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 
-# CHECK: "traceEvents": [
+# CHECK:  "beginningOfTime": {{[0-9]{16},}}
+# CHECK-NEXT: "traceEvents": [
 
 # Check one event has correct fields
 # CHECK:  "dur":

diff  --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index c907c1aaf983..93bf6f57e348 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ 

[PATCH] D78674: [SveEmitter] Add builtins for contiguous prefetches

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 259403.
sdesmalen added a comment.

- Removed unrelated whitespace changes.


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

https://reviews.llvm.org/D78674

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -537,6 +537,15 @@
 Immediate = true;
 PredicatePattern = true;
 break;
+  case 'J':
+Predicate = false;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+Signed = true;
+Immediate = true;
+PrefetchOp = true;
+break;
   case 'k':
 Predicate = false;
 Signed = true;
@@ -704,6 +713,9 @@
   if (T.isPredicatePattern())
 ImmChecks.emplace_back(
 I - 1, Emitter.getEnumValueForImmCheck("ImmCheck0_31"));
+  else if (T.isPrefetchOp())
+ImmChecks.emplace_back(
+I - 1, Emitter.getEnumValueForImmCheck("ImmCheck0_13"));
 }
   }
 
@@ -1006,6 +1018,22 @@
   OS << "  SV_ALL = 31\n";
   OS << "} sv_pattern;\n\n";
 
+  OS << "typedef enum\n";
+  OS << "{\n";
+  OS << "  SV_PLDL1KEEP = 0,\n";
+  OS << "  SV_PLDL1STRM = 1,\n";
+  OS << "  SV_PLDL2KEEP = 2,\n";
+  OS << "  SV_PLDL2STRM = 3,\n";
+  OS << "  SV_PLDL3KEEP = 4,\n";
+  OS << "  SV_PLDL3STRM = 5,\n";
+  OS << "  SV_PSTL1KEEP = 8,\n";
+  OS << "  SV_PSTL1STRM = 9,\n";
+  OS << "  SV_PSTL2KEEP = 10,\n";
+  OS << "  SV_PSTL2STRM = 11,\n";
+  OS << "  SV_PSTL3KEEP = 12,\n";
+  OS << "  SV_PSTL3STRM = 13\n";
+  OS << "} sv_prfop;\n\n";
+
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+void test_svprfw(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value 14 is outside the valid range [0, 13]}}
+  return svprfw(pg, base, 14);
+}
+
+void test_svprfw_1(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value -1 is outside the valid range [0, 13]}}
+  return svprfw(pg, base, -1);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+void test_svprfh(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value 14 is outside the valid range [0, 13]}}
+  return svprfh(pg, base, 14);
+}
+
+void test_svprfh_1(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value -1 is outside the valid range [0, 13]}}
+  return svprfh(pg, base, -1);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
===
--- 

[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion

2020-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 259398.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Change RUN lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78661

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-float-conversion.c


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wno-implicit-int-float-conversion 
-Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCONST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 22;
@@ -12,7 +16,9 @@
   float  = UL; // expected-warning {{changes value from 
 to 1312}}
 
   long l = L;
+#ifdef NONCOST
   float fff = l; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
 
 void testExpression() {
@@ -24,7 +30,9 @@
   float c =  + 2223; // expected-warning {{implicit conversion 
from 'int' to 'float' changes value from 4445 to }}
 
   int i = 0;
+#ifdef NONCONST
   float d = i + a; // expected-warning {{implicit conversion from 'int' to 
'float' may lose precision}}
+#endif
 
   double e = 0.0;
   double f = i + e;
@@ -36,5 +44,7 @@
   float a = {L}; // expected-warning {{changes value from 
 to 1312}}
 
   long b = L;
+#ifdef NONCONST
   float c = {b}; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3549,7 +3549,7 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_float_precision_constant : Warning<
   "implicit conversion from %2 to %3 changes value from %0 to %1">,
-  InGroup;
+  InGroup;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -85,7 +85,9 @@
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
  
[ObjCSignedCharBoolImplicitIntConversion]>;
-def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
+def ImplicitConstIntFloatConversion : 
DiagGroup<"implicit-const-int-float-conversion">;
+def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion",
+ [ImplicitConstIntFloatConversion]>;
 def ObjCSignedCharBoolImplicitFloatConversion :
   DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
 def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wno-implicit-int-float-conversion -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCONST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 22;
@@ -12,7 +16,9 @@
   float  = UL; // expected-warning {{changes value from  to 1312}}
 
   long l = L;
+#ifdef NONCOST
   float fff = l; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+#endif
 }
 
 void testExpression() {
@@ -24,7 +30,9 @@
   float c =  + 2223; // expected-warning {{implicit conversion from 'int' to 'float' changes value from 4445 to }}
 
   int i = 0;
+#ifdef NONCONST
   float d = i + a; // expected-warning {{implicit conversion from 'int' to 'float' may lose precision}}
+#endif
 
   double e = 0.0;
   double f = i + 

[PATCH] D78027: [TimeProfiler] Emit real process ID and thread names

2020-04-22 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5bf02815d8b: [TimeProfiler] Emit real process ID and thread 
names (authored by broadwaylamb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78027

Files:
  clang/test/Driver/check-time-trace.cpp
  lld/test/ELF/time-trace.s
  llvm/lib/Support/TimeProfiler.cpp

Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -75,7 +76,10 @@
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
   : StartTime(steady_clock::now()), ProcName(ProcName),
-Tid(llvm::get_threadid()), TimeTraceGranularity(TimeTraceGranularity) {}
+Pid(sys::Process::getProcessId()), Tid(llvm::get_threadid()),
+TimeTraceGranularity(TimeTraceGranularity) {
+llvm::get_thread_name(ThreadName);
+  }
 
   void begin(std::string Name, llvm::function_ref Detail) {
 Stack.emplace_back(steady_clock::now(), TimePointType(), std::move(Name),
@@ -138,8 +142,8 @@
   auto StartUs = E.getFlameGraphStartUs(StartTime);
   auto DurUs = E.getFlameGraphDurUs();
 
-  J.object([&]{
-J.attribute("pid", 1);
+  J.object([&] {
+J.attribute("pid", Pid);
 J.attribute("tid", int64_t(Tid));
 J.attribute("ph", "X");
 J.attribute("ts", StartUs);
@@ -194,8 +198,8 @@
   auto DurUs = duration_cast(Total.second.second).count();
   auto Count = AllCountAndTotalPerName[Total.first].first;
 
-  J.object([&]{
-J.attribute("pid", 1);
+  J.object([&] {
+J.attribute("pid", Pid);
 J.attribute("tid", int64_t(TotalTid));
 J.attribute("ph", "X");
 J.attribute("ts", 0);
@@ -210,16 +214,23 @@
   ++TotalTid;
 }
 
-// Emit metadata event with process name.
-J.object([&] {
-  J.attribute("cat", "");
-  J.attribute("pid", 1);
-  J.attribute("tid", 0);
-  J.attribute("ts", 0);
-  J.attribute("ph", "M");
-  J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
-});
+auto writeMetadataEvent = [&](const char *Name, uint64_t Tid,
+  StringRef arg) {
+  J.object([&] {
+J.attribute("cat", "");
+J.attribute("pid", Pid);
+J.attribute("tid", int64_t(Tid));
+J.attribute("ts", 0);
+J.attribute("ph", "M");
+J.attribute("name", Name);
+J.attributeObject("args", [&] { J.attribute("name", arg); });
+  });
+};
+
+writeMetadataEvent("process_name", Tid, ProcName);
+writeMetadataEvent("thread_name", Tid, ThreadName);
+for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
+  writeMetadataEvent("thread_name", TTP->Tid, TTP->ThreadName);
 
 J.arrayEnd();
 J.attributeEnd();
@@ -231,6 +242,8 @@
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
   const std::string ProcName;
+  const sys::Process::Pid Pid;
+  SmallString<0> ThreadName;
   const uint64_t Tid;
 
   // Minimum time granularity (in microseconds)
Index: lld/test/ELF/time-trace.s
===
--- lld/test/ELF/time-trace.s
+++ lld/test/ELF/time-trace.s
@@ -34,6 +34,7 @@
 # Check process_name entry field
 # CHECK: "name": "ld.lld{{(.exe)?}}"
 # CHECK: "name": "process_name"
+# CHECK: "name": "thread_name"
 
 .globl _start
 _start:
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -14,6 +14,7 @@
 // CHECK-NEXT: "ts":
 // CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
+// CHECK: "name": "thread_name"
 
 template 
 struct Struct {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78674: [SveEmitter] Add builtins for contiguous prefetches

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma, ctetreau.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen updated this revision to Diff 259403.
sdesmalen added a comment.

- Removed unrelated whitespace changes.


This patch also adds the enum `sv_prfop` for the prefetch operation specifier
and checks to ensure the passed enum values are valid.


https://reviews.llvm.org/D78674

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -537,6 +537,15 @@
 Immediate = true;
 PredicatePattern = true;
 break;
+  case 'J':
+Predicate = false;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+Signed = true;
+Immediate = true;
+PrefetchOp = true;
+break;
   case 'k':
 Predicate = false;
 Signed = true;
@@ -704,6 +713,9 @@
   if (T.isPredicatePattern())
 ImmChecks.emplace_back(
 I - 1, Emitter.getEnumValueForImmCheck("ImmCheck0_31"));
+  else if (T.isPrefetchOp())
+ImmChecks.emplace_back(
+I - 1, Emitter.getEnumValueForImmCheck("ImmCheck0_13"));
 }
   }
 
@@ -1006,6 +1018,22 @@
   OS << "  SV_ALL = 31\n";
   OS << "} sv_pattern;\n\n";
 
+  OS << "typedef enum\n";
+  OS << "{\n";
+  OS << "  SV_PLDL1KEEP = 0,\n";
+  OS << "  SV_PLDL1STRM = 1,\n";
+  OS << "  SV_PLDL2KEEP = 2,\n";
+  OS << "  SV_PLDL2STRM = 3,\n";
+  OS << "  SV_PLDL3KEEP = 4,\n";
+  OS << "  SV_PLDL3STRM = 5,\n";
+  OS << "  SV_PSTL1KEEP = 8,\n";
+  OS << "  SV_PSTL1STRM = 9,\n";
+  OS << "  SV_PSTL2KEEP = 10,\n";
+  OS << "  SV_PSTL2STRM = 11,\n";
+  OS << "  SV_PSTL3KEEP = 12,\n";
+  OS << "  SV_PSTL3STRM = 13\n";
+  OS << "} sv_prfop;\n\n";
+
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+void test_svprfw(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value 14 is outside the valid range [0, 13]}}
+  return svprfw(pg, base, 14);
+}
+
+void test_svprfw_1(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value -1 is outside the valid range [0, 13]}}
+  return svprfw(pg, base, -1);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+void test_svprfh(svbool_t pg, const void *base)
+{
+  // expected-error@+1 {{argument value 14 is outside the valid range [0, 13]}}
+  return svprfh(pg, base, 14);
+}
+
+void test_svprfh_1(svbool_t pg, const void *base)
+{
+  // expected-error@+1 

[clang] a5bf028 - [TimeProfiler] Emit real process ID and thread names

2020-04-22 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-04-23T00:12:51+03:00
New Revision: a5bf02815d8b8d1a76682a63281561f076968dae

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

LOG: [TimeProfiler] Emit real process ID and thread names

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

Added: 


Modified: 
clang/test/Driver/check-time-trace.cpp
lld/test/ELF/time-trace.s
llvm/lib/Support/TimeProfiler.cpp

Removed: 




diff  --git a/clang/test/Driver/check-time-trace.cpp 
b/clang/test/Driver/check-time-trace.cpp
index bff2c1984daa..1484462b72bb 100644
--- a/clang/test/Driver/check-time-trace.cpp
+++ b/clang/test/Driver/check-time-trace.cpp
@@ -14,6 +14,7 @@
 // CHECK-NEXT: "ts":
 // CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
+// CHECK: "name": "thread_name"
 
 template 
 struct Struct {

diff  --git a/lld/test/ELF/time-trace.s b/lld/test/ELF/time-trace.s
index 74311a984110..8085a256649e 100644
--- a/lld/test/ELF/time-trace.s
+++ b/lld/test/ELF/time-trace.s
@@ -34,6 +34,7 @@
 # Check process_name entry field
 # CHECK: "name": "ld.lld{{(.exe)?}}"
 # CHECK: "name": "process_name"
+# CHECK: "name": "thread_name"
 
 .globl _start
 _start:

diff  --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 510f763b8fe3..c907c1aaf983 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -75,7 +76,10 @@ struct Entry {
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
   : StartTime(steady_clock::now()), ProcName(ProcName),
-Tid(llvm::get_threadid()), TimeTraceGranularity(TimeTraceGranularity) 
{}
+Pid(sys::Process::getProcessId()), Tid(llvm::get_threadid()),
+TimeTraceGranularity(TimeTraceGranularity) {
+llvm::get_thread_name(ThreadName);
+  }
 
   void begin(std::string Name, llvm::function_ref Detail) {
 Stack.emplace_back(steady_clock::now(), TimePointType(), std::move(Name),
@@ -138,8 +142,8 @@ struct llvm::TimeTraceProfiler {
   auto StartUs = E.getFlameGraphStartUs(StartTime);
   auto DurUs = E.getFlameGraphDurUs();
 
-  J.object([&]{
-J.attribute("pid", 1);
+  J.object([&] {
+J.attribute("pid", Pid);
 J.attribute("tid", int64_t(Tid));
 J.attribute("ph", "X");
 J.attribute("ts", StartUs);
@@ -194,8 +198,8 @@ struct llvm::TimeTraceProfiler {
   auto DurUs = duration_cast(Total.second.second).count();
   auto Count = AllCountAndTotalPerName[Total.first].first;
 
-  J.object([&]{
-J.attribute("pid", 1);
+  J.object([&] {
+J.attribute("pid", Pid);
 J.attribute("tid", int64_t(TotalTid));
 J.attribute("ph", "X");
 J.attribute("ts", 0);
@@ -210,16 +214,23 @@ struct llvm::TimeTraceProfiler {
   ++TotalTid;
 }
 
-// Emit metadata event with process name.
-J.object([&] {
-  J.attribute("cat", "");
-  J.attribute("pid", 1);
-  J.attribute("tid", 0);
-  J.attribute("ts", 0);
-  J.attribute("ph", "M");
-  J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
-});
+auto writeMetadataEvent = [&](const char *Name, uint64_t Tid,
+  StringRef arg) {
+  J.object([&] {
+J.attribute("cat", "");
+J.attribute("pid", Pid);
+J.attribute("tid", int64_t(Tid));
+J.attribute("ts", 0);
+J.attribute("ph", "M");
+J.attribute("name", Name);
+J.attributeObject("args", [&] { J.attribute("name", arg); });
+  });
+};
+
+writeMetadataEvent("process_name", Tid, ProcName);
+writeMetadataEvent("thread_name", Tid, ThreadName);
+for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
+  writeMetadataEvent("thread_name", TTP->Tid, TTP->ThreadName);
 
 J.arrayEnd();
 J.attributeEnd();
@@ -231,6 +242,8 @@ struct llvm::TimeTraceProfiler {
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
   const std::string ProcName;
+  const sys::Process::Pid Pid;
+  SmallString<0> ThreadName;
   const uint64_t Tid;
 
   // Minimum time granularity (in microseconds)



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


[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion

2020-04-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Sema/implicit-int-float-conversion.c:3
+// RUN: %clang_cc1 %s -verify -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 

If I understand the bug description properly:
You should add a test based on the description where you disable 
-Wimplicit-int-float-conversion, then re-enable 
-Wimplicit-const-int-float-conversion, and observe 
-Wimplicit-const-int-float-conversion diagnostics. ie.

```
// RUN: %clang_cc1 %s -verify -Wno-implicit-int-float-conversion 
-Wimplicit-const-int-float-conversion
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78661



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


[PATCH] D76038: PR45000: Let Sema::SubstParmVarDecl handle default args of lambdas in initializers

2020-04-22 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf43859a099fa: PR45000: Let Sema::SubstParmVarDecl handle 
default args of lambdas in… (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76038

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/vartemplate-lambda.cpp
  clang/test/SemaTemplate/instantiate-local-class.cpp

Index: clang/test/SemaTemplate/instantiate-local-class.cpp
===
--- clang/test/SemaTemplate/instantiate-local-class.cpp
+++ clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -486,3 +486,16 @@
   }
   void g() { f(); }
 }
+
+namespace PR45000 {
+  template 
+  void f(int x = [](T x = nullptr) -> int { return x; }());
+  // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}}
+  // expected-note@-2 {{passing argument to parameter 'x' here}}
+  // expected-error@-3 {{no matching function for call}}
+  // expected-note@-4 {{candidate function not viable: requires single argument 'x', but no arguments were provided}}
+  // expected-note@-5 {{conversion candidate of type 'auto (*)(int) -> int'}}
+
+  void g() { f(); }
+  // expected-note@-1 {{in instantiation of default function argument expression for 'f' required here}}
+}
Index: clang/test/SemaCXX/vartemplate-lambda.cpp
===
--- clang/test/SemaCXX/vartemplate-lambda.cpp
+++ clang/test/SemaCXX/vartemplate-lambda.cpp
@@ -4,7 +4,12 @@
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
-template auto v1 = [](int a = T(1)) { return a; }();
+template auto v1 = [](int a = T()) { return a; }();
+// expected-error@-1{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}}
+// expected-error@-2{{no matching function for call}}
+// expected-note@-3{{passing argument to parameter 'a' here}}
+// expected-note@-4{{candidate function not viable}}
+// expected-note@-5{{conversion candidate of type 'int (*)(int)'}}
 
 struct S {
   template
@@ -16,6 +21,7 @@
   X a = 0x61;
   fn1(a);
   (void)v1;
+  (void)v1; // expected-note{{in instantiation of variable template specialization 'v1' requested here}}
   (void)S::t; // expected-note{{in instantiation of static data member 'S::t' requested here}}
   return 0;
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12219,19 +12219,6 @@
 
   LSI->CallOperator = NewCallOperator;
 
-  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
-   I != NumParams; ++I) {
-auto *P = NewCallOperator->getParamDecl(I);
-if (P->hasUninstantiatedDefaultArg()) {
-  EnterExpressionEvaluationContext Eval(
-  getSema(),
-  Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P);
-  ExprResult R = getDerived().TransformExpr(
-  E->getCallOperator()->getParamDecl(I)->getDefaultArg());
-  P->setDefaultArg(R.get());
-}
-  }
-
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
 
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4363,7 +4363,7 @@
 EPI.ExceptionSpec.Type != EST_None &&
 EPI.ExceptionSpec.Type != EST_DynamicNone &&
 EPI.ExceptionSpec.Type != EST_BasicNoexcept &&
-!Tmpl->isLexicallyWithinFunctionOrMethod()) {
+!Tmpl->isInLocalScope()) {
   FunctionDecl *ExceptionSpecTemplate = Tmpl;
   if (EPI.ExceptionSpec.Type == EST_Uninstantiated)
 ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2380,7 +2380,7 @@
 UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm);
   } else if (Expr *Arg = OldParm->getDefaultArg()) {
 FunctionDecl *OwningFunc = cast(OldParm->getDeclContext());
-if (OwningFunc->isLexicallyWithinFunctionOrMethod()) {
+if (OwningFunc->isInLocalScope()) {
   // Instantiate default arguments for methods of local classes (DR1484)
   // and non-defining declarations.
   Sema::ContextRAII SavedContext(*this, OwningFunc);
Index: clang/lib/AST/DeclBase.cpp

[PATCH] D77595: [SveEmitter] Add builtins for svwhile

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1559485e6002: [SveEmitter] Add builtins for svwhile 
(authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D77595?vs=257829=259392#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77595

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c

Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svwhilegt_b8_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b8_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv16i1.i32(i32 %op1, i32 %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b8'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b8_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b8,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b16_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b16_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv8i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b16'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b16_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b16,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b32_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b32_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv4i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b32'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b32_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b32,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b64_s32(int32_t op1, int32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b64_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilegt.nxv2i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b64'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b64_s32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b64,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b8_u32(uint32_t op1, uint32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b8_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilehi.nxv16i1.i32(i32 %op1, i32 %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilegt_b8'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilegt_b8_u32'}}
+  return SVE_ACLE_FUNC(svwhilegt_b8,_u32,,)(op1, op2);
+}
+
+svbool_t test_svwhilegt_b16_u32(uint32_t op1, uint32_t op2)
+{
+  // CHECK-LABEL: test_svwhilegt_b16_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilehi.nxv8i1.i32(i32 %op1, i32 %op2)
+  // CHECK: %[[CAST:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[CAST]]
+  // overload-warning@+2 {{implicit 

[PATCH] D78238: [SveEmitter] Add builtins for svwhilerw/svwhilewr

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d1baf606ab4: [SveEmitter] Add builtins for 
svwhilerw/svwhilewr (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D78238?vs=257822=259394#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78238

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c

Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svwhilewr_s8(const int8_t *op1, const int8_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_s8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.b.nxv16i1.p0i8(i8* %op1, i8* %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_s8'}}
+  return SVE_ACLE_FUNC(svwhilewr,_s8,,)(op1, op2);
+}
+
+svbool_t test_svwhilewr_s16(const int16_t *op1, const int16_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_s16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.h.nxv8i1.p0i16(i16* %op1, i16* %op2)
+  // CHECK: %[[INTRINSIC_REINT:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[INTRINSIC_REINT]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_s16'}}
+  return SVE_ACLE_FUNC(svwhilewr,_s16,,)(op1, op2);
+}
+
+svbool_t test_svwhilewr_s32(const int32_t *op1, const int32_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.s.nxv4i1.p0i32(i32* %op1, i32* %op2)
+  // CHECK: %[[INTRINSIC_REINT:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[INTRINSIC_REINT]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_s32'}}
+  return SVE_ACLE_FUNC(svwhilewr,_s32,,)(op1, op2);
+}
+
+svbool_t test_svwhilewr_s64(const int64_t *op1, const int64_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_s64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.d.nxv2i1.p0i64(i64* %op1, i64* %op2)
+  // CHECK: %[[INTRINSIC_REINT:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[INTRINSIC_REINT]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_s64'}}
+  return SVE_ACLE_FUNC(svwhilewr,_s64,,)(op1, op2);
+}
+
+svbool_t test_svwhilewr_u8(const uint8_t *op1, const uint8_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_u8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.b.nxv16i1.p0i8(i8* %op1, i8* %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_u8'}}
+  return SVE_ACLE_FUNC(svwhilewr,_u8,,)(op1, op2);
+}
+
+svbool_t test_svwhilewr_u16(const uint16_t *op1, const uint16_t *op2)
+{
+  // CHECK-LABEL: test_svwhilewr_u16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.whilewr.h.nxv8i1.p0i16(i16* %op1, i16* %op2)
+  // CHECK: %[[INTRINSIC_REINT:.*]] = call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
+  // CHECK: ret  %[[INTRINSIC_REINT]]
+  // overload-warning@+2 

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D77233#1997294 , @erik.pilkington 
wrote:

> LGTM, again :) Thanks for cleaning this up.


Thank you Erik!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233



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


[clang] 2d1baf6 - [SveEmitter] Add builtins for svwhilerw/svwhilewr

2020-04-22 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-22T21:49:18+01:00
New Revision: 2d1baf606ab46daf9a322e5751d364c55c86deca

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

LOG: [SveEmitter] Add builtins for svwhilerw/svwhilewr

This also adds the IsOverloadWhileRW flag which tells CGBuiltin to use
the result predicate type and the first pointer type as the
overloaded types for the LLVM IR intrinsic.

Reviewers: SjoerdMeijer, efriedma

Reviewed By: efriedma

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 25c738bc3796..661691e3d2a5 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -236,6 +236,7 @@ namespace clang {
 bool isOverloadNone() const { return Flags & IsOverloadNone; }
 bool isOverloadWhile() const { return Flags & IsOverloadWhile; }
 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
+bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
 
 uint64_t getBits() const { return Flags; }
 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }

diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index fd15c86bec9f..1feeeba6d780 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -169,6 +169,7 @@ def IsStructStore : FlagType<0x0004>;
 def IsZExtReturn  : FlagType<0x0008>; // Return value is 
sign-extend by default
 def IsOverloadNone: FlagType<0x0010>; // Intrinsic does not 
take any overloaded types.
 def IsOverloadWhile   : FlagType<0x0020>; // Use {default type, 
typeof(operand1)} as overloaded types.
+def IsOverloadWhileRW : FlagType<0x0040>; // Use {pred(default 
type), typeof(operand0)} as overloaded types.
 def OverloadKindMask  : FlagType<0x00E0>; // When the masked 
values are all '0', the default type is used as overload type.
 //  : :
 //  : :
@@ -714,3 +715,17 @@ def SVSTNT1_SCATTER_INDEX_S  : 
MInst<"svstnt1_scatter[_{2}base]_index[_{d}]",  "
 def SVSTNT1H_SCATTER_INDEX_S : MInst<"svstnt1h_scatter[_{2}base]_index[_{d}]", 
"vPuld", "ilUiUl",   [IsScatterStore], MemEltTyInt16,   
"aarch64_sve_stnt1_scatter_scalar_offset">;
 def SVSTNT1W_SCATTER_INDEX_S : MInst<"svstnt1w_scatter[_{2}base]_index[_{d}]", 
"vPuld", "lUl",  [IsScatterStore], MemEltTyInt32,   
"aarch64_sve_stnt1_scatter_scalar_offset">;
 }
+
+
+// SVE2 - Contiguous conflict detection
+let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {
+def SVWHILERW_B : SInst<"svwhilerw[_{1}]", "Pcc", "cUc",  MergeNone, 
"aarch64_sve_whilerw_b", [IsOverloadWhileRW]>;
+def SVWHILERW_H : SInst<"svwhilerw[_{1}]", "Pcc", "sUsh", MergeNone, 
"aarch64_sve_whilerw_h", [IsOverloadWhileRW]>;
+def SVWHILERW_S : SInst<"svwhilerw[_{1}]", "Pcc", "iUif", MergeNone, 
"aarch64_sve_whilerw_s", [IsOverloadWhileRW]>;
+def SVWHILERW_D : SInst<"svwhilerw[_{1}]", "Pcc", "lUld", MergeNone, 
"aarch64_sve_whilerw_d", [IsOverloadWhileRW]>;
+
+def SVWHILEWR_B : SInst<"svwhilewr[_{1}]", "Pcc", "cUc",  MergeNone, 
"aarch64_sve_whilewr_b", [IsOverloadWhileRW]>;
+def SVWHILEWR_H : SInst<"svwhilewr[_{1}]", "Pcc", "sUsh", MergeNone, 
"aarch64_sve_whilewr_h", [IsOverloadWhileRW]>;
+def SVWHILEWR_S : SInst<"svwhilewr[_{1}]", "Pcc", "iUif", MergeNone, 
"aarch64_sve_whilewr_s", [IsOverloadWhileRW]>;
+def SVWHILEWR_D : SInst<"svwhilewr[_{1}]", "Pcc", "lUld", MergeNone, 
"aarch64_sve_whilewr_d", [IsOverloadWhileRW]>;
+}

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6c58cfd81acc..e1dd8f9bfda5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7511,6 +7511,30 @@ llvm::Type *CodeGenFunction::getEltType(SVETypeFlags 
TypeFlags) {
   }
 }
 
+// Return the llvm predicate vector type corresponding to the specified element
+// TypeFlags.
+llvm::VectorType* CodeGenFunction::getSVEPredType(SVETypeFlags TypeFlags) {
+  switch (TypeFlags.getEltType()) {
+  default: llvm_unreachable("Unhandled SVETypeFlag!");
+
+  case SVETypeFlags::EltTyInt8:
+return llvm::VectorType::get(Builder.getInt1Ty(), { 16, true });

[clang] 1559485 - [SveEmitter] Add builtins for svwhile

2020-04-22 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-22T21:47:47+01:00
New Revision: 1559485e600242343cb21c7ffbf345172008cd59

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

LOG: [SveEmitter] Add builtins for svwhile

This also adds the IsOverloadWhile flag which tells CGBuiltin to use
both the default type (predicate) and the type of the second operand
(scalar) as the overloaded types for the LLMV IR intrinsic.

Reviewers: SjoerdMeijer, efriedma, rovka

Reviewed By: efriedma

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 042f60739f85..25c738bc3796 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -234,6 +234,7 @@ namespace clang {
 bool isZExtReturn() const { return Flags & IsZExtReturn; }
 bool isByteIndexed() const { return Flags & IsByteIndexed; }
 bool isOverloadNone() const { return Flags & IsOverloadNone; }
+bool isOverloadWhile() const { return Flags & IsOverloadWhile; }
 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
 
 uint64_t getBits() const { return Flags; }

diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index c2794356d251..fd15c86bec9f 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -168,6 +168,7 @@ def IsStructLoad  : FlagType<0x0002>;
 def IsStructStore : FlagType<0x0004>;
 def IsZExtReturn  : FlagType<0x0008>; // Return value is 
sign-extend by default
 def IsOverloadNone: FlagType<0x0010>; // Intrinsic does not 
take any overloaded types.
+def IsOverloadWhile   : FlagType<0x0020>; // Use {default type, 
typeof(operand1)} as overloaded types.
 def OverloadKindMask  : FlagType<0x00E0>; // When the masked 
values are all '0', the default type is used as overload type.
 //  : :
 //  : :
@@ -528,6 +529,18 @@ let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {
 def SVQSHLU_M  : SInst<"svqshlu[_n_{d}]", "uPdi", "csil", MergeOp1,  
"aarch64_sve_sqshlu", [], [ImmCheck<2, ImmCheckShiftLeft,  1>]>;
 }
 
+
+// While comparisons
+
+def SVWHILELE_S32 : SInst<"svwhilele_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilele", [IsOverloadWhile]>;
+def SVWHILELE_S64 : SInst<"svwhilele_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilele", [IsOverloadWhile]>;
+def SVWHILELO_U32 : SInst<"svwhilelt_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilelo", [IsOverloadWhile]>;
+def SVWHILELO_U64 : SInst<"svwhilelt_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilelo", [IsOverloadWhile]>;
+def SVWHILELS_U32 : SInst<"svwhilele_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilels", [IsOverloadWhile]>;
+def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilels", [IsOverloadWhile]>;
+def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
+def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
+
 

 // Floating-point arithmetic
 
@@ -567,6 +580,19 @@ def SVCNTD_PAT : SInst<"svcntd_pat", "nI", "", MergeNone, 
"aarch64_sve_cntd", [I
 def SVDOT_LANE_S : SInst<"svdot_lane[_{d}]",  "ddqqi",  "il",   MergeNone, 
"aarch64_sve_sdot_lane", [], [ImmCheck<3, ImmCheckLaneIndexDot, 2>]>;
 def SVDOT_LANE_U : SInst<"svdot_lane[_{d}]",  "ddqqi",  "UiUl", MergeNone, 
"aarch64_sve_udot_lane", [], [ImmCheck<3, ImmCheckLaneIndexDot, 2>]>;
 
+
+// SVE2 WhileGE/GT
+let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {
+def SVWHILEGE_S32 : SInst<"svwhilege_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilege", [IsOverloadWhile]>;
+def SVWHILEGE_S64 : SInst<"svwhilege_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, 

[clang] f43859a - PR45000: Let Sema::SubstParmVarDecl handle default args of lambdas in initializers

2020-04-22 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-04-22T22:37:21+02:00
New Revision: f43859a099fa3587123717be941fa63ba8d0d4f2

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

LOG: PR45000: Let Sema::SubstParmVarDecl handle default args of lambdas in 
initializers

Summary:
We extend the behavior for local functions and methods of local classes
to lambdas in variable initializers. The initializer is not a separate
scope, but we treat it as such.

We also remove the (faulty) instantiation of default arguments in
TreeTransform::TransformLambdaExpr, because it doesn't do proper
initialization, and if it did, we would do it twice (and thus also emit
eventual errors twice).

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/vartemplate-lambda.cpp
clang/test/SemaTemplate/instantiate-local-class.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index b48f7e4f9308..91875377679d 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -869,14 +869,15 @@ class alignas(8) Decl {
 return getParentFunctionOrMethod() == nullptr;
   }
 
-  /// Returns true if this declaration lexically is inside a function.
-  /// It recognizes non-defining declarations as well as members of local
-  /// classes:
+  /// Returns true if this declaration is lexically inside a function or inside
+  /// a variable initializer. It recognizes non-defining declarations as well
+  /// as members of local classes:
   /// \code
   /// void foo() { void bar(); }
   /// void foo2() { class ABC { void bar(); }; }
+  /// inline int x = [](){ return 0; };
   /// \endcode
-  bool isLexicallyWithinFunctionOrMethod() const;
+  bool isInLocalScope() const;
 
   /// If this decl is defined inside a function/method/block it returns
   /// the corresponding DeclContext, otherwise it returns null.

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 8a18de1e8248..2aab53f4fa90 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -332,13 +332,16 @@ void Decl::setDeclContextsImpl(DeclContext *SemaDC, 
DeclContext *LexicalDC,
   }
 }
 
-bool Decl::isLexicallyWithinFunctionOrMethod() const {
+bool Decl::isInLocalScope() const {
   const DeclContext *LDC = getLexicalDeclContext();
   while (true) {
 if (LDC->isFunctionOrMethod())
   return true;
 if (!isa(LDC))
   return false;
+if (const auto *CRD = dyn_cast(LDC))
+  if (CRD->isLambda())
+return true;
 LDC = LDC->getLexicalParent();
   }
   return false;

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e2b3ebba6bbe..4b6b92ccab2c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2380,7 +2380,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
 UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm);
   } else if (Expr *Arg = OldParm->getDefaultArg()) {
 FunctionDecl *OwningFunc = cast(OldParm->getDeclContext());
-if (OwningFunc->isLexicallyWithinFunctionOrMethod()) {
+if (OwningFunc->isInLocalScope()) {
   // Instantiate default arguments for methods of local classes (DR1484)
   // and non-defining declarations.
   Sema::ContextRAII SavedContext(*this, OwningFunc);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 551517581063..a6541dabe6b2 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4363,7 +4363,7 @@ 
TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
 EPI.ExceptionSpec.Type != EST_None &&
 EPI.ExceptionSpec.Type != EST_DynamicNone &&
 EPI.ExceptionSpec.Type != EST_BasicNoexcept &&
-!Tmpl->isLexicallyWithinFunctionOrMethod()) {
+!Tmpl->isInLocalScope()) {
   FunctionDecl *ExceptionSpecTemplate = Tmpl;
   if (EPI.ExceptionSpec.Type == EST_Uninstantiated)
 ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate;

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index abde968bed8c..da6ff8e5cea8 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12219,19 +12219,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 
   LSI->CallOperator = NewCallOperator;
 
-  for (unsigned I = 0, NumParams = 

[PATCH] D78000: [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)

2020-04-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.

Hello Shafik!
The patch looks good, I only have a few stylish nits.




Comment at: clang/unittests/AST/ASTImporterTest.cpp:5964
+  new SourceWithCompletedTagList(CompletedTags);
+  clang::ASTContext  = FromTU->getASTContext();
+  context.setExternalSource(std::move(source));

Context (starting with capital).



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5980
+  // Import the definition of the created class.
+  llvm::Error err = findFromTU(Record)->Importer->ImportDefinition(Record);
+  EXPECT_FALSE((bool)err);

Err (starting with capital).


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

https://reviews.llvm.org/D78000



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


[PATCH] D78192: Support compiler extensions as a normal component

2020-04-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Is this ready to try out?

In D78192#1996859 , @serge-sans-paille 
wrote:

> Note that this should solve in an elegant (?) way the multiple link errors 
> found when linking clang with LLVM_DYLIB.


Aren't these fixed already?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78192



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


[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-04-22 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy updated this revision to Diff 259374.
LemonBoy added a comment.

Fix a C error in the attached test case.


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

https://reviews.llvm.org/D78658

Files:
  clang/lib/Frontend/ASTUnit.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp

Index: clang/unittests/Frontend/ASTUnitTest.cpp
===
--- clang/unittests/Frontend/ASTUnitTest.cpp
+++ clang/unittests/Frontend/ASTUnitTest.cpp
@@ -111,4 +111,28 @@
 llvm::MemoryBuffer::MemoryBuffer_MMap);
 }
 
+TEST_F(ASTUnitTest, LoadFromCommandLineEarlyError) {
+  EXPECT_FALSE(
+  llvm::sys::fs::createTemporaryFile("ast-unit", "c", FD, InputFileName));
+  input_file = std::make_unique(InputFileName, FD);
+  input_file->os() << "";
+
+  const char *Args[] = {"clang", "-target", "foobar", InputFileName.c_str()};
+
+  auto Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions());
+  auto PCHContainerOps = std::make_shared();
+  std::unique_ptr ErrUnit;
+
+  ASTUnit *AST = ASTUnit::LoadFromCommandLine(
+  [0], [4], PCHContainerOps, Diags, "", false,
+  CaptureDiagsKind::All, None, true, 0, TU_Complete, false, false, false,
+  SkipFunctionBodiesScope::None, false, true, false, false, None, ,
+  nullptr);
+
+  ASSERT_EQ(AST, nullptr);
+  ASSERT_NE(ErrUnit, nullptr);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_NE(ErrUnit->stored_diag_size(), 0U);
+}
+
 } // anonymous namespace
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1118,6 +1118,18 @@
   std::unique_ptr Clang(
   new CompilerInstance(std::move(PCHContainerOps)));
 
+  auto OnError = [&]() {
+// Remove the overridden buffer we used for the preamble.
+SavedMainFileBuffer = nullptr;
+
+// Keep the ownership of the data in the ASTUnit because the client may
+// want to see the diagnostics.
+transferASTDataFromCompilerInstance(*Clang);
+FailedParseDiagnostics.swap(StoredDiagnostics);
+StoredDiagnostics.clear();
+NumStoredDiagnosticsFromDriver = 0;
+  };
+
   // Ensure that Clang has a FileManager with the right VFS, which may have
   // changed above in AddImplicitPreamble.  If VFS is nullptr, rely on
   // createFileManager to create one.
@@ -1141,8 +1153,10 @@
   // Create the target instance.
   Clang->setTarget(TargetInfo::CreateTargetInfo(
   Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->hasTarget()) {
+OnError();
 return true;
+  }
 
   // Inform the target of the language options.
   //
@@ -1199,8 +1213,10 @@
   llvm::CrashRecoveryContextCleanupRegistrar
 ActCleanup(Act.get());
 
-  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
-goto error;
+  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
+OnError();
+return true;
+  }
 
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
@@ -1210,7 +1226,8 @@
 
   if (llvm::Error Err = Act->Execute()) {
 consumeError(std::move(Err)); // FIXME this drops errors on the floor.
-goto error;
+OnError();
+return true;
   }
 
   transferASTDataFromCompilerInstance(*Clang);
@@ -1220,18 +1237,6 @@
   FailedParseDiagnostics.clear();
 
   return false;
-
-error:
-  // Remove the overridden buffer we used for the preamble.
-  SavedMainFileBuffer = nullptr;
-
-  // Keep the ownership of the data in the ASTUnit because the client may
-  // want to see the diagnostics.
-  transferASTDataFromCompilerInstance(*Clang);
-  FailedParseDiagnostics.swap(StoredDiagnostics);
-  StoredDiagnostics.clear();
-  NumStoredDiagnosticsFromDriver = 0;
-  return true;
 }
 
 static std::pair
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Everything's clear! Nice detective work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion

2020-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 259370.
MaskRay added a comment.

Fixed a typo noticed by @bmoses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78661

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-float-conversion.c


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCONST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 22;
@@ -12,7 +16,9 @@
   float  = UL; // expected-warning {{changes value from 
 to 1312}}
 
   long l = L;
+#ifdef NONCOST
   float fff = l; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
 
 void testExpression() {
@@ -24,7 +30,9 @@
   float c =  + 2223; // expected-warning {{implicit conversion 
from 'int' to 'float' changes value from 4445 to }}
 
   int i = 0;
+#ifdef NONCONST
   float d = i + a; // expected-warning {{implicit conversion from 'int' to 
'float' may lose precision}}
+#endif
 
   double e = 0.0;
   double f = i + e;
@@ -36,5 +44,7 @@
   float a = {L}; // expected-warning {{changes value from 
 to 1312}}
 
   long b = L;
+#ifdef NONCONST
   float c = {b}; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3549,7 +3549,7 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_float_precision_constant : Warning<
   "implicit conversion from %2 to %3 changes value from %0 to %1">,
-  InGroup;
+  InGroup;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -85,7 +85,9 @@
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
  
[ObjCSignedCharBoolImplicitIntConversion]>;
-def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
+def ImplicitConstIntFloatConversion : 
DiagGroup<"implicit-const-int-float-conversion">;
+def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion",
+ [ImplicitConstIntFloatConversion]>;
 def ObjCSignedCharBoolImplicitFloatConversion :
   DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
 def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCONST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 22;
@@ -12,7 +16,9 @@
   float  = UL; // expected-warning {{changes value from  to 1312}}
 
   long l = L;
+#ifdef NONCOST
   float fff = l; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+#endif
 }
 
 void testExpression() {
@@ -24,7 +30,9 @@
   float c =  + 2223; // expected-warning {{implicit conversion from 'int' to 'float' changes value from 4445 to }}
 
   int i = 0;
+#ifdef NONCONST
   float d = i + a; // expected-warning {{implicit conversion from 'int' to 'float' may lose precision}}
+#endif
 
   double e = 0.0;
   double f = i + e;
@@ -36,5 +44,7 @@
   float a = {L}; // expected-warning {{changes value from 

[PATCH] D73845: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-04-22 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

ping @phosek  ?


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

https://reviews.llvm.org/D73845



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-04-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 2 inline comments as done.
mibintc added a comment.

added a couple inline explanatory comments




Comment at: clang/include/clang/Basic/LangOptions.h:307
 
+  bool denormalIsIEEE = false;
+

I added this boolean as part of validating the correctness of the pragma's that 
access the FP environment, according to the Microsoft checks.. Copying from the 
Microsoft doc:  "There are restrictions on the ways you can use the fenv_access 
pragma in combination with other floating-point settings:

You can't enable fenv_access unless precise semantics are enabled. Precise 
semantics can be enabled either by the float_control pragma, or by using the 
/fp:precise or /fp:strict compiler options. The compiler defaults to 
/fp:precise if no other floating-point command-line option is specified.

You can't use float_control to disable precise semantics when fenv_access(on) 
is set."
This is copied from 
https://docs.microsoft.com/en-us/cpp/preprocessor/fenv-access?view=vs-2019



Comment at: clang/test/CodeGen/constrained-math-builtins.c:157
 
-// CHECK: call float @llvm.experimental.constrained.fmuladd.f32
-// CHECK: fneg
-// CHECK: call double @llvm.experimental.constrained.fmuladd.f64
-// CHECK: fneg
-// CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80
+  // CHECK: call contract float @llvm.experimental.constrained.fmuladd.f32
+  // CHECK: fneg

Since this patch constructs the FPFeatures using the floating point settings 
from the command line versus the default FPOptions() constructor, several tests 
need to be changed. Some of the changes I made showing the flags on the IR, 
other tests I changed by adding ffp-contract to the RUN line to match the 
expected IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D77374: Fix -fsanitize=array-bounds with comma operator

2020-04-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:882-887
+  while (const BinaryOperator *BO = dyn_cast(E)) {
+if (!BO->isCommaOp())
+  break;
+E = BO->getRHS();
+E = E->IgnoreParens();
+  }

vitalybuka wrote:
> rsmith wrote:
> > If we're going to further extend what Clang considers to be a flexible 
> > array access, we should do so consistently across our warning machinery and 
> > our sanitizers. Perhaps we could start by unifying this function with 
> > `IsTailPaddedMemberArray` in `SemaChecking`?
> There is one place in external code which is blocking me from enabling this 
> at Google.
> 
> How much work it's going to be? To me these functions looks very different.
If you don't want to do the refactoring, please at least update 
`Sema::CheckArrayAccess` to skip over commas when looking for a member access 
in `BaseExpr`. Testcase:

```
struct X { int a; int b[1]; } *p;
int n = (0, p->b)[3];
```

... currently warns and trips the array-bounds sanitizer; with this change it 
would still warn but not trip the sanitizer, which seems bad. (Though I suppose 
the opposite case is worse.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77374



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D78638#1997576 , @Szelethus wrote:

> How come rGe20b388e2f923bfc98f63a13fea9fc19aeaec425 
>  doesn't 
> solve this? Or, rather, how come it even worked if this patch is needed? Is 
> the index being a global variable the issue? The change looks great, but I'm 
> a bit confused.


Hey, thanks! So, I've tried to cover it in the comment and in the commit 
message.

In this test, both `do while` and the global index help to reproduce the 
erroneous behaviour. Usually, the analyzer tracks through array subscript 
expressions and it adds notes like expected in the test ("Assuming pointer 
value is null"). But in the test snippet, it was not adding those. The main 
reason is not in `trackExpressionValue`, it works fine! `trackExpressionValue` 
starts with finding an exploded node, where the lvalue is defined, and such 
node was not found. A little bit of digging later I found out that the node 
collector (aka garbage collector) threw those nodes away (check 
`ExplodedGraph::shouldCollect` and 
`ExplodedGraph::reclaimRecentlyAllocatedNodes`)! Because of the `do while` loop 
and the global index, the number of exploded nodes is pretty large. This fact 
causes GC to kick in and remove the nodes that we need for 
`trackExpressionValue` to work. Interesting nodes are on the other hand not 
deleted and this what helped with the problem.

I hope this clears it a bit!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rG411a254af3ff: [clang] Make sure argument expansion locations 
are correct in presence of… (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D78649?vs=259332=259363#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649

Files:
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/unittests/Basic/SourceManagerTest.cpp
  clang/unittests/Lex/LexerTest.cpp


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+  EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
+1U);
+}
 } // anonymous namespace
Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -294,10 +294,16 @@
   TrivialModuleLoader ModLoader;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, &*Target);
+
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
   SourceMgr, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
+  // Ensure we can get expanded locations in presence of implicit includes.
+  // These are different than normal includes since predefines buffer doesn't
+  // have a valid insertion location.
+  PP.setPredefines("#include \"/implicit-header.h\"");
+  FileMgr.getVirtualFile("/implicit-header.h", 0, 0);
   PP.Initialize(*Target);
   PP.EnterMainSourceFile();
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -415,7 +415,10 @@
 }
 
 if (!isEndOfMacro && CurPPLexer &&
-SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid()) {
+(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
+ // Predefines file doesn't have a valid include location.
+ (PredefinesFileID.isValid() &&
+  CurPPLexer->getFileID() == PredefinesFileID))) {
   // Notify SourceManager to record the number of FileIDs that were created
   // during lexing of the #include'd file.
   unsigned NumFIDs =
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1800,15 +1800,23 @@
   return;
 if (Entry.isFile()) {
   SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
-  if (IncludeLoc.isInvalid())
+  bool IncludedInFID =
+  (IncludeLoc.isValid() && isInFileID(IncludeLoc, FID)) ||
+  // Predefined header doesn't have a valid include location in main
+  // file, but any files created by it should still be skipped when
+  // computing macro args expanded in the main file.
+  (FID == MainFileID && Entry.getFile().Filename == "");
+  if (IncludedInFID) {
+// Skip the files/macros of the #include'd file, we only care about
+// macros that lexed macro arguments from our file.
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;
 continue;
-  if (!isInFileID(IncludeLoc, FID))
-return; // No more files/macros that may be "contained" in this file.
-
-  // Skip the files/macros of the #include'd file, we only care about 
macros
-  // that lexed macro arguments from our file.
-  if (Entry.getFile().NumCreatedFIDs)
-ID += Entry.getFile().NumCreatedFIDs - 1/*because of next ++ID*/;
+  } else if (IncludeLoc.isValid()) {
+// If file was included but not from FID, there is no more files/macros
+// that may be "contained" in this file.
+return;
+  }
   continue;
 }
 


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", 

[PATCH] D78626: [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.

2020-04-22 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d1ee639cb9e: [clangd] Fix a crash for accessing a null 
template decl returned by… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78626

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


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1286,6 +1286,20 @@
 "1: targets = {}\n"
 "2: targets = {T}\n"
   },
+  // unknown template name should not crash.
+  {R"cpp(
+template  typename T>
+struct Base {};
+namespace foo {
+template 
+struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
+}
+  )cpp",
+  "0: targets = {foo::Derive::T}, decl\n"
+  "1: targets = {foo::Derive}, decl\n"
+  "2: targets = {Base}\n"
+  "3: targets = {foo::Derive::T}\n"
+  "4: targets = {}, qualifier = 'T::'\n"},
 };
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -860,15 +860,17 @@
   // TemplateArgumentLoc is the only way to get locations for references to
   // template template parameters.
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
+llvm::SmallVector Targets;
 switch (A.getArgument().getKind()) {
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
+  if (const auto *D = A.getArgument()
+  .getAsTemplateOrTemplatePattern()
+  .getAsTemplateDecl())
+Targets.push_back(D);
   reportReference(ReferenceLoc{A.getTemplateQualifierLoc(),
A.getTemplateNameLoc(),
-   /*IsDecl=*/false,
-   {A.getArgument()
-.getAsTemplateOrTemplatePattern()
-.getAsTemplateDecl()}},
+   /*IsDecl=*/false, Targets},
   DynTypedNode::create(A.getArgument()));
   break;
 case TemplateArgument::Declaration:


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1286,6 +1286,20 @@
 "1: targets = {}\n"
 "2: targets = {T}\n"
   },
+  // unknown template name should not crash.
+  {R"cpp(
+template  typename T>
+struct Base {};
+namespace foo {
+template 
+struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
+}
+  )cpp",
+  "0: targets = {foo::Derive::T}, decl\n"
+  "1: targets = {foo::Derive}, decl\n"
+  "2: targets = {Base}\n"
+  "3: targets = {foo::Derive::T}\n"
+  "4: targets = {}, qualifier = 'T::'\n"},
 };
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -860,15 +860,17 @@
   // TemplateArgumentLoc is the only way to get locations for references to
   // template template parameters.
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
+llvm::SmallVector Targets;
 switch (A.getArgument().getKind()) {
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
+  if (const auto *D = A.getArgument()
+  .getAsTemplateOrTemplatePattern()
+  .getAsTemplateDecl())
+Targets.push_back(D);
   reportReference(ReferenceLoc{A.getTemplateQualifierLoc(),
A.getTemplateNameLoc(),
-   /*IsDecl=*/false,
-   {A.getArgument()
-.getAsTemplateOrTemplatePattern()
-.getAsTemplateDecl()}},
+   /*IsDecl=*/false, Targets},
   DynTypedNode::create(A.getArgument()));
   break;
 case TemplateArgument::Declaration:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78521: [clangd] Extend dexp to support remote index

2020-04-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/Index.proto:37
+message FuzzyFindReply {
+  // FIXME(kirillbobyrev): Convert to Symbol.
+  repeated string symbols = 1;

sammccall wrote:
> kbobyrev wrote:
> > sammccall wrote:
> > > confused... why not use Symbol now?
> > Couldn't put `Symbol`s into `FuzzyFindReply` for some reason. Clangd 
> > behaves really weird with Protobuf inclusions for me... Need to figure out 
> > why that happens, but might be me doing something wrong.
> Did you find out? Fixing this isn't a backwards-compatible change, and "this 
> code is broken and I don't know why" isn't a great state for checkin.
> 
> Happy to help but please provide some details.
Yes, it has to do with different code generated by Protobuf and I learned how 
to discover which API is becoming removed and which is accessible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78521



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

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

How come rGe20b388e2f923bfc98f63a13fea9fc19aeaec425 
 doesn't 
solve this? Or, rather, how come it even worked if this patch is needed? Is the 
index being a global variable the issue? The change looks great, but I'm a bit 
confused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D78521: [clangd] Extend dexp to support remote index

2020-04-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 259356.
kbobyrev marked 10 inline comments as done.
kbobyrev added a comment.

Just a checkpoint: resolve several comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78521

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.cpp
  clang-tools-extra/clangd/index/remote/Index.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/Marshalling.h
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,6 +8,7 @@
 
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/remote/Marshalling.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/LineEditor/LineEditor.h"
@@ -23,6 +24,7 @@
 
 namespace clang {
 namespace clangd {
+namespace remote {
 namespace {
 
 static const std::string Overview = R"(
@@ -33,8 +35,9 @@
 llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
-llvm::cl::opt ServerAddress("server-address",
- llvm::cl::init("0.0.0.0:50051"));
+llvm::cl::opt ServerAddress(
+"server-address", llvm::cl::init("0.0.0.0:50051"),
+llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
 std::unique_ptr openIndex(llvm::StringRef Index) {
   return loadIndex(Index, /*UseIndex=*/true);
@@ -47,24 +50,58 @@
 
 private:
   grpc::Status Lookup(grpc::ServerContext *Context,
-  const remote::LookupRequest *Request,
-  grpc::ServerWriter *Reply) override {
-llvm::outs() << "Lookup of symbol with ID " << Request->id() << '\n';
-LookupRequest Req;
-auto SID = SymbolID::fromStr(Request->id());
-if (!SID) {
-  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
-  return grpc::Status::CANCELLED;
+  const LookupRequest *Request,
+  grpc::ServerWriter *Reply) override {
+clangd::LookupRequest Req;
+for (const auto  : Request->ids()) {
+  auto SID = SymbolID::fromStr(StringRef(ID));
+  if (!SID)
+return grpc::Status::CANCELLED;
+  Req.IDs.insert(*SID);
 }
-Req.IDs.insert(*SID);
-Index->lookup(Req, [&](const Symbol ) {
-  remote::LookupReply NextSymbol;
-  NextSymbol.set_symbol_yaml(toYAML(Sym));
+Index->lookup(Req, [&](const clangd::Symbol ) {
+  remote::Symbol NextSymbol;
+  NextSymbol.set_yaml_serializatiton(toYAML(Sym));
   Reply->Write(NextSymbol);
 });
 return grpc::Status::OK;
   }
 
+  grpc::Status FuzzyFind(grpc::ServerContext *Context,
+ const FuzzyFindRequest *Request,
+ grpc::ServerWriter *Reply) override {
+const auto Req = fromProtobuf(Request);
+bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol ) {
+  FuzzyFindReply NextMessage;
+  NextMessage.mutable_symbol()->set_yaml_serializatiton(toYAML(Sym));
+  Reply->Write(NextMessage);
+});
+FuzzyFindReply LastMessage;
+LastMessage.set_has_more(HasMore);
+Reply->Write(LastMessage);
+return grpc::Status::OK;
+  }
+
+  grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
+grpc::ServerWriter *Reply) override {
+clangd::RefsRequest Req;
+for (const auto  : Request->ids()) {
+  auto SID = SymbolID::fromStr(StringRef(ID));
+  if (!SID)
+return grpc::Status::CANCELLED;
+  Req.IDs.insert(*SID);
+}
+bool HasMore = Index->refs(Req, [&](const clangd::Ref ) {
+  RefsReply NextMessage;
+  NextMessage.mutable_ref()->set_yaml_serializatiton(toYAML(Reference));
+  Reply->Write(NextMessage);
+});
+RefsReply LastMessage;
+LastMessage.set_has_more(HasMore);
+Reply->Write(LastMessage);
+return grpc::Status::OK;
+  }
+
   std::unique_ptr Index;
 };
 
@@ -83,15 +120,16 @@
 }
 
 } // namespace
+} // namespace remote
 } // namespace clangd
 } // namespace clang
 
 int main(int argc, char *argv[]) {
-  using namespace clang::clangd;
-  

[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion

2020-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: aaron.ballman, jfb, nickdesaulniers, rsmith, scanon, 
xbolva00, ziangwan.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Currently, both `warn_impcast_integer_float_precision_constant` and
`warn_impcast_integer_float_precision` are covered by
-Wimplicit-int-float-conversion, but only the ..._constant warning is on
by default.

`warn_impcast_integer_float_precision_constant` likely flags real problems
while `warn_impcast_integer_float_precision` may flag legitimate use
cases (for example, `int` used with limited range support by `float`).

If -Wno-implicit-int-float-conversion is used, currently there is no way
to restore the ..._constant warning. This patch adds
-Wimplicit-const-int-float-conversion to address the issue. (Similar to
the reasoning in https://reviews.llvm.org/D64666#1598194)

Adapted from a patch by Brooks Moses.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78661

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-float-conversion.c


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCOST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 22;
@@ -12,7 +16,9 @@
   float  = UL; // expected-warning {{changes value from 
 to 1312}}
 
   long l = L;
+#ifdef NONCOST
   float fff = l; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
 
 void testExpression() {
@@ -24,7 +30,9 @@
   float c =  + 2223; // expected-warning {{implicit conversion 
from 'int' to 'float' changes value from 4445 to }}
 
   int i = 0;
+#ifdef NONCOST
   float d = i + a; // expected-warning {{implicit conversion from 'int' to 
'float' may lose precision}}
+#endif
 
   double e = 0.0;
   double f = i + e;
@@ -36,5 +44,7 @@
   float a = {L}; // expected-warning {{changes value from 
 to 1312}}
 
   long b = L;
+#ifdef NONCOST
   float c = {b}; // expected-warning {{implicit conversion from 'long' to 
'float' may lose precision}}
+#endif
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3549,7 +3549,7 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_float_precision_constant : Warning<
   "implicit conversion from %2 to %3 changes value from %0 to %1">,
-  InGroup;
+  InGroup;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -85,7 +85,9 @@
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
  
[ObjCSignedCharBoolImplicitIntConversion]>;
-def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
+def ImplicitConstIntFloatConversion : 
DiagGroup<"implicit-const-int-float-conversion">;
+def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion",
+ [ImplicitConstIntFloatConversion]>;
 def ObjCSignedCharBoolImplicitFloatConversion :
   DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
 def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",


Index: clang/test/Sema/implicit-int-float-conversion.c
===
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
 
+#ifdef NONCOST
 long testReturn(long a, float b) {
   return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
 }
+#endif
 
 void testAssignment() {
   float f = 

[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

To be completely open about this, I had an offline chat with @psmith  and 
@kristof.beyls  about this. The reasoning is that this is probably related to 
my relatively poor choice of the 2 first cores that I describe here. They are 
microcontrollers, and Clang/LLVM doesn't provide a full embedded toolchain 
(linker, libraries, etc.), which is e.g. what we add downstream. So, if you're 
creating an embedded toolchain, you probably know what you're doing, and this 
is not one of the first problems that you have.

While I agree with that, I also mentioned that there are many issues orthogonal 
to this. Yes, we need a full toolchain, but I don't understand how improving 
things step-by-step can be a bad thing, or why we should wait for another thing 
to appear first before this becomes more valuable.  And yes, also -m option 
documentation needs to be improved, but again, for me that is orthogonal to 
this doc change. And what I also mentioned, is that absolutely nothing changes 
about the whole story here if you take an A-core application processor instead 
of an M-core, for which the toolchain probably looks simpler.

I agree with all your updates and replies on the cfe dev list. You mentioned 
"complete overhaul", and yes, I think option handling is inconsistent, 
undocumented, and so in general quite broken. Problem is that I didn't get a 
lot of buy in here and on the mailing list. So, I was happy to abandon this as 
I didn't feel like spending more time on this at this point.   But my idea was 
to step-by-step add more cores to this doc, also A-cores.


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

https://reviews.llvm.org/D78565



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


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

1. Tests missing
2. Why isn't `noinline` sufficient, why a whole new attribue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78659



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


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: llvm-commits.
lebedev.ri added a comment.

+ llvm-commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78659



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


[clang] 411a254 - [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-22T21:01:52+02:00
New Revision: 411a254af3ff5dd05e6c522cc7bccdf043967070

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

LOG: [clang] Make sure argument expansion locations are correct in presence of 
predefined buffer

Summary:
Macro argument expansion logic relies on skipping file IDs that created
as a result of an include. Unfortunately it fails to do that for
predefined buffer since it doesn't have a valid insertion location.

As a result of that any file ID created for an include inside the
predefined buffers breaks the traversal logic in
SourceManager::computeMacroArgsCache.

To fix this issue we first record number of created FIDs for predefined
buffer, and then skip them explicitly in source manager.

Another solution would be to just give predefined buffers a valid source
location, but it is unclear where that should be..

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/PPLexerChange.cpp
clang/unittests/Basic/SourceManagerTest.cpp
clang/unittests/Lex/LexerTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 8ba581598109..e42c3f4ca73f 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1800,15 +1800,23 @@ void SourceManager::computeMacroArgsCache(MacroArgsMap 
,
   return;
 if (Entry.isFile()) {
   SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
-  if (IncludeLoc.isInvalid())
+  bool IncludedInFID =
+  (IncludeLoc.isValid() && isInFileID(IncludeLoc, FID)) ||
+  // Predefined header doesn't have a valid include location in main
+  // file, but any files created by it should still be skipped when
+  // computing macro args expanded in the main file.
+  (FID == MainFileID && Entry.getFile().Filename == "");
+  if (IncludedInFID) {
+// Skip the files/macros of the #include'd file, we only care about
+// macros that lexed macro arguments from our file.
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;
 continue;
-  if (!isInFileID(IncludeLoc, FID))
-return; // No more files/macros that may be "contained" in this file.
-
-  // Skip the files/macros of the #include'd file, we only care about 
macros
-  // that lexed macro arguments from our file.
-  if (Entry.getFile().NumCreatedFIDs)
-ID += Entry.getFile().NumCreatedFIDs - 1/*because of next ++ID*/;
+  } else if (IncludeLoc.isValid()) {
+// If file was included but not from FID, there is no more files/macros
+// that may be "contained" in this file.
+return;
+  }
   continue;
 }
 

diff  --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index dd22cc207860..b7c7e2693ef1 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -415,7 +415,10 @@ bool Preprocessor::HandleEndOfFile(Token , bool 
isEndOfMacro) {
 }
 
 if (!isEndOfMacro && CurPPLexer &&
-SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid()) {
+(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
+ // Predefines file doesn't have a valid include location.
+ (PredefinesFileID.isValid() &&
+  CurPPLexer->getFileID() == PredefinesFileID))) {
   // Notify SourceManager to record the number of FileIDs that were created
   // during lexing of the #include'd file.
   unsigned NumFIDs =

diff  --git a/clang/unittests/Basic/SourceManagerTest.cpp 
b/clang/unittests/Basic/SourceManagerTest.cpp
index f4bdd9c0aefc..850a08b74ace 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -294,10 +294,16 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
   TrivialModuleLoader ModLoader;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, &*Target);
+
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
   SourceMgr, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
+  // Ensure we can get expanded locations in presence of implicit includes.
+  // These are 
diff erent than normal includes since predefines buffer doesn't
+  // have a valid insertion location.
+  PP.setPredefines("#include \"/implicit-header.h\"");
+  FileMgr.getVirtualFile("/implicit-header.h", 0, 0);
   PP.Initialize(*Target);
   PP.EnterMainSourceFile();
 

diff  --git 

[clang-tools-extra] 7d1ee63 - [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.

2020-04-22 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-04-22T21:00:20+02:00
New Revision: 7d1ee639cb9efea364bec90afe4d1161ec624a7f

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

LOG: [clangd] Fix a crash for accessing a null template decl returned by 
findExplicitReferences.

Summary: Fixes https://github.com/clangd/clangd/issues/347.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 1ff20e6e4bc1..be3306f3fc78 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -860,15 +860,17 @@ class ExplicitReferenceCollector
   // TemplateArgumentLoc is the only way to get locations for references to
   // template template parameters.
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
+llvm::SmallVector Targets;
 switch (A.getArgument().getKind()) {
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
+  if (const auto *D = A.getArgument()
+  .getAsTemplateOrTemplatePattern()
+  .getAsTemplateDecl())
+Targets.push_back(D);
   reportReference(ReferenceLoc{A.getTemplateQualifierLoc(),
A.getTemplateNameLoc(),
-   /*IsDecl=*/false,
-   {A.getArgument()
-.getAsTemplateOrTemplatePattern()
-.getAsTemplateDecl()}},
+   /*IsDecl=*/false, Targets},
   DynTypedNode::create(A.getArgument()));
   break;
 case TemplateArgument::Declaration:

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f943772e052e..03cdc02fbb18 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1286,6 +1286,20 @@ TEST_F(FindExplicitReferencesTest, All) {
 "1: targets = {}\n"
 "2: targets = {T}\n"
   },
+  // unknown template name should not crash.
+  {R"cpp(
+template  typename T>
+struct Base {};
+namespace foo {
+template 
+struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
+}
+  )cpp",
+  "0: targets = {foo::Derive::T}, decl\n"
+  "1: targets = {foo::Derive}, decl\n"
+  "2: targets = {Base}\n"
+  "3: targets = {foo::Derive::T}\n"
+  "4: targets = {}, qualifier = 'T::'\n"},
 };
 
   for (const auto  : Cases) {



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


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: asbirlea, rnk.
zequanwu added projects: LLVM, clang.
Herald added subscribers: cfe-commits, hiraditya.

We want to add a way to avoid tail calls to noreturn function from being 
merged. 
This patch add nomerge to disable the optimization in IR level.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78659

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1287,6 +1287,10 @@
 if (!TTI.isProfitableToHoist(I1) || !TTI.isProfitableToHoist(I2))
   return Changed;
 
+// If any of the two call sites has nomerge attribute, stop hoisting.
+if (C1->cannotMerge() || C2->cannotMerge())
+  return Changed;
+
 if (isa(I1) || isa(I2)) {
   assert (isa(I1) && isa(I2));
   // The debug location is an integral part of a debug info intrinsic
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1509,6 +1509,7 @@
 /// Return true if this attribute kind only applies to functions.
 static bool isFuncOnlyAttr(Attribute::AttrKind Kind) {
   switch (Kind) {
+  case Attribute::NoMerge:
   case Attribute::NoReturn:
   case Attribute::NoSync:
   case Attribute::WillReturn:
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -368,6 +368,8 @@
 return "noinline";
   if (hasAttribute(Attribute::NonLazyBind))
 return "nonlazybind";
+  if (hasAttribute(Attribute::NoMerge))
+return "nomerge";
   if (hasAttribute(Attribute::NonNull))
 return "nonnull";
   if (hasAttribute(Attribute::NoRedZone))
Index: llvm/include/llvm/IR/InstrTypes.h
===
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1717,6 +1717,9 @@
 addAttribute(AttributeList::FunctionIndex, Attribute::NoDuplicate);
   }
 
+  /// Determine if the invoke cannot be tail merged.
+  bool cannotMerge() const { return hasFnAttr(Attribute::NoMerge); }
+
   /// Determine if the invoke is convergent
   bool isConvergent() const { return hasFnAttr(Attribute::Convergent); }
   void setConvergent() {
Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -97,6 +97,9 @@
 /// Function is called early and/or often, so lazy binding isn't worthwhile.
 def NonLazyBind : EnumAttr<"nonlazybind">;
 
+/// Disable tail merge for this function
+def NoMerge : EnumAttr<"nomerge">;
+
 /// Pointer is known to be not null.
 def NonNull : EnumAttr<"nonnull">;
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1905,6 +1905,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   AddAttributesFromFunctionProtoType(
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -350,6 +350,14 @@
   }];
 }
 
+def NoMergeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+A function declared as ``nomerge`` shall not be tail merged at call sites during
+optimization phase.
+  }];
+}
+
 def AssertCapabilityDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "assert_capability, assert_shared_capability";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1793,6 +1793,13 @@
   let Documentation = [Undocumented];
 }
 
+def NoMerge : InheritableAttr {
+  let Spellings = [Clang<"nomerge">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoMergeDocs];
+  let SimpleHandler = 1;
+}
+
 def NoInstrumentFunction : InheritableAttr {
   let Spellings = [GCC<"no_instrument_function">];
   let Subjects = SubjectList<[Function]>;
___
cfe-commits mailing list

[PATCH] D77641: [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls

2020-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77641



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a reviewer: rsmith.
tra added a subscriber: rsmith.
tra added a comment.

Summoning @rsmith as I'm sure that there are interesting corner cases in lambda 
handling that we didn't consider.

Making lambdas implicitly HD will make it easier to write the code which can't 
be instantiated on one side of the compilation. That's probably observable via 
SFINAE, but I can't tell whether that matters.
By default I'd rather err on handling lambdas the same way as we do regular 
user-authored functions.




Comment at: clang/lib/Sema/SemaCUDA.cpp:722
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));

What about `__global__` lambdas? We probably don't want to add HD attributes on 
them here.



Comment at: clang/test/CodeGenCUDA/lambda.cu:16-26
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;

The test example may not be doing what it's seemingly supposed to be doing:
https://cppinsights.io/s/3a5c42ff

`h()` gets a temporary host-side object which keeps the reference to `a` and 
that reference will actually point to the host-side shadow of the actual 
device-side `a`. When you get to execute `g` it's `this` may not be very usable 
on device side and thus `f.operator()` will probably not work.

Alas, we currently have no diagnostics for that kind of error.

Change it to a non-capturing lambda, perhaps?


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

https://reviews.llvm.org/D78655



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


[PATCH] D78626: [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.

2020-04-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:1293
+struct Base {};
+namespace foo {
+template 

kadircet wrote:
> is namespace required?
yes, the test expects to look for `foo` namespace or `foo` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78626



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


[PATCH] D78660: [SemaObjC] Add a warning for dictionary literals with duplicate keys

2020-04-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, bendjones.
Herald added subscribers: ributzka, dexonsmith, jkorous.

Duplicate keys in a literal break NSDictionary's invariants.

Fixes rdar://50454461


Repository:
  rC Clang

https://reviews.llvm.org/D78660

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/dictionary-literal-duplicates.m

Index: clang/test/SemaObjC/dictionary-literal-duplicates.m
===
--- /dev/null
+++ clang/test/SemaObjC/dictionary-literal-duplicates.m
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -Wno-objc-root-class %s -verify
+// RUN: %clang_cc1 -xobjective-c++ -Wno-objc-root-class %s -verify
+
+#define YES __objc_yes
+#define NO __objc_no
+
+@interface NSNumber
++(instancetype)numberWithChar:(char)value;
++(instancetype)numberWithInt:(int)value;
++(instancetype)numberWithDouble:(double)value;
++(instancetype)numberWithBool:(unsigned char)value;
++(instancetype)numberWithUnsignedLong:(unsigned long)value;
++(instancetype)numberWithLongLong:(long long) value;
++(instancetype)numberWithUnsignedInt:(unsigned)value;
+@end
+
+@interface NSString
+@end
+
+@interface NSDictionary
++ (instancetype)dictionaryWithObjects:(const id[])objects
+  forKeys:(const id[])keys
+count:(unsigned long)cnt;
+@end
+
+void test() {
+  NSDictionary *t1 = @{
+@"foo" : @0, // expected-note 2 {{previous equal key is here}}
+@"foo" : @0, // expected-warning{{duplicate key in dictionary literal}}
+@("foo") : @0, // expected-warning{{duplicate key in dictionary literal}}
+@"foo\0" : @0,
+
+@1 : @0, // expected-note + {{previous equal key is here}}
+@YES : @0, // expected-warning{{duplicate key in dictionary literal}}
+@'\1' : @0, // expected-warning{{duplicate key in dictionary literal}}
+@1 : @0, // expected-warning{{duplicate key in dictionary literal}}
+@1ul : @0, // expected-warning{{duplicate key in dictionary literal}}
+@1ll : @0, // expected-warning{{duplicate key in dictionary literal}}
+#ifdef __cplusplus
+@true : @0, // expected-warning{{duplicate key in dictionary literal}}
+#endif
+@1.0 : @0, // FIXME: should warn
+
+@-1 : @0, // expected-note + {{previous equal key is here}}
+@4294967295u : @0, // no warning
+@-1ll : @0, // expected-warning{{duplicate key in dictionary literal}}
+@(NO-YES) : @0, // expected-warning{{duplicate key in dictionary literal}}
+  };
+}
+
+#ifdef __cplusplus
+template  void variadic(Ts... ts) {
+  NSDictionary *nd = @{
+ts : @0 ...,
+@0 : ts ... // expected-warning 2 {{duplicate key in dictionary literal}} expected-note 2 {{previous equal key is here}}
+  };
+}
+
+void call_variadic() {
+  variadic(@0, @1, @2); // expected-note {{in instantiation}}
+}
+#endif
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -894,6 +894,62 @@
 ArrayWithObjectsMethod, SR));
 }
 
+/// Check for duplicate keys in an ObjC dictionary literal. For instance:
+///   NSDictionary *nd = @{ @"foo" : @"bar", @"foo" : @"baz" };
+static void
+CheckObjCDictionaryLiteralDuplicateKeys(Sema ,
+ObjCDictionaryLiteral *Literal) {
+  if (Literal->isValueDependent() || Literal->isTypeDependent())
+return;
+
+  // NSNumber has quite relaxed equality semantics (for instance, @YES is
+  // considered equal to @1.0). For now, ignore floating points and just do a
+  // bit-width and sign agnostic integer compare.
+  struct APSIntCompare {
+bool operator()(const llvm::APSInt , const llvm::APSInt ) const {
+  return llvm::APSInt::compareValues(LHS, RHS) < 0;
+}
+  };
+
+  llvm::DenseMap StringKeys;
+  std::map IntegralKeys;
+
+  auto checkOneKey = [&](auto , const auto , SourceLocation Loc) {
+auto Pair = Map.insert({Key, Loc});
+if (!Pair.second) {
+  S.Diag(Loc, diag::warn_nsdictionary_duplicate_key);
+  S.Diag(Pair.first->second, diag::note_nsdictionary_duplicate_key_here);
+}
+  };
+
+  for (unsigned Idx = 0, End = Literal->getNumElements(); Idx != End; ++Idx) {
+Expr *Key = Literal->getKeyValueElement(Idx).Key->IgnoreParenImpCasts();
+
+if (auto *StrLit = dyn_cast(Key)) {
+  StringRef Bytes = StrLit->getString()->getBytes();
+  SourceLocation Loc = StrLit->getExprLoc();
+  checkOneKey(StringKeys, Bytes, Loc);
+}
+
+if (auto *BE = dyn_cast(Key)) {
+  Expr *Boxed = BE->getSubExpr();
+  SourceLocation Loc = BE->getExprLoc();
+
+  // Check for @("foo").
+  if (auto *Str = dyn_cast(Boxed->IgnoreParenImpCasts())) {
+checkOneKey(StringKeys, Str->getBytes(), Loc);
+continue;
+  }
+
+  Expr::EvalResult Result;
+  if 

[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-04-22 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy created this revision.
LemonBoy added a reviewer: rsmith.
LemonBoy added a project: clang.
Herald added a subscriber: cfe-commits.

Some early errors during the ASTUnit creation were not transferred to the 
`FailedParseDiagnostic` so when the code in `LoadFromCommandLine` swaps its 
content with the content of `StoredDiagnostics` they cannot be retrieved by the 
user in any way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78658

Files:
  clang/lib/Frontend/ASTUnit.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp

Index: clang/unittests/Frontend/ASTUnitTest.cpp
===
--- clang/unittests/Frontend/ASTUnitTest.cpp
+++ clang/unittests/Frontend/ASTUnitTest.cpp
@@ -111,4 +111,30 @@
 llvm::MemoryBuffer::MemoryBuffer_MMap);
 }
 
+TEST_F(ASTUnitTest, LoadFromCommandLineEarlyError) {
+  EXPECT_FALSE(
+  llvm::sys::fs::createTemporaryFile("ast-unit", "c", FD, InputFileName));
+  input_file = std::make_unique(InputFileName, FD);
+  input_file->os() << "";
+
+  const char *Args[] = {"clang", "-target", "foobar", InputFileName.c_str()};
+
+  auto Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions());
+  auto PCHContainerOps = std::make_shared();
+  std::unique_ptr ErrUnit;
+
+  ASTUnit *AST = ASTUnit::LoadFromCommandLine(
+  [0], [4], PCHContainerOps, Diags, "", false,
+  CaptureDiagsKind::All, None, true, 0, TU_Complete, false, false, false,
+  SkipFunctionBodiesScope::None, false, true, false, false, None, ,
+  nullptr);
+
+  if (!AST)
+FAIL() << "failed to create ASTUnit";
+
+  ASSERT_NE(ErrUnit, nullptr);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_NE(ErrUnit->stored_diag_size(), 0U);
+}
+
 } // anonymous namespace
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1118,6 +1118,18 @@
   std::unique_ptr Clang(
   new CompilerInstance(std::move(PCHContainerOps)));
 
+  auto OnError = [&]() {
+// Remove the overridden buffer we used for the preamble.
+SavedMainFileBuffer = nullptr;
+
+// Keep the ownership of the data in the ASTUnit because the client may
+// want to see the diagnostics.
+transferASTDataFromCompilerInstance(*Clang);
+FailedParseDiagnostics.swap(StoredDiagnostics);
+StoredDiagnostics.clear();
+NumStoredDiagnosticsFromDriver = 0;
+  };
+
   // Ensure that Clang has a FileManager with the right VFS, which may have
   // changed above in AddImplicitPreamble.  If VFS is nullptr, rely on
   // createFileManager to create one.
@@ -1141,8 +1153,10 @@
   // Create the target instance.
   Clang->setTarget(TargetInfo::CreateTargetInfo(
   Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->hasTarget()) {
+OnError();
 return true;
+  }
 
   // Inform the target of the language options.
   //
@@ -1199,8 +1213,10 @@
   llvm::CrashRecoveryContextCleanupRegistrar
 ActCleanup(Act.get());
 
-  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
-goto error;
+  if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
+OnError();
+return true;
+  }
 
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
@@ -1210,7 +1226,8 @@
 
   if (llvm::Error Err = Act->Execute()) {
 consumeError(std::move(Err)); // FIXME this drops errors on the floor.
-goto error;
+OnError();
+return true;
   }
 
   transferASTDataFromCompilerInstance(*Clang);
@@ -1220,18 +1237,6 @@
   FailedParseDiagnostics.clear();
 
   return false;
-
-error:
-  // Remove the overridden buffer we used for the preamble.
-  SavedMainFileBuffer = nullptr;
-
-  // Keep the ownership of the data in the ASTUnit because the client may
-  // want to see the diagnostics.
-  transferASTDataFromCompilerInstance(*Clang);
-  FailedParseDiagnostics.swap(StoredDiagnostics);
-  StoredDiagnostics.clear();
-  NumStoredDiagnosticsFromDriver = 0;
-  return true;
 }
 
 static std::pair
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Hana Joo via Phabricator via cfe-commits
h-joo updated this revision to Diff 259343.
h-joo added a comment.

In D78643#1997405 , @ABataev wrote:

> In D78643#1997344 , @jdoerfert wrote:
>
> > This looks reasonable to me. @ABataev WDYT?
>
>
> I would add a positive test with -ast-print




1. Changed into a positive test with -ast-print
2. Just `QualType BaseType = ASE->getBase()->getType().getNonReferenceType();` 
and dropped all the call for getNonReferenceType() in later checks.

Thank you for your time for the review! I do have one more question to ask. I 
don't understand the log of the build failure, would you be able to give me a 
bit of a hint?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depend_template_subscription.cpp


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) 
+  {
+;
+  }
+}
+// CHECK: template  void test(double *A, IndexT k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+// CHECK: template<> void test(double *A, int k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable 
lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function 
template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,24 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) 
{
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType().getNonReferenceType();
+  if (!BaseType->isDependentType() && !BaseType->isPointerType() &&
+  !BaseType->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0) << 
RefExpr->getSourceRange();
+continue;
+  }
+}
+
 ExprResult Res;
 {
   Sema::TentativeAnalysisScope Trap(*this);


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) 
+  {
+;
+  }
+}
+// CHECK: template  void test(double *A, IndexT k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+// CHECK: template<> void test(double *A, int k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function template specialization 'test2' requested 

[PATCH] D62368: Add support for Hygon Dhyana processor

2020-04-22 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

Hey,

`clang/lib/Headers/cpuid.h` would have to be in its own CL that would have to 
be sent separately from the Scudo one.
It would have to be reviewed by clang people and likely some tests added.

Once this is done and landed, then the Scudo part can happen.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[clang] 1b3f1f4 - Rename warning identifiers from cxx2a to cxx20; NFC.

2020-04-22 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-04-22T14:31:13-04:00
New Revision: 1b3f1f443670f202a0490ccf9d1f7b28e949bfe7

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

LOG: Rename warning identifiers from cxx2a to cxx20; NFC.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 9e0449d34104..ef90bdf84c8a 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -33,7 +33,7 @@ def warn_cxx98_compat_less_colon_colon : Warning<
 def warn_cxx17_compat_spaceship : Warning<
   "'<=>' operator is incompatible with C++ standards before C++20">,
   InGroup, DefaultIgnore;
-def warn_cxx2a_compat_spaceship : Warning<
+def warn_cxx20_compat_spaceship : Warning<
   "'<=>' is a single token in C++20; "
   "add a space to avoid a change in behavior">,
   InGroup;
@@ -78,7 +78,7 @@ def ext_token_used : Extension<"extension used">,
 
 def warn_cxx11_keyword : Warning<"'%0' is a keyword in C++11">,
   InGroup, DefaultIgnore;
-def warn_cxx2a_keyword : Warning<"'%0' is a keyword in C++20">,
+def warn_cxx20_keyword : Warning<"'%0' is a keyword in C++20">,
   InGroup, DefaultIgnore;
 
 def ext_unterminated_char_or_string : ExtWarn<

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 29497f9c8296..337614c33661 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -676,7 +676,7 @@ def err_ms_property_expected_comma_or_rparen : Error<
 def err_ms_property_initializer : Error<
   "property declaration cannot have an in-class initializer">;
 
-def warn_cxx2a_compat_explicit_bool : Warning<
+def warn_cxx20_compat_explicit_bool : Warning<
   "this expression will be parsed as explicit(bool) in C++20">,
   InGroup, DefaultIgnore;
 def warn_cxx17_compat_explicit_bool : Warning<

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 014ee1c2f2d7..1101bd5a4bb6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2009,7 +2009,7 @@ def err_reference_bind_init_list : Error<
 def err_init_list_bad_dest_type : Error<
   "%select{|non-aggregate }0type %1 cannot be initialized with an initializer "
   "list">;
-def warn_cxx2a_compat_aggregate_init_with_ctors : Warning<
+def warn_cxx20_compat_aggregate_init_with_ctors : Warning<
   "aggregate initialization of type %0 with user-declared constructors "
   "is incompatible with C++20">, DefaultIgnore, InGroup;
 
@@ -2530,7 +2530,7 @@ def warn_cxx11_compat_constexpr_body_invalid_stmt : 
Warning<
   "use of this statement in a constexpr %select{function|constructor}0 "
   "is incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;
-def ext_constexpr_body_invalid_stmt_cxx2a : ExtWarn<
+def ext_constexpr_body_invalid_stmt_cxx20 : ExtWarn<
   "use of this statement in a constexpr %select{function|constructor}0 "
   "is a C++20 extension">, InGroup;
 def warn_cxx17_compat_constexpr_body_invalid_stmt : Warning<
@@ -2593,7 +2593,7 @@ def note_constexpr_body_previous_return : Note<
   "previous return statement is here">;
 
 // C++20 function try blocks in constexpr
-def ext_constexpr_function_try_block_cxx2a : ExtWarn<
+def ext_constexpr_function_try_block_cxx20 : ExtWarn<
   "function try block in constexpr %select{function|constructor}0 is "
   "a C++20 extension">, InGroup;
 def warn_cxx17_compat_constexpr_function_try_block : Warning<
@@ -6294,10 +6294,10 @@ def note_array_init_plain_string_into_char8_t : Note<
 def err_array_init_utf8_string_into_char : Error<
   "%select{|ISO C++20 does not permit }0initialization of char array with "
   "UTF-8 string literal%select{ is not permitted by '-fchar8_t'|}0">;
-def warn_cxx2a_compat_utf8_string : Warning<
+def warn_cxx20_compat_utf8_string : Warning<
   "type of UTF-8 string literal will change from array of const char to "
   "array of const char8_t in C++20">, InGroup, DefaultIgnore;
-def note_cxx2a_compat_utf8_string_remove_u8 : Note<
+def note_cxx20_compat_utf8_string_remove_u8 : Note<
   "remove 'u8' prefix to avoid a change of behavior; "
   "Clang encodes unprefixed 

[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 259341.
vsavchenko added a comment.

Add more clarity on what we test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638

Files:
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp


Index: clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
===
--- /dev/null
+++ clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+// We want to check here that the notes about the origins of the null pointer
+// (array[index] = foo()) will get to the final report.
+//
+// The analyzer used to drop exploded nodes for array subscripts when it was
+// time to collect redundant nodes. This GC-like mechanism kicks in only when
+// the exploded graph is large enough (>1K nodes). For this reason, 'index'
+// is a global variable, and the sink point is inside of a loop.
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop 
condition is false. Execution continues on line 34}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 
'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is 
null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {


Index: clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
===
--- /dev/null
+++ clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+// We want to check here that the notes about the origins of the null pointer
+// (array[index] = foo()) will get to the final report.
+//
+// The analyzer used to drop exploded nodes for array subscripts when it was
+// time to collect redundant nodes. This GC-like mechanism kicks in only when
+// the exploded graph is large enough (>1K nodes). For this reason, 'index'
+// is a global variable, and the sink point is inside of a loop.
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop condition is false. Execution continues on line 34}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-04-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D76801#1996376 , @labath wrote:

> In D76801#1995058 , @dblaikie wrote:
>
> > > It becomes a gdb-index problem because with an index the debugger will do 
> > > a (hashed?) string lookup and expect the string to be there. If the 
> > > strings differ, the lookup won't find anything. In the no-index scenario, 
> > > the debugger has to trawl the debug info itself, and so it has some 
> > > opportunities to do fuzzy matching.
> >
> > That surprises me a bit - given that one of the things debuggers provide is 
> > autocomplete (I'm unlikely to write out a type name exactly as the debug 
> > info contains it - if two compilers can't agree, it's much less likely that 
> > all users will agree with any compiler rendering), which I'd have thought 
> > would be facilitated by the index too - in which case lookup via exact 
> > match wouldn't be viable, you'd still want a way to list anything with a 
> > matching substring (or at least prefix), etc. Which could help facilitate 
> > lookup fuzzy matching like in this sort of case.
>
>
> That is kind of true, and I don't really have a definitive reply to that. I 
> suppose there is a difference between the lookups done for type completion 
> and those done e.g. in expression evaluation. The latter are probably more 
> frequent and are assumed to be correct. Maybe they shouldn't be, but in that 
> cases, then there would probably be no use for the hash tables in indexes (I 
> am not very familiar with the gdb index, but I know it has hash tables 
> similar to debug_names/apple_names). I don't know what gdb does for tab 
> completion, but it probably bypasses the hash table (though the index could 
> still be useful even then as it has a concise list of all strings in the 
> debug info), or it gets the list of strings-to-complete from a completely 
> different source (demangled function names?).
>
> Tab completion is always a bit dodgy. E.g., in your example `ptype tmpl` 
> completes to `ptype tmpl>`, but then running that produces an 
> error: `No symbol "tmpl" in current context.`
>
> In lldb, tab completion in expressions works by hooking into the regular 
> clang tab-completion machinery used by editors.  The up- and down-side of 
> that is that it uses the same code path used for actual expression evaluation 
> -- i.e. all the types will be looked up the same (exact) way.
>
> Speaking of templates and indexes, the thing we would really like in lldb 
> would be to have just the bare names of templated class in the indexes -- 
> that way we could reliably look up all instantiations of a template and do 
> the filtering ourselves. However, this runs afoul of the dwarf specification, 
> which says that the index names should match the DW_AT_names of relevant DIEs 
> (and these contain the template arguments for other reasons...). This means 
> that currently we have outstanding issues when looking up templated types, 
> but we haven't really figured out what to do about that...


Yeah, points all taken - as for this actual issue... I'm kind of inclined to 
say "hey, our template names already diverge somewhat - and this divergence is 
in the realm of acceptable by gdb (without an index) so... *thumbs up*/let's 
stick with it" & as I think you mentioned earlier, this is more a problem for 
the index support, than for the debug info producer. I don't think it's a 
reasonable goal that Clang & GCC produce /exactly/ the same names for templates 
like this... I mean, we /could/ try, but I don't think it's worthwhile 
(especially given that gdb's got support intended to do fuzzy matching/allow 
some divergence)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Basic/SourceManager.cpp:1816
+  } else if (IncludeLoc.isValid()) {
+// If file wasn't included from FID, there is no more files/macros that
+// may be "contained" in this file.

wasn't included from FID -> was included but not from FID


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D78643#1997344 , @jdoerfert wrote:

> This looks reasonable to me. @ABataev WDYT?


I would add a positive test with -ast-print




Comment at: clang/lib/Sema/SemaOpenMP.cpp:15913
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&

Just `QualType BaseType = ASE->getBase()->getType().getNonReferenceType();` and 
drop the call for `getNonReferenceType()` in later checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/test/Analysis/PR53280338.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+

martong wrote:
> AFAIK rdar is not accessible outside Apple. So, for the rest of the open 
> source developers any rdar info is totally useless. Thus, could you please 
> copy the relevant parts of the bug description from there into the test file? 
> Would be even better if we could just mention the rdar link in the test file 
> and the filename itself was better explaining the nature of the bug.
It is a fair point, I'll make it more clear what exactly we are testing here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D75479: [clangd] go-to-def on names in comments etc that are used nearby.

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f1c2bf1712c: [clangd] go-to-def on names in comments etc 
that are used nearby. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75479

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -685,10 +685,15 @@
 
 auto AST = TU.build();
 auto Index = TU.index();
-auto Results = locateSymbolNamedTextuallyAt(
-AST, Index.get(),
+auto Word = SpelledWord::touching(
 cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-testPath(TU.Filename));
+AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word touching point!" << Test;
+  continue;
+}
+auto Results =
+locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
 
 if (!WantDecl) {
   EXPECT_THAT(Results, IsEmpty()) << Test;
@@ -788,10 +793,12 @@
   auto TU = TestTU::withCode(T.code());
   auto AST = TU.build();
   auto Index = TU.index();
-  auto Results = locateSymbolNamedTextuallyAt(
-  AST, Index.get(),
+  auto Word = SpelledWord::touching(
   cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-  testPath(TU.Filename));
+  AST.getTokens(), AST.getLangOpts());
+  ASSERT_TRUE(Word);
+  auto Results =
+  locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
   EXPECT_THAT(Results,
   UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
Sym("uniqueMethodName", T.range("BarLoc";
@@ -985,6 +992,101 @@
   ElementsAre(Sym("foo", FooWithoutHeader.range(;
 }
 
+TEST(LocateSymbol, NearbyTokenSmoke) {
+  auto T = Annotations(R"cpp(
+// prints e^rr and crashes
+void die(const char* [[err]]);
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  // We don't pass an index, so can't hit index-based fallback.
+  EXPECT_THAT(locateSymbolAt(AST, T.point()),
+  ElementsAre(Sym("err", T.range(;
+}
+
+TEST(LocateSymbol, NearbyIdentifier) {
+  const char *Tests[] = {
+  R"cpp(
+  // regular identifiers (won't trigger)
+  int hello;
+  int y = he^llo;
+)cpp",
+  R"cpp(
+  // disabled preprocessor sections
+  int [[hello]];
+  #if 0
+  int y = ^hello;
+  #endif
+)cpp",
+  R"cpp(
+  // comments
+  // he^llo, world
+  int [[hello]];
+)cpp",
+  R"cpp(
+  // not triggered by string literals
+  int hello;
+  const char* greeting = "h^ello, world";
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations
+  #define INT int
+  [[INT]] x;
+  // I^NT
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations (even if they expand to nothing)
+  #define EMPTY
+  [[EMPTY]] int x;
+  // E^MPTY
+)cpp",
+
+  R"cpp(
+  // prefer nearest occurrence, backwards is worse than forwards
+  int hello;
+  int x = hello;
+  // h^ello
+  int y = [[hello]];
+  int z = hello;
+)cpp",
+
+  R"cpp(
+  // short identifiers find near results
+  int [[hi]];
+  // h^i
+)cpp",
+  R"cpp(
+  // short identifiers don't find far results
+  int hi;
+
+
+
+  // h^i
+)cpp",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+const auto  = AST.getSourceManager();
+llvm::Optional Nearby;
+auto Word =
+SpelledWord::touching(cantFail(sourceLocationInMainFile(SM, T.point())),
+  AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word at point! " << Test;
+  continue;
+}
+if (const auto *Tok = findNearbyIdentifier(*Word, AST.getTokens()))
+  Nearby = halfOpenToRange(SM, CharSourceRange::getCharRange(
+   Tok->location(), Tok->endLocation()));
+if (T.ranges().empty())
+  EXPECT_THAT(Nearby, Eq(llvm::None)) << Test;
+else
+  EXPECT_EQ(Nearby, T.range()) << Test;
+  }
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ 

[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D78565#1997372 , @greened wrote:

> In D78565#1996297 , @SjoerdMeijer 
> wrote:
>
> > Fair enough, perhaps the audience is too small here on llvm.org for this 
> > and this is too niche. In A-profile we have the same problem, so could the 
> > exercise for an A-core here, but can't spend time on that now, so will 
> > abandon this.
>
>
> I would find this extremely valuable in the clang documentation.  Not sure 
> why this should be put on developer.arm.com as it is compiler-specific as wel 
> as (sub-)target-specific.


To be clear, I also like Peter's suggestion of documenting all `-m` options as 
gcc does.  There's room for both-and here.


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

https://reviews.llvm.org/D78565



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

Lambda functions do not have names, therefore they do not need host/device
attribute for overloading resolution. They are also have internal linkage and
is only emitted if used, therefore no need to use host/device attribute to
indicate that they should only be emitted for host or device, since clang
can detect whether they are used and emitted accordingly.

Therefore it seems letting lambda functions have host device attributes
by default should not cause ambiguity or unexpected emission.

On the other hand, inferring host/device attribute of lambda function
by context is inaccurate, since a lambda function can be defined in
a host function and passed to a template kernel as template argument
and called in that kernel, i.e., many cases a lambda function defined in
a host function is intended to be a device function.

This patch let lambda function be host device by default for HIP.
This should make lambda easier to use without unwanted side effect.


https://reviews.llvm.org/D78655

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/lambda.cu


Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] 
c"_Z1gIZ4mainEUlvE_EvT_\00"
+// HOST: define internal void @_Z1hIZ4mainEUlvE_EvT_
+// HOST: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+// DEV: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: define internal void @_ZZ4mainENKUlvE_clEv
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));


Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] c"_Z1gIZ4mainEUlvE_EvT_\00"
+// HOST: define internal void @_Z1hIZ4mainEUlvE_EvT_
+// HOST: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+// DEV: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: define internal void @_ZZ4mainENKUlvE_clEv
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D78565#1996297 , @SjoerdMeijer 
wrote:

> Fair enough, perhaps the audience is too small here on llvm.org for this and 
> this is too niche. In A-profile we have the same problem, so could the 
> exercise for an A-core here, but can't spend time on that now, so will 
> abandon this.


I would find this extremely valuable in the clang documentation.  Not sure why 
this should be put on developer.arm.com as it is compiler-specific as wel as 
(sub-)target-specific.


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

https://reviews.llvm.org/D78565



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


[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This looks reasonable to me. @ABataev WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 259332.
kadircet marked an inline comment as done.
kadircet added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649

Files:
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/unittests/Basic/SourceManagerTest.cpp
  clang/unittests/Lex/LexerTest.cpp


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+  EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
+1U);
+}
 } // anonymous namespace
Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -294,10 +294,16 @@
   TrivialModuleLoader ModLoader;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, &*Target);
+
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
   SourceMgr, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
+  // Ensure we can get expanded locations in presence of implicit includes.
+  // These are different than normal includes since predefines buffer doesn't
+  // have a valid insertion location.
+  PP.setPredefines("#include \"/implicit-header.h\"");
+  FileMgr.getVirtualFile("/implicit-header.h", 0, 0);
   PP.Initialize(*Target);
   PP.EnterMainSourceFile();
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -415,7 +415,10 @@
 }
 
 if (!isEndOfMacro && CurPPLexer &&
-SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid()) {
+(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
+ // Predefines file doesn't have a valid include location.
+ (PredefinesFileID.isValid() &&
+  CurPPLexer->getFileID() == PredefinesFileID))) {
   // Notify SourceManager to record the number of FileIDs that were created
   // during lexing of the #include'd file.
   unsigned NumFIDs =
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1800,15 +1800,23 @@
   return;
 if (Entry.isFile()) {
   SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
-  if (IncludeLoc.isInvalid())
+  bool IncludedInFID =
+  (IncludeLoc.isValid() && isInFileID(IncludeLoc, FID)) ||
+  // Predefined header doesn't have a valid include location in main
+  // file, but any files created by it should still be skipped when
+  // computing macro args expanded in the main file.
+  (FID == MainFileID && Entry.getFile().Filename == "");
+  if (IncludedInFID) {
+// Skip the files/macros of the #include'd file, we only care about
+// macros that lexed macro arguments from our file.
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;
 continue;
-  if (!isInFileID(IncludeLoc, FID))
-return; // No more files/macros that may be "contained" in this file.
-
-  // Skip the files/macros of the #include'd file, we only care about 
macros
-  // that lexed macro arguments from our file.
-  if (Entry.getFile().NumCreatedFIDs)
-ID += Entry.getFile().NumCreatedFIDs - 1/*because of next ++ID*/;
+  } else if (IncludeLoc.isValid()) {
+// If file wasn't included from FID, there is no more files/macros that
+// may be "contained" in this file.
+return;
+  }
   continue;
 }
 


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+

[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

2020-04-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I personally don't think the note is useful. What we're trying to tell the user 
is "don't use X after you've moved out of X" -- whether the move actually has 
an effect or not is not useful information. To me, adding `; move of a 'const' 
argument has no effect` just makes things less clear -- are you trying to tell 
me I shouldn't use-after-move, or something else more subtle?

Just my .02


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

https://reviews.llvm.org/D74692



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 4 inline comments as done.
kadircet added inline comments.



Comment at: clang/lib/Lex/PPLexerChange.cpp:420
+ // Predefines file doesn't have a valid include location.
+ CurPPLexer->FID == getPredefinesFileID())) {
   // Notify SourceManager to record the number of FileIDs that were created

sammccall wrote:
> Can we ever get spurious equality here because both sides are 0?
the latter is set during `Preprocessor::EnterMainSourceFile()` which 
initializes the PP and all users seem to be calling it first, therefore I 
assumed it would alwyas be a valid file id.

putting a `&& getPredefinesFileID().isValid()` to be on the safe side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[clang-tools-extra] 3f1c2bf - [clangd] go-to-def on names in comments etc that are used nearby.

2020-04-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-22T19:46:41+02:00
New Revision: 3f1c2bf1712c7496a80a0f89036ab1625ff347a5

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

LOG: [clangd] go-to-def on names in comments etc that are used nearby.

Summary:
This is intended as a companion to (and is inspired by) D72874 which attempts to
resolve these cases using the index.
The intent is we'd try this strategy after the AST-based approach but before the
index-based (I think local usages would be more reliable than index matches).

Reviewers: nridge

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 1943784bfd18..dd4c863cb96a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -855,6 +855,96 @@ llvm::StringSet<> collectWords(llvm::StringRef Content) {
   return Result;
 }
 
+static bool isLikelyIdentifier(llvm::StringRef Word, llvm::StringRef Before,
+   llvm::StringRef After) {
+  // `foo` is an identifier.
+  if (Before.endswith("`") && After.startswith("`"))
+return true;
+  // In foo::bar, both foo and bar are identifiers.
+  if (Before.endswith("::") || After.startswith("::"))
+return true;
+  // Doxygen tags like \c foo indicate identifiers.
+  // Don't search too far back.
+  // This duplicates clang's doxygen parser, revisit if it gets complicated.
+  Before = Before.take_back(100); // Don't search too far back.
+  auto Pos = Before.find_last_of("\\@");
+  if (Pos != llvm::StringRef::npos) {
+llvm::StringRef Tag = Before.substr(Pos + 1).rtrim(' ');
+if (Tag == "p" || Tag == "c" || Tag == "class" || Tag == "tparam" ||
+Tag == "param" || Tag == "param[in]" || Tag == "param[out]" ||
+Tag == "param[in,out]" || Tag == "retval" || Tag == "throw" ||
+Tag == "throws" || Tag == "link")
+  return true;
+  }
+
+  // Word contains underscore.
+  // This handles things like snake_case and MACRO_CASE.
+  if (Word.contains('_')) {
+return true;
+  }
+  // Word contains capital letter other than at beginning.
+  // This handles things like lowerCamel and UpperCamel.
+  // The check for also containing a lowercase letter is to rule out
+  // initialisms like "HTTP".
+  bool HasLower = Word.find_if(clang::isLowercase) != StringRef::npos;
+  bool HasUpper = Word.substr(1).find_if(clang::isUppercase) != 
StringRef::npos;
+  if (HasLower && HasUpper) {
+return true;
+  }
+  // FIXME: consider mid-sentence Capitalization?
+  return false;
+}
+
+llvm::Optional SpelledWord::touching(SourceLocation SpelledLoc,
+  const syntax::TokenBuffer 
,
+  const LangOptions ) 
{
+  const auto  = TB.sourceManager();
+  auto Touching = syntax::spelledTokensTouching(SpelledLoc, TB);
+  for (const auto  : Touching) {
+// If the token is an identifier or a keyword, don't use any heuristics.
+if (tok::isAnyIdentifier(T.kind()) || tok::getKeywordSpelling(T.kind())) {
+  SpelledWord Result;
+  Result.Location = T.location();
+  Result.Text = T.text(SM);
+  Result.LikelyIdentifier = tok::isAnyIdentifier(T.kind());
+  Result.PartOfSpelledToken = 
+  Result.SpelledToken = 
+  auto Expanded =
+  TB.expandedTokens(SM.getMacroArgExpandedLocation(T.location()));
+  if (Expanded.size() == 1 && Expanded.front().text(SM) == Result.Text)
+Result.ExpandedToken = ();
+  return Result;
+}
+  }
+  FileID File;
+  unsigned Offset;
+  std::tie(File, Offset) = SM.getDecomposedLoc(SpelledLoc);
+  bool Invalid = false;
+  llvm::StringRef Code = SM.getBufferData(File, );
+  if (Invalid)
+return llvm::None;
+  unsigned B = Offset, E = Offset;
+  while (B > 0 && isIdentifierBody(Code[B - 1]))
+--B;
+  while (E < Code.size() && isIdentifierBody(Code[E]))
+++E;
+  if (B == E)
+return llvm::None;
+
+  SpelledWord Result;
+  Result.Location = SM.getComposedLoc(File, B);
+  Result.Text = Code.slice(B, E);
+  Result.LikelyIdentifier =
+  isLikelyIdentifier(Result.Text, Code.substr(0, B), Code.substr(E)) &&
+  // should not be a keyword
+  tok::isAnyIdentifier(
+  IdentifierTable(LangOpts).get(Result.Text).getTokenID());
+  for (const 

[clang] 089fbe6 - [Docs] Fixed formatting in release notes, NFC

2020-04-22 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-04-22T18:25:22+01:00
New Revision: 089fbe69193364fee14ed94a58c530d8417dc391

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

LOG: [Docs] Fixed formatting in release notes, NFC

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1f4bc0f0d0da..88edf0092dc5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,8 +61,8 @@ Non-comprehensive list of changes in this release
   v8.1-M MVE instruction set.  supports the complete API defined
   in the Arm C Language Extensions.
 
-- For the ARM target, C-language intrinsics  for the CDE instruction
-  set are now provided.
+- For the ARM target, C-language intrinsics  for the CDE
+  instruction set are now provided.
 
 * clang adds support for a set of  extended integer types (``_ExtInt(N)``) that
   permit non-power of 2 integers, exposing the LLVM integer types. Since a 
major

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 3afdce296fcd..e0ff25622704 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -79,7 +79,7 @@ During this release ...
 * Added support for assembly for the optional Custom Datapath Extension (CDE)
   for Arm M-profile targets.
 
-* Implemented C-language intrinsics  for the CDE instruction set.
+* Implemented C-language intrinsics  for the CDE instruction 
set.
 
 Changes to the MIPS Target
 --



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


[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Hana Joo via Phabricator via cfe-commits
h-joo updated this revision to Diff 259326.
h-joo added a comment.

In D78643#1997103 , @jdoerfert wrote:

> Can we create a test case that shows even if it is a dependent type we will 
> eventuall issue an error if it is not an addressable lvalue or array item?
>  If this is the part that needs refactoring to work, we should add the test 
> with a TODO.


Added a test to check the test triggers in presence of lvalue expression. 
Although the test does not trigger line 15912, but rather line 15905.  I tried 
some examples and it seems like after during  the template instantiation, while 
an ArraySubscriptExpr is being constructed, it already checks whether it's a 
pointer type or an array type, thus, I am thinking this check in line 15912 
might actually be redundant?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depend_template_subscription.cpp


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+
+  #pragma omp task depend(out: A[k]) // Should not print error Bug #45383
+  {
+;
+  }
+}
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable 
lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function 
template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) 
{
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&
+  !BaseType.getNonReferenceType()->isPointerType() &&
+  !BaseType.getNonReferenceType()->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0) << 
RefExpr->getSourceRange();
+continue;
+  }
+}
+
 ExprResult Res;
 {
   Sema::TentativeAnalysisScope Trap(*this);


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+
+  #pragma omp task depend(out: A[k]) // Should not print error Bug #45383
+  {
+;
+  }
+}
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-22 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, again :) Thanks for cleaning this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233



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


[PATCH] D77871: [AArch64] Armv8.6-a Matrix Mult Assembly + Intrinsics

2020-04-22 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 259327.
LukeGeeson marked 5 inline comments as done.
LukeGeeson added a comment.

- fixed typos
- added sroa as mem2reg arg to reduce redundant mem accesses in tests, 
refactored test
- addressed other comments


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

https://reviews.llvm.org/D77871

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-matmul.cpp
  clang/test/CodeGen/aarch64-v8.6a-neon-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/aarch64-matmul.ll
  llvm/test/MC/AArch64/armv8.6a-simd-matmul-error.s
  llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
  llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt

Index: llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt
@@ -0,0 +1,34 @@
+# RUN: llvm-mc -triple=aarch64  -mattr=+i8mm -disassemble < %s   | FileCheck %s
+# RUN: llvm-mc -triple=aarch64  -mattr=+v8.6a -disassemble < %s  | FileCheck %s
+# RUN: not llvm-mc -triple=aarch64  -mattr=+v8.5a -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOI8MM
+
+[0x01,0xa6,0x9f,0x4e]
+[0x01,0xa6,0x9f,0x6e]
+[0x01,0xae,0x9f,0x4e]
+# CHECK: smmla   v1.4s, v16.16b, v31.16b
+# CHECK: ummla   v1.4s, v16.16b, v31.16b
+# CHECK: usmmla  v1.4s, v16.16b, v31.16b
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0xe3,0x9d,0x9e,0x0e]
+[0xe3,0x9d,0x9e,0x4e]
+# CHECK: usdot   v3.2s, v15.8b, v30.8b
+# CHECK: usdot   v3.4s, v15.16b, v30.16b
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0x3f,0xf8,0xa2,0x0f]
+[0x3f,0xf8,0xa2,0x4f]
+# CHECK: usdot   v31.2s, v1.8b, v2.4b[3]
+# CHECK: usdot   v31.4s, v1.16b, v2.4b[3]
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0x3f,0xf8,0x22,0x0f]
+[0x3f,0xf8,0x22,0x4f]
+# CHECK: sudot   v31.2s, v1.8b, v2.4b[3]
+# CHECK: sudot   v31.4s, v1.16b, v2.4b[3]
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
Index: llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
===
--- /dev/null
+++ llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
@@ -0,0 +1,43 @@
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+i8mm   < %s  | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+v8.6a  < %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=+v8.6a-i8mm < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
+
+smmla  v1.4s, v16.16b, v31.16b
+ummla  v1.4s, v16.16b, v31.16b
+usmmla v1.4s, v16.16b, v31.16b
+// CHECK: smmla   v1.4s, v16.16b, v31.16b // encoding: [0x01,0xa6,0x9f,0x4e]
+// CHECK: ummla   v1.4s, v16.16b, v31.16b // encoding: [0x01,0xa6,0x9f,0x6e]
+// CHECK: usmmla  v1.4s, v16.16b, v31.16b // encoding: [0x01,0xae,0x9f,0x4e]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: smmla  v1.4s, v16.16b, v31.16b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: ummla  v1.4s, v16.16b, v31.16b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usmmla  v1.4s, v16.16b, v31.16b
+
+usdot v3.2s, v15.8b, v30.8b
+usdot v3.4s, v15.16b, v30.16b
+// CHECK: usdot   v3.2s, v15.8b, v30.8b   // encoding: [0xe3,0x9d,0x9e,0x0e]
+// CHECK: usdot   v3.4s, v15.16b, v30.16b // encoding: [0xe3,0x9d,0x9e,0x4e]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot v3.2s, v15.8b, v30.8b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot v3.4s, v15.16b, v30.16b
+
+usdot v31.2s, v1.8b,  v2.4b[3]
+usdot v31.4s, v1.16b, v2.4b[3]
+// CHECK: usdot   v31.2s, v1.8b, v2.4b[3] // encoding: [0x3f,0xf8,0xa2,0x0f]
+// CHECK: usdot   v31.4s, v1.16b, v2.4b[3] // encoding: [0x3f,0xf8,0xa2,0x4f]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot   v31.2s, v1.8b, v2.4b[3]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot   v31.4s, v1.16b, v2.4b[3]
+
+sudot v31.2s, v1.8b,  v2.4b[3]
+sudot v31.4s, v1.16b, v2.4b[3]
+// CHECK: sudot   v31.2s, v1.8b, v2.4b[3] // encoding: [0x3f,0xf8,0x22,0x0f]
+// CHECK: sudot   v31.4s, v1.16b, v2.4b[3] // encoding: [0x3f,0xf8,0x22,0x4f]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: 

[PATCH] D75041: [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 259324.
whisperity retitled this revision from "[clang-tidy] Approximate implicit 
conversion issues for the 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check" to "[clang-tidy] Approximate implicit conversion issues in 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'".
whisperity added a comment.

- Re-organised code, removed debug prints, rebased, the usual tidy-up.
- Bug fixes on certain crashes like incomplete types, conversion operator 
templates, etc.
- Even more bug fixes against crashes, hopefully... sorry I lost the individual 
commits in a `squash` I think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041

Files:
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -32,3 +32,6 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'equals2' of similar type ('S') are
 // CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in this range is 'l'
 // CHECK-MESSAGES: :[[@LINE-3]]:20: note: the last parameter in this range is 'r'
+
+void ptrs(int *i, long *l) {}
+// NO-WARN: Mixing fundamentals' pointers is diagnosed by compiler warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
@@ -203,3 +203,20 @@
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Background' is 'OldSchoolTermColour'
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Foreground' is 'OldSchoolTermColour'
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Border' is 'OldSchoolTermColour'
+
+// NO-WARN: Implicit conversions should not warn if the check option is turned off.
+
+void integral1(signed char sc, int si) {}
+
+struct FromInt {
+  FromInt(int);
+};
+void userConv1(int i, FromInt fi) {}
+
+struct Base {};
+struct Derived1 : Base {};
+struct Derived2 : Base {};
+void upcasting(Base *bp, Derived1 *d1p, Derived2 *d2p) {}
+void upcasting_ref(const Base , const Derived1 , const Derived2 ) {}
+
+// END of NO-WARN.
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
@@ -0,0 +1,362 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.ImplicitConversion, value: 1} \
+// RUN:   ]}' --
+
+void compare(int a, int b, int c) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 3 adjacent parameters for 'compare' of similar type ('int') are easily swapped by mistake [experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in this range is 'a'
+// CHECK-MESSAGES: :[[@LINE-3]]:32: note: the last parameter in this range is 'c'
+
+void b(bool b1, bool b2, int i) {}
+// CHECK-MESSAGES: 

[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst:136-139
+typedef   T  element_type;
+typedef const Tconst_element_type;
+typedef   T &reference_type;
+typedef const T &  const_reference_type;

Why are these typos still here, `typedef`??? instead of `typename`.


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

https://reviews.llvm.org/D69560



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


[PATCH] D75041: [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 2 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp:747
 OS << "...";
-  } else
+  } else {
 // There are things like "GCC Vector type" and such that who knows how

'chute, I hate merge conflicts...



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst:113-120
+.. warning::
+Turning the modelling of implicit conversion sequences on
+relaxes the constraints for "type convertibility" significantly,
+however, it also applies a generous performance hit on the check's 
cost.
+The check will have to explore a **polynomially more** possibilities:
+O(n\ :sup:`2`\ ) instead of O(n) for each function's ``n`` parameters.
+The emitted diagnostics will also be more verbose, which might take 
more

This change to check the "left half" of a full graph moved to the main checker 
patch D69560 and there is no significant (few seconds, on large projects like 
LLVM) time difference between the modes at all even on large projects... so 
this fearmongering text should be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041



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


[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 259320.
whisperity added a comment.

- Better organisation of code, cleanup of debug prints, fix nomenclature of 
functions
- Explicitly mention the first and last param of the range for clarity
- Downlift the logic of joining and breaking ranges to main patch (this isn't 
terribly useful at this point, but both subsequent improvements to the check 
depend on this change)
  - Basically no longer assume that if param N can be swapped with param 1, 
then it can also be swapped with 2, 3, etc. without checking.
- Made the list of ignored parameter and type names configurable as a checker 
option
- Changed the default value of `MinimumLength` to `2`, as prescribed in the 
guideline's text.


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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-ignores.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN:   ]}' --
+
+struct T {};
+
+void memcpy(struct T *restrict dest, const struct T *restrict src) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'memcpy' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:32: note: the first parameter in this range is 'dest'
+// CHECK-MESSAGES: :[[@LINE-3]]:63: note: the last parameter in this range is 'src'
+// CHECK-MESSAGES: :[[@LINE-4]]:38: note: at a call site, 'const struct T * restrict' might bind with same force as 'struct T *restrict'
+
+void merge(struct T *dst, const struct T *src1, const struct T *src2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 3 adjacent parameters for 'merge' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in this range is 'dst'
+// CHECK-MESSAGES: :[[@LINE-3]]:65: note: the last parameter in this range is 'src2'
+// CHECK-MESSAGES: :[[@LINE-4]]:27: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+// CHECK-MESSAGES: :[[@LINE-5]]:49: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+
+int equals(struct T a, struct T b) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters for 'equals' of similar type ('struct T') are
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in this range is 'a'
+// CHECK-MESSAGES: :[[@LINE-3]]:33: note: the last parameter in this range is 'b'
+
+typedef struct {
+  int x;
+} S;
+
+int equals2(S l, S r) { return l.x == r.x; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'equals2' of similar type ('S') are
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in this range is 'l'
+// CHECK-MESSAGES: :[[@LINE-3]]:20: note: the last parameter in this range is 'r'
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
@@ -0,0 +1,205 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.MinimumLength, value: 3} \
+// 

[PATCH] D78652: [clang-tidy] Add "ignore related parameters" heuristics to 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added reviewers: aaron.ballman, alexfh, hokein, JonasToth, zporky.
whisperity added projects: clang-tools-extra, clang.
Herald added subscribers: cfe-commits, martong, gamesh411, dkrupp, rnkovacs, 
kbarton, nemanjai.
whisperity added a parent revision: D69560: [clang-tidy] Add 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check.
Herald added a subscriber: wuzish.

The basic version of the checker only considers the pseudo-equality between 
types of parameters as the predicate on deciding whether or not the two can be 
mixed up with each other at a potential call site. This, together with a low 
minimum range length requirement, results in an incredibly verbose checker with 
report count potentially in the multiple thousands.

This patch aims to mitigate that problem by silencing warnings about adjacent 
parameter ranges in which the parameters are //related// to each other.
While this change definitely brings in false negatives (as mixing the arguments 
to `max(a, b)` is still a potential issue, but we really can't do better in 
that case...), the sheer amount of reduction in the report count should make up 
for it. Across multiple projects (from both C and C++), the number of reports 
has dropped by **at least 40%**.
This should help to make sure that the dodgiest interfaces are not hidden under 
clumps of naively generated reports.

Currently, three relatedness heuristics are implemented, each in a way that it 
is easy to, in the future, remove them or add new ones.

- Common expression: if both parameters are found in a common expression 
somewhere in the function, they are considered related. This heuristic is an 
absolute blast because it deals with arithmetics, comparisons, and forwarding 
functions all in one.
- Return: if both parameters are returned on different execution paths of the 
function, they are considered related. This deals with switch-like functions.
- Pass to same function: if both parameters are passed to the same function in 
the same index, they are considered related. This is a special case of 
forwarding. I.e. for `a` and `b` if there exists a call `f(foo, a);` and 
`f(bar, b);`, they are deemed related. Thanks to @zporky, our C++ expert, the 
idea.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78652

Files:
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -1,7 +1,8 @@
 // RUN: %check_clang_tidy %s \
 // RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
 // RUN:   -config='{CheckOptions: [ \
-// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1}, \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CheckRelatedness, value: 0} \
 // RUN:   ]}' --
 
 struct T {};
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
@@ -0,0 +1,187 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CheckRelatedness, value: 1} \
+// RUN:   ]}' --
+
+namespace std {
+// NO-WARN: Not a definition, the user has no chance to fix this!
+int max(int x, int y);
+int abs(int x);
+
+template 
+bool less(const T , const T );
+} // namespace std
+
+class C {
+public:
+  void foo(int a);
+  void bar(int a, int b);
+};
+
+bool coin();
+int f(int a);
+int g(int b);
+int h(int a, 

[PATCH] D78577: [OPENMP50]Basic support for uses_allocators clause.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: rnk.
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:33
 #include "clang/AST/NSAPI.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/PrettyPrinter.h"

I think @rnk might not be happy with this include as it might be costly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78577



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:1805
+  // macro args expanded in the main file.
+  if (Entry.getFile().Filename == "" && FID == getMainFileID()) {
+if (Entry.getFile().NumCreatedFIDs)

nit: reverse the order of this check to avoid the string compare?
You could also consider hoisting `bool IsMainFile` out of the loop, maybe the 
optimizer can see this but I think it's probably a readablity win anyway.



Comment at: clang/lib/Basic/SourceManager.cpp:1806
+  if (Entry.getFile().Filename == "" && FID == getMainFileID()) {
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;

I don't love having this code duplicated.

What about:
```
SourceLocation IncludeLoc = ...
bool IncludedFromMain = isInFileID(IncludeLoc, FID) || (IsMainFile && Filename 
= "");
if (IncludedFromMain) {
  // increment ID
} else if (IncludeLoc.isValid()) { // included, but not from this file
  return
}
continue;
```



Comment at: clang/lib/Lex/PPLexerChange.cpp:420
+ // Predefines file doesn't have a valid include location.
+ CurPPLexer->FID == getPredefinesFileID())) {
   // Notify SourceManager to record the number of FileIDs that were created

Can we ever get spurious equality here because both sides are 0?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/test/Analysis/PR53280338.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+

AFAIK rdar is not accessible outside Apple. So, for the rest of the open source 
developers any rdar info is totally useless. Thus, could you please copy the 
relevant parts of the bug description from there into the test file? Would be 
even better if we could just mention the rdar link in the test file and the 
filename itself was better explaining the nature of the bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D77596: [SveEmitter] Add IsOverloadNone flag and builtins for svpfalse and svcnt[bhwd]_pat

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG662cbaf6476b: [SveEmitter] Add IsOverloadNone flag and 
builtins for svpfalse and svcnt… (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D77596?vs=257824=259318#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77596

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -264,6 +264,14 @@
 llvm_unreachable("Unsupported imm check");
   }
 
+  /// Returns the enum value for the flag type
+  uint64_t getEnumValueForFlag(StringRef C) const {
+auto Res = FlagTypes.find(C);
+if (Res != FlagTypes.end())
+  return Res->getValue();
+llvm_unreachable("Unsupported flag");
+  }
+
   // Returns the SVETypeFlags for a given value and mask.
   uint64_t encodeFlag(uint64_t V, StringRef MaskName) const {
 auto It = FlagTypes.find(MaskName);
@@ -528,6 +536,13 @@
 Immediate = true;
 PredicatePattern = true;
 break;
+  case 'k':
+Predicate = false;
+Signed = true;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
   case 'l':
 Predicate = false;
 Signed = true;
@@ -535,6 +550,20 @@
 ElementBitwidth = Bitwidth = 64;
 NumVectors = 0;
 break;
+  case 'm':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
+  case 'n':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 64;
+NumVectors = 0;
+break;
   case 'S':
 Constant = true;
 Pointer = true;
@@ -831,6 +860,13 @@
   for (auto FlagRec : FlagsList)
 Flags |= FlagRec->getValueAsInt("Value");
 
+  // Create a dummy TypeSpec for non-overloaded builtins.
+  if (Types.empty()) {
+assert((Flags & getEnumValueForFlag("IsOverloadNone")) &&
+   "Expect TypeSpec for overloaded builtin!");
+Types = "i";
+  }
+
   // Extract type specs from string
   SmallVector TypeSpecs;
   TypeSpec Acc;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svpfalse_b()
+{
+  // CHECK-LABEL: test_svpfalse_b
+  // CHECK: ret  zeroinitializer
+  return SVE_ACLE_FUNC(svpfalse,_b,,)();
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+uint64_t test_svcntw_pat()
+{
+  // CHECK-LABEL: test_svcntw_pat
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 0)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_POW2);
+}
+
+uint64_t test_svcntw_pat_1()
+{
+  // CHECK-LABEL: test_svcntw_pat_1
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 1)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_VL1);
+}
+
+uint64_t test_svcntw_pat_2()
+{
+  // CHECK-LABEL: test_svcntw_pat_2
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 2)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_VL2);
+}
+
+uint64_t test_svcntw_pat_3()
+{
+  // CHECK-LABEL: test_svcntw_pat_3
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 3)
+  // CHECK: ret i64 

[PATCH] D70073: [ConstExprPreter] Implemented function calls and if statements

2020-04-22 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70073



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


[PATCH] D78286: [analyzer] Track runtime types represented by Obj-C Class objects

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:198
+  // 'self' variable of the current class method.
+  if (ReceiverSVal == Message.getSelfSVal()) {
+// In this case, we should return the type of the enclosing class

NoQ wrote:
> NoQ wrote:
> > vsavchenko wrote:
> > > NoQ wrote:
> > > > vsavchenko wrote:
> > > > > NoQ wrote:
> > > > > > I believe this is pretty much always the case. At least whenever 
> > > > > > `getInstanceReceiver()` is available. Another exception seem to be 
> > > > > > when `ReceiverSVal` is an `UnknownVal` (in this case `self` is 
> > > > > > going to be `SymbolRegionValue` because it's never set in the 
> > > > > > Store), but that's it. I inferred this by looking at 
> > > > > > `ObjCMethodCall::getInitialStackFrameContents()`.
> > > > > > 
> > > > > > I think we should have used `getSelfSVal()` to begin with.
> > > > > > I believe this is pretty much always the case.
> > > > > 
> > > > > I didn't quite get what you mean by that
> > > > > 
> > > > > 
> > > > What i'm trying to say is that `C.getSVal(RecE)` and 
> > > > `Message.getSelfSVal()` and `Message.getReceiverSVal()` are basically 
> > > > the same `SVal`. It shouldn't be necessary to check both or check 
> > > > whether they're the same; you must have meant to check for something 
> > > > else, probably something purely syntactic.
> > > > 
> > > > 
> > > > 
> > > > > I inferred this by looking at 
> > > > > ObjCMethodCall::getInitialStackFrameContents().
> > > > 
> > > > Wait, so it's only true for inlined methods. For non-inlined methods 
> > > > `getSelfSVal()` will be unknown :/
> > > Yeah, that might be a bit extraneous to do it with `SVal`s, but this code 
> > > for sure does its job (it is definitely not a redundant check). 
> > > `getSelfSVal()` returns receiver of the function //containing// the call 
> > > and not the call itself. So, it does check if we the receiver of the 
> > > message is `self`.
> > > 
> > > I changed it to this way of doing things because it is consistent with 
> > > how the same thing is done in `getRuntimeDefinition`.
> > > `getSelfSVal()` returns receiver of the function containing the call and 
> > > not the call itself
> > 
> >  looks broken to me.
> Let's rename `getSelfSVal()` so that it screamed that it's the callee's self 
> as opposed to the caller's self, and explain in a long comment why do we even 
> care about the caller's self. I.e., that we heuristically assume that if a 
> class method jumps into another class method on the same class object, it's 
> going to be devirtualized to the same class. Which isn't always the case, 
> hence !Precise.
> 
> 
I don't really think that it's a good idea to mix these two worlds:

  - **world one** - interface function that allows to get an `SVal` for `self` 
of the containing method. It does exactly this, for no specific reason. I'm on 
board with renaming, but we need to come up with an appropriate name that 
describes what it gives and not why.
  - **world two** - use-case of this interface method that tries to figure out 
the type of the receiver (for devirtualization purposes or not).

So, the comment can be only here. I agree, I can add more explanation about 
what we are doing in this particular piece of code, but it won't make any sense 
to add this (or similar) comment for `getSelfSVal()`.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:85-87
+  if (const DynamicTypeInfo *DTI = State->get(Sym))
+return *DTI;
+  return {};

NoQ wrote:
> My favorite idiom for this stuff so far:
> ```lang=c++
>   const DynamicTypeInfo *DTI = State->get(Sym);
>   return DTI ? *DTI : {};
> ```
> (not sure `?:` will typecheck correctly in case of `{}` though)
Yep, initializer lists are not allowed in ternary operators.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:147
+static bool isLive(SymbolReaper , const MemRegion *MR) {
+  return SR.isLiveRegion(MR);
+}

NoQ wrote:
> Feel free to rename `isLiveRegion` instead if it helps :)
Unfortunately, it is named a bit differently for a reason, - compiler couldn't 
decide which function to use `bool isLive(const MemRegion *region)` or `bool 
isLive(const VarRegion *VR, bool includeStoreBindings = false) const` for a 
call `isLive(VarRegion *)` (even though it's pretty obvious). Splitting 
`isLive` for `VarRegion` into two functions doesn't seem like an easy one. The 
only option I can see is the introduction of `isLiveImpl` (not very pretty in a 
header file) and two functions `isLive(const VarRegion*) const ` and 
`isLiveIncludingStoreBindings(const VarRegion *) const`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78286



___
cfe-commits mailing list

[PATCH] D78286: [analyzer] Track runtime types represented by Obj-C Class objects

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 259314.
vsavchenko marked 9 inline comments as done.
vsavchenko added a comment.

Fix review remarks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78286

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/class-object-state-dump.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/inlining/ObjCDynTypePopagation.m
  clang/test/Analysis/retain-release-inline.m

Index: clang/test/Analysis/retain-release-inline.m
===
--- clang/test/Analysis/retain-release-inline.m
+++ clang/test/Analysis/retain-release-inline.m
@@ -13,6 +13,7 @@
 // It includes the basic definitions for the test cases below.
 //===--===//
 #define NULL 0
+#define nil ((id)0)
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -21,14 +22,14 @@
 typedef signed long CFIndex;
 typedef CFIndex CFByteOrder;
 typedef struct {
-CFIndex location;
-CFIndex length;
+  CFIndex location;
+  CFIndex length;
 } CFRange;
 static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
-CFRange range;
-range.location = loc;
-range.length = len;
-return range;
+  CFRange range;
+  range.location = loc;
+  range.length = len;
+  return range;
 }
 typedef const void * CFTypeRef;
 typedef const struct __CFString * CFStringRef;
@@ -91,6 +92,7 @@
 - (BOOL)isEqual:(id)object;
 - (id)retain;
 - (oneway void)release;
+- (Class)class;
 - (id)autorelease;
 - (id)init;
 @end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
@@ -100,6 +102,7 @@
 @interface NSObject  {}
 + (id)allocWithZone:(NSZone *)zone;
 + (id)alloc;
++ (Class)class;
 - (void)dealloc;
 @end
 @interface NSObject (NSCoderMethods)
@@ -481,3 +484,33 @@
   [self test_inline_tiny_when_reanalyzing];
 }
 @end
+
+// Original problem: rdar://problem/50739539
+@interface MyClassThatLeaksDuringInit : NSObject
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1;
++ (MyClassThatLeaksDuringInit *)getAnInstance2;
+
+@end
+
+@implementation MyClassThatLeaksDuringInit
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1 {
+  return [[[MyClassThatLeaksDuringInit alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
++ (MyClassThatLeaksDuringInit *)getAnInstance2 {
+  return self class] alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
+- (instancetype)init {
+  if (1) {
+return nil;
+  }
+
+  if (nil != (self = [super init])) {
+  }
+  return self;
+}
+
+@end
Index: clang/test/Analysis/inlining/ObjCDynTypePopagation.m
===
--- clang/test/Analysis/inlining/ObjCDynTypePopagation.m
+++ clang/test/Analysis/inlining/ObjCDynTypePopagation.m
@@ -7,68 +7,67 @@
 PublicSubClass2 *getObj();
 
 @implementation PublicParent
-- (int) getZeroOverridden {
-   return 1;
+- (int)getZeroOverridden {
+  return 1;
 }
-- (int) getZero {
-   return 0;
+- (int)getZero {
+  return 0;
 }
 @end
 
 @implementation PublicSubClass2
-- (int) getZeroOverridden {
-   return 0;
+- (int)getZeroOverridden {
+  return 0;
 }
 
 /* Test that we get the right type from call to alloc. */
-+ (void) testAllocSelf {
++ (void)testAllocSelf {
   id a = [self alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-
-+ (void) testAllocClass {
++ (void)testAllocClass {
   id a = [PublicSubClass2 alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocSuperOverriden {
++ (void)testAllocSuperOverriden {
   id a = [super alloc];
   // Evaluates to 1 in the parent.
-  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}} 
+  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}}
 }
 
-+ (void) testAllocSuper {
++ (void)testAllocSuper {
   id a = [super alloc];
   clang_analyzer_eval([a getZero] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocInit {
++ (void)testAllocInit {
   id a = [[self alloc] init];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testNewSelf {
++ (void)testNewSelf {
   id a = [self new];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-// Casting to parent should not pessimize the dynamic type. 
-+ (void) testCastToParent {
- id a = [[self alloc] init];
- 

  1   2   >