[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree.  The arrangement logic is assuming that the exact pointer type doesn't 
matter because it's all just a pointer in the end, but of course that breaks 
down when we start inferring attributes.

Pointer authentication also really wants to know the original declaration which 
gave rise to a v-table slot, and it's not the only thing.  Maybe we should just 
change the v-table data structure to store that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[PATCH] D100615: [RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and baremetal::Linker

2021-04-16 Thread ShihPo Hung via Phabricator via cfe-commits
arcbbb updated this revision to Diff 338004.
arcbbb added a comment.

Addressed @MaskRay 's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100615

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/riscv-args.c


Index: clang/test/Driver/riscv-args.c
===
--- /dev/null
+++ clang/test/Driver/riscv-args.c
@@ -0,0 +1,7 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### -target riscv32 \
+// RUN:   --gcc-toolchain= -Xlinker --defsym=ABC=10 -T a.lds %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=ABC=10" {{.*}} "-T" "a.lds"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -181,14 +181,14 @@
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs,
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-
   // TODO: add C++ includes and libs if compiling C++.
 
   if (!Args.hasArg(options::OPT_nostdlib) &&


Index: clang/test/Driver/riscv-args.c
===
--- /dev/null
+++ clang/test/Driver/riscv-args.c
@@ -0,0 +1,7 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### -target riscv32 \
+// RUN:   --gcc-toolchain= -Xlinker --defsym=ABC=10 -T a.lds %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=ABC=10" {{.*}} "-T" "a.lds"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -181,14 +181,14 @@
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs,
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-
   // TODO: add C++ includes and libs if compiling C++.
 
   if (!Args.hasArg(options::OPT_nostdlib) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

@max_s I think you need to rebase on current main and fix two tests as 
//probably// D98237  (or another patch) 
changed the behaviour of this patch.

  [  FAILED  ] 2 tests, listed below:
  [  FAILED  ] FormatTest.FormatsAccessModifiers
  [  FAILED  ] FormatTest.FormatsAfterAccessModifiers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

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


[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I have tried to fix this in D100388 , but i 
don't quite understand all the moving parts,
so it's still not in a working state (even though it fixed those two tests),
so i'm not sure how productive it is to develop it via a review feedback :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[PATCH] D100596: [WebAssembly] Remove saturating fp-to-int target intrinsics

2021-04-16 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:124-127
+  if (Subtarget->hasNontrappingFPToInt())
+for (auto Op : {ISD::FP_TO_SINT_SAT, ISD::FP_TO_UINT_SAT})
+  for (auto T : {MVT::i32, MVT::i64})
+setOperationAction(Op, T, Custom);

So far these have been expanded then?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2100
+TargetLowering::DAGCombinerInfo &DCI) {
+  auto &DAG = DCI.DAG;
+  assert(N->getOpcode() == ISD::CONCAT_VECTORS);

So even though you used `Builder.CreateShuffleVector` in Clang, do they appear 
as not `VECTOR_SHUFFLE` but `CONCAT_VECTORS` by the time they reach isel?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2130
+return SDValue();
+  if (!!SplatValue)
+return SDValue();

Nit: I think it is a little easier to read 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100596

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


[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-16 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S updated this revision to Diff 338011.
Max_S added a comment.

Sorry for the inconvenience. These were the errors, that inspired this patch.

In all cases the new version is now the correct one. The default setting of 
EmptyLineBeforeAccessModifier is to insert empty lines for logical blocks, 
which it does now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,48 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsAfterAccessModifiers) {
@@ -9266,32 +9308,26 @@
   // Leave tests rely on the code layout, test::messUp can not be used.
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
   Style.MaxEmptyLinesToKeep = 0u;
-  EXPECT_EQ("struct foo {\n"
-"private:\n"
-"  void f() {}\n"
-"private:\n"
-"  int i;\n"
-"protected:\n"
-"  int j;\n"
-"};\n",
-format("struct foo {\n"
-   "private:\n"
-   "  void f() {}\n"
-   "\n"
-   "private:\n"
-   "  int i;\n"
-   "\n"
-   "protected:\n"
-   "  int j;\n"
-   "};\n",
-   Style));
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   Style);
 
   // Check if MaxEmptyLinesToKeep is respected.
   EXPECT_EQ("struct foo {\n"
 "private:\n"
 "  void f() {}\n"
+"\n"
 "private:\n"
 "  int i;\n"
+"\n"
 "protected:\n"
 "  int j;\n"
 "};\n",
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1254,15 +1254,14 @@
   if (PreviousLine && RootToken.isAccessSpecifier()) {
 switch (Style.EmptyLineBeforeAccessModifier) {
 case FormatStyle::ELBAMS_Never:
-  if (RootToken.NewlinesBefore > 1)
+  if (Newlines > 1)
 Newlines = 1;
   break;
 case FormatStyle::ELBAMS_Leave:
   Newlines = std::max(RootToken.NewlinesBefore, 1u);
   break;
 case FormatStyle::ELBAMS_LogicalBlock:
-  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
-  RootToken.NewlinesBefore <= 1)
+  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) && Newlines <= 1)
 Newlines = 2;
   if (PreviousLine->First->isAccessSpecifier())
 Newlines = 1; // Previous is an access modifier remove all new lines.
@@ -1273,8 +1272,7 @@
 previousToken = PreviousLine->Last->getPreviousNonComment();
   else
 previousToken = PreviousLine->Last;
-  if ((!previousToken || !previousToken->is(tok::l_brace)) &&
-  RootToken.NewlinesBefore <= 1)
+  if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 1)
 Newlines = 2;
 } break;
 }
Index: clang/docs/ReleaseNotes.rst
===

[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-16 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 338017.
Jim added a comment.

1. Updating D99158 : [RISCV][WIP] Implement 
intrinsics for P extension #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Only define 1 kind of intrinsic for most intructions, which
operand type and result type are the same scalar or vector type.
But s[z]unpkd* instructions have two kinds of intrinsics, extra
one has operand element width is half of result element width but
with more elements.

Refine code for IR codegen in CGBuiltin.cpp to look like B extension's 
implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv32p.c
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv64p.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoP.td
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv32p.ll
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv64p.ll

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-04-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sorry for the delay.  That seems like a reasonable summary of our discussion.  
Let me try to lay out the right architecture for this as I see it.

Conceptually, we can split the translation unit into a sequence of partial 
translation units (PTUs).  Every declaration will be associated with a unique 
PTU that owns it.

The first key insight here is that the owning PTU isn't always the "active" 
(most recent) PTU, and it isn't always the PTU that the declaration "comes 
from".  A new declaration (that isn't a redeclaration or specialization of 
anything) does belong to the active PTU.  A template specialization, however, 
belongs to the most recent PTU of all the declarations in its signature — 
mostly that means that it can be pulled into a more recent PTU by its template 
arguments.

The second key insight is that processing a PTU might extend an earlier PTU.  
Rolling back the later PTU shouldn't throw that extension away.  For example, 
if the second PTU defines a template, and the third PTU requires that template 
to be instantiated at `float`, that template specialization is still part of 
the second PTU.  Similarly, if the fifth PTU uses an inline function belonging 
to the fourth, that definition still belongs to the fourth.  When we go to emit 
code in a new PTU, we map each declaration we have to emit back to its owning 
PTU and emit it in a new module for just the extensions to that PTU.  We keep 
track of all the modules we've emitted for a PTU so that we can unload them all 
if we decide to roll it back.

Most declarations/definitions will only refer to entities from the same or 
earlier PTUs.  However, it is possible (primarily by defining a 
previously-declared entity, but also through templates or ADL) for an entity 
that belongs to one PTU to refer to something from a later PTU.  We will have 
to keep track of this and prevent unwinding to later PTU when we recognize it.  
Fortunately, this should be very rare; and crucially, we don't have to do the 
bookkeeping for this if we've only got one PTU, e.g. in normal compilation.  
Otherwise, PTUs after the first just need to record enough metadata to be able 
to revert any changes they've made to declarations belonging to earlier PTUs, 
e.g. to redeclaration chains or template specialization lists.

It should even eventually be possible for PTUs to provide their own slab 
allocators which can be thrown away as part of rolling back the PTU.  We can 
maintain a notion of the active allocator and allocate things like Stmt/Expr 
nodes in it, temporarily changing it to the appropriate PTU whenever we go to 
do something like instantiate a function template.  More care will be required 
when allocating declarations and types, though.

We would want the PTU to be efficiently recoverable from a `Decl`; I'm not sure 
how best to do that.  An easy option that would cover most declarations would 
be to make multiple `TranslationUnitDecl`s and parent the declarations 
appropriately, but I don't think that's good enough for things like member 
function templates, since an instantiation of that would still be parented by 
its original class.  Maybe we can work this into the DC chain somehow, like how 
lexical DCs are.


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

https://reviews.llvm.org/D96033

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-16 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:762
+  for (unsigned Opc = 0; Opc < ISD::BUILTIN_OP_END; ++Opc)
+setOperationAction(Opc, VT, Expand);
+

craig.topper wrote:
> You probably need handling for insert_vector_elt and extract_vector_elt or 
> some of the expansions will probably break.
I will implement it in another patch for codegen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D100626: [analyzer][NFC] Remove duplicated work from retain count leak report

2021-04-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
kristof.beyls, xazax.hun.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allocation site is the key location for the leak checker.  It is a
uniqueing location for the report and a source of information for
the warning's message.

Before this patch, we calculated and used it twice in bug report and
in bug report visitor.  Such duplication is not only harmful
performance-wise (not much, but still), but also design-wise.  Because
changing something about the end piece of the report should've been
repeated for description as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100626

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp


Index: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -337,11 +337,15 @@
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
+  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
 const ExplodedNode *N,
 PathSensitiveBugReport &BR) override;
+
+private:
+  const MemRegion *FirstBinding;
 };
 
 } // end namespace retaincountchecker
@@ -729,14 +733,6 @@
   // assigned to different variables, etc.
   BR.markInteresting(Sym);
 
-  // We are reporting a leak.  Walk up the graph to get to the first node where
-  // the symbol appeared, and also get the first VarDecl that tracked object
-  // is stored to.
-  AllocationInfo AllocI = GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
-  const MemRegion* FirstBinding = AllocI.R;
-  BR.markInteresting(AllocI.InterestingMethodContext);
-
   PathDiagnosticLocation L = cast(BR).getEndOfPath();
 
   std::string sbuf;
@@ -902,15 +898,15 @@
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug &D, const LangOptions &LOpts,
- ExplodedNode *n, SymbolRef sym,
+ ExplodedNode *N, SymbolRef Sym,
  CheckerContext &Ctx)
-: RefCountReport(D, LOpts, n, sym, /*isLeak=*/true) {
+: RefCountReport(D, LOpts, N, Sym, /*isLeak=*/true) {
 
-  deriveAllocLocation(Ctx, sym);
+  deriveAllocLocation(Ctx, Sym);
   if (!AllocBinding)
-deriveParamLocation(Ctx, sym);
+deriveParamLocation(Ctx, Sym);
 
   createDescription(Ctx);
 
-  addVisitor(std::make_unique(sym));
+  addVisitor(std::make_unique(Sym, AllocBinding));
 }


Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -337,11 +337,15 @@
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
+  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
 const ExplodedNode *N,
 PathSensitiveBugReport &BR) override;
+
+private:
+  const MemRegion *FirstBinding;
 };
 
 } // end namespace retaincountchecker
@@ -729,14 +733,6 @@
   // assigned to different variables, etc.
   BR.markInteresting(Sym);
 
-  // We are reporting a leak.  Walk up the graph to get to the first node where
-  // the symbol appeared, and also get the first VarDecl that tracked object
-  // is stored to.
-  AllocationInfo AllocI = GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
-  const MemRegion* FirstBinding = AllocI.R;
-  BR.markInteresting(AllocI.InterestingMethodContext);
-
   PathDiagnosticLocation L = cast(BR).getEndOfPath();
 
   std::string sbuf;
@@ -902,15 +898,15 @@
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug &D, const LangOptions &LOpts,
- ExplodedNode *n, SymbolRef sym,
+ ExplodedNode *N, SymbolRef Sym,
  CheckerContext &Ctx)
-: RefCountReport(D, LOpts, n, sym, /*isLeak=*/true) {
+: RefCountReport(D, LOpts, N, Sym, /*isLeak=*/true) {
 
-  der

[clang] fd4e08a - [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-16 Thread Marek Kurdej via cfe-commits

Author: Max Sagebaum
Date: 2021-04-16T10:39:13+02:00
New Revision: fd4e08aa8f7edfe877d022859ce162a1b4fa684c

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

LOG: [clang-format] Inconsistent behavior regarding line break before access 
modifier

Fixes https://llvm.org/PR41870.

Checks for newlines in option Style.EmptyLineBeforeAccessModifier are now based 
on the formatted new lines and not on the new lines in the file.

Reviewed By: HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ddf048c2dd33a..ad7ff71802ddc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -225,6 +225,10 @@ clang-format
 - Option ``EmptyLineAfterAccessModifier`` has been added to remove, force or 
keep
   new lines after access modifiers.
 
+- Checks for newlines in option ``EmptyLineBeforeAccessModifier`` are now based
+  on the formatted new lines and not on the new lines in the file. (Fixes
+  https://llvm.org/PR41870.)
+
 libclang
 
 

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 991f4fafe5ac2..e38d90d58362e 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1254,15 +1254,14 @@ void UnwrappedLineFormatter::formatFirstToken(
   if (PreviousLine && RootToken.isAccessSpecifier()) {
 switch (Style.EmptyLineBeforeAccessModifier) {
 case FormatStyle::ELBAMS_Never:
-  if (RootToken.NewlinesBefore > 1)
+  if (Newlines > 1)
 Newlines = 1;
   break;
 case FormatStyle::ELBAMS_Leave:
   Newlines = std::max(RootToken.NewlinesBefore, 1u);
   break;
 case FormatStyle::ELBAMS_LogicalBlock:
-  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
-  RootToken.NewlinesBefore <= 1)
+  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) && Newlines <= 
1)
 Newlines = 2;
   if (PreviousLine->First->isAccessSpecifier())
 Newlines = 1; // Previous is an access modifier remove all new lines.
@@ -1273,8 +1272,7 @@ void UnwrappedLineFormatter::formatFirstToken(
 previousToken = PreviousLine->Last->getPreviousNonComment();
   else
 previousToken = PreviousLine->Last;
-  if ((!previousToken || !previousToken->is(tok::l_brace)) &&
-  RootToken.NewlinesBefore <= 1)
+  if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 
1)
 Newlines = 2;
 } break;
 }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 36d560469119a..5ae67d91323df 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,48 @@ TEST_F(FormatTest, FormatsAccessModifiers) {
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsAfterAccessModifiers) {
@@ -9266,32 +9308,26 @@ TEST_F(FormatTest, FormatsAfterAccessModifiers) {
   // Leave tests rely on the code layout, test::messUp can not be used.
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
   Style.MaxEmptyLinesToKeep = 0u;
-  EXPECT_EQ("struct foo {\n"
-"private:\n"
-"  void f() {}\n"
-"private:\n"
-   

[PATCH] D99503: [clang-format] Inconsistent behavior regarding line break before access modifier

2021-04-16 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd4e08aa8f7e: [clang-format] Inconsistent behavior regarding 
line break before access modifier (authored by Max_S, committed by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99503

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9177,6 +9177,48 @@
"  int j;\n"
"};\n",
Style);
+
+  FormatStyle NoEmptyLines = getLLVMStyle();
+  NoEmptyLines.MaxEmptyLinesToKeep = 0;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "private:\n"
+   "  int i;\n"
+   "public:\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
+
+  NoEmptyLines.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "public:\n"
+   "\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   NoEmptyLines);
 }
 
 TEST_F(FormatTest, FormatsAfterAccessModifiers) {
@@ -9266,32 +9308,26 @@
   // Leave tests rely on the code layout, test::messUp can not be used.
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
   Style.MaxEmptyLinesToKeep = 0u;
-  EXPECT_EQ("struct foo {\n"
-"private:\n"
-"  void f() {}\n"
-"private:\n"
-"  int i;\n"
-"protected:\n"
-"  int j;\n"
-"};\n",
-format("struct foo {\n"
-   "private:\n"
-   "  void f() {}\n"
-   "\n"
-   "private:\n"
-   "  int i;\n"
-   "\n"
-   "protected:\n"
-   "  int j;\n"
-   "};\n",
-   Style));
+  verifyFormat("struct foo {\n"
+   "private:\n"
+   "  void f() {}\n"
+   "\n"
+   "private:\n"
+   "  int i;\n"
+   "\n"
+   "protected:\n"
+   "  int j;\n"
+   "};\n",
+   Style);
 
   // Check if MaxEmptyLinesToKeep is respected.
   EXPECT_EQ("struct foo {\n"
 "private:\n"
 "  void f() {}\n"
+"\n"
 "private:\n"
 "  int i;\n"
+"\n"
 "protected:\n"
 "  int j;\n"
 "};\n",
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1254,15 +1254,14 @@
   if (PreviousLine && RootToken.isAccessSpecifier()) {
 switch (Style.EmptyLineBeforeAccessModifier) {
 case FormatStyle::ELBAMS_Never:
-  if (RootToken.NewlinesBefore > 1)
+  if (Newlines > 1)
 Newlines = 1;
   break;
 case FormatStyle::ELBAMS_Leave:
   Newlines = std::max(RootToken.NewlinesBefore, 1u);
   break;
 case FormatStyle::ELBAMS_LogicalBlock:
-  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
-  RootToken.NewlinesBefore <= 1)
+  if (PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) && Newlines <= 1)
 Newlines = 2;
   if (PreviousLine->First->isAccessSpecifier())
 Newlines = 1; // Previous is an access modifier remove all new lines.
@@ -1273,8 +1272,7 @@
 previousToken = PreviousLine->Last->getPreviousNonComment();
   else
 previousToken = PreviousLine->Last;
-  if ((!previousToken || !previousToken->is(tok::l_brace)) &&
-  RootToken.NewlinesBefore <= 1)
+  if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 1)
 Newlines = 2;
 } break;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -22

[PATCH] D100611: [RISCV] Add new attribute __clang_riscv_builtin_alias for intrinsics.

2021-04-16 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

Is this idea that this will later be "automatically" applied to builtins in 
`riscv_vector.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

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


[PATCH] D100516: [AST] Add TypeLoc support to node introspection

2021-04-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 338030.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100516

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -26,25 +26,27 @@
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
 
-template
-std::map
+template 
+std::vector>
 FormatExpected(const MapType &Accessors) {
-  std::map Result;
+  std::vector> Result;
   llvm::transform(llvm::make_filter_range(Accessors,
   [](const auto &Accessor) {
 return Accessor.first.isValid();
   }),
-  std::inserter(Result, Result.end()),
-  [](const auto &Accessor) {
-return std::make_pair(LocationCallFormatterCpp::format(
-  *Accessor.second.get()),
-  Accessor.first);
+  std::back_inserter(Result), [](const auto &Accessor) {
+return std::make_pair(
+LocationCallFormatterCpp::format(*Accessor.second),
+Accessor.first);
   });
   return Result;
 }
 
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
+#define STRING_LOCATION_STDPAIR(INSTANCE, LOC) \
+  std::make_pair(std::string(#LOC), INSTANCE->LOC)
+
 /**
   A test formatter for a hypothetical language which needs
   neither casts nor '->'.
@@ -200,26 +202,85 @@
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
-  EXPECT_THAT(ExpectedLocations,
-  UnorderedElementsAre(
-  STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getLocation()),
-  STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
+  llvm::sort(ExpectedLocations);
+
+  // clang-format off
+  EXPECT_EQ(
+  ExpectedLocations,
+  (std::vector>{
+STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getBodyRBrace()),
+STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeBegin()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeEnd()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getRParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getTemplateNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getNextTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getNextTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSo

[clang] efc013e - Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

2021-04-16 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-04-16T09:16:58Z
New Revision: efc013ec4d950a68e6f80dd98cda35e1a96a6fc8

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

LOG: Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

This reverts commit 7029cffc4e78556cfe820791c612968bb15b2ffb.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/tools/CMakeLists.txt

Removed: 
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_different
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_fail
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx906
clang/test/Driver/Inputs/amdgpu-arch/amdgpu_arch_gfx908_gfx908
clang/test/Driver/amdgpu-openmp-system-arch-fail.c
clang/test/Driver/amdgpu-openmp-system-arch.c
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index aa3b00c231cbe..5e580cc4fbb7a 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -67,8 +67,6 @@ def err_drv_no_hip_runtime : Error<
   "cannot find HIP runtime. Provide its path via --rocm-path, or pass "
   "-nogpuinc to build without HIP runtime.">;
 
-def err_drv_undetermined_amdgpu_arch : Error<
-  "Cannot determine AMDGPU architecture. Consider passing it via -march">;
 def err_drv_cuda_version_unsupported : Error<
   "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
   "but installation at %3 is %4. Use --cuda-path to specify a 
diff erent CUDA "

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 5fbcd64b69376..9e15712eb2d51 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -918,8 +918,6 @@ def rocm_path_EQ : Joined<["--"], "rocm-path=">, 
Group,
   HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
 def hip_path_EQ : Joined<["--"], "hip-path=">, Group,
   HelpText<"HIP runtime installation path, used for finding HIP version and 
adding HIP include path.">;
-def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">, Group,
-  HelpText<"Tool used for detecting AMD GPU arch in the system.">;
 def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, 
Group,
   HelpText<"ROCm device library path. Alternative to rocm-path.">;
 def : Joined<["--"], "hip-device-lib-path=">, Alias;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 37da2c05dcf67..dc9c9751c851d 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -12,15 +12,10 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
-#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
-#define AMDGPU_ARCH_PROGRAM_NAME "amdgpu-arch"
-
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
@@ -720,57 +715,6 @@ void AMDGPUToolChain::checkTargetID(
   }
 }
 
-llvm::SmallVector, 1>
-AMDGPUToolChain::detectSystemGPUs(const ArgList &Args) const {
-  std::string Program;
-  if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
-Program = A->getValue();
-  else
-Program = GetProgramPath(AMDGPU_ARCH_PROGRAM_NAME);
-  llvm::SmallString<64> OutputFile;
-  llvm::sys::fs::createTemporaryFile("print-system-gpus", "" /* No Suffix */,
- OutputFile);
-  llvm::FileRemover OutputRemover(OutputFile.c_str());
-  llvm::Optional Redirects[] = {
-  {""},
-  StringRef(OutputFile),
-  {""},
-  };
-
-  if (llvm::sys::ExecuteAndWait(Program.c_str(), {}, {}, Redirects)) {
-return {};
-  }
-
-  llvm::ErrorOr> OutputBuf =
-  llvm::MemoryBuffer::getFile(OutputFile.c_str());
-  if (!OutputBuf)
-return {};
-
-  llvm::SmallVector, 1> GPUArchs;
-  for (llvm::line_iterator LineIt(**OutputBuf); !LineIt.is_at_end(); ++LineIt) 
{
-GPUArchs.push_back(*LineIt);
-  }
-  return GPUArchs;
-}
-
-SmallString<8> AMDGPUToolChain::getSystemGPUArch(const ArgList &Args) const {
-  // detect the AMDGPU installed in system
-  auto GPUArchs = detectSystemGPUs(Args);
-  if (GPUArchs.empty()) {
-return SmallString<8>(

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

I've reverted this from main for now as there seems to be issue with executing 
test script on some CI machines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-16 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 338032.
olestrohm set the repository for this revision to rG LLVM Github Monorepo.
olestrohm added a comment.

Restricted the checks to C++ for OpenCL and added another test for OpenCL 
vector types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100471

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,58 @@
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+kernel void int_v(int in);
+kernel void int_p(__global int *in);
+kernel void int_r(__global int &in);
+kernel void int_p_p(__global int *__global *in);
+kernel void int_p_r(__global int *__global &in);
+kernel void int_p_p_r(__global int *__global *__global &in);
+
+// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
+kernel void k_atomic_v(atomic_int in);
+kernel void k_atomic_p(__global atomic_int *in);
+kernel void k_atomic_r(__global atomic_int &in);
+
+kernel void k_pipe(read_only pipe int in, write_only pipe int out);
+kernel void k_sampler(sampler_t in);
+kernel void k_void(__global void *in);
+
+typedef int int4 __attribute__((ext_vector_type(4)));
+
+kernel void int4_v(int4 in);
+kernel void int4_p(__global int4 *in);
+kernel void int4_p_p(__global int4 *__global *in);
+kernel void int4_r(__global int4 &in);
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD *in) {}
+kernel void pod_p_p(__global POD *__global *in) {}
+kernel void pod_r(__global POD &in) {}
+
+struct StandardLayout {
+  int a;
+  int b;
+  StandardLayout(int a, int b) : a(a), b(b) {}
+};
+
+kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_p(__global StandardLayout *in) {}
+kernel void standard_p_p(__global StandardLayout *__global *in) {}
+kernel void standard_r(__global StandardLayout &in) {}
+
+struct Trivial {
+  int a;
+private:
+  int b;
+};
+
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial *in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p_p(__global Trivial *__global *in) {} //expected-error{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_r(__global Trivial &in) {} //expected-error{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8648,7 +8648,7 @@
 }
 
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
-  if (PT->isPointerType()) {
+  if (PT->isPointerType() || PT->isReferenceType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
@@ -8665,6 +8665,15 @@
 
   return PtrPtrKernelParam;
 }
+
+// C++ for OpenCL v1.0 s2.4:
+// Moreover the types used in parameters of the kernel functions must be:
+// Standard layout types for pointer parameters. The same applies to
+// reference if an implementation supports them in kernel parameters.
+if (S.getLangOpts().OpenCLCPlusPlus && !PointeeType->isAtomicType() &&
+!PointeeType->isVoidType() && !PointeeType->isStandardLayoutType())
+  return InvalidKernelParam;
+
 return PtrKernelParam;
   }
 
@@ -8689,9 +8698,6 @@
   PT->isHalfType())
 return InvalidKernelParam;
 
-  if (PT->isRecordType())
-return RecordKernelParam;
-
   // Look into an array argument to check if it has a forbidden type.
   if (PT->isArrayType()) {
 const Type *UnderlyingTy = PT->getPointeeOrArrayElementType();
@@ -8701,6 +8707,17 @@
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }
 
+  // C++ for OpenCL v1.0 s2.4:
+  // Moreover the types used in parameters of the kernel functions must be:
+  // Trivial and standard-layout types C++17 [basic.types] (plain old data
+  // types) for par

[PATCH] D100460: [WIP][clang] Move deep copy into CompilerInvocation::clone

2021-04-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 338034.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100460

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,13 +97,24 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor/assignment perform deep copy of reference-counted pointers.
+// Clone performs deep copy of reference-counted pointers.
 
-TEST(CompilerInvocationTest, DeepCopyConstructor) {
+TEST(CompilerInvocationTest, CloneWithMoveConstructor) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
-  CompilerInvocation B(A);
+  CompilerInvocation B(A.clone());
+  B.getAnalyzerOpts()->Config["Key"] = "New";
+
+  ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+}
+
+TEST(CompilerInvocationTest, CloneWithMoveAssignment) {
+  CompilerInvocation A;
+  A.getAnalyzerOpts()->Config["Key"] = "Old";
+
+  CompilerInvocation B;
+  B = A.clone();
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
@@ -120,6 +131,11 @@
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, NotCopyConstructibleNorAssignable) {
+  ASSERT_FALSE(std::is_copy_constructible::value);
+  ASSERT_FALSE(std::is_copy_assignable::value);
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -64,7 +64,8 @@
 return;
   }
 
-  auto Invocation = std::make_shared(CI.getInvocation());
+  auto Invocation =
+  std::make_shared(CI.getInvocation().clone());
 
   FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
   InputKind IK = Language::CXX; // FIXME
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -244,7 +244,7 @@
 CompilerInstance Instance(CI.getPCHContainerOperations(),
   &CI.getModuleCache());
 Instance.setInvocation(
-std::make_shared(CI.getInvocation()));
+std::make_shared(CI.getInvocation().clone()));
 Instance.createDiagnostics(
 new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
 /*ShouldOwnClient=*/true);
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -317,7 +317,8 @@
 PreambleCallbacks &Callbacks) {
   assert(VFS && "VFS is null");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
@@ -501,7 +502,8 @@
   Bounds.Size <= MainFileBuffer.getBufferSize() &&
   "Buffer is too large. Bounds were calculated from a different buffer?");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1041,8 +1041,8 @@
   llvm::TimeTraceScope TimeScope("Module Compile", ModuleName);
 
   // Construct a compiler invocation for creating this module.
-  auto Invocation =
-  std::make_shared(ImportingInstance.getInvocation());
+  auto Invocation = std::make_shared(
+  ImportingInstance.getInvocation().clone());
 
   PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
 
Index: clang/lib/Frontend/ChainedIncludes

[PATCH] D100460: [WIP][clang] Move deep copy into CompilerInvocation::clone

2021-04-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 338036.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100460

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -97,29 +97,34 @@
   ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
 }
 
-// Copy constructor/assignment perform deep copy of reference-counted pointers.
+// Clone performs deep copy of reference-counted pointers.
 
-TEST(CompilerInvocationTest, DeepCopyConstructor) {
+TEST(CompilerInvocationTest, CloneWithMoveConstructor) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
-  CompilerInvocation B(A);
+  CompilerInvocation B(A.clone());
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
-TEST(CompilerInvocationTest, DeepCopyAssignment) {
+TEST(CompilerInvocationTest, CloneWithMoveAssignment) {
   CompilerInvocation A;
   A.getAnalyzerOpts()->Config["Key"] = "Old";
 
   CompilerInvocation B;
-  B = A;
+  B = A.clone();
   B.getAnalyzerOpts()->Config["Key"] = "New";
 
   ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
 }
 
+TEST(CompilerInvocationTest, NotCopyConstructibleNorAssignable) {
+  ASSERT_FALSE(std::is_copy_constructible::value);
+  ASSERT_FALSE(std::is_copy_assignable::value);
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
Index: clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -64,7 +64,8 @@
 return;
   }
 
-  auto Invocation = std::make_shared(CI.getInvocation());
+  auto Invocation =
+  std::make_shared(CI.getInvocation().clone());
 
   FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
   InputKind IK = Language::CXX; // FIXME
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -244,7 +244,7 @@
 CompilerInstance Instance(CI.getPCHContainerOperations(),
   &CI.getModuleCache());
 Instance.setInvocation(
-std::make_shared(CI.getInvocation()));
+std::make_shared(CI.getInvocation().clone()));
 Instance.createDiagnostics(
 new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
 /*ShouldOwnClient=*/true);
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -317,7 +317,8 @@
 PreambleCallbacks &Callbacks) {
   assert(VFS && "VFS is null");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
@@ -501,7 +502,8 @@
   Bounds.Size <= MainFileBuffer.getBufferSize() &&
   "Buffer is too large. Bounds were calculated from a different buffer?");
 
-  auto PreambleInvocation = std::make_shared(Invocation);
+  auto PreambleInvocation =
+  std::make_shared(Invocation.clone());
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1041,8 +1041,8 @@
   llvm::TimeTraceScope TimeScope("Module Compile", ModuleName);
 
   // Construct a compiler invocation for creating this module.
-  auto Invocation =
-  std::make_shared(ImportingInstance.getInvocation());
+  auto Invocation = std::make_shared(
+  ImportingInstance.getInvocation().clone());
 
   PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
 
Index: clang/lib/Frontend/ChainedIncludesSource.cpp
=

[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-16 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Both clang and GCC have their issues when it comes to matching the ACLE, so I 
wouldn't take the header guard as fact. It could be that we never implemented 
the A32 path for these functions/when they were added the document was in 
flux/no on ever tried this on A32.

I think you could implement `vadd_p8` on A32 with:

  veor.u8 d0, d0, d0

I think we just show A64 versions in the documentation. I think. Possible that 
what I've got above is a simd instruction but not an "advanced simd" 
instruction and that somehow doesn't count?

(caveat: I've mostly been making sure the function prototypes match the ACLE, 
not actually using these to do real work)

If I bodge the header to have vadd_p8 on Arm I get:

  $ cat /tmp/test.c
  #include 
  
  poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
  return vadd_p8 (a, b);
  }
  $ ./bin/clang -target arm-arm-none-eabi -mcpu=cortex-a57 -S -o - /tmp/test.c 
-O3
  <...>
  test_vadd_p8:
  .fnstart
  vmovd16, r0, r1
  vmovd17, r2, r3
  veord16, d17, d16
  vmovr0, r1, d16
  bx  lr

Which seems to confirm but I don't know why it's put behind the `__aarch64__` 
guard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100499

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


[PATCH] D100616: [clang][NFC] Fix a potential assert failure

2021-04-16 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 338045.
benshi001 retitled this revision from "[clang] Fix a potential assert failure" 
to "[clang][NFC] Fix a potential assert failure".
benshi001 added a reviewer: craig.topper.

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

https://reviews.llvm.org/D100616

Files:
  clang/include/clang/Basic/TargetBuiltins.h


Index: clang/include/clang/Basic/TargetBuiltins.h
===
--- clang/include/clang/Basic/TargetBuiltins.h
+++ clang/include/clang/Basic/TargetBuiltins.h
@@ -331,9 +331,9 @@
   }
 
   static constexpr uint64_t LargestBuiltinID = std::max(
-  {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
-   AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,
-   NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin,
+  {ARM::LastTSBuiltin, AArch64::LastTSBuiltin, BPF::LastTSBuiltin,
+   PPC::LastTSBuiltin, NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin,
+   X86::LastTSBuiltin, VE::LastTSBuiltin, RISCV::LastTSBuiltin,
Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin,
Le64::LastTSBuiltin, SystemZ::LastTSBuiltin,
WebAssembly::LastTSBuiltin});


Index: clang/include/clang/Basic/TargetBuiltins.h
===
--- clang/include/clang/Basic/TargetBuiltins.h
+++ clang/include/clang/Basic/TargetBuiltins.h
@@ -331,9 +331,9 @@
   }
 
   static constexpr uint64_t LargestBuiltinID = std::max(
-  {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
-   AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,
-   NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin,
+  {ARM::LastTSBuiltin, AArch64::LastTSBuiltin, BPF::LastTSBuiltin,
+   PPC::LastTSBuiltin, NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin,
+   X86::LastTSBuiltin, VE::LastTSBuiltin, RISCV::LastTSBuiltin,
Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin,
Le64::LastTSBuiltin, SystemZ::LastTSBuiltin,
WebAssembly::LastTSBuiltin});
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100616: [clang][NFC] Fix a potential assert failure

2021-04-16 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/include/clang/Basic/TargetBuiltins.h:334
   static constexpr uint64_t LargestBuiltinID = std::max(
   {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,

MaskRay wrote:
> SVE::FirstTSBuiltin can be dropped.
SVE and NEON are removed, VE and RISCV are added.

Can I commit it?


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

https://reviews.llvm.org/D100616

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-16 Thread David Candler via Phabricator via cfe-commits
dcandler updated this revision to Diff 338046.
dcandler added a comment.

I've updated the patch to fix the test failures, and slightly reworked the 
driver code to avoid the above iterator invalidation. I've also added a comment 
there to clarify what it is doing: individually determining whether the sha2 
and aes features should be enabled and explicitly setting them, since they can 
be controlled both by crypto and their specific feature. Using the last 
occurance of either in the vector ensures whatever options are passed to 
-mcpu/-march are evaluated in the correct order.


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

https://reviews.llvm.org/D99079

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm-target-features.c
  clang/test/CodeGen/arm64_crypto.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Driver/arm-features.c
  clang/test/Driver/arm-mfpu.c
  clang/test/Driver/armv8.1m.main.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/test/Bindings/llvm-c/ARM/disassemble.test
  llvm/test/MC/ARM/directive-arch_extension-aes-sha2.s
  llvm/test/MC/ARM/directive-arch_extension-crypto.s
  llvm/test/MC/ARM/neon-crypto.s

Index: llvm/test/MC/ARM/neon-crypto.s
===
--- llvm/test/MC/ARM/neon-crypto.s
+++ llvm/test/MC/ARM/neon-crypto.s
@@ -9,10 +9,10 @@
 @ CHECK: aese.8 q0, q1  @ encoding: [0x02,0x03,0xb0,0xf3]
 @ CHECK: aesimc.8 q0, q1@ encoding: [0xc2,0x03,0xb0,0xf3]
 @ CHECK: aesmc.8 q0, q1 @ encoding: [0x82,0x03,0xb0,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
 
 sha1h.32  q0, q1
 sha1su1.32  q0, q1
@@ -20,9 +20,9 @@
 @ CHECK: sha1h.32  q0, q1   @ encoding: [0xc2,0x02,0xb9,0xf3]
 @ CHECK: sha1su1.32 q0, q1  @ encoding: [0x82,0x03,0xba,0xf3]
 @ CHECK: sha256su0.32 q0, q1@ encoding: [0xc2,0x03,0xba,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 sha1c.32  q0, q1, q2
 sha1m.32  q0, q1, q2
@@ -38,14 +38,14 @@
 @ CHECK: sha256h.32  q0, q1, q2  @ encoding: [0x44,0x0c,0x02,0xf3]
 @ CHECK: sha256h2.32 q0, q1, q2  @ encoding: [0x44,0x0c,0x12,0xf3]
 @ CHECK: sha256su1.32 q0, q1, q2 @ encoding: [0x44,0x0c,0x22,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 vmull.p64 q8, d16, d17
 @ CHECK: vmull.p64  q8, d16, d17@ encoding: [0xa1,0x0e,0xe0,0xf2]
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
Index: llvm/test/MC/ARM/directive-arch_extension-crypto.s
===
--- llvm/test/MC/ARM/directive-arch_extension-crypto.s
+++ llvm/test/MC/ARM/directive-arch_extension-crypto.s
@@ -17,38 +17,38 @@
 	.type crypto,%function
 crypto:
 	vmull.p64 q0, d0, d1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 
 	aesd.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aese.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aesimc.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: err

[PATCH] D99936: [clang][parser] Unify rejecting (non) decl stmt with gnu attributes

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

Hey Aaron, it's been a while. Do you have a suggestion on how to proceed if 
@rsmith has no opinion on it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99936

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


[PATCH] D100516: [AST] Add TypeLoc support to node introspection

2021-04-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 338049.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100516

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -26,25 +26,27 @@
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
 
-template
-std::map
+template 
+std::vector>
 FormatExpected(const MapType &Accessors) {
-  std::map Result;
+  std::vector> Result;
   llvm::transform(llvm::make_filter_range(Accessors,
   [](const auto &Accessor) {
 return Accessor.first.isValid();
   }),
-  std::inserter(Result, Result.end()),
-  [](const auto &Accessor) {
-return std::make_pair(LocationCallFormatterCpp::format(
-  *Accessor.second.get()),
-  Accessor.first);
+  std::back_inserter(Result), [](const auto &Accessor) {
+return std::make_pair(
+LocationCallFormatterCpp::format(*Accessor.second),
+Accessor.first);
   });
   return Result;
 }
 
 #define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
 
+#define STRING_LOCATION_STDPAIR(INSTANCE, LOC) \
+  std::make_pair(std::string(#LOC), INSTANCE->LOC)
+
 /**
   A test formatter for a hypothetical language which needs
   neither casts nor '->'.
@@ -200,26 +202,85 @@
   auto ExpectedLocations =
   FormatExpected(Result.LocationAccessors);
 
-  EXPECT_THAT(ExpectedLocations,
-  UnorderedElementsAre(
-  STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getLocation()),
-  STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
-  STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
+  llvm::sort(ExpectedLocations);
+
+  // clang-format off
+  EXPECT_EQ(
+  ExpectedLocations,
+  (std::vector>{
+STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getBodyRBrace()),
+STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeBegin()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getLocalRangeEnd()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getRParenLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getAs().getTemplateNameLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getAs().getNamedTypeLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getNextTypeLoc().getAs().getLAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSourceInfo()->getTypeLoc().getAs().getReturnLoc().getNextTypeLoc().getAs().getRAngleLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getTypeSo

[PATCH] D100638: [AST][Introspection] Avoid creating temporary strings when comparing LocationCalls.

2021-04-16 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: steveire.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds a bit of boiler plate, but removing the need to build temporary strings to 
compare the calls definitely worth it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100638

Files:
  clang/lib/Tooling/NodeIntrospection.cpp


Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -13,6 +13,9 @@
 #include "clang/Tooling/NodeIntrospection.h"
 
 #include "clang/AST/AST.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -49,6 +52,56 @@
   return Result;
 }
 
+/// lexicographical 3 way comparison.
+static int compareStringArray(llvm::ArrayRef LHS,
+  llvm::ArrayRef RHS) {
+  // Most accessors don't accept any arguments
+  if (LLVM_LIKELY(LHS.empty() && RHS.empty()))
+return 0;
+  auto LI = LHS.begin(), LE = LHS.end(), RI = RHS.begin(), RE = RHS.end();
+  for (; LI != LE && RI != RE; ++LI, ++RI) {
+if (auto Cmp = LI->compare(*RI))
+  return Cmp;
+  }
+  if (LI == LE && RI == RE)
+return 0;
+  // Return -1 if Left contains less items, 1 if more items.
+  return LI == LE ? -1 : 1;
+}
+
+/// A 3 way comparison of what LHS and RHS would look like when formatted as a
+/// cpp string.
+static int compareLocationCall(const LocationCall &LHS,
+   const LocationCall &RHS) {
+  // Expand the call stacks into a vector so we can traverse it in reverse
+  // order.
+  llvm::SmallVector Left, Right;
+  for (const LocationCall *Item = &LHS; Item; Item = Item->on())
+Left.push_back(Item);
+  for (const LocationCall *Item = &RHS; Item; Item = Item->on())
+Right.push_back(Item);
+
+  auto LI = Left.rbegin(), LE = Left.rend(), RI = Right.rbegin();
+  for (; LI != LE; ++LI, ++RI) {
+// If we haven't returned up to here, both call stacks are the same up the
+// here are the same. If we detect that RI is at the end, that means the
+// rights last item was a SourceLocation/Range accessor. Therefore the
+// preceding item in left should also return a Loc/Range and it should be
+// the last item in its stack.
+assert(RI != Right.rend());
+if (auto Strcmp = (*LI)->name().compare((*RI)->name()))
+  return Strcmp;
+if (auto ArgCmp = compareStringArray((*LI)->args(), (*RI)->args()))
+  return ArgCmp;
+// As both calls are the same, they should both either return by value or
+// both return by pointer.
+assert((*LI)->returnsPointer() == (*RI)->returnsPointer());
+  }
+  // As before but flipped.
+  assert(RI == Right.rend());
+  return 0;
+}
+
 namespace internal {
 bool RangeLessThan::operator()(
 std::pair const &LHS,
@@ -66,15 +119,13 @@
   else if (LHS.first.getEnd() != RHS.first.getEnd())
 return false;
 
-  return LocationCallFormatterCpp::format(*LHS.second) <
- LocationCallFormatterCpp::format(*RHS.second);
+  return compareLocationCall(*LHS.second, *RHS.second) < 0;
 }
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
   if (LHS.first == RHS.first)
-return LocationCallFormatterCpp::format(*LHS.second) <
-   LocationCallFormatterCpp::format(*RHS.second);
+return compareLocationCall(*LHS.second, *RHS.second) < 0;
   return LHS.first < RHS.first;
 }
 } // namespace internal


Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -13,6 +13,9 @@
 #include "clang/Tooling/NodeIntrospection.h"
 
 #include "clang/AST/AST.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -49,6 +52,56 @@
   return Result;
 }
 
+/// lexicographical 3 way comparison.
+static int compareStringArray(llvm::ArrayRef LHS,
+  llvm::ArrayRef RHS) {
+  // Most accessors don't accept any arguments
+  if (LLVM_LIKELY(LHS.empty() && RHS.empty()))
+return 0;
+  auto LI = LHS.begin(), LE = LHS.end(), RI = RHS.begin(), RE = RHS.end();
+  for (; LI != LE && RI != RE; ++LI, ++RI) {
+if (auto Cmp = LI->compare(*RI))
+  return Cmp;
+  }
+  if (LI == LE && RI == RE)
+return 0;
+  // Return -1 if Left contains less items, 1 if more items.
+  return LI == LE ? -1 : 1;
+}
+
+/// A 3 way comparison of what LHS and RHS would look like when formatted as a
+/// cpp string.
+static int compareLocationCall(const LocationCall &LHS,
+   const LocationCall &RHS) {
+  // Ex

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

The failing log pointed at `"-mllvm" "--amdhsa-code-object-version=4"`, which 
is a hard error if the amdgpu triple is missing from the llvm. I see the test 
features amdgpu-registered-target. Perhaps that does not behave as one might 
wish?

I'd suggest rebuilding locally without the amdgpu triple enabled and see if 
that fails comparably, and if so, it's another argument for fixing  D98746 
. Until the front end can run without amdgpu 
triple built for the middle end, I don't see how we can have any front end 
tests for amdgpu.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-16 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Ok, it's behind the aarch64 guard because there's a giant #ifdef around it that 
I didn't see. If you move it in `arm_neon.td` down to outside that #ifdef you 
get the definitions. Next problem is that the `poly128_t` type isn't 
implemented for AArch32. Not sure why but for example in the bf16 tests:

  clang/test/CodeGen/arm-bf16-reinterpret-intrinsics.c:
  // TODO: poly128_t not implemented on aarch32
  // CHCK-LABEL: @test_vreinterpretq_p128_bf16

If you split the def in two, one for the non Q, one for the Q parts that can 
work and you get the non poly128_t definitions for Arm and then I can compile 
my test program without modifications to the header.

  --- a/clang/include/clang/Basic/arm_neon.td
  +++ b/clang/include/clang/Basic/arm_neon.td
  @@ -1160,7 +1160,8 @@ def SM4E : SInst<"vsm4e", "...", "QUi">;
   def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
   }
  
  -def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPlQPk">;
  +// TODO: poly128_t isn't implemented for AArch32
  +def VADDP   : WInst<"vadd", "...", "QPcQPsQPlQPk">;
  
   

   // Float -> Int conversions with explicit rounding mode
  @@ -1630,6 +1631,9 @@ def SCALAR_VDUP_LANEQ : IInst<"vdup_laneq", "1QI", 
"ScSsSiSlSfSdSUcSUsSUiSUlSPcS
   }
   }
  
  +// Everything that doesn't use poly128_t
  +def VADDP_Q   : WInst<"vadd", "...", "PcPsPl">;
  +
   // ARMv8.2-A FP16 vector intrinsics for A32/A64.
   let ArchGuard = "defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in {

However I ran into issues trying to get the relevant bits of aarc64-poly-add.c 
to compile for Arm and don't have time time to pursue it myself. If you can get 
those to run (or make an arm specific test file, some others do already) then 
all you'd need to do is remove the `vaddq_p128`  in `CGBuiltin.cpp` to prevent 
anyone thinking it is implemented for AArch32. (no one would be able to hit it 
without a modified header anyway)

My conclusion being that this group of intrinsics should be for A32 and A64 as 
the ACLE says. However we can't do all of them on A32 without poly128_t.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100499

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Was there any more progress on this? If not, let's revert for now to not 
permanently slow down tests by over 20%.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D100638: [AST][Introspection] Avoid creating temporary strings when comparing LocationCalls.

2021-04-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:84
+
+  auto LI = Left.rbegin(), LE = Left.rend(), RI = Right.rbegin();
+  for (; LI != LE; ++LI, ++RI) {

Would it make sense to compare the sizes `(leftsize < rightsize) return true` 
etc and only loop if the containers are the same size?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100638

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


[PATCH] D96367: Partially Revert "scan-view: Remove Reporter.py and associated AppleScript files"

2021-04-16 Thread Arfrever Frehtes Taifersar Arahesis via Phabricator via cfe-commits
Arfrever added a comment.

This commit is missing in `release/12.x` branch, so `scan-view` in recently 
released Clang 12.0.0 is broken.
Please backport this commit to `release/12.x` branch so that it is included at 
least in upcoming Clang 12.0.1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96367

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


[PATCH] D100590: DeclContext: Fix iterator category

2021-04-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

Nice catch! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100590

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-16 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D99741#2694344 , @thakis wrote:

> Was there any more progress on this? If not, let's revert for now to not 
> permanently slow down tests by over 20%.

https://reviews.llvm.org/D100611
https://reviews.llvm.org/D100617

Do you mean revert 
https://github.com/llvm/llvm-project/compare/a3bfddbb6a27...59d5b8c27b43?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-04-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h:20
+// need to `include `.
+#include 
+#endif

I think there are legitimate use cases for writing code that doesn't include 
new. Can we add the forms that are meant to be available without the include 
here, instead of just pulling in all new?



Comment at: clang/test/Headers/Inputs/include/cstdlib:5
 
+void *malloc(size_t);
+void free(void*);

These are in stdlib just above, no? Possibly with noexcept tags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || Context.getASTContext().getLangOpts().SYCLIsDevice)
 ASString = "AS" + llvm::utostr(TargetAS);

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > bader wrote:
> > > > > Anastasia wrote:
> > > > > > Any reason not to use OpenCL mangling? If you do then you might be 
> > > > > > able to link against libraries compiled for OpenCL. Also you will 
> > > > > > get more stable naming i.e. it would not differ from target to 
> > > > > > target. 
> > > > > > Any reason not to use OpenCL mangling? If you do then you might be 
> > > > > > able to link against libraries compiled for OpenCL. Also you will 
> > > > > > get more stable naming i.e. it would not differ from target to 
> > > > > > target. 
> > > > > 
> > > > > I'm not sure I understand your suggestion. Could you elaborate on 
> > > > > "OpenCL mangling", please?
> > > > > 
> > > > > Let me clarify the problem this change addresses. The test case 
> > > > > covering it is located in 
> > > > > `clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp` 
> > > > > lines 86-91.
> > > > > 
> > > > > ```
> > > > > template 
> > > > > void tmpl(T t) {}
> > > > > 
> > > > > int *NoAS;
> > > > > __attribute__((opencl_private)) int *PRIV;
> > > > > 
> > > > > tmpl(PRIV);
> > > > > // CHECK-DAG: [[PRIV_LOAD5:%[a-zA-Z0-9]+]] = load i32*, i32* 
> > > > > addrspace(4)* [[PRIV]].ascast
> > > > > // CHECK-DAG: call spir_func void [[PRIV_TMPL:@[a-zA-Z0-9_]+]](i32* 
> > > > > [[PRIV_LOAD5]])
> > > > > tmpl(NoAS);
> > > > > // CHECK-DAG: [[NoAS_LOAD5:%[a-zA-Z0-9]+]] = load i32 addrspace(4)*, 
> > > > > i32 addrspace(4)* addrspace(4)* [[NoAS]].ascast
> > > > > // CHECK-DAG: call spir_func void [[GEN_TMPL:@[a-zA-Z0-9_]+]](i32 
> > > > > addrspace(4)* [[NoAS_LOAD5]])
> > > > > ```
> > > > > Clang has separate code paths for mangling types w/ and w/o address 
> > > > > space attributes (i.e. using `Default` address space).
> > > > > 
> > > > > Address space is not mangled if there is no AS attribute (`Default`) 
> > > > > or if address space attribute is maps to `0` target address space. 
> > > > > SPIR target maps `*_private` address space to `0`, which causes name 
> > > > > conflict for the example above.
> > > > > 
> > > > > This change for SYCL compiler enables mangling for non-default 
> > > > > address space attributes regardless of their mapping to target 
> > > > > address space.
> > > > It's just that all language address spaces are mangled with the source 
> > > > spelling in Italium ABI right now, if you check the `else` statement. I 
> > > > don't think it is part of the official spec yet but it might be better 
> > > > to stick to the same pattern if possible.
> > > > It's just that all language address spaces are mangled with the source 
> > > > spelling in Italium ABI right now, if you check the `else` statement. I 
> > > > don't think it is part of the official spec yet but it might be better 
> > > > to stick to the same pattern if possible.
> > > 
> > > I would really love to avoid changes to the mangler (e.g. to be able to 
> > > link binaries produced by different front-end like SYCL/OpenCL/CUDA), but 
> > > I don't know the better way to address the issue 
> > > Sorry, I don't get what do you suggest here. Could you clarify what 
> > > exactly I should change, please?
> > For now I am just trying to understand why you are not adopting similar 
> > mangling scheme as for other language address spaces since it gives more 
> > stable mangling irrespective from the target compiled for.
> > 
> > If you plan to link libraries from other frontends i.e. OpenCL or CUDA the 
> > mangling you use is different from what they produce. Just have a look at 
> > the  line 2470 that explains OpenCL mangling or line 2494 explaining CUDA 
> > mangling. FYI similar scheme applies to other language address spaces, so 
> > the `AS` was only really used for the address spaces that have no 
> > source spelling i.e. no language semantics.
> > For now I am just trying to understand why you are not adopting similar 
> > mangling scheme as for other language address spaces since it gives more 
> > stable mangling irrespective from the target compiled for.
> 
> According to my understanding this code is used for other language spaces. 
> For instance, per comments at lines 2455-2457 it's used for OpenCL and CUDA 
> address spaces.
> Do you mean some other mangling scheme?
> 
> > If you plan to link libraries from other frontends i.e. OpenCL or CUDA the 
> > mangling you use is different from what they produce. 
> 
> SYCL standard doesn't have such functionality. OpenCL C functions are not 
> mangled (only built-ins), so there should be no problem to link with OpenCL C 
> libraries. 
> I know that ma

[PATCH] D100638: [AST][Introspection] Avoid creating temporary strings when comparing LocationCalls.

2021-04-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:84
+
+  auto LI = Left.rbegin(), LE = Left.rend(), RI = Right.rbegin();
+  for (; LI != LE; ++LI, ++RI) {

steveire wrote:
> Would it make sense to compare the sizes `(leftsize < rightsize) return true` 
> etc and only loop if the containers are the same size?
That wouldn't work as we are comparing lexicographically. If leftsize was 
smaller than rightsize, but the first item in left was ``, and first in 
right was ``. We'd want right to be marked as less then left.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100638

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


[PATCH] D100534: [clang][deps] Generate the full command-line for modules

2021-04-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 338069.
jansvoboda11 added a comment.

Share `ModuleDeps::Invocation`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100534

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp

Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -31,11 +31,11 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps",
-// CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
-// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
-// CHECK-NEXT:   ],
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
+// CHECK:  "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
@@ -47,9 +47,9 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps"
-// CHECK-NEXT:   ],
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H2:[A-Z0-9]+]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
@@ -61,9 +61,9 @@
 // CHECK-NEXT:   "clang-module-deps": [],
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
-// CHECK-NEXT: "-fno-implicit-modules",
-// CHECK-NEXT: "-fno-implicit-module-maps"
-// CHECK-NEXT:   ],
+// CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
 // CHECK-NEXT:   "file-deps": [
 // CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h",
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -12,32 +12,61 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "llvm/Support/StringSaver.h"
 
 using namespace clang;
 using namespace tooling;
 using namespace dependencies;
 
+static CompilerInvocation
+makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps) {
+  // Make a deep copy of the invocation.
+  CompilerInvocation CI(*Deps.Invocation);
+
+  // Remove options incompatible with explicit module build.
+  CI.getFrontendOpts().Inputs.clear();
+  CI.getFrontendOpts().OutputFile.clear();
+
+  CI.getFrontendOpts().ProgramAction = frontend::GenerateModule;
+  CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
+  CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
+
+  CI.getLangOpts()->ImplicitModules = false;
+  CI.getHeaderSearchOpts().ImplicitModuleMaps = false;
+
+  return CI;
+}
+
+static std::vector
+serializeCompilerInvocation(CompilerInvocation &CI) {
+  // Set up string allocator.
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Strings(Alloc);
+  auto SA = [&Strings](const Twine &Arg) { return Strings.save(Arg).data(); };
+  SmallVector Args;
+
+  // Synthesize full command line from the CompilerInvocation.
+  CI.generateCC1CommandLine(Args, SA);
+
+  // Convert arguments to the return type.
+  std::vector Ret;
+  Ret.reserve(Args.size());
+  for (const char *Arg : Args)
+Ret.emplace_back(Arg);
+
+  return Ret;
+}
+
 std::vector ModuleDeps::getFullCommandLine(
 std::function LookupPCMPath,
 std::function LookupModuleDeps) const {
-  // TODO: Build full command line. That also means capturing the original
-  //   command line into NonPathCommandLine.
-
-  std::vector Ret{
-  "-fno-implicit-modules",
-  "-fno-implicit-module-maps",
-  };
+  CompilerInvocation CI(makeInvocationForModuleBuildWi

[PATCH] D100534: [clang][deps] Generate the full command-line for modules

2021-04-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h:78-80
+  /// The compiler invocation associated with the translation unit that imports
+  /// this module.
+  CompilerInvocation Invocation;

dexonsmith wrote:
> Looks like this will be a deep copy, but it doesn't look like it's being 
> modified. Can this just be a `const &`, taken in the `ModuleDeps` 
> constructor? Or is there a lifetime reason this needs to be as it is?
It can't be `const &` for two reasons:

1. The current code value-initializes `ModuleDeps` in two places and truly 
initializes it later in `ModuleDepCollectorPP::handleTopLevelModule`. We'd have 
to go with something like `optional>` to 
be able to delay the initialization.
2. The lifetime of the `CompilerInvocation` is a bit wild, but the reference 
most likely wouldn't outlive `ModuleDeps` (depends on the client).

I think the best solution would be to extract the `shared_ptr` from 
`CompilerInstance`, share it across `ModuleDeps` instances and only do a deep 
copy when actually generating the command line.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:25
+
+  // Remove options incompatible with explicit module build.
+  CI.getFrontendOpts().Inputs.clear();

dexonsmith wrote:
> Should this call any of the `resetNonModularOptions()` functions, or are 
> those intentionally omitted?
My intent for this patch was to simply take the work @Bigcheese has done 
downstream with `-remove-preceeding-explicit-module-build-incompatible-options` 
and port it to `CompilerInvocation`.

Calling `resetNonModularOptions()` here would be the next step I intend to do 
in a future patch.

I also think disabling implicit module maps here is not correct, as that seems 
to disable inferred top-level modules.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:26-27
+  // Remove options incompatible with explicit module build.
+  CI.getFrontendOpts().Inputs.clear();
+  CI.getFrontendOpts().OutputFile.clear();
+

dexonsmith wrote:
> Should `FrontendOpts` gain a `resetNonModularOptions()`?
Most likely yes. I'd like to look into it in a next patch.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:62
 std::function LookupModuleDeps) const {
-  // TODO: Build full command line. That also means capturing the original
-  //   command line into NonPathCommandLine.
-
-  std::vector Ret{
-  "-fno-implicit-modules",
-  "-fno-implicit-module-maps",
-  };
+  CompilerInvocation CI = getFullCommandLineCompilerInvocation(*this);
 

dexonsmith wrote:
> I think guaranteed copy elision means this won't be a deep copy of the 
> return, but it might be nice to add a move constructor for 
> `CompilerInvocation` so it's more obvious.
That's intentional. The deep copy is performed inside the function.

Shouldn't the move constructor of `CompilerInvocation` be defaulted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100534

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


[PATCH] D100534: [clang][deps] Generate the full command-line for modules

2021-04-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:62
 std::function LookupModuleDeps) const {
-  // TODO: Build full command line. That also means capturing the original
-  //   command line into NonPathCommandLine.
-
-  std::vector Ret{
-  "-fno-implicit-modules",
-  "-fno-implicit-module-maps",
-  };
+  CompilerInvocation CI = getFullCommandLineCompilerInvocation(*this);
 

jansvoboda11 wrote:
> dexonsmith wrote:
> > I think guaranteed copy elision means this won't be a deep copy of the 
> > return, but it might be nice to add a move constructor for 
> > `CompilerInvocation` so it's more obvious.
> That's intentional. The deep copy is performed inside the function.
> 
> Shouldn't the move constructor of `CompilerInvocation` be defaulted?
s/defaulted/implicitly-defined/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100534

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


[PATCH] D100638: [AST][Introspection] Avoid creating temporary strings when comparing LocationCalls.

2021-04-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/lib/Tooling/NodeIntrospection.cpp:84
+
+  auto LI = Left.rbegin(), LE = Left.rend(), RI = Right.rbegin();
+  for (; LI != LE; ++LI, ++RI) {

njames93 wrote:
> steveire wrote:
> > Would it make sense to compare the sizes `(leftsize < rightsize) return 
> > true` etc and only loop if the containers are the same size?
> That wouldn't work as we are comparing lexicographically. If leftsize was 
> smaller than rightsize, but the first item in left was ``, and first in 
> right was ``. We'd want right to be marked as less then left.
I don't think we would want that. All we need is to be able to put these things 
in a std set. We only need uniquenes and deterministic order. We don't need or 
want any particular order at all. 

Besides, your implementation orders elements as they are formatted for c++, 
which could differ from the order the calls would be in if casts are omitted 
(js, python).

Besides, https://en.m.wikipedia.org/wiki/Lexicographic_order "One variant 
applies to sequences of different lengths by comparing the lengths of the 
sequences before considering their elements."

It should be possible to implement this without creating the local vectors. 
Just iterate in parallel through the location calls, comparing names, and if 
one chain ends before the other return early. That would seem to have all the 
properties we need, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100638

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D99741#2694369 , @khchen wrote:

> In D99741#2694344 , @thakis wrote:
>
>> Was there any more progress on this? If not, let's revert for now to not 
>> permanently slow down tests by over 20%.
>
> https://reviews.llvm.org/D100611
> https://reviews.llvm.org/D100617

Great, let's wait and see for a few days to see if it lands, and if so how much 
that recovers then.

> Do you mean revert 
> https://github.com/llvm/llvm-project/compare/a3bfddbb6a27...59d5b8c27b43?

Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-16 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D99741#2694435 , @thakis wrote:

> In D99741#2694369 , @khchen wrote:
>
>> In D99741#2694344 , @thakis wrote:
>>
>>> Was there any more progress on this? If not, let's revert for now to not 
>>> permanently slow down tests by over 20%.
>>
>> https://reviews.llvm.org/D100611
>> https://reviews.llvm.org/D100617
>
> Great, let's wait and see for a few days to see if it lands, and if so how 
> much that recovers then.
>
>> Do you mean revert 
>> https://github.com/llvm/llvm-project/compare/a3bfddbb6a27...59d5b8c27b43?
>
> Yes.

Please wait a few days. 
Those commits add almost total 300k line from all tests.
I think maybe reverting is not a good idea if we have a good progress on this 
slow down issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-16 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100471

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


[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D100488#2692772 , @rnk wrote:

> In D100488#2689494 , @amccarth 
> wrote:
>
>> Personally, I'm not a fan of boolean function parameters because of the 
>> inline comments necessary to make the call site understandable.  But it 
>> appears to be consistent with LLVM Coding Standards and other APIs, so this 
>> looks right to me.
>
> I think it would be a reasonable follow-up change to turn these optional 
> boolean parameters into a flags enum.

That's a good idea. There hasn't been a usage of getFile or getFileOrSTDIN that 
wanted CRLF translation so far, but this may not be the case always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

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


[clang] 10c7b9f - [OPENMP]Fix PR49115: Incorrect results for scan directive.

2021-04-16 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-04-16T06:25:35-07:00
New Revision: 10c7b9f64fa6c0257fe8a7f89123afb5e463ebda

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

LOG: [OPENMP]Fix PR49115: Incorrect results for scan directive.

For combined worksharing directives need to emit the temp arrays outside
of the parallel region and update them in the master thread only.

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_for_scan_codegen.cpp
clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 827102ba7d7a2..7d8744651a4ee 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -241,11 +241,22 @@ class OMPSimdLexicalScope : public 
CodeGenFunction::LexicalScope {
   if (const Expr *E = TG->getReductionRef())
 CGF.EmitVarDecl(*cast(cast(E)->getDecl()));
 }
+// Temp copy arrays for inscan reductions should not be emitted as they are
+// not used in simd only mode.
+llvm::DenseSet> CopyArrayTemps;
+for (const auto *C : S.getClausesOfKind()) {
+  if (C->getModifier() != OMPC_REDUCTION_inscan)
+continue;
+  for (const Expr *E : C->copy_array_temps())
+CopyArrayTemps.insert(cast(E)->getDecl());
+}
 const auto *CS = cast_or_null(S.getAssociatedStmt());
 while (CS) {
   for (auto &C : CS->captures()) {
 if (C.capturesVariable() || C.capturesVariableByCopy()) {
   auto *VD = C.getCapturedVar();
+  if (CopyArrayTemps.contains(VD))
+continue;
   assert(VD == VD->getCanonicalDecl() &&
  "Canonical decl must be captured.");
   DeclRefExpr DRE(CGF.getContext(), const_cast(VD),
@@ -3295,53 +3306,30 @@ emitDispatchForLoopBounds(CodeGenFunction &CGF, const 
OMPExecutableDirective &S,
   return {LBVal, UBVal};
 }
 
-/// Emits the code for the directive with inscan reductions.
+/// Emits internal temp array declarations for the directive with inscan
+/// reductions.
 /// The code is the following:
 /// \code
 /// size num_iters = ;
 ///  buffer[num_iters];
-/// #pragma omp ...
-/// for (i: 0..) {
-///   ;
-///   buffer[i] = red;
-/// }
-/// for (int k = 0; k != ceil(log2(num_iters)); ++k)
-/// for (size cnt = last_iter; cnt >= pow(2, k); --k)
-///   buffer[i] op= buffer[i-pow(2,k)];
-/// #pragma omp ...
-/// for (0..) {
-///   red = InclusiveScan ? buffer[i] : buffer[i-1];
-///   ;
-/// }
 /// \endcode
-static void emitScanBasedDirective(
+static void emitScanBasedDirectiveDecls(
 CodeGenFunction &CGF, const OMPLoopDirective &S,
-llvm::function_ref NumIteratorsGen,
-llvm::function_ref FirstGen,
-llvm::function_ref SecondGen) {
+llvm::function_ref NumIteratorsGen) {
   llvm::Value *OMPScanNumIterations = CGF.Builder.CreateIntCast(
   NumIteratorsGen(CGF), CGF.SizeTy, /*isSigned=*/false);
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector ReductionOps;
-  SmallVector LHSs;
-  SmallVector RHSs;
-  SmallVector CopyOps;
   SmallVector CopyArrayTemps;
-  SmallVector CopyArrayElems;
   for (const auto *C : S.getClausesOfKind()) {
 assert(C->getModifier() == OMPC_REDUCTION_inscan &&
"Only inscan reductions are expected.");
 Shareds.append(C->varlist_begin(), C->varlist_end());
 Privates.append(C->privates().begin(), C->privates().end());
 ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
-LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
-RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
-CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
-CopyArrayElems.append(C->copy_array_elems().begin(),
-  C->copy_array_elems().end());
   }
   {
 // Emit buffers for each reduction variables.
@@ -3370,6 +3358,49 @@ static void emitScanBasedDirective(
   ++Count;
 }
   }
+}
+
+/// Emits the code for the directive with inscan reductions.
+/// The code is the following:
+/// \code
+/// #pragma omp ...
+/// for (i: 0..) {
+///   ;
+///   buffer[i] = red;
+/// }
+/// #pragma omp master // in parallel region
+/// for (int k = 0; k != ceil(log2(num_iters)); ++k)
+/// for (size cnt = last_iter; cnt >= pow(2, k); --k)
+///   buffer[i] op= buffer[i-pow(2,k)];
+/// #pragma omp barrier // in parallel region
+/// #pragma omp ...
+/// for (0..) {
+///   red = InclusiveScan ? buffer[i] : buffer[i-1];
+///   ;
+/// }
+/// \endcode
+static void emitScanBasedD

[PATCH] D100187: [OPENMP]Fix PR49115: Incorrect results for scan directive.

2021-04-16 Thread Alexey Bataev 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 rG10c7b9f64fa6: [OPENMP]Fix PR49115: Incorrect results for 
scan directive. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100187

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_for_scan_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp

Index: clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
===
--- clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
+++ clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
@@ -18,10 +18,15 @@
   static float a[10];
   static double b;
 
-  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+  // CHECK: call i8* @llvm.stacksave()
+  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
+
+  // float a_buffer[10][n];
+  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
+  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+
   // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
 
-  // CHECK: call i8* @llvm.stacksave()
   // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
 
   // float a_buffer[10][n];
@@ -29,6 +34,9 @@
 
   // double b_buffer[10];
   // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+  // CHECK: call void @llvm.stackrestore(i8*
+
 #pragma omp parallel for simd reduction(inscan, +:a[:n], b)
   for (int i = 0; i < 10; ++i) {
 // CHECK: call void @__kmpc_for_static_init_4(
@@ -42,8 +50,8 @@
 // a_buffer[i][0..n] = a_priv[[0..n];
 // CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
 // CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
-// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
-// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS:%.+]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF:%.+]], i64 [[IDX]]
 // CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
 // CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
 // CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
@@ -51,7 +59,7 @@
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
 
 // b_buffer[i] = b_priv;
-// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF:%.+]], i64 [[BASE_IDX]]
 // CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
 // CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
 // CHECK: br label %[[LOOP_CONTINUE:.+]]
@@ -158,17 +166,8 @@
 // CHECK: [[LOOP_CONTINUE]]:
 // CHECK: call void @llvm.stackrestore(i8* %
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @llvm.stackrestore(i8*
   }
 
-  // CHECK: call i8* @llvm.stacksave()
-  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
-
-  // float a_buffer[10][n];
-  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
-
-  // double b_buffer[10];
-  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
 #pragma omp parallel for simd reduction(inscan, +:a[:n], b)
   for (int i = 0; i < 10; ++i) {
 // CHECK: call void @__kmpc_for_static_init_4(
@@ -185,8 +184,8 @@
 // a_buffer[i][0..n] = a_priv[[0..n];
 // CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
 // CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
-// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
-// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS:%.+]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF:%.+]], i64 [[IDX]]
 // CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
 // CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
 // CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
@@ -194,7 +193,7 @@
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
 
 // b_buffer[i] = b_priv;
-// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF:%.+]], i64 [[BASE_IDX]]
 // CH

[PATCH] D100644: [clang][cli] NFC: Use Diags to report parsing success/failure

2021-04-16 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.

`Success` is set to `false` whenever `Diags.Report(diag::err_)` is called. 
Remove the duplication and use `Diags` as the source of truth when deciding 
whether to report parsing success/failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100644

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -134,9 +134,10 @@
 #include "clang/Driver/Options.inc"
 #undef SIMPLE_ENUM_VALUE_TABLE
 
-static llvm::Optional
-normalizeSimpleFlag(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
-DiagnosticsEngine &Diags, bool &Success) {
+static llvm::Optional normalizeSimpleFlag(OptSpecifier Opt,
+unsigned TableIndex,
+const ArgList &Args,
+DiagnosticsEngine &Diags) {
   if (Args.hasArg(Opt))
 return true;
   return None;
@@ -144,8 +145,7 @@
 
 static Optional normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
   const ArgList &Args,
-  DiagnosticsEngine &,
-  bool &Success) {
+  DiagnosticsEngine &) {
   if (Args.hasArg(Opt))
 return false;
   return None;
@@ -171,7 +171,7 @@
   std::enable_if_t(), bool> = false>
 static auto makeFlagToValueNormalizer(T Value) {
   return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &, bool &Success) -> Optional {
+ DiagnosticsEngine &) -> Optional {
 if (Args.hasArg(Opt))
   return Value;
 return None;
@@ -187,8 +187,8 @@
 static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
 OptSpecifier OtherOpt) {
   return [Value, OtherValue, OtherOpt](OptSpecifier Opt, unsigned,
-   const ArgList &Args, DiagnosticsEngine &,
-   bool &Success) -> Optional {
+   const ArgList &Args,
+   DiagnosticsEngine &) -> Optional {
 if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
   return A->getOption().matches(Opt) ? Value : OtherValue;
 }
@@ -253,9 +253,10 @@
   return None;
 }
 
-static llvm::Optional
-normalizeSimpleEnum(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
-DiagnosticsEngine &Diags, bool &Success) {
+static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt,
+unsigned TableIndex,
+const ArgList &Args,
+DiagnosticsEngine &Diags) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
 
@@ -267,7 +268,6 @@
   if (auto MaybeEnumVal = findValueTableByName(Table, ArgValue))
 return MaybeEnumVal->Value;
 
-  Success = false;
   Diags.Report(diag::err_drv_invalid_value)
   << Arg->getAsString(Args) << ArgValue;
   return None;
@@ -301,8 +301,7 @@
 
 static Optional normalizeString(OptSpecifier Opt, int TableIndex,
  const ArgList &Args,
- DiagnosticsEngine &Diags,
- bool &Success) {
+ DiagnosticsEngine &Diags) {
   auto *Arg = Args.getLastArg(Opt);
   if (!Arg)
 return None;
@@ -310,15 +309,14 @@
 }
 
 template 
-static Optional
-normalizeStringIntegral(OptSpecifier Opt, int, const ArgList &Args,
-DiagnosticsEngine &Diags, bool &Success) {
+static Optional normalizeStringIntegral(OptSpecifier Opt, int,
+   const ArgList &Args,
+   DiagnosticsEngine &Diags) {
   auto *Arg = Args.getLastArg(Opt);
   if (!Arg)
 return None;
   IntTy Res;
   if (StringRef(Arg->getValue()).getAsInteger(0, Res)) {
-Success = false;
 Diags.Report(diag::err_drv_invalid_int_value)
 << Arg->getAsString(Args) << Arg->getValue();
 return None;
@@ -328,7 +326,7 @@
 
 static Optional>
 normalizeStringVector(OptSpecifier Opt, int, const ArgList &Args,
-  DiagnosticsEngine &, bool &Success) {
+  DiagnosticsEngine &) {
 

[PATCH] D100611: [RISCV] Add new attribute __clang_riscv_builtin_alias for intrinsics.

2021-04-16 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D100611#2694004 , @frasercrmck 
wrote:

> Is this idea that this will later be "automatically" applied to builtins in 
> `riscv_vector.h`?

I will prepare another patch to update the header generator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

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


[PATCH] D99861: [Clang] Record tokens in attribute arguments for user-defined C++/C2x attributes

2021-04-16 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

See also https://bugs.llvm.org/show_bug.cgi?id=46446.  when I first fell into 
this issue, I did think it was trying to save the token stream as this patch is 
doing.  Neat I thought :)  although I'm a clang weenie, saving the tokens is 
putting this into deferred-parse territory, which makes me nervous.  Wouldn't 
it be better for the ParsedAttrInfo objects to determine whether and how to 
parse their arguments.  They could do so immediately, or save tokens, or 
whatever on a per-attribute per-argument basis.  Isn't that more flexible?  Add 
some ParsedAttrInfo defaults for the default cxx11, gnu & clang flavours of 
attributes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99861

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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2021-04-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

In D45639#2693706 , @phosek wrote:

> It's depends on the order: whichever comes first wins. The default order of 
> paths that the driver uses is (1) toolchain library paths, (2) library paths 
> specified explicitly using `-L`, (3) sysroot library paths. So if 
> `/lib/libc++.a` exists, it'd be picked up, otherwise 
> `/lib/libc++.dylib` would be used.

Okay, so if that's the behavior after this patch, I think this is good.


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

https://reviews.llvm.org/D45639

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> Please wait a few days. 
> Those commits add almost total 300k line from all tests.
> I think maybe reverting is not a good idea if we have a good progress on this 
> slow down issue.

Yes, if we can fix the regression in a few days, then all is good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 338099.
mibintc added a comment.

I accidentally dropped the test case in previous commit.  Just adding it back 
in -- under the llvm/test directory (previously it was in the wrong location).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence.ll
@@ -0,0 +1,122 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X64
+
+define float @f1(float %a, float %b, float %c) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; X86-NEXT:vfmadd213ss {{.*#+}} xmm1 = (xmm0 * xmm1) + mem
+; X86-NEXT:vmovss %xmm1, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm1 * xmm0) + xmm2
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %add = fadd fast float %mul, %c
+  ret float %add
+}
+
+define float @f2(float %a, float %b, float %c) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmulss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vaddss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:vmovss %xmm0, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:vmulss %xmm0, %xmm1, %xmm0
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %tmp = call float @llvm.arithmetic.fence.f32(float %mul)
+  %add = fadd fast float %tmp, %c
+  ret float %add
+}
+
+define double @f3(double %a, double %b, double %c) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vaddsd 16(%ebp), %xmm0, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:vaddsd %xmm2, %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %b
+  %2 = fsub fast double %c, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f4(double %a, double %b, double %c) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vmovsd {{.*#+}} xmm1 = mem[0],zero
+; X86-NEXT:vaddsd 16(%ebp), %xmm1, %xmm2
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vsubsd %xmm1, %xmm0, %xmm0
+; X86-NEXT:vaddsd %xmm0, %xmm2, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:vaddsd %xmm1, %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:vsubsd %xmm0, %xmm2, %xmm0
+; X64-NEXT:vaddsd %xmm0, %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %b
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fsub fast double %c, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+declare float @llvm.arithmetic.fence.f32(float)
+declare

[PATCH] D99689: [OPENMP]Add option -fopenmp-cuda-const-firstprivate to control address space of the corresponding global.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338100.
ABataev added a comment.

Rebase + update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99689

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -52,7 +52,6 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l76]] = internal global [[TTII]] zeroinitializer
 // CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}]
 // CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [2 x i64] [i64 288, i64 49]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
@@ -336,8 +335,6 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
@@ -346,7 +343,7 @@
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
   // CHECK:  [[BASE_PTR_GEP3_1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_1]] to [[TTII]]**
-  // CHECK:  store [[TTII]]* [[FP_E]], [[TTII]]** [[BCAST_TOPTR]],
+  // CHECK:  store [[TTII]]* [[FP_E:%.+]], [[TTII]]** [[BCAST_TOPTR]],
   // CHECK:  [[PTR_GEP3_1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[PTR_GEP3_1]] to [[TTII]]**
   // CHECK:  store [[TTII]]* [[FP_E]], [[TTII]]** [[BCAST_TOPTR]],
@@ -356,9 +353,8 @@
   // CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
 
   // TCHECK:  define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[PTR_ADDR:%.+]] = alloca double*,
-  // TCHECK-NOT: alloca [[TTII]],
+  // TCHECK:  alloca [[TTII]],
   // TCHECK-NOT: alloca double*,
   // TCHECK:  store double* [[PTR_IN]], double** [[PTR_ADDR]],
   // TCHECK-NOT: store double* %
Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -1,8 +1,10 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 --check-prefix TCHECK-NONCONST
+// RUN: %clang_cc1 -debug-info-kind=limited -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-cuda-const-firstprivate -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 --check-prefix TCHECK-CONST
 // RUN: %cla

[clang] e71994a - [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-16 Thread Abhina Sreeskantharajan via cfe-commits

Author: Jonathan Crowther
Date: 2021-04-16T10:08:36-04:00
New Revision: e71994a239d5f807c1c75515bfa512495224469f

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

LOG: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help 
z/OS distinguish between text and binary correctly. This is an extension to 
[this patch](https://reviews.llvm.org/D97785)

Reviewed By: abhina.sreeskantharajan, amccarth

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

Added: 


Modified: 
clang/tools/driver/cc1as_main.cpp
llvm/lib/AsmParser/Parser.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/Testing/Support/SupportHelpers.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-mc/llvm-mc.cpp

Removed: 




diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 570e3e40ebdd9..083fc0846ac18 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -342,7 +342,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
 return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
 
   ErrorOr> Buffer =
-  MemoryBuffer::getFileOrSTDIN(Opts.InputFile);
+  MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
 
   if (std::error_code EC = Buffer.getError()) {
 Error = EC.message();

diff  --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp
index 8147620181f9c..b4be041d6212b 100644
--- a/llvm/lib/AsmParser/Parser.cpp
+++ b/llvm/lib/AsmParser/Parser.cpp
@@ -104,7 +104,7 @@ parseAssemblyFileWithIndex(StringRef Filename, SMDiagnostic 
&Err,
bool UpgradeDebugInfo,
DataLayoutCallbackTy DataLayoutCallback) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(Filename);
+  MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError()) {
 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + EC.message());

diff  --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp 
b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e4e00b2057ce1..88dc4571b2d77 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -984,7 +984,7 @@ bool MIRParser::parseMachineFunctions(Module &M, 
MachineModuleInfo &MMI) {
 std::unique_ptr llvm::createMIRParserFromFile(
 StringRef Filename, SMDiagnostic &Error, LLVMContext &Context,
 std::function ProcessIRFunction) {
-  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError()) {
 Error = SMDiagnostic(Filename, SourceMgr::DK_Error,
  "Could not open input file: " + EC.message());

diff  --git a/llvm/lib/ProfileData/InstrProfReader.cpp 
b/llvm/lib/ProfileData/InstrProfReader.cpp
index 9581e5b486a6f..b83295a16f0f8 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -41,7 +41,7 @@ using namespace llvm;
 static Expected>
 setupMemoryBuffer(const Twine &Path) {
   ErrorOr> BufferOrErr =
-  MemoryBuffer::getFileOrSTDIN(Path);
+  MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return errorCodeToError(EC);
   return std::move(BufferOrErr.get());

diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp 
b/llvm/lib/ProfileData/SampleProfReader.cpp
index 200a0afb01c61..656638d7dc63f 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -1575,7 +1575,7 @@ 
SampleProfileReaderItaniumRemapper::lookUpNameInProfile(StringRef Fname) {
 /// \returns an error code indicating the status of the buffer.
 static ErrorOr>
 setupMemoryBuffer(const Twine &Filename) {
-  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return EC;
   auto Buffer = std::move(BufferOrErr.get());

diff  --git a/llvm/lib/Testing/Support/SupportHelpers.cpp 
b/llvm/lib/Testing/Support/SupportHelpers.cpp
index 5f53b2330b206..3c12edfa9d99b 100644
--- a/llvm/lib/Testing/Support/SupportHelpers.cpp
+++ b/llvm/lib/Testing/Support/SupportHelpers.cpp
@@ -40,7 +40,7 @@ SmallString<128> llvm::unittest::getInputFileDirectory(const 
char *Argv0) {
 
   EXPECT_TRUE(Found) << "Unit test source directory file

[PATCH] D100488: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

2021-04-16 Thread Abhina Sree 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 rGe71994a239d5: [SystemZ][z/OS] Add IsText Argument to GetFile 
and GetFileOrSTDIN (authored by Jonathan.Crowther, committed by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100488

Files:
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/AsmParser/Parser.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Testing/Support/SupportHelpers.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -343,7 +343,7 @@
   Triple TheTriple(TripleName);
 
   ErrorOr> BufferPtr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (std::error_code EC = BufferPtr.getError()) {
 WithColor::error(errs(), ProgName)
 << InputFilename << ": " << EC.message() << '\n';
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -182,7 +182,7 @@
 static Expected> readInputFile(StringRef FilePath) {
   // Read in file.
   ErrorOr> BufOrError =
-  MemoryBuffer::getFileOrSTDIN(FilePath);
+  MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true);
   if (!BufOrError)
 return createStringError(BufOrError.getError(), "Could not open `%s`",
  FilePath.data());
Index: llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===
--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -334,7 +334,7 @@
 Expected
 InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 InstructionBenchmark Benchmark;
@@ -351,7 +351,7 @@
 Expected>
 InstructionBenchmark::readYamls(const LLVMState &State, StringRef Filename) {
   if (auto ExpectedMemoryBuffer =
-  errorOrToExpected(MemoryBuffer::getFile(Filename))) {
+  errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) {
 yaml::Input Yin(*ExpectedMemoryBuffer.get());
 YamlContext Context(State);
 std::vector Benchmarks;
Index: llvm/lib/Testing/Support/SupportHelpers.cpp
===
--- llvm/lib/Testing/Support/SupportHelpers.cpp
+++ llvm/lib/Testing/Support/SupportHelpers.cpp
@@ -40,7 +40,7 @@
 
   EXPECT_TRUE(Found) << "Unit test source directory file does not exist.";
 
-  auto File = MemoryBuffer::getFile(InputFilePath);
+  auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true);
 
   EXPECT_TRUE(static_cast(File))
   << "Could not open unit test source directory file.";
Index: llvm/lib/ProfileData/SampleProfReader.cpp
===
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -1575,7 +1575,7 @@
 /// \returns an error code indicating the status of the buffer.
 static ErrorOr>
 setupMemoryBuffer(const Twine &Filename) {
-  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return EC;
   auto Buffer = std::move(BufferOrErr.get());
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -41,7 +41,7 @@
 static Expected>
 setupMemoryBuffer(const Twine &Path) {
   ErrorOr> BufferOrErr =
-  MemoryBuffer::getFileOrSTDIN(Path);
+  MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true);
   if (std::error_code EC = BufferOrErr.getError())
 return errorCodeToError(EC);
   return std::move(BufferOrErr.get());
Index: llvm/lib/CodeGen/MIRParser/MIRParser.cpp
===
--- llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -984,7 +984,7 @@
 std::unique_ptr llvm::createMIRParserFromFile(
 StringRef Filename, SMDiagnostic &Error, LLVMContext &Context,
 std::function ProcessIRFun

[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

One optional nit and LGTM, assuming the DILocalVariable ordering is consistent 
with what we see downstream.




Comment at: clang/test/CodeGenCoroutines/coro-dwarf.cpp:1
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 
-debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \

I prefer the spelling `-disable-llvm-passes` 


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

https://reviews.llvm.org/D100298

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


[PATCH] D95976: [OpenMP] Simplify offloading parallel call codegen

2021-04-16 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 338102.
ggeorgakoudis added a comment.

Fix for getThreadsLimit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95976

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread ChenZheng via Phabricator via cfe-commits
shchenz created this revision.
shchenz added reviewers: dblaikie, aprantl, probinson, jsji, Esme, echristo, 
PowerPC.
shchenz added a project: debug-info.
shchenz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As discussed in D99250  , we added a new 
tuning debugger DBX(D99400 ) to add some debug 
info customizations for DBX on AIX.

This is part of the customizations, not generating DWARF infos not matching the 
DWARF version.

This is for DW_TAG_rvalue_reference_type tag.

Now for DBX, we only generate this tag when DWARF version is 4 or higher.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // For DBX, we generate DWARF 4 tag at DWARF version no less than 4.
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::DBX &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // For DBX, we generate DWARF 4 tag at DWARF version no less than 4.
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::DBX &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

If DBX is going to be really pedantic about not recognizing tags or attributes 
that don't align with the DWARF version, maybe we're better off with really 
supporting `-gstrict-dwarf` and just have DBX tuning imply that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D100611: [RISCV] Add new attribute __clang_riscv_builtin_alias for intrinsics.

2021-04-16 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 338105.
HsiangKai added a comment.

Add a negative test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -142,6 +142,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVBuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -target-feature +experimental-v \
+// RUN:   %s -o - \
+// RUN:   | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((__clang_riscv_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[OP0_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[OP1_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[VL_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[RET:%.*]] = alloca , align 1
+// CHECK-NEXT:store  [[OP0:%.*]], * [[OP0_ADDR]], align 1
+// CHECK-NEXT:store  [[OP1:%.*]], * [[OP1_ADDR]], align 1
+// CHECK-NEXT:store i64 [[VL:%.*]], i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load , * [[OP0_ADDR]], align 1
+// CHECK-NEXT:[[TMP1:%.*]] = load , * [[OP1_ADDR]], align 1
+// CHECK-NEXT:[[TMP2:%.*]] = load i64, i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = call  @llvm.riscv.vadd.nxv8i8.nxv8i8.i64( [[TMP0]],  [[TMP1]], i64 [[TMP2]])
+// CHECK-NEXT:store  [[TMP3]], * [[RET]], align 1
+// CHECK-NEXT:[[TMP4:%.*]] = load , * [[RET]], align 1
+// CHECK-NEXT:ret  [[TMP4]]
+//
+vint8m1_t test(vint8m1_t op0, vint8m1_t op1, size_t vl) {
+  vint8m1_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: not %clang_cc1 -triple riscv64 -fsyntax-only -verify \
+// RUN:   -target-feature +experimental-v %s 2>&1 \
+// RUN: | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((__clang_riscv_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK: passing 'vint8m2_t' (aka '__rvv_int8m2_t') to parameter of incompatible type 'vint8m1_t'
+vint8m2_t test(vint8m2_t op0, vint8m2_t op1, size_t vl) {
+  vint8m2_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5120,6 +5120,7 @@
 #define GET_SVE_BUILTINS
 #define BUILTIN(name, types, attr) case SVE::BI##name:
 #include "clang/Basic/arm_sve_builtins.inc"
+#undef BUILTIN
 return true;
   }
 }
@@ -5146,6 +5147,37 @@
   D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static bool RISCVVAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  switch (BuiltinID) {
+  default:
+return false;
+#define BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
+#include "clang/Basic/BuiltinsRISCV.def"
+#undef BUILTIN
+return true;
+  }
+}
+
+static void handleRISCVBuiltinAliasAttr(Sema &S, Decl *D,
+const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_ar

[PATCH] D99432: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338107.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99432

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp

Index: clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
===
--- clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
+++ clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
@@ -28,16 +28,19 @@
 int main(int argc, char **argv) {
   int b[10], c[10], d[10];
 #pragma omp target teams map(tofrom:a)
+  {
+double escaped = 0;
 #pragma omp distribute parallel for firstprivate(b) lastprivate(c) if(a)
   for (int i= 0; i < argc; ++i)
-a = foo(&i) + foo(&a) + foo(&b[i]) + foo(&c[i]) + foo(&d[i]);
+a = foo(&i) + foo(&a) + foo(&b[i]) + foo(&c[i]) + foo(&d[i]) + escaped;
+  }
   return 0;
 }
 
 // SEQ: [[MEM_TY:%.+]] = type { [128 x i8] }
 // SEQ-DAG: [[SHARED_GLOBAL_RD:@.+]] = weak addrspace(3) global [[MEM_TY]] undef
 // SEQ-DAG: [[KERNEL_PTR:@.+]] = internal addrspace(3) global i8* undef
-// SEQ-DAG: [[KERNEL_SIZE:@.+]] = internal unnamed_addr constant i{{64|32}} 40
+// SEQ-DAG: [[KERNEL_SIZE:@.+]] = internal unnamed_addr constant i{{64|32}} 48
 // SEQ-DAG: [[KERNEL_SHARED:@.+]] = internal unnamed_addr constant i16 1
 // CHECK-DAG: @__omp_offloading_{{.*}}_main_[[LINE:l.+]]_exec_mode = weak constant i8 0
 
@@ -47,9 +50,10 @@
 // SEQ: call void @__kmpc_get_team_static_memory(i16 1, i8* addrspacecast (i8 addrspace(3)* getelementptr inbounds ([[MEM_TY]], [[MEM_TY]] addrspace(3)* [[SHARED_GLOBAL_RD]], i32 0, i32 0, i32 0) to i8*), i{{64|32}} [[SIZE]], i16 [[SHARED]], i8** addrspacecast (i8* addrspace(3)* [[KERNEL_PTR]] to i8**))
 // SEQ: [[PTR:%.+]] = load i8*, i8* addrspace(3)* [[KERNEL_PTR]],
 // SEQ: [[GEP:%.+]] = getelementptr inbounds i8, i8* [[PTR]], i{{64|32}} 0
-// PAR: [[GEP:%.+]] = call i8* @__kmpc_data_sharing_push_stack(i{{32|64}} 40, i16 1)
+// PAR: [[GEP:%.+]] = call i8* @__kmpc_data_sharing_push_stack(i{{32|64}} 48, i16 1)
 // CHECK: [[STACK:%.+]] = bitcast i8* [[GEP]] to %struct._globalized_locals_ty*
-// CHECK: getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[STACK]], i{{32|64}} 0, i{{32|64}} 0
+// CHECK-DAG: getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[STACK]], i{{32|64}} 0, i{{32|64}} 1
+// CHECK-DAG: getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[STACK]], i{{32|64}} 0, i{{32|64}} 0
 // CHECK-NOT: getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[STACK]],
 // CHECK: call void @__kmpc_for_static_init_4(
 
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -229,6 +229,7 @@
   llvm::SmallDenseMap MappedDeclsFields;
   bool AllEscaped = false;
   bool IsForCombinedParallelRegion = false;
+  bool IsInSPMDKernel = false;
 
   void markAsEscaped(const ValueDecl *VD) {
 // Do not globalize declare target variables.
@@ -242,6 +243,9 @@
 // Variables captured by value must be globalized.
 if (auto *CSI = CGF.CapturedStmtInfo) {
   if (const FieldDecl *FD = CSI->lookup(cast(VD))) {
+// Do not globalize captured vars in SPMD mode.
+if (IsInSPMDKernel)
+  return;
 // Check if need to capture the variable that was already captured by
 // value in the outer region.
 if (!IsForCombinedParallelRegion) {
@@ -351,9 +355,10 @@
 
 public:
   CheckVarsEscapingDeclContext(CodeGenFunction &CGF,
-   ArrayRef TeamsReductions)
-  : CGF(CGF), EscapedDecls(TeamsReductions.begin(), TeamsReductions.end()) {
-  }
+   ArrayRef TeamsReductions,
+   bool IsInSPMDKernel = false)
+  : CGF(CGF), EscapedDecls(TeamsReductions.begin(), TeamsReductions.end()),
+IsInSPMDKernel(IsInSPMDKernel) {}
   virtual ~CheckVarsEscapingDeclContext() = default;
   void VisitDeclStmt(const DeclStmt *S) {
 if (!S)
@@ -1631,65 +1636,30 @@
 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) {
   SourceLocation Loc = D.getBeginLoc();
 
-  const RecordDecl *GlobalizedRD = nullptr;
-  llvm::SmallVector LastPrivatesReductions;
-  llvm::SmallDenseMap MappedDeclsFields;
-  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
-  // Globalize team reductions variable unconditionally in all modes.
-  if (getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
-getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
-  if (getExecutionMode() == CGOpenMPRuntimeGPU::EM_SPMD) {
-get

[PATCH] D100448: [RISCV][Clang] Add RVV AMO builtins

2021-04-16 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:749
+  foreach type = type_list in
+foreach eew_list = [["8", "(Log2EEW:3)"], ["16", "(Log2EEW:4)"],
+["32", "(Log2EEW:5)"], ["64", "(Log2EEW:6)"]] in {

`foreach eew_list = EEWList in {`



Comment at: clang/include/clang/Basic/riscv_vector.td:766
+Ops[0] = Builder.CreateBitCast(Ops[0],
+  llvm::PointerType::getUnqual(ResultType));
+  }] in {

`ResultType->getPointerTo()`



Comment at: clang/include/clang/Basic/riscv_vector.td:770
+  def : RVVBuiltin<"v", "vPe" # eew_index # "Uvv", type>;
+if !and(!ne(type, "f"), !ne(type, "d"), has_unsigned) then
+  def : RVVBuiltin<"Uv", "UvPUe" # eew_index # "UvUv", type>;

`if !and(!not(IsFloat.val), has_unsigned) then`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100448

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


[PATCH] D100644: [clang][cli] NFC: Use Diags to report parsing success/failure

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100644

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


[PATCH] D100391: [RISCV][Clang] Add RVV miscellaneous intrinsic functions.

2021-04-16 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1304
+// Reinterpret between different SEW under the same LMUL
+foreach dst_sew = ["(FixedLog2SEW:3)", "(FixedLog2SEW:4)", 
"(FixedLog2SEW:5)",
+   "(FixedLog2SEW:6)"] in {

craig.topper wrote:
> Would this make more sense as just FixedSEW:8, FixedSEW:16, etc. I don't 
> think the Log2 is helping here. We need it for LMUL because of the fractional 
> lmul, but not SEW.
Agreed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100391

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


[PATCH] D99530: [OPENMP]Fix PR49098: respect firstprivate of declare target variable.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338111.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99530

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

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -43,6 +43,9 @@
   tx X;
   ty Y;
 };
+#pragma omp declare target
+int ga = 5;
+#pragma omp end declare target
 
 // CHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // CHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
@@ -52,9 +55,9 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l76]] = internal global [[TTII]] zeroinitializer
-// CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}]
-// CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [2 x i64] [i64 288, i64 49]
+// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
+// CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
+// CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
 // CHECK-DAG:  [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
 // CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
@@ -76,7 +79,7 @@
   const TT e = {n, n};
   int *p __attribute__ ((aligned (64))) = &a;
 
-#pragma omp target firstprivate(a, p)
+#pragma omp target firstprivate(a, p, ga)
   {
   }
 
@@ -91,8 +94,8 @@
   // CHECK:  [[D:%.+]] = alloca [[TT]],
   // CHECK:  [[P:%.+]] = alloca i32*, align 64
   // CHECK:  [[ACAST:%.+]] = alloca i{{[0-9]+}},
-  // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [2 x i8*],
-  // CHECK:  [[PTR_ARR:%.+]] = alloca [2 x i8*],
+  // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
+  // CHECK:  [[PTR_ARR:%.+]] = alloca [3 x i8*],
   // CHECK:  [[A2CAST:%.+]] = alloca i{{[0-9]+}},
   // CHECK:  [[BASE_PTR_ARR2:%.+]] = alloca [9 x i8*],
   // CHECK:  [[PTR_ARR2:%.+]] = alloca [9 x i8*],
@@ -116,29 +119,37 @@
   // CHECK-32:  store i{{[0-9]+}} [[AVAL]], i{{[0-9]+}}* [[ACAST]],
   // CHECK:  [[ACAST_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[ACAST]],
   // CHECK:  [[P_PTR:%.+]] = load i32*, i32** [[P]], align 64
-  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[ACAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP]] to i{{[0-9]+}}*
   // CHECK:  store i{{[0-9]+}} [[ACAST_VAL]], i{{[0-9]+}}* [[ACAST_TOPTR]],
-  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[ACAST_TOPTR2:%.+]] = bitcast i8** [[PTR_GEP]] to i{{[0-9]+}}*
   // CHECK:  store i{{[0-9]+}} [[ACAST_VAL]], i{{[0-9]+}}* [[ACAST_TOPTR2]],
-  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+  // CHECK:  [[BASE_PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[PCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP]] to i32***
   // CHECK:  store i32** [[P]], i32*** [[PCAST_TOPTR]],
-  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+  // CHECK:  [[PTR_GEP:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
   // CHECK:  [[PCAST_TOPTR2:%.+]] = bitcast i8** [[PTR_GEP]] to i32**
   // CHECK:  store i32* [[P_PTR]], i32** [[PCAST_TOPTR2]],
-  // CHECK:  [[BASE_PTR_GEP_ARG:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // CHECK:  [[PTR_GEP_ARG:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[PTR_ARR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // CHECK:  {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG]], i8** [[PTR_GEP_ARG]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT]], i32 0, i32 0), i8** null, i8** null)
-
-  // TCHECK:  d

[PATCH] D100534: [clang][deps] Generate the full command-line for modules

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

LGTM, just a couple of other comments inline.




Comment at: clang/include/clang/Frontend/CompilerInstance.h:230
+
+  std::shared_ptr getInvocationPtr() {
 assert(Invocation && "Compiler instance has no invocation!");

Is `get*Ptr()` already used in CompilerInstance? If so, matching that style 
sounds great. Otherwise I have a slight preference for `getShared*()`.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h:78-80
+  /// The compiler invocation associated with the translation unit that imports
+  /// this module.
+  CompilerInvocation Invocation;

jansvoboda11 wrote:
> dexonsmith wrote:
> > Looks like this will be a deep copy, but it doesn't look like it's being 
> > modified. Can this just be a `const &`, taken in the `ModuleDeps` 
> > constructor? Or is there a lifetime reason this needs to be as it is?
> It can't be `const &` for two reasons:
> 
> 1. The current code value-initializes `ModuleDeps` in two places and truly 
> initializes it later in `ModuleDepCollectorPP::handleTopLevelModule`. We'd 
> have to go with something like 
> `optional>` to be able to delay the 
> initialization.
> 2. The lifetime of the `CompilerInvocation` is a bit wild, but the reference 
> most likely wouldn't outlive `ModuleDeps` (depends on the client).
> 
> I think the best solution would be to extract the `shared_ptr` from 
> `CompilerInstance`, share it across `ModuleDeps` instances and only do a deep 
> copy when actually generating the command line.
Using shared_ptr seems right given the lifetime issues.

FWIW, I think `const CompilerInvocation*` is probably simpler to work with than 
`Optional>`.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:62
 std::function LookupModuleDeps) const {
-  // TODO: Build full command line. That also means capturing the original
-  //   command line into NonPathCommandLine.
-
-  std::vector Ret{
-  "-fno-implicit-modules",
-  "-fno-implicit-module-maps",
-  };
+  CompilerInvocation CI = getFullCommandLineCompilerInvocation(*this);
 

jansvoboda11 wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > I think guaranteed copy elision means this won't be a deep copy of the 
> > > return, but it might be nice to add a move constructor for 
> > > `CompilerInvocation` so it's more obvious.
> > That's intentional. The deep copy is performed inside the function.
> > 
> > Shouldn't the move constructor of `CompilerInvocation` be defaulted?
> s/defaulted/implicitly-defined/
Explicitly declaring a copy constructor suppresses the implicit move 
constructor. But adding a move with `= default` is probably all that's needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100534

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


[PATCH] D99436: [OPENMP]Fix PR49366: crash on VLAs in task untied regions.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338114.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99436

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp

Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -691,7 +691,7 @@
 
 void test_loop_eh() {
   const int N = 100;
-  float a[N], b[N], c[N];
+  float a[N], b[N], c[N]; // expected-note {{declared here}}
 #pragma omp parallel
 #pragma omp taskloop
   for (int i = 0; i < 10; i++) {
@@ -729,6 +729,13 @@
   void g() { throw 0; }
 };
   }
+// expected-error@+5 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+4 {{read of non-constexpr variable 'c' is not allowed in a constant expression}}
+#pragma omp taskloop untied
+  {
+  for (int i = 0; i < 10; ++i)
+int array[(int)c[0]];
+  }
 }
 
 void test_loop_firstprivate_lastprivate() {
Index: clang/test/OpenMP/task_messages.cpp
===
--- clang/test/OpenMP/task_messages.cpp
+++ clang/test/OpenMP/task_messages.cpp
@@ -173,7 +173,7 @@
   int &b = a;
   S sa;
   S &sb = sa;
-  int r;
+  int r; // expected-note {{declared here}}
 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   foo();
 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -330,6 +330,12 @@
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
 #pragma omp task mergeable mergeable
   ++r;
+// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
+#pragma omp task untied
+  {
+int array[r];
+  }
   volatile omp_event_handle_t evt;
   omp_event_handle_t sevt;
   const omp_event_handle_t cevt = evt;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2417,6 +2417,9 @@
   } else if (isSFINAEContext()) {
 VLADiag = diag::err_vla_in_sfinae;
 VLAIsError = true;
+  } else if (getLangOpts().OpenMP && isInOpenMPTaskUntiedContext()) {
+VLADiag = diag::err_openmp_vla_in_task_untied;
+VLAIsError = true;
   } else {
 VLADiag = diag::ext_vla;
 VLAIsError = false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -174,6 +174,7 @@
 bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
+bool UntiedRegion = false;
 bool CancelRegion = false;
 bool LoopStart = false;
 bool BodyComplete = false;
@@ -841,6 +842,15 @@
   return Parent->NowaitRegion;
 return false;
   }
+  /// Marks current region as untied (it has a 'untied' clause).
+  void setUntiedRegion(bool IsUntied = true) {
+getTopOfStack().UntiedRegion = IsUntied;
+  }
+  /// Return true if current region is untied.
+  bool isUntiedRegion() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->UntiedRegion : false;
+  }
   /// Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
 if (SharingMapTy *Parent = getSecondOnStackOrNull())
@@ -2154,6 +2164,11 @@
   return DSAStack->getNestingLevel();
 }
 
+bool Sema::isInOpenMPTaskUntiedContext() const {
+  return isOpenMPTaskingDirective(DSAStack->getCurrentDirective()) &&
+ DSAStack->isUntiedRegion();
+}
+
 bool Sema::isInOpenMPTargetExecutionDirective() const {
   return (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
   !DSAStack->isClauseParsingMode()) ||
@@ -14657,6 +14672,7 @@
 
 OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
  SourceLocation EndLoc) {
+  DSAStack->setUntiedRegion();
   return new (Context) OMPUntiedClause(StartLoc, EndLoc);
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10491,6 +10491,10 @@
   void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
  const FunctionDecl *Callee,
  SourceLocation Loc);
+
+  /// Return tru

[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338116.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_codegen.cpp


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -42,10 +42,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* 
[[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 
@{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10651,11 +10651,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -42,10 +42,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* [[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10651,11 +10651,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8628ed0 - [Driver] Allow both lib64 and lib in rocm-detect test.

2021-04-16 Thread Troy Johnson via cfe-commits

Author: Troy Johnson
Date: 2021-04-16T09:55:57-05:00
New Revision: 8628ed0310e2fc97e1536a8032327d746973069a

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

LOG: [Driver] Allow both lib64 and lib in rocm-detect test.

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

Added: 


Modified: 
clang/test/Driver/rocm-detect.hip

Removed: 




diff  --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index 5df5d2a9be067..68ae1edb4eb26 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd



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


[PATCH] D100502: Allow lib64 in driver test

2021-04-16 Thread Troy Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8628ed0310e2: [Driver] Allow both lib64 and lib in 
rocm-detect test. (authored by troyj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100502

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: 
[[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: 
[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -81,7 +81,7 @@
 
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
-// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib/clang/{{[0-9.]+}}
+// SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}}
 // SPACK: ROCm installation search path: /opt/rocm
 // SPACK: InstalledDir: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100652: [HIP] Support hipRTC in header

2021-04-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

hipRTC compiles HIP device code at run time. Since the system may not
have development tools installed, when a HIP program is compiled through
hipRTC, there is no standard C or C++ header available. As such, the HIP
headers should not depend on standard C or C++ headers when used
with hipRTC. Basically when hipRTC is used, HIP headers only provides
definitions of HIP device API functions. This is in line with what nvRTC does.

This patch adds support of hipRTC to HIP headers in clang. Basically hipRTC
defines a macro __HIPCC_RTC__ when compile HIP code at run time. When
this macro is defined, HIP headers do not include standard C/C++ headers.


https://reviews.llvm.org/D100652

Files:
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Headers/hip-header.hip
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -25,7 +25,7 @@
 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
+config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip',
'.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
Index: clang/test/Headers/hip-header.hip
===
--- /dev/null
+++ clang/test/Headers/hip-header.hip
@@ -0,0 +1,20 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -include __clang_hip_runtime_wrapper.h \
+// RUN:   -internal-isystem %S/../../lib/Headers/cuda_wrappers \
+// RUN:   -internal-isystem %S/Inputs/include \
+// RUN:   -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown \
+// RUN:   -target-cpu gfx906 -emit-llvm %s -fcuda-is-device -o - \
+// RUN:   -D__HIPCC_RTC__ | FileCheck %s
+
+// expected-no-diagnostics
+
+// CHECK-LABEL: amdgpu_kernel void @_Z4kernPff
+__global__ void kern(float *x, float y) {
+  *x = sin(y);
+}
+
+// CHECK-LABEL: define{{.*}} i64 @_Z11test_size_tv
+// CHEC: ret i64 8
+__device__ size_t test_size_t() {
+  return sizeof(size_t);
+}
Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -18,9 +18,27 @@
 
 #if __HIP__
 
+#if !defined(__HIPCC_RTC__)
 #include 
 #include 
 #include 
+#else
+typedef __SIZE_TYPE__ size_t;
+// Define macros which are needed to declare HIP device API's without standard
+// C/C++ headers. This is for readability so that these API's can be written
+// the same way as non-hipRTC use case. These macros need to be popped so that
+// they do not pollute users' name space.
+#pragma push_macro("NULL")
+#pragma push_macro("uint32_t")
+#pragma push_macro("uint64_t")
+#pragma push_macro("CHAR_BIT")
+#pragma push_macro("INT_MAX")
+#define NULL (void *)0
+#define uint32_t __UINT32_TYPE__
+#define uint64_t __UINT64_TYPE__
+#define CHAR_BIT __CHAR_BIT__
+#define INT_MAX __INTMAX_MAX__
+#endif // __HIPCC_RTC__
 
 #define __host__ __attribute__((host))
 #define __device__ __attribute__((device))
@@ -54,6 +72,7 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
+#if !defined(__HIPCC_RTC__)
 #if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 #include <__clang_cuda_math_forward_declares.h>
 #include <__clang_hip_cmath.h>
@@ -62,9 +81,16 @@
 #include 
 #include 
 #include 
+#endif // __HIPCC_RTC__
 #endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 
 #define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1
-
+#if defined(__HIPCC_RTC__)
+#pragma pop_macro("NULL")
+#pragma pop_macro("uint32_t")
+#pragma pop_macro("uint64_t")
+#pragma pop_macro("CHAR_BIT")
+#pragma pop_macro("INT_MAX")
+#endif // __HIPCC_RTC__
 #endif // __HIP__
 #endif // __CLANG_HIP_RUNTIME_WRAPPER_H__
Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -13,11 +13,13 @@
 #error "This file is for HIP and OpenMP AMDGCN device compilation only."
 #endif
 
+#if !defined(__HIPCC_RTC__)
 #if defined(__cplusplus)
 #include 
 #endif
 #include 
 #include 
+#endif // __HIPCC_RTC__
 
 #pragma push_macro("__DEVICE__")
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -1260,6 +1262,7 @@
 __DEVICE__
 double min(double __x, double __y) { return fmin(__x, __y); }
 
+#if !defined(__HIPCC_RTC__)
 __host__ inline static int min(int __arg1, int __arg2) {
   return std::min(__arg1, _

[PATCH] D99762: [OPENMP]Fix PR49777: Clang should not try to specialize orphaned directives in device codegen.

2021-04-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 338122.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99762

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c

Index: clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
===
--- clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -44,4 +44,4 @@
 }
 
 // expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num moved to}}
-// expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
+// expected-remark@* 2 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
Index: clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
===
--- clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -98,5 +98,5 @@
   }
 }
 
-// all-remark@* 3 {{OpenMP runtime call __kmpc_global_thread_num moved to}}
-// all-remark@* 3 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
+// all-remark@* 5 {{OpenMP runtime call __kmpc_global_thread_num moved to}}
+// all-remark@* 12 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
Index: clang/test/OpenMP/declare_target_codegen_globalization.cpp
===
--- clang/test/OpenMP/declare_target_codegen_globalization.cpp
+++ clang/test/OpenMP/declare_target_codegen_globalization.cpp
@@ -37,11 +37,14 @@
 // CHECK: define {{.*}}[[BAR]]()
 // CHECK: alloca i32,
 // CHECK: [[A_LOCAL_ADDR:%.+]] = alloca i32,
+// CHECK: [[PL:%.+]] = call i16 @__kmpc_parallel_level(
+// CHECK: [[IS_IN_PARALLEL:%.+]] = icmp eq i16 [[PL]], 0
 // CHECK: [[RES:%.+]] = call i8 @__kmpc_is_spmd_exec_mode()
 // CHECK: [[IS_SPMD:%.+]] = icmp ne i8 [[RES]], 0
 // CHECK: br i1 [[IS_SPMD]], label
 // CHECK: br label
-// CHECK: [[RES:%.+]] = call i8* @__kmpc_data_sharing_coalesced_push_stack(i64 128, i16 0)
+// CHECK: [[SZ:%.+]] = select i1 [[IS_IN_PARALLEL]], i64 4, i64 128
+// CHECK: [[RES:%.+]] = call i8* @__kmpc_data_sharing_coalesced_push_stack(i64 [[SZ]], i16 0)
 // CHECK: [[GLOBALS:%.+]] = bitcast i8* [[RES]] to [[GLOBAL_ST:%.+]]*
 // CHECK: br label
 // CHECK: [[ITEMS:%.+]] = phi [[GLOBAL_ST]]* [ null, {{.+}} ], [ [[GLOBALS]], {{.+}} ]
@@ -49,7 +52,9 @@
 // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
 // CHECK: [[LID:%.+]] = and i32 [[TID]], 31
 // CHECK: [[A_GLOBAL_ADDR:%.+]] = getelementptr inbounds [32 x i32], [32 x i32]* [[A_ADDR]], i32 0, i32 [[LID]]
-// CHECK: [[A_ADDR:%.+]] = select i1 [[IS_SPMD]], i32* [[A_LOCAL_ADDR]], i32* [[A_GLOBAL_ADDR]]
+// CHECK: [[A_GLOBAL_PARALLEL_ADDR:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
+// CHECK: [[A_PARALLEL_ADDR:%.+]] = select i1 [[IS_IN_PARALLEL]], i32* [[A_GLOBAL_PARALLEL_ADDR]], i32* [[A_GLOBAL_ADDR]]
+// CHECK: [[A_ADDR:%.+]] = select i1 [[IS_SPMD]], i32* [[A_LOCAL_ADDR]], i32* [[A_PARALLEL_ADDR]]
 // CHECK: call {{.*}}[[FOO]](i32* nonnull align {{[0-9]+}} dereferenceable{{.*}} [[A_ADDR]])
 // CHECK: br i1 [[IS_SPMD]], label
 // CHECK: [[BC:%.+]] = bitcast [[GLOBAL_ST]]* [[ITEMS]] to i8*
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -427,6 +427,20 @@
   /// true if we're definitely in the parallel region.
   bool IsInParallelRegion = false;
 
+  struct StateMode {
+ExecutionMode SavedExecutionMode = EM_Unknown;
+bool SavedIsInTargetMasterThreadRegion = false;
+bool SavedIsInTTDRegion = false;
+bool SavedIsInParallelRegion = false;
+StateMode(ExecutionMode SavedExecutionMode,
+  bool SavedIsInTargetMasterThreadRegion, bool SavedIsInTTDRegion,
+  bool SavedIsInParallelRegion)
+: SavedExecutionMode(SavedExecutionMode),
+  SavedIsInTargetMasterThreadRegion(SavedIsInTargetMasterThreadRegion),
+  SavedIsInTTDRegion(SavedIsInTTDRegion),
+  SavedIsInParallelRegion(SavedIsInParallelRegion) {}
+  };
+  llvm::DenseMap, StateMode> SavedExecutionModes;
   /// Map between an outlined function and its wrapper.
   llvm::DenseMap WrapperFunctionsMap;
 
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -4311,9 +4311,6 @@
 
 void CGOpenMPRunti

[PATCH] D100653: [clang][cli] NFC: Move conditional LangOptions parsing/generation

2021-04-16 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.

NFC, this simplifies the main parsing/generating functions by moving logic 
around conditional `LangOptions` where it belongs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100653

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
@@ -3260,7 +3260,21 @@
 void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
   SmallVectorImpl &Args,
   StringAllocator SA,
-  const llvm::Triple &T) {
+  const llvm::Triple &T, InputKind IK) {
+  if (IK.getFormat() == InputKind::Precompiled ||
+  IK.getLanguage() == Language::LLVM_IR) {
+if (Opts.ObjCAutoRefCount)
+  GenerateArg(Args, OPT_fobjc_arc, SA);
+if (Opts.PICLevel != 0)
+  GenerateArg(Args, OPT_pic_level, Twine(Opts.PICLevel), SA);
+if (Opts.PIE)
+  GenerateArg(Args, OPT_pic_is_pie, SA);
+for (StringRef Sanitizer : serializeSanitizerKinds(Opts.Sanitize))
+  GenerateArg(Args, OPT_fsanitize_EQ, Sanitizer, SA);
+
+return;
+  }
+
   OptSpecifier StdOpt;
   switch (Opts.LangStd) {
   case LangStandard::lang_opencl10:
@@ -3482,6 +3496,26 @@
DiagnosticsEngine &Diags) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
 
+  if (IK.getFormat() == InputKind::Precompiled ||
+  IK.getLanguage() == Language::LLVM_IR) {
+// ObjCAAutoRefCount and Sanitize LangOpts are used to setup the
+// PassManager in BackendUtil.cpp. They need to be initialized no matter
+// what the input type is.
+if (Args.hasArg(OPT_fobjc_arc))
+  Opts.ObjCAutoRefCount = 1;
+// PICLevel and PIELevel are needed during code generation and this should
+// be set regardless of the input type.
+Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+Opts.PIE = Args.hasArg(OPT_pic_is_pie);
+parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
+Diags, Opts.Sanitize);
+
+return Diags.getNumErrors() == NumErrorsBefore;
+  }
+
+  // Other LangOpts are only initialized when the input is not AST or LLVM IR.
+  // FIXME: Should we really be parsing this for an Language::Asm input?
+
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
   if (const Arg *A = Args.getLastArg(OPT_std_EQ)) {
@@ -4285,27 +4319,11 @@
   llvm::Triple T(Res.getTargetOpts().Triple);
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
 Res.getFileSystemOpts().WorkingDir);
-  if (DashX.getFormat() == InputKind::Precompiled ||
-  DashX.getLanguage() == Language::LLVM_IR) {
-// ObjCAAutoRefCount and Sanitize LangOpts are used to setup the
-// PassManager in BackendUtil.cpp. They need to be initializd no matter
-// what the input type is.
-if (Args.hasArg(OPT_fobjc_arc))
-  LangOpts.ObjCAutoRefCount = 1;
-// PIClevel and PIELevel are needed during code generation and this should be
-// set regardless of the input type.
-LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
-LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
-parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, LangOpts.Sanitize);
-  } else {
-// Other LangOpts are only initialized when the input is not AST or LLVM IR.
-// FIXME: Should we really be calling this for an Language::Asm input?
-ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes,
-  Diags);
-if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
-  LangOpts.ObjCExceptions = 1;
-  }
+
+  ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes,
+Diags);
+  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
+LangOpts.ObjCExceptions = 1;
 
   if (LangOpts.CUDA) {
 // During CUDA device-side compilation, the aux triple is the
@@ -4499,24 +4517,7 @@
   GenerateFrontendArgs(FrontendOpts, Args, SA, LangOpts->IsHeaderFile);
   GenerateTargetArgs(*TargetOpts, Args, SA);
   GenerateHeaderSearchArgs(*HeaderSearchOpts, Args, SA);
-
-  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->PICL

[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-16 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:437
+  CompoundStmt *CS = CompoundStmt::Create(Context, Elts, L, R);
+  DiagnoseUnusedButSetVariables(CS);
+  return CS;

mbenfield wrote:
> mbenfield wrote:
> > george.burgess.iv wrote:
> > > It seems like these two warnings are doing analyses with identical 
> > > requirements (e.g., the function's body must be present), but are taking 
> > > two different sets of variables into account while doing so.
> > > 
> > > Is there a way we can rephrase this so we only need to walk the AST 
> > > checking once for all of this?
> > I'll think about this. It might be tricky. 
> I'll implement this. It will be a fairly different approach though. 
I have this implemented. I am going to run a performance comparison on the two 
approaches before making a new revision here. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-16 Thread David Candler via Phabricator via cfe-commits
dcandler updated this revision to Diff 338126.
dcandler marked 2 inline comments as done.
dcandler added a comment.

Removed one duplicated line.


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

https://reviews.llvm.org/D99079

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm-target-features.c
  clang/test/CodeGen/arm64_crypto.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Driver/arm-features.c
  clang/test/Driver/arm-mfpu.c
  clang/test/Driver/armv8.1m.main.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/test/Bindings/llvm-c/ARM/disassemble.test
  llvm/test/MC/ARM/directive-arch_extension-aes-sha2.s
  llvm/test/MC/ARM/directive-arch_extension-crypto.s
  llvm/test/MC/ARM/neon-crypto.s

Index: llvm/test/MC/ARM/neon-crypto.s
===
--- llvm/test/MC/ARM/neon-crypto.s
+++ llvm/test/MC/ARM/neon-crypto.s
@@ -9,10 +9,10 @@
 @ CHECK: aese.8 q0, q1  @ encoding: [0x02,0x03,0xb0,0xf3]
 @ CHECK: aesimc.8 q0, q1@ encoding: [0xc2,0x03,0xb0,0xf3]
 @ CHECK: aesmc.8 q0, q1 @ encoding: [0x82,0x03,0xb0,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
 
 sha1h.32  q0, q1
 sha1su1.32  q0, q1
@@ -20,9 +20,9 @@
 @ CHECK: sha1h.32  q0, q1   @ encoding: [0xc2,0x02,0xb9,0xf3]
 @ CHECK: sha1su1.32 q0, q1  @ encoding: [0x82,0x03,0xba,0xf3]
 @ CHECK: sha256su0.32 q0, q1@ encoding: [0xc2,0x03,0xba,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 sha1c.32  q0, q1, q2
 sha1m.32  q0, q1, q2
@@ -38,14 +38,14 @@
 @ CHECK: sha256h.32  q0, q1, q2  @ encoding: [0x44,0x0c,0x02,0xf3]
 @ CHECK: sha256h2.32 q0, q1, q2  @ encoding: [0x44,0x0c,0x12,0xf3]
 @ CHECK: sha256su1.32 q0, q1, q2 @ encoding: [0x44,0x0c,0x22,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 vmull.p64 q8, d16, d17
 @ CHECK: vmull.p64  q8, d16, d17@ encoding: [0xa1,0x0e,0xe0,0xf2]
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
Index: llvm/test/MC/ARM/directive-arch_extension-crypto.s
===
--- llvm/test/MC/ARM/directive-arch_extension-crypto.s
+++ llvm/test/MC/ARM/directive-arch_extension-crypto.s
@@ -17,38 +17,38 @@
 	.type crypto,%function
 crypto:
 	vmull.p64 q0, d0, d1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 
 	aesd.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aese.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aesimc.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aesmc.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 
 	sha1h.32 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: sha2 armv8
 	sha1su1.32 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: sha2 armv8
 	sha256su0.32 q0, q1
-

[PATCH] D100654: [SystemZ][z/OS] Set more text files as text

2021-04-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, arphaman.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch corrects more instances of text files being opened as text.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100654

Files:
  clang/tools/driver/cc1gen_reproducer_main.cpp
  clang/tools/libclang/CIndexer.cpp
  llvm/include/llvm/Support/GraphWriter.h


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";


Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -331,7 +331,8 @@
   if (Filename.empty()) {
 Filename = createGraphFilename(Name.str(), FD);
   } else {
-std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+std::error_code EC = sys::fs::openFileForWrite(
+Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
 // Writing over an existing file is not considered an error.
 if (EC == std::errc::file_exists) {
Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -163,7 +163,8 @@
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+  llvm::sys::fs::OF_Text))
 return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
Index: clang/tools/driver/cc1gen_reproducer_main.cpp
===
--- clang/tools/driver/cc1gen_reproducer_main.cpp
+++ clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -162,7 +162,7 @@
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr> Buffer =
-  llvm::MemoryBuffer::getFile(Input);
+  llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
 llvm::errs() << "error: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100533: [clang][deps] Remove the -full-command-line flag

2021-04-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100533

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


[PATCH] D100653: [clang][cli] NFC: Move conditional LangOptions parsing/generation

2021-04-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100653

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


[PATCH] D100455: [clang] Rename CompilerInvocationBase to RefBase, split out ValueBase

2021-04-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100455

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


[PATCH] D100473: [clang] Implement CompilerInvocation copy assignment

2021-04-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

I think this is fine given that we already have a copy constructor with deep 
copy semantics.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100473

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


[PATCH] D99861: [Clang] Record tokens in attribute arguments for user-defined C++/C2x attributes

2021-04-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99861#2694605 , @urnathan wrote:

> See also https://bugs.llvm.org/show_bug.cgi?id=46446.  when I first fell into 
> this issue, I did think it was trying to save the token stream as this patch 
> is doing.  Neat I thought :)  although I'm a clang weenie, saving the tokens 
> is putting this into deferred-parse territory, which makes me nervous.

FWIW, I've been stewing on the deferred parse issues with the approach from 
this patch because they make me nervous as well. Because `[[]]` attributes can 
have arbitrary token soup for their arguments and that includes arbitrary 
expressions, I worry that just giving the plugin author a bunch of tokens and 
saying "you deal with it" will only work for very trivial arguments.

> Wouldn't it be better for the ParsedAttrInfo objects to determine whether and 
> how to parse their arguments.  They could do so immediately, or save tokens, 
> or whatever on a per-attribute per-argument basis.  Isn't that more flexible? 
>  Add some ParsedAttrInfo defaults for the default cxx11, gnu & clang flavours 
> of attributes?

I think this would be an improved approach over just replaying the tokens for 
the plugin to handle. I would hope that we'd be able to design something that 
handles the easy cases of passing a string literal, an integer value, an 
enumerated list of named values, etc so that plugin authors don't have to 
reinvent the wheel for basic needs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99861

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


[PATCH] D100391: [RISCV][Clang] Add RVV miscellaneous intrinsic functions.

2021-04-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D100391/new/

https://reviews.llvm.org/D100391

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


[PATCH] D99936: [clang][parser] Unify rejecting (non) decl stmt with gnu attributes

2021-04-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D99936#2694178 , @tbaeder wrote:

> Hey Aaron, it's been a while. Do you have a suggestion on how to proceed if 
> @rsmith has no opinion on it?

I think the behavior in the patch is okay as-is, so LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99936

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


[PATCH] D100617: [RISCV][Clang] Drop the assembly tests for RVV intrinsics.

2021-04-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D100617/new/

https://reviews.llvm.org/D100617

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/RISCV/rvp/intrinsics-rv32p.ll:25
+  %1 = bitcast i32 %b.coerce to <4 x i8>
+  %2 = tail call <4 x i8> @llvm.riscv.add8.v4i8(<4 x i8> %0, <4 x i8> %1)
+  %3 = bitcast <4 x i8> %2 to i32

I'm still not clear why we need to have two different ways to do the same 
operation. Why isn't the C interface all scalar types or all vector types? How 
do users choose which interface to use?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Also can you please explain the vector codegen plan at a high level? Do you 
intend to support auto vectorization or just using vector_size in C?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:41
 //  E -> ext_vector, followed by the number of elements and the base type.
+//  e -> Register sized Vector, followd by the base type and
+//   its width is the same as the register size.

followd -> followed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-04-16 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 338160.
ffrankies marked 3 inline comments as done.
ffrankies added a comment.

Removed `*- C++ -*` from IdDependentBackwardBranchCheck.cpp file-level comment.


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

https://reviews.llvm.org/D70094

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  //  Assignments 
+  int ThreadID = get_local_id(0);
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-3]]:3: note: assignment of ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+
+  int ThreadID3 = Example.IDDepField; // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+  ThreadID * 2 // OK: not used in any loops
+  };
+
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-9]]:3: note: inferred assignment of ID-dependent value from ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-29]]:3: note: assignment of ID-dependent variable ThreadID
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-24]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-30]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-38]]:3: note: assignment of ID-dependent field IDDepField
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
=

[PATCH] D100609: [Offload][OpenMP][CUDA] Allow fembed-bitcode for device offload

2021-04-16 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4442-4446
+  std::string CPU = getCPUName(Args, Triple, /*FromAs*/ false);
+  if (!CPU.empty()) {
+CmdArgs.push_back("-target-cpu");
+CmdArgs.push_back(Args.MakeArgString(CPU));
+  }

This duplicates the same code a bit further down in the function. I think you 
should just set `-target-cpu` for everyone before diving into 
`if(embedBitcodeInObject)`.



Comment at: clang/test/Driver/embed-bitcode-nvptx.cu:1
+// RUN: %clang -Xclang -triple -Xclang nvptx64 -S -Xclang -target-feature 
-Xclang +ptx70 -fembed-bitcode=all --cuda-device-only -nocudalib -nocudainc %s 
-o - | FileCheck %s
+// REQUIRES: nvptx-registered-target

This command line looks extremely odd to me.
If you are compiling with `--cuda-device-only`, then clang should've already 
set the right triple and the features.

Could you tell me more about what is the intent of the compilation and why you 
use this particular set of options?
I.e. why not just do `clang -x cuda --offload-arch=sm_70 --cuda-device-only 
-nocudalib -nocudainc`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100609

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


[PATCH] D100619: [ASTReader] Only mark module out of date if not already compiled

2021-04-16 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/test/Modules/Inputs/error/error.h:1
+#pragma mark mark
+

Is this pragma relevant for the test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100619

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D100630#2694681 , @probinson wrote:

> If DBX is going to be really pedantic about not recognizing tags or 
> attributes that don't align with the DWARF version, maybe we're better off 
> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.

Thanks! Yes, that is a good idea. By adding `-gstrict-dwarf`, all these dwarf 
version check work might be beneficial to others, not just for *dbx* .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D100514#2693600 , @jdoerfert wrote:

> Any reason we should not unconditionally use the OMPIRBuilder impl? (btw, 
> many thanks for providing one!)
> We have an OMPIRBuilder always around in clang's codegen, so there is little 
> reason not to use it if it is feature complete.

I'm fine using OMPIRBuilder as default. I was not set it as default since most 
of the clause/directive are still using Clang codegen as default (ex: `master`, 
`critical`, and `for` are now use Clang codegen as default).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

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


[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D100514#2693601 , @jdoerfert wrote:

> Also, don't forget to mark it as done in 
> https://clang.llvm.org/docs/OpenMPSupport.html :)

I'll mark it as done after combined constructs are also done. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

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


[PATCH] D100514: [OpenMP] Added codegen for masked directive

2021-04-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D100514#2695271 , @cchen wrote:

> In D100514#2693600 , @jdoerfert 
> wrote:
>
>> Any reason we should not unconditionally use the OMPIRBuilder impl? (btw, 
>> many thanks for providing one!)
>> We have an OMPIRBuilder always around in clang's codegen, so there is little 
>> reason not to use it if it is feature complete.
>
> I'm fine using OMPIRBuilder as default. I was not set it as default since 
> most of the clause/directive are still using Clang codegen as default (ex: 
> `master`, `critical`, and `for` are now use Clang codegen as default).

Initially we did not have an OMPIRBuilder object unconditionally, now we have. 
Let's move over everything that is ready. So master and critical should be good 
to go as well I suppose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100514

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


[PATCH] D100609: [Offload][OpenMP][CUDA] Allow fembed-bitcode for device offload

2021-04-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4442-4446
+  std::string CPU = getCPUName(Args, Triple, /*FromAs*/ false);
+  if (!CPU.empty()) {
+CmdArgs.push_back("-target-cpu");
+CmdArgs.push_back(Args.MakeArgString(CPU));
+  }

tra wrote:
> This duplicates the same code a bit further down in the function. I think you 
> should just set `-target-cpu` for everyone before diving into 
> `if(embedBitcodeInObject)`.
Fair. I'll update it.



Comment at: clang/test/Driver/embed-bitcode-nvptx.cu:1
+// RUN: %clang -Xclang -triple -Xclang nvptx64 -S -Xclang -target-feature 
-Xclang +ptx70 -fembed-bitcode=all --cuda-device-only -nocudalib -nocudainc %s 
-o - | FileCheck %s
+// REQUIRES: nvptx-registered-target

tra wrote:
> This command line looks extremely odd to me.
> If you are compiling with `--cuda-device-only`, then clang should've already 
> set the right triple and the features.
> 
> Could you tell me more about what is the intent of the compilation and why 
> you use this particular set of options?
> I.e. why not just do `clang -x cuda --offload-arch=sm_70 --cuda-device-only 
> -nocudalib -nocudainc`.
> 
> Could you tell me more about what is the intent of the compilation and why 
> you use this particular set of options?

because I never compiled cuda really ;)

I'll go with your options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100609

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-16 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Running this over Chromium, I'm getting

  $ cat /tmp/a.cc
  struct A {
int i;
A(int i): i(i) {}
  };
  
  $ ./build/rel/bin/clang++ -fsyntax-only /tmp/a.cc -Wunused-but-set-parameter
  /tmp/a.cc:3:9: warning: parameter 'i' set but not used 
[-Wunused-but-set-parameter]
A(int i): i(i) {}
  ^
  1 warning generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-16 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

-Wunused-but-set-variable is firing on `x` at [1]

[1] 
https://source.chromium.org/chromium/chromium/src/+/master:third_party/abseil-cpp/absl/synchronization/mutex.h;drc=07cb7b184515ad207d30f00d0b00b8ce96d0a750;l=947

  ../../third_party/abseil-cpp/absl/synchronization/mutex.h:947:6: error: 
variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
T *x = static_cast(c->arg_);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[clang] 59437cb - [M68k] Fix empty builtin va_list kind

2021-04-16 Thread Min-Yih Hsu via cfe-commits

Author: Min-Yih Hsu
Date: 2021-04-16T11:09:22-07:00
New Revision: 59437cb7d7c30054f0e77b2369c0aeffed3ccb14

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

LOG: [M68k] Fix empty builtin va_list kind

Clang _requires_ every target to provide a va_list kind so we shouldn't
put a llvm_unreachable there. Using `VoidPtrBuiltinVaList` because m68k
doesn't have any special ABI for variadic args.

Added: 


Modified: 
clang/lib/Basic/Targets/M68k.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/M68k.cpp 
b/clang/lib/Basic/Targets/M68k.cpp
index e10fd77d2590a..8e8a69f75c8b0 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -159,9 +159,8 @@ const char *M68kTargetInfo::getClobbers() const {
   return "";
 }
 
-M68kTargetInfo::BuiltinVaListKind M68kTargetInfo::getBuiltinVaListKind() const 
{
-  // FIXME: implement
-  llvm_unreachable("Not implemented yet");
+TargetInfo::BuiltinVaListKind M68kTargetInfo::getBuiltinVaListKind() const {
+  return TargetInfo::VoidPtrBuiltinVaList;
 }
 
 } // namespace targets



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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I thought that adding a new fence required changing every optimization pass in 
LLVM. That's why the constrained intrinsics were implemented they way they are 
where no fence is needed.

Aren't you going to have miscompiles using this new fence until all that 
optimization work is done? Or am I wrong? @andrew.w.kaylor?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D100118#2695365 , @kpn wrote:

> I thought that adding a new fence required changing every optimization pass 
> in LLVM. That's why the constrained intrinsics were implemented they way they 
> are where no fence is needed.
>
> Aren't you going to have miscompiles using this new fence until all that 
> optimization work is done? Or am I wrong? @andrew.w.kaylor?

Perhaps there is no problem. I'm looking at D99675 
 now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

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


  1   2   >