[PATCH] D80109: [AST][RecoveryExpr] Preserve type for broken member call expr.

2020-11-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added a comment.

sorry for the delay, picking it up now.




Comment at: clang/lib/Sema/SemaCoroutine.cpp:864
 ExprResult R = buildPromiseCall(*this, Promise, Loc, "await_transform", E);
-if (R.isInvalid()) {
+if (R.isInvalid() || R.get()->containsErrors()) {
   Diag(Loc,

we need this change to prevent a regression on co_await-range-for.

without this change, we will emit 2 `call to deleted member function 
'await_transform'` diagnostics  on 
https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCXX/co_await-range-for.cpp#L52-L54.



Comment at: clang/test/AST/ast-dump-recovery.cpp:123
+
+  // FIXME: capture the type!
+  f.func(1);

sammccall wrote:
> why does this not work?
> isn't there only one candidate, so chooseRecoveryType should pick it?
this is on a different codepath, will fix in https://reviews.llvm.org/D92298


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80109

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


[PATCH] D92198: [clangd] Implement remote index handshake

2020-11-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 308269.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.
Herald added a subscriber: jfb.

Use WaitForStateChange instead. Simplify code structure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92198

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp


Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -6,10 +6,14 @@
 //
 
//===--===//
 
+#include 
 #include 
 
 #include "Client.h"
 #include "Service.grpc.pb.h"
+#include "grpc/impl/codegen/connectivity_state.h"
+#include "grpcpp/channel.h"
+#include "grpcpp/impl/codegen/completion_queue.h"
 #include "index/Index.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
@@ -19,6 +23,33 @@
 #include "llvm/Support/Error.h"
 
 #include 
+#include 
+#include 
+
+namespace llvm {
+template <> struct format_provider {
+  static void format(const grpc_connectivity_state &State, raw_ostream &Stream,
+ StringRef Style) {
+switch (State) {
+case GRPC_CHANNEL_IDLE:
+  Stream << "GRPC_CHANNEL_IDLE";
+  break;
+case GRPC_CHANNEL_CONNECTING:
+  Stream << "GRPC_CHANNEL_CONNECTING";
+  break;
+case GRPC_CHANNEL_READY:
+  Stream << "GRPC_CHANNEL_READY";
+  break;
+case GRPC_CHANNEL_TRANSIENT_FAILURE:
+  Stream << "GRPC_CHANNEL_TRANSIENT_FAILURE";
+  break;
+case GRPC_CHANNEL_SHUTDOWN:
+  Stream << "GRPC_CHANNEL_SHUTDOWN";
+  break;
+}
+  }
+};
+} // namespace llvm
 
 namespace clang {
 namespace clangd {
@@ -80,6 +111,25 @@
   /*LocalIndexRoot=*/ProjectRoot)),
 DeadlineWaitingTime(DeadlineTime) {
 assert(!ProjectRoot.empty());
+ChannelStatusWatcher = std::thread([&Channel]() {
+  grpc_connectivity_state Status =
+  Channel->GetState(/*try_to_connect=*/true);
+  static constexpr auto DeadlineWaitingTime = std::chrono::seconds(1);
+  log("Remote index connection status: {0}", Status);
+  while (!ClientShutdownRequested) {
+if (Channel->WaitForStateChange(Status,
+std::chrono::system_clock::now() +
+DeadlineWaitingTime)) {
+  Status = Channel->GetState(/*try_to_connect=*/true);
+  log("Remote index connection status changed: {0}", Status);
+}
+  }
+});
+  }
+
+  ~IndexClient() {
+ClientShutdownRequested = true;
+ChannelStatusWatcher.join();
   }
 
   void lookup(const clangd::LookupRequest &Request,
@@ -121,15 +171,18 @@
   std::unique_ptr ProtobufMarshaller;
   // Each request will be terminated if it takes too long.
   std::chrono::milliseconds DeadlineWaitingTime;
+  static std::atomic ClientShutdownRequested;
+  std::thread ChannelStatusWatcher;
 };
 
+std::atomic IndexClient::ClientShutdownRequested = {false};
+
 } // namespace
 
 std::unique_ptr getClient(llvm::StringRef Address,
llvm::StringRef ProjectRoot) {
   const auto Channel =
   grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
-  Channel->GetState(true);
   return std::unique_ptr(
   new IndexClient(Channel, ProjectRoot));
 }


Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -6,10 +6,14 @@
 //
 //===--===//
 
+#include 
 #include 
 
 #include "Client.h"
 #include "Service.grpc.pb.h"
+#include "grpc/impl/codegen/connectivity_state.h"
+#include "grpcpp/channel.h"
+#include "grpcpp/impl/codegen/completion_queue.h"
 #include "index/Index.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
@@ -19,6 +23,33 @@
 #include "llvm/Support/Error.h"
 
 #include 
+#include 
+#include 
+
+namespace llvm {
+template <> struct format_provider {
+  static void format(const grpc_connectivity_state &State, raw_ostream &Stream,
+ StringRef Style) {
+switch (State) {
+case GRPC_CHANNEL_IDLE:
+  Stream << "GRPC_CHANNEL_IDLE";
+  break;
+case GRPC_CHANNEL_CONNECTING:
+  Stream << "GRPC_CHANNEL_CONNECTING";
+  break;
+case GRPC_CHANNEL_READY:
+  Stream << "GRPC_CHANNEL_READY";
+  break;
+case GRPC_CHANNEL_TRANSIENT_FAILURE:
+  Stream << "GRPC_CHANNEL_TRANSIENT_FAILURE";
+  break;
+case GRPC_CHANNEL_SHUTDOWN:
+  Stream << "GRPC_CHANNEL_SHUTDOWN";
+  break;
+}
+  }
+};
+} // namespace llvm
 
 namespace clang {

[PATCH] D92198: [clangd] Implement remote index handshake

2020-11-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Yes, the idea here is to provide logging for gRPC server state. My original 
thought was that default `HealthCheck` might not be enough and we might want to 
add more things in the mechanism but I guess it's not obvious what these 
extensions might be and getting `grpc_connectivity_state` might be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92198

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


[clang] ec6c5e9 - [clang] Improve diagnostics for auto-return-type function if the return expr had an error.

2020-11-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-30T09:19:15+01:00
New Revision: ec6c5e920a89db0e1c5f73b8349ee0b84192072d

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

LOG: [clang] Improve diagnostics for auto-return-type function if the return 
expr had an error.

Given the following case:

```
auto k() {
  return undef();
  return 1;
}
```

Prior to the patch, clang emits an `cannot initialize return object of type
'auto' with an rvalue of type 'int'` diagnostic on the second return
(because the return type of the function cannot be deduced from the first 
contain-errors return).

This patch suppresses this error.

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

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/attr-target-mv.cpp
clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
clang/test/SemaCXX/lambda-expressions.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 195121e1e256..f5bf889b3878 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3327,9 +3327,14 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, 
Expr *RetValExp) {
   }
 
   if (HasDeducedReturnType) {
+FunctionDecl *FD = CurLambda->CallOperator;
+// If we've already decided this lambda is invalid, e.g. because
+// we saw a `return` whose expression had an error, don't keep
+// trying to deduce its return type.
+if (FD->isInvalidDecl())
+  return StmtError();
 // In C++1y, the return type may involve 'auto'.
 // FIXME: Blocks might have a return type of 'auto' explicitly specified.
-FunctionDecl *FD = CurLambda->CallOperator;
 if (CurCap->ReturnType.isNull())
   CurCap->ReturnType = FD->getReturnType();
 
@@ -3709,6 +3714,11 @@ StmtResult Sema::BuildReturnStmt(SourceLocation 
ReturnLoc, Expr *RetValExp) {
   if (getLangOpts().CPlusPlus14) {
 if (AutoType *AT = FnRetType->getContainedAutoType()) {
   FunctionDecl *FD = cast(CurContext);
+  // If we've already decided this function is invalid, e.g. because
+  // we saw a `return` whose expression had an error, don't keep
+  // trying to deduce its return type.
+  if (FD->isInvalidDecl())
+return StmtError();
   if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
 FD->setInvalidDecl();
 return StmtError();

diff  --git a/clang/test/SemaCXX/attr-target-mv.cpp 
b/clang/test/SemaCXX/attr-target-mv.cpp
index 11f3a276c7c7..5ef1d398d2d8 100644
--- a/clang/test/SemaCXX/attr-target-mv.cpp
+++ b/clang/test/SemaCXX/attr-target-mv.cpp
@@ -107,7 +107,6 @@ int __attribute__((target("arch=sandybridge"))) 
diff _mangle(void) { return 0; }
 
 // expected-error@+1 {{multiversioned functions do not yet support deduced 
return types}}
 auto __attribute__((target("default"))) deduced_return(void) { return 0; }
-// expected-error@-1 {{cannot initialize return object of type 'auto' with an 
rvalue of type 'int'}}
 
 auto __attribute__((target("default"))) trailing_return(void)-> int { return 
0; }
 

diff  --git a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp 
b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
index 958728b10487..3e544c300884 100644
--- a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -22,7 +22,7 @@ int conv1d = conv1.operator int(); // expected-error {{no 
member named 'operator
 
 struct Conv2 {
   operator auto() { return 0; }  // expected-note {{previous}}
-  operator auto() { return 0.; } // expected-error {{cannot be redeclared}} 
expected-error {{cannot initialize return object of type 'auto' with an rvalue 
of type 'double'}}
+  operator auto() { return 0.; } // expected-error {{cannot be redeclared}}
 };
 
 struct Conv3 {
@@ -100,7 +100,7 @@ auto fac(int n) {
 auto fac_2(int n) { // expected-note {{declared here}}
   if (n > 2)
 return n * fac_2(n-1); // expected-error {{cannot be used before it is 
defined}}
-  return n; // expected-error {{cannot initialize return object of type 
'auto'}}
+  return n;
 }
 
 auto void_ret() {}
@@ -617,7 +617,6 @@ namespace PR33222 {
   };
   template<> auto *B::q() { return (int*)0; }
   template<> auto B::q() { return (int*)0; } // expected-error 
{{return type}}
-  // FIXME: suppress this follow-on error: expected-error@-1 {{cannot 
initialize}}
   template<> int B::q() { return 0; } // expected-error {{return 
type}}
 }
 

diff  --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 7f7f9c570487..22e0939379f5 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -521,6 +521,10 @@ void foo() {
   return undeclared_error; // expected-error {{us

[PATCH] D92211: [clang] Improve diagnostics for auto-return-type function if the return expr had an error

2020-11-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec6c5e920a89: [clang] Improve diagnostics for 
auto-return-type function if the return expr… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92211

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/attr-target-mv.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -521,6 +521,10 @@
   return undeclared_error; // expected-error {{use of undeclared 
identifier}}
 return 0;
   };
+  auto bar = []() {
+return undef(); // expected-error {{use of undeclared identifier}}
+return 0; // verify no init_conversion_failed diagnostic emitted.
+  };
 }
 }
 
Index: clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
===
--- clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -22,7 +22,7 @@
 
 struct Conv2 {
   operator auto() { return 0; }  // expected-note {{previous}}
-  operator auto() { return 0.; } // expected-error {{cannot be redeclared}} 
expected-error {{cannot initialize return object of type 'auto' with an rvalue 
of type 'double'}}
+  operator auto() { return 0.; } // expected-error {{cannot be redeclared}}
 };
 
 struct Conv3 {
@@ -100,7 +100,7 @@
 auto fac_2(int n) { // expected-note {{declared here}}
   if (n > 2)
 return n * fac_2(n-1); // expected-error {{cannot be used before it is 
defined}}
-  return n; // expected-error {{cannot initialize return object of type 
'auto'}}
+  return n;
 }
 
 auto void_ret() {}
@@ -617,7 +617,6 @@
   };
   template<> auto *B::q() { return (int*)0; }
   template<> auto B::q() { return (int*)0; } // expected-error 
{{return type}}
-  // FIXME: suppress this follow-on error: expected-error@-1 {{cannot 
initialize}}
   template<> int B::q() { return 0; } // expected-error {{return 
type}}
 }
 
Index: clang/test/SemaCXX/attr-target-mv.cpp
===
--- clang/test/SemaCXX/attr-target-mv.cpp
+++ clang/test/SemaCXX/attr-target-mv.cpp
@@ -107,7 +107,6 @@
 
 // expected-error@+1 {{multiversioned functions do not yet support deduced 
return types}}
 auto __attribute__((target("default"))) deduced_return(void) { return 0; }
-// expected-error@-1 {{cannot initialize return object of type 'auto' with an 
rvalue of type 'int'}}
 
 auto __attribute__((target("default"))) trailing_return(void)-> int { return 
0; }
 
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3327,9 +3327,14 @@
   }
 
   if (HasDeducedReturnType) {
+FunctionDecl *FD = CurLambda->CallOperator;
+// If we've already decided this lambda is invalid, e.g. because
+// we saw a `return` whose expression had an error, don't keep
+// trying to deduce its return type.
+if (FD->isInvalidDecl())
+  return StmtError();
 // In C++1y, the return type may involve 'auto'.
 // FIXME: Blocks might have a return type of 'auto' explicitly specified.
-FunctionDecl *FD = CurLambda->CallOperator;
 if (CurCap->ReturnType.isNull())
   CurCap->ReturnType = FD->getReturnType();
 
@@ -3709,6 +3714,11 @@
   if (getLangOpts().CPlusPlus14) {
 if (AutoType *AT = FnRetType->getContainedAutoType()) {
   FunctionDecl *FD = cast(CurContext);
+  // If we've already decided this function is invalid, e.g. because
+  // we saw a `return` whose expression had an error, don't keep
+  // trying to deduce its return type.
+  if (FD->isInvalidDecl())
+return StmtError();
   if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
 FD->setInvalidDecl();
 return StmtError();


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -521,6 +521,10 @@
   return undeclared_error; // expected-error {{use of undeclared identifier}}
 return 0;
   };
+  auto bar = []() {
+return undef(); // expected-error {{use of undeclared identifier}}
+return 0; // verify no init_conversion_failed diagnostic emitted.
+  };
 }
 }
 
Index: clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
===
--- clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -22,7 +22,7 @@
 
 struct Conv2 {
   operator auto() { return 0; }  // expected-note

[PATCH] D92221: Don't delete default constructor of PathDiagnosticConsumerOptions

2020-11-30 Thread Moritz Sichert via Phabricator via cfe-commits
MoritzS added a comment.

Another way to avoid UB in that case is to use value initialization, i.e. 
`PathDiagnosticConsumerOptions options{};`.

Can you commit this, please? I don't have commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92221

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


[clang] c219282 - [AST][RecoveryAST] Preseve more invalid return stmt.

2020-11-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-30T09:26:41+01:00
New Revision: c21928285430cc25905f774a89cb948867ae55b6

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

LOG: [AST][RecoveryAST] Preseve more invalid return stmt.

suppress the diagnostics for missing return stmt in constexpr func.

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

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/typo-correction-crash.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index f5bf889b3878..d89dfaf78a9c 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3629,7 +3629,8 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr 
*RetValExp,
   Scope *CurScope) {
   // Correct typos, in case the containing function returns 'auto' and
   // RetValExp should determine the deduced type.
-  ExprResult RetVal = CorrectDelayedTyposInExpr(RetValExp);
+  ExprResult RetVal = CorrectDelayedTyposInExpr(
+  RetValExp, nullptr, /*RecoverUncorrectedTypos=*/true);
   if (RetVal.isInvalid())
 return StmtError();
   StmtResult R = BuildReturnStmt(ReturnLoc, RetVal.get());

diff  --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp 
b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index 8b80f5438d8e..67c5e78b8791 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1807,11 +1807,10 @@ namespace PR15884 {
 }
 
 namespace AfterError {
-  // FIXME: Suppress the 'no return statements' diagnostic if the body is 
invalid.
-  constexpr int error() { // expected-error {{no return statement}}
+  constexpr int error() {
 return foobar; // expected-error {{undeclared identifier}}
   }
-  constexpr int k = error();
+  constexpr int k = error(); // expected-error {{constexpr variable 'k' must 
be initialized by a constant expression}}
 }
 
 namespace std {

diff  --git a/clang/test/SemaCXX/typo-correction-crash.cpp 
b/clang/test/SemaCXX/typo-correction-crash.cpp
index 10c0c11aaa6b..49ea4c1bf16c 100644
--- a/clang/test/SemaCXX/typo-correction-crash.cpp
+++ b/clang/test/SemaCXX/typo-correction-crash.cpp
@@ -16,7 +16,8 @@ template  struct is_same { static constexpr 
bool value = true; };
 
 auto L1 = [] { return s; }; // expected-error {{use of undeclared identifier 
's'}}
 using T1 = decltype(L1());
-static_assert(is_same::value, "Return statement should be 
discarded");
+// FIXME: Suppress the 'undeclared identifier T1' diagnostic, the UsingDecl T1 
is discarded because of an invalid L1().
+static_assert(is_same::value, "Return statement should be 
discarded"); // expected-error {{use of undeclared identifier 'T1'}}
 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 
'tes'; did you mean 'test'?}}
 using T2 = decltype(L2());
 static_assert(is_same::value, "Return statement was corrected");



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


[PATCH] D82284: [AST][RecoveryAST] Preseve invalid return stmt, and suppress the diagnostics for missing return stmt in constexpr func.

2020-11-30 Thread Haojian Wu 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 rGc21928285430: [AST][RecoveryAST] Preseve more invalid return 
stmt. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82284

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/typo-correction-crash.cpp


Index: clang/test/SemaCXX/typo-correction-crash.cpp
===
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -16,7 +16,8 @@
 
 auto L1 = [] { return s; }; // expected-error {{use of undeclared identifier 
's'}}
 using T1 = decltype(L1());
-static_assert(is_same::value, "Return statement should be 
discarded");
+// FIXME: Suppress the 'undeclared identifier T1' diagnostic, the UsingDecl T1 
is discarded because of an invalid L1().
+static_assert(is_same::value, "Return statement should be 
discarded"); // expected-error {{use of undeclared identifier 'T1'}}
 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 
'tes'; did you mean 'test'?}}
 using T2 = decltype(L2());
 static_assert(is_same::value, "Return statement was corrected");
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1807,11 +1807,10 @@
 }
 
 namespace AfterError {
-  // FIXME: Suppress the 'no return statements' diagnostic if the body is 
invalid.
-  constexpr int error() { // expected-error {{no return statement}}
+  constexpr int error() {
 return foobar; // expected-error {{undeclared identifier}}
   }
-  constexpr int k = error();
+  constexpr int k = error(); // expected-error {{constexpr variable 'k' must 
be initialized by a constant expression}}
 }
 
 namespace std {
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3629,7 +3629,8 @@
   Scope *CurScope) {
   // Correct typos, in case the containing function returns 'auto' and
   // RetValExp should determine the deduced type.
-  ExprResult RetVal = CorrectDelayedTyposInExpr(RetValExp);
+  ExprResult RetVal = CorrectDelayedTyposInExpr(
+  RetValExp, nullptr, /*RecoverUncorrectedTypos=*/true);
   if (RetVal.isInvalid())
 return StmtError();
   StmtResult R = BuildReturnStmt(ReturnLoc, RetVal.get());


Index: clang/test/SemaCXX/typo-correction-crash.cpp
===
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -16,7 +16,8 @@
 
 auto L1 = [] { return s; }; // expected-error {{use of undeclared identifier 's'}}
 using T1 = decltype(L1());
-static_assert(is_same::value, "Return statement should be discarded");
+// FIXME: Suppress the 'undeclared identifier T1' diagnostic, the UsingDecl T1 is discarded because of an invalid L1().
+static_assert(is_same::value, "Return statement should be discarded"); // expected-error {{use of undeclared identifier 'T1'}}
 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
 using T2 = decltype(L2());
 static_assert(is_same::value, "Return statement was corrected");
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1807,11 +1807,10 @@
 }
 
 namespace AfterError {
-  // FIXME: Suppress the 'no return statements' diagnostic if the body is invalid.
-  constexpr int error() { // expected-error {{no return statement}}
+  constexpr int error() {
 return foobar; // expected-error {{undeclared identifier}}
   }
-  constexpr int k = error();
+  constexpr int k = error(); // expected-error {{constexpr variable 'k' must be initialized by a constant expression}}
 }
 
 namespace std {
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3629,7 +3629,8 @@
   Scope *CurScope) {
   // Correct typos, in case the containing function returns 'auto' and
   // RetValExp should determine the deduced type.
-  ExprResult RetVal = CorrectDelayedTyposInExpr(RetValExp);
+  ExprResult RetVal = CorrectDelayedTyposInExpr(
+  RetValExp, nullptr, /*RecoverUncorrectedTypos=*/true);
   if (RetVal.isInvalid())
 return StmtError();
   StmtResult R = BuildReturnStmt(ReturnLoc, RetVal.get());
___

[PATCH] D92299: [clangd] Go-to-definition on pure virtual method decls jumps to all overrides.

2020-11-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: usaxena95.
Herald added subscribers: kadircet, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92299

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -349,6 +349,22 @@
   ElementsAre(Sym("Forward", SymbolHeader.range("forward"), Test.range(;
 }
 
+TEST(LocateSymbol, FindOverrides) {
+  auto Code = Annotations(R"cpp(
+class Foo {
+  virtual void $1[[fo^o]]() = 0;
+};
+class Bar : public Foo {
+  void $2[[foo]]() override;
+};
+  )cpp");
+  TestTU TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  EXPECT_THAT(locateSymbolAt(AST, Code.point(), TU.index().get()),
+  UnorderedElementsAre(Sym("foo", Code.range("1"), llvm::None),
+   Sym("foo", Code.range("2"), llvm::None)));
+}
+
 TEST(LocateSymbol, WithIndexPreferredLocation) {
   Annotations SymbolHeader(R"cpp(
 class $p[[Proto]] {};
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -292,6 +292,35 @@
   return D;
 }
 
+std::vector findOverrides(llvm::DenseSet IDs,
+ const SymbolIndex *Index,
+ llvm::StringRef MainFilePath) {
+  if (IDs.empty())
+return {};
+  RelationsRequest Req;
+  Req.Predicate = RelationKind::OverriddenBy;
+  Req.Subjects = std::move(IDs);
+  std::vector Results;
+  Index->relations(Req, [&](const SymbolID &Subject, const Symbol &Object) {
+auto DeclLoc =
+indexToLSPLocation(Object.CanonicalDeclaration, MainFilePath);
+if (!DeclLoc) {
+  elog("Find overrides: {0}", DeclLoc.takeError());
+  return;
+}
+Results.emplace_back();
+Results.back().Name = Object.Name.str();
+Results.back().PreferredDeclaration = *DeclLoc;
+auto DefLoc = indexToLSPLocation(Object.Definition, MainFilePath);
+if (!DefLoc) {
+  elog("Failed to convert location:", DefLoc.takeError());
+  return;
+}
+Results.back().Definition = *DefLoc;
+  });
+  return Results;
+}
+
 // Decls are more complicated.
 // The AST contains at least a declaration, maybe a definition.
 // These are up-to-date, and so generally preferred over index results.
@@ -330,10 +359,19 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto Candidates =
   getDeclAtPositionWithRelations(AST, CurLoc, Relations, NodeKind);
+  llvm::DenseSet VirtualMethods;
   for (const auto &E : Candidates) {
 const NamedDecl *D = E.first;
-// Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
+  // Special case: virtual void ^method() = 0: jump to all overrides.
+  // FIXME: extend it to ^virtual, unfortunately, virtual location is not
+  // saved in the AST.
+  if (CMD->isPure()) {
+if (TouchedIdentifier && SM.getSpellingLoc(CMD->getLocation()) ==
+ TouchedIdentifier->location())
+  VirtualMethods.insert(getSymbolID(CMD));
+  }
+  // Special case: void foo() ^override: jump to the overridden method.
   const InheritableAttr *Attr = D->getAttr();
   if (!Attr)
 Attr = D->getAttr();
@@ -420,6 +458,8 @@
 });
   }
 
+  auto Overrides = findOverrides(VirtualMethods, Index, MainFilePath);
+  Result.insert(Result.end(), Overrides.begin(), Overrides.end());
   return Result;
 }
 
@@ -1145,36 +1185,14 @@
  CurLoc.takeError());
 return {};
   }
-  std::vector Results;
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  RelationsRequest Req;
-  Req.Predicate = RelationKind::OverriddenBy;
+  llvm::DenseSet VirtualMethods;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations))
 if (const CXXMethodDecl *CXXMD = llvm::dyn_cast(ND))
   if (CXXMD->isVirtual())
-Req.Subjects.insert(getSymbolID(ND));
-
-  if (Req.Subjects.empty())
-return Results;
-  Index->relations(Req, [&](const SymbolID &Subject, const Symbol &Object) {
-auto DeclLoc =
-indexToLSPLocation(Object.CanonicalDeclaration, *MainFilePath);
-if (!DeclLoc) {
-  elog("Find implementation: {0}", DeclLoc.takeError());
-  return;
-}
-LocatedSymbol Loc;
-Loc.Name = Object.Name.str();
-Loc.PreferredDeclaration = *DeclLoc;
-auto DefLoc = indexToLSPLocation(Object.Definition, *MainFilePath);
-if (DefL

[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-30 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:276-277
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on Windows or Mac OS X">;
 

kristof.beyls wrote:
> There are more OSes than Linux, Windows or OSX.
> Maybe it's somewhat better to say "-fstack-clash-protection is not supported 
> on %0", with the targeted OS being fed in.
> If that is not easily possible, maybe just say "-fstack-clash-protection is 
> not supported on the targeted OS"?
> Maybe it's somewhat better to say "-fstack-clash-protection is not supported 
> on %0", with the targeted OS being fed in.
I second that one.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3084
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain);

In that case you should probably allow explicitly the different Linux flavors 
here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2356-2359
+  auto *CD = cast(OldParam->getDeclContext());
+  // If the typedef is not a local typedef, then skip the transform.
+  if (OldTypedefDecl->getDeclContext() != CD->getDeclContext())
+return OldParam;

I think it would be equivalent and simpler to check only 
`OldTypedefDecl->getDeclContext()->isDependentContext()`. If we can resolve the 
name of the typedef to a dependently-scoped typedef, it must be a member of the 
current instantiation, and that's what we really care about here. This would 
also avoid any concerns about whether we're looking at the right declaration of 
the enclosing class (in the case where multiple definitions from different 
modules got merged), whether we need to skip over transparent contexts, and so 
on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

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


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2020-11-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:661
+  }
+}
   }

These fixes look unrelated. Is it possible to test them separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86844

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


[clang-tools-extra] 8da7efb - [clang-tidy] add concurrency module

2020-11-30 Thread Roman Lebedev via cfe-commits

Author: Vasily Kulikov
Date: 2020-11-30T12:27:17+03:00
New Revision: 8da7efbb0d5ec315a27b7b5286dbdd25694905ad

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

LOG: [clang-tidy] add concurrency module

The module will contain checks related to concurrent programming (including 
threads, fibers, coroutines, etc.).

Reviewed By: lebedev.ri

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

Added: 
clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp

Modified: 
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/index.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/CMakeLists.txt
index ca7a5afed6b0..455645050d93 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -55,6 +55,7 @@ add_subdirectory(altera)
 add_subdirectory(boost)
 add_subdirectory(bugprone)
 add_subdirectory(cert)
+add_subdirectory(concurrency)
 add_subdirectory(cppcoreguidelines)
 add_subdirectory(darwin)
 add_subdirectory(fuchsia)
@@ -81,6 +82,7 @@ set(ALL_CLANG_TIDY_CHECKS
   clangTidyBoostModule
   clangTidyBugproneModule
   clangTidyCERTModule
+  clangTidyConcurrencyModule
   clangTidyCppCoreGuidelinesModule
   clangTidyDarwinModule
   clangTidyFuchsiaModule

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h 
b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
index 3a5330c85c3b..2691d90fa521 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -45,6 +45,11 @@ extern volatile int CERTModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
+// This anchor is used to force the linker to link the ConcurrencyModule.
+extern volatile int ConcurrencyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ConcurrencyModuleAnchorDestination =
+ConcurrencyModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =

diff  --git a/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
new file mode 100644
index ..e09de74706d8
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
@@ -0,0 +1,22 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_library(clangTidyConcurrencyModule
+  ConcurrencyTidyModule.cpp
+
+  LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyConcurrencyModule
+  PRIVATE
+  clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangSerialization
+  clangTooling
+  )

diff  --git 
a/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp 
b/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
new file mode 100644
index ..be8fa7e8ef53
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
@@ -0,0 +1,33 @@
+//===--- ConcurrencyTidyModule.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+namespace clang {
+namespace tidy {
+namespace concurrency {
+
+class ConcurrencyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
+};
+
+} // namespace concurrency
+
+// Register the ConcurrencyTidyModule using this statically initialized 
variable.
+static ClangTidyModuleRegistry::Add
+X("concurrency-module", "Adds concurrency checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the ConcurrencyModule.
+volatile int ConcurrencyModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 46bb36c271d3..46461a2a6e8d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,11 @@ New modules
   `Altera SDK for OpenCL: Best Practices Guide
   


[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-30 Thread Roman Lebedev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8da7efbb0d5e: [clang-tidy] add concurrency module (authored 
by segoon, committed by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91656

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -64,6 +64,8 @@
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``concurrency-``   Checks related to concurrent programming (including
+   threads, fibers, coroutines, etc.).
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,11 @@
   `Altera SDK for OpenCL: Best Practices Guide
   `_.
 
+- New ``concurrency`` module.
+
+  Includes checks related to concurrent programming (e.g. threads, fibers,
+  coroutines, etc.).
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
@@ -0,0 +1,33 @@
+//===--- ConcurrencyTidyModule.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+namespace clang {
+namespace tidy {
+namespace concurrency {
+
+class ConcurrencyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
+};
+
+} // namespace concurrency
+
+// Register the ConcurrencyTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add
+X("concurrency-module", "Adds concurrency checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the ConcurrencyModule.
+volatile int ConcurrencyModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
@@ -0,0 +1,22 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_library(clangTidyConcurrencyModule
+  ConcurrencyTidyModule.cpp
+
+  LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyConcurrencyModule
+  PRIVATE
+  clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangSerialization
+  clangTooling
+  )
Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
===
--- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -45,6 +45,11 @@
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
+// This anchor is used to force the linker to link the ConcurrencyModule.
+extern volatile int ConcurrencyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ConcurrencyModuleAnchorDestination =
+ConcurrencyModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
Index: clang-tools-extra/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -55,6 +55,7 @@
 add_subdirectory(boost)
 add_subdirectory(bugprone)
 add_subdirectory(

[clang-tools-extra] cac5be4 - [clang-tidy] implement concurrency-mt-unsafe

2020-11-30 Thread Roman Lebedev via cfe-commits

Author: Vasily Kulikov
Date: 2020-11-30T12:27:17+03:00
New Revision: cac5be495ed88b269ad7a3000305e714cce60e63

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

LOG: [clang-tidy] implement concurrency-mt-unsafe

Checks for some thread-unsafe functions against a black list
of known-to-be-unsafe functions. Usually they access static variables
without synchronization (e.g. gmtime(3)) or utilize signals
in a racy way (e.g. sleep(3)).

The patch adds a check instead of auto-fix as thread-safe alternatives
usually have API with an additional argument
(e.g. gmtime(3) v.s. gmtime_r(3)) or have a different semantics
(e.g. exit(3) v.s. __exit(3)), so it is a rather tricky
or non-expected fix.

An option specifies which functions in libc should be considered
thread-safe, possible values are `posix`, `glibc`,
or `any` (the most strict check). It defaults to 'any' as it is
unknown what target libc type is - clang-tidy may be run
on linux but check sources compiled for other *NIX.

The check is used in Yandex Taxi backend and has caught
many unpleasant bugs. A similar patch for coroutine-unsafe API
is coming next.

Reviewed By: lebedev.ri

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

Added: 
clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.h
clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp

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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
index e09de74706d8..df329662b0df 100644
--- a/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangTidyConcurrencyModule
   ConcurrencyTidyModule.cpp
+  MtUnsafeCheck.cpp
 
   LINK_LIBS
   clangTidy

diff  --git 
a/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp 
b/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
index be8fa7e8ef53..ea4131e0ca51 100644
--- a/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "MtUnsafeCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -16,7 +17,10 @@ namespace concurrency {
 
 class ConcurrencyModule : public ClangTidyModule {
 public:
-  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"concurrency-mt-unsafe");
+  }
 };
 
 } // namespace concurrency

diff  --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp 
b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
new file mode 100644
index ..bc9f7403b6e9
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
@@ -0,0 +1,316 @@
+//===--- MtUnsafeCheck.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MtUnsafeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+// Initial list was extracted from gcc documentation
+static const clang::StringRef GlibcFunctions[] = {
+"::argp_error",
+"::argp_help",
+"::argp_parse",
+"::argp_state_help",
+"::argp_usage",
+"::asctime",
+"::clearenv",
+"::crypt",
+"::ctime",
+"::cuserid",
+"::drand48",
+"::ecvt",
+"::encrypt",
+"::endfsent",
+"::endgrent",
+"::endhostent",
+"::endnetent",
+"::endnetgrent",
+"::endprotoent",
+"::endpwent",
+"::endservent",
+"::endutent",
+"::endutxent",
+"::erand48",
+"::error_at_line",
+"::exit",
+"::fcloseall",
+"::fcvt",
+"::fgetgrent",
+"::fgetpwent",
+"::gammal",
+"::getchar_

[PATCH] D90944: [clang-tidy] implement concurrency-mt-unsafe

2020-11-30 Thread Roman Lebedev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcac5be495ed8: [clang-tidy] implement concurrency-mt-unsafe 
(authored by segoon, committed by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90944

Files:
  clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "posix"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  ::sleep(2);
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "glibc"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  dirname(nullptr);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -138,6 +138,7 @@
`clang-analyzer-valist.CopyToSelf `_,
`clang-analyzer-valist.Uninitialized `_,
`clang-analyzer-valist.Unterminated `_,
+   `concurrency-mt-unsafe `_,
`cppcoreguidelines-avoid-goto `_,
`cppcoreguidelines-avoid-non-const-global-variables `_,
`cppcoreguidelines-init-variables `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
@@ -0,0 +1,52 @@
+.. title:: clang-tidy - concurrency-mt-unsafe
+
+concurrency-mt-unsafe
+=
+
+Checks f

[PATCH] D92291: clang/test: Remove platform-linker feature

2020-11-30 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

If that's okay with @leonardchan in terms of RISCV validation, I'm fine with 
that one. Any branch removed is less path to cover!


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

https://reviews.llvm.org/D92291

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


[PATCH] D91799: [clang-format] State where clang-format-diff.py should be run from

2020-11-30 Thread David Spickett 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 rGb5fbc60e4de4: [clang-format] State where 
clang-format-diff.py should be run from (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91799

Files:
  clang/docs/ClangFormat.rst


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -248,6 +248,9 @@
 The option `-U0` will create a diff without context lines (the script would 
format
 those as well).
 
+These commands use the file paths shown in the diff output
+so they will only work from the root of the repository.
+
 Current State of Clang Format for LLVM
 ==
 


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -248,6 +248,9 @@
 The option `-U0` will create a diff without context lines (the script would format
 those as well).
 
+These commands use the file paths shown in the diff output
+so they will only work from the root of the repository.
+
 Current State of Clang Format for LLVM
 ==
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b5fbc60 - [clang-format] State where clang-format-diff.py should be run from

2020-11-30 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2020-11-30T10:00:49Z
New Revision: b5fbc60e4de45f2b56331281a706b78ff52bd286

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

LOG: [clang-format] State where clang-format-diff.py should be run from

At least with git, file paths in a diff will be relative
to the repo root. So if you are in "llvm-project/lldb"
and the diff shows "clang/foo" modified you get:
No such file or directory

>From clang-format-diff.py, since clang-format was
asked to read:
llvm-project/lldb/clang/foo

Add a note to the docs to explain this.

(there is `git diff --relative` but that excludes
changes outside of the current dir)

Reviewed By: sylvestre.ledru

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

Added: 


Modified: 
clang/docs/ClangFormat.rst

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index d396667ce10c..b746ed3453df 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -248,6 +248,9 @@ In an SVN client, you can do:
 The option `-U0` will create a 
diff  without context lines (the script would format
 those as well).
 
+These commands use the file paths shown in the 
diff  output
+so they will only work from the root of the repository.
+
 Current State of Clang Format for LLVM
 ==
 



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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-30 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 308290.
sylvestre.ledru added a comment.

Fix the error message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,15 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+   << EffectiveTriple.getOSName();
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -4045,7 +4048,7 @@
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
-  const char *ModuleName = [&]{
+  const char *ModuleName = [&] {
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
@@ -5551,7 +5554,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,15 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+	<< EffectiveTriple.getOSName();
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -4045,7 +4048,7 @@
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
-  const char *ModuleName = [&]{
+  const char *ModuleName = [&] {
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
@@ -5551,7 +5554,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;
___
cfe-commits mailing list

[clang-tools-extra] 317ca3e - [NFC][clang-tidy] Do link FrontendOpenMP into concurrency module after all

2020-11-30 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-11-30T13:34:00+03:00
New Revision: 317ca3ecf8244cabb4ca9d45e626ad3cf0f8e4b2

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

LOG: [NFC][clang-tidy] Do link FrontendOpenMP into concurrency module after all

It seems that while clangASTMatchers does add FrontendOpenMP into
it's LLVM_LINK_COMPONENTS, it's still not being propagated transitively.

Added: 


Modified: 
clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
index df329662b0df..b757d6a60b78 100644
--- a/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
   Support
   )
 



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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-11-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think fundamentally from my perspective this seem ok, out of interest can I 
ask what drove you to require it?

My assumption is that some people write comments like

  // Free comment without space\n"

and you want to be able to consistently format it to be (N spaces, as 
clang-format already does 1 space correct?)

  //  Free comment without space\n"

is that correct? is there a common style guide asking for that? what is the 
rationale




Comment at: clang/lib/Format/BreakableToken.cpp:790
+  (Style.Language != FormatStyle::LK_TextProto ||
+   OriginalPrefix[i].substr(0, 2) != "##")) {
+Prefix[i] = IndentPrefix.str();

is this case covered by a unit test at all? sorry can you explain why you are 
looking for "##"?



Comment at: clang/lib/Format/BreakableToken.cpp:797
+IndentPrefix
+.drop_back(SpacesInPrefix - Style.SpacesInLineComments.Maximum)
+.str();

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > my assumption is when Maximum is -1 this is a very large -ve number 
> > correct? is that defined behavior for drop_back()
> Since we check beforehand SpacesInPrefix is larger than Maximum there is no 
> problem.
yep sorry didn't see that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2020-11-30 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added inline comments.



Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:661
+  }
+}
   }

nikic wrote:
> These fixes look unrelated. Is it possible to test them separately?
So my understanding is that the actual line that fixes the compile time error 
is 651, that is, just having that line fixes the compile time error. I would 
assume its because before I didn't tell the dominator tree to remove the edge 
connecting the preheader and header, and not having that cascade, GVN was 
unable to iterate properly in some cases over the (now) dead blocks because it 
wasn't updated in LLVM's internal structures. The actual error was from the 
iteration in GVN::assignValNumForDeadCode() where it would try to iterate 
through a block that partially existed but didn't really.

The lines 652-660 that update MemorySSA I added because in the other more 
general case above, we seem to update MemorySSA right after updating the 
Dominator Tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86844

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


[PATCH] D92091: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-11-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!

The testing can be improved before committing!




Comment at: clang/lib/Sema/SemaDecl.cpp:8638
 // array, this recursive call only happens once.
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }

svenvh wrote:
> Anastasia wrote:
> > Btw I am surprised that we recurse to check the underlying type of an array 
> > but not the pointer. I guess this spec wording implies that pointed types 
> > should be checked too?
> > 
> > > The   size   in   bytes   of   these   types   areimplementation-defined  
> > > and  in  addition  can  also  be  different  for  the  OpenCL  device  
> > > and  the host processor making it difficult to allocate buffer objects to 
> > > be passed as arguments to a kernel declared as pointer to these types.
> > 
> > 
> > Also I can't find anything specific to the arrays...
> > 
> > Do you think we need to chase this with the spec?
> I have raised https://github.com/KhronosGroup/OpenCL-Docs/issues/504
Great! Thanks!



Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:13
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 

Btw this was missing in the original testing, could we add a line with 
`__constant ` and `__local`? Or perhaps just replace the first two `global` in 
this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92091

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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: martong, NoQ, vsavchenko, balazske, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

The `fd` parameter of

  void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t 
offset)

should be constrained to the range `[0, IntMax]` as that is of type `int`.
Constraining to the range `[0, Off_tMax]` would result in a crash as that is
of an unsigned type with the value of `0xff..f`.

The crash would happen when we try to apply the arg constraints.
At line 583: `assert(Min <= Max)`, as `0 <= -1` is not satisfied

The `mmap64` is fixed for the same reason.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92307

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-posix-crash.c


Index: clang/test/Analysis/std-c-library-posix-crash.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-posix-crash.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -verify %s
+//
+// expected-no-diagnostics
+
+typedef long off_t;
+typedef long long off64_t;
+typedef unsigned long size_t;
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t 
offset);
+void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t 
offset);
+
+void test(long len) {
+  mmap(0, len, 2, 1, 0, 0);   // no-crash
+  mmap64(0, len, 2, 1, 0, 0); // no-crash
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1722,7 +1722,6 @@
 "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}),
 Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
 
-Optional Off_tMax = getMaxValue(Off_tTy);
 // void *mmap(void *addr, size_t length, int prot, int flags, int fd,
 // off_t offset);
 addToFunctionSummaryMap(
@@ -1732,10 +1731,9 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,
 // off64_t offset);
 addToFunctionSummaryMap(
@@ -1745,7 +1743,7 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off64_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 // int pipe(int fildes[2]);
 addToFunctionSummaryMap(


Index: clang/test/Analysis/std-c-library-posix-crash.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-posix-crash.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -verify %s
+//
+// expected-no-diagnostics
+
+typedef long off_t;
+typedef long long off64_t;
+typedef unsigned long size_t;
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
+void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t offset);
+
+void test(long len) {
+  mmap(0, len, 2, 1, 0, 0);   // no-crash
+  mmap64(0, len, 2, 1, 0, 0); // no-crash
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1722,7 +1722,6 @@
 "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}),
 Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
 
-Optional Off_tMax = getMaxValue(Off_tTy);
 // void *mmap(void *addr, size_t length, int prot, int flags, int fd,
 // off_t offset);
 addToFunctionSummaryMap(
@@ -1732,10 +1731,9 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, Within

[PATCH] D83979: Port LangOpts option flags to new option parsing system

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1738
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,

BTW this should have referred to `Off64_tTy` instead of `Off_tTy`.
Not a problem anymore :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308311.
jansvoboda11 added a comment.

Rebase, move options back, port new options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -289,7 +289,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return Value;
+  return static_cast(Value);
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -305,7 +305,8 @@
   return KeyPath & Value;
 }
 
-static void FixupInvocation(CompilerInvocation &Invocation) {
+static void FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
@@ -315,9 +316,16 @@
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
+
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
+  LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
+  LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+
+  if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
+Diags.Report(diag::warn_c_kext);
 }
 
 //===--===//
@@ -2380,9 +2388,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_dllexport_inlines))
-Opts.DllExportInlines = false;
-
   if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
 StringRef Name = A->getValue();
 if (Name == "full" || Name == "branch") {
@@ -2411,7 +2416,6 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
   if (Opts.SYCL) {
 // -sycl-std applies to any SYCL source, not only those containing kernels,
@@ -2429,9 +2433,6 @@
 }
   }
 
-  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
-  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
-
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
@@ -2458,22 +2459,9 @@
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Args.hasArg(OPT_fcuda_is_device))
-Opts.CUDAIsDevice = 1;
-
-  if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
-Opts.CUDAAllowVariadicFunctions = 1;
-
-  if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
-Opts.CUDAHostDeviceConstexpr = 0;
-
-  if (Args.hasArg(OPT_fgpu_defer_diag))
-Opts.GPUDeferDiag = 1;
-
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
 Opts.CUDADeviceApproxTranscendentals = 1;
 
-  Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
   if (Args.hasArg(OPT_fgpu_allow_device_init)) {
 if (Opts.HIP)
   Opts.GPUAllowDeviceInit = 1;
@@ -2481,7 +2469,6 @@
   Diags.Report(diag::warn_ignored_hip_only_option)
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
-  Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
   if (Opts.HIP)
 Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
@@ -2501,7 +2488,6 @@
 else if (Args.hasArg(OPT_fobjc_gc))
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
-  Opts.ObjCAutoRefCount = 1;
   if (!Opts.ObjCRuntime.allowsARC())
 Diags.Report(diag::err_arc_unsupported_on_runtime);
 }
@@ -2531,9 +2517,6 @@
   Opts.ObjCWeak = Opts.ObjCWeakRuntime;
 }
 
-if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
-  Opts.ObjCInferRelatedResultType = 0;
-
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
@@ -2562,18 +2545,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (Args.hasArg(OPT_fapple_kext)) {
-if (!Opts.CPlusPlus)
-  Diags.Report(diag::warn_c_kext);
-else
-  Opts.AppleKext = 1;
-  }
-
-  if (Args.hasArg(OPT_print_ivar_layout))
-Opts.ObjCGCBitmapPrint = 1;
-
-  if (Args.hasArg(OPT_fno_constant_cfstrings))
-Opts.NoConstantCFStrings = 1;
   if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
 Opts.CFRuntime =
 l

[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

That's a good fix!
How did this happen though that max value of `off_t` was even used for `fd`.  
Seems pretty odd!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308312.
jansvoboda11 added a comment.

Fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -289,7 +289,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return Value;
+  return static_cast(Value);
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -305,7 +305,8 @@
   return KeyPath & Value;
 }
 
-static void FixupInvocation(CompilerInvocation &Invocation) {
+static void FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
@@ -315,9 +316,16 @@
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
+
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
+  LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
+  LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+
+  if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
+Diags.Report(diag::warn_c_kext);
 }
 
 //===--===//
@@ -2380,9 +2388,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_dllexport_inlines))
-Opts.DllExportInlines = false;
-
   if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
 StringRef Name = A->getValue();
 if (Name == "full" || Name == "branch") {
@@ -2411,7 +2416,6 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
   if (Opts.SYCL) {
 // -sycl-std applies to any SYCL source, not only those containing kernels,
@@ -2429,9 +2433,6 @@
 }
   }
 
-  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
-  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
-
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
@@ -2458,22 +2459,9 @@
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Args.hasArg(OPT_fcuda_is_device))
-Opts.CUDAIsDevice = 1;
-
-  if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
-Opts.CUDAAllowVariadicFunctions = 1;
-
-  if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
-Opts.CUDAHostDeviceConstexpr = 0;
-
-  if (Args.hasArg(OPT_fgpu_defer_diag))
-Opts.GPUDeferDiag = 1;
-
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
 Opts.CUDADeviceApproxTranscendentals = 1;
 
-  Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
   if (Args.hasArg(OPT_fgpu_allow_device_init)) {
 if (Opts.HIP)
   Opts.GPUAllowDeviceInit = 1;
@@ -2481,7 +2469,6 @@
   Diags.Report(diag::warn_ignored_hip_only_option)
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
-  Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
   if (Opts.HIP)
 Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
@@ -2501,7 +2488,6 @@
 else if (Args.hasArg(OPT_fobjc_gc))
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
-  Opts.ObjCAutoRefCount = 1;
   if (!Opts.ObjCRuntime.allowsARC())
 Diags.Report(diag::err_arc_unsupported_on_runtime);
 }
@@ -2531,9 +2517,6 @@
   Opts.ObjCWeak = Opts.ObjCWeakRuntime;
 }
 
-if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
-  Opts.ObjCInferRelatedResultType = 0;
-
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
@@ -2562,18 +2545,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (Args.hasArg(OPT_fapple_kext)) {
-if (!Opts.CPlusPlus)
-  Diags.Report(diag::warn_c_kext);
-else
-  Opts.AppleKext = 1;
-  }
-
-  if (Args.hasArg(OPT_print_ivar_layout))
-Opts.ObjCGCBitmapPrint = 1;
-
-  if (Args.hasArg(OPT_fno_constant_cfstrings))
-Opts.NoConstantCFStrings = 1;
   if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
 Opts.CFRuntime =
 llvm::StringSwitch(A->getValue

[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

I'm seeing a miscompile with this patch. I'm not very good at the semantic 
differences between undef and poison so I don't know really where it goes wrong.

Before Early CSE I see this in the input:

  entry:
%cmp1 = icmp uge i16 1015, 16, !dbg !9
%shr = lshr i16 -1, 1015
%cmp2 = icmp ugt i16 2, %shr
%or.cond = or i1 %cmp1, %cmp2, !dbg !10
br i1 %or.cond, label %if.then3, label %if.else4, !dbg !10

This corresponds to the following C-code:

  int16_t y1 = 1022;
  uint16_t res1 = 0;
  if (y1 < 0)
res1 = 0;
  else
res1 = 1015;
  
  if ((res1 >= 16) || (2 > (65535u >> res1)))
res2 = 42;
  else
res2 = 1;

So in the C input, the right shift is guarded and won't be carried out if res1 
is too large to avoid UB, but in the ll file the lshr is executed 
unconditionally.

Then after Early CSE I instead get

  entry:
br i1 poison, label %if.then3, label %if.else4, !dbg !9

So I suppose, with this patch the lshr will result in poison, and that poison 
will then make both %cmp2 and %or.cond be poison. And then we don't know where 
to jump so res2 gets the wrong value.

I'm not very good at poison semantics, but it seems to me that either the input 
to ewarly cse is invalid, or the patch has broken the semantics of "or"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-11-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can this be moved from bugprone to the new concurrency module added in D91656 
.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308322.
jansvoboda11 added a comment.

Revert accidental changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -289,7 +289,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return Value;
+  return static_cast(Value);
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -305,7 +305,8 @@
   return KeyPath & Value;
 }
 
-static void FixupInvocation(CompilerInvocation &Invocation) {
+static void FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
@@ -315,9 +316,16 @@
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
+
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
+  LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
+  LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+
+  if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
+Diags.Report(diag::warn_c_kext);
 }
 
 //===--===//
@@ -2380,9 +2388,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_dllexport_inlines))
-Opts.DllExportInlines = false;
-
   if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
 StringRef Name = A->getValue();
 if (Name == "full" || Name == "branch") {
@@ -2411,7 +2416,6 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
   if (Opts.SYCL) {
 // -sycl-std applies to any SYCL source, not only those containing kernels,
@@ -2429,9 +2433,6 @@
 }
   }
 
-  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
-  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
-
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
@@ -2458,22 +2459,9 @@
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Args.hasArg(OPT_fcuda_is_device))
-Opts.CUDAIsDevice = 1;
-
-  if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
-Opts.CUDAAllowVariadicFunctions = 1;
-
-  if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
-Opts.CUDAHostDeviceConstexpr = 0;
-
-  if (Args.hasArg(OPT_fgpu_defer_diag))
-Opts.GPUDeferDiag = 1;
-
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
 Opts.CUDADeviceApproxTranscendentals = 1;
 
-  Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
   if (Args.hasArg(OPT_fgpu_allow_device_init)) {
 if (Opts.HIP)
   Opts.GPUAllowDeviceInit = 1;
@@ -2481,7 +2469,6 @@
   Diags.Report(diag::warn_ignored_hip_only_option)
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
-  Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
   if (Opts.HIP)
 Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
@@ -2501,7 +2488,6 @@
 else if (Args.hasArg(OPT_fobjc_gc))
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
-  Opts.ObjCAutoRefCount = 1;
   if (!Opts.ObjCRuntime.allowsARC())
 Diags.Report(diag::err_arc_unsupported_on_runtime);
 }
@@ -2531,9 +2517,6 @@
   Opts.ObjCWeak = Opts.ObjCWeakRuntime;
 }
 
-if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
-  Opts.ObjCInferRelatedResultType = 0;
-
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
@@ -2562,18 +2545,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (Args.hasArg(OPT_fapple_kext)) {
-if (!Opts.CPlusPlus)
-  Diags.Report(diag::warn_c_kext);
-else
-  Opts.AppleKext = 1;
-  }
-
-  if (Args.hasArg(OPT_print_ivar_layout))
-Opts.ObjCGCBitmapPrint = 1;
-
-  if (Args.hasArg(OPT_fno_constant_cfstrings))
-Opts.NoConstantCFStrings = 1;
   if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
 Opts.CFRuntime =
 llvm::StringSwitch(

[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

While it would be nice for `dereferenceable` to not imply nonnull, the 
implementation currently assumes it does and will speculate loads based on 
that. See `llvm::Value::getPointerDereferenceableBytes` and its users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D92307#2422468 , @vsavchenko wrote:

> That's a good fix!
> How did this happen though that max value of `off_t` was even used for `fd`.  
> Seems pretty odd!

I used a semi-automated approach to create these summaries from cppcheck 
 : I translated the 
XML into C++ source code, but could not do the translation for ranges. E.g., 
`0:` was just simply copied and I had to manually modify the generated C++ code 
to have the proper range. And that's where I made the wrong index for the param 
(cppcheck starts from idx 1, here we start from idx 0). Here the 5th param has 
the `off_t` type, so I thought we have to get the max for `off_t`.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1738
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,

steakhal wrote:
> BTW this should have referred to `Off64_tTy` instead of `Off_tTy`.
> Not a problem anymore :D
Yep, copy pasta error again, my bad :(



Comment at: clang/test/Analysis/std-c-library-posix-crash.c:1
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \

I like this new test file. Probably we are going to extend this as we advance 
with the evaluation of these summaries on open-source projects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Looks good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[clang] 33eac0f - [VE] Specify vector alignments

2020-11-30 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-11-30T22:09:21+09:00
New Revision: 33eac0f2830ee3f362ec0207a3d0e5f0861de8f1

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

LOG: [VE] Specify vector alignments

Specify alignments for all vector types.  Update a regression test also.

Reviewed By: simoll

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

Added: 


Modified: 
clang/lib/Basic/Targets/VE.h
clang/test/CodeGen/target-data.c
llvm/lib/Target/VE/VETargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h
index b8143747a38d..2d9c74ac5247 100644
--- a/clang/lib/Basic/Targets/VE.h
+++ b/clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,9 @@ class LLVM_LIBRARY_VISIBILITY VETargetInfo : public 
TargetInfo {
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S128");
+resetDataLayout(
+"e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-"
+"v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64");
   }
 
   void getTargetDefines(const LangOptions &Opts,

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 82a0a867526b..1d7ed500340c 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -281,4 +281,4 @@
 
 // RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=VE
-// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"
+// VE: target datalayout = 
"e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64"

diff  --git a/llvm/lib/Target/VE/VETargetMachine.cpp 
b/llvm/lib/Target/VE/VETargetMachine.cpp
index 12c4f4628811..1077abc54141 100644
--- a/llvm/lib/Target/VE/VETargetMachine.cpp
+++ b/llvm/lib/Target/VE/VETargetMachine.cpp
@@ -44,6 +44,19 @@ static std::string computeDataLayout(const Triple &T) {
   // Stack alignment is 128 bits
   Ret += "-S128";
 
+  // Vector alignments are 64 bits
+  // Need to define all of them.  Otherwise, each alignment becomes
+  // the size of each data by default.
+  Ret += "-v64:64:64"; // for v2f32
+  Ret += "-v128:64:64";
+  Ret += "-v256:64:64";
+  Ret += "-v512:64:64";
+  Ret += "-v1024:64:64";
+  Ret += "-v2048:64:64";
+  Ret += "-v4096:64:64";
+  Ret += "-v8192:64:64";
+  Ret += "-v16384:64:64"; // for v256f64
+
   return Ret;
 }
 



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


[PATCH] D92256: [VE] Specify vector alignments

2020-11-30 Thread Kazushi Marukawa 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 rG33eac0f2830e: [VE] Specify vector alignments (authored by 
kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92256

Files:
  clang/lib/Basic/Targets/VE.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/VE/VETargetMachine.cpp


Index: llvm/lib/Target/VE/VETargetMachine.cpp
===
--- llvm/lib/Target/VE/VETargetMachine.cpp
+++ llvm/lib/Target/VE/VETargetMachine.cpp
@@ -44,6 +44,19 @@
   // Stack alignment is 128 bits
   Ret += "-S128";
 
+  // Vector alignments are 64 bits
+  // Need to define all of them.  Otherwise, each alignment becomes
+  // the size of each data by default.
+  Ret += "-v64:64:64"; // for v2f32
+  Ret += "-v128:64:64";
+  Ret += "-v256:64:64";
+  Ret += "-v512:64:64";
+  Ret += "-v1024:64:64";
+  Ret += "-v2048:64:64";
+  Ret += "-v4096:64:64";
+  Ret += "-v8192:64:64";
+  Ret += "-v16384:64:64"; // for v256f64
+
   return Ret;
 }
 
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -281,4 +281,4 @@
 
 // RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=VE
-// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"
+// VE: target datalayout = 
"e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64"
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,9 @@
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S128");
+resetDataLayout(
+"e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-"
+"v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64");
   }
 
   void getTargetDefines(const LangOptions &Opts,


Index: llvm/lib/Target/VE/VETargetMachine.cpp
===
--- llvm/lib/Target/VE/VETargetMachine.cpp
+++ llvm/lib/Target/VE/VETargetMachine.cpp
@@ -44,6 +44,19 @@
   // Stack alignment is 128 bits
   Ret += "-S128";
 
+  // Vector alignments are 64 bits
+  // Need to define all of them.  Otherwise, each alignment becomes
+  // the size of each data by default.
+  Ret += "-v64:64:64"; // for v2f32
+  Ret += "-v128:64:64";
+  Ret += "-v256:64:64";
+  Ret += "-v512:64:64";
+  Ret += "-v1024:64:64";
+  Ret += "-v2048:64:64";
+  Ret += "-v4096:64:64";
+  Ret += "-v8192:64:64";
+  Ret += "-v16384:64:64"; // for v256f64
+
   return Ret;
 }
 
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -281,4 +281,4 @@
 
 // RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=VE
-// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"
+// VE: target datalayout = "e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64"
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,9 @@
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S128");
+resetDataLayout(
+"e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-"
+"v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64");
   }
 
   void getTargetDefines(const LangOptions &Opts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.

In D92307#2422603 , @martong wrote:

> In D92307#2422468 , @vsavchenko 
> wrote:
>
>> That's a good fix!
>> How did this happen though that max value of `off_t` was even used for `fd`. 
>>  Seems pretty odd!
>
> I used a semi-automated approach to create these summaries from cppcheck 
>  : I translated 
> the XML into C++ source code, but could not do the translation for ranges. 
> E.g., `0:` was just simply copied and I had to manually modify the generated 
> C++ code to have the proper range. And that's where I made the wrong index 
> for the param (cppcheck starts from idx 1, here we start from idx 0). Here 
> the 5th param has the `off_t` type, so I thought we have to get the max for 
> `off_t`.

I see, thanks for clarification!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

off_t is s signed type. Please fix the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-30 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

Hi,

It seems it is related to two optimizations:
(1) `select i1 x, true, y` -> `or i1 x, y`
(2) `or i1 x, poison` -> `poison`

Semantically, the first one is broken. It needs to freeze y. But, it will 
introduce a lot of freeze instructions. The clang patches that introduce 
noundef to function arguments is still ongoing.
Another workaround is to weaken (2) to `or i1 x, poison` -> `x`. This fixes the 
miscompilation; I'll push a commit that does this.

  --- a/llvm/lib/IR/ConstantFold.cpp
  +++ b/llvm/lib/IR/ConstantFold.cpp
  @@ -1105,7 +1105,10 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned 
Opcode, Constant *C1,
 }
   
 // Binary operations propagate poison.
  -  if (isa(C1) || isa(C2))
  +  bool PoisonFold = !C1->getType()->isIntegerTy(1) || 
  +  (Opcode != Instruction::Or && Opcode != Instruction::And &&
  +   Opcode != Instruction::Xor);
  +  if (PoisonFold && (isa(C1) || isa(C2)))
   return PoisonValue::get(C1->getType());
   
 // Handle scalar UndefValue and scalable vector UndefValue. Fixed-length


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

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


[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D92270#2422625 , @aqjune wrote:

> Hi,
>
> It seems it is related to two optimizations:
> (1) `select i1 x, true, y` -> `or i1 x, y`
> (2) `or i1 x, poison` -> `poison`
>
> Semantically, the first one is broken. It needs to freeze y. But, it will 
> introduce a lot of freeze instructions. The clang patches that introduce 
> noundef to function arguments is still ongoing.
> Another workaround is to weaken (2) to `or i1 x, poison` -> `x`. This fixes 
> the miscompilation; I'll push a commit that does this.

Should langref also be updated to describe this? Or does it already?
I just found this "An instruction that depends on a poison value, produces a 
poison value itself.".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

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


[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-11-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 308335.
martong marked 2 inline comments as done.
martong added a comment.

- Check for dependent DeclContext
- Remove "dump()" calls from tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5884,6 +5884,54 @@
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldCopyALocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_NE(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2350,6 +2350,15 @@
   ParmVarDecl *OldParam, MultiLevelTemplateArgumentList &Args,
   llvm::SmallVectorImpl &MaterializedTypedefs) {
 TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo();
+
+if (auto *OldTypedefT = OldParam->getType()->getAs()) {
+  TypedefNameDecl *OldTypedefDecl = OldTypedefT->getDecl();
+  // If the typedef does not have a dependent context then skip the
+  // transform.
+  if (!OldTypedefDecl->getDeclContext()->isDependentContext())
+return OldParam;
+}
+
 TypeSourceInfo *NewDI;
 if (auto PackTL = OldDI->getTypeLoc().getAs()) {
   // Expand out the one and only element in each inner pack.


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5884,6 +5884,54 @@
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldCopyALocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, type

[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-11-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2356-2359
+  auto *CD = cast(OldParam->getDeclContext());
+  // If the typedef is not a local typedef, then skip the transform.
+  if (OldTypedefDecl->getDeclContext() != CD->getDeclContext())
+return OldParam;

rsmith wrote:
> I think it would be equivalent and simpler to check only 
> `OldTypedefDecl->getDeclContext()->isDependentContext()`. If we can resolve 
> the name of the typedef to a dependently-scoped typedef, it must be a member 
> of the current instantiation, and that's what we really care about here. This 
> would also avoid any concerns about whether we're looking at the right 
> declaration of the enclosing class (in the case where multiple definitions 
> from different modules got merged), whether we need to skip over transparent 
> contexts, and so on.
Thanks for the review! I've updated to check for the dependent context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

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


[PATCH] D92198: [clangd] Log remote index connectivity status

2020-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks! Hooking into the native status stuff seems much nicer!

Sorry if it seems like we're going in circles here, I think we should be 
careful about adding background threads so want to look at an alternative too.




Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:29
+
+namespace llvm {
+template <> struct format_provider {

this seems pedantic, but we really shouldn't specialize templates we don't own 
for types we don't own (ODR concerns)

I'd just make this function (state -> StringRef) and call it



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:35
+case GRPC_CHANNEL_IDLE:
+  Stream << "GRPC_CHANNEL_IDLE";
+  break;

any reason not to make these a bit more human-readable? 
connecting/ready/transient failure/shutdown?



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:114
 assert(!ProjectRoot.empty());
+ChannelStatusWatcher = std::thread([&Channel]() {
+  grpc_connectivity_state Status =

The thread is a bit surprising here. I was assuming we'd use some 
callback-based API to watch rather than spawn a thread to do the "work" of 
blocking on a change.
Also this is going to "wake up" periodically to refresh the watch, which seems 
undesirable if we want to go truly idle.

Ah, so there's no callback-type connection-changed API! Sorry to mislead you 
:-( I hadn't read the API carefully. (I think this is coming as some point - 
they're talking about replacing CompletionQueue with EventManager which is a 
callback-based abstraction)

Seems the "async" option is to subscribe on a CompletionQueue, but then we have 
to poll it. We can use a zero timeout so the poll doesn't block... But then we 
might as well poll GetStatus directly.

Then the question is where to do that from. What if we called GetStatus 
before/after each request, and reported whenever it has changed? That means:

- no idle background work
- we know the connection state for each request
- we know when a request triggered a connection, and whether that connection 
succeeded in time for the request
- if a connection goes idle, we don't know *when*, it gets reported on the next 
request



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:123
+DeadlineWaitingTime)) {
+  Status = Channel->GetState(/*try_to_connect=*/true);
+  log("Remote index connection status changed: {0}", Status);

This is spinning in the background keeping the channel alive (`true`)... I'm 
actually not sure that's advisable.

If the connection is being used, it'll stay alive in the same way. So true here 
affects idle (and init) behavior.

Specifically, we maintain the TCP connection for the idle period to reduce 
latency of the first couple of requests after waking up (reestablish 
connection). I'm not sure this is a good trade, idle could easily be long and I 
don't think we know better than the OS when to drop a connection. (Cost might 
be battery life, background CPU load... IDK but probably something)

I think we should ask the connection to establish on startup (*high* chance we 
need it soon) but otherwise only in response to requests



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:124
+  Status = Channel->GetState(/*try_to_connect=*/true);
+  log("Remote index connection status changed: {0}", Status);
+}

Can we include the remote address and prior status?

e.g. `"Remote index ({0}): {1} => {2}"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92198

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


[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-30 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D92270#2422661 , @uabelho wrote:

> Should langref also be updated to describe this? Or does it already?
> I just found this
>  "An instruction that depends on a poison value, produces a poison value 
> itself."
> here
>  http://llvm.org/docs/LangRef.html#poison-values

I think "Values other than phi nodes and select instructions depend on their 
operands." was supposed to say that. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

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


[PATCH] D92270: [ConstantFold] Fold more operations to poison

2020-11-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D92270#2422741 , @aqjune wrote:

> In D92270#2422661 , @uabelho wrote:
>
>> Should langref also be updated to describe this? Or does it already?
>> I just found this
>>  "An instruction that depends on a poison value, produces a poison value 
>> itself."
>> here
>>  http://llvm.org/docs/LangRef.html#poison-values
>
> I think "Values other than phi nodes and select instructions depend on their 
> operands." was supposed to say that. :)

I see. Ok, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270

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


[PATCH] D91840: OpaquePtr: Require byval on x86_intrcc parameter 0

2020-11-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 308354.
arsenm added a comment.

Fix bitcode upgrade after rebase


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

https://reviews.llvm.org/D91840

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/attr-x86-interrupt.c
  clang/test/CodeGenCXX/attr-x86-interrupt.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Assembler/x86_intrcc.ll
  llvm/test/Bitcode/Inputs/x86_intrcc_upgrade.bc
  llvm/test/Bitcode/compatibility-6.0.ll
  llvm/test/Bitcode/compatibility.ll
  llvm/test/Bitcode/x86_intr-upgrade.test
  llvm/test/CodeGen/X86/x86-32-intrcc.ll
  llvm/test/CodeGen/X86/x86-64-intrcc-nosse.ll
  llvm/test/CodeGen/X86/x86-64-intrcc.ll
  llvm/test/CodeGen/X86/x86-interrupt_cc.ll
  llvm/test/CodeGen/X86/x86-interrupt_cld.ll
  llvm/test/CodeGen/X86/x86-interrupt_vzeroupper.ll
  llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
  llvm/test/Verifier/x86_intr.ll

Index: llvm/test/Verifier/x86_intr.ll
===
--- /dev/null
+++ llvm/test/Verifier/x86_intr.ll
@@ -0,0 +1,21 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: Calling convention parameter requires byval
+; CHECK-NEXT: void (i32)* @non_ptr_arg0
+define x86_intrcc void @non_ptr_arg0(i32) {
+  ret void
+}
+
+; CHECK: Calling convention parameter requires byval
+; CHECK-NEXT: void (i32*)* @non_byval_ptr_arg0
+define x86_intrcc void @non_byval_ptr_arg0(i32*) {
+  ret void
+}
+
+; CHECK: Calling convention parameter requires byval
+; CHECK-NEXT: void (i32)* @non_ptr_arg0_decl
+declare x86_intrcc void @non_ptr_arg0_decl(i32)
+
+; CHECK: Calling convention parameter requires byval
+; CHECK-NEXT: void (i32*)* @non_byval_ptr_arg0_decl
+declare x86_intrcc void @non_byval_ptr_arg0_decl(i32*)
Index: llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
===
--- llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
+++ llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
@@ -7,7 +7,7 @@
 ;; In functions with 'no_caller_saved_registers' attribute, all registers should
 ;; be preserved except for registers used for passing/returning arguments.
 ;; The test checks that function "bar" preserves xmm0 register.
-;; It also checks that caller function "foo" does not store registers for callee 
+;; It also checks that caller function "foo" does not store registers for callee
 ;; "bar". For example, there is no store/load/access to xmm registers.
 
 
@@ -20,7 +20,7 @@
   ret i32 1
 }
 
-define x86_intrcc void @foo(i8* nocapture readnone %c) {
+define x86_intrcc void @foo(i8* byval(i8) nocapture readnone %c) {
 ; CHECK-LABEL: foo
 ; CHECK-NOT: xmm
 entry:
Index: llvm/test/CodeGen/X86/x86-interrupt_vzeroupper.ll
===
--- llvm/test/CodeGen/X86/x86-interrupt_vzeroupper.ll
+++ llvm/test/CodeGen/X86/x86-interrupt_vzeroupper.ll
@@ -10,7 +10,7 @@
 ; CHECK-NOT: vzeroupper
 ; CHECK: iret
 
-define x86_intrcc void @foo(i8* %frame) {
+define x86_intrcc void @foo(i8* byval(i8) %frame) {
   call void @bar()
   ret void
 }
Index: llvm/test/CodeGen/X86/x86-interrupt_cld.ll
===
--- llvm/test/CodeGen/X86/x86-interrupt_cld.ll
+++ llvm/test/CodeGen/X86/x86-interrupt_cld.ll
@@ -8,7 +8,7 @@
 ; CHECK: cld
 ; CHECK: call
 
-define x86_intrcc void @foo(i8* %frame) {
+define x86_intrcc void @foo(i8* byval(i8) %frame) {
   call void @bar()
   ret void
 }
Index: llvm/test/CodeGen/X86/x86-interrupt_cc.ll
===
--- llvm/test/CodeGen/X86/x86-interrupt_cc.ll
+++ llvm/test/CodeGen/X86/x86-interrupt_cc.ll
@@ -6,7 +6,7 @@
 
 ; Make sure we spill the high numbered zmm registers and K registers with the right encoding.
 
-define x86_intrcc void @foo(i8* %frame) {
+define x86_intrcc void @foo(i8* byval(i8) %frame) {
 ; CHECK64-KNL-LABEL: foo:
 ; CHECK64-KNL:   ## %bb.0:
 ; CHECK64-KNL-NEXT:pushq %rax ## encoding: [0x50]
Index: llvm/test/CodeGen/X86/x86-64-intrcc.ll
===
--- llvm/test/CodeGen/X86/x86-64-intrcc.ll
+++ llvm/test/CodeGen/X86/x86-64-intrcc.ll
@@ -8,7 +8,7 @@
 
 ; Spills rax, putting original esp at +8.
 ; No stack adjustment if declared with no error code
-define x86_intrcc void @test_isr_no_ecode(%struct.interrupt_frame* %frame) {
+define x86_intrcc void @test_isr_no_ecode(%struct.interrupt_frame* byval(%struct.interrupt_frame) %frame) {
   ; CHECK-LABEL: test_isr_no_ecode:
   ; CHECK: pushq %rax
   ; CHECK: movq 24(%rsp), %rax
@@ -28,7 +28,7 @@
 
 ; Spills rax and rcx, putting original rsp at +16. Stack is adjusted up another 8 bytes
 ; before return, popping the error code.
-define x86_int

[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-30 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

Can we add a test that the feature can be enabled on an OS other than Linux / 
Windows / Darwin?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[clang] d5aaf60 - [windows-itanium] handle dllimport/export code paths separately and share with PS4

2020-11-30 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2020-11-30T14:36:39Z
New Revision: d5aaf6021476243de73f8eb8a7479a2288582225

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

LOG: [windows-itanium] handle dllimport/export code paths separately and share 
with PS4

Similar to Windows Itanium, PS4 is also an Itanium C++ ABI variant
which shares the goal of semantic compatibility with Microsoft C++
code that uses dllimport/export.

This change introduces a new function to determine from the triple
if an environment aims for compatibility with MS C++ code w.r.t to
these attributes and guards the relevant code paths using that
function.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/dllexport-vtable-thunks.cpp
clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp
clang/test/CodeGenCXX/windows-itanium-dllexport.cpp
clang/test/Sema/dllimport.c
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 698964b94ee2..de91ca2ee82e 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1098,6 +1098,13 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
   /// either; the entire thing is pretty badly mangled.
   virtual bool hasProtectedVisibility() const { return true; }
 
+  /// Does this target aim for semantic compatibility with
+  /// Microsoft C++ code using dllimport/export attributes?
+  virtual bool shouldDLLImportComdatSymbols() const {
+return getTriple().isWindowsMSVCEnvironment() ||
+   getTriple().isWindowsItaniumEnvironment() || getTriple().isPS4CPU();
+  }
+
   /// An optional hook that targets can implement to perform semantic
   /// checking on attribute((section("foo"))) specifiers.
   ///

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ce7475b0d5da..9c282a73e0ed 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6510,9 +6510,7 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   // special MSVC extension: in the last case, the declaration is treated as if
   // it were marked dllexport.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  bool IsMicrosoft =
-  S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-  S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment();
+  bool IsMicrosoftABI  = 
S.Context.getTargetInfo().shouldDLLImportComdatSymbols();
   if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.
@@ -6526,9 +6524,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   }
 
   if (OldImportAttr && !HasNewAttr &&
-  (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
+  (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
   !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
-if (IsMicrosoft && IsDefinition) {
+if (IsMicrosoftABI && IsDefinition) {
   S.Diag(NewDecl->getLocation(),
  diag::warn_redeclaration_without_import_attribute)
   << NewDecl;
@@ -6545,7 +6543,7 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   OldDecl->dropAttr();
   NewDecl->dropAttr();
 }
-  } else if (IsInline && OldImportAttr && !IsMicrosoft) {
+  } else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
 // In MinGW, seeing a function declared inline drops the dllimport
 // attribute.
 OldDecl->dropAttr();

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index a14c16229419..d31d18eac474 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6791,16 +6791,14 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
 
 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
   if (isa(D) &&
-  (S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
+  (S.Context.getTargetInfo().shouldDLLImportComdatSymbols())) {
 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A;
 return;
   }
 
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport &&
-!(S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-  
S.Context.getTargetInfo().g

[PATCH] D90299: [windows-itanium] handle dllimport/export code paths separately and share with PS4

2020-11-30 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5aaf6021476: [windows-itanium] handle dllimport/export code 
paths separately and share with… (authored by Ben Dunbobbin 
).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90299

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CodeGenCXX/dllexport-vtable-thunks.cpp
  clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp
  clang/test/CodeGenCXX/windows-itanium-dllexport.cpp
  clang/test/Sema/dllimport.c
  clang/test/SemaCXX/dllexport.cpp
  clang/test/SemaCXX/dllimport.cpp

Index: clang/test/SemaCXX/dllimport.cpp
===
--- clang/test/SemaCXX/dllimport.cpp
+++ clang/test/SemaCXX/dllimport.cpp
@@ -5,6 +5,8 @@
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
Index: clang/test/SemaCXX/dllexport.cpp
===
--- clang/test/SemaCXX/dllexport.cpp
+++ clang/test/SemaCXX/dllexport.cpp
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++1y -Wunsupported-dll-base-class-template -DWI %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
Index: clang/test/Sema/dllimport.c
===
--- clang/test/Sema/dllimport.c
+++ clang/test/Sema/dllimport.c
@@ -5,6 +5,8 @@
 // RUN: %clang_cc1 -triple aarch64-win32  -fsyntax-only -fms-extensions -verify -std=c99 -DMS %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c99 -DWI %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c11 -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fms-extensions -verify -std=c11 -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fms-extensions -verify -std=c99 -DWI %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1;
Index: clang/test/CodeGenCXX/windows-itanium-dllexport.cpp
===
--- clang/test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ clang/test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -emit-llvm -triple i686-windows-itanium -fdeclspec %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple i686-windows-itanium -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,WI
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-scei-ps4 -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,PS4
 
 #define JOIN2(x, y) x##y
 #define JOIN(x, y) JOIN2(x, y)
@@ -25,14 +26,18 @@
 extern template class c;
 template class __declspec(dllexport) c;
 
-// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
-// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
+// WI: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
+// WI: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
+// PS4-NOT: @_ZN1cIcEaSERKS0_
+// PS4: define weak_odr void @_ZN1cIcE1fEv
 
 c g;
 template class __declspec(dllexport) c;
 
-// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_
-// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv
+// WI: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_
+// WI: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv
+// PS4-NOT: @_ZN1cIdEaSERKS0_
+// PS4: define weak_odr void @_ZN1cIdE1fEv
 
 template 
 struct outer {

[PATCH] D91874: [GNU ObjC] Fix a regression listing methods twice.

2020-11-30 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

I'd like to get this into the 11 point release, so it would be good to have a 
review...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91874

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


[PATCH] D83211: [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

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


[PATCH] D91861: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

2020-11-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4027-4031
+  if (((FLAGS)&options::CC1Option) &&  
\
+  (ALWAYS_EMIT ||  
\
+   (EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE && !(IMPLIED_CHECK { 
\
 DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
   }

jansvoboda11 wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > I'm not sure this logic is quite right. It looks to me like if an option 
> > > can very be implied, it will never be seriazed to `-cc1`, even if its 
> > > current value is not an implied one.
> > > 
> > > Or have I understood the conditions under which `IMPLIED_CHECK` returns 
> > > `true`?
> > > 
> > > IIUC, then this logic seems closer:
> > > ```
> > > if (((FLAGS)&options::CC1Option) &&   
> > >\
> > > (ALWAYS_EMIT ||   
> > >\
> > >  (EXTRACTOR(this->KEYPATH) != 
> > >\
> > >   (IMPLIED_CHECK ? (DEFAULT_VALUE)
> > >\
> > >  : (MERGER(DEFAULT_VALUE, IMPLIED_VALUE)) {   
> > >\
> > >   DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, 
> > > EXTRACTOR(this->KEYPATH));   \
> > > }
> > > ```
> > > 
> > > It would be great to see tests in particular for a bitset (or similar) 
> > > option where the merger does a union.
> > `IMPLIED_CHECK` is a logical disjunction of the implying option keypaths. 
> > It evaluates to `true` whenever at least one of the implying keypaths 
> > evaluates to `true`.
> > 
> > I think I know what you're concerned about. Let me paraphrase it and check 
> > if my understanding is correct:
> > Suppose option `a` has default value of `x`, and flag `b` can imply the 
> > value of `a` to be `y`. If we have a command line `-b -a=z`, then `-a=z` 
> > would not be generated with the current logic: `EXTRACTOR(this->KEYPATH) != 
> > DEFAULT_VALUE` evaluates to true, but `!(IMPLIED_CHECK)` to `false`.
> > 
> > Your conditions gets close, but I think the ternary branches should be the 
> > other way around.
> > 
> > Here's a table exploring all cases:
> > 
> > ```
> > IMPLIED_CHECK | EXTRACTOR(this->KEYPATH) == | SHOULD_EMIT
> > --+-+-
> > true  | IMPLIED_VALUE   | NO - emitting only the 
> > implying option is enough
> > true  | DEFAULT_VALUE   | YES - value explicitly 
> > specified (and it's DEFAULT_VALUE just by chance)
> > true  | ??? | YES - value explicitly 
> > specified
> > false | IMPLIED_VALUE   | YES - value explicitly 
> > specified (and it's IMPLIED_VALUE just by chance)
> > false | DEFAULT_VALUE   | NO - default value handles 
> > this automatically
> > false | ??? | YES - value explicitly 
> > specified
> > ```
> > 
> > I think this logic is what we're looking for:
> > 
> > ```
> >   if (((FLAGS)&options::CC1Option) &&   
> >\
> >   (ALWAYS_EMIT ||   
> >\
> >(EXTRACTOR(this->KEYPATH) != 
> >\
> > ((IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE) {  
> >\
> > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, 
> > EXTRACTOR(this->KEYPATH));   \
> >   }
> > ```
> It would be great to be able to test this logic even when no Clang options 
> exercise it properly yet. Any ideas on that front?
> Including a different `Options.inc` in `CompilerInvocation.cpp` for tests and 
> re-linking the whole library seems wasteful.
That'd be great, but I don't see a simple way. Can you find a flag that would 
exercise it properly? If so, I suggest converting just that one flag as part of 
this patch, and then you can test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91861

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2020-11-30 Thread Alex Orlov via Phabricator via cfe-commits
aorlov updated this revision to Diff 308373.
aorlov added a comment.

Improved solution. Added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/temp/temp.spec/func.spec.cpp
  clang/test/CXX/temp/temp.spec/part.spec.cpp

Index: clang/test/CXX/temp/temp.spec/part.spec.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.spec/part.spec.cpp
@@ -0,0 +1,563 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++20 [temp.class.spec] 17.6.5/10:
+//   The usual access checking rules do not apply to non-dependent names used
+//   to specify template arguments of the simple-template-id of the partial
+//   specialization.
+
+// class for tests
+class TestClass {
+public:
+  class PublicClass {};
+  template  class TemplatePublicClass {};
+
+  using AliasPublicClass = unsigned char;
+
+  void publicFunc();
+  void publicFuncOverloaded();
+  void publicFuncOverloaded(int);
+
+  static void publicStaticFunc();
+  static void publicStaticFuncOverloaded();
+  static void publicStaticFuncOverloaded(int);
+
+  static constexpr int publicStaticInt = 42;
+
+protected:
+  // expected-note@+1 8{{declared protected here}}
+  class ProtectedClass {};
+  template  class TemplateProtectedClass {};
+
+  // expected-note@+1 2{{declared protected here}}
+  using AliasProtectedClass = const char;
+
+  // expected-note@+1 3{{declared protected here}}
+  void protectedFunc();
+  void protectedFuncOverloaded();
+  void protectedFuncOverloaded(int);
+
+  // expected-note@+1 2{{declared protected here}}
+  static void protectedStaticFunc();
+  // expected-note@+1 2{{declared protected here}}
+  static void protectedStaticFuncOverloaded();
+  static void protectedStaticFuncOverloaded(int);
+
+  // expected-note@+1 2{{declared protected here}}
+  static constexpr int protectedStaticInt = 43;
+
+private:
+  // expected-note@+1 10{{declared private here}}
+  class PrivateClass {};
+  // expected-note@+1 {{declared private here}}
+  template  class TemplatePrivateClass {};
+
+  using AliasPrivateClass = char *;
+
+  void privateFunc();
+  void privateFuncOverloaded();
+  void privateFuncOverloaded(int);
+
+  static void privateStaticFunc();
+  static void privateStaticFuncOverloaded();
+  static void privateStaticFuncOverloaded(int);
+
+  static constexpr int privateStaticInt = 44;
+};
+
+void globalFunction() {}
+
+//--//
+
+// template declarations for full specializations
+template  class CT1 {};
+template  class CT2 {};
+template  class CT3 {};
+template  class CT4 {};
+template  class CT5 {};
+template  class CT6 {
+  template  class NCT1 {};
+  template  class NCT2; // forward declaration
+};
+
+// full specializations
+
+// public
+template <> class CT1;
+template  class CT1>; // not full but let it be here
+template <> class CT1>;
+template <> class CT1;
+template <> class CT2;
+template <> class CT3;
+template <> class CT4<&TestClass::publicFunc>;
+template <> class CT4<&TestClass::publicFuncOverloaded>;
+template <> class CT5<&TestClass::publicStaticFunc>;
+template <> class CT5<&TestClass::publicStaticFuncOverloaded>;
+template <> class CT5<&globalFunction>;
+template <> template <> class CT6::NCT1;
+
+template <> class CT1 {};
+template  class CT1> {};
+template <> class CT1> {};
+template <> class CT1 {};
+template <> class CT2 {};
+template <> class CT3 {};
+template <> class CT4<&TestClass::publicFunc> {};
+template <> class CT4<&TestClass::publicFuncOverloaded> {};
+template <> class CT5<&TestClass::publicStaticFunc> {};
+template <> class CT5<&TestClass::publicStaticFuncOverloaded> {};
+template <> class CT5<&globalFunction> {};
+template <> template <> class CT6::NCT1 {};
+template <> template  class CT6::NCT2 {}; // declaration
+
+// protected
+template <> class CT1;
+template  class CT1>; // not full but let it be here
+template <> class CT1>;
+template <> class CT1;
+template <> class CT2;
+template <> class CT3;
+template <> class CT4<&TestClass::protectedFunc>;
+template <> class CT4<&TestClass::protectedFuncOverloaded>;
+template <> class CT5<&TestClass::protectedStaticFunc>;
+template <> class CT5<&TestClass::protectedStaticFuncOverloaded>;
+template <> template <> class CT6::NCT1;
+
+template <> class CT1 {};
+template  class CT1> {}; // not full but let it be here
+template <> class CT1> {};
+template <> class CT1 {};
+template <> class CT2 {};
+template <> class CT3 {};
+template <> class CT4<&TestClass::protectedFunc> {};
+template <> class CT4<&TestClass::protectedFuncOverloaded> {};
+template <> class CT5<&TestClass::protectedStaticFunc> {};
+template <> class CT5<&TestClass::protectedStaticFuncOverloaded

[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D92307#2422624 , @joerg wrote:

> off_t is s signed type. Please fix the description.

Oh, thanks. Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

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


[PATCH] D92091: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-11-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:13
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 

Anastasia wrote:
> Btw this was missing in the original testing, could we add a line with 
> `__constant ` and `__local`? Or perhaps just replace the first two `global` 
> in this line.
Sure, will do!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92091

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


[PATCH] D92329: [PowerPC][Clang] Remove QPX support

2020-11-30 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
Herald added subscribers: cfe-commits, dang, shchenz, kbarton, nemanjai.
Herald added a project: clang.
jsji requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Clean up QPX code in clang missed in https://reviews.llvm.org/D83915


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92329

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64-elf-abi.c
  clang/test/CodeGen/ppc64-qpx-vector.c
  clang/test/Driver/linux-ld.c
  clang/test/Driver/ppc-features.cpp
  clang/test/OpenMP/simd_metadata.c

Index: clang/test/OpenMP/simd_metadata.c
===
--- clang/test/OpenMP/simd_metadata.c
+++ clang/test/OpenMP/simd_metadata.c
@@ -5,7 +5,6 @@
 // RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
 // RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
 // RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
-// RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
 
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
@@ -14,7 +13,6 @@
 // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
 // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
 // RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
-// RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
 
 void h1(float *c, float *a, double b[], int size)
 {
@@ -28,14 +26,12 @@
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
   // CHECK-NEXT: load
 
   // X86-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   for (int i = 0; i < size; ++i) {
 c[i] = a[i] * a[i] + b[i] * b[t];
 ++t;
@@ -50,14 +46,12 @@
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
   // CHECK-NEXT: load
 
   // X86-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   for (int i = 0; i < size; ++i) {
 c[i] = a[i] * a[i] + b[i] * b[t];
 ++t;
@@ -72,14 +66,12 @@
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "ali

[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-11-30 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D52050#2369856 , @glaubitz wrote:

> In D52050#2369838 , @dschuff wrote:
>
>> One other question then: do you know if Debian and/or Ubuntu still have the 
>> same support for running x32 programs on the regular x86-64 distribution? 
>> (presumably yes, since you aren't changing the existing behavior).
>> AFAIK clang's current support was developed against Ubuntu, but I haven't 
>> tried it in a long time and to my knowledge nobody has submitted any patches 
>> for x32 in a while either.
>
> I have seen the testsuite failures and I have to verify that. What I know is 
> that Ubuntu 14.04, against this was tested, is no longer supported.
>
> I have to admit that I don't fully understand yet why the tests fail. I will 
> verify what GCC does but I assume we have to update the other tests.

Were you able to compare against GCC and also determine debian/ubuntu's x86_64 
current support for x32 executables?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D52050

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


[PATCH] D90053: Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D90053

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


[PATCH] D92329: [PowerPC][Clang] Remove QPX support

2020-11-30 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

Another small place also needs remove? (but not related to clang)

`llvm/test/Transforms/LoopVectorize/PowerPC/vectorize-only-for-real.ll`:

  attributes #0 = { nounwind "target-cpu"="a2q" 
"target-features"="+qpx,-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx"
 }
  attributes #1 = { argmemonly nounwind }
  attributes #2 = { "target-cpu"="a2q" 
"target-features"="+qpx,-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx"
 }
  attributes #3 = { nounwind }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92329

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


[PATCH] D90485: Lex: Update Module::findHeader to return FileEntryRef, NFC

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D90485

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


[PATCH] D90497: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D90497

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


[PATCH] D91310: [AMDGPU] Add -mcode-object-version=n

2020-11-30 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D91310

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


[clang] 70eb2ce - [ASTImporter] Support import of CXXDeductionGuideDecl

2020-11-30 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-11-30T17:55:25+01:00
New Revision: 70eb2ce395be1fe39ceede6719aa667658d1e5a3

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

LOG: [ASTImporter] Support import of CXXDeductionGuideDecl

CXXDeductionGuideDecl is a FunctionDecl, but its constructor should be called
appropriately, at least to set the kind variable properly.

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 01ee8d275af1..1b014314996b 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -499,6 +499,7 @@ namespace clang {
 ExpectedDecl VisitCXXConstructorDecl(CXXConstructorDecl *D);
 ExpectedDecl VisitCXXDestructorDecl(CXXDestructorDecl *D);
 ExpectedDecl VisitCXXConversionDecl(CXXConversionDecl *D);
+ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D);
 ExpectedDecl VisitFieldDecl(FieldDecl *D);
 ExpectedDecl VisitIndirectFieldDecl(IndirectFieldDecl *D);
 ExpectedDecl VisitFriendDecl(FriendDecl *D);
@@ -3328,6 +3329,17 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   return ToPOrErr.takeError();
   }
 
+  // Common code to import an explicit specifier of 
diff erent kind of functions.
+  auto ImportExplicitExpr = [this, &Err](auto *Fun) -> ExpectedExpr {
+Expr *ExplicitExpr = nullptr;
+if (Fun->getExplicitSpecifier().getExpr()) {
+  ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
+  if (Err)
+return std::move(Err);
+}
+return ExplicitExpr;
+  };
+
   // Create the imported function.
   FunctionDecl *ToFunction = nullptr;
   if (auto *FromConstructor = dyn_cast(D)) {
@@ -3369,17 +3381,13 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
-Expr *ExplicitExpr = nullptr;
-if (FromConversion->getExplicitSpecifier().getExpr()) {
-  auto Imp = import(FromConversion->getExplicitSpecifier().getExpr());
-  if (!Imp)
-return Imp.takeError();
-  ExplicitExpr = *Imp;
-}
+ExpectedExpr ExplicitExpr = ImportExplicitExpr(FromConversion);
+if (!ExplicitExpr)
+  return ExplicitExpr.takeError();
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
 ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
-ExplicitSpecifier(ExplicitExpr,
+ExplicitSpecifier(*ExplicitExpr,
   
FromConversion->getExplicitSpecifier().getKind()),
 D->getConstexprKind(), SourceLocation(), TrailingRequiresClause))
   return ToFunction;
@@ -3390,6 +3398,18 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 Method->isInlineSpecified(), D->getConstexprKind(),
 SourceLocation(), TrailingRequiresClause))
   return ToFunction;
+  } else if (auto *Guide = dyn_cast(D)) {
+ExpectedExpr ExplicitExpr = ImportExplicitExpr(Guide);
+if (!ExplicitExpr)
+  return ExplicitExpr.takeError();
+if (GetImportedOrCreateDecl(
+ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
+ExplicitSpecifier(*ExplicitExpr,
+  Guide->getExplicitSpecifier().getKind()),
+NameInfo, T, TInfo, ToEndLoc))
+  return ToFunction;
+cast(ToFunction)
+->setIsCopyDeductionCandidate(Guide->isCopyDeductionCandidate());
   } else {
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
@@ -3517,6 +3537,11 @@ ExpectedDecl 
ASTNodeImporter::VisitCXXConversionDecl(CXXConversionDecl *D) {
   return VisitCXXMethodDecl(D);
 }
 
+ExpectedDecl
+ASTNodeImporter::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) {
+  return VisitFunctionDecl(D);
+}
+
 ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
   // Import the major distinguishing characteristics of a variable.
   DeclContext *DC, *LexicalDC;

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 81a92a10f48d..7e56b3ed501f 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5957,6 +5957,47 @@ TEST_P(ImportWithExternalSource, 
CompleteRecordBeforeImporting) {
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+TEST_P(ImportFunctions, CTADImplicit) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  struct A {
+A(T);
+  };

[PATCH] D92109: [ASTImporter] Support import of CXXDeductionGuideDecl

2020-11-30 Thread Gabor Marton 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 rG70eb2ce395be: [ASTImporter] Support import of 
CXXDeductionGuideDecl (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92109

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5957,6 +5957,47 @@
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+TEST_P(ImportFunctions, CTADImplicit) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  struct A {
+A(T);
+  };
+  A a{(int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU,
+  cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  // Check that the deduced class template is also imported.
+  EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
+  FromD->getDeducedTemplate()));
+}
+
+TEST_P(ImportFunctions, CTADUserDefinedExplicit) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  struct A {
+A(T);
+  };
+  template  explicit A(T) -> A;
+  A a{(int)0}; // calls A::A(float)
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, cxxDeductionGuideDecl(unless(isImplicit(;
+  // Not-implicit: i.e. not compiler-generated, user defined.
+  ASSERT_FALSE(FromD->isImplicit());
+  ASSERT_TRUE(FromD->isExplicit()); // Has the explicit keyword.
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+  EXPECT_FALSE(FromD->isImplicit());
+  EXPECT_TRUE(ToD->isExplicit());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -499,6 +499,7 @@
 ExpectedDecl VisitCXXConstructorDecl(CXXConstructorDecl *D);
 ExpectedDecl VisitCXXDestructorDecl(CXXDestructorDecl *D);
 ExpectedDecl VisitCXXConversionDecl(CXXConversionDecl *D);
+ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D);
 ExpectedDecl VisitFieldDecl(FieldDecl *D);
 ExpectedDecl VisitIndirectFieldDecl(IndirectFieldDecl *D);
 ExpectedDecl VisitFriendDecl(FriendDecl *D);
@@ -3328,6 +3329,17 @@
   return ToPOrErr.takeError();
   }
 
+  // Common code to import an explicit specifier of different kind of functions.
+  auto ImportExplicitExpr = [this, &Err](auto *Fun) -> ExpectedExpr {
+Expr *ExplicitExpr = nullptr;
+if (Fun->getExplicitSpecifier().getExpr()) {
+  ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
+  if (Err)
+return std::move(Err);
+}
+return ExplicitExpr;
+  };
+
   // Create the imported function.
   FunctionDecl *ToFunction = nullptr;
   if (auto *FromConstructor = dyn_cast(D)) {
@@ -3369,17 +3381,13 @@
 ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
-Expr *ExplicitExpr = nullptr;
-if (FromConversion->getExplicitSpecifier().getExpr()) {
-  auto Imp = import(FromConversion->getExplicitSpecifier().getExpr());
-  if (!Imp)
-return Imp.takeError();
-  ExplicitExpr = *Imp;
-}
+ExpectedExpr ExplicitExpr = ImportExplicitExpr(FromConversion);
+if (!ExplicitExpr)
+  return ExplicitExpr.takeError();
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
 ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
-ExplicitSpecifier(ExplicitExpr,
+ExplicitSpecifier(*ExplicitExpr,
   FromConversion->getExplicitSpecifier().getKind()),
 D->getConstexprKind(), SourceLocation(), TrailingRequiresClause))
   return ToFunction;
@@ -3390,6 +3398,18 @@
 Method->isInlineSpecified(), D->getConstexprKind(),
 SourceLocation(), TrailingRequiresClause))
   return ToFunction;
+  } else if (auto *Guide = dyn_cast(D)) {
+ExpectedExpr ExplicitExpr = ImportExplicitExpr(Guide);
+if (!ExplicitExpr)
+  return ExplicitExpr.takeError();
+if (GetImportedOrCreateDecl(
+ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
+ExplicitSpecifier(*ExplicitExpr,
+  Guide->getExplicitSpecifier().getKind()),
+NameInfo, T, TInfo, ToEndLoc))
+  

[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-11-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

Left tiny question inline, but LGTM anyways.




Comment at: clang/unittests/Basic/FileEntryTest.cpp:95
 
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;

Dead variable, do we need it?


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

https://reviews.llvm.org/D90484

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


[clang] abfbc55 - [FPEnv] clang should get from the AST the metadata for constrained FP builtins

2020-11-30 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-11-30T11:59:37-05:00
New Revision: abfbc5579bd4507ae286d4f29f8a157de0629372

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

LOG: [FPEnv] clang should get from the AST the metadata for constrained FP 
builtins

Currently clang is not correctly retrieving from the AST the metadata for
constrained FP builtins. This patch fixes that for the non-target specific
builtins.

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

Added: 
clang/test/CodeGen/strictfp_fpclassify.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtin_float_strictfp.c
clang/test/CodeGen/constrained-math-builtins.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 828d66f83de9..73897a27bd94 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -440,6 +440,7 @@ static Value 
*emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
   } else {
@@ -457,6 +458,7 @@ static Value 
*emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
   } else {
@@ -475,6 +477,7 @@ static Value 
*emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
   } else {
@@ -556,6 +559,7 @@ emitMaybeConstrainedFPToIntRoundBuiltin(CodeGenFunction 
&CGF, const CallExpr *E,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID,
{ResultType, Src0->getType()});
 return CGF.Builder.CreateConstrainedFPCall(F, {Src0});
@@ -2218,6 +,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 case Builtin::BI__builtin_fmodf16:
 case Builtin::BI__builtin_fmodl:
 case Builtin::BI__builtin_fmodf128: {
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
   Value *Arg1 = EmitScalarExpr(E->getArg(0));
   Value *Arg2 = EmitScalarExpr(E->getArg(1));
   return RValue::get(Builder.CreateFRem(Arg1, Arg2, "fmod"));
@@ -2828,6 +2833,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_isunordered: {
 // Ordered comparisons: we know the arguments to these are matching scalar
 // floating point values.
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *LHS = EmitScalarExpr(E->getArg(0));
 Value *RHS = EmitScalarExpr(E->getArg(1));
 
@@ -2856,6 +2863,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType(;
   }
   case Builtin::BI__builtin_isnan: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *V = EmitScalarExpr(E->getArg(0));
 V = Builder.CreateFCmpUNO(V, V, "cmp");
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
@@ -2919,6 +2928,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 // isinf(x)--> fabs(x) == infinity
 // isfinite(x) --> fabs(x) != infinity
 // x != NaN via the ordered compare in either case.
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *V = EmitScalarExpr(E->getArg(0));
 Value *Fabs = EmitFAbs(*this, V);
 Constant *Infinity = ConstantFP::getInfinity(V->getType());
@@ -2931,6 +2942,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 
   case Builtin::BI__builtin_isinf_sign: {
 // isinf_sign(x) -> fabs(x) == infinity ? (sign

[PATCH] D92122: [FPEnv] clang should get from the AST the metadata for constrained FP builtins

2020-11-30 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabfbc5579bd4: [FPEnv] clang should get from the AST the 
metadata for constrained FP builtins (authored by kpn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92122

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin_float_strictfp.c
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/strictfp_fpclassify.c

Index: clang/test/CodeGen/strictfp_fpclassify.c
===
--- /dev/null
+++ clang/test/CodeGen/strictfp_fpclassify.c
@@ -0,0 +1,130 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple x86_64-unknown-unknown | FileCheck %s
+
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+// FIXME: these functions shouldn't trap on SNaN.
+
+#pragma float_control(except, on)
+
+int printf(const char *, ...);
+
+// CHECK-LABEL: @p(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[STR_ADDR:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i8* [[STR:%.*]], i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* [[TMP0]], i32 [[TMP1]]) [[ATTR4:#.*]]
+// CHECK-NEXT:ret void
+//
+void p(char *str, int x) {
+  printf("%s: %d\n", str, x);
+}
+
+#define P(n,args) p(#n #args, __builtin_##n args)
+
+// CHECK-LABEL: @test_fpclassify(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISZERO]], label [[FPCLASSIFY_END:%.*]], label [[FPCLASSIFY_NOT_ZERO:%.*]]
+// CHECK:   fpclassify_end:
+// CHECK-NEXT:[[FPCLASSIFY_RESULT:%.*]] = phi i32 [ 4, [[ENTRY:%.*]] ], [ 0, [[FPCLASSIFY_NOT_ZERO]] ], [ 1, [[FPCLASSIFY_NOT_NAN:%.*]] ], [ [[TMP2:%.*]], [[FPCLASSIFY_NOT_INF:%.*]] ]
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 [[FPCLASSIFY_RESULT]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+// CHECK:   fpclassify_not_zero:
+// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[CMP]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_NAN]]
+// CHECK:   fpclassify_not_nan:
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5:#.*]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISINF]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_INF]]
+// CHECK:   fpclassify_not_inf:
+// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2]] = select i1 [[ISNORMAL]], i32 2, i32 3
+// CHECK-NEXT:br label [[FPCLASSIFY_END]]
+//
+void test_fpclassify(double d) {
+  P(fpclassify, (0, 1, 2, 3, 4, d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5]]
+// CHECK-NEXT:[[CMPINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2:%.*]] = zext i1 [[CMPINF]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 [[TMP2]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_isinf(double d) {
+  P(isinf, (d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf_sign(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D

[PATCH] D92122: [FPEnv] clang should get from the AST the metadata for constrained FP builtins

2020-11-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Thanks for the quick turnaround!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92122

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-30 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

In D91747#2412346 , @alanphipps wrote:

> Looks like _LIBCPP_HAS_NO_THREADS is being set for libcxxabi, and the build 
> now fails with this change:
>
> llvm-project/libcxxabi/../libcxx/include/__config:1172:2: error: 
> _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set

Indeed: LIBCXX_ENABLE_THREADS is off by default.

@zequanwu, what's your take on this... which part of the system needs to adapt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[clang] ee073c7 - [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2020-11-30T18:06:28+01:00
New Revision: ee073c798515e56b23463391a7b40d5ee6527337

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

LOG: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and 
mmap64

The fd parameter of
```
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
```
should be constrained to the range [0, IntMax] as that is of type int.
Constraining to the range [0, Off_tMax] would result in a crash as that is
of a signed type with the value of 0xff..f (-1).

The crash would happen when we try to apply the arg constraints.
At line 583: assert(Min <= Max), as 0 <= -1 is not satisfied

The mmap64 is fixed for the same reason.

Reviewed By: martong, vsavchenko

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

Added: 
clang/test/Analysis/std-c-library-posix-crash.c

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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 10011effe039..f8eafde3218d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1722,7 +1722,6 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}),
 Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
 
-Optional Off_tMax = getMaxValue(Off_tTy);
 // void *mmap(void *addr, size_t length, int prot, int flags, int fd,
 // off_t offset);
 addToFunctionSummaryMap(
@@ -1732,10 +1731,9 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,
 // off64_t offset);
 addToFunctionSummaryMap(
@@ -1745,7 +1743,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off64_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 // int pipe(int fildes[2]);
 addToFunctionSummaryMap(

diff  --git a/clang/test/Analysis/std-c-library-posix-crash.c 
b/clang/test/Analysis/std-c-library-posix-crash.c
new file mode 100644
index ..23321d548d6d
--- /dev/null
+++ b/clang/test/Analysis/std-c-library-posix-crash.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -verify %s
+//
+// expected-no-diagnostics
+
+typedef long off_t;
+typedef long long off64_t;
+typedef unsigned long size_t;
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t 
offset);
+void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t 
offset);
+
+void test(long len) {
+  mmap(0, len, 2, 1, 0, 0);   // no-crash
+  mmap64(0, len, 2, 1, 0, 0); // no-crash
+}



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


[PATCH] D92307: [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64

2020-11-30 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee073c798515: [analyzer][StdLibraryFunctionsChecker] Fix 
typos in summaries of mmap and mmap64 (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92307

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-posix-crash.c


Index: clang/test/Analysis/std-c-library-posix-crash.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-posix-crash.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -verify %s
+//
+// expected-no-diagnostics
+
+typedef long off_t;
+typedef long long off64_t;
+typedef unsigned long size_t;
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t 
offset);
+void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t 
offset);
+
+void test(long len) {
+  mmap(0, len, 2, 1, 0, 0);   // no-crash
+  mmap64(0, len, 2, 1, 0, 0); // no-crash
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1722,7 +1722,6 @@
 "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}),
 Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
 
-Optional Off_tMax = getMaxValue(Off_tTy);
 // void *mmap(void *addr, size_t length, int prot, int flags, int fd,
 // off_t offset);
 addToFunctionSummaryMap(
@@ -1732,10 +1731,9 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,
 // off64_t offset);
 addToFunctionSummaryMap(
@@ -1745,7 +1743,7 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off64_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 // int pipe(int fildes[2]);
 addToFunctionSummaryMap(


Index: clang/test/Analysis/std-c-library-posix-crash.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-posix-crash.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -verify %s
+//
+// expected-no-diagnostics
+
+typedef long off_t;
+typedef long long off64_t;
+typedef unsigned long size_t;
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
+void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t offset);
+
+void test(long len) {
+  mmap(0, len, 2, 1, 0, 0);   // no-crash
+  mmap64(0, len, 2, 1, 0, 0); // no-crash
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1722,7 +1722,6 @@
 "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}),
 Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
 
-Optional Off_tMax = getMaxValue(Off_tTy);
 // void *mmap(void *addr, size_t length, int prot, int flags, int fd,
 // off_t offset);
 addToFunctionSummaryMap(
@@ -1732,10 +1731,9 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off_tMax;
+ArgumentCondition(4, WithinRange, Range(0, IntMax;
 
 Optional Off64_tTy = lookupTy("off64_t");
-Optional Off64_tMax = getMaxValue(Off_tTy);
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,
 // off64_t offset);
 addToFunctionSummaryMap(
@@ -1745,7 +1743,7 @@
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, Off64_tM

[PATCH] D92330: [clang-scan-deps] Improve argument parsing to find target object file path.

2020-11-30 Thread Sylvain Audi via Phabricator via cfe-commits
saudi created this revision.
saudi added reviewers: arphaman, jkolek, Bigcheese.
saudi added a project: clang.
Herald added subscribers: cfe-commits, tschuett.
saudi requested review of this revision.

This patch adds support for the joined version of `-o` (e.g. `-ofilename`)  
command parameter when reading the clang arguments.

It also fixes a bug, as the first occurence of `-o` was used instead of the 
last one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92330

Files:
  clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
  clang/test/ClangScanDeps/target-filename.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -425,18 +425,21 @@
 if (!Args.empty()) {
   std::size_t Idx = Args.size() - 1;
   for (auto It = Args.rbegin(); It != Args.rend(); ++It) {
-if (It != Args.rbegin()) {
-  if (Args[Idx] == "-o")
+StringRef Arg = Args[Idx];
+if (LastO.empty()) {
+  if (Arg == "-o" && It != Args.rbegin())
 LastO = Args[Idx + 1];
-  if (Args[Idx] == "-MT")
-HasMT = true;
-  if (Args[Idx] == "-MQ")
-HasMQ = true;
-  if (Args[Idx] == "-MD")
-HasMD = true;
-  if (Args[Idx] == "-resource-dir")
-HasResourceDir = true;
+  else if (Arg.startswith("-o"))
+LastO = Arg.drop_front(2).str();
 }
+if (Arg == "-MT")
+  HasMT = true;
+if (Arg == "-MQ")
+  HasMQ = true;
+if (Arg == "-MD")
+  HasMD = true;
+if (Arg == "-resource-dir")
+  HasResourceDir = true;
 --Idx;
   }
 }
Index: clang/test/ClangScanDeps/target-filename.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/target-filename.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/target-filename_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/target-filename-cdb.json > %t.cdb
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+// CHECK: target-filename_input.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: a.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: b.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: last.o:
+// CHECK-NEXT: target-filename_input.cpp
Index: clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
@@ -0,0 +1,22 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/target-filename_input.cpp",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/target-filename_input.cpp -o a.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/target-filename_input.cpp -ob.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/target-filename_input.cpp -o first.o -o last.o",
+  "file": "DIR/target-filename_input.cpp"
+}
+]


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -425,18 +425,21 @@
 if (!Args.empty()) {
   std::size_t Idx = Args.size() - 1;
   for (auto It = Args.rbegin(); It != Args.rend(); ++It) {
-if (It != Args.rbegin()) {
-  if (Args[Idx] == "-o")
+StringRef Arg = Args[Idx];
+if (LastO.empty()) {
+  if (Arg == "-o" && It != Args.rbegin())
 LastO = Args[Idx + 1];
-  if (Args[Idx] == "-MT")
-HasMT = true;
-  if (Args[Idx] == "-MQ")
-HasMQ = true;
-  if (Args[Idx] == "-MD")
-HasMD = true;
-  if (Args[Idx] == "-resource-dir")
-HasResourceDir = true;
+  else if (Arg.startswith("-o"))
+LastO = Arg.drop_front(2).str();
 }
+if (Arg == "-MT")
+  HasMT = true;
+if (Arg == "-MQ")
+  HasMQ = true;
+if (Arg == "-MD")
+  HasMD = true;
+if (Arg == "-resource-dir")
+  HasResourceDir = true;
 --Idx;
   }
 }
Index: clang/test/ClangScanDeps/targ

[clang] bc7b268 - Add -fintegrated-as to second invocation of clang in test case.

2020-11-30 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2020-11-30T12:15:25-05:00
New Revision: bc7b2688d6762687ab4ec103d214ce5bb5d4210f

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

LOG: Add -fintegrated-as to second invocation of clang in test case.

Added: 


Modified: 
clang/test/Driver/report-stat.c

Removed: 




diff  --git a/clang/test/Driver/report-stat.c b/clang/test/Driver/report-stat.c
index 621b99384b27..3662d0df47cc 100644
--- a/clang/test/Driver/report-stat.c
+++ b/clang/test/Driver/report-stat.c
@@ -1,6 +1,6 @@
 // RUN: %clang -c -fproc-stat-report -fintegrated-as %s | FileCheck %s
 // CHECK: clang{{.*}}: output={{.*}}.o, total={{[0-9.]+}} ms, user={{[0-9.]+}} 
ms, mem={{[0-9]+}} Kb
 
-// RUN: %clang -c -fproc-stat-report=%t %s
+// RUN: %clang -c -fintegrated-as -fproc-stat-report=%t %s
 // RUN: cat %t | FileCheck --check-prefix=CSV %s
 // CSV: clang{{.*}},"{{.*}}.o",{{[0-9]+}},{{[0-9]+}},{{[0-9]+}}



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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-11-30 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 308402.
sylvestre.ledru added a comment.
Herald added subscribers: llvm-commits, pengfei.
Herald added a project: LLVM.

extend the test (thanks serge)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/test/CodeGen/X86/stack-clash-large.ll


Index: llvm/test/CodeGen/X86/stack-clash-large.ll
===
--- llvm/test/CodeGen/X86/stack-clash-large.ll
+++ llvm/test/CodeGen/X86/stack-clash-large.ll
@@ -1,5 +1,7 @@
 ; RUN: llc -mtriple=x86_64-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s 
 ; RUN: llc -mtriple=i686-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-32 %s 
+; RUN: llc -mtriple=x86_64-unknown-freebsd < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
 
 define i32 @foo() local_unnamed_addr #0 {
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,15 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+<< EffectiveTriple.getOSName();
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -5551,7 +5554,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;


Index: llvm/test/CodeGen/X86/stack-clash-large.ll
===
--- llvm/test/CodeGen/X86/stack-clash-large.ll
+++ llvm/test/CodeGen/X86/stack-clash-large.ll
@@ -1,5 +1,7 @@
 ; RUN: llc -mtriple=x86_64-linux-android < %s | FileCheck -check-prefix=CHECK-X86-64 %s 
 ; RUN: llc -mtriple=i686-linux-android < %s | FileCheck -check-prefix=CHECK-X86-32 %s 
+; RUN: llc -mtriple=x86_64-unknown-freebsd < %s | FileCheck -check-prefix=CHECK-X86-64 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck -check-prefix=CHECK-X86-64 %s
 
 define i32 @foo() local_unnamed_addr #0 {
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3077,12 +3077,15 @@
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+<< EffectiveTriple.getOSName();
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -5551,7 +5554,7 @@
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign
Index: clang/include/clang/Basic/DiagnosticDrive

[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D92297#2422568 , @bkramer wrote:

> While it would be nice for `dereferenceable` to not imply nonnull, the 
> implementation currently assumes it does and will speculate loads based on 
> that. See `llvm::Value::getPointerDereferenceableBytes` and its users.

LLVM-Core unfortunately conflated `null` as 0x00 and as "invalid 
pointer"/"non-dereferencable". This patch just works around that. While this is 
fine for now, a FIXME should be placed and LLVM-Core needs fixing.

I briefly scanned my history and found D4  
which is relevant and gives some context and my attempt to fix this last year.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

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


[PATCH] D92329: [PowerPC][Clang] Remove QPX support

2020-11-30 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 308405.
jsji added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix llvm test as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92329

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64-elf-abi.c
  clang/test/CodeGen/ppc64-qpx-vector.c
  clang/test/Driver/linux-ld.c
  clang/test/Driver/ppc-features.cpp
  clang/test/OpenMP/simd_metadata.c
  llvm/test/Transforms/LoopVectorize/PowerPC/vectorize-only-for-real.ll

Index: llvm/test/Transforms/LoopVectorize/PowerPC/vectorize-only-for-real.ll
===
--- llvm/test/Transforms/LoopVectorize/PowerPC/vectorize-only-for-real.ll
+++ llvm/test/Transforms/LoopVectorize/PowerPC/vectorize-only-for-real.ll
@@ -55,8 +55,8 @@
 
 declare signext i32 @bar(i32*, i32*) #2
 
-attributes #0 = { nounwind "target-cpu"="a2q" "target-features"="+qpx,-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" }
+attributes #0 = { nounwind "target-features"="-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" }
 attributes #1 = { argmemonly nounwind }
-attributes #2 = { "target-cpu"="a2q" "target-features"="+qpx,-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" }
+attributes #2 = { "target-features"="-altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" }
 attributes #3 = { nounwind }
 
Index: clang/test/OpenMP/simd_metadata.c
===
--- clang/test/OpenMP/simd_metadata.c
+++ clang/test/OpenMP/simd_metadata.c
@@ -5,7 +5,6 @@
 // RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
 // RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
 // RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
-// RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
 
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
@@ -14,7 +13,6 @@
 // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
 // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
 // RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
-// RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
 
 void h1(float *c, float *a, double b[], int size)
 {
@@ -28,14 +26,12 @@
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
   // CHECK-NEXT: load
 
   // X86-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(double* [[PTR6:%.*]], {{i64|i32}} 32) ]
   for (int i = 0; i < size; ++i) {
 c[i] = a[i] * a[i] + b[i] * b[t];
 ++t;
@@ -50,14 +46,12 @@
   // X86-AVX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 32) ]
   // X86-AVX512-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 64) ]
   // PPC-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
-  // PPC-QPX-NEXT:   call void @llvm.assume(i1 true) [ "align"(float* [[PTR5:%.*]], {{i64|i32}} 16) ]
   // CHECK-NEX

[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D92004#2420121 , @svenvh wrote:

>> I am still unclear what should we do with testing though.
>
> We probably don't want to hold up this patch until we have more thorough 
> testing in place, since we don't even have any concrete plans for such 
> testing at the moment.

Well accepting such a significant change that implements the entire 
functionality of a new standard without a single test doesn't sound a workable 
approach. We should at least add some amount of testing in existing 
lib/Headers/opencl-c.h. However, instead of fighting with ad-hoc testing, it 
might save us time if we agree on a strategy and just do the testing properly. 
After all it is relatively clear what is to be tested. The issue is mainly with 
the testing time and amount of overloads to be tested. It should not be too 
difficult to guard such testing by a cmake option to avoid long execution time 
of default testing target of clang. However, it might be time-consuming to list 
all overloads. If we could use C++ templates it would help.

> Perhaps we should just land the patch once it's ready and if any problems are 
> reported then we can always temporarily revert?

I am not sure what do you mean by revert temporarily. What if other commits lie 
on top or depend on this change. Not to say that other repositories might start 
building functionality on top e.g. SPIRV-LLVM Translator or clspv. I can 
imagine how this could become a burden for the community. From my experience 
reverting only works if done within a few days after the commit, then it 
becomes much harder if not impossible. Another aspect we should consider - how 
it can impact releasing Clang. What if someone discovers the bug in this header 
when the release is in preparation? We won't even be able to test the fix 
adequately especially within releasing time bounds. Or even worst what if  a 
release is out with that bug? Will it be expected from us that a new release 
will be created with a fix?

It becomes evident that this is no longer experimental functionality and 
therefore saving on testing will sooner or later lead to a maintenance 
nightmare. I am not saying that this patch introduced the problems but it just 
highlights that functionality here is being used and released in products and 
not in the experimental phase anymore.

> One idea for getting some confidence of not breaking OpenCL 2.0 too much, is 
> to remove the `-fdeclare-opencl-builtins` flags from the SPIR-V LLVM 
> translator  test 
> suite and then run those tests to exercise `opencl-c.h` a bit.

Ok, I think it is generally acceptable. LLVM testing is already very 
heterogeneous. Would it mean we can test clang commits with such test regularly 
or would it be done once on this patch only? I anticipate it is likely we will 
have follow up fix ups.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-11-30 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D52050#2423144 , @RKSimon wrote:

> Were you able to compare against GCC and also determine debian/ubuntu's 
> x86_64 current support for x32 executables?

Not yet. Currently freeing up space on my VM host so I can perform a fresh 
Ubuntu installation to make sure I have verified that Debian and Ubuntu don't 
deviate here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D52050

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.
Herald added a subscriber: hoy.

@tejohnson @MaskRay Do you have other comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[PATCH] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks.

2020-11-30 Thread Hongtao Yu via Phabricator via cfe-commits
hoy abandoned this revision.
hoy added a comment.

Abandoning this diff which has been broken into four other diffs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

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


[PATCH] D86502: [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

2020-11-30 Thread Hongtao Yu 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 rGc083fededfa6: [CSSPGO] A Clang switch 
-fpseudo-probe-for-profiling for pseudo-probe… (authored by hoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86502

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp

Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -952,6 +952,12 @@
ThinLTOPhase Phase) {
   ModulePassManager MPM(DebugLogging);
 
+  // Place pseudo probe instrumentation as the first pass of the pipeline to
+  // minimize the impact of optimization changes.
+  if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
+  Phase != ThinLTOPhase::PostLink)
+MPM.addPass(SampleProfileProbePass(TM));
+
   bool HasSampleProfile = PGOOpt && (PGOOpt->Action == PGOOptions::SampleUse);
 
   // In ThinLTO mode, when flattened profile is used, all the available
@@ -1320,7 +1326,7 @@
   for (auto &C : PipelineStartEPCallbacks)
 C(MPM, Level);
 
-  if (PGOOpt && PGOOpt->SamplePGOSupport)
+  if (PGOOpt && PGOOpt->DebugInfoForProfiling)
 MPM.addPass(createModuleToFunctionPassAdaptor(AddDiscriminatorsPass()));
 
   // Add the core simplification pipeline.
@@ -1351,7 +1357,7 @@
   // Force any function attributes we want the rest of the pipeline to observe.
   MPM.addPass(ForceFunctionAttrsPass());
 
-  if (PGOOpt && PGOOpt->SamplePGOSupport)
+  if (PGOOpt && PGOOpt->DebugInfoForProfiling)
 MPM.addPass(createModuleToFunctionPassAdaptor(AddDiscriminatorsPass()));
 
   // Apply module pipeline start EP callback.
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -36,11 +36,15 @@
   enum CSPGOAction { NoCSAction, CSIRInstr, CSIRUse };
   PGOOptions(std::string ProfileFile = "", std::string CSProfileGenFile = "",
  std::string ProfileRemappingFile = "", PGOAction Action = NoAction,
- CSPGOAction CSAction = NoCSAction, bool SamplePGOSupport = false)
+ CSPGOAction CSAction = NoCSAction,
+ bool DebugInfoForProfiling = false,
+ bool PseudoProbeForProfiling = false)
   : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile),
 ProfileRemappingFile(ProfileRemappingFile), Action(Action),
-CSAction(CSAction),
-SamplePGOSupport(SamplePGOSupport || Action == SampleUse) {
+CSAction(CSAction), DebugInfoForProfiling(DebugInfoForProfiling ||
+  (Action == SampleUse &&
+   !PseudoProbeForProfiling)),
+PseudoProbeForProfiling(PseudoProbeForProfiling) {
 // Note, we do allow ProfileFile.empty() for Action=IRUse LTO can
 // callback with IRUse action without ProfileFile.
 
@@ -55,16 +59,18 @@
 // a profile.
 assert(this->CSAction != CSIRUse || this->Action == IRUse);
 
-// If neither Action nor CSAction, SamplePGOSupport needs to be true.
+// If neither Action nor CSAction, DebugInfoForProfiling or
+// PseudoProbeForProfiling needs to be true.
 assert(this->Action != NoAction || this->CSAction != NoCSAction ||
-   this->SamplePGOSupport);
+   this->DebugInfoForProfiling || this->PseudoProbeForProfiling);
   }
   std::string ProfileFile;
   std::string CSProfileGenFile;
   std::string ProfileRemappingFile;
   PGOAction Action;
   CSPGOAction CSAction;
-  bool SamplePGOSupport;
+  bool DebugInfoForProfiling;
+  bool PseudoProbeForProfiling;
 };
 
 /// Tunable parameters for passes in the default pipelines.
Index: clang/test/CodeGen/pseudo-probe-emit.c
===
--- /dev/null
+++ clang/test/CodeGen/pseudo-probe-emit.c
@@ -0,0 +1,17 @@
+// RUN: %clang -O2  -fexperimental-new-pass-manager -fpseudo-probe-for-profiling -g -emit-llvm -S -o - %s | FileCheck %s
+
+// Check the generation of pseudoprobe intrinsic call
+
+void bar();
+void go();
+
+void foo(int x) {
+  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0)
+  if (x == 0)
+// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2, i32 0)
+bar();
+  else
+// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3, i32 0)
+go();
+  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0)
+}
Index: cla

[clang] c083fed - [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

2020-11-30 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2020-11-30T10:16:54-08:00
New Revision: c083fededfa63df6e1a560334bdb78797da9ee57

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

LOG: [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe 
instrumentation.

This change introduces a new clang switch `-fpseudo-probe-for-profiling` to 
enable AutoFDO with pseudo instrumentation. Please refer to 
https://reviews.llvm.org/D86193 for the whole story.

One implication from pseudo-probe instrumentation is that the profile is now 
sensitive to CFG changes. We perform the pseudo instrumentation very early in 
the pre-LTO pipeline, before any CFG transformation. This ensures that the CFG 
instrumented and annotated is stable and optimization-resilient.

The early instrumentation also allows the inliner to duplicate probes for 
inlined instances. When a probe along with the other instructions of a callee 
function are inlined into its caller function, the GUID of the callee function 
goes with the probe. This allows samples collected on inlined probes to be 
reported for the original callee function.

Reviewed By: wmi

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

Added: 
clang/test/CodeGen/pseudo-probe-emit.c

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d90e403915ed..8c4a70ba4125 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -380,6 +380,9 @@ CODEGENOPT(StrictReturn, 1, 1)
 /// Whether emit extra debug info for sample pgo profile collection.
 CODEGENOPT(DebugInfoForProfiling, 1, 0)
 
+/// Whether emit pseudo probes for sample pgo profile collection.
+CODEGENOPT(PseudoProbeForProfiling, 1, 0)
+
 /// Whether 3-component vector type is preserved.
 CODEGENOPT(PreserveVec3Type, 1, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0014ced5dca7..ac0761ec773f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -903,6 +903,12 @@ def fprofile_exclude_files_EQ : Joined<["-"], 
"fprofile-exclude-files=">,
 def fprofile_update_EQ : Joined<["-"], "fprofile-update=">,
 Group, Flags<[CC1Option, CoreOption]>, 
Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters 
(atomic,prefer-atomic,single)">;
+def fpseudo_probe_for_profiling : Flag<["-"], "fpseudo-probe-for-profiling">,
+Group, Flags<[NoXarchOption, CC1Option]>,
+HelpText<"Emit pseudo probes for sample profiler">;
+def fno_pseudo_probe_for_profiling : Flag<["-"], 
"fno-pseudo-probe-for-profiling">,
+Group, Flags<[NoXarchOption, CC1Option]>,
+HelpText<"Do not emit pseudo probes for sample profiler.">;
 def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Generate instrumented code to collect order file into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index dbc18cc40241..b62a66a51d26 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1094,10 +1094,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 CSAction, CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
+PGOOpt = PGOOptions(
+CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
+PGOOptions::SampleUse, PGOOptions::NoCSAction,
+CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
+  else if (CodeGenOpts.PseudoProbeForProfiling)
+// -fpseudo-probe-for-profiling
 PGOOpt =
-PGOOptions(CodeGenOpts.SampleProfileFile, "",
-   CodeGenOpts.ProfileRemappingFile, PGOOptions::SampleUse,
-   PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling);
+PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
+   CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-profiling
 PGOOpt = PGOOptions("", "", "", PGOOptions::NoAction,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6d6153

[PATCH] D92291: clang/test: Remove platform-linker feature

2020-11-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a subscriber: phosek.
leonardchan added a comment.

@phosek This shouldn't affect supporting riscv with our toolchain, right?


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

https://reviews.llvm.org/D92291

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


[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 308419.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Add FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/this-nonnull.cpp


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects 
NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull 
dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* 
dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid.  However, dereferenceable currently does not 
always
+  // respect NullPointerIsValid and may imply nonnul and break the program.
+  // See https://reviews.llvm.org/D4 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 


Index: clang/test/CodeGenCXX/this-nonnull.cpp
===
--- clang/test/CodeGenCXX/this-nonnull.cpp
+++ clang/test/CodeGenCXX/this-nonnull.cpp
@@ -12,8 +12,9 @@
   s.ReturnsVoid();
 
   // CHECK-YES: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12) %0)
-  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12) %0)
+  /// FIXME Use dereferenceable after dereferenceable respects NullPointerIsValid.
+  // CHECK-NO: call void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12) %0)
 }
 
 // CHECK-YES: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* nonnull dereferenceable(12))
-// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable(12))
+// CHECK-NO: declare void @_ZN6Struct11ReturnsVoidEv(%struct.Struct* dereferenceable_or_null(12))
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2168,13 +2168,21 @@
 if (!CodeGenOpts.NullPointerIsValid &&
 getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
   Attrs.addAttribute(llvm::Attribute::NonNull);
+  Attrs.addDereferenceableAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid.  However, dereferenceable currently does not always
+  // respect NullPointerIsValid and may imply nonnul and break the program.
+  // See https://reviews.llvm.org/D4 for discussions.
+  Attrs.addDereferenceableOrNullAttr(
+  getMinimumObjectSize(
+  FI.arg_begin()->type.castAs()->getPointeeType())
+  .getQuantity());
 }
 
-Attrs.addDereferenceableAttr(
-getMinimumObjectSize(
-FI.arg_begin()->type.castAs()->getPointeeType())
-.getQuantity());
-
 ArgAttrs[IRArgs.first] = llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

>> We probably don't want to hold up this patch until we have more thorough 
>> testing in place, since we don't even have any concrete plans for such 
>> testing at the moment.
>
> Well accepting such a significant change that implements the entire 
> functionality of a new standard without a single test doesn't sound a 
> workable approach. We should at least add some amount of testing in existing 
> lib/Headers/opencl-c.h. However, instead of fighting with ad-hoc testing, it 
> might save us time if we agree on a strategy and just do the testing 
> properly. After all it is relatively clear what is to be tested. The issue is 
> mainly with the testing time and amount of overloads to be tested. It should 
> not be too difficult to guard such testing by a cmake option to avoid long 
> execution time of default testing target of clang. However, it might be 
> time-consuming to list all overloads. If we could use C++ templates it would 
> help.

Perhaps my assumption that we do not want to hold up this patch until we have 
more thorough testing in place was wrong then.  I agree it would be good to 
have better header testing of the header.  I merely wanted to point out that 
testing the header thoroughly is a substantial piece of work.  So if we want to 
have such testing in place first, we need to delay this patch and start a 
thread outside of this review.

>> One idea for getting some confidence of not breaking OpenCL 2.0 too much, is 
>> to remove the `-fdeclare-opencl-builtins` flags from the SPIR-V LLVM 
>> translator  test 
>> suite and then run those tests to exercise `opencl-c.h` a bit.
>
> Ok, I think it is generally acceptable. LLVM testing is already very 
> heterogeneous. Would it mean we can test clang commits with such test 
> regularly or would it be done once on this patch only?

This idea would be a one-off test only, done locally.  The aim is to increase 
confidence in the patch, and only that.  This idea does not describe any form 
of regular testing, nor anything close to cover the entire header.  I don't see 
a trivial way of setting this up for regular testing, as the various translator 
tests should keep the `-fdeclare-opencl-builtins` flag for speed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D92297: [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null

2020-11-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2176
+} else {
+  // FIXME dereferenceable should be correct here, regardless of
+  // NullPointerIsValid.  However, dereferenceable currently does not 
always

@rsmith @jdoerfert Am I right about the FIXME issue here?

Should I link to D66618 instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92297

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-30 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 308422.
mtrofin added a comment.

Fixed the LTO case.

Also fixed the p46945 test, which, post - D90566 
, was passing without the need of a 
preliminary always-inlier pass.
The reason is that the order of the traversal of the functions in a SCC 
changed. The test requies that the 'alwaysinline'
function be processed first (to render it recursive and, thus, uninlinable).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Analysis/MLInlineAdvisor.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-module-inliner-wrapper.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
  llvm/test/Transforms/Inline/ML/bounds-checks.ll
  llvm/test/Transforms/Inline/inline_stats.ll
  llvm/test/Transforms/Inline/pr46945.ll

Index: llvm/test/Transforms/Inline/pr46945.ll
===
--- llvm/test/Transforms/Inline/pr46945.ll
+++ llvm/test/Transforms/Inline/pr46945.ll
@@ -1,12 +1,12 @@
-; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes=always-inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s -check-prefix=BASELINE
 
-; CHECK-NOT: call void @b()
-define void @a() {
-entry:
-  call void @b()
-  ret void
-}
+; In the baseline case, a will be first inlined into b, which makes c recursive,
+; and, thus, un-inlinable. We need a baseline case to make sure intra-SCC order
+; is as expected: b first, then a.
 
+; BASELINE: call void @b()
+; CHECK-NOT: call void @b()
 define void @b() alwaysinline {
 entry:
   br label %for.cond
@@ -16,3 +16,8 @@
   br label %for.cond
 }
 
+define void @a() {
+entry:
+  call void @b()
+  ret void
+}
Index: llvm/test/Transforms/Inline/inline_stats.ll
===
--- llvm/test/Transforms/Inline/inline_stats.ll
+++ llvm/test/Transforms/Inline/inline_stats.ll
@@ -6,8 +6,11 @@
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
 
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
+
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
 
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
Index: llvm/test/Transforms/Inline/ML/bounds-checks.ll
===
--- llvm/test/Transforms/Inline/ML/bounds-checks.ll
+++ llvm/test/Transforms/Inline/ML/bounds-checks.ll
@@ -4,7 +4,7 @@
 ; factor, we don't inline anymore.
 ; REQUIRES: have_tf_aot
 ; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=10.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOBOUNDS
-; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -disable-always-inliner-in-module-wrapper -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
+; RUN: opt

[PATCH] D91428: Add support for multiple program address spaces

2020-11-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos abandoned this revision.
pmatos added a comment.

In D91428#2413292 , @pmatos wrote:

> Thanks, @arichardson and @jrtc27 for your comments. 
> I am definitely surprised to find that if you explicitly mark the call with 
> the address space, this patch is not required. At first look, this RFC is not 
> required any more but I need sometime to investigate further. If no changes 
> are necessary, this is indeed good news.

Thank you for your comments - I am dropping this patch and the RFC as it is 
indeed not required by my use case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D92004#2423441 , @svenvh wrote:

>>> We probably don't want to hold up this patch until we have more thorough 
>>> testing in place, since we don't even have any concrete plans for such 
>>> testing at the moment.
>>
>> Well accepting such a significant change that implements the entire 
>> functionality of a new standard without a single test doesn't sound a 
>> workable approach. We should at least add some amount of testing in existing 
>> lib/Headers/opencl-c.h. However, instead of fighting with ad-hoc testing, it 
>> might save us time if we agree on a strategy and just do the testing 
>> properly. After all it is relatively clear what is to be tested. The issue 
>> is mainly with the testing time and amount of overloads to be tested. It 
>> should not be too difficult to guard such testing by a cmake option to avoid 
>> long execution time of default testing target of clang. However, it might be 
>> time-consuming to list all overloads. If we could use C++ templates it would 
>> help.
>
> Perhaps my assumption that we do not want to hold up this patch until we have 
> more thorough testing in place was wrong then.  I agree it would be good to 
> have better header testing of the header.  I merely wanted to point out that 
> testing the header thoroughly is a substantial piece of work.  So if we want 
> to have such testing in place first, we need to delay this patch and start a 
> thread outside of this review.

Yes, this is a substantial amount of work indeed and yes a separate discussion 
would make sense. One way to approach this could be to start by testing the 
functionality affected by this patch only. Then we wouldn't necessarily need to 
hold off until we have the full testing which would take a while. We could 
split the features being added here into separate patches with tests being 
added accordingly to each of them.  I also think it will simplify the reviewing 
process and allow the key functionality to be added earlier instead of waiting 
for everything to be ready at once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AIXException.cpp:48
+  const DataLayout &DL = MMI->getModule()->getDataLayout();
+  const unsigned PointerSize = DL.getPointerSizeInBits() == 64 ? 8 : 4;
+

nit: Why not just call `getPointerSize()` instead? (`getPointerSizeInBits()` 
does `getPointerSize()*8` under the hood anyway)


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

https://reviews.llvm.org/D91455

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

aside from some nits, lgtm
thanks for doing this!




Comment at: clang/test/Frontend/optimization-remark-line-directive.c:5
 
-// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-emit-llvm-only -verify -fno-experimental-new-pass-manager
+// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-emit-llvm-only -verify -fno-experimental-new-pass-manager -mllvm 
-mandatory-inlining-first=0
 

the change on this line shouldn't be necessary, this is a legacy PM RUN line



Comment at: llvm/include/llvm/Analysis/InlineAdvisor.h:27
 
 /// There are 3 scenarios we can use the InlineAdvisor:
 /// - Default - use manual heuristics.

aeubanks wrote:
> 4
ping



Comment at: llvm/test/Transforms/Inline/pr46945.ll:1-2
-; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes=always-inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s 
-check-prefix=BASELINE
 

maybe we should have a RUN line with `-passes='default'` to make sure the 
whole thing works


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-11-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

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


[PATCH] D92330: [clang-scan-deps] Improve argument parsing to find target object file path.

2020-11-30 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92330

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-11-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 308433.
weiwang added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/opt-record.c
  clang/test/Frontend/Inputs/remarks-hotness.prof
  clang/test/Frontend/remarks-hotness.cpp
  llvm/include/llvm/Analysis/ProfileSummaryInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Other/optimization-remarks-auto.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
  llvm/test/Transforms/SampleProfile/remarks-hotness.ll

Index: llvm/test/Transforms/SampleProfile/remarks-hotness.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -0,0 +1,96 @@
+;; This test verifies 'auto' hotness threshold when profile file is provided.
+;;
+;; new PM
+; RUN: rm -f %t.yaml %t.hot.yaml
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \
+; RUN: -pass-remarks-with-hotness --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml
+; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml
+
+;; test 'auto' threshold
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml
+; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml
+
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks=inline --pass-remarks-missed=inline --pass-remarks-analysis=inline \
+; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-RPASS
+
+; YAML-PASS:  --- !Passed
+; YAML-PASS-NEXT: Pass:inline
+; YAML-PASS-NEXT: Name:Inlined
+; YAML-PASS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 10, Column: 10 }
+; YAML-PASS-NEXT: Function:_Z7caller1v
+; YAML-PASS-NEXT: Hotness: 401
+
+; YAML-MISS:  --- !Missed
+; YAML-MISS-NEXT: Pass:inline
+; YAML-MISS-NEXT: Name:NeverInline
+; YAML-MISS-NEXT: DebugLoc:{ File: remarks-hotness.cpp, Line: 14, Column: 10 }
+; YAML-MISS-NEXT: Function:_Z7caller2v
+; YAML-MISS-NEXT: Hotness: 2
+
+; CHECK-RPASS: _Z7callee1v inlined into _Z7caller1v with (cost=-30, threshold=4500) at callsite _Z7caller1v:1 (hotness: 401)
+; CHECK-RPASS-NOT: _Z7callee2v not inlined into _Z7caller2v because it should never be inlined (cost=never): noinline function attribute (hotness: 2)
+
+; ModuleID = 'remarks-hotness.cpp'
+source_filename = "remarks-hotness.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7callee1v() #0 !dbg !7 {
+  ret i32 1, !dbg !11
+}
+
+; Function Attrs: noinline nounwind uwtable use-sample-profile
+define dso_local i32 @_Z7callee2v() #1 !dbg !12 {
+  ret i32 2, !dbg !13
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller1v() #0 !dbg !14 {
+  %1 = call i32 @_Z7callee1v(), !dbg !15
+  ret i32 %1, !dbg !16
+}
+
+; Function Attrs: use-sample-profile
+define dso_local i32 @_Z7caller2v() #0 !dbg !17 {
+  %1 = call i32 @_Z7callee2v(), !dbg !18
+  ret i32 %1, !dbg !19
+}
+
+attributes #0 = { "use-sample-profile" }
+attributes #1 = { noinline nounwind uwtable "use-sample-profile" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
+!1 = !DIFile(filename: "remarks-hotness.cpp", directory: ".")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 11.0.0"}
+!7 = distinct !DISubprogram(name: "callee1", linkageName: "_Z7callee1v", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flag

[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-11-30 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:889
+  CompactUnwindSection =
+  Ctx->getXCOFFSection(".eh_info_table", 
XCOFF::StorageMappingClass::XMC_RW,
+   XCOFF::XTY_SD, SectionKind::getData());

I think this may have been discussed elsewhere, but why do we want to emit this 
as a RW section?


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

https://reviews.llvm.org/D91455

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


[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

2020-11-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/lib/AST/ASTTypeTraits.cpp:138
+return ASTNodeKind(NKI_##A##Attr);
+#include "clang/Basic/AttrList.inc"
+  }

aaron.ballman wrote:
> Oye, this brings up an interesting point. Plugin-based attributes currently 
> cannot create their own semantic attribute, but will often instead reuse an 
> existing semantic attribute like `annotate`. This means code like 
> `[[clang::plugin_attr]] int x;` may or may not be possible to match. Further, 
> some builtin attributes have no semantic attribute associated with them 
> whatsoever: 
> https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Basic/Attr.td#L2740
> 
> I think the `switch` statement logic here is correct in these weird cases and 
> we won't hit the `llvm_unreachable`. For attributes with no AST 
> representation, there's no `Attr` object that could be passed in the first 
> place. Unknown attributes similarly won't get here because there's no way to 
> get an AST node for them. Plugin-based attributes are still going to be 
> similarly surprising, but... I don't know that we can solve that here given 
> there's no way to create a plugin-based semantic attribute yet.
> 
> Pining @ymandel to raise awareness of these sorts of issues that stencil may 
> run into. For the AST matchers, I think it's reasonable for us to say "if 
> there's no AST node, we can't match on it", but IIRC, stencil was looking to 
> stay a bit closer to the user's source code rather than be strongly tied to 
> the AST.
@aaron.ballman Thanks for pinging me. However, `Stencil` is limited to AST 
nodes, for better or worse. They make it somewhat easier to _generate_ source 
plainly, but they are fundamentaly an abstraction over the AST.  I think that 
the only way we'll get beyond the AST is Syntax Trees.

Still, nice to see this patch! I've been meaning to do the same for 
LambaCapture for a while and this will be a handy guide to what needs to be 
changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thank you, lgtm!


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

https://reviews.llvm.org/D84467

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-30 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 308441.
mtrofin marked 5 inline comments as done.
mtrofin added a comment.

fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Analysis/MLInlineAdvisor.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-module-inliner-wrapper.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
  llvm/test/Transforms/Inline/ML/bounds-checks.ll
  llvm/test/Transforms/Inline/inline_stats.ll
  llvm/test/Transforms/Inline/pr46945.ll

Index: llvm/test/Transforms/Inline/pr46945.ll
===
--- llvm/test/Transforms/Inline/pr46945.ll
+++ llvm/test/Transforms/Inline/pr46945.ll
@@ -1,12 +1,13 @@
-; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes=always-inliner-wrapper | FileCheck %s
+; RUN: opt %s -o - -S -passes='default' | FileCheck %s
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s -check-prefix=BASELINE
 
-; CHECK-NOT: call void @b()
-define void @a() {
-entry:
-  call void @b()
-  ret void
-}
+; In the baseline case, a will be first inlined into b, which makes c recursive,
+; and, thus, un-inlinable. We need a baseline case to make sure intra-SCC order
+; is as expected: b first, then a.
 
+; BASELINE: call void @b()
+; CHECK-NOT: call void @b()
 define void @b() alwaysinline {
 entry:
   br label %for.cond
@@ -16,3 +17,8 @@
   br label %for.cond
 }
 
+define void @a() {
+entry:
+  call void @b()
+  ret void
+}
Index: llvm/test/Transforms/Inline/inline_stats.ll
===
--- llvm/test/Transforms/Inline/inline_stats.ll
+++ llvm/test/Transforms/Inline/inline_stats.ll
@@ -6,8 +6,11 @@
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
 
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
+
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
 
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
Index: llvm/test/Transforms/Inline/ML/bounds-checks.ll
===
--- llvm/test/Transforms/Inline/ML/bounds-checks.ll
+++ llvm/test/Transforms/Inline/ML/bounds-checks.ll
@@ -4,7 +4,7 @@
 ; factor, we don't inline anymore.
 ; REQUIRES: have_tf_aot
 ; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=10.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOBOUNDS
-; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -disable-always-inliner-in-module-wrapper -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
+; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 tar

  1   2   3   >