[PATCH] D96155: [clang][cli] Generate and round-trip Frontend options

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thanks, a copy-paste mistake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96155

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


[clang] d1522d3 - [-Wcompletion-handler] Support checks with builtins

2021-02-09 Thread Valeriy Savchenko via cfe-commits
Author: Valeriy Savchenko
Date: 2021-02-09T11:32:24+03:00
New Revision: d1522d349f4d4b960ff7a37303103e95aa535af3

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

LOG: [-Wcompletion-handler] Support checks with builtins

It is very common to check callbacks and completion handlers for null.
This patch supports such checks using built-in functions:
  * __builtin_expect
  * __builtin_expect_with_probablity
  * __builtin_unpredictable

rdar://73455388

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

Added: 


Modified: 
clang/lib/Analysis/CalledOnceCheck.cpp
clang/test/SemaObjC/warn-called-once.m

Removed: 




diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index 883629a300dc..92d68d85fbc2 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -22,6 +22,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/BitVector.h"
@@ -330,6 +331,29 @@ class DeclRefFinder
 return Visit(OVE->getSourceExpr());
   }
 
+  const DeclRefExpr *VisitCallExpr(const CallExpr *CE) {
+if (!ShouldRetrieveFromComparisons)
+  return nullptr;
+
+// We want to see through some of the boolean builtin functions
+// that we are likely to see in conditions.
+switch (CE->getBuiltinCallee()) {
+case Builtin::BI__builtin_expect:
+case Builtin::BI__builtin_expect_with_probability: {
+  assert(CE->getNumArgs() >= 2);
+
+  const DeclRefExpr *Candidate = Visit(CE->getArg(0));
+  return Candidate != nullptr ? Candidate : Visit(CE->getArg(1));
+}
+
+case Builtin::BI__builtin_unpredictable:
+  return Visit(CE->getArg(0));
+
+default:
+  return nullptr;
+}
+  }
+
   const DeclRefExpr *VisitExpr(const Expr *E) {
 // It is a fallback method that gets called whenever the actual type
 // of the given expression is not covered.

diff  --git a/clang/test/SemaObjC/warn-called-once.m 
b/clang/test/SemaObjC/warn-called-once.m
index 094f92a49935..0c11d0e0a15b 100644
--- a/clang/test/SemaObjC/warn-called-once.m
+++ b/clang/test/SemaObjC/warn-called-once.m
@@ -4,6 +4,11 @@
 #define nil (id)0
 #define CALLED_ONCE __attribute__((called_once))
 #define NORETURN __attribute__((noreturn))
+#define LIKELY(X) __builtin_expect(!!(X), 1)
+#define UNLIKELY(X) __builtin_expect(!!(X), 0)
+#define LIKELY_WITH_PROBA(X, P) __builtin_expect_with_probability(!!(X), 1, P)
+#define UNLIKELY_WITH_PROBA(X, P) __builtin_expect_with_probability(!!(X), 0, 
P)
+#define UNPRED(X) __builtin_unpredictable((long)(X))
 
 @protocol NSObject
 @end
@@ -547,6 +552,70 @@ int call_with_check_7(int (^callback)(void) CALLED_ONCE) {
   // no-warning
 }
 
+void call_with_builtin_check_1(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY(callback))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_2(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY(callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_3(int (^callback)(void) CALLED_ONCE) {
+  if (__builtin_expect((long)callback, 0L)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_4(int (^callback)(void) CALLED_ONCE) {
+  if (__builtin_expect(0L, (long)callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_5(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY_WITH_PROBA(callback, 0.9))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_6(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY_WITH_PROBA(callback, 0.9)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_7(int (^callback)(void) CALLED_ONCE) {
+  if (UNPRED(callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_8(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY(callback != nil))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_9(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY(callback == NULL))
+callback();
+  // no-warning
+}
+
 void unreachable_true_branch(void (^callback)(void) CALLED_ONCE) {
   if (0) {
 



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


[PATCH] D96268: [-Wcompletion-handler] Support checks with builtins

2021-02-09 Thread Valeriy Savchenko 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 rGd1522d349f4d: [-Wcompletion-handler] Support checks with 
builtins (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96268

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -4,6 +4,11 @@
 #define nil (id)0
 #define CALLED_ONCE __attribute__((called_once))
 #define NORETURN __attribute__((noreturn))
+#define LIKELY(X) __builtin_expect(!!(X), 1)
+#define UNLIKELY(X) __builtin_expect(!!(X), 0)
+#define LIKELY_WITH_PROBA(X, P) __builtin_expect_with_probability(!!(X), 1, P)
+#define UNLIKELY_WITH_PROBA(X, P) __builtin_expect_with_probability(!!(X), 0, P)
+#define UNPRED(X) __builtin_unpredictable((long)(X))
 
 @protocol NSObject
 @end
@@ -547,6 +552,70 @@
   // no-warning
 }
 
+void call_with_builtin_check_1(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY(callback))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_2(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY(callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_3(int (^callback)(void) CALLED_ONCE) {
+  if (__builtin_expect((long)callback, 0L)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_4(int (^callback)(void) CALLED_ONCE) {
+  if (__builtin_expect(0L, (long)callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_5(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY_WITH_PROBA(callback, 0.9))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_6(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY_WITH_PROBA(callback, 0.9)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_7(int (^callback)(void) CALLED_ONCE) {
+  if (UNPRED(callback)) {
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void call_with_builtin_check_8(int (^callback)(void) CALLED_ONCE) {
+  if (LIKELY(callback != nil))
+callback();
+  // no-warning
+}
+
+void call_with_builtin_check_9(int (^callback)(void) CALLED_ONCE) {
+  if (!UNLIKELY(callback == NULL))
+callback();
+  // no-warning
+}
+
 void unreachable_true_branch(void (^callback)(void) CALLED_ONCE) {
   if (0) {
 
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -22,6 +22,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/BitVector.h"
@@ -330,6 +331,29 @@
 return Visit(OVE->getSourceExpr());
   }
 
+  const DeclRefExpr *VisitCallExpr(const CallExpr *CE) {
+if (!ShouldRetrieveFromComparisons)
+  return nullptr;
+
+// We want to see through some of the boolean builtin functions
+// that we are likely to see in conditions.
+switch (CE->getBuiltinCallee()) {
+case Builtin::BI__builtin_expect:
+case Builtin::BI__builtin_expect_with_probability: {
+  assert(CE->getNumArgs() >= 2);
+
+  const DeclRefExpr *Candidate = Visit(CE->getArg(0));
+  return Candidate != nullptr ? Candidate : Visit(CE->getArg(1));
+}
+
+case Builtin::BI__builtin_unpredictable:
+  return Visit(CE->getArg(0));
+
+default:
+  return nullptr;
+}
+  }
+
   const DeclRefExpr *VisitExpr(const Expr *E) {
 // It is a fallback method that gets called whenever the actual type
 // of the given expression is not covered.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94661: [clang-format] [PR19056] Add support for access modifiers indentation

2021-02-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

It's getting into a good shape. Please fix the nits.




Comment at: clang/unittests/Format/FormatTest.cpp:19059
+  // Members are *two* levels below the record;
+  // Style.IndentWidth == 2, thus yielding a 4 spaces wide indentation
+  verifyFormat("class C {\n"

Nit: please put full stops at the end of comments. Here and elsewhere.



Comment at: clang/unittests/Format/FormatTest.cpp:19097
+  // Test with a different indentation width;
+  // also proves that the result is Style.AccessModifierOffset agonistic
+  Style.IndentWidth = 3;

Typo: agnostic.


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

https://reviews.llvm.org/D94661

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


[PATCH] D95877: [analyzer] Fix static_cast on pointer-to-member handling

2021-02-09 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@vsavchenko, anything else to add?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95877

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


[PATCH] D95877: [analyzer] Fix static_cast on pointer-to-member handling

2021-02-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Great job!  Thanks for dealing with all my nit-picking!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95877

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


[PATCH] D96280: [WIP][clang][cli] Round-trip the whole CompilerInvocation

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 322310.
jansvoboda11 added a comment.

Replace commented-out code with reason behind not generating arguments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96280

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,11 @@
 
 static const StringRef GetInputKindName(InputKind IK);
 
-static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags, const InputArgList &Args,
+static bool FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags, const ArgList &Args,
 InputKind IK) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   LangOptions &LangOpts = *Invocation.getLangOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -502,6 +504,8 @@
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
 << "-fno-legacy-pass-manager";
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 //===--===//
@@ -569,39 +573,39 @@
 Opt.getKind(), 0, Value);
 }
 
-// Parse subset of command line arguments into a member of CompilerInvocation.
-using ParseFn = llvm::function_ref;
+// Parse command line arguments into CompilerInvocation.
+using ParseFn =
+llvm::function_ref,
+DiagnosticsEngine &, const char *)>;
 
-// Generate part of command line arguments from a member of CompilerInvocation.
+// Generate command line arguments from CompilerInvocation.
 using GenerateFn = llvm::function_ref &,
 CompilerInvocation::StringAllocator)>;
 
-// Swap between dummy/real instance of a CompilerInvocation member.
-using SwapOptsFn = llvm::function_ref;
-
 // Performs round-trip of command line arguments if OriginalArgs contain
 // "-round-trip-args". Effectively runs the Parse function for a part of
 // CompilerInvocation on command line arguments that were already once parsed
 // and generated. This is used to check the Generate function produces arguments
 // that are semantically equivalent to those that were used to create
 // CompilerInvocation.
-static bool RoundTrip(ParseFn Parse, GenerateFn Generate, SwapOptsFn SwapOpts,
-  CompilerInvocation &Res, ArgList &OriginalArgs,
-  DiagnosticsEngine &Diags, StringRef OptsName) {
+static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
+  CompilerInvocation &RealInvocation,
+  CompilerInvocation &DummyInvocation,
+  ArrayRef CommandLineArgs,
+  DiagnosticsEngine &Diags, const char *Argv0) {
   bool DoRoundTrip = false;
 #ifdef CLANG_ROUND_TRIP_CC1_ARGS
   DoRoundTrip = true;
 #endif
 
-  // If round-trip was not requested, simply run the parser with the original
-  // options and diagnostics.
+  // If round-trip was not requested, simply run the parser with the real
+  // invocation diagnostics.
   if (!DoRoundTrip)
-return Parse(Res, OriginalArgs, Diags);
+return Parse(RealInvocation, CommandLineArgs, Diags, Argv0);
 
   // Serializes quoted (and potentially escaped) arguments.
-  auto SerializeArgs = [](ArgStringList &Args) {
+  auto SerializeArgs = [](ArrayRef Args) {
 std::string Buffer;
 llvm::raw_string_ostream OS(Buffer);
 for (const char *Arg : Args) {
@@ -612,34 +616,28 @@
 return Buffer;
   };
 
-  OriginalArgs.clearQueriedOpts();
-
   // Setup a dummy DiagnosticsEngine.
   DiagnosticsEngine DummyDiags(new DiagnosticIDs(), new DiagnosticOptions());
   DummyDiags.setClient(new TextDiagnosticBuffer());
 
-  // Run the first parse on the original arguments with dummy options and
+  // Run the first parse on the original arguments with the dummy invocation and
   // diagnostics.
-  SwapOpts(Res);
-  if (!Parse(Res, OriginalArgs, DummyDiags) ||
+  if (!Parse(DummyInvocation, CommandLineArgs, DummyDiags, Argv0) ||
   DummyDiags.getNumWarnings() != 0) {
 // If the first parse did not succeed, it must be user mistake (invalid
 // command line arguments). We won't be able to generate arguments that
-// would reproduce the same result. Let's fail again with the original
-// options and diagnostics, so all side-effects of parsing are visible.
+// would reproduce the same result. Let's fail again with the real
+// invocation and diagnostics, so all sid

[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-02-09 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:356
+  I->eraseFromParent();
+}
+  }

I see you need force match bitcast then replace, add assert for no bitcast case



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:471
+  for (auto *Inst : TileLoads) {
+C |= lowerTileLoad(Inst);
+  }

'|' is bits or, use logic ||


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D96280: [clang][cli] Round-trip the whole CompilerInvocation

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Updated the patch, removed `[WIP]` from the title and replied to comments.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1940-1941
 case EDK_ProfileList:
-  GenerateArg(Args, OPT_fprofile_list_EQ, Dep.first, SA);
+  // Generated from LanguageOptions.
+  // GenerateArg(Args, OPT_fprofile_list_EQ, Dep.first, SA);
   break;

dexonsmith wrote:
> Was it intentional to comment this out? If so, probably better to delete the 
> line of code.
Yes, it was intentional. I've now replaced the commented-out code with a 
comment explaining why profile list arguments are not generated here.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3438-3439
 
-  if (Opts.NoInlineDefine && Opts.Optimize)
-GenerateArg(Args, OPT_fno_inline, SA);
+  // if (Opts.NoInlineDefine && Opts.Optimize)
+  //   GenerateArg(Args, OPT_fno_inline, SA);
 

dexonsmith wrote:
> Was it intentional to comment out this code? If so, probably better to delete 
> it.
Same as above.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4534-4547
+  InputKind DashX = FrontendOpts.DashX;
+  if (DashX.getFormat() == InputKind::Precompiled ||
+  DashX.getLanguage() == Language::LLVM_IR) {
+if (LangOpts->ObjCAutoRefCount)
+  GenerateArg(Args, OPT_fobjc_arc, SA);
+if (LangOpts->PICLevel != 0)
+  GenerateArg(Args, OPT_pic_level, Twine(LangOpts->PICLevel), SA);

dexonsmith wrote:
> This change, like the commented out code I already pointed at, seems not 
> strictly-related to changing round-tripping to happen at a higher level. Is 
> there some reason it's tied to landing at the same time? (If that somehow 
> avoids a bunch of refactoring that'll have to be undone after, fine by me, 
> but otherwise it'd be nice to make this particular patch as clean as possible 
> I think and land the more functional changes ahead of time.)
> 
> I also wonder if this special-case logic could/should be buried inside 
> `GenerateLangArgs`, possibly by passing in `DashX` as an argument. (Maybe 
> with a FIXME to handle via ShouldParseIf? E.g., maybe almost all lang options 
> could be moved to a `let` scope that turns on ShouldParseIf with this logic, 
> and these four are left outside of it. Up to you, whether you think that's a 
> good idea.)
This change is necessary for the patch.

Until now, `GenerateLangArgs` was called (during round-trip) from 
`ParseLangArgs`, which is behind the same condition in `CreateFromArgs`: `if 
(!(DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == 
Language::LLVM_IR))`. This change attempts to preserve the previous behavior 
and also to avoid calling `GenerateLangArgs` with unexpected/invalid `DashX`.

I agree eventually moving the logic into `{Parse,Generate}LangArgs` would be 
nice, but I'd like to do that in a follow up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96280

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D69560#2549959 , @steveire wrote:

> Why "easily" instead of "suspicious", "spuriously" or any of the other words 
> that are already used?

The name was @aaron.ballman's idea after we postponed the 
`experimental-cppcoreguidelines-yaddayaddayadda...`.
The best I could come up with is `potentially`. The `suspicious` is a problem 
because this check is an interface check, not a call-site check. (The sister 
check is currently called `suspiciously-swapped-argument` or something like 
that.)

The original check idea from C++ Core Guidelines 

 also uses the phrase:

> Reason: Adjacent arguments of the same type are easily swapped by mistake.

However, `potentially-swappable-parameters` just sounds... wonky. It does not 
carry the weight the rule otherwise meant to.
`weakly-typed-parameters`?

I am not good with names, sadly.



I am conflicted about saying that "easily" **always** refers to some "positive 
aspect", however. Use a [[unnamed trademarked safety device]] because you can 
end up easily cutting off your finger during work. Do not touch a stove/hot 
water fountain, because you can easily get burnt. Leaving Christmas candles 
unattended could easily lead to a house fire. Does anyone want to get hurt, 
burnt, their house destroyed, etc.? There is nothing "positive" in these 
suggestions or regulations either. And we are doing a tool that is practically 
the same thing, trying to prevent a (different kind of) fire.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[clang] 40c261c - [clang][cli] Generate and round-trip language options

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T10:18:55+01:00
New Revision: 40c261c41c4ceb0dff802d6a83f7ae65af936af8

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

LOG: [clang][cli] Generate and round-trip language options

This patch implements generation of remaining language options and tests it by 
performing parse-generate-parse round trip (on by default for assert builds, 
off otherwise).

This patch also correctly reports failures in `parseSanitizerKinds`, which is 
necessary for emitting diagnostics when an invalid sanitizer is passed to 
`-fsanitize=` during round-trip.

This patch also removes TableGen marshalling classes from two options:
* `fsanitize_blacklist` When parsing: it's first initialized via the generated 
code, but then also changed by manually written code, which is confusing.
* `fopenmp` When parsing: it's first initialized via generated code, but then 
conditionally changed by manually written code. This is also confusing. 
Moreover, we need to do some extra checks when generating it, which would be 
really cumbersome in TableGen. (Specifically, not emitting it when 
`-fopenmp-simd` was present.)

Reviewed By: dexonsmith

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

Added: 
clang/unittests/Basic/SanitizersTest.cpp

Modified: 
clang/include/clang/Basic/Sanitizers.h
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Basic/Sanitizers.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Basic/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Basic/Sanitizers.h 
b/clang/include/clang/Basic/Sanitizers.h
index c6b0446cea4f..675fa15fdec8 100644
--- a/clang/include/clang/Basic/Sanitizers.h
+++ b/clang/include/clang/Basic/Sanitizers.h
@@ -178,6 +178,10 @@ struct SanitizerSet {
 /// Returns a non-zero SanitizerMask, or \c 0 if \p Value is not known.
 SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups);
 
+/// Serialize a SanitizerSet into values for -fsanitize= or -fno-sanitize=.
+void serializeSanitizerSet(SanitizerSet Set,
+   SmallVectorImpl &Values);
+
 /// For each sanitizer group bit set in \p Kinds, set the bits for sanitizers
 /// this group enables.
 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3f7519fb05f5..baea96df5829 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1423,8 +1423,7 @@ def fno_sanitize_EQ : CommaJoined<["-"], 
"fno-sanitize=">, Group,
   Flags<[CoreOption, NoXarchOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
   Group,
-  HelpText<"Path to blacklist file for sanitizers">,
-  
MarshallingInfoStringVector>;
+  HelpText<"Path to blacklist file for sanitizers">;
 def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
   HelpText<"Path to system blacklist file for sanitizers">,
   Flags<[CC1Option]>;
@@ -2159,8 +2158,7 @@ def fno_objc_nonfragile_abi : Flag<["-"], 
"fno-objc-nonfragile-abi">, Group, Group;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
-  HelpText<"Parse OpenMP pragmas and generate parallel code.">,
-  MarshallingInfoFlag, "0u">, 
Normalizer<"makeFlagToValueNormalizer(50u)">;
+  HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index e880713b71aa..0b53c867cd98 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -249,11 +249,22 @@ class CompilerInvocation : public CompilerInvocationBase {
DiagnosticsEngine &Diags);
 
   /// Parse command line options that map to LangOptions.
-  static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
-InputKind IK, const llvm::Triple &T,
+  static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args,
+InputKind IK, const llvm::Triple &T,
+std::vector &Includes,
+DiagnosticsEngine &Diags);
+
+  static bool ParseLangArgs(Compile

[PATCH] D95793: [clang][cli] Generate and round-trip language options

2021-02-09 Thread Jan Svoboda 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 rG40c261c41c4c: [clang][cli] Generate and round-trip language 
options (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D95793?vs=322106&id=322311#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95793

Files:
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SanitizersTest.cpp

Index: clang/unittests/Basic/SanitizersTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SanitizersTest.cpp
@@ -0,0 +1,49 @@
+//===- unittests/Basic/SanitizersTest.cpp - Test Sanitizers ---===//
+//
+// 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 "clang/Basic/Sanitizers.h"
+
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+using testing::Contains;
+using testing::Not;
+
+TEST(SanitizersTest, serializeSanitizers) {
+  SanitizerSet Set;
+  Set.set(parseSanitizerValue("memory", false), true);
+  Set.set(parseSanitizerValue("nullability-arg", false), true);
+
+  SmallVector Serialized;
+  serializeSanitizerSet(Set, Serialized);
+
+  ASSERT_EQ(Serialized.size(), 2u);
+  ASSERT_THAT(Serialized, Contains("memory"));
+  ASSERT_THAT(Serialized, Contains("nullability-arg"));
+}
+
+TEST(SanitizersTest, serializeSanitizersIndividual) {
+  SanitizerSet Set;
+  Set.set(parseSanitizerValue("memory", false), true);
+  Set.set(parseSanitizerValue("nullability-arg", false), true);
+  Set.set(parseSanitizerValue("nullability-assign", false), true);
+  Set.set(parseSanitizerValue("nullability-return", false), true);
+
+  SmallVector Serialized;
+  serializeSanitizerSet(Set, Serialized);
+
+  ASSERT_EQ(Serialized.size(), 4u);
+  ASSERT_THAT(Serialized, Contains("memory"));
+  ASSERT_THAT(Serialized, Contains("nullability-arg"));
+  ASSERT_THAT(Serialized, Contains("nullability-assign"));
+  ASSERT_THAT(Serialized, Contains("nullability-return"));
+  // Individual sanitizers don't get squashed into a single group.
+  ASSERT_THAT(Serialized, Not(Contains("nullability")));
+}
Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -8,6 +8,7 @@
   FileEntryTest.cpp
   FileManagerTest.cpp
   LineOffsetMappingTest.cpp
+  SanitizersTest.cpp
   SourceManagerTest.cpp
   )
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -214,6 +214,7 @@
 Args.push_back(SA(Value));
 break;
   case Option::JoinedClass:
+  case Option::CommaJoinedClass:
 Args.push_back(SA(Twine(Spelling) + Value));
 break;
   default:
@@ -1212,6 +1213,12 @@
   }
 }
 
+static SmallVector serializeSanitizerKinds(SanitizerSet S) {
+  SmallVector Values;
+  serializeSanitizerSet(S, Values);
+  return Values;
+}
+
 static void parseXRayInstrumentationBundle(StringRef FlagName, StringRef Bundle,
ArgList &Args, DiagnosticsEngine &D,
XRayInstrSet &S) {
@@ -2633,19 +2640,231 @@
   llvm_unreachable("unknown input language");
 }
 
-static void GenerateLangArgs(const LangOptions &Opts,
- SmallVectorImpl &Args,
- CompilerInvocation::StringAllocator SA) {
+void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
+  SmallVectorImpl &Args,
+  StringAllocator SA,
+  const llvm::Triple &T) {
+  OptSpecifier StdOpt;
+  switch (Opts.LangStd) {
+  case LangStandard::lang_opencl10:
+  case LangStandard::lang_opencl11:
+  case LangStandard::lang_opencl12:
+  case LangStandard::lang_opencl20:
+  case LangStandard::lang_opencl30:
+  case LangStandard::lang_openclcpp:
+StdOpt = OPT_cl_std_EQ;
+break;
+  default:
+StdOpt = OPT_std_EQ;
+break;
+  }
+
+  auto LangStandard = LangStandard::getLangStandardForKind(Opts.LangStd);
+  GenerateArg(Args, StdOpt, LangStandard.getName(), SA);
+
   if (Opts.IncludeDefaultHeader)
 GenerateArg(Args, OPT_finclude_default_header, SA);
   if 

[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-02-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:433
+bool X86LowerAMXIntrinsics::visit() {
+  bool C;
+  SmallVector TileDPBSSDs;

`bool C = false`



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:439
+
+  for (BasicBlock *BB : post_order(&Func)) {
+for (BasicBlock::reverse_iterator II = BB->rbegin(), IE = BB->rend();

We can use a forward order to iterate it.
Besides, we cannot assume there always be bitcast after e.g. 
x86_tileloadd64_internal. So we need to insert one bitcast as required.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:470
+
+  for (auto *Inst : TileLoads) {
+C |= lowerTileLoad(Inst);

Remove the `{}` for single line loop.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:506
+X86LowerAMXIntrinsics LAT(F, &DT, &LI);
+bool C = LAT.visit();
+return C;

You can just return it by `return LAT.visit()`.



Comment at: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll:60
+entry:
+  %amx = call x86_amx @llvm.x86.tileloadd64.internal(i16 %row, i16 %col, i8* 
%ptr, i64 %stride)
+  %vec = bitcast x86_amx %amx to <256 x i32>

Maybe we can use zero mask load in future optimization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-02-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll:174-175
+; CHECK-NEXT:[[TMP13:%.*]] = bitcast i32 [[TMP12]] to <2 x i16>
+; CHECK-NEXT:[[TMP14:%.*]] = zext <2 x i16> [[TMP11]] to <2 x i32>
+; CHECK-NEXT:[[TMP15:%.*]] = shl <2 x i32> [[TMP14]], 
+; CHECK-NEXT:[[TMP16:%.*]] = bitcast <2 x i32> [[TMP15]] to <2 x float>

Can we use a shuffle instruction?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

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


[PATCH] D96323: [clang][cli] NFC: Remove intermediate command line parsing functions

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Patch D96280  moved command line 
round-tripping from each parsing functions into single `CreateFromArgs` 
function.

This patch cleans up the individual parsing functions, essentially merging 
`ParseXxxImpl` with `ParseXxx`, as the distinction is not necessary anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96323

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -845,8 +845,8 @@
   // Nothing to generate for FullCompilerInvocation.
 }
 
-static bool ParseAnalyzerArgsImpl(AnalyzerOptions &Opts, ArgList &Args,
-  DiagnosticsEngine &Diags) {
+static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags) {
   AnalyzerOptions *AnalyzerOpts = &Opts;
   bool Success = true;
 
@@ -1013,11 +1013,6 @@
   return Success;
 }
 
-static bool ParseAnalyzerArgs(CompilerInvocation &Res, AnalyzerOptions &Opts,
-  ArgList &Args, DiagnosticsEngine &Diags) {
-  return ParseAnalyzerArgsImpl(*Res.getAnalyzerOpts(), Args, Diags);
-}
-
 static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config,
  StringRef OptionName, StringRef DefaultVal) {
   return Config.insert({OptionName, std::string(DefaultVal)}).first->second;
@@ -1478,12 +1473,12 @@
 GenerateArg(Args, OPT_Qn, SA);
 }
 
-bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,
-  ArgList &Args, InputKind IK,
-  DiagnosticsEngine &Diags,
-  const llvm::Triple &T,
-  const std::string &OutputFile,
-  const LangOptions &LangOptsRef) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
+  InputKind IK,
+  DiagnosticsEngine &Diags,
+  const llvm::Triple &T,
+  const std::string &OutputFile,
+  const LangOptions &LangOptsRef) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
 
   bool Success = true;
@@ -1891,14 +1886,6 @@
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
-bool CompilerInvocation::ParseCodeGenArgs(
-CompilerInvocation &Res, CodeGenOptions &Opts, ArgList &Args, InputKind IK,
-DiagnosticsEngine &Diags, const llvm::Triple &T,
-const std::string &OutputFile, const LangOptions &LangOptsRef) {
-  return ParseCodeGenArgsImpl(Res.getCodeGenOpts(), Args, IK, Diags, T,
-  OutputFile, LangOptsRef);
-}
-
 static void
 GenerateDependencyOutputArgs(const DependencyOutputOptions &Opts,
  SmallVectorImpl &Args,
@@ -1938,10 +1925,10 @@
   }
 }
 
-static bool ParseDependencyOutputArgsImpl(
-DependencyOutputOptions &Opts, ArgList &Args,
-DiagnosticsEngine &Diags,
-frontend::ActionKind Action, bool ShowLineMarkers) {
+static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
+  ArgList &Args, DiagnosticsEngine &Diags,
+  frontend::ActionKind Action,
+  bool ShowLineMarkers) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
   bool Success = true;
 
@@ -2006,15 +1993,6 @@
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
-static bool ParseDependencyOutputArgs(CompilerInvocation &Res,
-  DependencyOutputOptions &Opts,
-  ArgList &Args, DiagnosticsEngine &Diags,
-  frontend::ActionKind Action,
-  bool ShowLineMarkers) {
-  return ParseDependencyOutputArgsImpl(Res.getDependencyOutputOpts(), Args,
-   Diags, Action, ShowLineMarkers);
-}
-
 static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
   // Color diagnostics default to auto ("on" if terminal supports) in the driver
   // but default to off in cc1, needing an explicit OPT_fdiagnostics_color.
@@ -2267,15 +2245,6 @@
   return Success;
 }
 
-bool CompilerInvocation::ParseDiagnosticArgsRoundTrip(CompilerInvocation &Res,
-  

[PATCH] D96324: [clangd] Rename references to function arguments within the same file

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This is a fix of the problem (rather than a patch - D96247 
) discussed in
https://github.com/clangd/clangd/issues/685.

Fixes: https://github.com/clangd/clangd/issues/685


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96324

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -678,6 +678,34 @@
 }
   )cpp",
 
+  // Function argument.
+  R"cpp(
+void foo(int [[Bar^]]);
+void foo(int [[Bar^]]);
+
+void foo(int [[Bar^]]) {
+}
+  )cpp",
+
+  // Template function argument.
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+
+template <>
+void foo(int [[Bar^]]) {}
+  )cpp",
+
   // Namespace alias.
   R"cpp(
 namespace a { namespace b { void foo(); } }
@@ -1089,6 +1117,15 @@
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(
+void func(int V^ar);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -151,6 +151,20 @@
   if (const auto *VD = dyn_cast(D)) {
 if (const VarDecl *OriginalVD = VD->getInstantiatedFromStaticDataMember())
   VD = OriginalVD;
+// Arguments are canonicalized to their function's canonical function
+// arguments.
+if (const auto *Argument = dyn_cast(VD)) {
+  if (const auto *Function =
+  dyn_cast(Argument->getDeclContext())) {
+// FIXME(kirillbobyrev): This excludes constructors: their canonical
+// decls are canonicalized RecordDecls.
+if (const auto *Canonical =
+dyn_cast(canonicalRenameDecl(Function))) {
+  return Canonical->getParamDecl(Argument->getFunctionScopeIndex())
+  ->getCanonicalDecl();
+}
+  }
+}
 return VD->getCanonicalDecl();
   }
   return dyn_cast(D->getCanonicalDecl());


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -678,6 +678,34 @@
 }
   )cpp",
 
+  // Function argument.
+  R"cpp(
+void foo(int [[Bar^]]);
+void foo(int [[Bar^]]);
+
+void foo(int [[Bar^]]) {
+}
+  )cpp",
+
+  // Template function argument.
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+
+template <>
+void foo(int [[Bar^]]) {}
+  )cpp",
+
   // Namespace alias.
   R"cpp(
 namespace a { namespace b { void foo(); } }
@@ -1089,6 +1117,15 @@
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(
+void func(int V^ar);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -151,6 +151,20 @@
   if (const auto *VD = dyn_cast(D)) {
 if (const VarDecl *OriginalVD = VD->getInstantiatedFromStaticDataMember())
   VD = OriginalVD;
+// Arguments are canonicalized to their function's canonical function
+// arguments.
+if (const auto *Argument = dyn_cast(VD)) {
+  if (const auto *Function =
+  dyn_cast(Argument->getDeclContext())) {
+// FIXME(kirillbobyrev): This excludes constructors: their canonical
+// decls are canonicalized RecordDecls.
+if (const auto *Canon

[PATCH] D96285: [clang][Arm] Fix handling of -Wa,-implicit-it=

2021-02-09 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2307
 
+static bool AddImplicitITArgs(const ArgList &Args, ArgStringList &CmdArgs,
+  StringRef Value) {

I would rename this AddARMImplicitITArgs to match AddARMTargetArgs.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2386
+if (Value.startswith("-mimplicit-it="))
+  if (AddImplicitITArgs(Args, CmdArgs, Value.split("=").second))
+continue;

You could merge the two ifs with &&



Comment at: clang/test/Driver/arm-target-as-mimplicit-it.s:13
+/// Test space seperated -Wa,- arguments.
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mthumb 
-Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mthumb 
-Wa,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER

For these multiple option tests, we're checking that the last -mimplicit-it 
wins, so I think the first argument should be another different value. E.g.
-Wa,-mimplicit-it=thumb -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s 
--check-prefix=ALWAYS

Then if we got our logic wrong, we'll see "=thumb" in the result and fail.
(afaik -mthumb doesn't set implicit-it to anything)



Comment at: clang/test/Driver/arm-target-as-mimplicit-it.s:26
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 
2>&1 | FileCheck %s --check-prefix=XINVALID
+
+

Does it make sense to check which wins of -mimplicit-it and -Wa,-mimplicit-it 
for assembler and c inputs?

I guess right now we would have the first for C files, and both for assembler 
files but the last -mllvm implicit-it wins, and it'd be the assembler's option. 
Either way some tests to confirm that would be good.

You can use any old C file, my change that you reviewed does the same thing to 
check this. (but in that case, since it was earlier it could tell whether we 
had both kinds of option which I don't think can be done here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96285

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


[PATCH] D96270: [release][docs] Update contributions to LLVM 12 for scalable vectors.

2021-02-09 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 322316.

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

https://reviews.llvm.org/D96270

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -144,6 +144,18 @@
 
 - ...
 
+Modified Pragmas in Clang
+-
+
+- The "#pragma clang loop vectorize_width" has been extended to support an
+  optional 'fixed|scalable' argument, which can be used to indicate that the
+  compiler should use fixed-width or scalable vectorization.  Fixed-width is
+  assumed by default.
+
+  Scalable or vector length agnostic vectorization is an experimental feature
+  for targets that support scalable vectors. For more information please refer
+  to the Clang Language Extensions documentation.
+
 Attribute Changes in Clang
 --
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -144,6 +144,18 @@
 
 - ...
 
+Modified Pragmas in Clang
+-
+
+- The "#pragma clang loop vectorize_width" has been extended to support an
+  optional 'fixed|scalable' argument, which can be used to indicate that the
+  compiler should use fixed-width or scalable vectorization.  Fixed-width is
+  assumed by default.
+
+  Scalable or vector length agnostic vectorization is an experimental feature
+  for targets that support scalable vectors. For more information please refer
+  to the Clang Language Extensions documentation.
+
 Attribute Changes in Clang
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ec12f5f - [clang][codegen] Remember string used to create llvm::Regex for optimization remarks

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T11:12:13+01:00
New Revision: ec12f5febed04dd32e7d4b766b2853d50fca9657

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

LOG: [clang][codegen] Remember string used to create llvm::Regex for 
optimization remarks

Regular expression patterns passed through the command line are being used to 
create an instances of `llvm::Regex` and thrown away.

There is no API to serialize `Regex` back to the original pattern. This means 
we have no way to reconstruct the original pattern from command line. This is 
necessary for serializing `CompilerInvocation`.

This patch stores the original pattern string in `CodeGenOptions` alongside the 
`llvm::Regex` instance.

Reviewed By: dexonsmith, thegameg

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 73d41e3293c6..38979520b90d 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -278,19 +278,29 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
   std::string SymbolPartition;
 
+  /// Regular expression and the string it was created from.
+  struct RemarkPattern {
+std::string Pattern;
+std::shared_ptr Regex;
+
+explicit operator bool() const { return Regex != nullptr; }
+
+llvm::Regex *operator->() const { return Regex.get(); }
+  };
+
   /// Regular expression to select optimizations for which we should enable
   /// optimization remarks. Transformation passes whose name matches this
   /// expression (and support this feature), will emit a diagnostic
   /// whenever they perform a transformation. This is enabled by the
   /// -Rpass=regexp flag.
-  std::shared_ptr OptimizationRemarkPattern;
+  RemarkPattern OptimizationRemarkPattern;
 
   /// Regular expression to select optimizations for which we should enable
   /// missed optimization remarks. Transformation passes whose name matches 
this
   /// expression (and support this feature), will emit a diagnostic
   /// whenever they tried but failed to perform a transformation. This is
   /// enabled by the -Rpass-missed=regexp flag.
-  std::shared_ptr OptimizationRemarkMissedPattern;
+  RemarkPattern OptimizationRemarkMissedPattern;
 
   /// Regular expression to select optimizations for which we should enable
   /// optimization analyses. Transformation passes whose name matches this
@@ -298,7 +308,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// whenever they want to explain why they decided to apply or not apply
   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
   /// flag.
-  std::shared_ptr OptimizationRemarkAnalysisPattern;
+  RemarkPattern OptimizationRemarkAnalysisPattern;
 
   /// Set of files defining the rules for the symbol rewriting.
   std::vector RewriteMapFiles;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 09444b2dda79..658dad54532e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1164,8 +1164,8 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
 }
 
 /// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns a pointer to the newly generated Regex instance.
-static std::shared_ptr
+/// It returns the string and a pointer to the newly generated Regex instance.
+static CodeGenOptions::RemarkPattern
 GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
 Arg *RpassArg) {
   StringRef Val = RpassArg->getValue();
@@ -1176,7 +1176,7 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, 
ArgList &Args,
 << RegexError << RpassArg->getAsString(Args);
 Pattern.reset();
   }
-  return Pattern;
+  return {std::string(Val), Pattern};
 }
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,



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


[PATCH] D96036: [clang][codegen] Remember string used to create llvm::Regex for optimization remarks

2021-02-09 Thread Jan Svoboda 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 rGec12f5febed0: [clang][codegen] Remember string used to 
create llvm::Regex for optimization… (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96036

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1164,8 +1164,8 @@
 }
 
 /// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns a pointer to the newly generated Regex instance.
-static std::shared_ptr
+/// It returns the string and a pointer to the newly generated Regex instance.
+static CodeGenOptions::RemarkPattern
 GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
 Arg *RpassArg) {
   StringRef Val = RpassArg->getValue();
@@ -1176,7 +1176,7 @@
 << RegexError << RpassArg->getAsString(Args);
 Pattern.reset();
   }
-  return Pattern;
+  return {std::string(Val), Pattern};
 }
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -278,19 +278,29 @@
   /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
   std::string SymbolPartition;
 
+  /// Regular expression and the string it was created from.
+  struct RemarkPattern {
+std::string Pattern;
+std::shared_ptr Regex;
+
+explicit operator bool() const { return Regex != nullptr; }
+
+llvm::Regex *operator->() const { return Regex.get(); }
+  };
+
   /// Regular expression to select optimizations for which we should enable
   /// optimization remarks. Transformation passes whose name matches this
   /// expression (and support this feature), will emit a diagnostic
   /// whenever they perform a transformation. This is enabled by the
   /// -Rpass=regexp flag.
-  std::shared_ptr OptimizationRemarkPattern;
+  RemarkPattern OptimizationRemarkPattern;
 
   /// Regular expression to select optimizations for which we should enable
   /// missed optimization remarks. Transformation passes whose name matches 
this
   /// expression (and support this feature), will emit a diagnostic
   /// whenever they tried but failed to perform a transformation. This is
   /// enabled by the -Rpass-missed=regexp flag.
-  std::shared_ptr OptimizationRemarkMissedPattern;
+  RemarkPattern OptimizationRemarkMissedPattern;
 
   /// Regular expression to select optimizations for which we should enable
   /// optimization analyses. Transformation passes whose name matches this
@@ -298,7 +308,7 @@
   /// whenever they want to explain why they decided to apply or not apply
   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
   /// flag.
-  std::shared_ptr OptimizationRemarkAnalysisPattern;
+  RemarkPattern OptimizationRemarkAnalysisPattern;
 
   /// Set of files defining the rules for the symbol rewriting.
   std::vector RewriteMapFiles;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1164,8 +1164,8 @@
 }
 
 /// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns a pointer to the newly generated Regex instance.
-static std::shared_ptr
+/// It returns the string and a pointer to the newly generated Regex instance.
+static CodeGenOptions::RemarkPattern
 GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
 Arg *RpassArg) {
   StringRef Val = RpassArg->getValue();
@@ -1176,7 +1176,7 @@
 << RegexError << RpassArg->getAsString(Args);
 Pattern.reset();
   }
-  return Pattern;
+  return {std::string(Val), Pattern};
 }
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -278,19 +278,29 @@
   /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
   std::string SymbolPartition;
 
+  /// Regular expression and the string it was created from.
+  struct RemarkPattern {
+std::string Pattern;
+std::shared_ptr Regex;
+
+explicit operator bool() const { return Regex != nullptr; }
+
+llvm::Regex *operator->() const { return Regex.get(); }
+  };
+
   /// Regular expression to se

[PATCH] D96324: [clangd] Rename references to function arguments within the same file

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 322321.
kbobyrev added a comment.

Implement constructors handling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96324

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -678,6 +678,61 @@
 }
   )cpp",
 
+  // Function argument.
+  R"cpp(
+// Main.cpp
+void foo(int [[Bar^]]);
+
+void foo(int [[Bar^]]) {}
+
+// Forward declarations somewhere else.
+void foo(int [[Bar^]]);
+void foo(int /*Bar*/);
+  )cpp",
+
+  // Template function argument.
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+
+template <>
+void foo(int [[Bar^]]) {}
+  )cpp",
+
+  // Constructor argument.
+  R"cpp(
+class Foo {
+  Foo(int [[Bar^]]);
+};
+Foo::Foo(int [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+class Foo {
+  template 
+  Foo(T Something, U [[Bar^]]);
+
+  Foo();
+};
+
+template 
+Foo::Foo(T Something, U [[Bar^]]) {}
+
+template <>
+Foo::Foo(int Something, int [[Bar^]]) {}
+template <>
+Foo::Foo(bool Something, bool [[Bar^]]) {}
+  )cpp",
+
   // Namespace alias.
   R"cpp(
 namespace a { namespace b { void foo(); } }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -100,7 +100,8 @@
 //
 // Here, both partial (2) and full (3) specializations are canonicalized to (1)
 // which ensures all three of them are renamed.
-const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D,
+ bool CanonicalizeCtorsToType = false) {
   if (const auto *VarTemplate = dyn_cast(D))
 return canonicalRenameDecl(
 VarTemplate->getSpecializedTemplate()->getTemplatedDecl());
@@ -113,9 +114,17 @@
 ClassTemplateSpecialization->getSpecializedTemplate()
 ->getTemplatedDecl());
   if (const auto *Method = dyn_cast(D)) {
-if (Method->getDeclKind() == Decl::Kind::CXXConstructor ||
+// By default ctors and dtors are canonicalized to the returned type but
+// when CanonicalizeCtorsToType is set, we should still retrieve the
+// canonical method.
+if ((Method->getDeclKind() == Decl::Kind::CXXConstructor &&
+ !CanonicalizeCtorsToType) ||
 Method->getDeclKind() == Decl::Kind::CXXDestructor)
   return canonicalRenameDecl(Method->getParent());
+if (const FunctionTemplateDecl *Template = Method->getPrimaryTemplate())
+  if (const auto *TemplatedDecl =
+  dyn_cast(Template->getTemplatedDecl()))
+Method = TemplatedDecl;
 if (const FunctionDecl *InstantiatedMethod =
 Method->getInstantiatedFromMemberFunction())
   Method = cast(InstantiatedMethod);
@@ -151,6 +160,18 @@
   if (const auto *VD = dyn_cast(D)) {
 if (const VarDecl *OriginalVD = VD->getInstantiatedFromStaticDataMember())
   VD = OriginalVD;
+// Arguments are canonicalized to their canonical function's arguments.
+if (const auto *Argument = dyn_cast(VD)) {
+  if (const auto *Function =
+  dyn_cast(Argument->getDeclContext())) {
+const auto *Canonical = dyn_cast(
+canonicalRenameDecl(Function, /*SameType=*/true));
+assert(Canonical && "canonicalRenameDecl should return the declaration "
+"of the same type with SameType=true.");
+return Canonical->getParamDecl(Argument->getFunctionScopeIndex())
+->getCanonicalDecl();
+  }
+}
 return VD->getCanonicalDecl();
   }
   return dyn_cast(D->getCanonicalDecl());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96324: [clangd] Rename references to function arguments within the same file

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

This likely needs some further thought on conflict detection. Assume we have

  void foo(int Argument^); // case 1
  void foo(int OhWait); // case 2
  void foo(int Argument); // case 3
  
  void foo(int AnotherOne) {} // case 4

What should we do when renaming `Argument`? Just rename all of them? Only 
rename in places where the name matches the original one (case 3)? Bail out and 
report an error? Also, there is no easy way to check all of these cases within 
our existing conflict detection pipeline: IIUC we'd need to walk the whole AST 
again for that (like we do in this patch within the rename pipeline).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96324

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


[clang] e721bc9 - [clang][cli] Generate and round-trip CodeGen options

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T11:43:38+01:00
New Revision: e721bc9effefab8a625e913e7391bdd340693ddc

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

LOG: [clang][cli] Generate and round-trip CodeGen options

This patch implements generation of remaining codegen options and tests it by 
performing parse-generate-parse round trip.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/XRayInstr.h
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Basic/XRayInstr.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Basic/XRayInstr.h 
b/clang/include/clang/Basic/XRayInstr.h
index 42ca7773fcceb..23ca2c75fc997 100644
--- a/clang/include/clang/Basic/XRayInstr.h
+++ b/clang/include/clang/Basic/XRayInstr.h
@@ -65,8 +65,13 @@ struct XRayInstrSet {
   XRayInstrMask Mask = 0;
 };
 
+/// Parses a command line argument into a mask.
 XRayInstrMask parseXRayInstrValue(StringRef Value);
 
+/// Serializes a set into a list of command line arguments.
+void serializeXRayInstrValue(XRayInstrSet Set,
+ SmallVectorImpl &Values);
+
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index baea96df5829b..544f5771861ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4453,12 +4453,7 @@ def migrator_no_finalize_removal : Flag<["-"], 
"no-finalize-removal">,
 
//===--===//
 
 let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
-def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">,
-  
Values<"line-tables-only,line-directives-only,constructor,limited,standalone,unused-types">,
-  NormalizedValuesScope<"codegenoptions">,
-  NormalizedValues<["DebugLineTablesOnly", "DebugDirectivesOnly", 
"DebugInfoConstructor",
-"LimitedDebugInfo", "FullDebugInfo", "UnusedTypeInfo"]>,
-  MarshallingInfoString, "NoDebugInfo">, 
AutoNormalizeEnum;
+def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">;
 def debug_info_macro : Flag<["-"], "debug-info-macro">,
   HelpText<"Emit macro debug information">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 0b53c867cd98d..8cd512cbfd89e 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -266,12 +266,26 @@ class CompilerInvocation : public CompilerInvocationBase {
StringAllocator SA, const llvm::Triple &T);
 
   /// Parse command line options that map to CodeGenOptions.
-  static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
-   InputKind IK, DiagnosticsEngine &Diags,
-   const llvm::Triple &T,
+  static bool ParseCodeGenArgsImpl(CodeGenOptions &Opts,
+   llvm::opt::ArgList &Args, InputKind IK,
+   DiagnosticsEngine &Diags,
+   const llvm::Triple &T,
+   const std::string &OutputFile,
+   const LangOptions &LangOptsRef);
+
+  static bool ParseCodeGenArgs(CompilerInvocation &Res, CodeGenOptions &Opts,
+   llvm::opt::ArgList &Args, InputKind IK,
+   DiagnosticsEngine &Diags, const llvm::Triple &T,
const std::string &OutputFile,
const LangOptions &LangOptsRef);
 
+  // Generate command line options from CodeGenOptions.
+  static void GenerateCodeGenArgs(const CodeGenOptions &Opts,
+  SmallVectorImpl &Args,
+  StringAllocator SA, const llvm::Triple &T,
+  const std::string &OutputFile,
+  const LangOptions *LangOpts);
+
   /// Parse command line options that map to HeaderSearchOptions.
   static void ParseHeaderSearchArgs(CompilerInvocation &Res,
 HeaderSearchOptions &Opts,

diff  --git a/clang/lib/Basic/XRayInstr.cpp b/clang/lib/Basic/XRayInstr.cpp
index 79052e05860ea..822e14bbb622d 100644
--- a/clang/lib/Basic/XRayInstr.cpp
+++ b/clang/lib/Basic/XRayInstr.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #inc

[PATCH] D96056: [clang][cli] Generate and round-trip CodeGen options

2021-02-09 Thread Jan Svoboda 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 rGe721bc9effef: [clang][cli] Generate and round-trip CodeGen 
options (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D96056?vs=322118&id=322322#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96056

Files:
  clang/include/clang/Basic/XRayInstr.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Basic/XRayInstr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -175,7 +175,7 @@
 class MarshallingInfoStringInt
   : MarshallingInfo {
   code Normalizer = "normalizeStringIntegral<"#type#">";
-  code Denormalizer = "denormalizeString";
+  code Denormalizer = "denormalizeString<"#type#">";
 }
 
 class MarshallingInfoStringVector
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -54,6 +54,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -625,14 +626,17 @@
   // Run the first parse on the original arguments with dummy options and
   // diagnostics.
   SwapOpts(Res);
-  if (!Parse(Res, OriginalArgs, DummyDiags)) {
+  if (!Parse(Res, OriginalArgs, DummyDiags) ||
+  DummyDiags.getNumWarnings() != 0) {
 // If the first parse did not succeed, it must be user mistake (invalid
 // command line arguments). We won't be able to generate arguments that
 // would reproduce the same result. Let's fail again with the original
 // options and diagnostics, so all side-effects of parsing are visible.
+unsigned NumWarningsBefore = Diags.getNumWarnings();
 SwapOpts(Res);
-if (!Parse(Res, OriginalArgs, Diags))
-  return false;
+auto Success = Parse(Res, OriginalArgs, Diags);
+if (!Success || Diags.getNumWarnings() != NumWarningsBefore)
+  return Success;
 
 // Parse with original options and diagnostics succeeded even though it
 // shouldn't have. Something is off.
@@ -749,16 +753,11 @@
 
 static void getAllNoBuiltinFuncValues(ArgList &Args,
   std::vector &Funcs) {
-  SmallVector Values;
-  for (const auto &Arg : Args) {
-const Option &O = Arg->getOption();
-if (O.matches(options::OPT_fno_builtin_)) {
-  const char *FuncName = Arg->getValue();
-  if (Builtin::Context::isBuiltinFunc(FuncName))
-Values.push_back(FuncName);
-}
-  }
-  Funcs.insert(Funcs.end(), Values.begin(), Values.end());
+  std::vector Values = Args.getAllArgValues(OPT_fno_builtin_);
+  auto BuiltinEnd = llvm::partition(Values, [](const std::string FuncName) {
+return Builtin::Context::isBuiltinFunc(FuncName);
+  });
+  Funcs.insert(Funcs.end(), Values.begin(), BuiltinEnd);
 }
 
 static void GenerateAnalyzerArgs(AnalyzerOptions &Opts,
@@ -1238,6 +1237,15 @@
   }
 }
 
+static std::string serializeXRayInstrumentationBundle(const XRayInstrSet &S) {
+  llvm::SmallVector BundleParts;
+  serializeXRayInstrValue(S, BundleParts);
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+  llvm::interleave(BundleParts, OS, [&OS](StringRef Part) { OS << Part; }, ",");
+  return OS.str();
+}
+
 // Set the profile kind using fprofile-instrument-use-path.
 static void setPGOUseInstrumentor(CodeGenOptions &Opts,
   const Twine &ProfileName) {
@@ -1259,12 +1267,258 @@
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 }
 
-bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
-  InputKind IK,
-  DiagnosticsEngine &Diags,
-  const llvm::Triple &T,
-  const std::string &OutputFile,
-  const LangOptions &LangOptsRef) {
+void CompilerInvocation::GenerateCodeGenArgs(
+const CodeGenOptions &Opts, SmallVectorImpl &Args,
+StringAllocator SA, const llvm::Triple &T, const std::string &OutputFile,
+const LangOptions *LangOpts) {
+  const CodeGenOptions &CodeGenOpts = Opts;
+
+  if (Opts.OptimizationLevel == 0)
+GenerateArg(Args, OPT_O0, SA);
+  else
+GenerateArg(Args, OPT_O, Twine(Opts.OptimizationLevel), SA);
+
+#define CODEGEN_OPTION_WITH_MARSHALLING(   

[PATCH] D96247: [clangd] Fix false positive in local rename collision detetction

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 322323.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Resolve review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96247

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@
"conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
+void func(int Var);
+
 void func(int V^ar) {
   bool Conflict;
 }
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(// No conflict: only forward declaration's argument is renamed.
+void func(int [[V^ar]]);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@
 for (const auto *Parameter : EnclosingFunction->parameters())
   if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
 return Parameter;
+// FIXME: We don't modify all references to function parameters when
+// renaming from forward declaration now, so using a name colliding with
+// something in the definition's body is a valid transformation.
+if (!EnclosingFunction->doesThisDeclarationHaveABody())
+  return nullptr;
 return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
   }
 


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@
"conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
+void func(int Var);
+
 void func(int V^ar) {
   bool Conflict;
 }
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(// No conflict: only forward declaration's argument is renamed.
+void func(int [[V^ar]]);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@
 for (const auto *Parameter : EnclosingFunction->parameters())
   if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
 return Parameter;
+// FIXME: We don't modify all references to function parameters when
+// renaming from forward declaration now, so using a name colliding with
+// something in the definition's body is a valid transformation.
+if (!EnclosingFunction->doesThisDeclarationHaveABody())
+  return nullptr;
 return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2f994d4 - [-Wcompletion-handler][NFC] Remove unexpected warnings on Windows

2021-02-09 Thread Valeriy Savchenko via cfe-commits
Author: Valeriy Savchenko
Date: 2021-02-09T13:50:11+03:00
New Revision: 2f994d4ee920983cf7624ce2208756e0c7d19007

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

LOG: [-Wcompletion-handler][NFC] Remove unexpected warnings on Windows

Added: 


Modified: 
clang/test/SemaObjC/warn-called-once.m

Removed: 




diff  --git a/clang/test/SemaObjC/warn-called-once.m 
b/clang/test/SemaObjC/warn-called-once.m
index 0c11d0e0a15b..1014e1730163 100644
--- a/clang/test/SemaObjC/warn-called-once.m
+++ b/clang/test/SemaObjC/warn-called-once.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions 
-Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions 
-Wcompletion-handler -Wno-pointer-to-int-cast %s
 
 #define NULL (void *)0
 #define nil (id)0



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


[clang-tools-extra] b60428c - [clangd] Fix false positive in local rename collision detetction

2021-02-09 Thread Kirill Bobyrev via cfe-commits
Author: Kirill Bobyrev
Date: 2021-02-09T11:51:18+01:00
New Revision: b60428c7ea685e338df3369807c9b650f994554b

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

LOG: [clangd] Fix false positive in local rename collision detetction

Fixes https://github.com/clangd/clangd/issues/685

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 07422a06a923..6c117fc26273 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@ const NamedDecl 
*lookupSiblingWithinEnclosingScope(ASTContext &Ctx,
 for (const auto *Parameter : EnclosingFunction->parameters())
   if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
 return Parameter;
+// FIXME: We don't modify all references to function parameters when
+// renaming from forward declaration now, so using a name colliding with
+// something in the definition's body is a valid transformation.
+if (!EnclosingFunction->doesThisDeclarationHaveABody())
+  return nullptr;
 return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
   }
 

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 39104c675db2..f1f9e17a7b8b 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@ TEST(RenameTest, Renameable) {
"conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
+void func(int Var);
+
 void func(int V^ar) {
   bool Conflict;
 }
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(// No conflict: only forward declaration's argument is renamed.
+void func(int [[V^ar]]);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }



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


[PATCH] D96247: [clangd] Fix false positive in local rename collision detetction

2021-02-09 Thread Kirill Bobyrev 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 rGb60428c7ea68: [clangd] Fix false positive in local rename 
collision detetction (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96247

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@
"conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
+void func(int Var);
+
 void func(int V^ar) {
   bool Conflict;
 }
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(// No conflict: only forward declaration's argument is renamed.
+void func(int [[V^ar]]);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@
 for (const auto *Parameter : EnclosingFunction->parameters())
   if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
 return Parameter;
+// FIXME: We don't modify all references to function parameters when
+// renaming from forward declaration now, so using a name colliding with
+// something in the definition's body is a valid transformation.
+if (!EnclosingFunction->doesThisDeclarationHaveABody())
+  return nullptr;
 return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
   }
 


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@
"conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
+void func(int Var);
+
 void func(int V^ar) {
   bool Conflict;
 }
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
+  {R"cpp(// No conflict: only forward declaration's argument is renamed.
+void func(int [[V^ar]]);
+
+void func(int Var) {
+  bool Conflict;
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
+
   {R"cpp(
 void func(int V^ar, int Conflict) {
 }
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@
 for (const auto *Parameter : EnclosingFunction->parameters())
   if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
 return Parameter;
+// FIXME: We don't modify all references to function parameters when
+// renaming from forward declaration now, so using a name colliding with
+// something in the definition's body is a valid transformation.
+if (!EnclosingFunction->doesThisDeclarationHaveABody())
+  return nullptr;
 return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

2021-02-09 Thread Stuart Brady via Phabricator via cfe-commits
stuart requested changes to this revision.
stuart added a comment.
This revision now requires changes to proceed.

Looks good, just some suggestions about the test.




Comment at: clang/test/CodeGenOpenCL/kernel-arg-info.cl:110
 
+kernel void foo9(signed char si1,  global const signed char* si2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}

Suggest `sc1` and `sc2` as these are now signed chars, not signed ints.



Comment at: clang/test/CodeGenOpenCL/kernel-arg-info.cl:112-118
+// CHECK: !kernel_arg_addr_space ![[SINT_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SINT_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SINT_TY]]
+// CHECK: !kernel_arg_type_qual ![[SINT_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SINT_ARG_NAMES:[0-9]+]]

Would suggest `SCHAR_AS_QUAL` and `SCHAR_TY` now that this is using a signed 
char.



Comment at: clang/test/CodeGenOpenCL/kernel-arg-info.cl:159-162
+// CHECK: ![[SINT_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SINT_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SINT_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SINT_ARG_NAMES]] = !{!"si1", !"si2"}

... and here.


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

https://reviews.llvm.org/D96161

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


[clang] ea89109 - [NFC,Clang] Add LTO Driver Tsan tests

2021-02-09 Thread Vitaly Buka via cfe-commits
Author: Vitaly Buka
Date: 2021-02-09T03:08:00-08:00
New Revision: ea891099f2bc5d1749c7ce123391e530ed2ab9ef

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

LOG: [NFC,Clang] Add LTO Driver Tsan tests

Added: 


Modified: 
clang/test/Driver/tsan.c

Removed: 




diff  --git a/clang/test/Driver/tsan.c b/clang/test/Driver/tsan.c
index 7fca92fec457..c098fb6c12dd 100644
--- a/clang/test/Driver/tsan.c
+++ b/clang/test/Driver/tsan.c
@@ -4,7 +4,11 @@
 // RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread  %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck 
%s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck 
%s
 // Verify that -fsanitize=thread invokes tsan instrumentation.
 
 // Also check that this works with the new pass manager with and without
@@ -14,6 +18,10 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck 
%s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck 
%s
 
 int foo(int *a) { return *a; }
 // CHECK: __tsan_init



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


[clang] 9ff678f - [NFC,Clang] Add LTO Driver DFsan tests

2021-02-09 Thread Vitaly Buka via cfe-commits
Author: Vitaly Buka
Date: 2021-02-09T03:08:00-08:00
New Revision: 9ff678f614d37487d0d117709aa3263fbc0d8423

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

LOG: [NFC,Clang] Add LTO Driver DFsan tests

Added: 
clang/test/Driver/dfsan.c

Modified: 


Removed: 




diff  --git a/clang/test/Driver/dfsan.c b/clang/test/Driver/dfsan.c
new file mode 100644
index ..58d6ea6bccb8
--- /dev/null
+++ b/clang/test/Driver/dfsan.c
@@ -0,0 +1,22 @@
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto -o - | 
FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto -o - | 
FileCheck %s
+
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto -o - | 
FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=dataflow %s -S -emit-llvm -flto -o - | 
FileCheck %s
+
+// Verify that -fsanitize=dataflow invokes DataFlowSanitizerPass 
instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: __dfsan



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


[clang] dde9f0f - [NFC,Clang] Add LTO Driver MSan,KMsan tests

2021-02-09 Thread Vitaly Buka via cfe-commits
Author: Vitaly Buka
Date: 2021-02-09T03:08:00-08:00
New Revision: dde9f0fa9834afe02e32e27cc822cccb8ef6aeff

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

LOG: [NFC,Clang] Add LTO Driver MSan,KMsan tests

Added: 


Modified: 
clang/test/Driver/msan.c

Removed: 




diff  --git a/clang/test/Driver/msan.c b/clang/test/Driver/msan.c
index dcbace819b7e..eeacb99175ef 100644
--- a/clang/test/Driver/msan.c
+++ b/clang/test/Driver/msan.c
@@ -4,11 +4,19 @@
 // RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
 // RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
 // RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
 
 // RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefix=CHECK-KMSAN
 // RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefix=CHECK-KMSAN
 // RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefix=CHECK-KMSAN
 // RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefix=CHECK-KMSAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
 
 // RUN: %clang -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o 
- | FileCheck %s --check-prefix=CHECK-MSAN
 // RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
@@ -23,6 +31,19 @@
 // RUN: %clang -O1 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-MSAN
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-MSAN
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
+
+// FIX: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// FIX: %clang -O1 -fexperimental-new-

[clang] 4ddf756 - [NFC,Clang] Add SanCov Driver tests

2021-02-09 Thread Vitaly Buka via cfe-commits
Author: Vitaly Buka
Date: 2021-02-09T03:08:00-08:00
New Revision: 4ddf7562d5cce153b982cf16c2a776095495a2f9

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

LOG: [NFC,Clang] Add SanCov Driver tests

Added: 
clang/test/Driver/sancov.c

Modified: 


Removed: 




diff  --git a/clang/test/Driver/sancov.c b/clang/test/Driver/sancov.c
new file mode 100644
index ..16409427ac24
--- /dev/null
+++ b/clang/test/Driver/sancov.c
@@ -0,0 +1,22 @@
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm 
-flto=thin -o - | FileCheck %s
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm 
-flto=thin -o - | FileCheck %s
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto 
-o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto 
-o - | FileCheck %s
+
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm 
-flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm 
-flto=thin -o - | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto 
-o - | FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto 
-o - | FileCheck %s
+
+// Verify that -fsanitize-coverage invokes ModuleSanitizerCoveragePass 
instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: _sancov_



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


[clang] 03c6a6d - [NFC,Clang] Add more Asan Driver tests

2021-02-09 Thread Vitaly Buka via cfe-commits
Author: Vitaly Buka
Date: 2021-02-09T03:08:00-08:00
New Revision: 03c6a6d9ef5052a5eeedddf4d2d256be0e1d3348

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

LOG: [NFC,Clang] Add more Asan Driver tests

Added: 


Modified: 
clang/test/Driver/asan.c

Removed: 




diff  --git a/clang/test/Driver/asan.c b/clang/test/Driver/asan.c
index 51db6e24968b..fe1432497627 100644
--- a/clang/test/Driver/asan.c
+++ b/clang/test/Driver/asan.c
@@ -1,23 +1,78 @@
-// RUN: %clang -target i386-unknown-linux -fsanitize=address %s -S 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -flto=thin -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -flto=thin -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
+
+// RUN: %clang -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
 // RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
 // RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
 // RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-ASAN
-// RUN: %clang -target i386-unknown-linux -fsanitize=kernel-address %s -S 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-KASAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-ASAN
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
i386-unknown-linux -fsanitize=address %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-ASAN
+
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -flto=thin -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// FIX: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -flto=thin -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-llvm -flto -o - | FileCheck %s 
--check-prefix=CHECK-KASAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target i386-unknown-linux 
-fsanitize=kernel-address %s -S -emit-ll

[PATCH] D96328: [Clang, NewPM] Add KMSan support

2021-02-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: glider, eugenis.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends on D96320 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96328

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/msan.c


Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -36,14 +36,14 @@
 // RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefix=CHECK-MSAN
 
-// FIX: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -O1 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefix=CHECK-KMSAN
 // FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefix=CHECK-KMSAN
 
 int foo(int *a) { return *a; }
 // CHECK-MSAN: __msan_init
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1269,17 +1269,25 @@
 });
   }
 
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
-int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
-bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
-PB.registerOptimizerLastEPCallback(
-[TrackOrigins, Recover](ModulePassManager &MPM,
-PassBuilder::OptimizationLevel Level) {
-  MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
-  MPM.addPass(createModuleToFunctionPassAdaptor(
-  MemorySanitizerPass({TrackOrigins, Recover, false})));
-});
-  }
+  auto MSanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+if (LangOpts.Sanitize.has(Mask)) {
+  int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
+  bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+  PB.registerOptimizerLastEPCallback(
+  [CompileKernel, TrackOrigins,
+   Recover](ModulePassManager &MPM,
+PassBuilder::OptimizationLevel Level) {
+MPM.addPass(MemorySanitizerPass(
+ 

[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

2021-02-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 322330.
Anastasia added a comment.

Renamed variables in CHECK statements


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

https://reviews.llvm.org/D96161

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenOpenCL/kernel-arg-info.cl


Index: clang/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed char sc1,  global const signed char* sc2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SCHAR_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SCHAR_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SCHAR_TY]]
+// CHECK: !kernel_arg_type_qual ![[SCHAR_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SCHAR_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar 
__attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SCHAR_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SCHAR_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SCHAR_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SCHAR_ARG_NAMES]] = !{!"sc1", !"sc2"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1501,6 +1501,8 @@
   // Turn "unsigned type" to "utype"
   if (typeNameRef.consume_front("unsigned "))
 return std::string("u") + typeNameRef.str();
+  if (typeNameRef.consume_front("signed "))
+return typeNameRef.str();
 }
 
 return typeName;


Index: clang/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed char sc1,  global const signed char* sc2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SCHAR_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SCHAR_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SCHAR_TY]]
+// CHECK: !kernel_arg_type_qual ![[SCHAR_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SCHAR_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar __attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SCHAR_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SCHAR_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SCHAR_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SCHAR_ARG_NAMES]] = !{!"sc1", !"sc2"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1501,6 +1501,8 @@
   // Turn "unsigned type" to "utype"
   if (typeNameRef.consume_front("unsigned "))
 return std::string("u") + typeNameRef.str();
+

[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

2021-02-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/CodeGenOpenCL/kernel-arg-info.cl:112-118
+// CHECK: !kernel_arg_addr_space ![[SINT_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SINT_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SINT_TY]]
+// CHECK: !kernel_arg_type_qual ![[SINT_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SINT_ARG_NAMES:[0-9]+]]

stuart wrote:
> Would suggest `SCHAR_AS_QUAL` and `SCHAR_TY` now that this is using a signed 
> char.
FYI also `SCHAR_ARG_NAMES` and `SCHAR_QUAL`


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

https://reviews.llvm.org/D96161

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


[PATCH] D90595: [clangd] Fix race in background index rebuild, where index could stay stale.

2021-02-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp:850
+if (++IdleCount <= 2) {
+  Q.push(Task);
+  Q.push(Task);

kadircet wrote:
> as discussed offline there are no guarantees on these newly pushed tasks 
> finishing before the `OnIdle`.
i suppose we can do something like:
- Count number of times `OnIdle` has been executed.
- Enqueue 2 more tasks with first `OnIdle`.
- Assert that `OnIdle` has run twice ? (once on initial idleness, and once 
after completing 2 newly introduced tasks)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90595

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


[PATCH] D96120: [scudo] Port scudo sanitizer to Windows

2021-02-09 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D96120#2546077 , @mstorsjo wrote:

> As is, this breaks compilation for mingw. With the three modifications I 
> suggest here, it no longer breaks compilation for me - I have no idea if it 
> actually works in mingw configurations though, but not breaking compilation 
> is at least the first step.

Thanks for the information I'll try to run up a mingw environment and check it 
works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96120

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 322339.
whisperity added a comment.

- Added a C test file with some C-specific language constructs that we may or 
may not match.
- Explained limitations with regards to variadics, templates, etc. better in 
the docs, and added test cases for these too.
- When comparing the type names against the ignored type name list, do **not** 
consider `PrintingPolicy`, but take //exactly// what's in the source code. This 
mostly concerns `bool` and `_Bool` at face value, so this is tested in the C 
file too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -0,0 +1,93 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U"} \
+// RUN:  ]}' -- -x c
+
+#define bool _Bool
+#define true 1
+#define false 0
+
+typedef bool MyBool;
+
+void declVoid(void); // NO-WARN: Declaration only.
+void decl(); // NO-WARN: Declaration only.
+void oneParam(int I) {}  // NO-WARN: 1 parameter.
+void variadic(int I, ...) {} // NO-WARN: 1 visible parameter.
+
+void trivial(int I, int J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'trivial' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:25: note: the last parameter in the range is 'J'
+
+void qualifier(int I, const int CI) {} // NO-WARN: Distinct types.
+
+void restrictQualifier(char *restrict CPR1, char *restrict CPR2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 2 adjacent parameters of 'restrictQualifier' of similar type ('char *restrict')
+// CHECK-MESSAGES: :[[@LINE-2]]:39: note: the first parameter in the range is 'CPR1'
+// CHECK-MESSAGES: :[[@LINE-3]]:60: note: the last parameter in the range is 'CPR2'
+
+void pointer1(int *IP1, int *IP2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'pointer1' of similar type ('int *')
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: the first parameter in the range is 'IP1'
+// CHECK-MESSAGES: :[[@LINE-3]]:30: note: the last parameter in the range is 'IP2'
+
+void pointerConversion(int *IP, long *LP) {}
+// NO-WARN: Even though C can convert any T* to U* back and forth, compiler
+// warnings already exist for this.
+
+void testVariadicsCall() {
+  int IVal = 1;
+  decl(IVal); // NO-WARN: Particular calls to "variadics" are like template
+  // instantiations, and we do not model them.
+
+  variadic(IVal);  // NO-WARN.
+  variadic(IVal, 2, 3, 4); // NO-WARN.
+}
+
+struct S {};
+struct T {};
+
+void taggedTypes1(struct S SVar, struct T TVar) {} // NO-WARN: Distinct types.
+
+void taggedTypes2(struct S SVar1, struct S SVar2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 2 adjacent parameters of 'taggedTypes2' of similar type ('struct S')
+// CHECK-MESSAGES: :[[@LINE-2]]:28: note: the first parameter in the range is 'SVar1'
+// CHECK-MESSAGES: :[[@LINE-3]]:44: note: the last parameter in the range is 'SVar2'
+
+void unholy(I, J)
+  int I;
+  int J;
+{}
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 2 adjacent parameters of 'unholy' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the last parameter in the range is 'J'
+
+void boolAsWritten(bool B1, bool B2) {}
+// Even though it is "bool" what is written there, the preprocessor has changed
+// it to "_Bool" due to th

[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2021-02-09 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D92715#2544233 , @craig.topper 
wrote:

> In D92715#2544178 , @HsiangKai wrote:
>
>> In D92715#2520925 , @craig.topper 
>> wrote:
>>
>>> I wonder if these types should be prefixed with "__clang_" like AArch64 
>>> tuple types?
>>
>> It seems only AArch64 tuple types have "__clang_" prefix.
>
> I think the other types don't have it because they are defined by an ARM 
> standard. See the description for https://reviews.llvm.org/D81721

It seems to use `__clang_` to differentiate tuple types and non-tuple types. 
The mangling rules are different between tuple types and non-tuple types in 
ARM. We have no mangling rules in our specification. I have a TODO item in this 
patch to clarify the mangling rules later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92715

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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2021-02-09 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

I'm fine with any direction that helps people land test updates/implementations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:2
 
-RISCVV_BUILTIN(vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m1_m_vl, "q8Scq8bq8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_vl, "q4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_m_vl, "q4Ssq4bq4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_vl, "q2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_m_vl, "q2Siq2bq2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_vl, "q1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_vl, "q16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_m_vl, "q16Scq16bq16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_vl, "q8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_m_vl, "q8Ssq8bq8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_vl, "q4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_m_vl, "q4Siq4bq4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_vl, "q2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_vl, "q32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_m_vl, "q32Scq32bq32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_vl, "q16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_m_vl, "q16Ssq16bq16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_vl, "q8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_m_vl, "q8Siq8bq8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_vl, "q4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_vl, "q64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_m_vl, "q64Scq64bq64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_vl, "q32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_m_vl, "q32Ssq32bq32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_vl, "q16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_m_vl, "q16Siq16bq16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_vl, "q8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_vl, "q4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_m_vl, "q4Scq4bq4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_vl, "q2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_m_vl, "q2Ssq2bq2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_vl, "q1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_m_vl, "q1Siq1bq1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_vl, "q2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_m_vl, "q2Scq2bq2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_vl, "q1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_m_vl, "q1Ssq1bq1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_vl, "q1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_m_vl, "q1Scq1bq1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_vl, "q8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_m_vl, "q8Scq8bq8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_vl, "q4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_m_vl, "q4Ssq4bq4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_vl, "q2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_m_vl, "q2Siq2bq2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_vl, "q1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_vl, "q16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_m_vl, "q16Scq16bq16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_vl, "q8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_m_vl, "q8Ssq8bq8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_vl, "q4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_m_vl, "q4Siq4bq4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_vl, "q2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_vl, "q32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_m_vl, "q32Scq32bq32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_vl, "q16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_m_vl, "q16Ssq16bq16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_vl, "q8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_m_vl, "q8Siq8bq8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_vl, "q4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_vl, "q64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_m_vl, "q64Scq64bq64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_vl, "q32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_m_vl, "q32Ssq32bq32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_vl, "q16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_m_vl, "q16Siq16bq16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_vl, "q8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_vl, "q4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_m_vl, "q4Scq4bq4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_vl, "q2Ssq2SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_m_vl, "q2Ssq2bq2Ssq2SsSsz"

[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: llvm/docs/CommandGuide/tblgen.rst:141
 
-  Generate RISCV compressed instructions.
+  Generate RISC-V compressed instructions.
 

It is typo fix. Could you fix it in a separate patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 322297.
khchen marked 3 inline comments as done.
khchen added a comment.

1. address Jim's comment.
2. remove suffix `_vl` according by 
https://github.com/riscv/rvv-intrinsic-doc/pull/64


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:2
 
-RISCVV_BUILTIN(vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m1_m_vl, "q8Scq8bq8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_vl, "q4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_m_vl, "q4Ssq4bq4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_vl, "q2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_m_vl, "q2Siq2bq2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_vl, "q1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_vl, "q16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_m_vl, "q16Scq16bq16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_vl, "q8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_m_vl, "q8Ssq8bq8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_vl, "q4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_m_vl, "q4Siq4bq4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_vl, "q2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_vl, "q32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_m_vl, "q32Scq32bq32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_vl, "q16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_m_vl, "q16Ssq16bq16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_vl, "q8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_m_vl, "q8Siq8bq8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_vl, "q4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_vl, "q64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_m_vl, "q64Scq64bq64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_vl, "q32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_m_vl, "q32Ssq32bq32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_vl, "q16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_m_vl, "q16Siq16bq16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_vl, "q8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_vl, "q4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_m_vl, "q4Scq4bq4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_vl, "q2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_m_vl, "q2Ssq2bq2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_vl, "q1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_m_vl, "q1Siq1bq1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_vl, "q2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_m_vl, "q2Scq2bq2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_vl, "q1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_m_vl, "q1Ssq1bq1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_vl, "q1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_m_vl, "q1Scq1bq1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_vl, "q8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_m_vl, "q8Scq8bq8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_vl, "q4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_m_vl, "q4Ssq4bq4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_vl, "q2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_m_vl, "q2Siq2bq2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_vl, "q1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_vl, "q16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_m_vl, "q16Scq16bq16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_vl, "q8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_m_vl, "q8Ssq8bq8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_vl, "q4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_m_vl, "q4Siq4bq4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_vl, "q2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_vl, "q32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_m_vl, "q32Scq32bq32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_vl, "q16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_m_vl, "q16Ssq16bq16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_vl, "q8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_m_vl, "q8Siq8bq8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_vl, "q4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_vl, "q64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_m_vl, "q64Scq64bq64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_vl, "q32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_m_vl, "q32Ssq32bq32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_vl, "q16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_m_vl, "q16Siq16bq16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_vl, "q8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_vl, "q4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_m_vl, "q4Scq4bq4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_vl, "q2Ssq2SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_m_vl, "q2Ssq2bq2Ssq2SsS

[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 322300.
khchen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-09 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:2
 
-RISCVV_BUILTIN(vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m1_m_vl, "q8Scq8bq8Scq8Scq8Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_vl, "q4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m1_m_vl, "q4Ssq4bq4Ssq4Ssq4Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_vl, "q2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m1_m_vl, "q2Siq2bq2Siq2Siq2Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_vl, "q1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiq1SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_vl, "q16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m2_m_vl, "q16Scq16bq16Scq16Scq16Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_vl, "q8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m2_m_vl, "q8Ssq8bq8Ssq8Ssq8Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_vl, "q4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m2_m_vl, "q4Siq4bq4Siq4Siq4Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_vl, "q2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiq2SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_vl, "q32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m4_m_vl, "q32Scq32bq32Scq32Scq32Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_vl, "q16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m4_m_vl, "q16Ssq16bq16Ssq16Ssq16Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_vl, "q8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m4_m_vl, "q8Siq8bq8Siq8Siq8Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_vl, "q4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiq4SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_vl, "q64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8m8_m_vl, "q64Scq64bq64Scq64Scq64Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_vl, "q32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16m8_m_vl, "q32Ssq32bq32Ssq32Ssq32Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_vl, "q16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32m8_m_vl, "q16Siq16bq16Siq16Siq16Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_vl, "q8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiq8SWiz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_vl, "q4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf2_m_vl, "q4Scq4bq4Scq4Scq4Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_vl, "q2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf2_m_vl, "q2Ssq2bq2Ssq2Ssq2Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_vl, "q1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i32mf2_m_vl, "q1Siq1bq1Siq1Siq1Siz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_vl, "q2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf4_m_vl, "q2Scq2bq2Scq2Scq2Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_vl, "q1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i16mf4_m_vl, "q1Ssq1bq1Ssq1Ssq1Ssz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_vl, "q1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vv_i8mf8_m_vl, "q1Scq1bq1Scq1Scq1Scz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_vl, "q8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m1_m_vl, "q8Scq8bq8Scq8ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_vl, "q4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m1_m_vl, "q4Ssq4bq4Ssq4SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_vl, "q2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m1_m_vl, "q2Siq2bq2Siq2SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_vl, "q1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m1_m_vl, "q1SWiq1bq1SWiq1SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_vl, "q16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m2_m_vl, "q16Scq16bq16Scq16ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_vl, "q8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m2_m_vl, "q8Ssq8bq8Ssq8SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_vl, "q4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m2_m_vl, "q4Siq4bq4Siq4SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_vl, "q2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m2_m_vl, "q2SWiq2bq2SWiq2SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_vl, "q32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m4_m_vl, "q32Scq32bq32Scq32ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_vl, "q16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m4_m_vl, "q16Ssq16bq16Ssq16SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_vl, "q8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m4_m_vl, "q8Siq8bq8Siq8SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_vl, "q4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m4_m_vl, "q4SWiq4bq4SWiq4SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_vl, "q64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8m8_m_vl, "q64Scq64bq64Scq64ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_vl, "q32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16m8_m_vl, "q32Ssq32bq32Ssq32SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_vl, "q16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i32m8_m_vl, "q16Siq16bq16Siq16SiSiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_vl, "q8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i64m8_m_vl, "q8SWiq8bq8SWiq8SWiSWiz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_vl, "q4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i8mf2_m_vl, "q4Scq4bq4Scq4ScScz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_vl, "q2Ssq2SsSsz", "n")
-RISCVV_BUILTIN(vadd_vx_i16mf2_m_vl, "q2Ssq2bq2Ssq2SsSsz"

[PATCH] D96120: [scudo] Port scudo sanitizer to Windows

2021-02-09 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D96120#2545151 , @aganea wrote:

> A few questions: Does this work on x86 targets?

I haven't tried. I'll test this out.

> Are the scudo tests below being built with /MD or with /MT?

The lit tests? They don't specify either. Does that imply /MT?

> Would this change compile/work on MinGW as well?

I'll check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96120

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 4 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:255
+  std::string NodeTypeName =
+  Node->getType().getAsString(Node->getASTContext().getPrintingPolicy());
+  StringRef CaptureName{NodeTypeName};

whisperity wrote:
> aaron.ballman wrote:
> > whisperity wrote:
> > > aaron.ballman wrote:
> > > > Hmm, one downside to using the printing policy to get the node name is 
> > > > that there can be alternative spellings for the same type that the user 
> > > > might reasonably expect to be applied. e.g., if the user expects to 
> > > > ignore `bool` datatypes and the printing policy wants to spell the type 
> > > > as `_Bool`, this won't behave as expected.
> > > But then the diagnostic is inconsistent with what the compiler is 
> > > configured to output as diagnostics, isn't it? Can I stringify through 
> > > Clang with some "default" printing policy?
> > The situation I'm worried about is something like this in C code:
> > ```
> > #include 
> > 
> > void func(bool b, bool c) {}
> > ```
> > because the `bool` in the function signature will expand to `_Bool` after 
> > the preprocessor gets to it (because of the contents of ``). If 
> > the user writes `bool` in their configuration file because that's what 
> > they've written in their function signatures, will this fail because the 
> > printing policy says it should be `_Bool`?
> > 
> > Along similar lines, I wonder about things like `struct S` vs `S` (in C), 
> > `signed char` vs `char`, types within anonymous namespaces (where we print 
> > ``), etc. Basically, any time when the printing policy 
> > may differ from what the user lexically writes in code.
> Meanwhile, I realised we are talking of two entirely distinct things. I will 
> look into how this `PrintingPolicy` stuff works... I agree that the ignore 
> rules (where the comment was originally posted) should respect the text 
> written into the code as-is. The diagnostics printing type names could 
> continue using the proper printing policy (to be in line with how Sema 
> diagnoses, AFAIK).
Right, @aaron.ballman I think I got this tested. Please check the C test file. 
`bool` becomes `_Bool` in C code by the preprocessor, but the printing policy 
still says both should be printed as `bool`. I added some test cases about 
this. It is weird, because without doing some extra magic specifically against 
macros (which might break detecting type names in other locations), I can't 
really test ignoring `_Bool` but not ignoring `bool`. Now, the diagnostics 
respect the printing policy, but the type names are taken with an empty 
printing policy, which //should// give us the result as-is in the code. 
Unfortunately, "as-is" still means `_Bool` for `bool`'s case, so even if you 
ignore `bool`, you will still get results where `bool` is written, because 
`bool` is a macro (Tidy automatically puts a note about this!) and the real 
type is `_Bool`, as per the macro expansion.

Wow... okay, that explanation got convoluted.
Anyways, it's //really weird//. But: we no longer take the actual printing 
policy anymore, but the default, which should eliminate all these cases.
The `bool`/`_Bool` case doesn't fail because of the printing policy, it fails 
because `bool` is a macro in ``.

Also, the type name ignore list not a full match, but a //substring match// 
ignore list. So if you have a type named `struct Foo`, if you ignore `Foo`, 
both `struct Foo`, `Foo`, `MyFoo`, etc. will be also ignored. And it's case 
sensitive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[PATCH] D96120: [scudo] Port scudo sanitizer to Windows

2021-02-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D96120#2550876 , @russell.gallop 
wrote:

> In D96120#2546077 , @mstorsjo wrote:
>
>> As is, this breaks compilation for mingw. With the three modifications I 
>> suggest here, it no longer breaks compilation for me - I have no idea if it 
>> actually works in mingw configurations though, but not breaking compilation 
>> is at least the first step.
>
> Thanks for the information I'll try to run up a mingw environment and check 
> it works.

In case that turns out to be tricky, I might be able to help with that, at 
least for building a simple test program with it and running it, if you say how 
it's supposed to be used  (building/linking with `-fsanitize=scudo`?) and how 
to inspect whether it actually works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96120

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-02-09 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/lib/Target/X86/X86TargetMachine.cpp:416
+  if (TM->getOptLevel() == CodeGenOpt::None)
+addPass(createX86LowerAMXIntrinsicsPass());
+  else {

We may add both pass anyway and skip the pass based on the option level and 
option attribute in the two passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D96231: [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

2021-02-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 322344.
pengfei marked 7 inline comments as done.
pengfei added a comment.

Address Sanjay's comments. Thanks for the thoroughly review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96231

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fintrin.h
  clang/test/CodeGen/X86/avx512-reduceIntrin.c

Index: clang/test/CodeGen/X86/avx512-reduceIntrin.c
===
--- clang/test/CodeGen/X86/avx512-reduceIntrin.c
+++ clang/test/CodeGen/X86/avx512-reduceIntrin.c
@@ -11,13 +11,13 @@
 long long test_mm512_reduce_mul_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_epi64(
 // CHECK:call i64 @llvm.vector.reduce.mul.v8i64(<8 x i64> %{{.*}})
-  return _mm512_reduce_mul_epi64(__W); 
+  return _mm512_reduce_mul_epi64(__W);
 }
 
 long long test_mm512_reduce_or_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_or_epi64(
 // CHECK:call i64 @llvm.vector.reduce.or.v8i64(<8 x i64> %{{.*}})
-  return _mm512_reduce_or_epi64(__W); 
+  return _mm512_reduce_or_epi64(__W);
 }
 
 long long test_mm512_reduce_and_epi64(__m512i __W){
@@ -31,7 +31,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.add.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_add_epi64(__M, __W); 
+  return _mm512_mask_reduce_add_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_mul_epi64(__mmask8 __M, __m512i __W){
@@ -39,7 +39,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.mul.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_mul_epi64(__M, __W); 
+  return _mm512_mask_reduce_mul_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_and_epi64(__mmask8 __M, __m512i __W){
@@ -47,7 +47,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.and.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_and_epi64(__M, __W); 
+  return _mm512_mask_reduce_and_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_or_epi64(__mmask8 __M, __m512i __W){
@@ -55,30 +55,30 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.or.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_or_epi64(__M, __W); 
+  return _mm512_mask_reduce_or_epi64(__M, __W);
 }
 
 int test_mm512_reduce_add_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_add_epi32(
 // CHECK:call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_add_epi32(__W); 
+  return _mm512_reduce_add_epi32(__W);
 }
 
 int test_mm512_reduce_mul_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_epi32(
 // CHECK:call i32 @llvm.vector.reduce.mul.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_mul_epi32(__W); 
+  return _mm512_reduce_mul_epi32(__W);
 }
 
 int test_mm512_reduce_or_epi32(__m512i __W){
 // CHECK:call i32 @llvm.vector.reduce.or.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_or_epi32(__W); 
+  return _mm512_reduce_or_epi32(__W);
 }
 
 int test_mm512_reduce_and_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_and_epi32(
 // CHECK:call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_and_epi32(__W); 
+  return _mm512_reduce_and_epi32(__W);
 }
 
 int test_mm512_mask_reduce_add_epi32(__mmask16 __M, __m512i __W){
@@ -86,7 +86,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_add_epi32(__M, __W); 
+  return _mm512_mask_reduce_add_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_mul_epi32(__mmask16 __M, __m512i __W){
@@ -94,7 +94,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.mul.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_mul_epi32(__M, __W); 
+  return _mm512_mask_reduce_mul_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_and_epi32(__mmask16 __M, __m512i __W){
@@ -102,7 +102,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_and_epi32(__M, __W); 
+  return _mm512_mask_reduce_and_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_or_epi32(__mmask16 __M, __m512i __W){
@@ -110,61 +110,65 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>

[PATCH] D96231: [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

2021-02-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13829
 CGM.getIntrinsic(Intrinsic::vector_reduce_fadd, Ops[1]->getType());
+Builder.getFastMathFlags().setAllowReassoc(true);
 return Builder.CreateCall(F, {Ops[0], Ops[1]});

spatel wrote:
> spatel wrote:
> > I haven't looked at this part of the compiler in a long time, so I was 
> > wondering how we handle FMF scope. It looks like there is already an 
> > FMFGuard object in place -- CodeGenFunction::CGFPOptionsRAII(). So setting 
> > FMF here will not affect anything but this CreateCall(). 
> > 
> > Does that match your understanding? Should we have an extra regression test 
> > to make sure that does not change?
> > 
> > I am imagining something like:
> > 
> > ```
> > double test_mm512_reduce_add_pd(__m512d __W, double ExtraAddOp) {
> >   double S = _mm512_reduce_add_pd(__W) + ExtraAddOp;
> >   return S;
> > }
> > 
> > ```
> > 
> > Then we could confirm that `reassoc` is not applied to the `fadd` that 
> > follows the reduction call.
> Currently (and we could say that this is an LLVM codegen bug), we will not 
> generate the optimal/expected reduction with `reassoc` alone.
> 
> I think the x86 reduction definition is implicitly assuming that -0.0 is not 
> meaningful here, so we should add `nsz` too.
> 
> The backend is expecting an explicit `nsz` on this op. Ie, I see this x86 asm 
> currently with only `reassoc`:
>   
> ```
>   vextractf64x4   $1, %zmm0, %ymm1
>   vaddpd  %zmm1, %zmm0, %zmm0
>   vextractf128$1, %ymm0, %xmm1
>   vaddpd  %xmm1, %xmm0, %xmm0
>   vpermilpd   $1, %xmm0, %xmm1  
>   vaddsd  %xmm1, %xmm0, %xmm0 
>   vxorpd  %xmm1, %xmm1, %xmm1   <--- create 0.0
>   vaddsd  %xmm1, %xmm0, %xmm0   <--- add it to the reduction result
> ```
> 
> Alternatively (and I'm not sure where it is specified), we could replace the 
> default 0.0 argument with -0.0?
Confirmed by new tests.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13829
 CGM.getIntrinsic(Intrinsic::vector_reduce_fadd, Ops[1]->getType());
+Builder.getFastMathFlags().setAllowReassoc(true);
 return Builder.CreateCall(F, {Ops[0], Ops[1]});

pengfei wrote:
> spatel wrote:
> > spatel wrote:
> > > I haven't looked at this part of the compiler in a long time, so I was 
> > > wondering how we handle FMF scope. It looks like there is already an 
> > > FMFGuard object in place -- CodeGenFunction::CGFPOptionsRAII(). So 
> > > setting FMF here will not affect anything but this CreateCall(). 
> > > 
> > > Does that match your understanding? Should we have an extra regression 
> > > test to make sure that does not change?
> > > 
> > > I am imagining something like:
> > > 
> > > ```
> > > double test_mm512_reduce_add_pd(__m512d __W, double ExtraAddOp) {
> > >   double S = _mm512_reduce_add_pd(__W) + ExtraAddOp;
> > >   return S;
> > > }
> > > 
> > > ```
> > > 
> > > Then we could confirm that `reassoc` is not applied to the `fadd` that 
> > > follows the reduction call.
> > Currently (and we could say that this is an LLVM codegen bug), we will not 
> > generate the optimal/expected reduction with `reassoc` alone.
> > 
> > I think the x86 reduction definition is implicitly assuming that -0.0 is 
> > not meaningful here, so we should add `nsz` too.
> > 
> > The backend is expecting an explicit `nsz` on this op. Ie, I see this x86 
> > asm currently with only `reassoc`:
> > 
> > ```
> > vextractf64x4   $1, %zmm0, %ymm1
> > vaddpd  %zmm1, %zmm0, %zmm0
> > vextractf128$1, %ymm0, %xmm1
> > vaddpd  %xmm1, %xmm0, %xmm0
> > vpermilpd   $1, %xmm0, %xmm1  
> > vaddsd  %xmm1, %xmm0, %xmm0 
> > vxorpd  %xmm1, %xmm1, %xmm1   <--- create 0.0
> > vaddsd  %xmm1, %xmm0, %xmm0   <--- add it to the reduction result
> > ```
> > 
> > Alternatively (and I'm not sure where it is specified), we could replace 
> > the default 0.0 argument with -0.0?
> Confirmed by new tests.
I think there's no such assumption for fadd/fmul instructions. We do have it 
for fmin/fmax. So I think we don't need to add nsz here.



Comment at: clang/lib/Headers/avx512fintrin.h:9304
+ * For floating points type, we always assume the elements are reassociable 
even
+ * if -fast-math is off.
+

spatel wrote:
> Also mention that sign of zero is indeterminate. We might use the LangRef 
> text as a model for what to say here:
> https://llvm.org/docs/LangRef.html#llvm-vector-reduce-fadd-intrinsic
Got it. Thanks!



Comment at: clang/lib/Headers/avx512fintrin.h:9352
 static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_add_pd(__m512d 
__W) {
   return __builtin_ia32_reduce_fadd_pd512(0.0, __W);
 }

spatel wrote:
> Ah - this is where the +0.0 is specified. This should be -0.0. We could still 
> add 'nsz' flag to be safe.
-0.0 can fix the problem. But we don't need to add 

[PATCH] D96032: [flang][driver] Add support for -fopenmp and -fopenacc

2021-02-09 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 322347.
FarisRehman marked 3 inline comments as done.
FarisRehman added a comment.

Address review comment

Address review comment by @awarzynski


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96032

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/OpenACC/acc-atomic-validity.f90
  flang/test/Semantics/OpenACC/acc-branch.f90
  flang/test/Semantics/OpenACC/acc-cache-validity.f90
  flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90
  flang/test/Semantics/OpenACC/acc-data.f90
  flang/test/Semantics/OpenACC/acc-declare-validity.f90
  flang/test/Semantics/OpenACC/acc-host-data.f90
  flang/test/Semantics/OpenACC/acc-init-validity.f90
  flang/test/Semantics/OpenACC/acc-kernels-loop.f90
  flang/test/Semantics/OpenACC/acc-kernels.f90
  flang/test/Semantics/OpenACC/acc-loop.f90
  flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90
  flang/test/Semantics/OpenACC/acc-parallel.f90
  flang/test/Semantics/OpenACC/acc-resolve01.f90
  flang/test/Semantics/OpenACC/acc-resolve02.f90
  flang/test/Semantics/OpenACC/acc-routine-validity.f90
  flang/test/Semantics/OpenACC/acc-serial-loop.f90
  flang/test/Semantics/OpenACC/acc-serial.f90
  flang/test/Semantics/OpenACC/acc-set-validity.f90
  flang/test/Semantics/OpenACC/acc-shutdown-validity.f90
  flang/test/Semantics/OpenACC/acc-update-validity.f90
  flang/test/Semantics/OpenACC/acc-wait-validity.f90
  flang/test/Semantics/omp-atomic.f90
  flang/test/Semantics/omp-combined-constructs.f90
  flang/test/Semantics/omp-copyin01.f90
  flang/test/Semantics/omp-copyin02.f90
  flang/test/Semantics/omp-copyin03.f90
  flang/test/Semantics/omp-copyin04.f90
  flang/test/Semantics/omp-copyin05.f90
  flang/test/Semantics/omp-declarative-directive.f90
  flang/test/Semantics/omp-default.f90
  flang/test/Semantics/omp-default02.f90
  flang/test/Semantics/omp-depend01.f90
  flang/test/Semantics/omp-depend02.f90
  flang/test/Semantics/omp-depend03.f90
  flang/test/Semantics/omp-device-constructs.f90
  flang/test/Semantics/omp-do-collapse-positivecases.f90
  flang/test/Semantics/omp-do-collapse.f90
  flang/test/Semantics/omp-do-cycle.f90
  flang/test/Semantics/omp-do-ordered-positivecases.f90
  flang/test/Semantics/omp-do-ordered.f90
  flang/test/Semantics/omp-do-schedule01.f90
  flang/test/Semantics/omp-do-schedule02.f90
  flang/test/Semantics/omp-do01.f90
  flang/test/Semantics/omp-do02.f90
  flang/test/Semantics/omp-do03.f90
  flang/test/Semantics/omp-do04.f90
  flang/test/Semantics/omp-do05.f90
  flang/test/Semantics/omp-do06.f90
  flang/test/Semantics/omp-do07.f90
  flang/test/Semantics/omp-do08.f90
  flang/test/Semantics/omp-do09.f90
  flang/test/Semantics/omp-do10.f90
  flang/test/Semantics/omp-flush01.f90
  flang/test/Semantics/omp-invalid-branch.f90
  flang/test/Semantics/omp-loop-association.f90
  flang/test/Semantics/omp-loop-simd01.f90
  flang/test/Semantics/omp-nested01.f90
  flang/test/Semantics/omp-no-dowhile-in-parallel.f90
  flang/test/Semantics/omp-parallel-private01.f90
  flang/test/Semantics/omp-parallel-private02.f90
  flang/test/Semantics/omp-parallel-private03.f90
  flang/test/Semantics/omp-parallel-private04.f90
  flang/test/Semantics/omp-parallel-shared01.f90
  flang/test/Semantics/omp-parallel-shared02.f90
  flang/test/Semantics/omp-parallel-shared03.f90
  flang/test/Semantics/omp-parallel-shared04.f90
  flang/test/Semantics/omp-parallel01.f90
  flang/test/Semantics/omp-parallel02.f90
  flang/test/Semantics/omp-private01.f90
  flang/test/Semantics/omp-private02.f90
  flang/test/Semantics/omp-private03.f90
  flang/test/Semantics/omp-resolve01.f90
  flang/test/Semantics/omp-resolve02.f90
  flang/test/Semantics/omp-resolve03.f90
  flang/test/Semantics/omp-resolve04.f90
  flang/test/Semantics/omp-resolve05.f90
  flang/test/Semantics/omp-sections01.f90
  flang/test/Semantics/omp-simd01.f90
  flang/test/Semantics/omp-simd02.f90
  flang/test/Semantics/omp-simd03.f90
  flang/test/Semantics/omp-single01.f90
  flang/test/Semantics/omp-single02.f90
  flang/test/Semantics/omp-task01.f90
  flang/test/Semantics/omp-taskloop-simd01.f90
  flang/test/Semantics/omp-taskloop01.f90
  flang/test/Semantics/omp-taskloop02.f90
  flang/test/Semantics/omp-taskloop03.f90
  flang/test/Semantics/omp-workshare01.f90
  flang/test/Semantics/omp-workshare02.f90
  flang/test/Semantics/omp-workshare03.f90
  flang/test/Semantics/omp-workshare04.f90
  flang/test/Semantics/omp-workshare05.f90

Index: flang/test/Semantics/omp-workshare05.f90

[PATCH] D96032: [flang][driver] Add support for -fopenmp and -fopenacc

2021-02-09 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman added inline comments.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:25-26
   Args.AddAllArgs(CmdArgs, {options::OPT_ffixed_form, options::OPT_ffree_form,
-options::OPT_ffixed_line_length_EQ});
+options::OPT_ffixed_line_length_EQ,
++options::OPT_fopenmp, options::OPT_fopenacc});
 }

awarzynski wrote:
> `-fopenmp` and `-fopenacc` enable extensions, so they are not dialect options.
I decided to add this here as it is listed under "Fortran Dialect Options" in 
the gfortran documentation: 
https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96032

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


[PATCH] D96231: [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96231

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


[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-02-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D95534#2534510 , @smeenai wrote:

> I saw this on LLVM Weekly, and I like it a lot :)
>
> Now if only Windows could case-correct their SDKs so we didn't need VFS 
> overlays and symlinks for the linker...

We use ciopfs for this, 
https://source.chromium.org/chromium/chromium/src/+/master:build/vs_toolchain.py;l=485?q=ciopfs
 That code has worked without changes for the last 2.5 years.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95534

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


[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-02-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> We use ciopfs for this, 
> https://source.chromium.org/chromium/chromium/src/+/master:build/vs_toolchain.py;l=485?q=ciopfs
>  That code has worked without changes for the last 2.5 years.

(ciopfs is user-space, so it can be set up transparently by a normal post-pull 
hook and this doesn't need any manual setup by devs or bots.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95534

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


[PATCH] D96032: [flang][driver] Add support for -fopenmp and -fopenacc

2021-02-09 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added inline comments.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:25-26
   Args.AddAllArgs(CmdArgs, {options::OPT_ffixed_form, options::OPT_ffree_form,
-options::OPT_ffixed_line_length_EQ});
+options::OPT_ffixed_line_length_EQ,
++options::OPT_fopenmp, options::OPT_fopenacc});
 }

FarisRehman wrote:
> awarzynski wrote:
> > `-fopenmp` and `-fopenacc` enable extensions, so they are not dialect 
> > options.
> I decided to add this here as it is listed under "Fortran Dialect Options" in 
> the gfortran documentation: 
> https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html 
Makes sense, thanks for clarifying!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96032

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


[clang] dd2460e - [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

2021-02-09 Thread via cfe-commits
Author: Wang, Pengfei
Date: 2021-02-09T21:14:06+08:00
New Revision: dd2460ed5d77d908327ce29a15630cd3268bd76e

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

LOG: [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

Intrinsics *reduce_add/mul_ps/pd have assumption that the elements in
the vector are reassociable. So we need to always assign the reassoc
flag when we call _mm_reduce_* intrinsics.

Reviewed By: spatel

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/avx512fintrin.h
clang/test/CodeGen/X86/avx512-reduceIntrin.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4ff84ce8b79f..f7a4295b11c5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13826,12 +13826,14 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_reduce_fadd_ps512: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fadd, Ops[1]->getType());
+Builder.getFastMathFlags().setAllowReassoc(true);
 return Builder.CreateCall(F, {Ops[0], Ops[1]});
   }
   case X86::BI__builtin_ia32_reduce_fmul_pd512:
   case X86::BI__builtin_ia32_reduce_fmul_ps512: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fmul, Ops[1]->getType());
+Builder.getFastMathFlags().setAllowReassoc(true);
 return Builder.CreateCall(F, {Ops[0], Ops[1]});
   }
   case X86::BI__builtin_ia32_reduce_mul_d512:

diff  --git a/clang/lib/Headers/avx512fintrin.h 
b/clang/lib/Headers/avx512fintrin.h
index 2ee4350b14d4..f226382cbb2c 100644
--- a/clang/lib/Headers/avx512fintrin.h
+++ b/clang/lib/Headers/avx512fintrin.h
@@ -9297,9 +9297,12 @@ _mm512_mask_abs_pd(__m512d __W, __mmask8 __K, __m512d 
__A)
 
 /* Vector-reduction arithmetic accepts vectors as inputs and produces scalars 
as
  * outputs. This class of vector operation forms the basis of many scientific
- * computations. In vector-reduction arithmetic, the evaluation off is
+ * computations. In vector-reduction arithmetic, the evaluation order is
  * independent of the order of the input elements of V.
 
+ * For floating point types, we always assume the elements are reassociable 
even
+ * if -fast-math is off.
+
  * Used bisection method. At each step, we partition the vector with previous
  * step in half, and the operation is performed on its two halves.
  * This takes log2(n) steps where n is the number of elements in the vector.
@@ -9345,8 +9348,11 @@ _mm512_mask_reduce_or_epi64(__mmask8 __M, __m512i __W) {
   return __builtin_ia32_reduce_or_q512(__W);
 }
 
+// -0.0 is used to ignore the start value since it is the neutral value of
+// floating point addition. For more information, please refer to
+// https://llvm.org/docs/LangRef.html#llvm-vector-reduce-fadd-intrinsic
 static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_add_pd(__m512d 
__W) {
-  return __builtin_ia32_reduce_fadd_pd512(0.0, __W);
+  return __builtin_ia32_reduce_fadd_pd512(-0.0, __W);
 }
 
 static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_mul_pd(__m512d 
__W) {
@@ -9356,7 +9362,7 @@ static __inline__ double __DEFAULT_FN_ATTRS512 
_mm512_reduce_mul_pd(__m512d __W)
 static __inline__ double __DEFAULT_FN_ATTRS512
 _mm512_mask_reduce_add_pd(__mmask8 __M, __m512d __W) {
   __W = _mm512_maskz_mov_pd(__M, __W);
-  return __builtin_ia32_reduce_fadd_pd512(0.0, __W);
+  return __builtin_ia32_reduce_fadd_pd512(-0.0, __W);
 }
 
 static __inline__ double __DEFAULT_FN_ATTRS512
@@ -9411,7 +9417,7 @@ _mm512_mask_reduce_or_epi32(__mmask16 __M, __m512i __W) {
 
 static __inline__ float __DEFAULT_FN_ATTRS512
 _mm512_reduce_add_ps(__m512 __W) {
-  return __builtin_ia32_reduce_fadd_ps512(0.0f, __W);
+  return __builtin_ia32_reduce_fadd_ps512(-0.0f, __W);
 }
 
 static __inline__ float __DEFAULT_FN_ATTRS512
@@ -9422,7 +9428,7 @@ _mm512_reduce_mul_ps(__m512 __W) {
 static __inline__ float __DEFAULT_FN_ATTRS512
 _mm512_mask_reduce_add_ps(__mmask16 __M, __m512 __W) {
   __W = _mm512_maskz_mov_ps(__M, __W);
-  return __builtin_ia32_reduce_fadd_ps512(0.0f, __W);
+  return __builtin_ia32_reduce_fadd_ps512(-0.0f, __W);
 }
 
 static __inline__ float __DEFAULT_FN_ATTRS512

diff  --git a/clang/test/CodeGen/X86/avx512-reduceIntrin.c 
b/clang/test/CodeGen/X86/avx512-reduceIntrin.c
index d8a1130f3cef..62580ca1914e 100644
--- a/clang/test/CodeGen/X86/avx512-reduceIntrin.c
+++ b/clang/test/CodeGen/X86/avx512-reduceIntrin.c
@@ -11,13 +11,13 @@ long long test_mm512_reduce_add_epi64(__m512i __W){
 long long test_mm512_reduce_mul_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_epi64(
 // CHECK:call i64 @llvm.vector.reduce.mul.v8i64(<8 x i64> %{

[PATCH] D96231: [X86] Always assign reassoc flag for intrinsics *reduce_add/mul_ps/pd.

2021-02-09 Thread Pengfei Wang 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 rGdd2460ed5d77: [X86] Always assign reassoc flag for 
intrinsics *reduce_add/mul_ps/pd. (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96231

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fintrin.h
  clang/test/CodeGen/X86/avx512-reduceIntrin.c

Index: clang/test/CodeGen/X86/avx512-reduceIntrin.c
===
--- clang/test/CodeGen/X86/avx512-reduceIntrin.c
+++ clang/test/CodeGen/X86/avx512-reduceIntrin.c
@@ -11,13 +11,13 @@
 long long test_mm512_reduce_mul_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_epi64(
 // CHECK:call i64 @llvm.vector.reduce.mul.v8i64(<8 x i64> %{{.*}})
-  return _mm512_reduce_mul_epi64(__W); 
+  return _mm512_reduce_mul_epi64(__W);
 }
 
 long long test_mm512_reduce_or_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_or_epi64(
 // CHECK:call i64 @llvm.vector.reduce.or.v8i64(<8 x i64> %{{.*}})
-  return _mm512_reduce_or_epi64(__W); 
+  return _mm512_reduce_or_epi64(__W);
 }
 
 long long test_mm512_reduce_and_epi64(__m512i __W){
@@ -31,7 +31,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.add.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_add_epi64(__M, __W); 
+  return _mm512_mask_reduce_add_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_mul_epi64(__mmask8 __M, __m512i __W){
@@ -39,7 +39,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.mul.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_mul_epi64(__M, __W); 
+  return _mm512_mask_reduce_mul_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_and_epi64(__mmask8 __M, __m512i __W){
@@ -47,7 +47,7 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.and.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_and_epi64(__M, __W); 
+  return _mm512_mask_reduce_and_epi64(__M, __W);
 }
 
 long long test_mm512_mask_reduce_or_epi64(__mmask8 __M, __m512i __W){
@@ -55,30 +55,30 @@
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
 // CHECK:call i64 @llvm.vector.reduce.or.v8i64(<8 x i64> %{{.*}})
-  return _mm512_mask_reduce_or_epi64(__M, __W); 
+  return _mm512_mask_reduce_or_epi64(__M, __W);
 }
 
 int test_mm512_reduce_add_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_add_epi32(
 // CHECK:call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_add_epi32(__W); 
+  return _mm512_reduce_add_epi32(__W);
 }
 
 int test_mm512_reduce_mul_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_mul_epi32(
 // CHECK:call i32 @llvm.vector.reduce.mul.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_mul_epi32(__W); 
+  return _mm512_reduce_mul_epi32(__W);
 }
 
 int test_mm512_reduce_or_epi32(__m512i __W){
 // CHECK:call i32 @llvm.vector.reduce.or.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_or_epi32(__W); 
+  return _mm512_reduce_or_epi32(__W);
 }
 
 int test_mm512_reduce_and_epi32(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_and_epi32(
 // CHECK:call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> %{{.*}})
-  return _mm512_reduce_and_epi32(__W); 
+  return _mm512_reduce_and_epi32(__W);
 }
 
 int test_mm512_mask_reduce_add_epi32(__mmask16 __M, __m512i __W){
@@ -86,7 +86,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_add_epi32(__M, __W); 
+  return _mm512_mask_reduce_add_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_mul_epi32(__mmask16 __M, __m512i __W){
@@ -94,7 +94,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.mul.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_mul_epi32(__M, __W); 
+  return _mm512_mask_reduce_mul_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_and_epi32(__mmask16 __M, __m512i __W){
@@ -102,7 +102,7 @@
 // CHECK:bitcast i16 %{{.*}} to <16 x i1>
 // CHECK:select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
 // CHECK:call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> %{{.*}})
-  return _mm512_mask_reduce_and_epi32(__M, __W); 
+  return _mm512_mask_reduce_and_epi32(__M, __W);
 }
 
 int test_mm512_mask_reduce_or_epi32(__mmask16 __M, _

[PATCH] D93179: [X86] Convert fmin/fmax _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)

2021-02-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@pengfei Would you be happy to commandeer this patch to make it match D96231 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93179

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 322357.
whisperity added a comment.

Made detection of macros as "parameter type names" more robust.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -0,0 +1,148 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"} \
+// RUN:  ]}' -- -x c
+
+#define bool _Bool
+#define true 1
+#define false 0
+
+typedef bool MyBool;
+
+#define TheLogicalType bool
+
+void declVoid(void); // NO-WARN: Declaration only.
+void decl(); // NO-WARN: Declaration only.
+void oneParam(int I) {}  // NO-WARN: 1 parameter.
+void variadic(int I, ...) {} // NO-WARN: 1 visible parameter.
+
+void trivial(int I, int J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'trivial' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:25: note: the last parameter in the range is 'J'
+
+void qualifier(int I, const int CI) {} // NO-WARN: Distinct types.
+
+void restrictQualifier(char *restrict CPR1, char *restrict CPR2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 2 adjacent parameters of 'restrictQualifier' of similar type ('char *restrict')
+// CHECK-MESSAGES: :[[@LINE-2]]:39: note: the first parameter in the range is 'CPR1'
+// CHECK-MESSAGES: :[[@LINE-3]]:60: note: the last parameter in the range is 'CPR2'
+
+void pointer1(int *IP1, int *IP2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'pointer1' of similar type ('int *')
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: the first parameter in the range is 'IP1'
+// CHECK-MESSAGES: :[[@LINE-3]]:30: note: the last parameter in the range is 'IP2'
+
+void pointerConversion(int *IP, long *LP) {}
+// NO-WARN: Even though C can convert any T* to U* back and forth, compiler
+// warnings already exist for this.
+
+void testVariadicsCall() {
+  int IVal = 1;
+  decl(IVal); // NO-WARN: Particular calls to "variadics" are like template
+  // instantiations, and we do not model them.
+
+  variadic(IVal);  // NO-WARN.
+  variadic(IVal, 2, 3, 4); // NO-WARN.
+}
+
+struct S {};
+struct T {};
+
+void taggedTypes1(struct S SVar, struct T TVar) {} // NO-WARN: Distinct types.
+
+void taggedTypes2(struct S SVar1, struct S SVar2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 2 adjacent parameters of 'taggedTypes2' of similar type ('struct S')
+// CHECK-MESSAGES: :[[@LINE-2]]:28: note: the first parameter in the range is 'SVar1'
+// CHECK-MESSAGES: :[[@LINE-3]]:44: note: the last parameter in the range is 'SVar2'
+
+void wrappers(struct { int I; } I1, struct { int I; } I2) {} // NO-WARN: Distinct anonymous types.
+
+void knr(I, J)
+  int I;
+  int J;
+{}
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 2 adjacent parameters of 'knr' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the last parameter in the range is 'J'
+
+void boolAsWritten(bool B1, bool B2) {} // NO-WARN: The type name is ignored.
+// Note that "bool" is a macro that expands to "_Bool" internally, but it is
+// only "bool" that is ignored from the two.
+
+void underscoreBoolAsWritten(_Bool B1, _Bool B2) {}
+// Even though it is "_Bool" that is written in the code, the diagnostic message
+// respects the printing policy as defined by the compilatio

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:255
+  std::string NodeTypeName =
+  Node->getType().getAsString(Node->getASTContext().getPrintingPolicy());
+  StringRef CaptureName{NodeTypeName};

whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > whisperity wrote:
> > > > aaron.ballman wrote:
> > > > > Hmm, one downside to using the printing policy to get the node name 
> > > > > is that there can be alternative spellings for the same type that the 
> > > > > user might reasonably expect to be applied. e.g., if the user expects 
> > > > > to ignore `bool` datatypes and the printing policy wants to spell the 
> > > > > type as `_Bool`, this won't behave as expected.
> > > > But then the diagnostic is inconsistent with what the compiler is 
> > > > configured to output as diagnostics, isn't it? Can I stringify through 
> > > > Clang with some "default" printing policy?
> > > The situation I'm worried about is something like this in C code:
> > > ```
> > > #include 
> > > 
> > > void func(bool b, bool c) {}
> > > ```
> > > because the `bool` in the function signature will expand to `_Bool` after 
> > > the preprocessor gets to it (because of the contents of ``). 
> > > If the user writes `bool` in their configuration file because that's what 
> > > they've written in their function signatures, will this fail because the 
> > > printing policy says it should be `_Bool`?
> > > 
> > > Along similar lines, I wonder about things like `struct S` vs `S` (in C), 
> > > `signed char` vs `char`, types within anonymous namespaces (where we 
> > > print ``), etc. Basically, any time when the 
> > > printing policy may differ from what the user lexically writes in code.
> > Meanwhile, I realised we are talking of two entirely distinct things. I 
> > will look into how this `PrintingPolicy` stuff works... I agree that the 
> > ignore rules (where the comment was originally posted) should respect the 
> > text written into the code as-is. The diagnostics printing type names could 
> > continue using the proper printing policy (to be in line with how Sema 
> > diagnoses, AFAIK).
> Right, @aaron.ballman I think I got this tested. Please check the C test 
> file. `bool` becomes `_Bool` in C code by the preprocessor, but the printing 
> policy still says both should be printed as `bool`. I added some test cases 
> about this. It is weird, because without doing some extra magic specifically 
> against macros (which might break detecting type names in other locations), I 
> can't really test ignoring `_Bool` but not ignoring `bool`. Now, the 
> diagnostics respect the printing policy, but the type names are taken with an 
> empty printing policy, which //should// give us the result as-is in the code. 
> Unfortunately, "as-is" still means `_Bool` for `bool`'s case, so even if you 
> ignore `bool`, you will still get results where `bool` is written, because 
> `bool` is a macro (Tidy automatically puts a note about this!) and the real 
> type is `_Bool`, as per the macro expansion.
> 
> Wow... okay, that explanation got convoluted.
> Anyways, it's //really weird//. But: we no longer take the actual printing 
> policy anymore, but the default, which should eliminate all these cases.
> The `bool`/`_Bool` case doesn't fail because of the printing policy, it fails 
> because `bool` is a macro in ``.
> 
> Also, the type name ignore list not a full match, but a //substring match// 
> ignore list. So if you have a type named `struct Foo`, if you ignore `Foo`, 
> both `struct Foo`, `Foo`, `MyFoo`, etc. will be also ignored. And it's case 
> sensitive.
Nevermind, I think I figured this out... or at least managed to figure it out 
partially... This "SpellingLoc" and "ExpansionLoc" and all this stuff is really 
convoluted, and there doesn't seem to be any good documentation for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[PATCH] D90851: [clang-tidy] Extending bugprone-signal-handler with POSIX functions.

2021-02-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 322362.
balazske added a comment.

Added `quick_exit` to POSIX-allowed set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90851

Files:
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-handler.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-other.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/unistd.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
@@ -1,8 +1,9 @@
-// RUN: %check_clang_tidy %s cert-sig30-c %t -- -- -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s bugprone-signal-handler %t -- -- -isystem %S/Inputs/Headers
 
 #include "signal.h"
-#include "stdio.h"
 #include "stdlib.h"
+#include "stdio.h"
+#include "system-other.h"
 
 // The function should be classified as system call even if there is
 // declaration the in source file.
@@ -16,17 +17,9 @@
   abort();
 }
 
-void handler__Exit(int) {
-  _Exit(0);
-}
-
-void handler_quick_exit(int) {
-  quick_exit(0);
-}
-
 void handler_other(int) {
   printf("1234");
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void handler_signal(int) {
@@ -40,7 +33,7 @@
 
 void f_bad() {
   printf("1234");
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void f_extern();
@@ -55,13 +48,11 @@
 
 void handler_extern(int) {
   f_extern();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void test() {
   signal(SIGINT, handler_abort);
-  signal(SIGINT, handler__Exit);
-  signal(SIGINT, handler_quick_exit);
   signal(SIGINT, handler_signal);
   signal(SIGINT, handler_other);
 
@@ -69,9 +60,9 @@
   signal(SIGINT, handler_bad);
   signal(SIGINT, handler_extern);
 
-  signal(SIGINT, quick_exit);
+  signal(SIGINT, _Exit);
   signal(SIGINT, other_call);
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 
   signal(SIGINT, SIG_IGN);
   signal(SIGINT, SIG_DFL);
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s bugprone-signal-handler %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: bugprone-signal-handler.AsyncSafeFunctionSet, value: "POSIX"}]}' \
+// RUN: -- -isystem %S/Inputs/Headers
+
+#include "signal.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "unistd.h"
+
+void handler_bad(int) {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+}
+
+void handler_good(int) {
+  abort();
+  _Exit(0);
+  _exit(0);
+  quick_exit(0);
+  signal(0, SIG_DFL);
+  memcpy((void*)10, (const void*)20, 1);
+}
+
+void test() {
+  signal(SIGINT, handler_good);
+  signal(SIGINT, handler_bad);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c
===
--- /dev/null
+++ clang-tools-e

[PATCH] D90851: [clang-tidy] Extending bugprone-signal-handler with POSIX functions.

2021-02-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 322364.
balazske added a comment.

Update relative to previous commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90851

Files:
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-handler.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-other.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/unistd.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
@@ -1,8 +1,9 @@
-// RUN: %check_clang_tidy %s cert-sig30-c %t -- -- -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s bugprone-signal-handler %t -- -- -isystem %S/Inputs/Headers
 
 #include "signal.h"
-#include "stdio.h"
 #include "stdlib.h"
+#include "stdio.h"
+#include "system-other.h"
 
 // The function should be classified as system call even if there is
 // declaration the in source file.
@@ -16,17 +17,9 @@
   abort();
 }
 
-void handler__Exit(int) {
-  _Exit(0);
-}
-
-void handler_quick_exit(int) {
-  quick_exit(0);
-}
-
 void handler_other(int) {
   printf("1234");
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void handler_signal(int) {
@@ -40,7 +33,7 @@
 
 void f_bad() {
   printf("1234");
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void f_extern();
@@ -55,13 +48,11 @@
 
 void handler_extern(int) {
   f_extern();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 }
 
 void test() {
   signal(SIGINT, handler_abort);
-  signal(SIGINT, handler__Exit);
-  signal(SIGINT, handler_quick_exit);
   signal(SIGINT, handler_signal);
   signal(SIGINT, handler_other);
 
@@ -69,9 +60,9 @@
   signal(SIGINT, handler_bad);
   signal(SIGINT, handler_extern);
 
-  signal(SIGINT, quick_exit);
+  signal(SIGINT, _Exit);
   signal(SIGINT, other_call);
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
 
   signal(SIGINT, SIG_IGN);
   signal(SIGINT, SIG_DFL);
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s bugprone-signal-handler %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: bugprone-signal-handler.AsyncSafeFunctionSet, value: "POSIX"}]}' \
+// RUN: -- -isystem %S/Inputs/Headers
+
+#include "signal.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "unistd.h"
+
+void handler_bad(int) {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+}
+
+void handler_good(int) {
+  abort();
+  _Exit(0);
+  _exit(0);
+  quick_exit(0);
+  signal(0, SIG_DFL);
+  memcpy((void*)10, (const void*)20, 1);
+}
+
+void test() {
+  signal(SIGINT, handler_good);
+  signal(SIGINT, handler_bad);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c
===
--- /dev/null
+++ clang-tools-extra/

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-02-09 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 322363.
whisperity added a comment.

**NFC** (With all the restructuring and trying to figure out how to implement 
the latest change, I managed to upload the wrong, unclean diff...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -0,0 +1,148 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"} \
+// RUN:  ]}' -- -x c
+
+#define bool _Bool
+#define true 1
+#define false 0
+
+typedef bool MyBool;
+
+#define TheLogicalType bool
+
+void declVoid(void); // NO-WARN: Declaration only.
+void decl(); // NO-WARN: Declaration only.
+void oneParam(int I) {}  // NO-WARN: 1 parameter.
+void variadic(int I, ...) {} // NO-WARN: 1 visible parameter.
+
+void trivial(int I, int J) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'trivial' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:25: note: the last parameter in the range is 'J'
+
+void qualifier(int I, const int CI) {} // NO-WARN: Distinct types.
+
+void restrictQualifier(char *restrict CPR1, char *restrict CPR2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 2 adjacent parameters of 'restrictQualifier' of similar type ('char *restrict')
+// CHECK-MESSAGES: :[[@LINE-2]]:39: note: the first parameter in the range is 'CPR1'
+// CHECK-MESSAGES: :[[@LINE-3]]:60: note: the last parameter in the range is 'CPR2'
+
+void pointer1(int *IP1, int *IP2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'pointer1' of similar type ('int *')
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: the first parameter in the range is 'IP1'
+// CHECK-MESSAGES: :[[@LINE-3]]:30: note: the last parameter in the range is 'IP2'
+
+void pointerConversion(int *IP, long *LP) {}
+// NO-WARN: Even though C can convert any T* to U* back and forth, compiler
+// warnings already exist for this.
+
+void testVariadicsCall() {
+  int IVal = 1;
+  decl(IVal); // NO-WARN: Particular calls to "variadics" are like template
+  // instantiations, and we do not model them.
+
+  variadic(IVal);  // NO-WARN.
+  variadic(IVal, 2, 3, 4); // NO-WARN.
+}
+
+struct S {};
+struct T {};
+
+void taggedTypes1(struct S SVar, struct T TVar) {} // NO-WARN: Distinct types.
+
+void taggedTypes2(struct S SVar1, struct S SVar2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 2 adjacent parameters of 'taggedTypes2' of similar type ('struct S')
+// CHECK-MESSAGES: :[[@LINE-2]]:28: note: the first parameter in the range is 'SVar1'
+// CHECK-MESSAGES: :[[@LINE-3]]:44: note: the last parameter in the range is 'SVar2'
+
+void wrappers(struct { int I; } I1, struct { int I; } I2) {} // NO-WARN: Distinct anonymous types.
+
+void knr(I, J)
+  int I;
+  int J;
+{}
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 2 adjacent parameters of 'knr' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-4]]:7: note: the last parameter in the range is 'J'
+
+void boolAsWritten(bool B1, bool B2) {} // NO-WARN: The type name is ignored.
+// Note that "bool" is a macro that expands to "_Bool" internally, but it is
+// only "bool" that is ignored from the two.
+
+void underscoreBoolAsWritten(_Bool B1, _Bool B2) {}
+// Even though it is "_Bool" that is written in the code, th

[PATCH] D96274: [clang][cli] Generate and round-trip Diagnostic options

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 322365.
jansvoboda11 added a comment.

Remove the need for {Warnings,Remarks}AsWritten field


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96274

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -726,17 +726,17 @@
   for (auto *A : Args.filtered(Group)) {
 if (A->getOption().getKind() == Option::FlagClass) {
   // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
-  // its name (minus the "W" or "R" at the beginning) to the warning list.
+  // its name (minus the "W" or "R" at the beginning) to the diagnostics.
   Diagnostics.push_back(
   std::string(A->getOption().getName().drop_front(1)));
 } else if (A->getOption().matches(GroupWithValue)) {
-  // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic group.
+  // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic
+  // group. Add only the group name to the diagnostics.
   Diagnostics.push_back(
   std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
 } else {
   // Otherwise, add its value (for OPT_W_Joined and similar).
-  for (const auto *Arg : A->getValues())
-Diagnostics.emplace_back(Arg);
+  Diagnostics.push_back(A->getValue());
 }
   }
 }
@@ -2169,6 +2169,66 @@
   return Success;
 }
 
+void CompilerInvocation::GenerateDiagnosticArgs(
+const DiagnosticOptions &Opts, SmallVectorImpl &Args,
+StringAllocator SA, bool DefaultDiagColor) {
+  const DiagnosticOptions *DiagnosticOpts = &Opts;
+#define DIAG_OPTION_WITH_MARSHALLING(  \
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+MERGER, EXTRACTOR, TABLE_INDEX)\
+  GENERATE_OPTION_WITH_MARSHALLING(\
+  Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,\
+  IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef DIAG_OPTION_WITH_MARSHALLING
+
+  if (!Opts.DiagnosticSerializationFile.empty())
+GenerateArg(Args, OPT_diagnostic_serialized_file,
+Opts.DiagnosticSerializationFile, SA);
+
+  if (Opts.ShowColors)
+GenerateArg(Args, OPT_fcolor_diagnostics, SA);
+
+  if (Opts.CLFallbackMode)
+GenerateArg(Args, OPT_fdiagnostics_format, "msvc-fallback", SA);
+
+  if (Opts.VerifyDiagnostics &&
+  llvm::is_contained(Opts.VerifyPrefixes, "expected"))
+GenerateArg(Args, OPT_verify, SA);
+
+  for (const auto &Prefix : Opts.VerifyPrefixes)
+if (Prefix != "expected")
+  GenerateArg(Args, OPT_verify_EQ, Prefix, SA);
+
+  DiagnosticLevelMask VIU = Opts.getVerifyIgnoreUnexpected();
+  if (VIU == DiagnosticLevelMask::None) {
+// This is the default, don't generate anything.
+  } else if (VIU == DiagnosticLevelMask::All) {
+GenerateArg(Args, OPT_verify_ignore_unexpected, SA);
+  } else {
+if (static_cast(VIU & DiagnosticLevelMask::Note) != 0)
+  GenerateArg(Args, OPT_verify_ignore_unexpected_EQ, "note", SA);
+if (static_cast(VIU & DiagnosticLevelMask::Remark) != 0)
+  GenerateArg(Args, OPT_verify_ignore_unexpected_EQ, "remark", SA);
+if (static_cast(VIU & DiagnosticLevelMask::Warning) != 0)
+  GenerateArg(Args, OPT_verify_ignore_unexpected_EQ, "warning", SA);
+if (static_cast(VIU & DiagnosticLevelMask::Error) != 0)
+  GenerateArg(Args, OPT_verify_ignore_unexpected_EQ, "error", SA);
+  }
+
+  for (const auto &Warning : Opts.Warnings) {
+// This option is automatically generated from UndefPrefixes.
+if (Warning == "undef-prefix")
+  continue;
+Args.push_back(SA(StringRef("-W") + Warning));
+  }
+
+  for (const auto &Remark : Opts.Remarks)
+Args.push_back(SA(StringRef("-R") + Remark));
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
@@ -2207,6 +2267,7 @@
 Opts.CLFallbackMode = true;
 
   Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ);
+  Opts.VerifyPrefixes = Args.getAllArgValues(OPT_verify_EQ);
   if (Args.hasArg(OPT_verify))
 Opts.VerifyPrefixes.push_back("expected");
   // Keep VerifyPrefixes in its original order for the sake of diagnostics, and
@@ -22

[clang-tools-extra] 98146c1 - [clang-tidy] fix modernize-use-nullptr false positive with spaceship operator comparisons

2021-02-09 Thread Nathan James via cfe-commits
Author: poelmanc
Date: 2021-02-09T14:02:45Z
New Revision: 98146c1f5d0c772aec56149724119d49990f4d0c

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

LOG: [clang-tidy] fix modernize-use-nullptr false positive with spaceship 
operator comparisons

`clang-tidy -std=c++20` with `modernize-use-nullptr` mistakenly inserts 
`nullptr` in place of the comparison operator if the comparison internally 
expands in the AST to a rewritten spaceship operator. This can be reproduced by 
running the new `modernize-use-nullptr-cxx20.cpp` test without applying the 
supplied patch to `UseNullptrCheck.cpp`; the current clang-tidy will mistakenly 
replace:
```result = (a1 < a2);```
with
```result = (a1 nullptr a2);```

Reviewed By: njames93

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

Added: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index e32687ba7b35..5ca2be2eb556 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -41,12 +41,28 @@ StatementMatcher makeCastSequenceMatcher() {
   
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
+  auto IsOrHasDescendant = [](auto InnerMatcher) {
+return anyOf(InnerMatcher, hasDescendant(InnerMatcher));
+  };
+
   return traverse(
   TK_AsIs,
-  castExpr(anyOf(ImplicitCastToNull,
- explicitCastExpr(hasDescendant(ImplicitCastToNull))),
-   unless(hasAncestor(explicitCastExpr(
-  .bind(CastSequence));
+  anyOf(castExpr(anyOf(ImplicitCastToNull,
+   
explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+ unless(hasAncestor(explicitCastExpr())),
+ unless(hasAncestor(cxxRewrittenBinaryOperator(
+.bind(CastSequence),
+cxxRewrittenBinaryOperator(
+// Match rewritten operators, but verify (in the check method)
+// that if an implicit cast is found, it is not from another
+// nested rewritten operator.
+expr().bind("matchBinopOperands"),
+hasEitherOperand(IsOrHasDescendant(
+implicitCastExpr(
+ImplicitCastToNull,
+hasAncestor(cxxRewrittenBinaryOperator().bind(
+"checkBinopOperands")))
+.bind(CastSequence));
 }
 
 bool isReplaceableRange(SourceLocation StartLoc, SourceLocation EndLoc,
@@ -480,6 +496,11 @@ void UseNullptrCheck::check(const MatchFinder::MatchResult 
&Result) {
   const auto *NullCast = Result.Nodes.getNodeAs(CastSequence);
   assert(NullCast && "Bad Callback. No node provided");
 
+  if (Result.Nodes.getNodeAs(
+  "matchBinopOperands") !=
+  Result.Nodes.getNodeAs("checkBinopOperands"))
+return;
+
   // Given an implicit null-ptr cast or an explicit cast with an implicit
   // null-to-pointer cast within use CastSequenceVisitor to identify sequences
   // of explicit casts that can be converted into 'nullptr'.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
new file mode 100644
index ..b00cb5787ea0
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+  int *ptr = 0;
+  // CHECK-FIXES: int *ptr = nullptr;
+  result = (a1 > (ptr == 0 ? a1 : a2));
+  // CHECK-FIXES: result = (a1 > (ptr == nullptr ? a1 : a2));
+  result = (a1 > ((a1 > (ptr == 0 ? a1 : a2)) ? a1 : a2));
+  /

[PATCH] D95714: [clang-tidy] fix modernize-use-nullptr false positive with spaceship operator comparisons

2021-02-09 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98146c1f5d0c: [clang-tidy] fix modernize-use-nullptr false 
positive with spaceship operator… (authored by poelmanc, committed by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95714

Files:
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+  int *ptr = 0;
+  // CHECK-FIXES: int *ptr = nullptr;
+  result = (a1 > (ptr == 0 ? a1 : a2));
+  // CHECK-FIXES: result = (a1 > (ptr == nullptr ? a1 : a2));
+  result = (a1 > ((a1 > (ptr == 0 ? a1 : a2)) ? a1 : a2));
+  // CHECK-FIXES: result = (a1 > ((a1 > (ptr == nullptr ? a1 : a2)) ? a1 : 
a2));
+}
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -41,12 +41,28 @@
   
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
+  auto IsOrHasDescendant = [](auto InnerMatcher) {
+return anyOf(InnerMatcher, hasDescendant(InnerMatcher));
+  };
+
   return traverse(
   TK_AsIs,
-  castExpr(anyOf(ImplicitCastToNull,
- explicitCastExpr(hasDescendant(ImplicitCastToNull))),
-   unless(hasAncestor(explicitCastExpr(
-  .bind(CastSequence));
+  anyOf(castExpr(anyOf(ImplicitCastToNull,
+   
explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+ unless(hasAncestor(explicitCastExpr())),
+ unless(hasAncestor(cxxRewrittenBinaryOperator(
+.bind(CastSequence),
+cxxRewrittenBinaryOperator(
+// Match rewritten operators, but verify (in the check method)
+// that if an implicit cast is found, it is not from another
+// nested rewritten operator.
+expr().bind("matchBinopOperands"),
+hasEitherOperand(IsOrHasDescendant(
+implicitCastExpr(
+ImplicitCastToNull,
+hasAncestor(cxxRewrittenBinaryOperator().bind(
+"checkBinopOperands")))
+.bind(CastSequence));
 }
 
 bool isReplaceableRange(SourceLocation StartLoc, SourceLocation EndLoc,
@@ -480,6 +496,11 @@
   const auto *NullCast = Result.Nodes.getNodeAs(CastSequence);
   assert(NullCast && "Bad Callback. No node provided");
 
+  if (Result.Nodes.getNodeAs(
+  "matchBinopOperands") !=
+  Result.Nodes.getNodeAs("checkBinopOperands"))
+return;
+
   // Given an implicit null-ptr cast or an explicit cast with an implicit
   // null-to-pointer cast within use CastSequenceVisitor to identify sequences
   // of explicit casts that can be converted into 'nullptr'.


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bo

[PATCH] D96274: [clang][cli] Generate and round-trip Diagnostic options

2021-02-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Got rid of `{Warnings,Remarks}AsWritten` entirely.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:745
+
+A->render(Args, Rendered);
   }

dexonsmith wrote:
> It's not obvious why this renders the args instead of calling 
> `A->getAsString()` to get the literal command-line argument and putting it 
> directly in DiagnosticsAsWritten. If that'll work, I suggest switching to 
> that, since it's a bit more straightforward; if there's some reason you can't 
> do that, please leave a comment explaining why.
I removed `DiagnosticsAsWritten` completely.

Previously, the code looped over `A->getValues()`, which gave me the impression 
it handles a flag that might indeed have multiple values (e.g. 
`-Wsomething=a,b,c`). If the code only stored `{a,b,c}` into `Diagnostics`, 
`GenerateDiagnosticArgs` could never reconstruct the original argument.

However, after looking closely at all `-W` and `-R` options, this never happens 
and `A->getValues()` always has exactly one element. I've refactored the code 
and clarified the comment for the branch above.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2230-2240
+  for (const auto &Warning : Opts.WarningsAsWritten) {
+// This option also maps to UndefPrefixes that generates it automatically.
+if (StringRef(Warning).startswith("-Wundef-prefix="))
+  continue;
+// TODO: Consider ignoring '-Wno-rewrite-macros' that maps to
+// NoRewriteMacros.
+Args.push_back(SA(Warning));

dexonsmith wrote:
> Does this mean that if some client is programmatically modifying the 
> `Warnings` array (which is what `CompilerInstance` reads) they need to also 
> update `WarningsAsWritten` array identically to get command-line generation 
> to work?
> 
> If so, then this is a bit non-obvious / error-prone. Maybe these can 
> encapsulated together:
> ```
> struct DiagnosticArg {
>   std::string Name;
>   std::string AsWritten;
> };
> std::vector Warnings;
> std::vector Remarks;
> ```
I double-checked and managed to get rid of this entirely, see the other comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96274

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


[PATCH] D96248: [OpenMP][AMDGPU] Add support for linking libomptarget bitcode

2021-02-09 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:193
   CC1Args.push_back("-emit-llvm-bc");
+
+  std::string BitcodeSuffix = "amdgcn-" + GpuArch.str();

JonChesterfield wrote:
> tianshilei1992 wrote:
> > JonChesterfield wrote:
> > > Need `if (DriverArgs.hasArg(options::OPT_nogpulib)) return;` here or we 
> > > can't build the deviceRTL without already having one on disk
> > FWIW, NVPTX `deviceRTLs` is built by directly calling FE, not via clang 
> > driver. `clang -fopenmp -fopenmp-targets=xxx` basically consists of two 
> > passes, and therefore generates two IRs, which is not what we expect. I'm 
> > not sure we really need the if statement.
> That explains what I was missing about the ptx cmake I think. I've had to 
> locally hack around clang creating a bundle, which llvm-link chokes on, 
> because cuda-device-only et al are ignored by openmp.
> 
> I think this check is right - it means nogpulib will exclude the rtl on both 
> GPUs. Nvptx already has it in the control flow.
> 
> Whether RTL cmake should bypass the driver is interesting, but I think 
> separate to this patch.
`cuda-device-only` is only for CUDA compilation. We don’t have an option to 
invoke device compilation only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96248

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


[clang] 521e173 - [clang][cli] Store InputKind in FrontendOptions

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T15:19:26+01:00
New Revision: 521e1733f1496f6d554e6ce8b69cd4251499b15e

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

LOG: [clang][cli] Store InputKind in FrontendOptions

This patch stores the `InputKind` (parsed mainly from `-x`) to 
`FrontendOptions`. This is necessary for command line generation.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 223c1e05d053..5c9a21813b62 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -374,6 +374,10 @@ class FrontendOptions {
   std::string MTMigrateDir;
   std::string ARCMTMigrateReportOut;
 
+  /// The input kind, either specified via -x argument or deduced from the 
input
+  /// file name.
+  InputKind DashX;
+
   /// The input files and their types.
   SmallVector Inputs;
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 020cbf0f176e..3df6b37917aa 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2153,9 +2153,10 @@ static bool parseTestModuleFileExtensionArg(StringRef 
Arg,
   return false;
 }
 
-static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
-   DiagnosticsEngine &Diags,
-   bool &IsHeaderFile) {
+static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   Opts.ProgramAction = frontend::ParseSyntaxOnly;
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
 switch (A->getOption().getID()) {
@@ -2424,7 +2425,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
 Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsSystem);
   }
 
-  return DashX;
+  Opts.DashX = DashX;
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
@@ -3968,9 +3971,10 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   }
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
+  Success &= ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
+   LangOpts.IsHeaderFile);
   // FIXME: We shouldn't have to pass the DashX option around here
-  InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
-  LangOpts.IsHeaderFile);
+  InputKind DashX = Res.getFrontendOpts().DashX;
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
   llvm::Triple T(Res.getTargetOpts().Triple);
   ParseHeaderSearchArgs(Res, Res.getHeaderSearchOpts(), Args, Diags,



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


[PATCH] D96149: [clang][cli] Store InputKind in FrontendOptions

2021-02-09 Thread Jan Svoboda 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 rG521e1733f149: [clang][cli] Store InputKind in 
FrontendOptions (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96149

Files:
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2153,9 +2153,10 @@
   return false;
 }
 
-static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
-   DiagnosticsEngine &Diags,
-   bool &IsHeaderFile) {
+static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   Opts.ProgramAction = frontend::ParseSyntaxOnly;
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
 switch (A->getOption().getID()) {
@@ -2424,7 +2425,9 @@
 Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsSystem);
   }
 
-  return DashX;
+  Opts.DashX = DashX;
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
@@ -3968,9 +3971,10 @@
   }
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
+  Success &= ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
+   LangOpts.IsHeaderFile);
   // FIXME: We shouldn't have to pass the DashX option around here
-  InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
-  LangOpts.IsHeaderFile);
+  InputKind DashX = Res.getFrontendOpts().DashX;
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
   llvm::Triple T(Res.getTargetOpts().Triple);
   ParseHeaderSearchArgs(Res, Res.getHeaderSearchOpts(), Args, Diags,
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -374,6 +374,10 @@
   std::string MTMigrateDir;
   std::string ARCMTMigrateReportOut;
 
+  /// The input kind, either specified via -x argument or deduced from the 
input
+  /// file name.
+  InputKind DashX;
+
   /// The input files and their types.
   SmallVector Inputs;
 


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2153,9 +2153,10 @@
   return false;
 }
 
-static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
-   DiagnosticsEngine &Diags,
-   bool &IsHeaderFile) {
+static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   Opts.ProgramAction = frontend::ParseSyntaxOnly;
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
 switch (A->getOption().getID()) {
@@ -2424,7 +2425,9 @@
 Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsSystem);
   }
 
-  return DashX;
+  Opts.DashX = DashX;
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
@@ -3968,9 +3971,10 @@
   }
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
+  Success &= ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
+   LangOpts.IsHeaderFile);
   // FIXME: We shouldn't have to pass the DashX option around here
-  InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
-  LangOpts.IsHeaderFile);
+  InputKind DashX = Res.getFrontendOpts().DashX;
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
   llvm::Triple T(Res.getTargetOpts().Triple);
   ParseHeaderSearchArgs(Res, Res.getHeaderSearchOpts(), Args, Diags,
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -374,6 +374,10 @@
   std::string MTMigrateDir;
   std::string ARCMTMigrateReportOut;
 
+  /// The input kind, either specified via -x argument or deduced from the input
+  /// file name.
+  InputKind DashX;
+
   /// The input files a

[PATCH] D96270: [release][docs] Update contributions to LLVM 12 for scalable vectors.

2021-02-09 Thread Will Lovett via Phabricator via cfe-commits
willlovett added a comment.

LGTM. Would prefer someone else accept


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

https://reviews.llvm.org/D96270

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


[PATCH] D96274: [clang][cli] Generate and round-trip Diagnostic options

2021-02-09 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I don't claim to be very familiar with this area but "round-trip" and "test" 
would make me think those bits should be in a lit test or unittest. As it is, 
it's not obvious what is functional and what is testing here.
Possibly I am misunderstanding something fundamental about how these options 
work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96274

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


[clang] 7369bfb - [clang][cli] Look up program action argument in a table

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T15:29:33+01:00
New Revision: 7369bfb8abb6f62eebd045b8b243972863bf3190

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

LOG: [clang][cli] Look up program action argument in a table

This patch extracts the mapping between command line option and 
frontend::ActionKind into a table. The table can be reused when parsing and 
also generating command line options.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 3df6b37917aa..d9df4da25eea 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2153,19 +2153,84 @@ static bool parseTestModuleFileExtensionArg(StringRef 
Arg,
   return false;
 }
 
+/// Return a table that associates command line option specifiers with the
+/// frontend action. Note: The pair {frontend::PluginAction, OPT_plugin} is
+/// intentionally missing, as this case is handled separately from other
+/// frontend options.
+static const auto &getFrontendActionTable() {
+  static const std::pair Table[] = {
+  {frontend::ASTDeclList, OPT_ast_list},
+
+  {frontend::ASTDump, OPT_ast_dump_all_EQ},
+  {frontend::ASTDump, OPT_ast_dump_all},
+  {frontend::ASTDump, OPT_ast_dump_EQ},
+  {frontend::ASTDump, OPT_ast_dump},
+  {frontend::ASTDump, OPT_ast_dump_lookups},
+  {frontend::ASTDump, OPT_ast_dump_decl_types},
+
+  {frontend::ASTPrint, OPT_ast_print},
+  {frontend::ASTView, OPT_ast_view},
+  {frontend::DumpCompilerOptions, OPT_compiler_options_dump},
+  {frontend::DumpRawTokens, OPT_dump_raw_tokens},
+  {frontend::DumpTokens, OPT_dump_tokens},
+  {frontend::EmitAssembly, OPT_S},
+  {frontend::EmitBC, OPT_emit_llvm_bc},
+  {frontend::EmitHTML, OPT_emit_html},
+  {frontend::EmitLLVM, OPT_emit_llvm},
+  {frontend::EmitLLVMOnly, OPT_emit_llvm_only},
+  {frontend::EmitCodeGenOnly, OPT_emit_codegen_only},
+  {frontend::EmitCodeGenOnly, OPT_emit_codegen_only},
+  {frontend::EmitObj, OPT_emit_obj},
+
+  {frontend::FixIt, OPT_fixit_EQ},
+  {frontend::FixIt, OPT_fixit},
+
+  {frontend::GenerateModule, OPT_emit_module},
+  {frontend::GenerateModuleInterface, OPT_emit_module_interface},
+  {frontend::GenerateHeaderModule, OPT_emit_header_module},
+  {frontend::GeneratePCH, OPT_emit_pch},
+  {frontend::GenerateInterfaceStubs, OPT_emit_interface_stubs},
+  {frontend::InitOnly, OPT_init_only},
+  {frontend::ParseSyntaxOnly, OPT_fsyntax_only},
+  {frontend::ModuleFileInfo, OPT_module_file_info},
+  {frontend::VerifyPCH, OPT_verify_pch},
+  {frontend::PrintPreamble, OPT_print_preamble},
+  {frontend::PrintPreprocessedInput, OPT_E},
+  {frontend::TemplightDump, OPT_templight_dump},
+  {frontend::RewriteMacros, OPT_rewrite_macros},
+  {frontend::RewriteObjC, OPT_rewrite_objc},
+  {frontend::RewriteTest, OPT_rewrite_test},
+  {frontend::RunAnalysis, OPT_analyze},
+  {frontend::MigrateSource, OPT_migrate},
+  {frontend::RunPreprocessorOnly, OPT_Eonly},
+  {frontend::PrintDependencyDirectivesSourceMinimizerOutput,
+  OPT_print_dependency_directives_minimized_source},
+  };
+
+  return Table;
+}
+
+/// Maps command line option to frontend action.
+static Optional getFrontendAction(OptSpecifier &Opt) {
+  for (const auto &ActionOpt : getFrontendActionTable())
+if (ActionOpt.second == Opt)
+  return ActionOpt.first;
+
+  return None;
+}
+
 static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags, bool &IsHeaderFile) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
 
   Opts.ProgramAction = frontend::ParseSyntaxOnly;
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
-switch (A->getOption().getID()) {
-default:
-  llvm_unreachable("Invalid option in group!");
-case OPT_ast_list:
-  Opts.ProgramAction = frontend::ASTDeclList; break;
-case OPT_ast_dump_all_EQ:
-case OPT_ast_dump_EQ: {
+OptSpecifier Opt = OptSpecifier(A->getOption().getID());
+Optional ProgramAction = getFrontendAction(Opt);
+assert(ProgramAction && "Option specifier not in Action_Group.");
+
+if (ProgramAction == frontend::ASTDump &&
+(Opt == OPT_ast_dump_all_EQ || Opt == OPT_ast_dump_EQ)) {
   unsigned Val = llvm::StringSwitch(A->getValue())
  .CaseLower("default", ADOF_Default)
  .CaseLower("json", ADOF_JSON)
@@ -2178,51 +2243,12 @@ static bool ParseFrontendArgs(FrontendOpt

[PATCH] D96269: [clang][cli] Look up program action argument in a table

2021-02-09 Thread Jan Svoboda 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 rG7369bfb8abb6: [clang][cli] Look up program action argument 
in a table (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96269

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2153,19 +2153,84 @@
   return false;
 }
 
+/// Return a table that associates command line option specifiers with the
+/// frontend action. Note: The pair {frontend::PluginAction, OPT_plugin} is
+/// intentionally missing, as this case is handled separately from other
+/// frontend options.
+static const auto &getFrontendActionTable() {
+  static const std::pair Table[] = {
+  {frontend::ASTDeclList, OPT_ast_list},
+
+  {frontend::ASTDump, OPT_ast_dump_all_EQ},
+  {frontend::ASTDump, OPT_ast_dump_all},
+  {frontend::ASTDump, OPT_ast_dump_EQ},
+  {frontend::ASTDump, OPT_ast_dump},
+  {frontend::ASTDump, OPT_ast_dump_lookups},
+  {frontend::ASTDump, OPT_ast_dump_decl_types},
+
+  {frontend::ASTPrint, OPT_ast_print},
+  {frontend::ASTView, OPT_ast_view},
+  {frontend::DumpCompilerOptions, OPT_compiler_options_dump},
+  {frontend::DumpRawTokens, OPT_dump_raw_tokens},
+  {frontend::DumpTokens, OPT_dump_tokens},
+  {frontend::EmitAssembly, OPT_S},
+  {frontend::EmitBC, OPT_emit_llvm_bc},
+  {frontend::EmitHTML, OPT_emit_html},
+  {frontend::EmitLLVM, OPT_emit_llvm},
+  {frontend::EmitLLVMOnly, OPT_emit_llvm_only},
+  {frontend::EmitCodeGenOnly, OPT_emit_codegen_only},
+  {frontend::EmitCodeGenOnly, OPT_emit_codegen_only},
+  {frontend::EmitObj, OPT_emit_obj},
+
+  {frontend::FixIt, OPT_fixit_EQ},
+  {frontend::FixIt, OPT_fixit},
+
+  {frontend::GenerateModule, OPT_emit_module},
+  {frontend::GenerateModuleInterface, OPT_emit_module_interface},
+  {frontend::GenerateHeaderModule, OPT_emit_header_module},
+  {frontend::GeneratePCH, OPT_emit_pch},
+  {frontend::GenerateInterfaceStubs, OPT_emit_interface_stubs},
+  {frontend::InitOnly, OPT_init_only},
+  {frontend::ParseSyntaxOnly, OPT_fsyntax_only},
+  {frontend::ModuleFileInfo, OPT_module_file_info},
+  {frontend::VerifyPCH, OPT_verify_pch},
+  {frontend::PrintPreamble, OPT_print_preamble},
+  {frontend::PrintPreprocessedInput, OPT_E},
+  {frontend::TemplightDump, OPT_templight_dump},
+  {frontend::RewriteMacros, OPT_rewrite_macros},
+  {frontend::RewriteObjC, OPT_rewrite_objc},
+  {frontend::RewriteTest, OPT_rewrite_test},
+  {frontend::RunAnalysis, OPT_analyze},
+  {frontend::MigrateSource, OPT_migrate},
+  {frontend::RunPreprocessorOnly, OPT_Eonly},
+  {frontend::PrintDependencyDirectivesSourceMinimizerOutput,
+  OPT_print_dependency_directives_minimized_source},
+  };
+
+  return Table;
+}
+
+/// Maps command line option to frontend action.
+static Optional getFrontendAction(OptSpecifier &Opt) {
+  for (const auto &ActionOpt : getFrontendActionTable())
+if (ActionOpt.second == Opt)
+  return ActionOpt.first;
+
+  return None;
+}
+
 static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags, bool &IsHeaderFile) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
 
   Opts.ProgramAction = frontend::ParseSyntaxOnly;
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
-switch (A->getOption().getID()) {
-default:
-  llvm_unreachable("Invalid option in group!");
-case OPT_ast_list:
-  Opts.ProgramAction = frontend::ASTDeclList; break;
-case OPT_ast_dump_all_EQ:
-case OPT_ast_dump_EQ: {
+OptSpecifier Opt = OptSpecifier(A->getOption().getID());
+Optional ProgramAction = getFrontendAction(Opt);
+assert(ProgramAction && "Option specifier not in Action_Group.");
+
+if (ProgramAction == frontend::ASTDump &&
+(Opt == OPT_ast_dump_all_EQ || Opt == OPT_ast_dump_EQ)) {
   unsigned Val = llvm::StringSwitch(A->getValue())
  .CaseLower("default", ADOF_Default)
  .CaseLower("json", ADOF_JSON)
@@ -2178,51 +2243,12 @@
 << A->getAsString(Args) << A->getValue();
 Opts.ASTDumpFormat = ADOF_Default;
   }
-  LLVM_FALLTHROUGH;
 }
-case OPT_ast_dump:
-case OPT_ast_dump_all:
-case OPT_ast_dump_lookups:
-case OPT_ast_dump_decl_types:
-  Opts.ProgramAction = frontend::ASTDump; break;
-case OPT_ast_print:
-  Opts.ProgramAction = frontend::ASTPrint; break;
-case OPT_ast_view:
-  Opts.ProgramAction = frontend::ASTView; break;
-case O

[PATCH] D96270: [release][docs] Update contributions to LLVM 12 for scalable vectors.

2021-02-09 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D96270

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


[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

2021-02-09 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.

LGTM, thanks. All the comments seem to be addressed.


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

https://reviews.llvm.org/D96161

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


[clang] 396d6a3 - [clang][cli] Store unsigned instead of OptSpecifier in table

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T15:46:10+01:00
New Revision: 396d6a3220ee131f58ce46ca47f6f98cf7a3fcae

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

LOG: [clang][cli] Store unsigned instead of OptSpecifier in table

This fixes some buildbot failures with ambiguous call to OptSpecifier 
constructor.

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d9df4da25eea..9cdaab8804d8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2158,7 +2158,7 @@ static bool parseTestModuleFileExtensionArg(StringRef Arg,
 /// intentionally missing, as this case is handled separately from other
 /// frontend options.
 static const auto &getFrontendActionTable() {
-  static const std::pair Table[] = {
+  static const std::pair Table[] = {
   {frontend::ASTDeclList, OPT_ast_list},
 
   {frontend::ASTDump, OPT_ast_dump_all_EQ},
@@ -2213,7 +2213,7 @@ static const auto &getFrontendActionTable() {
 /// Maps command line option to frontend action.
 static Optional getFrontendAction(OptSpecifier &Opt) {
   for (const auto &ActionOpt : getFrontendActionTable())
-if (ActionOpt.second == Opt)
+if (ActionOpt.second == Opt.getID())
   return ActionOpt.first;
 
   return None;



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


[PATCH] D96324: [clangd] Rename references to function arguments within the same file

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 322382.
kbobyrev added a comment.

Rebase on top of D96247 , check for conflicts 
in specialization bodies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96324

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -678,6 +678,61 @@
 }
   )cpp",
 
+  // Function argument.
+  R"cpp(
+// Main.cpp
+void foo(int [[Bar^]]);
+
+void foo(int [[Bar^]]) {}
+
+// Forward declarations somewhere else.
+void foo(int [[Bar^]]);
+void foo(int /*Bar*/);
+  )cpp",
+
+  // Template function argument.
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+template 
+void foo(T [[Bar^]]);
+
+template 
+void foo(T [[Bar^]]) {}
+
+template <>
+void foo(int [[Bar^]]) {}
+  )cpp",
+
+  // Constructor argument.
+  R"cpp(
+class Foo {
+  Foo(int [[Bar^]]);
+};
+Foo::Foo(int [[Bar^]]) {}
+  )cpp",
+  R"cpp(
+class Foo {
+  template 
+  Foo(T Something, U [[Bar^]]);
+
+  Foo();
+};
+
+template 
+Foo::Foo(T Something, U [[Bar^]]) {}
+
+template <>
+Foo::Foo(int Something, int [[Bar^]]) {}
+template <>
+Foo::Foo(bool Something, bool [[Bar^]]) {}
+  )cpp",
+
   // Namespace alias.
   R"cpp(
 namespace a { namespace b { void foo(); } }
@@ -1091,14 +1146,21 @@
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
-  {R"cpp(// No conflict: only forward declaration's argument is renamed.
-void func(int [[V^ar]]);
+  {R"cpp(
+template 
+void func(T Var);
+
+template <>
+void func(bool V^ar) {}
 
+template <>
 void func(int Var) {
-  bool Conflict;
+  // We are renaming from the primary template but the parameter name
+  // will also be changed here introducing a new conflict.
+  int Conflict;
 }
   )cpp",
-   nullptr, !HeaderFile, nullptr, "Conflict"},
+   "conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(
 void func(int V^ar, int Conflict) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -100,7 +100,8 @@
 //
 // Here, both partial (2) and full (3) specializations are canonicalized to (1)
 // which ensures all three of them are renamed.
-const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D,
+ bool CanonicalizeCtorToType = true) {
   if (const auto *VarTemplate = dyn_cast(D))
 return canonicalRenameDecl(
 VarTemplate->getSpecializedTemplate()->getTemplatedDecl());
@@ -113,9 +114,17 @@
 ClassTemplateSpecialization->getSpecializedTemplate()
 ->getTemplatedDecl());
   if (const auto *Method = dyn_cast(D)) {
-if (Method->getDeclKind() == Decl::Kind::CXXConstructor ||
+// By default ctors and dtors are canonicalized to the returned type but
+// when CanonicalizeCtorToType is not set, we should still retrieve the
+// canonical method.
+if ((Method->getDeclKind() == Decl::Kind::CXXConstructor &&
+ CanonicalizeCtorToType) ||
 Method->getDeclKind() == Decl::Kind::CXXDestructor)
   return canonicalRenameDecl(Method->getParent());
+if (const FunctionTemplateDecl *Template = Method->getPrimaryTemplate())
+  if (const auto *TemplatedDecl =
+  dyn_cast(Template->getTemplatedDecl()))
+Method = TemplatedDecl;
 if (const FunctionDecl *InstantiatedMethod =
 Method->getInstantiatedFromMemberFunction())
   Method = cast(InstantiatedMethod);
@@ -151,6 +160,19 @@
   if (const auto *VD = dyn_cast(D)) {
 if (const VarDecl *OriginalVD = VD->getInstantiatedFromStaticDataMember())
   VD = OriginalVD;
+// Arguments are canonicalized to their canonical function's arguments.
+if (const auto *Argument = dyn_cast(VD)) {
+  if (const auto *Function =
+  dyn_cast(Argument->getDeclContext())) {
+const auto *Canonical = dyn_cast(
+canonicalRenameDecl(Function, /*CanonicalizeCtorToType=*/false));
+assert(Canonical &&
+   "canonicalRenameDecl should return the 

[PATCH] D96017: [clang-check] Add tokens-dump in clang-check.

2021-02-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96017

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


[clang] 79b222c - [OpenCL] Fix types with signed prefix in arginfo metadata.

2021-02-09 Thread Anastasia Stulova via cfe-commits
Author: Anastasia Stulova
Date: 2021-02-09T15:13:19Z
New Revision: 79b222c39f0e4377b49191b6aba080b1607f3fa7

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

LOG: [OpenCL] Fix types with signed prefix in arginfo metadata.

Signed prefix is removed and the single word spelling is
printed for the scalar types.

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenOpenCL/kernel-arg-info.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 62448b74c727..1c28c50e60f5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1501,6 +1501,8 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function 
*Fn,
   // Turn "unsigned type" to "utype"
   if (typeNameRef.consume_front("unsigned "))
 return std::string("u") + typeNameRef.str();
+  if (typeNameRef.consume_front("signed "))
+return typeNameRef.str();
 }
 
 return typeName;

diff  --git a/clang/test/CodeGenOpenCL/kernel-arg-info.cl 
b/clang/test/CodeGenOpenCL/kernel-arg-info.cl
index fae8a007b2d8..dbb59af9470c 100644
--- a/clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ b/clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@ kernel void foo8(pipe int p1, pipe uchar p2, pipe uchar2 
p3, const pipe uchar p4
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed char sc1,  global const signed char* sc2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SCHAR_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SCHAR_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SCHAR_TY]]
+// CHECK: !kernel_arg_type_qual ![[SCHAR_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SCHAR_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@ kernel void foo8(pipe int p1, pipe uchar p2, pipe uchar2 
p3, const pipe uchar p4
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar 
__attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SCHAR_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SCHAR_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SCHAR_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SCHAR_ARG_NAMES]] = !{!"sc1", !"sc2"}



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


[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

2021-02-09 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79b222c39f0e: [OpenCL] Fix types with signed prefix in 
arginfo metadata. (authored by Anastasia).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D96161?vs=322330&id=322383#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96161

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenOpenCL/kernel-arg-info.cl


Index: clang/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed char sc1,  global const signed char* sc2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SCHAR_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SCHAR_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SCHAR_TY]]
+// CHECK: !kernel_arg_type_qual ![[SCHAR_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SCHAR_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar 
__attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SCHAR_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SCHAR_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SCHAR_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SCHAR_ARG_NAMES]] = !{!"sc1", !"sc2"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1501,6 +1501,8 @@
   // Turn "unsigned type" to "utype"
   if (typeNameRef.consume_front("unsigned "))
 return std::string("u") + typeNameRef.str();
+  if (typeNameRef.consume_front("signed "))
+return typeNameRef.str();
 }
 
 return typeName;


Index: clang/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed char sc1,  global const signed char* sc2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SCHAR_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SCHAR_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SCHAR_TY]]
+// CHECK: !kernel_arg_type_qual ![[SCHAR_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SCHAR_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar __attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SCHAR_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SCHAR_TY]] = !{!"char", !"char*"}
+// CHECK: ![[SCHAR_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SCHAR_ARG_NAMES]] = !{!"sc1", !"sc2"}
Index: clang/lib/CodeGen/CodeGenModule.cpp

[PATCH] D86376: [HIP] Emit kernel symbol

2021-02-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Actually there is one issue with this approach.

HIP have API's to launch kernels, which accept kernel as function pointer 
argument. Currently when taking address of kernel, we get the stub function. 
These kernel launching API's will not work if we use kernel symbol to register 
the kernel. A solution is to return the kernel symbol instead of stub function 
when taking address of the kernel in host compilation, i.e. if a function 
pointer is assigned to a kernel in host code, it gets the kernel symbol instead 
of the stub function. This will make the kernel launching API work.

To keep the triple chevron working, the kernel symbol will be initialized with 
the address of the stub function. For triple chevron call, the address of the 
stub function is loaded from the kernel symbol and invoked.


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

https://reviews.llvm.org/D86376

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


[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-02-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added a comment.

Thanks for the excellent comments, and sorry for the radio silence. (Kids got 
quarantined recently so work time has been... scarce).

I think there are improvements to be had here but it's probably time to land 
this...

In D77811#2544328 , @nridge wrote:

> I am curious what you think of the extension idea for readonly 
> , though obviously 
> it wouldn't be something to do in this patch.

Longer comment below, but:

- I love it
- it's not trivial to implement, I think
- not obvious whether this should replace the simple `readonly` given here, 
augment it, or be a different attribute - I'm probably happy with any of these.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:136
+// Whether D is const in a loose sense (should it be highlighted as such?)
+bool isConst(const Decl *D) {
+  if (llvm::isa(D) || llvm::isa(D))

nridge wrote:
> Do you think in the future it might make sense to have the `readonly` 
> modifier reflect, at least for variables, whether //the particular 
> reference// to the variable is a readonly reference (e.g. binding the 
> variable to a `const X&` vs. an `X&`)?
Do I understand correctly?

```
std::vector X; // X is not readonly
X.push_back(42); // X is not readonly
X.size(); // X is readonly
```

Distinguishing potentially-mutating from non-mutating uses seems really useful 
to me.
My only question is whether mapping this concept onto `readonly` is the right 
thing to do:
 - there are really three sets: const access, mutable access, and non-access 
(e.g. declaration, or on RHS of `using a=b`). And I think maybe the most useful 
thing to distinguish is mutable access vs everything else, which is awkward 
with an attribute called "readonly".
 - this also seems likely to diverge from how other languages use the attribute 
(most don't have this concept)
 - on the other hand, standard attribute names will be better supported by 
clients

This also might be somewhat complicated to implement :-)
I'd like to leave in this simple decl-based thing as a placeholder, and either 
we can replace it and add an additional "mutation" attribute later (once we 
work out how to implement it!) I've left a comment about this...

(Related: a while ago Google's style guide dropped its requirement to use 
pointers rather than references for mutable function params. Having `&x` at the 
callsite rather than just `x` is a useful hint, but obviously diverging from 
common practice has a cost. We discussed how we could use semantic highlighting 
to highlight where a param was being passed by mutable reference, though didn't 
have client-side support for it yet)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:476
+  if (!Kind || (Result && Kind != Result))
+continue;
+  Result = Kind;

nridge wrote:
> nridge wrote:
> > This is a change of behaviour from before, in the case where the 
> > `ReferenceLoc` has multiple targets.
> > 
> > Before, we would produce at most one highlighting token for the 
> > `ReferenceLoc`. In the case where different target decls had different 
> > highlighting kinds, we wouldn't produce any.
> > 
> > Now, it looks like we produce a separate token for every target whose kind 
> > matches the kind of the first target (and skip targets with a conflicting 
> > kind).
> > 
> > Is that the intention?
> > 
> > It seems a bit strange: if we allow multiple tokens, why couldn't they have 
> > different kinds?
> Thinking more about this, the behaviour may actually be reasonable as written.
> 
>   * Tokens with different kinds would get discarded via `resolveConflict()`.
>   * Multiple tokens with the same kind are potentially useful because they 
> may have different modifiers, and the modifiers are then merged in 
> `resolveConflict()`.
Oops, I don't think the part where we treat the first kind specially was 
intended.
I think the simplest thing is to emit all the tokens and let conflict 
resolution sort them out.
In practice this means:
 - if there's multiple kinds, discard all
 - if there's different sets of modifiers, take the union
Which seems reasonable to me until proven otherwise

(This part of the patch is really old so I can't be 100% sure what my intention 
was...)



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:264
+$Class[[D]] $Field_decl[[E]];
+static double $StaticField_decl_static[[S]];
+static void $StaticMethod_decl_static[[bar]]() {}

nridge wrote:
> sammccall wrote:
> > nridge wrote:
> > > Presumably, the highlighting kinds `StaticField` and `StaticMethod` are 
> > > going to be collapsed into `Field` and `Method` in a future change (after 
> > > the removal of TheiaSemanticHighlighting, I guess)?
> > Yeah, merg

[PATCH] D95536: [clang][sema] Note decl location on missing member

2021-02-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Any update on this?


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

https://reviews.llvm.org/D95536

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


[clang-tools-extra] dd8fb21 - [clangd] Implement semanticTokens modifiers

2021-02-09 Thread Sam McCall via cfe-commits
Author: Sam McCall
Date: 2021-02-09T16:31:22+01:00
New Revision: dd8fb21227cef26b1cdd44792a1ee77910afd86a

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

LOG: [clangd] Implement semanticTokens modifiers

- Infrastructure to support modifiers (protocol etc)
- standard modifiers:
  - declaration (but no definition, yet)
  - deprecated
  - readonly (based on a fairly fuzzy const checking)
  - static (for class members and locals, but *not* file-scope things!)
  - abstract (for C++ classes, and pure-virtual methods)
- nonstandard modifier:
  - deduced (on "auto" whose Kind is Class etc)
Happy to drop this if it's controversial at all.
- While here, update sample tweak to use our internal names, in
  anticipation of theia TM scopes going away.

This addresses some of the goals of D77702, but leaves some things undone.
Mostly because I think these will want some discussion.
 - no split between dependent type/name.
   (We may want to model this as a modifier, type+dependent vs ???+dependent)
 - no split between primitive/typedef.
   (Is introducing a nonstandard kind is worth this distinction?)
 - no nonstandard local attribute
   This probably makes sense, I'm wondering if we want others and how
   they fit together.

There's one minor regression in explicit template specialization declarations
due to a latent bug in findExplicitReferences, but fixing it after seems OK.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
llvm/lib/Testing/Support/Annotations.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 42e865d764ae..006b03531836 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -490,6 +490,15 @@ static std::vector semanticTokenTypes() {
   return Types;
 }
 
+static std::vector semanticTokenModifiers() {
+  std::vector Modifiers;
+  for (unsigned I = 0;
+   I <= static_cast(HighlightingModifier::LastModifier); ++I)
+Modifiers.push_back(
+toSemanticTokenModifier(static_cast(I)));
+  return Modifiers;
+}
+
 void ClangdLSPServer::onInitialize(const InitializeParams &Params,
Callback Reply) {
   // Determine character encoding first as it affects constructed ClangdServer.
@@ -628,8 +637,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
  {"full", llvm::json::Object{{"delta", true}}},
  {"range", false},
  {"legend",
-  llvm::json::Object{{"tokenTypes", semanticTokenTypes()},
- {"tokenModifiers", llvm::json::Array()}}},
+  llvm::json::Object{
+  {"tokenTypes", semanticTokenTypes()},
+  {"tokenModifiers", semanticTokenModifiers()}}},
  }},
 {"signatureHelpProvider",
  llvm::json::Object{

diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 5e70baf73310..00c6ed65d157 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -15,6 +15,8 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -118,17 +120,83 @@ llvm::Optional kindForType(const Type 
*TP) {
   return llvm::None;
 }
 
-llvm::Optional kindForReference(const ReferenceLoc &R) {
-  llvm::Optional Result;
-  for (const NamedDecl *Decl : R.Targets) {
-if (!canHighlightName(Decl->getDeclName()))
-  return llvm::None;
-auto Kind = kindForDecl(Decl);
-if (!Kind || (Result && Kind != Result))
-  return llvm::None;
-Result = Kind;
+// Whether T is const in a loose sense - is a variable with this type readonly?
+bool isConst(QualType T) {
+  if (T.isNull() || T->isDependentType())
+return false;
+  T = T.getNonReferenceType();
+  if (T.isConstQualified())
+return true;
+  if (const auto *AT = T->getAsArrayTypeUnsafe())
+return isCo

[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-02-09 Thread Sam McCall 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 rGdd8fb21227ce: [clangd] Implement semanticTokens modifiers 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D77811?vs=320464&id=322391#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77811

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
  llvm/lib/Testing/Support/Annotations.cpp

Index: llvm/lib/Testing/Support/Annotations.cpp
===
--- llvm/lib/Testing/Support/Annotations.cpp
+++ llvm/lib/Testing/Support/Annotations.cpp
@@ -53,7 +53,8 @@
   continue;
 }
 if (Text.consume_front("$")) {
-  Name = Text.take_while(llvm::isAlnum);
+  Name =
+  Text.take_while([](char C) { return llvm::isAlnum(C) || C == '_'; });
   Text = Text.drop_front(Name->size());
   continue;
 }
Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,15 +18,17 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
+  EXPECT_EQ("void /* Function [decl] */f() {}", apply("void ^f() {}"));
 
-  EXPECT_EQ(apply("[[void f1(); void f2();]]"),
-"void /* entity.name.function.cpp */f1(); "
-"void /* entity.name.function.cpp */f2();");
+  EXPECT_EQ(
+  apply("[[int f1(); const int x = f1();]]"),
+  "int /* Function [decl] */f1(); "
+  "const int /* Variable [decl] [readonly] */x = /* Function */f1();");
 
+  // Only the targeted range is annotated.
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"void /* entity.name.function.cpp */f2() {}");
+"void /* Function [decl] */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include 
 
@@ -86,7 +87,8 @@
 return L.R.start < R.R.start;
   }));
 
-  std::string Result;
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
   unsigned NextChar = 0;
   for (auto &T : Tokens) {
 unsigned StartOffset = llvm::cantFail(positionToOffset(Input, T.R.start));
@@ -94,14 +96,18 @@
 assert(StartOffset <= EndOffset);
 assert(NextChar <= StartOffset);
 
-Result += Input.substr(NextChar, StartOffset - NextChar);
-Result += std::string(
-llvm::formatv("${0}[[{1}]]", T.Kind,
-  Input.substr(StartOffset, EndOffset - StartOffset)));
+OS << Input.substr(NextChar, StartOffset - NextChar);
+OS << '$' << T.Kind;
+for (unsigned I = 0;
+ I <= static_cast(HighlightingModifier::LastModifier); ++I) {
+  if (T.Modifiers & (1 << I))
+OS << '_' << static_cast(I);
+}
+OS << "[[" << Input.substr(StartOffset, EndOffset - StartOffset) << "]]";
 NextChar = EndOffset;
   }
-  Result += Input.substr(NextChar);
-  return Result;
+  OS << Input.substr(NextChar);
+  return std::move(OS.str());
 }
 
 void checkHighlightings(llvm::StringRef Code,
@@ -160,337 +166,340 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
-  struct $Class[[AS]] {
-double $Field[[SomeMember]];
+  struct $Class_decl[[AS]] {
+double $Field_decl[[SomeMember]];
   };
   struct {
-  } $Variable[[S]];
-  void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
-$Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
-$Class[[AS]] $LocalVariable[[AA]];
-$Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
-auto $LocalVariable[[FN]] = [ $Loca

[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-09 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: awarzynski, sscalpone, clementval, tskeith, 
AMDChirag, SouraVX.
Herald added a subscriber: dang.
Herald added a reviewer: jansvoboda11.
arnamoy10 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Add support for the following Fortran dialect options:

- -default*
- -flarge-sizes

It also adds a test case for checking whether `flang-new` is passing options 
correctly to `flang-new -fc1`.

Also moves the Dialect related option parsing to a dedicated function.

Depends on: D96032 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96344

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/pipeline.f90

Index: flang/test/Flang-Driver/pipeline.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/pipeline.f90
@@ -0,0 +1,14 @@
+! Test that flang can forward all of the flags which are documented as
+! being supported by gfortran to flang-new for a fortran input file.
+!
+! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: -fdefault-double-8 \
+! RUN: -fdefault-integer-8 \
+! RUN: -fdefault-real-8 \
+! RUN:   | FileCheck %s
+!
+!
+! CHECK: "-fdefault-double-8"
+! CHECK: "-fdefault-integer-8"
+! CHECK: "-fdefault-real-8"
+
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -200,13 +200,6 @@
 }
   }
 
-  // Extensions
-  if (args.hasArg(clang::driver::options::OPT_fopenacc)) {
-opts.features_.Enable(Fortran::common::LanguageFeature::OpenACC);
-  }
-  if (args.hasArg(clang::driver::options::OPT_fopenmp)) {
-opts.features_.Enable(Fortran::common::LanguageFeature::OpenMP);
-  }
   return dashX;
 }
 
@@ -251,6 +244,38 @@
 moduleDir = moduleDirList[0];
 }
 
+/// Parses all Dialect related arguments and populates the variables
+/// options accordingly.
+static void parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
+clang::DiagnosticsEngine &diags) {
+
+ // -fedefault* family
+ if (args.hasArg(clang::driver::options::OPT_fdefault_real_8))
+ res.dialectOpts().dfltReal = true;
+ if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8))
+ res.dialectOpts().dfltInt = true;
+ if (args.hasArg(clang::driver::options::OPT_fdefault_double_8)) {
+ if (!res.dialectOpts().dfltReal) {
+   const unsigned diagID =
+   diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+ "Use of `-fdefault-double-8` requires `-fdefault-real-8`");
+   diags.Report(diagID);
+ }
+ res.dialectOpts().dfltDouble = true;
+ }
+ if (args.hasArg(clang::driver::options::OPT_flarge_sizes)) 
+ res.dialectOpts().largeSizes = true;
+
+ // -fopenmp and -fopenacc 
+ if (args.hasArg(clang::driver::options::OPT_fopenacc)) {
+   res.frontendOpts().features_.Enable(Fortran::common::LanguageFeature::OpenACC);
+ }
+ if (args.hasArg(clang::driver::options::OPT_fopenmp)) {
+   res.frontendOpts().features_.Enable(Fortran::common::LanguageFeature::OpenMP);
+ }
+ return; 
+}
+
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
 llvm::ArrayRef commandLineArgs,
 clang::DiagnosticsEngine &diags) {
@@ -282,6 +307,8 @@
   parsePreprocessorArgs(res.preprocessorOpts(), args);
   // Parse semantic args
   parseSemaArgs(res.moduleDir(), args, diags);
+  // Parse dialect arguments
+  parseDialectArgs(res, args, diags);
 
   return success;
 }
@@ -389,8 +416,19 @@
 Fortran::parser::AllCookedSources &allCookedSources) {
   const auto &fortranOptions = fortranOpts();
 
+  defaultKinds_ = std::make_unique();
+  if (this->dialectOpts_.dfltDouble) defaultKinds().set_defaultRealKind(4);
+  if (this->dialectOpts_.dfltReal) defaultKinds().set_defaultRealKind(8); 
+  if (this->dialectOpts_.dfltInt) {
+defaultKinds().set_defaultIntegerKind(8);
+defaultKinds().set_subscriptIntegerKind(8);
+defaultKinds().set_sizeIntegerKind(8);
+// TODO: Set more options based on PGF90
+  }
+  if (this->dialectOpts_.largeSizes) defaultKinds().set_sizeIntegerKind(8); 
+
   semanticsContext_ = std::make_unique(
-  *(new Fortran::common::IntrinsicTypeDefaultKinds()),
+  defaultKinds(),
   fortranOptions.features, allCookedSources);
 
   auto &moduleDirJ = moduleDir();
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -19,6 +19,13 @@
 
 namespace Fortran::fro

[clang] 5e8a246 - [clang][cli] Generate and round-trip Frontend options

2021-02-09 Thread Jan Svoboda via cfe-commits
Author: Jan Svoboda
Date: 2021-02-09T16:40:30+01:00
New Revision: 5e8a246ac9966e6ca43e7bd84db6df78b27d2201

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

LOG: [clang][cli] Generate and round-trip Frontend options

This patch implements generation of remaining frontend options and tests it by 
performing parse-generate-parse round trip.

Depends on D96269.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CommandLineSourceLoc.h
clang/include/clang/Serialization/ModuleFileExtension.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/TestModuleFileExtension.cpp
clang/lib/Frontend/TestModuleFileExtension.h

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 544f5771861a..0f0522410df6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -248,7 +248,7 @@ class LangOpts
 class TargetOpts
   : KeyPathAndMacro<"TargetOpts->", base> {}
 class FrontendOpts
-  : KeyPathAndMacro<"FrontendOpts.", base> {}
+  : KeyPathAndMacro<"FrontendOpts.", base, "FRONTEND_"> {}
 class PreprocessorOutputOpts
   : KeyPathAndMacro<"PreprocessorOutputOpts.", base> {}
 class DependencyOutputOpts

diff  --git a/clang/include/clang/Frontend/CommandLineSourceLoc.h 
b/clang/include/clang/Frontend/CommandLineSourceLoc.h
index 0827433462e1..dfc4454b4baf 100644
--- a/clang/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/clang/include/clang/Frontend/CommandLineSourceLoc.h
@@ -48,6 +48,13 @@ struct ParsedSourceLocation {
 
 return PSL;
   }
+
+  /// Serialize ParsedSourceLocation back to a string.
+  std::string ToString() const {
+return (llvm::Twine(FileName == "" ? "-" : FileName) + ":" +
+Twine(Line) + ":" + Twine(Column))
+.str();
+  }
 };
 
 /// A source range that has been parsed on the command line.

diff  --git a/clang/include/clang/Serialization/ModuleFileExtension.h 
b/clang/include/clang/Serialization/ModuleFileExtension.h
index 63562c0d6bd2..e9ac4c22520e 100644
--- a/clang/include/clang/Serialization/ModuleFileExtension.h
+++ b/clang/include/clang/Serialization/ModuleFileExtension.h
@@ -60,9 +60,20 @@ class ModuleFileExtensionWriter;
 /// custom writer that can then be accessed via a custom reader when
 /// the module file or precompiled header is loaded.
 class ModuleFileExtension {
+protected:
+  /// Discriminator for LLVM-style RTTI.
+  enum ModuleFileExtensionKind {
+MFEK_Test,
+  };
+
+  const ModuleFileExtensionKind Kind;
 public:
+  ModuleFileExtension(ModuleFileExtensionKind Kind) : Kind(Kind) {}
+
   virtual ~ModuleFileExtension();
 
+  ModuleFileExtensionKind getKind() const { return Kind; }
+
   /// Retrieves the metadata for this module file extension.
   virtual ModuleFileExtensionMetadata getExtensionMetadata() const = 0;
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 9cdaab8804d8..928009ebf2f4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -386,7 +386,7 @@ template  static T extractForwardValue(T 
KeyPath) {
 
 template 
 static T extractMaskValue(T KeyPath) {
-  return KeyPath & Value;
+  return ((KeyPath & Value) == Value) ? Value : T();
 }
 
 #define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
@@ -2219,9 +2219,188 @@ static Optional 
getFrontendAction(OptSpecifier &Opt) {
   return None;
 }
 
-static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
-  DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+/// Maps frontend action to command line option.
+static Optional
+getProgramActionOpt(frontend::ActionKind ProgramAction) {
+  for (const auto &ActionOpt : getFrontendActionTable())
+if (ActionOpt.first == ProgramAction)
+  return OptSpecifier(ActionOpt.second);
+
+  return None;
+}
+
+static void GenerateFrontendArgs(const FrontendOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA,
+ bool IsHeader) {
+  const FrontendOptions &FrontendOpts = Opts;
+#define FRONTEND_OPTION_WITH_MARSHALLING(  
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  GENERATE_OPTION_WITH_MAR

[PATCH] D96155: [clang][cli] Generate and round-trip Frontend options

2021-02-09 Thread Jan Svoboda 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 rG5e8a246ac996: [clang][cli] Generate and round-trip Frontend 
options (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D96155?vs=322121&id=322393#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96155

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CommandLineSourceLoc.h
  clang/include/clang/Serialization/ModuleFileExtension.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/TestModuleFileExtension.cpp
  clang/lib/Frontend/TestModuleFileExtension.h

Index: clang/lib/Frontend/TestModuleFileExtension.h
===
--- clang/lib/Frontend/TestModuleFileExtension.h
+++ clang/lib/Frontend/TestModuleFileExtension.h
@@ -48,7 +48,8 @@
   unsigned MinorVersion,
   bool Hashed,
   StringRef UserInfo)
-: BlockName(BlockName),
+: ModuleFileExtension(ModuleFileExtensionKind::MFEK_Test),
+  BlockName(BlockName),
   MajorVersion(MajorVersion), MinorVersion(MinorVersion),
   Hashed(Hashed), UserInfo(UserInfo) { }
   ~TestModuleFileExtension() override;
@@ -64,6 +65,14 @@
   createExtensionReader(const ModuleFileExtensionMetadata &Metadata,
 ASTReader &Reader, serialization::ModuleFile &Mod,
 const llvm::BitstreamCursor &Stream) override;
+
+  static bool classof(const ModuleFileExtension *E) {
+return E->getKind() == MFEK_Test;
+  }
+
+  /// Serialize the extension.
+  friend llvm::raw_ostream &
+  operator<<(llvm::raw_ostream &OS, const TestModuleFileExtension &Extension);
 };
 
 } // end namespace clang
Index: clang/lib/Frontend/TestModuleFileExtension.cpp
===
--- clang/lib/Frontend/TestModuleFileExtension.cpp
+++ clang/lib/Frontend/TestModuleFileExtension.cpp
@@ -127,3 +127,10 @@
   return std::unique_ptr(
 new TestModuleFileExtension::Reader(this, Stream));
 }
+
+llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
+ const TestModuleFileExtension &Extension) {
+  return OS << Extension.BlockName << ":" << Extension.MajorVersion << ":"
+<< Extension.MinorVersion << ":" << Extension.Hashed << ":"
+<< Extension.UserInfo;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -386,7 +386,7 @@
 
 template 
 static T extractMaskValue(T KeyPath) {
-  return KeyPath & Value;
+  return ((KeyPath & Value) == Value) ? Value : T();
 }
 
 #define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  \
@@ -2219,9 +2219,188 @@
   return None;
 }
 
-static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
-  DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+/// Maps frontend action to command line option.
+static Optional
+getProgramActionOpt(frontend::ActionKind ProgramAction) {
+  for (const auto &ActionOpt : getFrontendActionTable())
+if (ActionOpt.first == ProgramAction)
+  return OptSpecifier(ActionOpt.second);
+
+  return None;
+}
+
+static void GenerateFrontendArgs(const FrontendOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA,
+ bool IsHeader) {
+  const FrontendOptions &FrontendOpts = Opts;
+#define FRONTEND_OPTION_WITH_MARSHALLING(  \
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+MERGER, EXTRACTOR, TABLE_INDEX)\
+  GENERATE_OPTION_WITH_MARSHALLING(\
+  Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,\
+  IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef FRONTEND_OPTION_WITH_MARSHALLING
+
+  Optional ProgramActionOpt =
+  getProgramActionOpt(Opts.ProgramAction);
+
+  // Generating a simple flag covers most frontend actions.
+  std::function GenerateProgramAction = [&]() {
+GenerateArg(Args, *ProgramActionOpt, SA);
+  };
+
+  if (!ProgramActionOpt) {
+// PluginAction is the only program action handled separately.
+assert(Opts.ProgramAction == frontend::PluginAction 

[PATCH] D93446: [RISCV] Add vadd with mask and without mask builtin.

2021-02-09 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:89
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {"__builtin_rvv_" #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsRISCV.def"

Jim wrote:
> Builtins for other extension don't have "__builtin_rvv_" prefix.
maybe we could rename BuiltinsRISCV.def as BuiltinsRVV.def, and other extension 
defines their own .def file?

@Jim do you have any suggestion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93446

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This makes clang assert for some inputs. See 
https://bugs.chromium.org/p/chromium/issues/detail?id=1175886#c10 for a repro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D96262: [clang][index] report references from unreslovedLookupExpr.

2021-02-09 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

Thanks. LG.
Couple of comments about adding tests to clangd as well.




Comment at: clang/test/Index/Core/index-dependent-source.cpp:233
+// CHECK: [[@LINE-1]]:3 | function/C | foo | c:@FT@>1#Tfoo#v# |  | 
Ref,Call,RelCall,RelCont | rel: 1
+}

Maybe add more tests to clangd/XrefsTests like the ones specifically mentioned 
in https://github.com/clangd/clangd/issues/399

- Ref in uninstantiated `bar` is reported.
```
template  void $decl[[foo]](T t); 
template  void bar(T t) { [[foo]](t); }
void baz(int x) { [[f^oo]](x); }
```

What do you think about the behaviour ?
Should we report the ref in bar in the following example ?
- ADL: May be add a negative test documenting the behaviour. 
```
namespace ns {
struct S{};
void $decl[[foo]](S s);
}
template  void foo(T t); 
template  void bar(T t) { foo(t); } // FIXME: Maybe report this foo 
as a ref to ns::foo when bar is instantiated?
void baz(int x) { 
  ns::S s;
  bar(s);
  [[f^oo]](s); 
}

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96262

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


[PATCH] D96347: Include function return type in JSON AST dumps.

2021-02-09 Thread Rokas Kupstys via Phabricator via cfe-commits
rokups created this revision.
rokups requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For some reason return type was not included. Even though it is present
in full type dump, it is not good enough as C++ types can get quite
complex. Besides there is no way to get a desugared version of the type
from function type string. Patch uses "returnType" json key, just like
ObjCMethodDecl dumper. I also updated tests. If anything is missing -
please let me know.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96347

Files:
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-decl-context-json.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-decl-json.m
  clang/test/AST/ast-dump-expr-json.c
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr-json.m
  clang/test/AST/ast-dump-funcs-json.cpp
  clang/test/AST/ast-dump-macro-json.c
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt-json.m
  clang/test/AST/ast-dump-template-decls-json.cpp

Index: clang/test/AST/ast-dump-template-decls-json.cpp
===
--- clang/test/AST/ast-dump-template-decls-json.cpp
+++ clang/test/AST/ast-dump-template-decls-json.cpp
@@ -287,6 +287,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -394,6 +397,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty...)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -526,6 +532,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -592,6 +601,9 @@
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "void (float)"
 // CHECK-NEXT:},
+// CHECK-NEXT:"returnType": {
+// CHECK-NEXT: "qualType": "void"
+// CHECK-NEXT:},
 // CHECK-NEXT:"inner": [
 // CHECK-NEXT: {
 // CHECK-NEXT:  "kind": "TemplateArgument",
@@ -776,6 +788,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty, Uy)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -906,6 +921,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -1014,6 +1032,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (int)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -1176,6 +1197,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (Ty)"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -1302,6 +1326,9 @@
 // CHECK-NEXT:  "name": "h",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 // CHECK-NEXT:]
@@ -2468,6 +2495,9 @@
 // CHECK-NEXT:  "name": "f",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 // CHECK-NEXT:]
@@ -2558,6 +2588,9 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "returnType": {
+// CHECK-NEXT:   "qualType": "void"
+// CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
Index: clang/test/AST/ast-dump-stmt-json.m
=

[PATCH] D96178: [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

2021-02-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

@svenvh We haven't looked into address spaces in details when adding this. I 
wonder what behavior would make sense for new/delete? Do we plan to allow 
new/delete in named address spaces or only in generic? It might be more helpful 
to allow named address spaces since generic has not been intended for 
allocations, but however generic makes things easier because it avoids 
duplication and the concrete address space can always be cast to it. I think 
`constant` doesn't make sense at all since nothing can be done with a readonly 
chunk of memory?

Another aspect to consider - how will address spaces aligned with the concept 
of overloading i.e.

- Declaring multiple new operators with different address spaces in the same 
scope generates an error since overloading by the return type is not allowed.
- Declaring multiple delete operators differing by address spaces seems to fail 
because C++ doesn't allow to overload it yet.

While the test in the review works, if we start using other than generic 
address spaces it fails with various compile-time errors. For example, I get an 
error if I try to assign to `local` address space pointer even if the 
declaration of new has the address space too:

`class A {
public:

  __local void* operator new(size_t);

};
__local A* a = new A;`

`error: assigning 'A *' to '__local A *' changes address space of pointer`

Perhaps this deserves a PR at least?




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:15287
+
+if (CanQual ExpectedPtrTy =
+ExpectedResultType->getAs()) {

I think `getAs` returns a `PointerType*` that we could just use straight away 
without the need for `CanQual`? but actually, you could just change to `auto*` 
that would make things easier.

The same below.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:15289
+ExpectedResultType->getAs()) {
+  ExpectedResultType = SemaRef.Context.getCanonicalType(
+  RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy->getTypePtr()));

FYI I think `ExpectedResultType` is going to be in always in the canonical form 
here by the way it is constructed so `getCanonicalType` should be redundant.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96178

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


[clang] de1966e - Revert "[ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly"

2021-02-09 Thread Nico Weber via cfe-commits
Author: Nico Weber
Date: 2021-02-09T11:06:32-05:00
New Revision: de1966e5427985163f8e816834b3a0564b5e24cd

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

LOG: Revert "[ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of 
explicitly"

This reverts commit 4a64d8fe392449b205e59031aad5424968cf7446.
Makes clang crash when buildling trivial iOS programs, see comment
after https://reviews.llvm.org/D92808#2551401

Added: 
llvm/test/Transforms/TailCallElim/deopt-bundle.ll

Modified: 
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenObjC/arc-unsafeclaim.m
llvm/docs/LangRef.rst
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Intrinsics.td
llvm/include/llvm/IR/LLVMContext.h
llvm/lib/Analysis/ObjCARCInstKind.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.h
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/ObjCARC/PtrState.cpp
llvm/lib/Transforms/ObjCARC/PtrState.h
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
llvm/test/CodeGen/AArch64/call-rv-marker.ll
llvm/test/Transforms/DeadArgElim/deadretval.ll
llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
llvm/test/Transforms/ObjCARC/contract.ll
llvm/test/Transforms/ObjCARC/intrinsic-use.ll
llvm/test/Transforms/ObjCARC/rv.ll

Removed: 
clang/test/CodeGenObjC/arc-rv-attr.m
llvm/include/llvm/Analysis/ObjCARCUtil.h
llvm/test/Transforms/Inline/inline-retainRV-call.ll
llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
llvm/test/Transforms/TailCallElim/operand-bundles.ll



diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index ab3fba615335..3f930c76fe0a 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/BinaryFormat/MachO.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
@@ -2079,15 +2078,6 @@ void 
CodeGenFunction::EmitARCIntrinsicUse(ArrayRef values) {
   EmitNounwindRuntimeCall(fn, values);
 }
 
-/// Emit a call to "clang.arc.noop.use", which consumes the result of a call
-/// that has operand bundle "clang.arc.rv".
-void CodeGenFunction::EmitARCNoopIntrinsicUse(ArrayRef values) {
-  llvm::Function *&fn = CGM.getObjCEntrypoints().clang_arc_noop_use;
-  if (!fn)
-fn = CGM.getIntrinsic(llvm::Intrinsic::objc_clang_arc_noop_use);
-  EmitNounwindRuntimeCall(fn, values);
-}
-
 static void setARCRuntimeFunctionLinkage(CodeGenModule &CGM, llvm::Value *RTF) 
{
   if (auto *F = dyn_cast(RTF)) {
 // If the target runtime doesn't naturally support ARC, emit weak
@@ -2314,11 +2304,10 @@ static void 
emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) {
 // with this marker yet, so leave a breadcrumb for the ARC
 // optimizer to pick up.
 } else {
-  const char *retainRVMarkerKey = 
llvm::objcarc::getRVMarkerModuleFlagStr();
-  if (!CGF.CGM.getModule().getModuleFlag(retainRVMarkerKey)) {
+  const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
+  if (!CGF.CGM.getModule().getModuleFlag(markerKey)) {
 auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly);
-CGF.CGM.getModule().addModuleFlag(llvm::Module::Error,
-  retainRVMarkerKey, str);
+CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str);
   }
 }
   }
@@ -2328,46 +2317,6 @@ static void 
emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) {
 CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
-static llvm::Value *emitOptimizedARCReturnCall(llvm::Value *value,
-   bool IsRetainRV,
-   CodeGenFunction &CGF) {
-  emitAutoreleasedReturnValueMarker(CGF);
-
-  // Add operand bundle "clang.arc.rv" to the call instead of emitting retainRV
-  // or claimRV calls in the IR. We currently do this only when the 
optimization
-  // level isn't -O0 since global-isel, which is currently run at -O0, doesn't
-  // know about the operand bundle.
-
-  // FIXME: Do this when the target isn't aarch6

  1   2   >