[clang] 6c8041a - [AST][FPEnv] Keep FP options in trailing storage of CastExpr

2020-09-12 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-09-12T14:30:44+07:00
New Revision: 6c8041aa0ffed827636935e59c489b1e390c8542

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

LOG: [AST][FPEnv] Keep FP options in trailing storage of CastExpr

This change allow a CastExpr to have optional FPOptionsOverride object,
stored in trailing storage. Of all cast nodes only ImplicitCastExpr,
CStyleCastExpr, CXXFunctionalCastExpr and CXXStaticCastExpr are allowed
to have FPOptions.

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

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/ExprObjC.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 26e52ad367f8..1672fd707c6d 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3440,9 +3440,11 @@ class CastExpr : public Expr {
   }
   CXXBaseSpecifier **path_buffer();
 
+  friend class ASTStmtReader;
+
 protected:
   CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind,
-   Expr *op, unsigned BasePathSize)
+   Expr *op, unsigned BasePathSize, bool HasFPFeatures)
   : Expr(SC, ty, VK, OK_Ordinary), Op(op) {
 CastExprBits.Kind = kind;
 CastExprBits.PartOfExplicitCast = false;
@@ -3451,17 +3453,27 @@ class CastExpr : public Expr {
"BasePathSize overflow!");
 setDependence(computeDependence(this));
 assert(CastConsistency());
+CastExprBits.HasFPFeatures = HasFPFeatures;
   }
 
   /// Construct an empty cast.
-  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
-: Expr(SC, Empty) {
+  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize,
+   bool HasFPFeatures)
+  : Expr(SC, Empty) {
 CastExprBits.PartOfExplicitCast = false;
 CastExprBits.BasePathSize = BasePathSize;
+CastExprBits.HasFPFeatures = HasFPFeatures;
 assert((CastExprBits.BasePathSize == BasePathSize) &&
"BasePathSize overflow!");
   }
 
+  /// Return a pointer to the trailing FPOptions.
+  /// \pre hasStoredFPFeatures() == true
+  FPOptionsOverride *getTrailingFPFeatures();
+  const FPOptionsOverride *getTrailingFPFeatures() const {
+return const_cast(this)->getTrailingFPFeatures();
+  }
+
 public:
   CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
   void setCastKind(CastKind K) { CastExprBits.Kind = K; }
@@ -3506,6 +3518,28 @@ class CastExpr : public Expr {
 return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType());
   }
 
+  bool hasStoredFPFeatures() const { return CastExprBits.HasFPFeatures; }
+
+  /// Get FPOptionsOverride from trailing storage.
+  FPOptionsOverride getStoredFPFeatures() const {
+assert(hasStoredFPFeatures());
+return *getTrailingFPFeatures();
+  }
+
+  // Get the FP features status of this operation. Only meaningful for
+  // operations on floating point types.
+  FPOptions getFPFeaturesInEffect(const LangOptions &LO) const {
+if (hasStoredFPFeatures())
+  return getStoredFPFeatures().applyOverrides(LO);
+return FPOptions::defaultWithoutTrailingStorage(LO);
+  }
+
+  FPOptionsOverride getFPFeatures() const {
+if (hasStoredFPFeatures())
+  return getStoredFPFeatures();
+return FPOptionsOverride();
+  }
+
   static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
QualType opType);
   static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
@@ -3543,21 +3577,35 @@ class CastExpr : public Expr {
 /// @endcod

[PATCH] D85960: [AST][FPEnv] Keep FP options in trailing storage of CastExpr

2020-09-12 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c8041aa0ffe: [AST][FPEnv] Keep FP options in trailing 
storage of CastExpr (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D85960?vs=290487&id=291376#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85960

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/ExprObjC.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp

Index: clang/test/AST/ast-dump-fpfeatures.cpp
===
--- clang/test/AST/ast-dump-fpfeatures.cpp
+++ clang/test/AST/ast-dump-fpfeatures.cpp
@@ -36,6 +36,51 @@
 // CHECK-NEXT:   ReturnStmt
 // CHECK-NEXT: CallExpr {{.*}} FPContractMode=0
 
+int func_04(float x) {
+#pragma STDC FP_CONTRACT ON
+  return x;
+}
+
+// CHECK:  FunctionDecl {{.*}} func_04 'int (float)'
+// CHECK-NEXT:   ParmVarDecl {{.*}} x 'float'
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT:   ImplicitCastExpr {{.*}} 'int'  FPContractMode=1
+
+float func_05(double x) {
+#pragma STDC FP_CONTRACT ON
+  return (float)x;
+}
+
+// CHECK:  FunctionDecl {{.*}} func_05 'float (double)'
+// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT:   CStyleCastExpr {{.*}} FPContractMode=1
+
+float func_06(double x) {
+#pragma STDC FP_CONTRACT ON
+  return float(x);
+}
+
+// CHECK:  FunctionDecl {{.*}} func_06 'float (double)'
+// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT:   CXXFunctionalCastExpr {{.*}} FPContractMode=1
+
+float func_07(double x) {
+#pragma STDC FP_CONTRACT ON
+  return static_cast(x);
+}
+
+// CHECK:  FunctionDecl {{.*}} func_07 'float (double)'
+// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT:   CXXStaticCastExpr {{.*}} FPContractMode=1
+// CHECK-NEXT: CallExpr {{.*}} FPContractMode=0
+
 
 
 
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -946,12 +946,16 @@
 void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
   VisitExpr(E);
   Record.push_back(E->path_size());
+  Record.push_back(E->hasStoredFPFeatures());
   Record.AddStmt(E->getSubExpr());
   Record.push_back(E->getCastKind()); // FIXME: stable encoding
 
   for (CastExpr::path_iterator
  PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
 Record.AddCXXBaseSpecifier(**PI);
+
+  if (E->hasStoredFPFeatures())
+Record.push_back(E->getFPFeatures().getAsOpaqueInt());
 }
 
 void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
@@ -1003,7 +1007,7 @@
   VisitCastExpr(E);
   Record.push_back(E->isPartOfExplicitCast());
 
-  if (E->path_size() == 0)
+  if (E->path_size() == 0 && !E->hasStoredFPFeatures())
 AbbrevToUse = Writer.getExprImplicitCastAbbrev();
 
   Code = serialization::EXPR_IMPLICIT_CAST;
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2346,6 +2346,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   // CastExpr
   Abv->Add(BitCodeAbbrevOp(0)); // PathSize
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasFPFeatures
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
   Abv->Add(BitCodeAbbr

[clang] 9c651c2 - Missing change from previous commit

2020-09-12 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-09-12T15:11:09+07:00
New Revision: 9c651c231f3144f53e13cd0a1747589e1b2edccd

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

LOG: Missing change from previous commit

Added: 


Modified: 
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-fpfeatures.cpp 
b/clang/test/AST/ast-dump-fpfeatures.cpp
index 830623ff4852..e143009806b5 100644
--- a/clang/test/AST/ast-dump-fpfeatures.cpp
+++ b/clang/test/AST/ast-dump-fpfeatures.cpp
@@ -79,7 +79,6 @@ float func_07(double x) {
 // CHECK-NEXT:   CompoundStmt
 // CHECK-NEXT: ReturnStmt
 // CHECK-NEXT:   CXXStaticCastExpr {{.*}} FPContractMode=1
-// CHECK-NEXT: CallExpr {{.*}} FPContractMode=0
 
 
 



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


Re: [clang] a8503b8 - [NFC] Remove unused static function

2020-09-12 Thread Vitaly Buka via cfe-commits
build fails with -DLLVM_ENABLE_WERROR=ON

On Fri, 11 Sep 2020 at 23:16, Kristóf Umann  wrote:

> Yup, unless you this breaks something, I'd really prefer to keep it.
>
> On Sat, 12 Sep 2020, 03:24 David Blaikie,  wrote:
>
>> LLVM_DUMP_METHOD is meant to be used for annotating functions that might
>> be useful to execute from a debugger to dump data structures, etc - so it's
>> expected that they'd be unused. Do you find that this function is not
>> useful to use from a debugger/similar situation? (or perhaps because the
>> function was "static" it was hitting a compiler warning/error & not
>> actually being emitted into the resulting binary for use by an interactive
>> debugger?)
>>
>> +Kristof for comments/thoughts
>>
>> On Fri, Sep 11, 2020 at 4:50 PM Vitaly Buka via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Vitaly Buka
>>> Date: 2020-09-11T16:50:30-07:00
>>> New Revision: a8503b87f739776cc9d5738f69aa0990db952340
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/a8503b87f739776cc9d5738f69aa0990db952340
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/a8503b87f739776cc9d5738f69aa0990db952340.diff
>>>
>>> LOG: [NFC] Remove unused static function
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
>>> b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
>>> index 441dcad42444..ce4addd2f945 100644
>>> --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
>>> +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
>>> @@ -834,11 +834,6 @@ LLVM_DUMP_METHOD static void
>>> dumpArgTokensToStream(llvm::raw_ostream &Out,
>>> const Preprocessor
>>> &PP,
>>> const ArgTokensTy
>>> &Toks);
>>>
>>> -LLVM_DUMP_METHOD static void dumpArgTokens(const Preprocessor &PP,
>>> -   const ArgTokensTy &Toks) {
>>> -  dumpArgTokensToStream(llvm::errs(), PP, Toks);
>>> -}
>>> -
>>>  namespace {
>>>  /// Maps unexpanded macro parameters to expanded arguments. A macro
>>> argument may
>>>  /// need to expanded further when it is nested inside another macro.
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

We had this patch at MSYS2 for years and I'm not aware of any issues with the 
static library.
I think the library looks fine:

  $ nm lib/liblibclang.a | grep __imp_
   U __imp___acrt_iob_func
   U __imp___acrt_iob_func
   U __imp_GetModuleFileNameA
   U __imp_VirtualQuery
   U __imp___acrt_iob_func
   U __imp___acrt_iob_func
   U __imp___acrt_iob_func


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[clang] de044f7 - Revert "[AST][FPEnv] Keep FP options in trailing storage of CastExpr"

2020-09-12 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-09-12T17:06:42+07:00
New Revision: de044f756286edebf86044d5172016d87f49fda0

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

LOG: Revert "[AST][FPEnv] Keep FP options in trailing storage of CastExpr"

This reverts commit 6c8041aa0ffed827636935e59c489b1e390c8542.
It caused some fails on buildbots.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/ExprObjC.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 1672fd707c6d..26e52ad367f8 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3440,11 +3440,9 @@ class CastExpr : public Expr {
   }
   CXXBaseSpecifier **path_buffer();
 
-  friend class ASTStmtReader;
-
 protected:
   CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind,
-   Expr *op, unsigned BasePathSize, bool HasFPFeatures)
+   Expr *op, unsigned BasePathSize)
   : Expr(SC, ty, VK, OK_Ordinary), Op(op) {
 CastExprBits.Kind = kind;
 CastExprBits.PartOfExplicitCast = false;
@@ -3453,27 +3451,17 @@ class CastExpr : public Expr {
"BasePathSize overflow!");
 setDependence(computeDependence(this));
 assert(CastConsistency());
-CastExprBits.HasFPFeatures = HasFPFeatures;
   }
 
   /// Construct an empty cast.
-  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize,
-   bool HasFPFeatures)
-  : Expr(SC, Empty) {
+  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
+: Expr(SC, Empty) {
 CastExprBits.PartOfExplicitCast = false;
 CastExprBits.BasePathSize = BasePathSize;
-CastExprBits.HasFPFeatures = HasFPFeatures;
 assert((CastExprBits.BasePathSize == BasePathSize) &&
"BasePathSize overflow!");
   }
 
-  /// Return a pointer to the trailing FPOptions.
-  /// \pre hasStoredFPFeatures() == true
-  FPOptionsOverride *getTrailingFPFeatures();
-  const FPOptionsOverride *getTrailingFPFeatures() const {
-return const_cast(this)->getTrailingFPFeatures();
-  }
-
 public:
   CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
   void setCastKind(CastKind K) { CastExprBits.Kind = K; }
@@ -3518,28 +3506,6 @@ class CastExpr : public Expr {
 return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType());
   }
 
-  bool hasStoredFPFeatures() const { return CastExprBits.HasFPFeatures; }
-
-  /// Get FPOptionsOverride from trailing storage.
-  FPOptionsOverride getStoredFPFeatures() const {
-assert(hasStoredFPFeatures());
-return *getTrailingFPFeatures();
-  }
-
-  // Get the FP features status of this operation. Only meaningful for
-  // operations on floating point types.
-  FPOptions getFPFeaturesInEffect(const LangOptions &LO) const {
-if (hasStoredFPFeatures())
-  return getStoredFPFeatures().applyOverrides(LO);
-return FPOptions::defaultWithoutTrailingStorage(LO);
-  }
-
-  FPOptionsOverride getFPFeatures() const {
-if (hasStoredFPFeatures())
-  return getStoredFPFeatures();
-return FPOptionsOverride();
-  }
-
   static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
QualType opType);
   static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
@@ -3577,35 +3543,21 @@ class CastExpr : public Expr {
 /// @endcode
 class ImplicitCastExpr final
 : public CastExpr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects {
 
   ImplicitCastExpr(QualType ty, CastKind kind

[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D87539#2269385 , @mati865 wrote:

> We had this patch at MSYS2 for years and I'm not aware of any issues with the 
> static library.
> I think the library looks fine:
>
>   $ nm lib/liblibclang.a | grep __imp_
>U __imp___acrt_iob_func
>U __imp___acrt_iob_func
>U __imp_GetModuleFileNameA
>U __imp_VirtualQuery
>U __imp___acrt_iob_func
>U __imp___acrt_iob_func
>U __imp___acrt_iob_func

What about `llvm-readobj --coff-directives | grep -i export:`? The effect is 
often very subtle - if you build another DLL, that has no explicit dllexports 
of its own but rely on the default of exporting all symbols - it fails if a 
statically linked dependency contains explicit dllexports and only exports the 
dependency's symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D87537: [lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature

2020-09-12 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 291380.
sbc100 added a comment.

Feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87537

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c
  lld/test/wasm/Inputs/undefined-globals.s
  lld/test/wasm/emit-relocs-fpic.s
  lld/test/wasm/gc-imports.s
  lld/test/wasm/mutable-globals.s
  lld/test/wasm/pie.ll
  lld/test/wasm/shared.ll
  lld/wasm/Writer.cpp

Index: lld/wasm/Writer.cpp
===
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -461,6 +461,29 @@
   if (!config->checkFeatures)
 return;
 
+  if (!config->relocatable && used.count("mutable-globals") == 0) {
+for (Symbol *sym : symtab->getSymbols()) {
+  if (auto *global = dyn_cast(sym)) {
+if (global->getGlobalType()->Mutable) {
+  if (!sym->isLive())
+continue;
+  if (!sym->isUsedInRegularObj)
+continue;
+  if (sym->isUndefined() && sym->isWeak() && !config->relocatable)
+continue;
+  if (sym->isUndefined())
+error(Twine("mutable global imported but 'mutable-globals' feature "
+"not present in inputs: `") +
+  toString(*sym) + "`. Use --no-check-features to suppress.");
+  else if (sym->isExported())
+error(Twine("mutable global exported but 'mutable-globals' feature "
+"not present in inputs: `") +
+  toString(*sym) + "`. Use --no-check-features to suppress.");
+}
+  }
+}
+  }
+
   if (config->sharedMemory) {
 if (disallowed.count("shared-mem"))
   error("--shared-memory is disallowed by " + disallowed["shared-mem"] +
Index: lld/test/wasm/shared.ll
===
--- lld/test/wasm/shared.ll
+++ lld/test/wasm/shared.ll
@@ -1,4 +1,4 @@
-; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o
+; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o %t.o
 ; RUN: wasm-ld -shared -o %t.wasm %t.o
 ; RUN: obj2yaml %t.wasm | FileCheck %s
 
Index: lld/test/wasm/pie.ll
===
--- lld/test/wasm/pie.ll
+++ lld/test/wasm/pie.ll
@@ -1,4 +1,4 @@
-; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o
+; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o %t.o
 ; RUN: wasm-ld --no-gc-sections --allow-undefined -pie -o %t.wasm %t.o
 ; RUN: obj2yaml %t.wasm | FileCheck %s
 
Index: lld/test/wasm/mutable-globals.s
===
--- /dev/null
+++ lld/test/wasm/mutable-globals.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: not wasm-ld %t.o -o %t.wasm 2>&1 | FileCheck %s
+
+.globl _start
+_start:
+  .functype _start () -> ()
+  i32.const 1
+  global.set foo
+  end_function
+
+.globaltype foo, i32
+
+# CHECK: error: mutable global imported but 'mutable-globals' feature not present in inputs: `foo`. Use --no-check-features to suppress.
Index: lld/test/wasm/gc-imports.s
===
--- lld/test/wasm/gc-imports.s
+++ lld/test/wasm/gc-imports.s
@@ -31,7 +31,7 @@
 # CHECK-NEXT: Field:   used_undef_global
 # CHECK-NEXT: Kind:GLOBAL
 # CHECK-NEXT: GlobalType:  I64
-# CHECK-NEXT: GlobalMutable:   true
+# CHECK-NEXT: GlobalMutable:   false
 # CHECK-NEXT:   - Type:
 # CHECK:- Type:CUSTOM
 # CHECK-NEXT: Name:name
@@ -62,12 +62,12 @@
 # NO-GC-NEXT: Field:   unused_undef_global
 # NO-GC-NEXT: Kind:GLOBAL
 # NO-GC-NEXT: GlobalType:  I64
-# NO-GC-NEXT: GlobalMutable:   true
+# NO-GC-NEXT: GlobalMutable:   false
 # NO-GC-NEXT:   - Module:  env
 # NO-GC-NEXT: Field:   used_undef_global
 # NO-GC-NEXT: Kind:GLOBAL
 # NO-GC-NEXT: GlobalType:  I64
-# NO-GC-NEXT: GlobalMutable:   true
+# NO-GC-NEXT: GlobalMutable:   false
 # NO-GC-NEXT:   - Type:
 # NO-GC:- Type:CUSTOM
 # NO-GC-NEXT: Name:name
Index: lld/test/wasm/emit-relocs-fpic.s
===
--- lld/test/wasm/emit-relocs-fpic.s
+++ lld/test/wasm/emit-relocs-fpic.s
@@ -1,6 +1,6 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
-# RUN: wasm-ld -pie --export-all --no-gc-sections --no-entry --emit-relocs -o %t.wasm %t.o %t.ret32.o
+# RUN: wasm-ld -pie --export-all --no-c

[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-09-12 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

i believe all known issues with this patch have been fixed is it fine to reland 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

`bin/llvm-readobj --coff-directives lib/liblibclang.dll.a | grep -i export` 
shows nothing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D87539#2269442 , @mati865 wrote:

> `bin/llvm-readobj --coff-directives lib/liblibclang.dll.a | grep -i export` 
> shows nothing.

That's the import library, not the static library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Sorry, pasted wrong command. I was curious if import library has it (since 
static one did not) but in the end neither import nor static library shows any 
`export`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D85473: [Clang] Add option to allow marking pass-by-value args as noalias.

2020-09-12 Thread Florian Hahn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa874d6334409: [Clang] Add option to allow marking 
pass-by-value args as noalias. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D85473?vs=291183&id=291389#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85473

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/pass-by-value-noalias.c
  clang/test/CodeGenCXX/pass-by-value-noalias.cpp
  clang/test/CodeGenObjC/pass-by-value-noalias.m

Index: clang/test/CodeGenObjC/pass-by-value-noalias.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/pass-by-value-noalias.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fpass-by-value-is-noalias -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns -fobjc-runtime-has-weak -fobjc-arc -fobjc-dispatch-method=mixed %s -o - 2>&1 | FileCheck --check-prefix=WITH_NOALIAS %s
+// RUN: %clang_cc1 -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns -fobjc-runtime-has-weak -fobjc-arc -fobjc-dispatch-method=mixed %s -o - 2>&1 | FileCheck --check-prefix=NO_NOALIAS %s
+
+@interface Bar
+@property char value;
+@end
+
+// A struct large enough so it is not passed in registers on ARM64, but with a
+// weak reference, so noalias should not be added even with
+// -fpass-by-value-is-noalias.
+struct Foo {
+  int a;
+  int b;
+  int c;
+  int d;
+  int e;
+  Bar *__weak f;
+};
+
+// WITH_NOALIAS: define void @take(%struct.Foo* %arg)
+// NO_NOALIAS: define void @take(%struct.Foo* %arg)
+void take(struct Foo arg) {}
Index: clang/test/CodeGenCXX/pass-by-value-noalias.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pass-by-value-noalias.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -fpass-by-value-is-noalias -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns %s -o - 2>&1 | FileCheck --check-prefix=WITH_NOALIAS %s
+// RUN: %clang_cc1 -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns %s -o - 2>&1 | FileCheck --check-prefix=NO_NOALIAS %s
+
+// A trivial struct large enough so it is not passed in registers on ARM64.
+struct Foo {
+  int a;
+  int b;
+  int c;
+  int d;
+  int e;
+  int f;
+};
+
+// Make sure noalias is added to indirect arguments with trivially copyable types
+// if -fpass-by-value-is-noalias is provided.
+
+// WITH_NOALIAS: define void @_Z4take3Foo(%struct.Foo* noalias %arg)
+// NO_NOALIAS: define void @_Z4take3Foo(%struct.Foo* %arg)
+void take(Foo arg) {}
+
+int G;
+
+// NonTrivial is not trivially-copyable, because it has a non-trivial copy
+// constructor.
+struct NonTrivial {
+  int a;
+  int b;
+  int c;
+  int d;
+  int e;
+  int f;
+
+  NonTrivial(const NonTrivial &Other) {
+a = G + 10 + Other.a;
+  }
+};
+
+// Make sure noalias is not added to indirect arguments that are not trivially
+// copyable even if -fpass-by-value-is-noalias is provided.
+
+// WITH_NOALIAS: define void @_Z4take10NonTrivial(%struct.NonTrivial* %arg)
+// NO_NOALIAS:   define void @_Z4take10NonTrivial(%struct.NonTrivial* %arg)
+void take(NonTrivial arg) {}
+
+// Escape examples. Pointers to the objects passed to take() may escape, depending on whether a temporary copy is created or not (e.g. due to NRVO).
+struct A {
+  A(A **where) : data{"hello world 1"} {
+*where = this; //Escaped pointer 1 (proposed UB?)
+  }
+
+  A() : data{"hello world 2"} {}
+
+  char data[32];
+};
+A *p;
+
+// WITH_NOALIAS: define void @_Z4take1A(%struct.A* noalias %arg)
+// NO_NOALIAS: define void @_Z4take1A(%struct.A* %arg)
+void take(A arg) {}
+
+// WITH_NOALIAS: define void @_Z7CreateAPP1A(%struct.A* noalias sret align 1 %agg.result, %struct.A** %where)
+// NO_NOALIAS: define void @_Z7CreateAPP1A(%struct.A* noalias sret align 1 %agg.result, %struct.A** %where)
+A CreateA(A **where) {
+  A justlikethis;
+  *where = &justlikethis; //Escaped pointer 2 (should also be UB, then)
+  return justlikethis;
+}
+
+// elsewhere, perhaps compiled by a smarter compiler that doesn't make a copy here
+void test() {
+  take({&p});// 1
+  take(CreateA(&p)); // 2
+}
Index: clang/test/CodeGen/pass-by-value-noalias.c
===
--- /dev/null
+++ clang/test/CodeGen/pass-by-value-noalias.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fpass-by-value-is-noalias -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns %s -o - 2>&1 | FileCheck --check-prefix=WITH_NOALIAS %s
+// RUN: %clang_cc1 -triple arm64-apple-iphoneos -emit-llvm -disable-llvm-optzns %s -o - 2>&1 | FileCheck --check-prefix=NO_NOALIAS %s
+
+// A struct large enough so it is not passed in registers on ARM64.
+struct Foo {
+  int 

[clang] a874d63 - [Clang] Add option to allow marking pass-by-value args as noalias.

2020-09-12 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-09-12T14:56:13+01:00
New Revision: a874d63344093752c912d01de60211f65745ea6f

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

LOG: [Clang] Add option to allow marking pass-by-value args as noalias.

After the recent discussion on cfe-dev 'Can indirect class parameters be
noalias?' [1], it seems like using using noalias is problematic for
current C++, but should be allowed for C-only code.

This patch introduces a new option to let the user indicate that it is
safe to mark indirect class parameters as noalias. Note that this also
applies to external callers, e.g. it might not be safe to use this flag
for C functions that are called by C++ functions.

In targets that allocate indirect arguments in the called function, this
enables more agressive optimizations with respect to memory operations
and brings a ~1% - 2% codesize reduction for some programs.

[1] : http://lists.llvm.org/pipermail/cfe-dev/2020-July/066353.html

Reviewed By: rjmccall

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

Added: 
clang/test/CodeGen/pass-by-value-noalias.c
clang/test/CodeGenCXX/pass-by-value-noalias.cpp
clang/test/CodeGenObjC/pass-by-value-noalias.m

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index ec77f68062e7..740d54471051 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -395,6 +395,10 @@ CODEGENOPT(KeepStaticConsts, 1, 0)
 /// Whether to not follow the AAPCS that enforce at least one read before 
storing to a volatile bitfield
 CODEGENOPT(ForceAAPCSBitfieldLoad, 1, 0)
 
+/// Assume that by-value parameters do not alias any other values.
+CODEGENOPT(PassByValueIsNoAlias, 1, 0)
+
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 922ad580a53e..f196c1b72d27 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4322,6 +4322,9 @@ def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">,
 def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], 
"fcompatibility-qualified-id-block-type-checking">,
   HelpText<"Allow using blocks with parameters of more specific type than "
"the type system guarantees when a parameter is qualified id">;
+def fpass_by_value_is_noalias: Flag<["-"], "fpass-by-value-is-noalias">,
+  HelpText<"Allows assuming by-value parameters do not alias any other value. "
+   "Has no effect on non-trivially-copyable classes in C++.">, 
Group;
 
 // FIXME: Remove these entirely once functionality/tests have been excised.
 def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group,

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a4b35edb1bd9..adb68979568e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2201,6 +2201,13 @@ void CodeGenModule::ConstructAttributeList(
   if (AI.getIndirectByVal())
 Attrs.addByValAttr(getTypes().ConvertTypeForMem(ParamType));
 
+  auto *Decl = ParamType->getAsRecordDecl();
+  if (CodeGenOpts.PassByValueIsNoAlias && Decl &&
+  Decl->getArgPassingRestrictions() == RecordDecl::APK_CanPassInRegs)
+// When calling the function, the pointer passed in will be the only
+// reference to the underlying object. Mark it accordingly.
+Attrs.addAttribute(llvm::Attribute::NoAlias);
+
   // TODO: We could add the byref attribute if not byval, but it would
   // require updating many testcases.
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index fbccff11562c..0d8b0f9d07ef 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1453,6 +1453,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, 
ArgList &Args, InputKind IK,
   std::string(Args.getLastArgValue(OPT_fsymbol_partition_EQ));
 
   Opts.ForceAAPCSBitfieldLoad = Args.hasArg(OPT_ForceAAPCSBitfieldLoad);
+
+  Opts.PassByValueIsNoAlias = Args.hasArg(OPT_fpass_by_value_is_noalias);
   return Success;
 }
 

diff  --git a/clang/test/CodeGen/pass-by-value-noalias.c 
b/clang/test/CodeGen/pass-by-value-noalias.c
new file mode 100644
index ..f77ce2b1e35b
--- /dev/null
+++ b/clang/test/CodeGen/pass-by-value-noalias.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fpass-by-value-is-noalias -triple arm64-apple-iphoneos 
-emit-llvm -disable-l

[PATCH] D85473: [Clang] Add option to allow marking pass-by-value args as noalias.

2020-09-12 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4287-4290
+def fpass_by_value_noalias: Flag<["-"], "fpass-by-value-noalias">,
+  HelpText<"Allows assuming no references to passed by value escape before "
+   "transferring execution to the called function. Note that this "
+   "does not hold for C++">;

rjmccall wrote:
> fhahn wrote:
> > rjmccall wrote:
> > > rsmith wrote:
> > > > This should be in `Group`.
> > > The "Note" clause seems to muddy more than it clarifies.  Maybe "has no 
> > > effect on non-trivially-copyable classes in C++"?  Or add proper 
> > > documentation somewhere instead of trying to jam this into the help text.
> > I've added the clarification, thanks!
> Oh, you need a space after the period.
Done, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85473

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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

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

LGTM then! Can apply it a bit later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D87561: [Sema] List conversion validate character array

2020-09-12 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: lvoufo, rsmith.
Mordante added a project: clang.
Mordante requested review of this revision.

The function `TryListConversion` didn't properly validate the following part of 
the standard:

  Otherwise, if the parameter type is a character array [... ]
  and the initializer list has a single element that is an
  appropriately-typed string literal (8.5.2 [dcl.init.string]), the
  implicit conversion sequence is the identity conversion.

This caused the following call to `f()` to be ambiguous.

  void f(int(&&)[1]);
  void f(unsigned(&&)[1]);
  
  void g(unsigned i) {
f({i});
  }

This issue only occurrs when the initializer list had one element.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87561

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr14xx.cpp


Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -334,6 +334,22 @@
 
 X x;
 X x2{x};
+
+void f1(int);
+void f1(std::initializer_list);
+void g1() { f1({42}); }
+
+template 
+struct Pair {
+  Pair(T, U);
+};
+struct String {
+  String(const char *);
+};
+
+void f2(Pair);
+void f2(std::initializer_list);
+void g2() { f2({"foo", "bar"}); }
   } // dr_example
 
   namespace nonaggregate {
@@ -379,6 +395,31 @@
 struct Value { Value(Pair); Value(TwoPairs); };
 void f() { Value{{{1,2},{3,4}}}; }
   }
+  namespace NonAmbiguous {
+  // The original implementation made this case ambigious due to the special
+  // handling of one element initialization lists.
+  void f(int(&&)[1]);
+  void f(unsigned(&&)[1]);
+
+  void g(unsigned i) {
+f({i});
+  }
+  } // namespace NonAmbiguous
+
+#if __cplusplus >= 201103L
+  namespace StringLiterals {
+  void f(const char[4]);
+  void f(const wchar_t[4]);
+  void f(const char16_t[4]);
+  void f(const char32_t[4]);
+  void g() {
+f({"abc"}); // expected-warning {{braces around scalar initializer}}
+f({L"abc"});// expected-warning {{braces around scalar initializer}}
+f({uR"(abc)"}); // expected-warning {{braces around scalar initializer}}
+f({UR"(abc)"}); // expected-warning {{braces around scalar initializer}}
+  }
+  } // namespace StringLiterals
+#endif
 } // dr1467
 
 namespace dr1490 {  // dr1490: 3.7 c++11
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -4984,12 +4984,12 @@
  InOverloadResolution,
  AllowObjCWritebackConversion);
 }
-// FIXME: Check the other conditions here: array of character type,
-// initializer is a string literal.
-if (ToType->isArrayType()) {
+
+if (ToType->isArrayType() && ToType->isCharType() &&
+isa(From->getInit(0))) {
   InitializedEntity Entity =
-InitializedEntity::InitializeParameter(S.Context, ToType,
-   /*Consumed=*/false);
+  InitializedEntity::InitializeParameter(S.Context, ToType,
+ /*Consumed=*/false);
   if (S.CanPerformCopyInitialization(Entity, From)) {
 Result.setStandard();
 Result.Standard.setAsIdentityConversion();


Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -334,6 +334,22 @@
 
 X x;
 X x2{x};
+
+void f1(int);
+void f1(std::initializer_list);
+void g1() { f1({42}); }
+
+template 
+struct Pair {
+  Pair(T, U);
+};
+struct String {
+  String(const char *);
+};
+
+void f2(Pair);
+void f2(std::initializer_list);
+void g2() { f2({"foo", "bar"}); }
   } // dr_example
 
   namespace nonaggregate {
@@ -379,6 +395,31 @@
 struct Value { Value(Pair); Value(TwoPairs); };
 void f() { Value{{{1,2},{3,4}}}; }
   }
+  namespace NonAmbiguous {
+  // The original implementation made this case ambigious due to the special
+  // handling of one element initialization lists.
+  void f(int(&&)[1]);
+  void f(unsigned(&&)[1]);
+
+  void g(unsigned i) {
+f({i});
+  }
+  } // namespace NonAmbiguous
+
+#if __cplusplus >= 201103L
+  namespace StringLiterals {
+  void f(const char[4]);
+  void f(const wchar_t[4]);
+  void f(const char16_t[4]);
+  void f(const char32_t[4]);
+  void g() {
+f({"abc"}); // expected-warning {{braces around scalar initializer}}
+f({L"abc"});// expected-warning {{braces around scalar initializer}}
+f({uR"(abc)"}); // expected-warning {{braces around scalar initializer}}
+f({UR"(abc)"}); // expected-warning {{braces around scalar initializer}}
+  }
+  } // namespace StringLiterals
+

[PATCH] D87563: [Sema] Improve overload resolution

2020-09-12 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: lvoufo, rsmith.
Mordante added a project: clang.
Mordante requested review of this revision.

The overload resolution for initializer lists was incomplete. It did not
properly take the number of elements in the target array into account.  The
size comparison already allows for an array of unknown boud, per P0338 'Permit
conversions to arrays of unknown bound'. However currently this is dead code.

This fixes the overload resolution for cases like:

  void f(int(&&)[2]);
  
  void g() {
f({1});
f({1, 2});
f({1, 2, 3});
  }

The patch adds extra members to `ImplicitConversionSequence`, making it larger
for members only used for an initializer list. The largest member of the class'
union is `UserDefinedConversion`. An initializer list can be used with a user
defined conversion sequence, so it's not possible to use unused space in the
union. I'm open to suggestions how to avoid the enlargement of the class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87563

Files:
  clang/include/clang/Sema/Overload.h
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/overload-call.cpp

Index: clang/test/SemaCXX/overload-call.cpp
===
--- clang/test/SemaCXX/overload-call.cpp
+++ clang/test/SemaCXX/overload-call.cpp
@@ -688,3 +688,37 @@
 f(pmf);
   }
 }
+
+#if __cplusplus >= 201103L
+namespace InitializerListToArray {
+void f(int(&&)[2]); // expected-note {{candidate function not viable}}
+void f(int(&&)[3]); // expected-note {{candidate function not viable}}
+void f(int(&&)[4]); // expected-note {{candidate function not viable}}
+
+void g() {
+  f({1});
+  f({1, 2});
+  f({1, 2, 3});
+  f({1, 2, 3, 4});
+  f({1, 2, 3, 4, 5}); // expected-error {{no matching function for call to 'f'}}
+}
+
+struct S {
+  S();
+  S(double);
+};
+
+void h(S(&&)[2]); // expected-note {{candidate function not viable}}
+void h(S(&&)[3]); // expected-note {{candidate function not viable}}
+void h(S(&&)[4]); // expected-note {{candidate function not viable}}
+
+void i() {
+  h({1});
+  h({1, 2});
+  h({1, 2, 3});
+  h({1, 2, 3, 4});
+  h({1, 2, 3, 4, 5}); // expected-error {{no matching function for call to 'h'}}
+}
+
+} // namespace InitializerListToArray
+#endif
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -3686,6 +3686,100 @@
   ICS.UserDefined.Before.DeprecatedStringLiteralToCharPtr);
 }
 
+namespace {
+class CompareListInitializationSequences {
+  // List-initialization sequence L1 is a better conversion sequence than
+  // list-initialization sequence L2 if:
+  // ...
+  // - C++17:
+  //   L1 converts to type "array of N1 T", L2 converts to type "array of N2 T",
+  //   and N1 is smaller than N2.,
+  // - C++20
+  //   L1 and L2 convert to arrays of the same element type, and either the
+  //   number of elements n1 initialized by L1 is less than the number of
+  //   elements n2 initialized by L2, or n1=n2 and L2 converts to an array of
+  //   unknown bound and L1 does not,
+
+  struct Conversion {
+enum ConversionKind {
+  Bad,
+  // Conversion to an array of known bound. The source doesn't have too
+  // many elements.
+  ConstantArray,
+  // Conversion to an array of unknown bound, requires C++20.
+  IncompleteArray
+};
+ConversionKind Kind{Bad};
+// The number of elements the source has less than the target.
+// - Zero means the source and target have the same number of elements,
+//   or the target is an array of unknown bound.
+uint64_t Diff{0};
+QualType ElementType;
+
+Conversion(Sema &S, const ImplicitConversionSequence &ICS) {
+  const InitListExpr *From = ICS.getStdInitializerListFrom();
+  QualType ToType = ICS.getStdInitializerListToType();
+
+  if (ToType->isIncompleteArrayType() && S.getLangOpts().CPlusPlus20) {
+Kind = IncompleteArray;
+ElementType =
+S.Context.getAsIncompleteArrayType(ToType)->getElementType();
+
+  } else if (ToType->isConstantArrayType()) {
+const auto *Array = S.Context.getAsConstantArrayType(ToType);
+Diff = Array->getSize().getZExtValue();
+if (From->getNumInits() <= Diff) {
+  Diff -= From->getNumInits();
+  Kind = ConstantArray;
+}
+ElementType = Array->getElementType();
+  }
+}
+  };
+
+  static ImplicitConversionSequence::CompareKind Compare(const Conversion &C1,
+ const Conversion &C2) {
+if (C1.Kind != Conversion::Bad && C1.Kind == Conversion::Bad)
+  return ImplicitConversionSequence::Better;
+
+if (C1.Kind == Conversion::Bad && C1.Kind != Conversion::Bad)
+  return ImplicitConversionSequence::Worse;
+
+if (C1.Kind != Conversion::Bad && C1.Kind != Convers

[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-09-12 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

This looks like a good idea — people will probably have some options on the 
names and descriptions of the statistics  :-)




Comment at: clang/lib/Frontend/CompilerInstance.cpp:60
+
+ALWAYS_ENABLED_STATISTIC(NumCompileModule, "Number of compiled modules.");
+

`NumCompiledModules`?



Comment at: clang/lib/Serialization/ASTReader.cpp:151
+   "and using cached results.");
+ALWAYS_ENABLED_STATISTIC(NumReadASTCore, "Number of times read AST core.");
+

`Number of times ReadASTCore() is invoked`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86895

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


[PATCH] D87565: [Sema] Improve const_cast conformance to N4261

2020-09-12 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: rjmccall, rsmith.
Mordante added a project: clang.
Mordante requested review of this revision.

Allows `const_cast`s of similar non-record types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87565

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/SemaCXX/const-cast.cpp


Index: clang/test/SemaCXX/const-cast.cpp
===
--- clang/test/SemaCXX/const-cast.cpp
+++ clang/test/SemaCXX/const-cast.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 struct A {};
 
@@ -71,12 +74,30 @@
   f fp2 = const_cast(fp1); // expected-error {{const_cast to 'f' (aka 'int 
(*)(int)'), which is not a reference, pointer-to-object, or 
pointer-to-data-member}}
   void (A::*mfn)() = 0;
   (void)const_cast(mfn); // expected-error-re {{const_cast to 
'void (A::*)(){{( __attribute__\(\(thiscall\)\))?}}', which is not a reference, 
pointer-to-object, or pointer-to-data-member}}
-  (void)const_cast(0); // expected-error {{const_cast from rvalue to 
reference type 'int &&'}}
+  (void)const_cast(0);
+#if __cplusplus < 201703L // N4261
+  // expected-error@-2 {{const_cast from rvalue to reference type 'int &&'}}
+#endif
 #if __cplusplus <= 199711L // C++03 or earlier modes
-  // expected-warning@-2 {{rvalue references are a C++11 extension}}
+  // expected-warning@-5 {{rvalue references are a C++11 extension}}
 #endif
   return **var3;
 }
 
 template 
 char *PR21845() { return const_cast((void)T::x); } // expected-error 
{{const_cast from 'void' to 'char *' is not allowed}}
+
+#if __cplusplus >= 201103L
+namespace N4261 {
+typedef int *A[3];
+typedef const int *const CA[3];
+
+CA &&r = A{};
+A &&r1 = const_cast(CA{}); // expected-error {{const_cast to 'N4261::A' 
(aka 'int *[3]'), which is not a reference, pointer-to-object, or 
pointer-to-data-member}}
+
+A &&r2 = const_cast(CA{});
+#if __cplusplus < 201703L
+// expected-error@-2 {{const_cast from rvalue to reference type 'N4261::A &&' 
(aka 'int *(&&)[3]')}}
+#endif
+} // namespace N4261
+#endif
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -1769,7 +1769,7 @@
   QualType SrcType = SrcExpr.get()->getType();
   bool NeedToMaterializeTemporary = false;
 
-  if (const ReferenceType *DestTypeTmp =DestType->getAs()) {
+  if (const ReferenceType *DestTypeTmp = DestType->getAs()) {
 // C++11 5.2.11p4:
 //   if a pointer to T1 can be explicitly converted to the type "pointer to
 //   T2" using a const_cast, then the following conversions can also be
@@ -1790,16 +1790,23 @@
 }
 
 if (isa(DestTypeTmp) && SrcExpr.get()->isRValue()) {
-  if (!SrcType->isRecordType()) {
+  // Materialize the class prvalue so that the const_cast can bind a
+  // reference to it.
+  NeedToMaterializeTemporary = SrcType->isRecordType();
+
+  // C++17 [expr.const.cast]p3
+  // For two similar types T1 and T2, a prvalue of type T1 may be 
explicitly
+  // converted to the type T2 using a const_cast if, considering the
+  // cv-decompositions of both types, each P1i is the same as P2i for all 
i.
+  // The result of a const_cast refers to the original entity.
+  //
+  // Prior to C++17 only RecordTypes were allowed.
+  if (!NeedToMaterializeTemporary && !Self.getLangOpts().CPlusPlus17) {
 // Cannot const_cast non-class prvalue to rvalue reference type. But if
 // this is C-style, static_cast can do this.
 msg = diag::err_bad_cxx_cast_rvalue;
 return TC_NotApplicable;
   }
-
-  // Materialize the class prvalue so that the const_cast can bind a
-  // reference to it.
-  NeedToMaterializeTemporary = true;
 }
 
 // It's not completely clear under the standard whether we can


Index: clang/test/SemaCXX/const-cast.cpp
===
--- clang/test/SemaCXX/const-cast.cpp
+++ clang/test/SemaCXX/const-cast.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 struct A {};
 
@@ -71,12 +74,30 @@
   f fp2 = const_cast(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
   void (A::*mfn)() = 0;
   (void)const_cast(mfn); // expected-error-re

[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-12 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 291405.
fodinabor added a comment.

Address review comments, copy the help text into docs and add some basic unit 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,24 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnkownOption) {
+  std::string InputYAML = "Binary: \n"
+  "InvalidKey: InvalidValue";
+  BinaryHolder BH;
+  llvm::yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  llvm::yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+
+  BinaryHolder BH_GT;
+  BH_GT.Binary = yaml::BinaryRef("");
+  EXPECT_EQ(BH2.Binary, BH_GT.Binary);
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::

[PATCH] D87566: [Sema] Permit conversions to arrays of unknown bound

2020-09-12 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: lvoufo, rsmith.
Mordante added a project: clang.
Mordante requested review of this revision.

This implements C++20's P0388.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87566

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/const-cast.cpp
  clang/test/SemaCXX/overload-call.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1188,7 +1188,7 @@
 
   Permit conversions to arrays of unknown bound
   https://wg21.link/p0388r4";>P0388R4
-  No
+  Clang 12
 
 
   constinit
Index: clang/test/SemaCXX/overload-call.cpp
===
--- clang/test/SemaCXX/overload-call.cpp
+++ clang/test/SemaCXX/overload-call.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++98 %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++14 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++17 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++20 %s
 
 int* f(int) { return 0; }
 float* f(float) { return 0; }
@@ -721,4 +724,25 @@
 }
 
 } // namespace InitializerListToArray
+
+namespace P0338 {
+void f(int(&&)[]);
+void f(double(&&)[]);
+void f(int(&&)[2]);
+
+void g() {
+  f({1});
+#if __cplusplus < 202002L
+// expected-error@+3 {{type 'double' cannot be narrowed to 'int' in initializer list}}
+// expected-note@+2 {{insert an explicit cast to silence this issue}}
+#endif
+  f({1.0});
+#if __cplusplus < 202002L
+// expected-error@+3 2 {{type 'double' cannot be narrowed to 'int' in initializer list}}
+// expected-note@+2 2 {{insert an explicit cast to silence this issue}}
+#endif
+  f({1.0, 2.0});
+  f({1, 2});
+}
+} // namespace P0338
 #endif
Index: clang/test/SemaCXX/const-cast.cpp
===
--- clang/test/SemaCXX/const-cast.cpp
+++ clang/test/SemaCXX/const-cast.cpp
@@ -66,9 +66,15 @@
   (void) const_cast(&ar); // ok
   (void) const_cast(&aub); // ok
   // ... but the array bound must exactly match.
-  (void) const_cast(&ar); // expected-error {{const_cast from 'const int *(*)[100]' to 'int *(*)[]' is not allowed}}
+  (void) const_cast(&ar);
+#if __cplusplus < 202002L // P0388
+  // expected-error@-2 {{const_cast from 'const int *(*)[100]' to 'int *(*)[]' is not allowed}}
+#endif
   (void) const_cast(&ar); // expected-error {{const_cast from 'const int *(*)[100]' to 'int *(*)[99]' is not allowed}}
-  (void) const_cast(&aub); // expected-error {{const_cast from 'const int *(*)[]' to 'int *(*)[100]' is not allowed}}
+  (void) const_cast(&aub);
+#if __cplusplus < 202002L // P0388
+  // expected-error@-2 {{const_cast from 'const int *(*)[]' to 'int *(*)[100]' is not allowed}}
+#endif
   f fp1 = 0;
   // Function pointers.
   f fp2 = const_cast(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5060,8 +5060,10 @@
   Result.setBad(BadConversionSequence::no_conversion, From, ToType);
 
   // We need a complete type for what follows. Incomplete types can never be
-  // initialized from init lists.
-  if (!S.isCompleteType(From->getBeginLoc(), ToType))
+  // initialized from init lists. In C++20 an array of unknown bound can be
+  // initialized form a init list.
+  if (!S.isCompleteType(From->getBeginLoc(), ToType) &&
+  !S.getLangOpts().CPlusPlus20 && !isa(ToType))
 return Result;
 
   // Per DR1467:
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -5665,28 +5665,33 @@
 SourceRange());
 }
 
+static bool canUnwrapSimilarArrayTypes(const ArrayType *AT1,
+   const ArrayType *AT2, bool CPlusPlus20) {
+  // If we don't have two array types with the same constant bound nor two
+  // incomplete array types, we've unwrapped everything we can.
+  // C++20 allows the combintion of constant bound and incomplete arrays.
+  if (const auto *CAT1 = dyn_cast(AT1))
+if (const auto *CAT2 = dyn_cast(AT2))
+  return CAT1->getSize() == CAT2->getSize();
+
+  return CPlusPlus20 ||
+ (isa(AT1) && isa(AT2));
+}
+
 /// Attempt to unwrap two types that may both be array types with the same bound
 /// (or both be array types

[PATCH] D73425: [PPC] Fix platform definitions when compiling FreeBSD powerpc64 as LE

2020-09-12 Thread Brandon Bergren via Phabricator via cfe-commits
Bdragon28 added a comment.

That's fair. Will just use a patch on the FreeBSD side and revisit after 11.0.0 
is released. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73425

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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

The fix-up breaks tests: http://45.33.8.238/linux/27687/step_12.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-12 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D87163#2269674 , @thakis wrote:

> The fix-up breaks tests: http://45.33.8.238/linux/27687/step_12.txt

Thanks, should already be fixed in d85ac6d577ac 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87547: [MinGW][clang-shlib] Build by default on MinGW

2020-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb613044b680: [MinGW][clang-shlib] Build by default on MinGW 
(authored by mati865, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87547

Files:
  clang/tools/CMakeLists.txt


Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -15,7 +15,7 @@
 
 add_clang_subdirectory(clang-rename)
 add_clang_subdirectory(clang-refactor)
-if(UNIX)
+if(UNIX OR MINGW)
   add_clang_subdirectory(clang-shlib)
 endif()
 


Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -15,7 +15,7 @@
 
 add_clang_subdirectory(clang-rename)
 add_clang_subdirectory(clang-refactor)
-if(UNIX)
+if(UNIX OR MINGW)
   add_clang_subdirectory(clang-shlib)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cc76965 - [MinGW] Use lib prefix for libraries

2020-09-12 Thread Martin Storsjö via cfe-commits

Author: Mateusz Mikuła
Date: 2020-09-12T22:01:29+03:00
New Revision: cc76965b19085519278bff1052059e03769b71e8

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

LOG: [MinGW] Use lib prefix for libraries

In MinGW world, UNIX like lib prefix is preferred for the libraries.
This patch adjusts CMake files to do that.

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

Added: 


Modified: 
clang/tools/libclang/CMakeLists.txt
lldb/source/API/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/tools/llvm-config/llvm-config.cpp

Removed: 




diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index c3b9ab6ffb9b..88279ff7dae6 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -101,7 +101,7 @@ if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
   unset(ENABLE_STATIC)
 endif()
 
-if(WIN32)
+if(MSVC)
   set(output_name "libclang")
 else()
   set(output_name "clang")

diff  --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 8a7f28c01a9c..aeb1f15e294b 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -182,10 +182,10 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 endif()
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+if (MSVC)
   # Only MSVC has the ABI compatibility problem and avoids using 
FindPythonLibs,
   # so only it needs to explicitly link against ${Python3_LIBRARIES}
-  if (MSVC AND LLDB_ENABLE_PYTHON)
+  if (LLDB_ENABLE_PYTHON)
 target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
   endif()
 else()

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index a40cf17426fe..e57abea42753 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -567,7 +567,7 @@ function(llvm_add_library name)
   endif()
 
   if(ARG_SHARED)
-if(WIN32)
+if(MSVC)
   set_target_properties(${name} PROPERTIES
 PREFIX ""
 )

diff  --git a/llvm/tools/llvm-config/llvm-config.cpp 
b/llvm/tools/llvm-config/llvm-config.cpp
index a9d3f64aaa5b..1a2f04552d13 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -381,6 +381,7 @@ int main(int argc, char **argv) {
 SharedExt = "dll";
 SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
 if (HostTriple.isOSCygMing()) {
+  SharedPrefix = "lib";
   StaticExt = "a";
   StaticPrefix = "lib";
 } else {



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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7da941939902: [MinGW][libclang] Allow simultaneous shared 
and static lib (authored by mati865, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

Files:
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -97,7 +97,7 @@
   set(ENABLE_STATIC STATIC)
 endif()
 
-if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+if (MSVC AND ENABLE_SHARED AND ENABLE_STATIC)
   unset(ENABLE_STATIC)
 endif()
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -97,7 +97,7 @@
   set(ENABLE_STATIC STATIC)
 endif()
 
-if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+if (MSVC AND ENABLE_SHARED AND ENABLE_STATIC)
   unset(ENABLE_STATIC)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7da9419 - [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Martin Storsjö via cfe-commits

Author: Mateusz Mikuła
Date: 2020-09-12T22:03:43+03:00
New Revision: 7da941939902768af25ffa45149695a0a5f15951

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

LOG: [MinGW][libclang] Allow simultaneous shared and static lib

It builds fine for MinGW on Windows.

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

Added: 


Modified: 
clang/tools/libclang/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 88279ff7dae6..15f7ff94dfea 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -97,7 +97,7 @@ if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
-if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+if (MSVC AND ENABLE_SHARED AND ENABLE_STATIC)
   unset(ENABLE_STATIC)
 endif()
 



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


[clang] bb61304 - [MinGW][clang-shlib] Build by default on MinGW

2020-09-12 Thread Martin Storsjö via cfe-commits

Author: Mateusz Mikuła
Date: 2020-09-12T22:02:31+03:00
New Revision: bb613044b6800b8ccc238232677f905bda423819

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

LOG: [MinGW][clang-shlib] Build by default on MinGW

It builds without errors and makes possible to use
CLANG_LINK_CLANG_DYLIB=1.

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

Added: 


Modified: 
clang/tools/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index e46c3669a2c2..85a85812a8d4 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -15,7 +15,7 @@ add_clang_subdirectory(c-index-test)
 
 add_clang_subdirectory(clang-rename)
 add_clang_subdirectory(clang-refactor)
-if(UNIX)
+if(UNIX OR MINGW)
   add_clang_subdirectory(clang-shlib)
 endif()
 



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


[PATCH] D87517: [MinGW] Use lib prefix for libraries

2020-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc76965b1908: [MinGW] Use lib prefix for libraries (authored 
by mati865, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87517

Files:
  clang/tools/libclang/CMakeLists.txt
  lldb/source/API/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/llvm-config/llvm-config.cpp


Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -381,6 +381,7 @@
 SharedExt = "dll";
 SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
 if (HostTriple.isOSCygMing()) {
+  SharedPrefix = "lib";
   StaticExt = "a";
   StaticPrefix = "lib";
 } else {
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -567,7 +567,7 @@
   endif()
 
   if(ARG_SHARED)
-if(WIN32)
+if(MSVC)
   set_target_properties(${name} PROPERTIES
 PREFIX ""
 )
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -182,10 +182,10 @@
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 endif()
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+if (MSVC)
   # Only MSVC has the ABI compatibility problem and avoids using 
FindPythonLibs,
   # so only it needs to explicitly link against ${Python3_LIBRARIES}
-  if (MSVC AND LLDB_ENABLE_PYTHON)
+  if (LLDB_ENABLE_PYTHON)
 target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
   endif()
 else()
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -101,7 +101,7 @@
   unset(ENABLE_STATIC)
 endif()
 
-if(WIN32)
+if(MSVC)
   set(output_name "libclang")
 else()
   set(output_name "clang")


Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -381,6 +381,7 @@
 SharedExt = "dll";
 SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
 if (HostTriple.isOSCygMing()) {
+  SharedPrefix = "lib";
   StaticExt = "a";
   StaticPrefix = "lib";
 } else {
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -567,7 +567,7 @@
   endif()
 
   if(ARG_SHARED)
-if(WIN32)
+if(MSVC)
   set_target_properties(${name} PROPERTIES
 PREFIX ""
 )
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -182,10 +182,10 @@
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 endif()
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+if (MSVC)
   # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
   # so only it needs to explicitly link against ${Python3_LIBRARIES}
-  if (MSVC AND LLDB_ENABLE_PYTHON)
+  if (LLDB_ENABLE_PYTHON)
 target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
   endif()
 else()
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -101,7 +101,7 @@
   unset(ENABLE_STATIC)
 endif()
 
-if(WIN32)
+if(MSVC)
   set(output_name "libclang")
 else()
   set(output_name "clang")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] a8503b8 - [NFC] Remove unused static function

2020-09-12 Thread David Blaikie via cfe-commits
On Sat, Sep 12, 2020 at 1:15 AM Vitaly Buka  wrote:

> build fails with -DLLVM_ENABLE_WERROR=ON
>

Oh, I see - it's a -Wunused-function when building with LLVM_ENABLE_DUMP
off.

Kristof - if/when you want to recommit this, I think the only thing you
need to do is make this function not function-local "static".


>
> On Fri, 11 Sep 2020 at 23:16, Kristóf Umann  wrote:
>
>> Yup, unless you this breaks something, I'd really prefer to keep it.
>>
>> On Sat, 12 Sep 2020, 03:24 David Blaikie,  wrote:
>>
>>> LLVM_DUMP_METHOD is meant to be used for annotating functions that might
>>> be useful to execute from a debugger to dump data structures, etc - so it's
>>> expected that they'd be unused. Do you find that this function is not
>>> useful to use from a debugger/similar situation? (or perhaps because the
>>> function was "static" it was hitting a compiler warning/error & not
>>> actually being emitted into the resulting binary for use by an interactive
>>> debugger?)
>>>
>>> +Kristof for comments/thoughts
>>>
>>> On Fri, Sep 11, 2020 at 4:50 PM Vitaly Buka via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>

 Author: Vitaly Buka
 Date: 2020-09-11T16:50:30-07:00
 New Revision: a8503b87f739776cc9d5738f69aa0990db952340

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

 LOG: [NFC] Remove unused static function

 Added:


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

 Removed:




 
 diff  --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
 b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
 index 441dcad42444..ce4addd2f945 100644
 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
 +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
 @@ -834,11 +834,6 @@ LLVM_DUMP_METHOD static void
 dumpArgTokensToStream(llvm::raw_ostream &Out,
 const Preprocessor
 &PP,
 const ArgTokensTy
 &Toks);

 -LLVM_DUMP_METHOD static void dumpArgTokens(const Preprocessor &PP,
 -   const ArgTokensTy &Toks) {
 -  dumpArgTokensToStream(llvm::errs(), PP, Toks);
 -}
 -
  namespace {
  /// Maps unexpanded macro parameters to expanded arguments. A macro
 argument may
  /// need to expanded further when it is nested inside another macro.



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

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


[PATCH] D87539: [MinGW][libclang] Allow simultaneous shared and static lib

2020-09-12 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87539

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-12 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

rnk wrote:
> keith wrote:
> > rnk wrote:
> > > Please only make the path absolute if nothing in the prefix map matches. 
> > > Otherwise, the user must embed the CWD into the prefix map, which is 
> > > needlessly difficult for the build system. I believe it is also 
> > > consistent with the way that the debug info prefix map works. It appears 
> > > to operate on the possibly relative source paths received on the command 
> > > line (-I...).
> > Are you suggesting that I try to remap them relatively, and if that fails, 
> > absolutize it and attempt the remapping again? Or don't absolutize them at 
> > all anymore?
> I'd prefer to do the remapping once without any absolutization, and if that 
> fails, preserve the behavior of absolutizing.
> 
> It would be my preference to not absolutize paths at all, since that is what 
> is done for debug info. However, @vsk implemented things this way, and I do 
> understand that this is convenient default behavior for most users: the paths 
> in the coverage are valid anywhere on their system. So, changing this 
> behavior is out of scope for this patch.
I'm not sure how this changed would work for our use case. With bazel the usage 
of this works something like:

1. Relative paths are passed to the compiler `clang ... foo.c`
2. We would normally do `-fprofile-prefix-map=$PWD=.` to remap them

I think if we made this change, we would either have to:

1. Make the paths we pass absolute, which we couldn't do for reproducibility
2. Add some known prefix to the paths, like `.`, so we could 
`-fprofile-prefix-map=.=.` just to avoid this absolutizing codepath

So I think without actually removing the absolutizing behavior at the same 
time, this wouldn't work as we'd hope.

Let me know if I'm mis-understanding your suggestion!

If we did what I said above, I think it would work since relative path 
remapping would fail, but then prefix mapping the absolute path would work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D87201: [clang-format] Add a option for the position of Java static import

2020-09-12 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD accepted this revision.
JakeMerdichAMD added a comment.
This revision is now accepted and ready to land.

Sorry on the delay, LGTM too.

It looks like you're a first time contributor and probably don't have write 
access to the repo, do you want one of us to push this on your behalf? If you 
intend to have more commits in the future, write access to github isn't hard to 
get (just request it once you have a few changes in).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87201

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


[clang] d6fadc4 - [gcov] Process .gcda immediately after the accompanying .gcno instead of doing all .gcda after all .gcno

2020-09-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-09-12T13:53:03-07:00
New Revision: d6fadc49e3d7eb0977bca3ff92bf156bd059fcd4

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

LOG: [gcov] Process .gcda immediately after the accompanying .gcno instead of 
doing all .gcda after all .gcno

i.e. change the work flow from

* .gcno for function A
* .gcno for function B
* .gcno for function C
* .gcda for function A
* .gcda for function B
* .gcda for function C

to

* .gcno for function A
* .gcda for function A
* .gcno for function B
* .gcda for function B
* .gcno for function C
* .gcda for function C

Currently there is duplicate logic in .gcno & .gcda processing: how functions
are filtered, which edges are instrumented, etc. This refactor enables 
simplification.

Since we always process .gcno, in -fprofile-arcs -fno-test-coverage mode,
__llvm_internal_gcov_emit_function_args.0 will have non-zero checksums.

Added: 


Modified: 
clang/test/CodeGen/code-coverage.c
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Removed: 




diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index 5a663135e2f0..014dd9cfb5a7 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -38,7 +38,7 @@ int test2(int b) {
 
 
 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr 
constant [2 x %0]
-// CHECK-SAME: [%0 zeroinitializer, %0 { i32 1, i32 0, i32 0 }]
+// CHECK-SAME: [%0 { i32 0, i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }, %0 { i32 1, 
i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }]
 
 // CHECK: @__llvm_internal_gcov_emit_file_info = internal unnamed_addr 
constant [1 x %2]
 /// 0x3330342a '3' '0' '4' '*'

diff  --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp 
b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 15355ff8efd1..68df0af4892a 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -116,7 +116,11 @@ class GCOVProfiler {
 
   // Modify the program to track transitions along edges and call into the
   // profiling runtime to emit .gcda files when run.
-  bool emitProfileArcs(NamedMDNode *CUNode);
+  void instrumentFunction(
+  Function &F,
+  SmallVectorImpl> &CountersBySP);
+  void emitGlobalConstructor(
+  SmallVectorImpl> &CountersBySP);
 
   bool isFunctionInstrumented(const Function &F);
   std::vector createRegexesFromString(StringRef RegexesStr);
@@ -551,19 +555,15 @@ bool GCOVProfiler::runOnModule(
   Ctx = &M.getContext();
 
   NamedMDNode *CUNode = M.getNamedMetadata("llvm.dbg.cu");
-  if (!CUNode)
+  if (!CUNode || (!Options.EmitNotes && !Options.EmitData))
 return false;
 
   bool Modified = AddFlushBeforeForkAndExec();
 
   FilterRe = createRegexesFromString(Options.Filter);
   ExcludeRe = createRegexesFromString(Options.Exclude);
-
-  if (Options.EmitNotes)
-emitProfileNotes(CUNode);
-  if (Options.EmitData)
-Modified |= emitProfileArcs(CUNode);
-  return Modified;
+  emitProfileNotes(CUNode);
+  return Modified || Options.EmitData;
 }
 
 PreservedAnalyses GCOVProfilerPass::run(Module &M,
@@ -698,6 +698,7 @@ void GCOVProfiler::emitProfileNotes(NamedMDNode *CUNode) {
 : (c3 - '0') * 10 + c1 - '0';
   }
 
+  bool EmitGCDA = Options.EmitData;
   for (unsigned i = 0, e = CUNode->getNumOperands(); i != e; ++i) {
 // Each compile unit gets its own .gcno file. This means that whether we 
run
 // this pass over the original .o's as they're produced, or run it after
@@ -709,16 +710,8 @@ void GCOVProfiler::emitProfileNotes(NamedMDNode *CUNode) {
 if (CU->getDWOId())
   continue;
 
-std::error_code EC;
-raw_fd_ostream out(mangleName(CU, GCovFileType::GCNO), EC,
-   sys::fs::OF_None);
-if (EC) {
-  Ctx->emitError(Twine("failed to open coverage notes file for writing: ") 
+
- EC.message());
-  continue;
-}
-
 std::vector EdgeDestinations;
+SmallVector, 8> CountersBySP;
 
 Endian = M->getDataLayout().isLittleEndian() ? support::endianness::little
  : support::endianness::big;
@@ -789,165 +782,167 @@ void GCOVProfiler::emitProfileNotes(NamedMDNode 
*CUNode) {
 }
 Line = 0;
   }
+  if (EmitGCDA)
+instrumentFunction(F, CountersBySP);
 }
 
 char Tmp[4];
 JamCRC JC;
 JC.update(EdgeDestinations);
-os = &out;
 uint32_t Stamp = JC.getCRC();
 FileChecksums.push_back(Stamp);
-if (Endian == support::endianness::big) {
-  out.write("gcno", 4);
-  out.write(Options.Version, 4);
-} else {
-  out.write("oncg", 4);
-  std::reverse_copy(Options.Version, Options.Version + 4, Tmp)

[PATCH] D87537: [lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature

2020-09-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87537

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


[clang] 04febd3 - [lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature

2020-09-12 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2020-09-12T14:28:14-07:00
New Revision: 04febd30a8dab3ff4b6e6032f1a1a9f4725f8267

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

LOG: [lld][WebAssembly] Error on import/export of mutable global without 
`mutable-globals` feature

Also add the +mutable-globals features in clang when
building with `-fPIC` since the linker will generate mutable
globals imports and exports in that case.

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

Added: 
lld/test/wasm/mutable-globals.s

Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c
lld/test/wasm/Inputs/undefined-globals.s
lld/test/wasm/emit-relocs-fpic.s
lld/test/wasm/gc-imports.s
lld/test/wasm/pie.ll
lld/test/wasm/shared.ll
lld/wasm/Writer.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 10168736400f..d953082470aa 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -243,6 +243,27 @@ void WebAssembly::addClangTargetOptions(const ArgList 
&DriverArgs,
 CC1Args.push_back("+sign-ext");
   }
 
+  if (!DriverArgs.hasFlag(options::OPT_mmutable_globals,
+  options::OPT_mno_mutable_globals, false)) {
+// -fPIC implies +mutable-globals because the PIC ABI used by the linker
+// depends on importing and exporting mutable globals.
+llvm::Reloc::Model RelocationModel;
+unsigned PICLevel;
+bool IsPIE;
+std::tie(RelocationModel, PICLevel, IsPIE) =
+ParsePICArgs(*this, DriverArgs);
+if (RelocationModel == llvm::Reloc::PIC_) {
+  if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+ options::OPT_mmutable_globals, false)) {
+getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+<< "-fPIC"
+<< "-mno-mutable-globals";
+  }
+  CC1Args.push_back("-target-feature");
+  CC1Args.push_back("+mutable-globals");
+}
+  }
+
   if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) {
 // '-fwasm-exceptions' is not compatible with '-mno-exception-handling'
 if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index ad8b000ad225..3c2eb66f9e19 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -119,3 +119,14 @@
 // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
 // CHECK-REACTOR: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // CHECK-REACTOR: wasm-ld{{.*}}" "crt1-reactor.o" "--entry" "_initialize" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// -fPIC implies +mutable-globals
+
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIC %s
+// CHECK-PIC: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+mutable-globals"
+
+// '-mno-mutable-globals' is not allowed with '-fPIC'
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
+// PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'

diff  --git a/lld/test/wasm/Inputs/undefined-globals.s 
b/lld/test/wasm/Inputs/undefined-globals.s
index 607d7942d003..54dc4189a777 100644
--- a/lld/test/wasm/Inputs/undefined-globals.s
+++ b/lld/test/wasm/Inputs/undefined-globals.s
@@ -7,5 +7,5 @@ use_undef_global:
   global.get used_undef_global
   end_function
 
-.globaltype unused_undef_global, i64
-.globaltype used_undef_global, i64
+.globaltype unused_undef_global, i64, immutable
+.globaltype used_undef_global, i64, immutable

diff  --git a/lld/test/wasm/emit-relocs-fpic.s 
b/lld/test/wasm/emit-relocs-fpic.s
index c70e1e675109..1d81ca62786b 100644
--- a/lld/test/wasm/emit-relocs-fpic.s
+++ b/lld/test/wasm/emit-relocs-fpic.s
@@ -1,6 +1,6 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s 
-o %t.ret32.o
-# RUN: wasm-ld -pie --export-all --no-gc-sections --no-entry --emit-relocs -o 
%t.wasm %t.o %t.ret32.o
+# RUN: wasm-ld -pie --export-all --no-check-features --no-gc-sections 
--no-entry --emit-relocs -o %t.wasm %t.o %t.ret32.o
 # RUN: obj2yaml %t.wasm | FileCheck %s
 
 load_hidden_data:

diff  --git a/lld/test/wasm/gc-imports.s b/lld/test/wasm/gc-imports.s
index 6564b5c1a7d8..1f8bca9064e0 100644

[PATCH] D87537: [lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature

2020-09-12 Thread Sam Clegg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG04febd30a8da: [lld][WebAssembly] Error on import/export of 
mutable global without `mutable… (authored by sbc100).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87537

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c
  lld/test/wasm/Inputs/undefined-globals.s
  lld/test/wasm/emit-relocs-fpic.s
  lld/test/wasm/gc-imports.s
  lld/test/wasm/mutable-globals.s
  lld/test/wasm/pie.ll
  lld/test/wasm/shared.ll
  lld/wasm/Writer.cpp

Index: lld/wasm/Writer.cpp
===
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -461,6 +461,29 @@
   if (!config->checkFeatures)
 return;
 
+  if (!config->relocatable && used.count("mutable-globals") == 0) {
+for (Symbol *sym : symtab->getSymbols()) {
+  if (auto *global = dyn_cast(sym)) {
+if (global->getGlobalType()->Mutable) {
+  if (!sym->isLive())
+continue;
+  if (!sym->isUsedInRegularObj)
+continue;
+  if (sym->isUndefined() && sym->isWeak() && !config->relocatable)
+continue;
+  if (sym->isUndefined())
+error(Twine("mutable global imported but 'mutable-globals' feature "
+"not present in inputs: `") +
+  toString(*sym) + "`. Use --no-check-features to suppress.");
+  else if (sym->isExported())
+error(Twine("mutable global exported but 'mutable-globals' feature "
+"not present in inputs: `") +
+  toString(*sym) + "`. Use --no-check-features to suppress.");
+}
+  }
+}
+  }
+
   if (config->sharedMemory) {
 if (disallowed.count("shared-mem"))
   error("--shared-memory is disallowed by " + disallowed["shared-mem"] +
Index: lld/test/wasm/shared.ll
===
--- lld/test/wasm/shared.ll
+++ lld/test/wasm/shared.ll
@@ -1,4 +1,4 @@
-; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o
+; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o %t.o
 ; RUN: wasm-ld -shared -o %t.wasm %t.o
 ; RUN: obj2yaml %t.wasm | FileCheck %s
 
Index: lld/test/wasm/pie.ll
===
--- lld/test/wasm/pie.ll
+++ lld/test/wasm/pie.ll
@@ -1,4 +1,4 @@
-; RUN: llc -relocation-model=pic -filetype=obj %s -o %t.o
+; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o %t.o
 ; RUN: wasm-ld --no-gc-sections --allow-undefined -pie -o %t.wasm %t.o
 ; RUN: obj2yaml %t.wasm | FileCheck %s
 
Index: lld/test/wasm/mutable-globals.s
===
--- /dev/null
+++ lld/test/wasm/mutable-globals.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: not wasm-ld %t.o -o %t.wasm 2>&1 | FileCheck %s
+
+.globl _start
+_start:
+  .functype _start () -> ()
+  i32.const 1
+  global.set foo
+  end_function
+
+.globaltype foo, i32
+
+# CHECK: error: mutable global imported but 'mutable-globals' feature not present in inputs: `foo`. Use --no-check-features to suppress.
Index: lld/test/wasm/gc-imports.s
===
--- lld/test/wasm/gc-imports.s
+++ lld/test/wasm/gc-imports.s
@@ -31,7 +31,7 @@
 # CHECK-NEXT: Field:   used_undef_global
 # CHECK-NEXT: Kind:GLOBAL
 # CHECK-NEXT: GlobalType:  I64
-# CHECK-NEXT: GlobalMutable:   true
+# CHECK-NEXT: GlobalMutable:   false
 # CHECK-NEXT:   - Type:
 # CHECK:- Type:CUSTOM
 # CHECK-NEXT: Name:name
@@ -62,12 +62,12 @@
 # NO-GC-NEXT: Field:   unused_undef_global
 # NO-GC-NEXT: Kind:GLOBAL
 # NO-GC-NEXT: GlobalType:  I64
-# NO-GC-NEXT: GlobalMutable:   true
+# NO-GC-NEXT: GlobalMutable:   false
 # NO-GC-NEXT:   - Module:  env
 # NO-GC-NEXT: Field:   used_undef_global
 # NO-GC-NEXT: Kind:GLOBAL
 # NO-GC-NEXT: GlobalType:  I64
-# NO-GC-NEXT: GlobalMutable:   true
+# NO-GC-NEXT: GlobalMutable:   false
 # NO-GC-NEXT:   - Type:
 # NO-GC:- Type:CUSTOM
 # NO-GC-NEXT: Name:name
Index: lld/test/wasm/emit-relocs-fpic.s
===
--- lld/test/wasm/emit-relocs-fpic.s
+++ lld/test/wasm/emit-relocs-fpic.s
@@ -1,6 +1,6 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/ret32.s -o %t.ret32.o
-# RUN: wasm-ld

[PATCH] D87201: [clang-format] Add a option for the position of Java static import

2020-09-12 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee marked an inline comment as done.
bc-lee added a comment.

It's okay for some reviewers to make this change on my behalf. Thanks for 
reviewing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87201

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


[PATCH] D86581: [clang-format] Handle shifts within conditions

2020-09-12 Thread Miguel Saldivar via Phabricator via cfe-commits
Saldivarcher added a comment.

@MyDeveloperDay looks like it's in master, thanks for committing for me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86581

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


[PATCH] D85596: [Docs] Fix --print-supported-cpus option rendering

2020-09-12 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fb2203cd6c2: [Docs] Fix --print-supported-cpus option 
rendering (authored by tmfink, committed by mehdi_amini).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85596

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -338,12 +338,12 @@
 .. option:: --print-supported-cpus
 
   Print out a list of supported processors for the given target (specified
-  through --target= or -arch ). If no target is
-  specified, the system default target will be used.
+  through ``--target=`` or :option:`-arch` ). 
If no
+  target is specified, the system default target will be used.
 
 .. option:: -mcpu=?, -mtune=?
 
-  Aliases of --print-supported-cpus
+  Acts as an alias for :option:`--print-supported-cpus`.
 
 .. option:: -march=
 


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -338,12 +338,12 @@
 .. option:: --print-supported-cpus
 
   Print out a list of supported processors for the given target (specified
-  through --target= or -arch ). If no target is
-  specified, the system default target will be used.
+  through ``--target=`` or :option:`-arch` ). If no
+  target is specified, the system default target will be used.
 
 .. option:: -mcpu=?, -mtune=?
 
-  Aliases of --print-supported-cpus
+  Acts as an alias for :option:`--print-supported-cpus`.
 
 .. option:: -march=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0fb2203 - [Docs] Fix --print-supported-cpus option rendering

2020-09-12 Thread Mehdi Amini via cfe-commits

Author: Travis Finkenauer
Date: 2020-09-13T05:26:18Z
New Revision: 0fb2203cd6c287e7438b7ac2571645066c63eeb6

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

LOG: [Docs] Fix --print-supported-cpus option rendering

Adds link/code sample to avoid rendering two dashes as non-ASCII "en dash".
Also make wording a complete sentence.

Reviewed By: nickdesaulniers, tmfink

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

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 394bd1be24e8..11169e352894 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -338,12 +338,12 @@ number of cross compilers, or may only support a native 
target.
 .. option:: --print-supported-cpus
 
   Print out a list of supported processors for the given target (specified
-  through --target= or -arch ). If no target is
-  specified, the system default target will be used.
+  through ``--target=`` or :option:`-arch` ). 
If no
+  target is specified, the system default target will be used.
 
 .. option:: -mcpu=?, -mtune=?
 
-  Aliases of --print-supported-cpus
+  Acts as an alias for :option:`--print-supported-cpus`.
 
 .. option:: -march=
 



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


[clang] f086e85 - [gcov] Assign names to some types and loaded values used in @__llvm_internal*

2020-09-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-09-12T22:42:37-07:00
New Revision: f086e85eea94a51eb42115496ac5d24f07bc8791

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

LOG: [gcov] Assign names to some types and loaded values used in 
@__llvm_internal*

This makes the generated IR much more readable.

Added: 


Modified: 
clang/test/CodeGen/code-coverage.c
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Removed: 




diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index 014dd9cfb5a7..39c4556b9ff4 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -37,10 +37,10 @@ int test2(int b) {
 }
 
 
-// CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr 
constant [2 x %0]
-// CHECK-SAME: [%0 { i32 0, i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }, %0 { i32 1, 
i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }]
+// CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr 
constant [2 x %emit_function_args_ty]
+// CHECK-SAME: [%emit_function_args_ty { i32 0, i32 {{[-0-9]+}}, i32 
{{[-0-9]+}} }, %emit_function_args_ty { i32 1, i32 {{[-0-9]+}}, i32 {{[-0-9]+}} 
}]
 
-// CHECK: @__llvm_internal_gcov_emit_file_info = internal unnamed_addr 
constant [1 x %2]
+// CHECK: @__llvm_internal_gcov_emit_file_info = internal unnamed_addr 
constant [1 x %file_info]
 /// 0x3330342a '3' '0' '4' '*'
 // 304-SAME: i32 858797098
 /// 0x3430372a '4' '0' '7' '*'

diff  --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp 
b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 68df0af4892a..734deda99707 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -1029,15 +1029,19 @@ Function *GCOVProfiler::insertCounterWriteout(
   // Collect the relevant data into a large constant data structure that we can
   // walk to write out everything.
   StructType *StartFileCallArgsTy = StructType::create(
-  {Builder.getInt8PtrTy(), Builder.getInt32Ty(), Builder.getInt32Ty()});
+  {Builder.getInt8PtrTy(), Builder.getInt32Ty(), Builder.getInt32Ty()},
+  "start_file_args_ty");
   StructType *EmitFunctionCallArgsTy = StructType::create(
-  {Builder.getInt32Ty(), Builder.getInt32Ty(), Builder.getInt32Ty()});
+  {Builder.getInt32Ty(), Builder.getInt32Ty(), Builder.getInt32Ty()},
+  "emit_function_args_ty");
   StructType *EmitArcsCallArgsTy = StructType::create(
-  {Builder.getInt32Ty(), Builder.getInt64Ty()->getPointerTo()});
+  {Builder.getInt32Ty(), Builder.getInt64Ty()->getPointerTo()},
+  "emit_arcs_args_ty");
   StructType *FileInfoTy =
   StructType::create({StartFileCallArgsTy, Builder.getInt32Ty(),
   EmitFunctionCallArgsTy->getPointerTo(),
-  EmitArcsCallArgsTy->getPointerTo()});
+  EmitArcsCallArgsTy->getPointerTo()},
+ "file_info");
 
   Constant *Zero32 = Builder.getInt32(0);
   // Build an explicit array of two zeros for use in ConstantExpr GEP building.
@@ -1147,41 +1151,46 @@ Function *GCOVProfiler::insertCounterWriteout(
 
   // The index into the files structure is our loop induction variable.
   Builder.SetInsertPoint(FileLoopHeader);
-  PHINode *IV =
-  Builder.CreatePHI(Builder.getInt32Ty(), /*NumReservedValues*/ 2);
+  PHINode *IV = Builder.CreatePHI(Builder.getInt32Ty(), /*NumReservedValues*/ 
2,
+  "file_idx");
   IV->addIncoming(Builder.getInt32(0), BB);
   auto *FileInfoPtr = Builder.CreateInBoundsGEP(
   FileInfoArrayTy, FileInfoArrayGV, {Builder.getInt32(0), IV});
   auto *StartFileCallArgsPtr =
-  Builder.CreateStructGEP(FileInfoTy, FileInfoPtr, 0);
+  Builder.CreateStructGEP(FileInfoTy, FileInfoPtr, 0, "start_file_args");
   auto *StartFileCall = Builder.CreateCall(
   StartFile,
   {Builder.CreateLoad(StartFileCallArgsTy->getElementType(0),
   Builder.CreateStructGEP(StartFileCallArgsTy,
-  StartFileCallArgsPtr, 0)),
+  StartFileCallArgsPtr, 0),
+  "filename"),
Builder.CreateLoad(StartFileCallArgsTy->getElementType(1),
   Builder.CreateStructGEP(StartFileCallArgsTy,
-  StartFileCallArgsPtr, 1)),
+  StartFileCallArgsPtr, 1),
+  "version"),
Builder.CreateLoad(StartFileCallArgsTy->getElementType(2),
   Builder.CreateStructGEP(StartFileCallArgsTy,
-  StartFileCallA