Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-08-06 Thread Michael Kruse via cfe-commits
2018-07-13 10:07 GMT-05:00 Erich Keane via cfe-commits
:
> -class AttributeList { // TODO: This should really be called ParsedAttribute
> +class ParsedAttr { // TODO: This should really be called ParsedAttribute

Should this TODO be removed/ParsedAttr really be called ParsedAttribute?

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


Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-08-06 Thread Michael Kruse via cfe-commits
Thank you.

Michael


2018-08-06 13:13 GMT-05:00 Keane, Erich :
> Good grief... I even made a note to remove this 'TODO' on my whiteboard!
>
> I discussed the name with AaronBallman who preferred ParsedAttr over 
> ParsedAttribute (since ParsedAttributes is also a type).
>
> Fixed in r339039.
>
> -Original Message-
> From: meiners...@googlemail.com [mailto:meiners...@googlemail.com] On Behalf 
> Of Michael Kruse
> Sent: Monday, August 6, 2018 11:00 AM
> To: Keane, Erich 
> Cc: cfe-commits 
> Subject: Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr
>
> 2018-07-13 10:07 GMT-05:00 Erich Keane via cfe-commits
> :
>> -class AttributeList { // TODO: This should really be called ParsedAttribute
>> +class ParsedAttr { // TODO: This should really be called ParsedAttribute
>
> Should this TODO be removed/ParsedAttr really be called ParsedAttribute?
>
> Michael
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r338291 - Remove trailing space

2018-07-30 Thread Michael Kruse via cfe-commits
Can you point me to such a discussion about trailing whitespace?

It seems to contradict the conclusion in another current thread to not
consider churn for out-of-tree users (for C++ API in this case)

https://lists.llvm.org/pipermail/cfe-dev/2018-July/058579.html

> We have historically taken the position that the churn caused for
> out-of-tree users of the C++ API are not a consideration when performing an
> API refactoring. (For two reasons: one is that we explicitly do not have a
> stable C++ API; the other is that this is the mechanism by which we
> encourage people to upstream changes.) This actually seems like a
> relatively easy change in that regard: client code can be largely updated
> by a regular expression.


Michael



2018-07-30 15:36 GMT-05:00 Aaron Ballman :
> On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse
>  wrote:
>> I think removing trailing space is a good thing. Some editors remove
>> any trailing space when saving a file. This shows up in diffs that I
>> then have to undo manually.
>
> I've also run into the same issues on occasion. However, this isn't
> about whether we dislike trailing spaces or not; it's about NFC churn
> for out of tree users who have to try to keep their local patches
> clean against upstream. This kind of churn makes for merge conflicts
> and this is a the reason the community has traditionally rejected
> these large-scale commits in the past. If we want to change that
> policy, it should come after community discussion and agreement.
>
> ~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338800 - Append new attributes to the end of an AttributeList.

2018-08-02 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Thu Aug  2 18:21:16 2018
New Revision: 338800

URL: http://llvm.org/viewvc/llvm-project?rev=338800&view=rev
Log:
Append new attributes to the end of an AttributeList.

Recommit of r335084 after revert in r335516.

... instead of prepending it at the beginning (the original behavior
since implemented in r122535 2010-12-23). This builds up an
AttributeList in the the order in which the attributes appear in the
source.

The reverse order caused nodes for attributes in the AST (e.g. LoopHint)
to be in the reverse order, and therefore printed in the wrong order in
-ast-dump. Some TODO comments mention this. The order was explicitly
reversed for enable_if attribute overload resolution and name mangling,
which is not necessary anymore with this patch.

The change unfortunately has some secondary effect, especially on
diagnostic output. In the simplest cases, the CHECK lines or expected
diagnostic were changed to the the new output. If the kind of
error/warning changed, the attributes' order was changed instead.

This unfortunately causes some 'previous occurrence here' hints to be
textually after the main marker. This typically happens when attributes
are merged, but are incompatible to each other. Interchanging the role
of the the main and note SourceLocation will also cause the case where
two different declaration's attributes (in contrast to multiple
attributes of the same declaration) are merged to be reverse. There is
no easy fix because sometimes previous attributes are merged into a new
declaration's attribute list, sometimes new attributes are added to a
previous declaration's attribute list. Since 'previous occurrence here'
pointing to locations after the main marker is not rare, I left the
markers as-is; it is only relevant when the attributes are declared in
the same declaration anyway.

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

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
cfe/trunk/test/Index/complete-with-annotations.cpp
cfe/trunk/test/Misc/ast-print-pragmas.cpp
cfe/trunk/test/PCH/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-loop-safety.cpp
cfe/trunk/test/Parser/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-unroll-and-jam.cpp
cfe/trunk/test/Parser/pragma-unroll.cpp
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability.c
cfe/trunk/test/Sema/attr-coldhot.c
cfe/trunk/test/Sema/attr-disable-tail-calls.c
cfe/trunk/test/Sema/attr-long-call.c
cfe/trunk/test/Sema/attr-micromips.c
cfe/trunk/test/Sema/attr-notail.c
cfe/trunk/test/Sema/attr-ownership.c
cfe/trunk/test/Sema/attr-ownership.cpp
cfe/trunk/test/Sema/attr-print.c
cfe/trunk/test/Sema/attr-visibility.c
cfe/trunk/test/Sema/internal_linkage.c
cfe/trunk/test/Sema/mips-interrupt-attr.c
cfe/trunk/test/Sema/nullability.c
cfe/trunk/test/SemaCXX/attr-print.cpp
cfe/trunk/test/SemaCXX/ms-uuid.cpp
cfe/trunk/test/SemaObjC/nullability.m
cfe/trunk/test/SemaOpenCL/address-spaces.cl
cfe/trunk/test/SemaTemplate/attributes.cpp

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=338800&r1=338799&r2=338800&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  2 18:21:16 2018
@@ -728,10 +728,6 @@ public:
   ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; }
   const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; }
 
-  void addAtStart(ParsedAttr *newAttr) {
-assert(newAttr);
-AttrList.insert(AttrList.begin(), newAttr);
-  }
   void addAtEnd(ParsedAttr *newAttr) {
 assert(newAttr);
 AttrList.push_back(newAttr);
@@ -785,6 +781,23 @@ public:
   iterator end() { return iterator(AttrList.end()); }
   const_iterator end() const { return const_iterator(AttrList.end()); }
 
+  ParsedAttr &front() {
+assert(!empty());
+return *AttrList.front();
+  }
+  const ParsedAttr &front() const {
+assert(!empty());
+return *AttrList.front();
+  }
+  ParsedAttr &back() {
+assert(!empty());
+return *AttrList.back();
+  }
+  const ParsedAttr &back() const {
+assert(!empty());
+return *AttrList.back();
+  }
+
   bool hasAttribute(ParsedAttr::Kind K) const {
 return llvm::any_of(
 AttrList, [K](const ParsedAttr *AL) { return AL->getKind() == K; });
@@ -826,7 +839,7 @@ public:
  SourceLocation ellipsisLoc = SourceLocation()) {
 Parse

r338810 - [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-08-02 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Thu Aug  2 21:42:52 2018
New Revision: 338810

URL: http://llvm.org/viewvc/llvm-project?rev=338810&view=rev
Log:
[CodeGen] Emit parallel_loop_access for each loop in the loop stack.

Summary:
Emit !llvm.mem.parallel_loop_access metadata for memory accesses even if the 
parallel loop is not the top on the loop stack.

Fixes llvm.org/PR37558.

Reviewers: ABataev, hfinkel, amusman, tyler.nowicki

Reviewed By: hfinkel

Subscribers: Meinersbur, hfinkel, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp
Modified:
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=338810&r1=338809&r2=338810&view=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Thu Aug  2 21:42:52 2018
@@ -344,6 +344,17 @@ void LoopInfoStack::InsertHelper(Instruc
 return;
   }
 
-  if (L.getAttributes().IsParallel && I->mayReadOrWriteMemory())
-I->setMetadata("llvm.mem.parallel_loop_access", L.getLoopID());
+  if (I->mayReadOrWriteMemory()) {
+SmallVector ParallelLoopIDs;
+for (const LoopInfo &AL : Active)
+  if (AL.getAttributes().IsParallel)
+ParallelLoopIDs.push_back(AL.getLoopID());
+
+MDNode *ParallelMD = nullptr;
+if (ParallelLoopIDs.size() == 1)
+  ParallelMD = cast(ParallelLoopIDs[0]);
+else if (ParallelLoopIDs.size() >= 2)
+  ParallelMD = MDNode::get(I->getContext(), ParallelLoopIDs);
+I->setMetadata("llvm.mem.parallel_loop_access", ParallelMD);
+  }
 }

Added: cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp?rev=338810&view=auto
==
--- cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp Thu Aug  2 21:42:52 
2018
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the inner and outer loop using a list.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; ++i) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+for (int j = 0; j < Length; ++j)
+  List[i * Length + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[PARALLEL_LIST:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID:[0-9]+]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[PARALLEL_LIST]] = !{![[OUTER_LOOPID]], ![[INNER_LOOPID]]}
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],

Added: cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp?rev=338810&view=auto
==
--- cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp Thu Aug  2 21:42:52 
2018
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_outer_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+for (int j = 0; j < 2; j += 1)
+  List[i + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],


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


r335084 - Append new attributes to the end of an AttributeList.

2018-06-20 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Tue Jun 19 16:46:52 2018
New Revision: 335084

URL: http://llvm.org/viewvc/llvm-project?rev=335084&view=rev
Log:
Append new attributes to the end of an AttributeList.

... instead of prepending it at the beginning (the original behavior
since implemented in r122535 2010-12-23). This builds up an
AttributeList in the the order in which the attributes appear in the
source.

The reverse order caused nodes for attributes in the AST (e.g. LoopHint)
to be in the reverse, and therefore printed in the wrong order by
-ast-dump. Some TODO comments mention this. The order was explicitly
reversed for enable_if attribute overload resolution and name mangling,
which is not necessary anymore with this patch.

The change unfortunately has some secondary effects, especially for
diagnostic output. In the simplest cases, the CHECK lines or expected
diagnostic were changed to the the new output. If the kind of
error/warning changed, the attribute's order was changed instead.

It also causes some 'previous occurrence here' hints to be textually
after the main marker. This typically happens when attributes are
merged, but are incompatible. Interchanging the role of the the main
and note SourceLocation will also cause the case where two different
declaration's attributes (in contrast to multiple attributes of the
same declaration) are merged to be reversed. There is no easy fix
because sometimes previous attributes are merged into a new
declaration's attribute list, sometimes new attributes are added to a
previous declaration's attribute list. Since 'previous occurrence here'
pointing to locations after the main marker is not rare, I left the
markers as-is; it is only relevant when the attributes are declared in
the same declaration anyway, which often is on the same line.

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

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
cfe/trunk/test/Index/complete-with-annotations.cpp
cfe/trunk/test/Misc/ast-print-pragmas.cpp
cfe/trunk/test/PCH/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-loop-safety.cpp
cfe/trunk/test/Parser/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-unroll.cpp
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability.c
cfe/trunk/test/Sema/attr-coldhot.c
cfe/trunk/test/Sema/attr-disable-tail-calls.c
cfe/trunk/test/Sema/attr-long-call.c
cfe/trunk/test/Sema/attr-micromips.c
cfe/trunk/test/Sema/attr-notail.c
cfe/trunk/test/Sema/attr-ownership.c
cfe/trunk/test/Sema/attr-ownership.cpp
cfe/trunk/test/Sema/attr-print.c
cfe/trunk/test/Sema/attr-swiftcall.c
cfe/trunk/test/Sema/attr-target-mv.c
cfe/trunk/test/Sema/attr-visibility.c
cfe/trunk/test/Sema/internal_linkage.c
cfe/trunk/test/Sema/mips-interrupt-attr.c
cfe/trunk/test/Sema/ms_abi-sysv_abi.c
cfe/trunk/test/Sema/nullability.c
cfe/trunk/test/Sema/stdcall-fastcall.c
cfe/trunk/test/SemaCXX/attr-print.cpp
cfe/trunk/test/SemaCXX/attr-swiftcall.cpp
cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp
cfe/trunk/test/SemaCXX/ms-uuid.cpp
cfe/trunk/test/SemaOpenCL/address-spaces.cl
cfe/trunk/test/SemaTemplate/attributes.cpp

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=335084&r1=335083&r2=335084&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Jun 19 16:46:52 2018
@@ -764,8 +764,11 @@ public:
   void add(AttributeList *newAttr) {
 assert(newAttr);
 assert(newAttr->getNext() == nullptr);
-newAttr->setNext(list);
-list = newAttr;
+
+// FIXME: AttributeList is a singly linked list, i.e. appending to the end
+// requires walking to the last element. For adding n attributes, this
+// requires O(n^2) time. However, AttributeLists should be very short.
+addAllAtEnd(newAttr);
   }
 
   void addAll(AttributeList *newList) {

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=335084&r1=335083&r2=335084&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jun 19 16:46:52 2018
@@ -707,10 +707,8 @@ void CXXNameMangler::mangleFunctionEncod
   if (FD->hasAttr()) {
 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
 Out << "Ua9enable_ifI";
-// FIXME: specific_attr_iterator iterates in reverse order. Fix that and 
use
-// it here.
-   

Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-24 Thread Michael Kruse via cfe-commits
Hi,

multiple comments in the code indicate that the attribute order was
surprising and probably has lead to bugs, and will lead to bugs in the
future. The order had to be explicitly reversed to avoid those. This
alone for me this seems a good reason to have the attributes in the
order in which they appear in the source.

It would be nice it you could send a reproducer. At a glance, your
case does not seem related since the format strings are function
arguments, not attributes.

Michael


2018-06-23 17:17 GMT-05:00 David Jones :
> This commit seems to have some substantial downsides... for example, it now
> flags calls like this as warnings:
> http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/src/msgl-check.c?id=05ecefa943f339019b7127aa92cbb09f6fd49ed3#n478
>
> Previously, the reverse order meant that the plural format string was
> examined, but now it is only the singular string. Since the singular string
> doesn't include a substitution, the unused format variable warning fires
> after this revision.
>
> I don't see a strong argument for why one order is more correct than the
> other; however, given that this is in conflict with real code found in the
> wild, I think this needs to be addressed.
>
> Since the semantics of the ordering of multiple format args seems somewhat
> ill-defined, it seems to me like reverting may be the best near-term choice.
> I can imagine other ways to fix the diagnostic, but the only behaviour that
> I would believe to be expected by existing code is the old one, so a change
> like this one probably needs to be more carefully vetted before being
> (re-)committed.

Could you give more details about your concerns?


> Please let me know your plan. (If I don't hear back in a day or so, I'll go
> ahead and revert for you as the safe default course of action.)

On a weekend?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348762 - Use zip_longest for iterator range comparisons. NFC.

2018-12-10 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Dec 10 07:16:37 2018
New Revision: 348762

URL: http://llvm.org/viewvc/llvm-project?rev=348762&view=rev
Log:
Use zip_longest for iterator range comparisons. NFC.

Use zip_longest in two locations that compare iterator ranges.
zip_longest allows the iteration using a range-based for-loop and to be
symmetric over both ranges instead of prioritizing one over the other.
In that latter case code have to handle the case that the first is
longer than the second, the second is longer than the first, and both
are of the same length, which must partially be checked after the loop.

With zip_longest, this becomes an element comparison within the loop
like the comparison of the elements themselves. The symmetry makes it
clearer that neither the first and second iterators are handled
differently. The iterators are not event used directly anymore, just
the ranges.

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

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=348762&r1=348761&r2=348762&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Dec 10 07:16:37 2018
@@ -8977,25 +8977,28 @@ static Comparison compareEnableIfAttrs(c
   auto Cand1Attrs = Cand1->specific_attrs();
   auto Cand2Attrs = Cand2->specific_attrs();
 
-  auto Cand1I = Cand1Attrs.begin();
   llvm::FoldingSetNodeID Cand1ID, Cand2ID;
-  for (EnableIfAttr *Cand2A : Cand2Attrs) {
-Cand1ID.clear();
-Cand2ID.clear();
+  for (auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
+Optional Cand1A = std::get<0>(Pair);
+Optional Cand2A = std::get<1>(Pair);
 
 // It's impossible for Cand1 to be better than (or equal to) Cand2 if Cand1
-// has fewer enable_if attributes than Cand2.
-auto Cand1A = Cand1I++;
-if (Cand1A == Cand1Attrs.end())
+// has fewer enable_if attributes than Cand2, and vice versa.
+if (!Cand1A)
   return Comparison::Worse;
+if (!Cand2A)
+  return Comparison::Better;
+
+Cand1ID.clear();
+Cand2ID.clear();
 
-Cand1A->getCond()->Profile(Cand1ID, S.getASTContext(), true);
-Cand2A->getCond()->Profile(Cand2ID, S.getASTContext(), true);
+(*Cand1A)->getCond()->Profile(Cand1ID, S.getASTContext(), true);
+(*Cand2A)->getCond()->Profile(Cand2ID, S.getASTContext(), true);
 if (Cand1ID != Cand2ID)
   return Comparison::Worse;
   }
 
-  return Cand1I == Cand1Attrs.end() ? Comparison::Equal : Comparison::Better;
+  return Comparison::Equal;
 }
 
 static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=348762&r1=348761&r2=348762&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Dec 10 07:16:37 2018
@@ -2913,25 +2913,30 @@ static bool hasSameOverloadableAttrs(con
   // Note that pass_object_size attributes are represented in the function's
   // ExtParameterInfo, so we don't need to check them here.
 
-  // Return false if any of the enable_if expressions of A and B are different.
   llvm::FoldingSetNodeID Cand1ID, Cand2ID;
   auto AEnableIfAttrs = A->specific_attrs();
   auto BEnableIfAttrs = B->specific_attrs();
-  auto AEnableIf = AEnableIfAttrs.begin();
-  auto BEnableIf = BEnableIfAttrs.begin();
-  for (; AEnableIf != AEnableIfAttrs.end() && BEnableIf != 
BEnableIfAttrs.end();
-   ++BEnableIf, ++AEnableIf) {
+
+  for (auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
+Optional Cand1A = std::get<0>(Pair);
+Optional Cand2A = std::get<1>(Pair);
+
+// Return false if the number of enable_if attributes is different.
+if (!Cand1A || !Cand2A)
+  return false;
+
 Cand1ID.clear();
 Cand2ID.clear();
 
-AEnableIf->getCond()->Profile(Cand1ID, A->getASTContext(), true);
-BEnableIf->getCond()->Profile(Cand2ID, B->getASTContext(), true);
+(*Cand1A)->getCond()->Profile(Cand1ID, A->getASTContext(), true);
+(*Cand2A)->getCond()->Profile(Cand2ID, B->getASTContext(), true);
+
+// Return false if any of the enable_if expressions of A and B are
+// different.
 if (Cand1ID != Cand2ID)
   return false;
   }
-
-  // Return false if the number of enable_if attributes was different.
-  return AEnableIf == AEnableIfAttrs.end() && BEnableIf == 
BEnableIfAttrs.end();
+  return true;
 }
 
 /// Determine whether the two declarations refer to the same entity.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin

r354817 - [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

2019-02-25 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Feb 25 12:34:15 2019
New Revision: 354817

URL: http://llvm.org/viewvc/llvm-project?rev=354817&view=rev
Log:
[OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

This patch implements the parsing and sema support for the OpenMP
'from'-clause with potential user-defined mappers attached.
User-defined mappers are a new feature in OpenMP 5.0. A 'from'-clause
can have an explicit or implicit associated mapper, which instructs the
compiler to generate and use customized mapping functions. An example is
shown below:

struct S { int len; int *d; };
#pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
struct S ss;
#pragma omp target update from(mapper(id): ss) // use the mapper with name 
'id' to map ss from device

Contributed-by: Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=354817&r1=354816&r2=354817&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Feb 25 12:34:15 2019
@@ -5082,6 +5082,9 @@ class OMPFromClause final
 
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param MapperQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperIdInfo The identifier of associated user-defined mapper.
   /// \param Locs Locations needed to build a mappable clause. It includes 1)
   /// StartLoc: starting location of the clause (the clause keyword); 2)
   /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
@@ -5090,9 +5093,12 @@ class OMPFromClause final
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPFromClause(const OMPVarListLocTy &Locs,
+  explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc,
+ DeclarationNameInfo MapperIdInfo,
+ const OMPVarListLocTy &Locs,
  const OMPMappableExprListSizeTy &Sizes)
-  : OMPMappableExprListClause(OMPC_from, Locs, Sizes) {}
+  : OMPMappableExprListClause(OMPC_from, Locs, Sizes, &MapperQualifierLoc,
+  &MapperIdInfo) {}
 
   /// Build an empty clause.
   ///
@@ -5107,7 +5113,9 @@ class OMPFromClause final
   /// Define the sizes of each trailing object array except the last one. This
   /// is required for TrailingObjects to work properly.
   size_t numTrailingObjects(OverloadToken) const {
-return varlist_size();
+// There are varlist_size() of expressions, and varlist_size() of
+// user-defined mappers.
+return 2 * varlist_size();
   }
   size_t numTrailingObjects(OverloadToken) const {
 return getUniqueDeclarationsNum();
@@ -5126,10 +5134,18 @@ public:
   /// \param Vars The original expression used in the clause.
   /// \param Declarations Declarations used in the clause.
   /// \param ComponentLists Component lists used in the clause.
+  /// \param UDMapperRefs References to user-defined mappers associated with
+  /// expressions used in the clause.
+  /// \param UDMQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperId The identifier of associated user-defined mapper.
   static OMPFromClause *Create(const ASTContext &C, const OMPVarListLocTy 
&Locs,
ArrayRef Vars,
ArrayRef Declarations,
-   MappableExprComponentListsRef ComponentLists);
+   MappableExprComponentListsRef ComponentLists,
+   ArrayRef UDMapperRefs,
+   NestedNameSpecifierLoc UDMQualifierLoc,
+   DeclarationNameInfo MapperId);
 
   /// Creates an empty clause with the place for \a NumVars variables.
   ///

Modified: c

Re: r355182 - [clang-format] [NFC] clang-format the Format library

2019-03-08 Thread Michael Kruse via cfe-commits
Isn't this kind of commit discouraged?, as by
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

> Avoid committing formatting- or whitespace-only changes outside of code you 
> plan to make subsequent changes to.

and the discussion after which this has been added:
https://lists.llvm.org/pipermail/llvm-dev/2018-July/124941.html


Michael

Am Fr., 1. März 2019 um 03:09 Uhr schrieb Paul Hoad via cfe-commits
:
>
> Author: paulhoad
> Date: Fri Mar  1 01:09:54 2019
> New Revision: 355182
>
> URL: http://llvm.org/viewvc/llvm-project?rev=355182&view=rev
> Log:
> [clang-format] [NFC] clang-format the Format library
>
> Previously revisions commited non-clang-formatted changes to the Format 
> library, this means submitting any revision e.g. {D55170} can cause 
> additional whitespace changes to potentially be included in a revision.
>
> Commit a non functional change using latest build Windows clang-format 
> r351376 with no other changes, to remove these differences
>
> All FormatTests
> pass [==] 652 tests from 20 test cases ran.
>
> Modified:
> cfe/trunk/lib/Format/BreakableToken.cpp
> cfe/trunk/lib/Format/BreakableToken.h
> cfe/trunk/lib/Format/ContinuationIndenter.cpp
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/lib/Format/FormatToken.h
> cfe/trunk/lib/Format/FormatTokenLexer.h
> cfe/trunk/lib/Format/TokenAnnotator.cpp
> cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
> cfe/trunk/lib/Format/UnwrappedLineFormatter.h
> cfe/trunk/lib/Format/UnwrappedLineParser.cpp
> cfe/trunk/lib/Format/UnwrappedLineParser.h
> cfe/trunk/lib/Format/WhitespaceManager.cpp
>
> Modified: cfe/trunk/lib/Format/BreakableToken.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=355182&r1=355181&r2=355182&view=diff
> ==
> --- cfe/trunk/lib/Format/BreakableToken.cpp (original)
> +++ cfe/trunk/lib/Format/BreakableToken.cpp Fri Mar  1 01:09:54 2019
> @@ -62,12 +62,10 @@ static StringRef getLineCommentIndentPre
>return LongestPrefix;
>  }
>
> -static BreakableToken::Split getCommentSplit(StringRef Text,
> - unsigned ContentStartColumn,
> - unsigned ColumnLimit,
> - unsigned TabWidth,
> - encoding::Encoding Encoding,
> - const FormatStyle &Style) {
> +static BreakableToken::Split
> +getCommentSplit(StringRef Text, unsigned ContentStartColumn,
> +unsigned ColumnLimit, unsigned TabWidth,
> +encoding::Encoding Encoding, const FormatStyle &Style) {
>LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text
><< "\", Column limit: " << ColumnLimit
><< ", Content start: " << ContentStartColumn << 
> "\n");
> @@ -191,7 +189,7 @@ bool switchesFormatting(const FormatToke
>
>  unsigned
>  BreakableToken::getLengthAfterCompression(unsigned RemainingTokenColumns,
> -  Split Split) const {
> +  Split Split) const {
>// Example: consider the content
>// lala  lala
>// - RemainingTokenColumns is the original number of columns, 10;
> @@ -870,23 +868,20 @@ void BreakableLineCommentSection::reflow
>  // the next line.
>  unsigned WhitespaceLength =
>  Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data() - 
> Offset;
> -Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex],
> - Offset,
> +Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset,
>   /*ReplaceChars=*/WhitespaceLength,
>   /*PreviousPostfix=*/"",
>   /*CurrentPrefix=*/"",
>   /*InPPDirective=*/false,
>   /*Newlines=*/0,
>   /*Spaces=*/0);
> -
>}
>// Replace the indent and prefix of the token with the reflow prefix.
>unsigned Offset =
>Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data();
>unsigned WhitespaceLength =
>Content[LineIndex].data() - Lines[LineIndex].data();
> -  Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex],
> -   Offset,
> +  Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset,
> /*ReplaceChars=*/WhitespaceLength,
> /*PreviousPostfix=*/"",
> /*CurrentPrefix=*/ReflowPrefix,
>
> Modified: cfe/trunk/lib/Format/BreakableToken.h
> URL: 
> http://llvm.org/viewvc/llvm-pro

Re: r355182 - [clang-format] [NFC] clang-format the Format library

2019-03-11 Thread Michael Kruse via cfe-commits
Am Sa., 9. März 2019 um 13:54 Uhr schrieb MyDeveloper Day
:
>
> Yes ideally I'd agree, It also says:
>
> > Avoid committing formatting- or whitespace-only changes outside of code you 
> > plan to make subsequent changes to.
>
> This was getting to be a problem, every time we edited the file (with 
> auto-clang-format) a large number of other changes would also get made, 
> presumably because others hadn't been clang-formatting their commits 
> correctly! we'd have to merge out a lot of changes everytime.

This is the same motivation behind r338291 which motivated adding this
developer policy (see
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180730/236802.html).

I use "git clang-format origin/master" to only reformat lines that I touched.


> >Also, try to separate formatting or whitespace changes from functional 
> >changes, either by correcting the format first (ideally) or afterward
>
> which means you want those changes to be separate commits.. so ideally its 
> better we clang-format the file when there is no other related changes so 
> future revisions don't need to have a mixture of real changes and whitespace 
> changes.

The policy wants only those parts you are going to change to be
re-formatted, up to complete files (I've seen those sometimes), not
entire components.


> I also think given we also encourage people to clang-format out code,  its 
> ironic clang-format itself is not clang-formatted!

This should be pointed-out in reviews. Unfortunately, things will
always slip through. Also, clang-format changes over time, i.e. we
would have to reformat regularly anyway.


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


r357415 - [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-04-01 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Apr  1 10:47:41 2019
New Revision: 357415

URL: http://llvm.org/viewvc/llvm-project?rev=357415&view=rev
Log:
[CodeGen] Generate follow-up metadata for loops with more than one 
transformation.

Before this patch, CGLoop would dump all transformations for a loop into
a single LoopID without encoding any order in which to apply them.
rL348944 added the possibility to encode a transformation order using
followup-attributes.

When a loop has more than one transformation, use the follow-up
attribute define the order in which they are applied. The emitted order
is the defacto order as defined by the current LLVM pass pipeline,
which is:

  LoopFullUnrollPass
  LoopDistributePass
  LoopVectorizePass
  LoopUnrollAndJamPass
  LoopUnrollPass
  MachinePipeliner

This patch should therefore not change the assembly output, assuming
that all explicit transformations can be applied, and no implicit
transformations in-between. In the former case,
WarnMissedTransformationsPass should emit a warning (except for
MachinePipeliner which is not implemented yet). The latter could be
avoided by adding 'llvm.loop.disable_nonforced' attributes.

Because LoopUnrollAndJamPass processes a loop nest, generation of the
MDNode is delayed to after the inner loop metadata have been processed.
A temporary LoopID is therefore used to annotate instructions and
RAUW'ed by the actual LoopID later.

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

Added:
cfe/trunk/test/CodeGenCXX/pragma-followup_inner.cpp
cfe/trunk/test/CodeGenCXX/pragma-followup_outer.cpp
Modified:
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGLoopInfo.h
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop.cpp
cfe/trunk/test/CodeGenCXX/pragma-unroll-and-jam.cpp
cfe/trunk/test/OpenMP/simd_metadata.c

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=357415&r1=357414&r2=357415&view=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Mon Apr  1 10:47:41 2019
@@ -18,138 +18,396 @@
 using namespace clang::CodeGen;
 using namespace llvm;
 
-static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs,
-  const llvm::DebugLoc &StartLoc,
-  const llvm::DebugLoc &EndLoc, MDNode *&AccGroup) 
{
+MDNode *
+LoopInfo::createLoopPropertiesMetadata(ArrayRef LoopProperties) {
+  LLVMContext &Ctx = Header->getContext();
+  SmallVector NewLoopProperties;
+  TempMDTuple TempNode = MDNode::getTemporary(Ctx, None);
+  NewLoopProperties.push_back(TempNode.get());
+  NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end());
 
-  if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 &&
-  Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 &&
-  Attrs.UnrollAndJamCount == 0 && !Attrs.PipelineDisabled &&
-  Attrs.PipelineInitiationInterval == 0 &&
-  Attrs.VectorizeEnable == LoopAttributes::Unspecified &&
-  Attrs.UnrollEnable == LoopAttributes::Unspecified &&
-  Attrs.UnrollAndJamEnable == LoopAttributes::Unspecified &&
-  Attrs.DistributeEnable == LoopAttributes::Unspecified && !StartLoc &&
-  !EndLoc)
-return nullptr;
+  MDNode *LoopID = MDNode::getDistinct(Ctx, NewLoopProperties);
+  LoopID->replaceOperandWith(0, LoopID);
+  return LoopID;
+}
+
+MDNode *LoopInfo::createPipeliningMetadata(const LoopAttributes &Attrs,
+   ArrayRef LoopProperties,
+   bool &HasUserTransforms) {
+  LLVMContext &Ctx = Header->getContext();
+
+  Optional Enabled;
+  if (Attrs.PipelineDisabled)
+Enabled = false;
+  else if (Attrs.PipelineInitiationInterval != 0)
+Enabled = true;
+
+  if (Enabled != true) {
+SmallVector NewLoopProperties;
+if (Enabled == false) {
+  NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end());
+  NewLoopProperties.push_back(
+  MDNode::get(Ctx, {MDString::get(Ctx, "llvm.loop.pipeline.disable"),
+ConstantAsMetadata::get(ConstantInt::get(
+llvm::Type::getInt1Ty(Ctx), 1))}));
+  LoopProperties = NewLoopProperties;
+}
+return createLoopPropertiesMetadata(LoopProperties);
+  }
 
   SmallVector Args;
-  // Reserve operand 0 for loop id self reference.
-  auto TempNode = MDNode::getTemporary(Ctx, None);
+  TempMDTuple TempNode = MDNode::getTemporary(Ctx, None);
   Args.push_back(TempNode.get());
+  Args.append(LoopProperties.begin(), LoopProperties.end());
 
-  // If we have a valid star

r358507 - [Test] Remove obsolete test.

2019-04-16 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Tue Apr 16 09:44:45 2019
New Revision: 358507

URL: http://llvm.org/viewvc/llvm-project?rev=358507&view=rev
Log:
[Test] Remove obsolete test.

The FIXME of this test case has been addressed in r335084/r338800. Its
execution still does not succeed because of multiple syntax errors.

First, the "clang" namespace is missing on each of the 4 pragmas.
Second, the pragma for defining the vector width is "vectorize_width(4)"
instead of "vectorize(4)". Third, the pragma for defining the interleave
factor is "interleave_count(8)" instead of "interleave(8)".

The file was already using the wrong syntax when added in
r210925 2014-06-13. The file ast-print-pragmas.cpp already checks for
the correct pragma order, making this test redundant even if fixed.

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

Removed:
cfe/trunk/test/AST/ast-print-pragmas-xfail.cpp

Removed: cfe/trunk/test/AST/ast-print-pragmas-xfail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-print-pragmas-xfail.cpp?rev=358506&view=auto
==
--- cfe/trunk/test/AST/ast-print-pragmas-xfail.cpp (original)
+++ cfe/trunk/test/AST/ast-print-pragmas-xfail.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print -o - | FileCheck %s
-
-// FIXME: Test fails because attribute order is reversed by ParsedAttributes.
-// XFAIL: *
-
-void run1(int *List, int Length) {
-  int i = 0;
-// CHECK: #pragma loop vectorize(4)
-// CHECK-NEXT: #pragma loop interleave(8)
-// CHECK-NEXT: #pragma loop vectorize(enable)
-// CHECK-NEXT: #pragma loop interleave(enable)
-#pragma loop vectorize(4)
-#pragma loop interleave(8)
-#pragma loop vectorize(enable)
-#pragma loop interleave(enable)
-// CHECK-NEXT: while (i < Length)
-  while (i < Length) {
-List[i] = i;
-i++;
-  }
-}


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


Re: [PATCH] D42642: [CUDA] Detect installation in PATH

2019-05-01 Thread Michael Kruse via cfe-commits
Hi,

I had my own difficulties with this. It depends on how the repository
containing the symlink has been checked-out. For instance:

1. Using a windows git (such as git extensions, mingw-git, git for windows)
2. Using git inside wsl on a drvfs mount (i.e. a windows folder
mounted into the Unix filesystem)
3. Using git inside wsl on a lxfs mount (I.e. native mount such as '/')

In case 1. git does not create a Ubuntu symlink. Also, there are no
Unix symlinks in Windows filesystems, so when Unix tools (such as git)
request to create a symlink, it creates something else (AFAIR it's a
text file containing the symlink path, but having lost its symlink
properties). Case 3 should work.

I still managed to make cases 1 and 2 work by deleting the text file
and re-creating it with windows's "mklink" tool (which requires either
admin rights or developer mode turned on). It seems the WSL layer
translates this as a symlink to the Linux environment.

Michael





Am Mi., 1. Mai 2019 um 16:59 Uhr schrieb Alexandre Ganea via
Phabricator via llvm-commits :
>
> aganea added a subscriber: rnk.
> aganea added a comment.
>
> So it turns out this is a symlink issue. The file 
> `clang/trunk/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas` has been 
> synchronized on my Windows 10 PC as a regular text file, not a symlink. It 
> looks like TortoiseSVN doesn't implement symlinks. As WSL inherits of my file 
> system, it will not find the symbolic link. I suppose `REQUIRES: 
> !system-windows` isn't enough for `cuda-detect-path.cu`, and it would need 
> something like `REQUIRES: symlinks` along with support in lit. @rnk
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D42642/new/
>
> https://reviews.llvm.org/D42642
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D42642: [CUDA] Detect installation in PATH

2019-05-02 Thread Michael Kruse via cfe-commits
An update:

I just re-tried creating a symbolic link from inside wsl on drvfs
(case 2). It now created a symlink just as "mklink" does. What might
have changed is that I updated to a newer insider preview or that I
enabled developer mode when I tried the first time.

[1] seems to apply for case 1. [2] has a nice overview about what can
happen here.

Michael

[1] https://github.com/libgit2/libgit2/pull/4713
[2] 
https://stackoverflow.com/questions/11662868/what-happens-when-i-clone-a-repository-with-symlinks-on-windows

Am Do., 2. Mai 2019 um 10:17 Uhr schrieb Alexandre Ganea
:
>
> Thanks Michael, it makes sense. I'm still with the old SVN setup on Windows. 
> WSL uses the NTFS partition through drvfs (your case 2.)
> I'll switch to the git monorepo, it looks like the latest git supports [1] 
> symlinks on Windows (with the restrictions you've mentioned) and they should 
> be mapped properly inside WSL in that case.
>
> Should we then assume symlinks will always work for end-users? Should we 
> validate that somehow, during cmake setup?
>
> Alex.
>
> [1] https://github.com/libgit2/libgit2/pull/4713
>
> -Message d'origine-
> De : Michael Kruse 
> Envoyé : 1 mai 2019 17:23
> À : reviews+d42642+public+5dc9c99d2f2d3...@reviews.llvm.org; Alexandre Ganea 
> via Phabricator 
> Cc : hah...@hahnjo.de; jle...@google.com; t...@google.com; Alexandre Ganea 
> ; cfe-commits ; 
> llvm-commits ; sylvestre.le...@gmail.com
> Objet : Re: [PATCH] D42642: [CUDA] Detect installation in PATH
>
> Hi,
>
> I had my own difficulties with this. It depends on how the repository
> containing the symlink has been checked-out. For instance:
>
> 1. Using a windows git (such as git extensions, mingw-git, git for windows)
> 2. Using git inside wsl on a drvfs mount (i.e. a windows folder
> mounted into the Unix filesystem)
> 3. Using git inside wsl on a lxfs mount (I.e. native mount such as '/')
>
> In case 1. git does not create a Ubuntu symlink. Also, there are no
> Unix symlinks in Windows filesystems, so when Unix tools (such as git)
> request to create a symlink, it creates something else (AFAIR it's a
> text file containing the symlink path, but having lost its symlink
> properties). Case 3 should work.
>
> I still managed to make cases 1 and 2 work by deleting the text file
> and re-creating it with windows's "mklink" tool (which requires either
> admin rights or developer mode turned on). It seems the WSL layer
> translates this as a symlink to the Linux environment.
>
> Michael
>
>
>
>
>
> Am Mi., 1. Mai 2019 um 16:59 Uhr schrieb Alexandre Ganea via
> Phabricator via llvm-commits :
> >
> > aganea added a subscriber: rnk.
> > aganea added a comment.
> >
> > So it turns out this is a symlink issue. The file 
> > `clang/trunk/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas` has been 
> > synchronized on my Windows 10 PC as a regular text file, not a symlink. It 
> > looks like TortoiseSVN doesn't implement symlinks. As WSL inherits of my 
> > file system, it will not find the symbolic link. I suppose `REQUIRES: 
> > !system-windows` isn't enough for `cuda-detect-path.cu`, and it would need 
> > something like `REQUIRES: symlinks` along with support in lit. @rnk
> >
> >
> > Repository:
> >   rL LLVM
> >
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D42642/new/
> >
> > https://reviews.llvm.org/D42642
> >
> >
> >
> > ___
> > llvm-commits mailing list
> > llvm-comm...@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342861 - Add inherited attributes before parsed attributes.

2018-09-23 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Sun Sep 23 23:31:37 2018
New Revision: 342861

URL: http://llvm.org/viewvc/llvm-project?rev=342861&view=rev
Log:
Add inherited attributes before parsed attributes.

Currently, attributes from previous declarations ('inherited attributes')
are added to the end of a declaration's list of attributes. Before
r338800, the attribute list was in reverse. r338800 changed the order
of non-inherited (parsed from the current declaration) attributes, but
inherited attributes are still appended to the end of the list.

This patch appends inherited attributes after other inherited
attributes, but before any non-inherited attribute. This is to make the
order of attributes in the AST correspond to the order in the source
code.

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

Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-availability-ios.c
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability-watchos.c

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=342861&r1=342860&r2=342861&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sun Sep 23 23:31:37 2018
@@ -482,13 +482,7 @@ public:
 
   const AttrVec &getAttrs() const;
   void dropAttrs();
-
-  void addAttr(Attr *A) {
-if (hasAttrs())
-  getAttrs().push_back(A);
-else
-  setAttrs(AttrVec(1, A));
-  }
+  void addAttr(Attr *A);
 
   using attr_iterator = AttrVec::const_iterator;
   using attr_range = llvm::iterator_range;

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=342861&r1=342860&r2=342861&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Sep 23 23:31:37 2018
@@ -836,6 +836,29 @@ void Decl::dropAttrs() {
   getASTContext().eraseDeclAttrs(this);
 }
 
+void Decl::addAttr(Attr *A) {
+  if (!hasAttrs()) {
+setAttrs(AttrVec(1, A));
+return;
+  }
+
+  AttrVec &Attrs = getAttrs();
+  if (!A->isInherited()) {
+Attrs.push_back(A);
+return;
+  }
+
+  // Attribute inheritance is processed after attribute parsing. To keep the
+  // order as in the source code, add inherited attributes before non-inherited
+  // ones.
+  auto I = Attrs.begin(), E = Attrs.end();
+  for (; I != E; ++I) {
+if (!(*I)->isInherited())
+  break;
+  }
+  Attrs.insert(I, A);
+}
+
 const AttrVec &Decl::getAttrs() const {
   assert(HasAttrs && "No attrs to get!");
   return getASTContext().getDeclAttrs(this);

Modified: cfe/trunk/test/Misc/ast-dump-attr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-attr.cpp?rev=342861&r1=342860&r2=342861&view=diff
==
--- cfe/trunk/test/Misc/ast-dump-attr.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-attr.cpp Sun Sep 23 23:31:37 2018
@@ -209,3 +209,24 @@ namespace TestSuppress {
   }
 }
 }
+
+// Verify the order of attributes in the Ast. It must reflect the order
+// in the parsed source.
+int mergeAttrTest() __attribute__((deprecated)) 
__attribute__((warn_unused_result));
+int mergeAttrTest() __attribute__((annotate("test")));
+int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis));
+// CHECK: FunctionDecl{{.*}} mergeAttrTest
+// CHECK-NEXT: DeprecatedAttr
+// CHECK-NEXT: WarnUnusedResultAttr
+
+// CHECK: FunctionDecl{{.*}} mergeAttrTest
+// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
+// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
+// CHECK-NEXT: AnnotateAttr{{.*}}
+
+// CHECK: FunctionDecl{{.*}} mergeAttrTest
+// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
+// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
+// CHECK-NEXT: AnnotateAttr{{.*}} Inherited
+// CHECK-NEXT: UnusedAttr
+// CHECK-NEXT: NoThreadSafetyAnalysisAttr

Modified: cfe/trunk/test/Sema/attr-availability-ios.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-ios.c?rev=342861&r1=342860&r2=342861&view=diff
==
--- cfe/trunk/test/Sema/attr-availability-ios.c (original)
+++ cfe/trunk/test/Sema/attr-availability-ios.c Sun Sep 23 23:31:37 2018
@@ -7,8 +7,8 @@ void f3(int) __attribute__((availability
 void f4(int) 
__attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5),
 availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // 
expected-note{{explicitly marked unavailable}}
 
 void f5(int) __attribute__((availability(ios,introduced=2.0))) 
__attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has 

r352906 - [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

2019-02-01 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Fri Feb  1 12:25:04 2019
New Revision: 352906

URL: http://llvm.org/viewvc/llvm-project?rev=352906&view=rev
Log:
[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:

struct S {  int len;  int *d; };
#pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory 
region that d points to is also mapped using this mapper.

Contributed-by: Lingda Li 

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

Added:
cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclOpenMP.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=352906&r1=352905&r2=352906&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Feb  1 12:25:04 2019
@@ -175,7 +175,10 @@ public:
 IDNS_LocalExtern = 0x0800,
 
 /// This declaration is an OpenMP user defined reduction construction.
-IDNS_OMPReduction= 0x1000
+IDNS_OMPReduction= 0x1000,
+
+/// This declaration is an OpenMP user defined mapper.
+IDNS_OMPMapper   = 0x2000,
   };
 
   /// ObjCDeclQualifier - 'Qualifiers' written next to the return and
@@ -323,7 +326,7 @@ protected:
   unsigned FromASTFile : 1;
 
   /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
-  unsigned IdentifierNamespace : 13;
+  unsigned IdentifierNamespace : 14;
 
   /// If 0, we have not computed the linkage of this declaration.
   /// Otherwise, it is the linkage + 1.
@@ -1251,6 +1254,7 @@ public:
 ///   NamespaceDecl
 ///   TagDecl
 ///   OMPDeclareReductionDecl
+///   OMPDeclareMapperDecl
 ///   FunctionDecl
 ///   ObjCMethodDecl
 ///   ObjCContainerDecl

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=352906&r1=352905&r2=352906&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Feb  1 12:25:04 2019
@@ -1828,6 +1828,14 @@ public:
  CXXBasePath &Path, DeclarationName Name);
 
   /// Base-class lookup callback that determines whether there exists
+  /// an OpenMP declare mapper member with the given name.
+  ///
+  /// This callback can be used with \c lookupInBases() to find members
+  /// of the given name within a C++ class hierarchy.
+  static bool FindOMPMapperMember(const CXXBaseSpecifier *Specifier,
+  CXXBasePath &Path, DeclarationName Name);
+
+  /// Base-class lookup callback that determines whether there exists
   /// a member with the given name that can be used in a nested-name-specifier.
   ///
   /// This callback can be used with \c lookupInBases() to fi

Re: r352906 - [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

2019-02-01 Thread Michael Kruse via cfe-commits
Hi,

I never used modules. Can you give me hint where it exactly breaks? Is
it line 294 and 298 where it calls getExternalSource of ASTContext?

Michael



Am Fr., 1. Feb. 2019 um 12:58 Uhr schrieb Eric Fiselier :
>
> This breaks my build (I have modules enabled).
>
> DeclOpenMP.h uses ASTContext while it's still incomplete.
> Could you please fix this?
>
> /Eric
>
> On Fri, Feb 1, 2019 at 3:24 PM Michael Kruse via cfe-commits 
>  wrote:
>>
>> Author: meinersbur
>> Date: Fri Feb  1 12:25:04 2019
>> New Revision: 352906
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=352906&view=rev
>> Log:
>> [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.
>>
>> This patch implements parsing and sema for "omp declare mapper"
>> directive. User defined mapper, i.e., declare mapper directive, is a new
>> feature in OpenMP 5.0. It is introduced to extend existing map clauses
>> for the purpose of simplifying the copy of complex data structures
>> between host and device (i.e., deep copy). An example is shown below:
>>
>> struct S {  int len;  int *d; };
>> #pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory 
>> region that d points to is also mapped using this mapper.
>>
>> Contributed-by: Lingda Li 
>>
>> Differential Revision: https://reviews.llvm.org/D56326
>>
>> Added:
>> cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
>> cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
>> cfe/trunk/test/OpenMP/declare_mapper_messages.c
>> cfe/trunk/test/OpenMP/declare_mapper_messages.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/AST/DeclOpenMP.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/Basic/DeclNodes.td
>> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Basic/OpenMPKinds.def
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/AST/ASTDumper.cpp
>> cfe/trunk/lib/AST/CXXInheritance.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclOpenMP.cpp
>> cfe/trunk/lib/AST/DeclPrinter.cpp
>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>> cfe/trunk/lib/Basic/OpenMPKinds.cpp
>> cfe/trunk/lib/CodeGen/CGDecl.cpp
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
>> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> cfe/trunk/lib/CodeGen/CodeGenModule.h
>> cfe/trunk/lib/Parse/ParseOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/lib/Serialization/ASTCommon.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> cfe/trunk/tools/libclang/CIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=352906&r1=352905&r2=352906&view=diff
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Fri Feb  1 12:25:04 2019
>> @@ -175,7 +175,10 @@ public:
>>  IDNS_LocalExtern = 0x0800,
>>
>>  /// This declaration is an OpenMP user defined reduction construction.
>> -IDNS_OMPReduction= 0x1000
>> +IDNS_OMPReduction= 0x1000,
>> +
>> +/// This declaration is an OpenMP user defined mapper.
>> +IDNS_OMPMapper   = 0x2000,
>>};
>>
>>/// ObjCDeclQualifier - 'Qualifiers' written next to the return and
>> @@ -323,7 +326,7 @@ protected:
>>unsigned FromASTFile : 1;
>>
>>/// IdentifierNamespace - This specifies what IDNS_* namespace this lives 
>> in.
>> -  unsigned IdentifierNamespace : 13;
>> +  unsigned IdentifierNamespace : 14;
>>
>>/// If 0, we have not computed the linkage of this declaration.
>>  

r354698 - [OpenMP 5.0] Parsing/sema support for to clause with mapper modifier.

2019-02-22 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Fri Feb 22 14:29:42 2019
New Revision: 354698

URL: http://llvm.org/viewvc/llvm-project?rev=354698&view=rev
Log:
[OpenMP 5.0] Parsing/sema support for to clause with mapper modifier.

This patch implements the parsing and sema support for OpenMP to clause
with potential user-defined mappers attached. User defined mapper is a
new feature in OpenMP 5.0. A to/from clause can have an explicit or
implicit associated mapper, which instructs the compiler to generate and
use customized mapping functions. An example is shown below:

struct S { int len; int *d; };
#pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
struct S ss;
#pragma omp target update to(mapper(id): ss) // use the mapper with name 
'id' to map ss to device

Contributed-by: 

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=354698&r1=354697&r2=354698&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Feb 22 14:29:42 2019
@@ -158,8 +158,11 @@ public:
 
 /// This structure contains most locations needed for by an OMPVarListClause.
 struct OMPVarListLocTy {
+  /// Starting location of the clause (the clause keyword).
   SourceLocation StartLoc;
+  /// Location of '('.
   SourceLocation LParenLoc;
+  /// Ending location of the clause.
   SourceLocation EndLoc;
   OMPVarListLocTy() = default;
   OMPVarListLocTy(SourceLocation StartLoc, SourceLocation LParenLoc,
@@ -3609,9 +3612,13 @@ protected:
 /// This structure contains all sizes needed for by an
 /// OMPMappableExprListClause.
 struct OMPMappableExprListSizeTy {
+  /// Number of expressions listed.
   unsigned NumVars;
+  /// Number of unique base declarations.
   unsigned NumUniqueDeclarations;
+  /// Number of component lists.
   unsigned NumComponentLists;
+  /// Total number of expression components.
   unsigned NumComponents;
   OMPMappableExprListSizeTy() = default;
   OMPMappableExprListSizeTy(unsigned NumVars, unsigned NumUniqueDeclarations,
@@ -4969,6 +4976,10 @@ class OMPToClause final : public OMPMapp
 
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param MapperQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperIdInfo The identifier of associated user-defined mapper.
+  /// \param MapType Map type.
   /// \param Locs Locations needed to build a mappable clause. It includes 1)
   /// StartLoc: starting location of the clause (the clause keyword); 2)
   /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
@@ -4977,9 +4988,12 @@ class OMPToClause final : public OMPMapp
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(const OMPVarListLocTy &Locs,
+  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
+   DeclarationNameInfo MapperIdInfo,
+   const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
-  : OMPMappableExprListClause(OMPC_to, Locs, Sizes) {}
+  : OMPMappableExprListClause(OMPC_to, Locs, Sizes, &MapperQualifierLoc,
+  &MapperIdInfo) {}
 
   /// Build an empty clause.
   ///
@@ -4994,7 +5008,9 @@ class OMPToClause final : public OMPMapp
   /// Define the sizes of each trailing object array except the last one. This
   /// is required for TrailingObjects to work properly.
   size_t numTrailingObjects(OverloadToken) const {
-return varlist_size();
+// There are varlist_size() of expressions, and varlist_size() of
+// user-defined mappers.
+return 2 * varlist_size();
   }
   size_t numTrailingObjects(OverloadToken) const {
 return getUniqueDeclarationsNum();
@

r367773 - [OpenMP 5.0] Codegen support for user-defined mappers.

2019-08-03 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Sat Aug  3 21:18:42 2019
New Revision: 367773

URL: http://llvm.org/viewvc/llvm-project?rev=367773&view=rev
Log:
[OpenMP 5.0] Codegen support for user-defined mappers.

This patch implements the code generation for OpenMP 5.0 declare mapper
(user-defined mapper) constructs. For each declare mapper, a mapper
function is generated. These mapper functions will be called by the
runtime and/or other mapper functions to achieve user defined mapping.

The design slides can be found at
https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx

Patch by Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Sat Aug  3 21:18:42 2019
@@ -59,6 +59,7 @@ public:
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
+  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug  3 21:18:42 2019
@@ -9860,7 +9860,7 @@ bool ASTContext::DeclMustBeEmitted(const
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
-  else if (isa(D))
+  else if (isa(D) || isa(D))
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return true;

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Aug  3 21:18:42 2019
@@ -2530,10 +2530,11 @@ void CodeGenModule::EmitOMPDeclareReduct
 }
 
 void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
-CodeGenFunction *CGF) {
-  if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))
 return;
-  // FIXME: need to implement mapper code generation
+  getOpenMPRuntime().emitUserDefinedMapper(D, CGF);
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sat Aug  3 21:18:42 2019
@@ -752,6 +752,11 @@ enum OpenMPRTLFunction {
   // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t
   // *arg_types);
   OMPRTL__tgt_target_data_update_nowait,
+  // Call to int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
+  OMPRTL__tgt_mapper_num_components,
+  // Call to void __tgt_push_mapper_component(void *rt_mapper_handle, void
+  // *base, void *begin, int64_t size, int64_t type);
+  OMPRTL__tgt_push_mapper_component,
 };
 
 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
@@ -1686,6 +1691,12 @@ void CGOpenMPRuntime::functionFinished(C
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
+  auto I = FunctionUDMMap.find(CGF.CurFn);
+  if (I != FunctionUDMMap.end()) {
+for(auto *D : I->second)
+  UDMMap.erase(D);
+FunctionUDMMap.erase(I);
+  }
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -2459,6 +2470,24 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_target_data_update_nowait");
 break;
   }
+  case OMPRTL__tgt_mapper_num_comp

r367774 - Revert "[OpenMP 5.0] Codegen support for user-defined mappers."

2019-08-03 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Sat Aug  3 22:16:52 2019
New Revision: 367774

URL: http://llvm.org/viewvc/llvm-project?rev=367774&view=rev
Log:
Revert "[OpenMP 5.0] Codegen support for user-defined mappers."

This reverts commit r367773. The test case
OpenMP/declare_mapper_codegen.cpp is failing.

Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Sat Aug  3 22:16:52 2019
@@ -59,7 +59,6 @@ public:
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
-  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug  3 22:16:52 2019
@@ -9860,7 +9860,7 @@ bool ASTContext::DeclMustBeEmitted(const
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
-  else if (isa(D) || isa(D))
+  else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return true;

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Aug  3 22:16:52 2019
@@ -2530,11 +2530,10 @@ void CodeGenModule::EmitOMPDeclareReduct
 }
 
 void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
- CodeGenFunction *CGF) {
-  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
-  (!LangOpts.EmitAllDecls && !D->isUsed()))
+CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
 return;
-  getOpenMPRuntime().emitUserDefinedMapper(D, CGF);
+  // FIXME: need to implement mapper code generation
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sat Aug  3 22:16:52 2019
@@ -752,11 +752,6 @@ enum OpenMPRTLFunction {
   // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t
   // *arg_types);
   OMPRTL__tgt_target_data_update_nowait,
-  // Call to int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
-  OMPRTL__tgt_mapper_num_components,
-  // Call to void __tgt_push_mapper_component(void *rt_mapper_handle, void
-  // *base, void *begin, int64_t size, int64_t type);
-  OMPRTL__tgt_push_mapper_component,
 };
 
 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
@@ -1691,12 +1686,6 @@ void CGOpenMPRuntime::functionFinished(C
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
-  auto I = FunctionUDMMap.find(CGF.CurFn);
-  if (I != FunctionUDMMap.end()) {
-for(auto *D : I->second)
-  UDMMap.erase(D);
-FunctionUDMMap.erase(I);
-  }
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -2470,24 +2459,6 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_target_data_update_nowait");
 break;
   }
-  case OMPRTL__tgt_mapper_num_components: {
-// Build int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
-llvm::Type *TypeParams[] = {CGM.VoidPtrTy};
-auto *FnTy =
-llvm::FunctionType::get(CGM.Int64Ty, TypeParams, /*isVarArg*/ false);
-RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_mapper_num_components");
-break;
-  }
-  case OMPRTL__tgt_push_mapper_component: {
-/

r367905 - [OpenMP 5.0] Codegen support for user-defined mappers.

2019-08-05 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Aug  5 11:43:21 2019
New Revision: 367905

URL: http://llvm.org/viewvc/llvm-project?rev=367905&view=rev
Log:
[OpenMP 5.0] Codegen support for user-defined mappers.

This patch implements the code generation for OpenMP 5.0 declare mapper
(user-defined mapper) constructs. For each declare mapper, a mapper
function is generated. These mapper functions will be called by the
runtime and/or other mapper functions to achieve user defined mapping.

The design slides can be found at
https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx

Re-commit after revert in r367773 because r367755 changed the LLVM-IR
output such that a CHECK line failed.

Patch by Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=367905&r1=367904&r2=367905&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Mon Aug  5 11:43:21 2019
@@ -59,6 +59,7 @@ public:
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
+  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=367905&r1=367904&r2=367905&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Aug  5 11:43:21 2019
@@ -9860,7 +9860,7 @@ bool ASTContext::DeclMustBeEmitted(const
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
-  else if (isa(D))
+  else if (isa(D) || isa(D))
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return true;

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367905&r1=367904&r2=367905&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Aug  5 11:43:21 2019
@@ -2530,10 +2530,11 @@ void CodeGenModule::EmitOMPDeclareReduct
 }
 
 void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
-CodeGenFunction *CGF) {
-  if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))
 return;
-  // FIXME: need to implement mapper code generation
+  getOpenMPRuntime().emitUserDefinedMapper(D, CGF);
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=367905&r1=367904&r2=367905&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Aug  5 11:43:21 2019
@@ -752,6 +752,11 @@ enum OpenMPRTLFunction {
   // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t
   // *arg_types);
   OMPRTL__tgt_target_data_update_nowait,
+  // Call to int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
+  OMPRTL__tgt_mapper_num_components,
+  // Call to void __tgt_push_mapper_component(void *rt_mapper_handle, void
+  // *base, void *begin, int64_t size, int64_t type);
+  OMPRTL__tgt_push_mapper_component,
 };
 
 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
@@ -1686,6 +1691,12 @@ void CGOpenMPRuntime::functionFinished(C
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
+  auto I = FunctionUDMMap.find(CGF.CurFn);
+  if (I != FunctionUDMMap.end()) {
+for(auto *D : I->second)
+  UDMMap.erase(D);
+FunctionUDMMap.erase(I);
+  }
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -2459,6 +2470,24 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 RTLFn = CGM.CreateR

r348944 - [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

2018-12-12 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Wed Dec 12 09:32:52 2018
New Revision: 348944

URL: http://llvm.org/viewvc/llvm-project?rev=348944&view=rev
Log:
[Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

When multiple loop transformation are defined in a loop's metadata, their order 
of execution is defined by the order of their respective passes in the pass 
pipeline. For instance, e.g.

#pragma clang loop unroll_and_jam(enable)
#pragma clang loop distribute(enable)

is the same as

#pragma clang loop distribute(enable)
#pragma clang loop unroll_and_jam(enable)

and will try to loop-distribute before Unroll-And-Jam because the 
LoopDistribute pass is scheduled after UnrollAndJam pass. UnrollAndJamPass only 
supports one inner loop, i.e. it will necessarily fail after loop distribution. 
It is not possible to specify another execution order. Also,t the order of 
passes in the pipeline is subject to change between versions of LLVM, 
optimization options and which pass manager is used.

This patch adds 'followup' attributes to various loop transformation passes. 
These attributes define which attributes the resulting loop of a transformation 
should have. For instance,

!0 = !{!0, !1, !2}
!1 = !{!"llvm.loop.unroll_and_jam.enable"}
!2 = !{!"llvm.loop.unroll_and_jam.followup_inner", !3}
!3 = !{!"llvm.loop.distribute.enable"}

defines a loop ID (!0) to be unrolled-and-jammed (!1) and then the attribute !3 
to be added to the jammed inner loop, which contains the instruction to 
distribute the inner loop.

Currently, in both pass managers, pass execution is in a fixed order and 
UnrollAndJamPass will not execute again after LoopDistribute. We hope to fix 
this in the future by allowing pass managers to run passes until a fixpoint is 
reached, use Polly to perform these transformations, or add a loop 
transformation pass which takes the order issue into account.

For mandatory/forced transformations (e.g. by having been declared by #pragma 
omp simd), the user must be notified when a transformation could not be 
performed. It is not possible that the responsible pass emits such a warning 
because the transformation might be 'hidden' in a followup attribute when it is 
executed, or it is not present in the pipeline at all. For this reason, this 
patche introduces a WarnMissedTransformations pass, to warn about orphaned 
transformations.

Since this changes the user-visible diagnostic message when a transformation is 
applied, two test cases in the clang repository need to be updated.

To ensure that no other transformation is executed before the intended one, the 
attribute `llvm.loop.disable_nonforced` can be added which should disable 
transformation heuristics before the intended transformation is applied. E.g. 
it would be surprising if a loop is distributed before a #pragma unroll_and_jam 
is applied.

With more supported code transformations (loop fusion, interchange, 
stripmining, offloading, etc.), transformations can be used as building blocks 
for more complex transformations (e.g. stripmining+stripmining+interchange -> 
tiling).

Reviewed By: hfinkel, dmgreen

Differential Revision: https://reviews.llvm.org/D49281
Differential Revision: https://reviews.llvm.org/D55288

Modified:
cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp
cfe/trunk/test/Misc/backend-optimization-failure.cpp

Modified: cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp?rev=348944&r1=348943&r2=348944&view=diff
==
--- cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp (original)
+++ cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp Wed Dec 12 
09:32:52 2018
@@ -4,7 +4,7 @@
 // Test verifies optimization failures generated by the backend are handled
 // correctly by clang. LLVM tests verify all of the failure conditions.
 
-void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: failed explicitly specified loop vectorization}} */
+void test_switch(int *A, int *B, int Length, int J) { /* expected-warning 
{{loop not vectorized: the optimizer was unable to perform the requested 
transformation; the transformation might be disabled or specified as part of an 
unsupported transformation ordering}} */
 #pragma clang loop vectorize(enable) unroll(disable)
   for (int i = 0; i < Length; i++) {
 switch (A[i]) {

Modified: cfe/trunk/test/Misc/backend-optimization-failure.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-optimization-failure.cpp?rev=348944&r1=348943&r2=348944&view=diff
==
--- cfe/trunk/test/Misc/backend-optimization-failure.cpp (original)
+++ cfe/trunk/test/Misc/backend-optimization-failure.cpp Wed Dec 12 09:32:52 
2018
@@ -7,7 +

r349823 - [CodeGen] Generate llvm.loop.parallel_accesses instead of llvm.mem.parallel_loop_access metadata.

2018-12-20 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Thu Dec 20 13:24:54 2018
New Revision: 349823

URL: http://llvm.org/viewvc/llvm-project?rev=349823&view=rev
Log:
[CodeGen] Generate llvm.loop.parallel_accesses instead of 
llvm.mem.parallel_loop_access metadata.

Instead of generating llvm.mem.parallel_loop_access metadata, generate
llvm.access.group on instructions and llvm.loop.parallel_accesses on
loops. There is one access group per generated loop.

This is clang part of D52116/r349725.

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

Added:
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
Modified:
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGLoopInfo.h
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-nested.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety-outer.cpp
cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_simd_codegen.cpp
cfe/trunk/test/OpenMP/loops_explicit_clauses_codegen.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/schedule_codegen.cpp
cfe/trunk/test/OpenMP/simd_codegen.cpp
cfe/trunk/test/OpenMP/simd_metadata.c
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=349823&r1=349822&r2=349823&view=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Thu Dec 20 13:24:54 2018
@@ -21,7 +21,7 @@ using namespace llvm;
 
 static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs,
   const llvm::DebugLoc &StartLoc,
-  const llvm::DebugLoc &EndLoc) {
+  const llvm::DebugLoc &EndLoc, MDNode *&AccGroup) 
{
 
   if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 &&
   Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 &&
@@ -122,6 +122,12 @@ static MDNode *createMetadata(LLVMContex
 Args.push_back(MDNode::get(Ctx, Vals));
   }
 
+  if (Attrs.IsParallel) {
+AccGroup = MDNode::getDistinct(Ctx, {});
+Args.push_back(MDNode::get(
+Ctx, {MDString::get(Ctx, "llvm.loop.parallel_accesses"), AccGroup}));
+  }
+
   // Set the first operand to itself.
   MDNode *LoopID = MDNode::get(Ctx, Args);
   LoopID->replaceOperandWith(0, LoopID);
@@ -150,7 +156,8 @@ void LoopAttributes::clear() {
 LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs,
const llvm::DebugLoc &StartLoc, const llvm::DebugLoc 
&EndLoc)
 : LoopID(nullptr), Header(Header), Attrs(Attrs) {
-  LoopID = createMetadata(Header->getContext(), Attrs, StartLoc, EndLoc);
+  LoopID =
+  createMetadata(Header->getContext(), Attrs, StartLoc, EndLoc, AccGroup);
 }
 
 void LoopInfoStack::push(BasicBlock *Header, const llvm::DebugLoc &StartLoc,
@@ -328,6 +335,21 @@ void LoopInfoStack::pop() {
 }
 
 void LoopInfoStack::InsertHelper(Instruction *I) const {
+  if (I->mayReadOrWriteMemory()) {
+SmallVector AccessGroups;
+for (const LoopInfo &AL : Active) {
+  // Here we assume that every loop that has an access group is parallel.
+  if (MDNode *Group = AL.getAccessGroup())
+AccessGroups.push_back(Group);
+}
+MDNode *UnionMD = nullptr;
+if (AccessGroups.size() == 1)
+  UnionMD = cast(AccessGroups[0]);
+else if (AccessGroups.size() >= 2)
+  UnionMD = MDNode::get(I->getContext(), AccessGroups);
+I->setMetadata("llvm.access.group", UnionMD);
+  }
+
   if (!hasInfo())
 return;
 
@@ -343,18 +365,4 @@ void LoopInfoStack::InsertHelper(Instruc
   }
 return;
   }
-
-  if (I->mayReadOrWriteMemory()) {
-SmallVector ParallelLoopIDs;
-for (const LoopInfo &AL : Active)
-  if (AL.getAttributes().IsParallel)
-ParallelLoopIDs.push_back(AL.getLoopID());
-
-MDNode *ParallelMD = nullptr;
-if (ParallelLoopIDs.size() == 1)
-  ParallelMD = cast(ParallelLoopIDs[0]);
-else if (ParallelLoopIDs.size() >= 2)
-  ParallelMD = MDNode::get(I->getContext(), ParallelLoopIDs);
-I->setMetadata("llvm.mem.parallel_loop_access", ParallelMD);
-  }
 }

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.h?rev=349823&r1=349822&r2=349823&view=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.h Thu Dec 20 13:24:54 2018
@@ -84,6 +84,9 @@ public:
   /// Get the set of attributes active for this loop.
   const LoopAttributes &getAttributes() const { return Attrs; }
 
+  /// Return this loop's acc

r373023 - [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Thu Sep 26 15:53:01 2019
New Revision: 373023

URL: http://llvm.org/viewvc/llvm-project?rev=373023&view=rev
Log:
[OpenMP 5.0] Fix user-defined mapper lookup in sema

This patches fixes the case when a user-defined mapper is attached to
the elements of an array, and to report error when a mapper is used for
types other than struct, class, and union.

Patch by Lingda Li 

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373023&r1=373022&r2=373023&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 26 15:53:01 2019
@@ -14754,6 +14754,11 @@ static ExprResult buildUserDefinedMapper
 Expr *UnresolvedMapper) {
   if (MapperIdScopeSpec.isInvalid())
 return ExprError();
+  // Get the actual type for the array type.
+  if (Type->isArrayType()) {
+assert(Type->getAsArrayTypeUnsafe() && "Expect to get a valid array type");
+Type = Type->getAsArrayTypeUnsafe()->getElementType().getCanonicalType();
+  }
   // Find all user-defined mappers with the given MapperId.
   SmallVector, 4> Lookups;
   LookupResult Lookup(SemaRef, MapperId, Sema::LookupOMPMapperName);
@@ -14800,11 +14805,14 @@ static ExprResult buildUserDefinedMapper
 MapperIdScopeSpec.getWithLocInContext(SemaRef.Context), MapperId,
 /*ADL=*/false, /*Overloaded=*/true, URS.begin(), URS.end());
   }
+  SourceLocation Loc = MapperId.getLoc();
   // [OpenMP 5.0], 2.19.7.3 declare mapper Directive, Restrictions
   //  The type must be of struct, union or class type in C and C++
-  if (!Type->isStructureOrClassType() && !Type->isUnionType())
-return ExprEmpty();
-  SourceLocation Loc = MapperId.getLoc();
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);
+return ExprError();
+  }
   // Perform argument dependent lookup.
   if (SemaRef.getLangOpts().CPlusPlus && !MapperIdScopeSpec.isSet())
 argumentDependentLookup(SemaRef, MapperId, Loc, Type, Lookups);

Modified: cfe/trunk/test/OpenMP/declare_mapper_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_mapper_messages.c?rev=373023&r1=373022&r2=373023&view=diff
==
--- cfe/trunk/test/OpenMP/declare_mapper_messages.c (original)
+++ cfe/trunk/test/OpenMP/declare_mapper_messages.c Thu Sep 26 15:53:01 2019
@@ -36,6 +36,8 @@ int fun(int arg) {
 {
 #pragma omp declare mapper(id: struct vec v) map(v.len) allocate(v)   // 
expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp 
declare mapper'}}
   struct vec vv, v1;
+  struct vec arr[10];
+  double d;
 #pragma omp target map(mapper)  // 
expected-error {{use of undeclared identifier 'mapper'}}
   {}
 #pragma omp target map(mapper:vv)   // 
expected-error {{expected '(' after 'mapper'}}
@@ -46,9 +48,13 @@ int fun(int arg) {
   {}
 #pragma omp target map(mapper(ab) :vv)  // 
expected-error {{missing map type}} expected-error {{cannot find a valid 
user-defined mapper for type 'struct vec' with name 'ab'}}
   {}
+#pragma omp target map(mapper(ab) :arr[0:2])// 
expected-error {{missing map type}} expected-error {{cannot find a valid 
user-defined mapper for type 'struct vec' with name 'ab'}}
+  {}
 #pragma omp target map(mapper(aa) :vv)  // 
expected-error {{missing map type}}
   {}
-#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1)
+#pragma omp target map(mapper(aa) to:d) // 
expected-error {{mapper type must be of struct, union or class type}}
+  {}
+#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) 
map(mapper(aa) to:arr[0])
   {}
 
 #pragma omp target update to(mapper)// 
expected-error {{expected '(' after 'mapper'}} expected-error {{expected 
expression}} expected-error {{expected at least one 'to' clause or 'from' 
clause specified to '#pragma omp target update'}}
@@ -57,7 +63,10 @@ int fun(int arg) {
 #pragma omp target update to(mapper(:vv)// 
expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error 
{{expected at least one 'to' clause or 'from' clause specified to '#pragma omp 
target update'}}
 #pragma omp tar

Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-25 Thread Michael Kruse via cfe-commits
2018-06-25 14:20 GMT-05:00 Richard Smith :
> (I'm not sure what the problem is, but as a data point, Sema::checkCall
> iterates over the FormatAttrs in order, so it's possible that changing the
> order may have triggered a new warning. That may be due to a pre-existing
> order-dependence bug, or it may be that we're losing an attribute here.)

In this case the following patch should fix this.


diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 12a599b4f1..aeb7a83fa6 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -3172,7 +3172,8 @@ void Sema::checkCall(NamedDecl *FDecl, const
FunctionProtoType *Proto,
   // Printf and scanf checking.
   llvm::SmallBitVector CheckedVarArgs;
   if (FDecl) {
-for (const auto *I : FDecl->specific_attrs()) {
+SmallVector
FormatAttrs(FDecl->specific_attrs());
+for (const auto *I : llvm::reverse(FormatAttrs)) {
   // Only create vector if there are format attributes.
   CheckedVarArgs.resize(Args.size());


 However, if I understand __attribute__((format(...))) correctly,
there should be just one FormatAttr.


>> > Please let me know your plan. (If I don't hear back in a day or so, I'll
>> > go
>> > ahead and revert for you as the safe default course of action.)
>>
>> On a weekend?
>
>
> Yes; our policy is generally to revert to green if a patch causes
> regressions that aren't going to be fixed in a few hours. This is generally
> good for the committer, because it lets you figure out what's wrong and deal
> with it on your own schedule rather than being pressured to fix it urgently
> because you're blocking the work of others.

Should I revert the commit then?

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


Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-25 Thread Michael Kruse via cfe-commits
I just revert if to have further discussions (r335516)

Michael

2018-06-25 14:58 GMT-05:00 Eric Christopher :
>
>
> On Mon, Jun 25, 2018 at 12:21 PM Richard Smith via cfe-commits
>  wrote:
>>
>> On 23 June 2018 at 22:34, Michael Kruse via cfe-commits
>>  wrote:
>>>
>>> Hi,
>>>
>>> multiple comments in the code indicate that the attribute order was
>>> surprising and probably has lead to bugs, and will lead to bugs in the
>>> future. The order had to be explicitly reversed to avoid those. This
>>> alone for me this seems a good reason to have the attributes in the
>>> order in which they appear in the source.
>>>
>>> It would be nice it you could send a reproducer. At a glance, your
>>> case does not seem related since the format strings are function
>>> arguments, not attributes.
>>>
>>> Michael
>>>
>>>
>>> 2018-06-23 17:17 GMT-05:00 David Jones :
>>> > This commit seems to have some substantial downsides... for example, it
>>> > now
>>> > flags calls like this as warnings:
>>> >
>>> > http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/src/msgl-check.c?id=05ecefa943f339019b7127aa92cbb09f6fd49ed3#n478
>>> >
>>> > Previously, the reverse order meant that the plural format string was
>>> > examined, but now it is only the singular string. Since the singular
>>> > string
>>> > doesn't include a substitution, the unused format variable warning
>>> > fires
>>> > after this revision.
>>> >
>>> > I don't see a strong argument for why one order is more correct than
>>> > the
>>> > other; however, given that this is in conflict with real code found in
>>> > the
>>> > wild, I think this needs to be addressed.
>>> >
>>> > Since the semantics of the ordering of multiple format args seems
>>> > somewhat
>>> > ill-defined, it seems to me like reverting may be the best near-term
>>> > choice.
>>> > I can imagine other ways to fix the diagnostic, but the only behaviour
>>> > that
>>> > I would believe to be expected by existing code is the old one, so a
>>> > change
>>> > like this one probably needs to be more carefully vetted before being
>>> > (re-)committed.
>>>
>>> Could you give more details about your concerns?
>>
>>
>> (I'm not sure what the problem is, but as a data point, Sema::checkCall
>> iterates over the FormatAttrs in order, so it's possible that changing the
>> order may have triggered a new warning. That may be due to a pre-existing
>> order-dependence bug, or it may be that we're losing an attribute here.)
>>
>
> FWIW I just replied to the original review thread as well - there appear to
> be some warnings that are now missing that previously worked and some that
> are now in reverse order from the source. I think more work might need to
> happen before this patch should go back in.
>
> -eric
>
>>>
>>> > Please let me know your plan. (If I don't hear back in a day or so,
>>> > I'll go
>>> > ahead and revert for you as the safe default course of action.)
>>>
>>> On a weekend?
>>
>>
>> Yes; our policy is generally to revert to green if a patch causes
>> regressions that aren't going to be fixed in a few hours. This is generally
>> good for the committer, because it lets you figure out what's wrong and deal
>> with it on your own schedule rather than being pressured to fix it urgently
>> because you're blocking the work of others.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335516 - Revert "Append new attributes to the end of an AttributeList."

2018-06-25 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Jun 25 13:06:13 2018
New Revision: 335516

URL: http://llvm.org/viewvc/llvm-project?rev=335516&view=rev
Log:
Revert "Append new attributes to the end of an AttributeList."

This reverts commit r335084 as requested by David Jones and
Eric Christopher because of differences of emitted warnings.

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
cfe/trunk/test/Index/complete-with-annotations.cpp
cfe/trunk/test/Misc/ast-print-pragmas.cpp
cfe/trunk/test/PCH/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-loop-safety.cpp
cfe/trunk/test/Parser/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-unroll.cpp
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability.c
cfe/trunk/test/Sema/attr-coldhot.c
cfe/trunk/test/Sema/attr-disable-tail-calls.c
cfe/trunk/test/Sema/attr-long-call.c
cfe/trunk/test/Sema/attr-micromips.c
cfe/trunk/test/Sema/attr-notail.c
cfe/trunk/test/Sema/attr-ownership.c
cfe/trunk/test/Sema/attr-ownership.cpp
cfe/trunk/test/Sema/attr-print.c
cfe/trunk/test/Sema/attr-swiftcall.c
cfe/trunk/test/Sema/attr-target-mv.c
cfe/trunk/test/Sema/attr-visibility.c
cfe/trunk/test/Sema/internal_linkage.c
cfe/trunk/test/Sema/mips-interrupt-attr.c
cfe/trunk/test/Sema/ms_abi-sysv_abi.c
cfe/trunk/test/Sema/nullability.c
cfe/trunk/test/Sema/stdcall-fastcall.c
cfe/trunk/test/SemaCXX/attr-print.cpp
cfe/trunk/test/SemaCXX/attr-swiftcall.cpp
cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp
cfe/trunk/test/SemaCXX/ms-uuid.cpp
cfe/trunk/test/SemaOpenCL/address-spaces.cl
cfe/trunk/test/SemaTemplate/attributes.cpp

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=335516&r1=335515&r2=335516&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Mon Jun 25 13:06:13 2018
@@ -764,11 +764,8 @@ public:
   void add(AttributeList *newAttr) {
 assert(newAttr);
 assert(newAttr->getNext() == nullptr);
-
-// FIXME: AttributeList is a singly linked list, i.e. appending to the end
-// requires walking to the last element. For adding n attributes, this
-// requires O(n^2) time. However, AttributeLists should be very short.
-addAllAtEnd(newAttr);
+newAttr->setNext(list);
+list = newAttr;
   }
 
   void addAll(AttributeList *newList) {

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=335516&r1=335515&r2=335516&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Jun 25 13:06:13 2018
@@ -707,8 +707,10 @@ void CXXNameMangler::mangleFunctionEncod
   if (FD->hasAttr()) {
 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
 Out << "Ua9enable_ifI";
-for (AttrVec::const_iterator I = FD->getAttrs().begin(),
- E = FD->getAttrs().end();
+// FIXME: specific_attr_iterator iterates in reverse order. Fix that and 
use
+// it here.
+for (AttrVec::const_reverse_iterator I = FD->getAttrs().rbegin(),
+ E = FD->getAttrs().rend();
  I != E; ++I) {
   EnableIfAttr *EIA = dyn_cast(*I);
   if (!EIA)

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=335516&r1=335515&r2=335516&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jun 25 13:06:13 2018
@@ -1649,7 +1649,9 @@ void Parser::stripTypeAttributesOffDeclS
   }
 
   // Find end of type attributes Attrs and add NewTypeAttributes in the same
-  // order they were in originally.
+  // order they were in originally.  (Remember, in AttributeList things earlier
+  // in source order are later in the list, since new attributes are added to
+  // the front of the list.)
   Attrs.addAllAtEnd(TypeAttrHead);
 }
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=335516&r1=335515&r2=335516&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jun 25 13:06:13 2018
@@ -6189,6 +6189,24 @@ Sema::SelectBestMethod(Selector Sel, Mul
   r

Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-26 Thread Michael Kruse via cfe-commits
Thank you for your reproducer. I debugged it and found the issue.
ngettext is defined as follows.

extern char *ngettext (const char *__msgid1, const char *__msgid2,
 unsigned long int __n)
 throw () __attribute__ ((__format_arg__ (1))) __attribute__
((__format_arg__ (2)));

Indeed, two format attributes (Just not the plain "format" I
expected). The code which is processing it from SemaChecking.cpp:5521

if (const FormatArgAttr *FA = ND->getAttr()) {

That is, the code as written can process at most one FormatAttr and
takes the first one (which is a different one before and after my
patch).

I suggest to change this to:

for (const auto *FA : FDecl->specific_attrs()) {

such that both arguments to ngettext are checked, as defined by the
attributes. That also means that emitting the warning is emitted with
and without my patch.

Michael







2018-06-25 19:29 GMT-05:00 David Jones :
> (Sorry for the late reply...)
>
> On Mon, Jun 25, 2018 at 2:45 PM Michael Kruse via cfe-commits
>  wrote:
>>
>> I just revert if to have further discussions (r335516)
>>
>> Michael
>>
>> 2018-06-25 14:58 GMT-05:00 Eric Christopher :
>> >
>> >
>> > On Mon, Jun 25, 2018 at 12:21 PM Richard Smith via cfe-commits
>> >  wrote:
>> >>
>> >> On 23 June 2018 at 22:34, Michael Kruse via cfe-commits
>> >>  wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> multiple comments in the code indicate that the attribute order was
>> >>> surprising and probably has lead to bugs, and will lead to bugs in the
>> >>> future. The order had to be explicitly reversed to avoid those. This
>> >>> alone for me this seems a good reason to have the attributes in the
>> >>> order in which they appear in the source.
>> >>>
>> >>> It would be nice it you could send a reproducer. At a glance, your
>> >>> case does not seem related since the format strings are function
>> >>> arguments, not attributes.
>
>
> Well, there is a nested function call, but the format warning applies to two
> different parameters: a singular phrasing string, and a plural one. A
> reproducer would look like this, which is almost verbatim from the link:
>
> $ cat /tmp/repro.cc
> #include 
> #include 
>
> void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
> $ /bin/clang -Wall -c -o /dev/null /tmp/repro.cc
> /tmp/repro.cc:4:66: warning: data argument not used by format string
> [-Wformat-extra-args]
> void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
> ~^
> 1 warning generated.
>
>
> Swapping the string params works, and an older revision yields inverse
> results.
>
>
>>
>> >>> 2018-06-23 17:17 GMT-05:00 David Jones :
>> >>> > Since the semantics of the ordering of multiple format args seems
>> >>> > somewhat
>> >>> > ill-defined, it seems to me like reverting may be the best near-term
>> >>> > choice.
>> >>> > I can imagine other ways to fix the diagnostic, but the only
>> >>> > behaviour
>> >>> > that
>> >>> > I would believe to be expected by existing code is the old one, so a
>> >>> > change
>> >>> > like this one probably needs to be more carefully vetted before
>> >>> > being
>> >>> > (re-)committed.
>> >>>
>> >>> Could you give more details about your concerns?
>
>
>
> Multiple format strings (or repeating or reordering other attributes) seems
> like it lacks clear semantics. I can't find any particularly well-documented
> explanation of Clang's behaviour in these cases, which makes me suspect that
> most people would just "fix it until it works" and move on. GCC's
> documentation doesn't seem to be very decisive, either.
>
> For example, you mentioned that multiple format attributes may be invalid;
> if so, then rejecting such cases should probably be a part of the fix. But
> that would require some vetting, since this (pretty clearly) doesn't mirror
> the current reality.
>
>
>> >> (I'm not sure what the problem is, but as a data point, Sema::checkCall
>> >> iterates over the FormatAttrs in order, so it's possible that changing
>> >> the
>> >> order may have triggered a new warning. That may be due to a
>> >> pre-existing
>> >> ord

Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-27 Thread Michael Kruse via cfe-commits
Thanks for adding the regression test.

I'll wait for @erichkeane's work AttibuteList's linked list fix before
trying to re-commit.

Michael


2018-06-27 7:12 GMT-05:00 Nico Weber :
> Here's another regression that was introduced by the patch:
> https://bugs.llvm.org/show_bug.cgi?id=37935 I landed a test for that in
> r335725 (in case you're wondering why there's a new test failure when you
> reland).
>
> Thanks for working on this!
>
> On Tue, Jun 26, 2018 at 9:03 AM Michael Kruse via cfe-commits
>  wrote:
>>
>> Thank you for your reproducer. I debugged it and found the issue.
>> ngettext is defined as follows.
>>
>> extern char *ngettext (const char *__msgid1, const char *__msgid2,
>>  unsigned long int __n)
>>  throw () __attribute__ ((__format_arg__ (1))) __attribute__
>> ((__format_arg__ (2)));
>>
>> Indeed, two format attributes (Just not the plain "format" I
>> expected). The code which is processing it from SemaChecking.cpp:5521
>>
>> if (const FormatArgAttr *FA = ND->getAttr()) {
>>
>> That is, the code as written can process at most one FormatAttr and
>> takes the first one (which is a different one before and after my
>> patch).
>>
>> I suggest to change this to:
>>
>> for (const auto *FA : FDecl->specific_attrs()) {
>>
>> such that both arguments to ngettext are checked, as defined by the
>> attributes. That also means that emitting the warning is emitted with
>> and without my patch.
>>
>> Michael
>>
>>
>>
>>
>>
>>
>>
>> 2018-06-25 19:29 GMT-05:00 David Jones :
>> > (Sorry for the late reply...)
>> >
>> > On Mon, Jun 25, 2018 at 2:45 PM Michael Kruse via cfe-commits
>> >  wrote:
>> >>
>> >> I just revert if to have further discussions (r335516)
>> >>
>> >> Michael
>> >>
>> >> 2018-06-25 14:58 GMT-05:00 Eric Christopher :
>> >> >
>> >> >
>> >> > On Mon, Jun 25, 2018 at 12:21 PM Richard Smith via cfe-commits
>> >> >  wrote:
>> >> >>
>> >> >> On 23 June 2018 at 22:34, Michael Kruse via cfe-commits
>> >> >>  wrote:
>> >> >>>
>> >> >>> Hi,
>> >> >>>
>> >> >>> multiple comments in the code indicate that the attribute order was
>> >> >>> surprising and probably has lead to bugs, and will lead to bugs in
>> >> >>> the
>> >> >>> future. The order had to be explicitly reversed to avoid those.
>> >> >>> This
>> >> >>> alone for me this seems a good reason to have the attributes in the
>> >> >>> order in which they appear in the source.
>> >> >>>
>> >> >>> It would be nice it you could send a reproducer. At a glance, your
>> >> >>> case does not seem related since the format strings are function
>> >> >>> arguments, not attributes.
>> >
>> >
>> > Well, there is a nested function call, but the format warning applies to
>> > two
>> > different parameters: a singular phrasing string, and a plural one. A
>> > reproducer would look like this, which is almost verbatim from the link:
>> >
>> > $ cat /tmp/repro.cc
>> > #include 
>> > #include 
>> >
>> > void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
>> > $ /bin/clang -Wall -c -o /dev/null /tmp/repro.cc
>> > /tmp/repro.cc:4:66: warning: data argument not used by format string
>> > [-Wformat-extra-args]
>> > void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
>> > ~^
>> > 1 warning generated.
>> >
>> >
>> > Swapping the string params works, and an older revision yields inverse
>> > results.
>> >
>> >
>> >>
>> >> >>> 2018-06-23 17:17 GMT-05:00 David Jones :
>> >> >>> > Since the semantics of the ordering of multiple format args seems
>> >> >>> > somewhat
>> >> >>> > ill-defined, it seems to me like reverting may be the best
>> >> >>> > near-term
>> >> >>> > choice.
>> >> >>> > I can imagine other ways to fix the diagnostic, but t

r336239 - [Sema] Consider all format_arg attributes.

2018-07-04 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Tue Jul  3 18:37:11 2018
New Revision: 336239

URL: http://llvm.org/viewvc/llvm-project?rev=336239&view=rev
Log:
[Sema] Consider all format_arg attributes.

If a function has multiple format_arg attributes, clang only considers
the first it finds (because AttributeLists are in reverse order, not
necessarily the textually first) and ignores all others.

Loop over all FormatArgAttr to print warnings for all declared
format_arg attributes.

For instance, libintl's ngettext (select plural or singular version of
format string) has two __format_arg__ attributes.

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/attr-format_arg.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=336239&r1=336238&r2=336239&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Jul  3 18:37:11 2018
@@ -5518,13 +5518,22 @@ checkFormatStringExpr(Sema &S, const Exp
   case Stmt::CXXMemberCallExprClass: {
 const CallExpr *CE = cast(E);
 if (const NamedDecl *ND = 
dyn_cast_or_null(CE->getCalleeDecl())) {
-  if (const FormatArgAttr *FA = ND->getAttr()) {
+  bool IsFirst = true;
+  StringLiteralCheckType CommonResult;
+  for (const auto *FA : ND->specific_attrs()) {
 const Expr *Arg = CE->getArg(FA->getFormatIdx().getASTIndex());
-return checkFormatStringExpr(S, Arg, Args,
- HasVAListArg, format_idx, firstDataArg,
- Type, CallType, InFunctionCall,
- CheckedVarArgs, UncoveredArg, Offset);
-  } else if (const FunctionDecl *FD = dyn_cast(ND)) {
+StringLiteralCheckType Result = checkFormatStringExpr(
+S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
+if (IsFirst) {
+  CommonResult = Result;
+  IsFirst = false;
+}
+  }
+  if (!IsFirst)
+return CommonResult;
+
+  if (const auto *FD = dyn_cast(ND)) {
 unsigned BuiltinID = FD->getBuiltinID();
 if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
 BuiltinID == Builtin::BI__builtin___NSStringMakeConstantString) {

Modified: cfe/trunk/test/Sema/attr-format_arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-format_arg.c?rev=336239&r1=336238&r2=336239&view=diff
==
--- cfe/trunk/test/Sema/attr-format_arg.c (original)
+++ cfe/trunk/test/Sema/attr-format_arg.c Tue Jul  3 18:37:11 2018
@@ -4,10 +4,27 @@ int printf(const char *, ...);
 
 const char* f(const char *s) __attribute__((format_arg(1)));
 
+const char *h(const char *msg1, const char *msg2)
+__attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
+
 void g(const char *s) {
   printf("%d", 123);
   printf("%d %d", 123); // expected-warning{{more '%' conversions than data 
arguments}}
 
   printf(f("%d"), 123);
   printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data 
arguments}}
+
+  printf(h(
+"", // expected-warning {{format string is empty}}
+""  // expected-warning {{format string is empty}}
+  ), 123);
+  printf(h(
+"%d",
+""  // expected-warning {{format string is empty}}
+  ), 123);
+  printf(h(
+"", // expected-warning {{format string is empty}}
+"%d"
+  ), 123);
+  printf(h("%d", "%d"), 123);
 }


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


Re: r374288 - Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"

2019-10-21 Thread Michael Kruse via cfe-commits
Am Mo., 21. Okt. 2019 um 16:01 Uhr schrieb Jordan Rupprecht via
cfe-commits :
> There's also a curious failure caused by this patch (confirmed passing 
> @r374287, failing @r374288):

It's a warning, not a failure.


> $ cat /tmp/vectorize.cc
> void a() {
> #pragma clang loop vectorize(disable)
>   for (;;)
> ;
> }
>
> $ clang++ -Werror -O3 -c /tmp/vectorize.cc
> /tmp/vectorize.cc:1:6: error: loop not interleaved: the optimizer was unable 
> to perform the requested transformation; the transformation might be disabled 
> or specified as part of an unsupported transformation ordering 
> [-Werror,-Wpass-failed=transform-warning]
> void a() {
>
> I don't understand this warning -- there is no requested transformation; in 
> fact, we've explicitly specified that vectorization *should* be disabled.

https://reviews.llvm.org/D66290

generates the following metadata for #pragma clang loop vectorize(disable):

!3 = distinct !{!3, !4, !5}
!4 = !{!"llvm.loop.vectorize.enable", i1 true}
!5 = !{!"llvm.loop.vectorize.width", i32 1}

which is interpreted as "enable LoopVectorize, but only the interleave
part" by LoopVectorize and WarnMissedTransformations.

The tests in D66290 missed that because the regex may matche multiple MDNodes:

// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]],
![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_1:.*]]}

The additional "llvm.loop.vectorize.enable" is generated by:

  if (Attrs.VectorizeWidth > 0) {
// This implies vectorize.enable = true, but only add it when it is not
// already enabled.
if (Attrs.VectorizeEnable != LoopAttributes::Enable)

Attr.VectorizeWidth is set by the vectorize(disable) LoopHint:

case LoopHintAttr::Disable:
  switch (Option) {
  case LoopHintAttr::Vectorize:
// Disable vectorization by specifying a width of 1.
setVectorizeWidth(1);



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


Re: r374288 - Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"

2019-10-22 Thread Michael Kruse via cfe-commits
Am Mo., 21. Okt. 2019 um 23:44 Uhr schrieb Jordan Rupprecht
:
> At any rate, it sounds like this is not a codegen bug at all, but just an 
> over-eager warning?

That interpretation is different from mine. Codgen emits the following
from vectorize(disable)

!4 = !{!"llvm.loop.vectorize.enable", i1 true}

which is is not what I'd expect.

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


Re: [PATCH] D69391: Add #pragma clang loop ivdep

2019-10-25 Thread Michael Kruse via cfe-commits
What's the motivation of even allowing `#pragma clang loop
ivdep(disable)`? It either has no effect or conflicts with other loop
hints.



Sorry, for not using Phabricator. When I try to submit a comment, I
get the following error:

You Shall Not Pass: D69391

You do not have permission to edit this object.
Users with the "Can Edit" capability:

Administrators can take this action.
The owner of a revision can always view and edit it.



Michael


Am Fr., 25. Okt. 2019 um 12:43 Uhr schrieb Hal Finkel via Phabricator
:
>
> hfinkel added a comment.
>
> This is the same as #pragma clang loop vectorize(assume_safety)?
>
> In D69391#1720845 , @xbolva00 wrote:
>
> > "#pragma ivdep" should work too (compatibiluty mode with intel, gcc).
>
>
> The semantics are not the same, unfortunately.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D69391/new/
>
> https://reviews.llvm.org/D69391
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r374288 - Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)"

2019-10-25 Thread Michael Kruse via cfe-commits
@sjoerdmeijer

Before recommitting, please re-open the patch review.

Michael

Am Do., 24. Okt. 2019 um 18:45 Uhr schrieb Jordan Rupprecht
:
>
> Reverted in 6d424a161bf3e52730371da0b9439ed93a8ce406 due to the issue 
> described here. Should hopefully be a trivial fix forward.
>
> On Tue, Oct 22, 2019 at 2:46 PM Michael Kruse  
> wrote:
>>
>> Am Mo., 21. Okt. 2019 um 23:44 Uhr schrieb Jordan Rupprecht
>> :
>> > At any rate, it sounds like this is not a codegen bug at all, but just an 
>> > over-eager warning?
>>
>> That interpretation is different from mine. Codgen emits the following
>> from vectorize(disable)
>>
>> !4 = !{!"llvm.loop.vectorize.enable", i1 true}
>>
>> which is is not what I'd expect.
>>
>> Michael
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 80bd6ae - On Windows build, making the /bigobj flag global , instead of passing it per file.

2020-07-28 Thread Michael Kruse via cfe-commits

Author: Zahira Ammarguellat
Date: 2020-07-28T18:04:36-05:00
New Revision: 80bd6ae13ea23d453a1f45d6ccdbfc7d0c877bb0

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

LOG: On Windows build, making the /bigobj flag global , instead of passing it 
per file.

To avoid having this flag be passed in per/file manner, we are instead
passing it globally.

This fixes this bug: https://bugs.llvm.org/show_bug.cgi?id=46733

Reviewed-by: aaron.ballman, beanz, meinersbur

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

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
clang/lib/CodeGen/CMakeLists.txt
clang/lib/Sema/CMakeLists.txt
clang/unittests/AST/CMakeLists.txt
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/Tooling/CMakeLists.txt
lldb/source/API/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Passes/CMakeLists.txt
mlir/lib/Dialect/SPIRV/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt 
b/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
index adb891575b30..7110a503869e 100644
--- a/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
+++ b/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
 )
 
-# The registry source file ends up generating a lot of sections for each
-# matcher. Each matcher appears to get a vtable and several methods. Each
-# method needs .text, .pdata, .xdata, and .debug sections, adding to the
-# section multiplier. By default MSVC has a 2^16 limit on the number of
-# sections in an object file, and this needs more than that.
-if (MSVC)
-  set_source_files_properties(Registry.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 add_clang_library(clangDynamicASTMatchers
   Diagnostics.cpp
   Marshallers.cpp

diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index 8afd7219fbe1..88647a2007fb 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -26,10 +26,6 @@ set(LLVM_LINK_COMPONENTS
   TransformUtils
   )
 
-if (MSVC)
-  set_source_files_properties(CodeGenModule.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-endif()
-
 add_clang_library(clangCodeGen
   BackendUtil.cpp
   CGAtomic.cpp

diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index adadc06e209c..042ff561664d 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-if (MSVC)
-  set_source_files_properties(SemaDeclAttr.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
   SOURCE OpenCLBuiltins.td
   TARGET ClangOpenCLBuiltinsImpl

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 2e750ac9ea92..2d5d0172afed 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -3,9 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-if (MSVC)
-  set_source_files_properties(ASTImporterTest.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-endif()
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp

diff  --git a/clang/unittests/ASTMatchers/CMakeLists.txt 
b/clang/unittests/ASTMatchers/CMakeLists.txt
index c9ac6c57d689..b40b3886dcd2 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-# By default MSVC has a 2^16 limit on the number of sections in an object file,
-# and this needs more than that.
-if (MSVC)
-  set_source_files_properties(InternalASTMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(NodeMatchersTest.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(NarrowingMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(ASTTraversalMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-endif()
-
 add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp

diff  --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index c439f5a78637..f290c3d2bede 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -4,14 +4,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-#

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

2020-04-24 Thread Michael Kruse via cfe-commits
Weird. I already tried the patch under Windows/msvc and had no such problem.

Michael

Am Fr., 24. Apr. 2020 um 04:15 Uhr schrieb Russell Gallop
:
>
> Hi Serge,
>
> It looks like this is failing to build on Windows bots (e.g. 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/32003).
>  Error below.
>
> Please could you take a look?
>
> Thanks
> Russ
>
> FAILED: tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.obj 
> C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\bin\Hostx64\x64\cl.exe
>  /nologo /TP -DBUILD_EXAMPLES -DCMAKE_CFG_INTDIR=\".\" -DGTEST_HAS_RTTI=0 
> -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -Itools\llvm-config 
> -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\tools\llvm-config
>  -Iinclude 
> -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\include
>  /DWIN32 /D_WINDOWS /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
> -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 
> -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 
> -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 
> -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 
> -we4238 /Gw /MD /O2 /Ob2 /EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes 
> /Fotools\llvm-config\CMakeFiles\llvm-config.dir\llvm-config.cpp.obj 
> /Fdtools\llvm-config\CMakeFiles\llvm-config.dir\ /FS -c 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\tools\llvm-config\llvm-config.cpp
>  tools\llvm-config\ExtensionDependencies.inc(6): error C2280: 
> 'ExtensionDescriptor::ExtensionDescriptor(void)': attempting to reference a 
> deleted function tools\llvm-config\ExtensionDependencies.inc(5): note: 
> compiler has generated 'ExtensionDescriptor::ExtensionDescriptor' here 
> tools\llvm-config\ExtensionDependencies.inc(5): note: 
> 'ExtensionDescriptor::ExtensionDescriptor(void)': function was implicitly 
> deleted because 'ExtensionDescriptor' has an uninitialized const-qualified 
> data member 'ExtensionDescriptor::RequiredLibraries' 
> tools\llvm-config\ExtensionDependencies.inc(4): note: see declaration of 
> 'ExtensionDescriptor::RequiredLibraries'
>
> On Fri, 24 Apr 2020 at 09:02, serge via Phabricator via cfe-commits 
>  wrote:
>>
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rG8f766e382b77: Update compiler extension integration into 
>> the build system (authored by serge-sans-paille).
>>
>> Changed prior to commit:
>>   https://reviews.llvm.org/D78192?vs=259495&id=259827#toc
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D78192/new/
>>
>> https://reviews.llvm.org/D78192
>>
>> Files:
>>   clang/lib/CodeGen/CMakeLists.txt
>>   llvm/cmake/modules/AddLLVM.cmake
>>   llvm/lib/CMakeLists.txt
>>   llvm/lib/Extensions/CMakeLists.txt
>>   llvm/lib/Extensions/Extensions.cpp
>>   llvm/lib/Extensions/LLVMBuild.txt
>>   llvm/lib/LLVMBuild.txt
>>   llvm/lib/LTO/CMakeLists.txt
>>   llvm/lib/LTO/LLVMBuild.txt
>>   llvm/tools/bugpoint/CMakeLists.txt
>>   llvm/tools/llvm-config/llvm-config.cpp
>>   llvm/tools/opt/CMakeLists.txt
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 18eba16 - [OpenMP][docs] Update loop tiling status.

2020-07-31 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2020-07-31T13:01:55-05:00
New Revision: 18eba165e7ba80328a910cad3407599d8ff60f4f

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

LOG: [OpenMP][docs] Update loop tiling status.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 28fbd7baebb2..af5e538b1435 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -266,7 +266,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | misc extension   | default(firstprivate) & default(private)  
   | :part:`partial`  | firstprivate done: D75591   
  |
 
+--+--+--+---+
-| loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
+| loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+



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


[clang] [clang-format] Handle variable declarations in BreakAfterAttributes (PR #71755)

2023-11-10 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@owenca  You can run `ninja polly-update-format` which will use the in-tree 
`clang-format` to reformat all files. `git add` its changes, `git add --amend`, 
then push.

https://github.com/llvm/llvm-project/pull/71755
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed COFF linker arguments (PR #72889)

2023-11-20 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

The command-line argument handling is not related to 
[PE](https://en.wikipedia.org/wiki/Portable_Executable)/COFF, but to 
Microsoft's `link.exe` command line interface, for instance 
[`/libpath:`](https://learn.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=msvc-170).
 `/usr/bin/lld-link` is a `link.exe`-compatible interface for lld with an 
appropriate default triple, like `clang-cl` is for `clang`. IIRC, `lld` choses 
its command-line interface based on the `argv[0]` name, so should 
clang-linker-wrapper when passed `--linker-path=/usr/bin/lld-link` instead of 
`--linker-path=/usr/bin/lld`, but both should be able to generate PE files.

That is, this patch is not necessarily wrong, but the commit message and "// 
COFF-style linker options." should refer to the command line interface instead.

https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed COFF linker arguments (PR #72889)

2023-11-20 Thread Michael Kruse via cfe-commits


@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, 
Flags<[HelpHidden]>, Alias;
 
 def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>;
 def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, 
Flags<[HelpHidden]>;
+
+// COFF-style linker options.
+def out : Joined<["/", "-", "/?", "-?"], "out:">, Flags<[HelpHidden]>;

Meinersbur wrote:

Why `/?` and `-?` in the permitted option prefix list? Wouldn't this allow e.g. 
`-?out:`?

https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)

2023-11-22 Thread Michael Kruse via cfe-commits


@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, 
Flags<[HelpHidden]>, Alias;
 
 def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>;
 def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, 
Flags<[HelpHidden]>;
+
+// COFF-style linker options.
+def out : Joined<["/", "-", "/?", "-?"], "out:">, Flags<[HelpHidden]>;

Meinersbur wrote:

Feels strange to me, but justification is in 
4b81e9f8d10214fbb2c8e1a367a60801a5dd5fed

https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)

2023-11-22 Thread Michael Kruse via cfe-commits


@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, 
Flags<[HelpHidden]>, Alias;
 
 def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>;
 def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, 
Flags<[HelpHidden]>;
+
+// COFF-style linker options.

Meinersbur wrote:

```suggestion
// link.exe-style linker options.
```
Can you change this as well? 

https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)

2023-11-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur approved this pull request.

PE file start with the magic bytes `MZ` (0x4D5A). Extracting sections can 
usually done with the 
[dumpbin.exe](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170)
 tool. I don't know whether LLVM has means to do it itself as well.

https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)

2023-11-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)

2023-11-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/72889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ae6b400 - [Preprocessor] Implement -fminimize-whitespace.

2021-07-25 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-07-25T23:30:57-05:00
New Revision: ae6b4238e5f319ffcfc713a15e459be8

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

LOG: [Preprocessor] Implement -fminimize-whitespace.

This patch adds the -fminimize-whitespace with the following effects:

 * If combined with -E, remove as much non-line-breaking whitespace as
   possible.

 * If combined with -E -P, removes as much whitespace as possible,
   including line-breaks.

The motivation is to reduce the amount of insignificant changes in the
preprocessed output with source files where only whitespace has been
changed (add/remove comments, clang-format, etc.) which is in particular
useful with ccache.

A patch for ccache for using this flag has been proposed to ccache as well:
https://github.com/ccache/ccache/pull/815, which will use
-fnormalize-whitespace when clang-13 has been detected, and additionally
uses -P in "unify_mode". ccache already had a unify_mode in an older
version which was removed because of problems that using the
preprocessor itself does not have (such that the custom tokenizer did
not recognize C++11 raw strings).

This patch slightly reorganizes which part is responsible for adding
newlines that are required for semantics. It is now either
startNewLineIfNeeded() or MoveToLine() but never both; this avoids the
ShouldUpdateCurrentLine workaround and avoids redundant lines being
inserted in some cases. It also fixes a mandatory newline not inserted
after a _Pragma("...") that is expanded into a #pragma.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Preprocessor/line-directive-output-mincol.c
clang/test/Preprocessor/minimize-whitespace-messages.c
clang/test/Preprocessor/minimize-whitespace.c

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/Types.h
clang/include/clang/Frontend/PreprocessorOutputOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/Types.cpp
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/lib/Lex/Preprocessor.cpp
clang/test/Preprocessor/comment_save.c
clang/test/Preprocessor/first-line-indent.c
clang/test/Preprocessor/hash_line.c
clang/test/Preprocessor/line-directive-output.c
clang/test/Preprocessor/macro_space.c
clang/test/Preprocessor/print_line_include.c
clang/test/Preprocessor/stringize_space.c

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 74557c5bd581..35a3fdd382b4 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2475,6 +2475,16 @@ Turn on loop unroller
 
 Use #line in preprocessed output
 
+.. option:: -fminimize-whitespace, -fno-minimize-whitespace
+
+Ignore the whitespace from the input file when emitting preprocessor
+output. It will only contain whitespace when necessary, e.g. to keep two
+minus signs from merging into to an increment operator. Useful with the
+-P option to normalize whitespace such that two files with only formatting
+changes are equal.
+
+Only valid with -E on C-like inputs and incompatible with -traditional-cpp.
+
 .. option:: -fvalidate-ast-input-files-content
 
 Compute and store the hash of input files used to build an AST. Files with 
mismatching mtime's are considered valid if both contents is identical

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index fc3704303a95..3b4daa59f66b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -129,6 +129,8 @@ def err_drv_invalid_Xopenmp_target_with_args : Error<
   "invalid -Xopenmp-target argument: '%0', options requiring arguments are 
unsupported">;
 def err_drv_argument_only_allowed_with : Error<
   "invalid argument '%0' only allowed with '%1'">;
+def err_drv_minws_unsupported_input_type : Error<
+  "'-fminimize-whitespace' invalid for input of type %0">;
 def err_drv_amdgpu_ieee_without_no_honor_nans : Error<
   "invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN 
handling">;
 def err_drv_argument_not_allowed_with : Error<

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1815cd4621e8..991408c0e2a1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1799,6 +1799,9 @@ def frewrite_map_file_EQ : Joined<["-"], 
"frewrite-map-file=">,
 defm use_line_directives : BoolFOption<"use-line-directives",
   PreprocessorOutputOpts<"UseLineDirectives">, D

[clang] c6b0b16 - [Preprocessor] -E -P: Ensure newline after 8 skipped lines.

2021-07-28 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-07-28T22:50:54-05:00
New Revision: c6b0b16c0f55c34f4eaa05184815bbbe97f4b750

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

LOG: [Preprocessor] -E -P: Ensure newline after 8 skipped lines.

The implementation of -fminimize-whitespace (D104601) revised the logic
when to emit newlines. There was no case to handle when more than
8 lines were skippped in -P (DisableLineMarkers) mode and instead fell
through the case intended for -fminimize-whitespace, i.e. emit nothing.
This patch will emit one newline in this case.

The newline logic is slightly reorganized. The `-P -fminimize-whitespace`
case is handled explicitly and emitting at least one newline is the new
fallback case. The choice between emitting a line marker or up to
7 empty lines is now a choice only with enabled line markers. The up to
8 newlines likely are fewer characters than a line directive, but
in -P mode this had the paradoxic effect that it would print up to
7 empty lines, but none at all if more than 8 lines had to be skipped.
Now with DisableLineMarkers, we don't consider printing empty lines
(just start a new line) which matches gcc's behavior.

The line-directive-output-mincol.c test is replaced with a more
comprehensive test skip-empty-lines.c also testing the more than
8 skipped lines behaviour with all flag combinations.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Preprocessor/skip-empty-lines.c

Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/test/Preprocessor/minimize-whitespace.c

Removed: 
clang/test/Preprocessor/line-directive-output-mincol.c



diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index b7259569595d6..1759485de24db 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -276,20 +276,27 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo,
   // otherwise print a #line directive.
   if (CurLine == LineNo) {
 // Nothing to do if we are already on the correct line.
-  } else if (!StartedNewLine && (!MinimizeWhitespace || !DisableLineMarkers) &&
- LineNo - CurLine == 1) {
+  } else if (MinimizeWhitespace && DisableLineMarkers) {
+// With -E -P -fminimize-whitespace, don't emit anything if not necessary.
+  } else if (!StartedNewLine && LineNo - CurLine == 1) {
 // Printing a single line has priority over printing a #line directive, 
even
 // when minimizing whitespace which otherwise would print #line directives
 // for every single line.
 OS << '\n';
 StartedNewLine = true;
-  } else if (!MinimizeWhitespace && LineNo - CurLine <= 8) {
-const char *NewLines = "\n\n\n\n\n\n\n\n";
-OS.write(NewLines, LineNo - CurLine);
-StartedNewLine = true;
   } else if (!DisableLineMarkers) {
-// Emit a #line or line marker.
-WriteLineInfo(LineNo, nullptr, 0);
+if (LineNo - CurLine <= 8) {
+  const char *NewLines = "\n\n\n\n\n\n\n\n";
+  OS.write(NewLines, LineNo - CurLine);
+} else {
+  // Emit a #line or line marker.
+  WriteLineInfo(LineNo, nullptr, 0);
+}
+StartedNewLine = true;
+  } else if (!StartedNewLine) {
+// If we are not on the correct line and don't need to be line-correct,
+// at least ensure we start on a new line.
+OS << '\n';
 StartedNewLine = true;
   }
 

diff  --git a/clang/test/Preprocessor/line-directive-output-mincol.c 
b/clang/test/Preprocessor/line-directive-output-mincol.c
deleted file mode 100644
index 0f2466ebee971..0
--- a/clang/test/Preprocessor/line-directive-output-mincol.c
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -E -fminimize-whitespace %s 2>&1 | FileCheck %s 
-strict-whitespace
-
-// CHECK:  # 6 "{{.*}}line-directive-output-mincol.c"
-// CHECK-NEXT: int x;
-// CHECK-NEXT: int y;
-int x;
-int y;
-// CHECK-NEXT: # 10 "{{.*}}line-directive-output-mincol.c"
-// CHECK-NEXT: int z;
-int z;
-

diff  --git a/clang/test/Preprocessor/minimize-whitespace.c 
b/clang/test/Preprocessor/minimize-whitespace.c
index 3608e318dc135..137efe8393795 100644
--- a/clang/test/Preprocessor/minimize-whitespace.c
+++ b/clang/test/Preprocessor/minimize-whitespace.c
@@ -2,6 +2,12 @@
 // RUN: %clang_cc1 -fminimize-whitespace -E -C %s 2>&1 | FileCheck %s 
--strict-whitespace --check-prefix=MINCCOL
 // RUN: %clang_cc1 -fminimize-whitespace -E -P %s 2>&1 | FileCheck %s 
--strict-whitespace --check-prefix=MINWS
 // RUN: %clang_cc1 -fminimize-whitespace -E -C -P %s 2>&1 | FileCheck %s 
--strict-whitespace --check-prefix=MINCWS
+// The follow empty lines ensure that a #line directive is emitted instead of 
newline padding after the RUN co

[clang] 9ec501d - [OpenMP] Refactor OMPScheduleType enum.

2022-04-18 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-04-18T14:03:17-05:00
New Revision: 9ec501da76fc1559cadd6d6dac32766bf4376a3d

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

LOG: [OpenMP] Refactor OMPScheduleType enum.

The OMPScheduleType enum stores the constants from libomp's internal sched_type 
in kmp.h and are used by several kmp API functions. The enum values have an 
internal structure, namely each scheduling algorithm (e.g.) exists in four 
variants: unordered, orderend, normerge unordered, and nomerge ordered.

This patch (basically a followup to D114940) splits the "ordered" and "nomerge" 
bits into separate flags, as was already done for the "monotonic" and 
"nonmonotonic", so we can apply bit flags operations on them. It also now 
contains all possible combinations according to kmp's sched_type. Deriving of 
the OMPScheduleType enum from clause parameters has been moved form MLIR's 
OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as 
well. Since the primary purpose of the flag is the binary interface to libomp, 
it has been made more private to LLVMFrontend. The primary interface for 
generating worksharing-loop using OpenMPIRBuilder code becomes 
`applyWorkshareLoop` which derives the OMPScheduleType automatically and calls 
the appropriate emitter function.

While this is mostly a NFC refactor, it still applies the following functional 
changes:
 * The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also 
applies to clang. Most notably, it now applies the nonmonotonic flag for 
non-static schedules by default.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously 
not applied if the simd modifier was used. I assume this was a bug, since the 
effect was due to `loop.schedule_modifier()` returning 
`mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if 
ordered was specified, in breach to what the comment before citing the OpenMP 
specification says. I assume this was an oversight.

The ordered flag with parameter was not considered in this patch. Changes will 
need to be made (e.g. adding/modifying function parameters) when support for it 
is added. The lengthy names of the enum values can be discussed, for the moment 
this is avoiding reusing previously existing enum value names such as 
`StaticChunked` to avoid confusion.

Reviewed By: peixin

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned_auto.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e85c702907fa0..a249ef9d58d97 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3760,9 +3760,11 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
-AllocaIP, NeedsBarrier, SchedKind,
-ChunkSize);
+  OMPBuilder.applyWorkshareLoop(
+  Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
+  SchedKind, ChunkSize, /*HasSimdModifier=*/false,
+  /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
+  /*HasOrderedClause=*/false);
   return;
 }
 

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
index f1dadc63a22a0..bf0383cdb956c 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i3

[clang] af02851 - Revert "[OpenMP] Refactor OMPScheduleType enum."

2022-04-18 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-04-18T14:38:31-05:00
New Revision: af0285122f306573d9bcc4c4ad7f904cfdd4d869

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

LOG: Revert "[OpenMP] Refactor OMPScheduleType enum."

This reverts commit 9ec501da76fc1559cadd6d6dac32766bf4376a3d.

It may have caused the openmp-gcc-x86_64-linux-debian buildbot to fail.
https://lab.llvm.org/buildbot/#/builders/4/builds/20377

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned_auto.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a249ef9d58d97..e85c702907fa0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3760,11 +3760,9 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.applyWorkshareLoop(
-  Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
-  SchedKind, ChunkSize, /*HasSimdModifier=*/false,
-  /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
-  /*HasOrderedClause=*/false);
+  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
+AllocaIP, NeedsBarrier, SchedKind,
+ChunkSize);
   return;
 }
 

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
index bf0383cdb956c..f1dadc63a22a0 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741862, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 38, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
index 8a126c2ea440a..39321ff3b7af0 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
index 09773a2bd6f17..fd932a4f82070 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 5)
+// CHECK-NEXT:  

[clang] 2d92ee9 - Reapply "[OpenMP] Refactor OMPScheduleType enum."

2022-04-18 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-04-18T21:56:47-05:00
New Revision: 2d92ee97f1afb3657579a46a7dd4611b61e9cc16

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

LOG: Reapply "[OpenMP] Refactor OMPScheduleType enum."

This reverts commit af0285122f306573d9bcc4c4ad7f904cfdd4d869.

The test "libomp::loop_dispatch.c" on builder
openmp-gcc-x86_64-linux-debian fails from time-to-time.
See #54969. This patch is unrelated.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned_auto.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e85c702907fa0..a249ef9d58d97 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3760,9 +3760,11 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
-AllocaIP, NeedsBarrier, SchedKind,
-ChunkSize);
+  OMPBuilder.applyWorkshareLoop(
+  Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
+  SchedKind, ChunkSize, /*HasSimdModifier=*/false,
+  /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
+  /*HasOrderedClause=*/false);
   return;
 }
 

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
index f1dadc63a22a0..bf0383cdb956c 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 38, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741862, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
index 39321ff3b7af0..8a126c2ea440a 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
index fd932a4f82070..09773a2bd6f17 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 5)
+// CHECK-NEXT

[clang] acec070 - [OpenMP] Fix partial unrolling off-by-one.

2022-05-20 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-05-20T15:19:52-05:00
New Revision: acec07005e038ab2891f235ae60ba2f0236bb952

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

LOG: [OpenMP] Fix partial unrolling off-by-one.

Even though the comment description is ".unroll_inner.iv < NumIterations", the 
code emitted a BO_LE ('<=') operator for the inner loop that is to be unrolled. 
This lead to one additional copy of the body code in a partially unrolled. It 
only manifests when the unrolled loop is consumed by another loop-associated 
construct. Fix by using the BO_LT operator instead.

The condition for the outer loop and the corresponding code for tiling 
correctly used BO_LT already.

Fixes #55236

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
clang/test/OpenMP/unroll_codegen_for_partial.cpp
clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
clang/test/OpenMP/unroll_codegen_tile_for.cpp
clang/test/OpenMP/unroll_codegen_unroll_for.cpp
clang/test/OpenMP/unroll_codegen_unroll_for_attr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index e4305ba8c1718..42c3dbc181911 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14483,11 +14483,11 @@ StmtResult 
Sema::ActOnOpenMPUnrollDirective(ArrayRef Clauses,
   if (!EndOfTile.isUsable())
 return StmtError();
   ExprResult InnerCond1 = BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(),
- BO_LE, MakeInnerRef(), EndOfTile.get());
+ BO_LT, MakeInnerRef(), EndOfTile.get());
   if (!InnerCond1.isUsable())
 return StmtError();
   ExprResult InnerCond2 =
-  BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LE, 
MakeInnerRef(),
+  BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, 
MakeInnerRef(),
  MakeNumIterations());
   if (!InnerCond2.isUsable())
 return StmtError();

diff  --git a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c 
b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
index 0bfed911077bf..94d7a14a0bb87 100644
--- a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
+++ b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
@@ -106,12 +106,12 @@
 // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 
4
 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 4
-// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]]
+// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]]
 // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label 
%[[LAND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_RHS]]:
 // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
-// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8
+// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8
 // CHECK-NEXT:br label %[[LAND_END]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_END]]:

diff  --git 
a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c 
b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
index 1a2bd117bf98c..c44b2b3202694 100644
--- a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
+++ b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
@@ -114,12 +114,12 @@ double sind(double);
 // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 
4
 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 2
-// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]]
+// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]]
 // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label 
%[[LAND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_RHS]]:
 // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
-// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8
+// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8
 // CHECK-NEXT:br label %[[LAND_END]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_END]]:

diff  --git a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp 
b/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
index cafda811d0d0c..693cbf851b991 100644
--- a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
+++ b/clang/test/OpenMP/unro

[clang] [flang] [flang] Add --gcc-toolchain and --gcc-install-dir options to flang. (PR #87360)

2024-04-02 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/87360

The `--gcc-toolchain` and `--gcc-install-dir` option were previously only 
visible to the Clang driver, but not Flang. These determine which assembler, 
linker, and libraries to use, e.g. for cross-compiling, and therefore are 
relevant for Flang as well.

Fixes #86729

>From 6abdea97edcb345c97c32e2770016c3956f869a2 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 2 Apr 2024 17:33:13 +0200
Subject: [PATCH] [flang] Add --gcc-toolchain and --gcc-install-dir options to
 flang

---
 clang/include/clang/Driver/Options.td|  2 ++
 .../usr/bin/i386-unknown-linux-gnu-as|  1 +
 .../usr/bin/i386-unknown-linux-gnu-ld|  1 +
 .../usr/bin/i386-unknown-linux-gnu-ld.bfd|  1 +
 .../usr/bin/i386-unknown-linux-gnu-ld.gold   |  1 +
 .../usr/bin/x86_64-unknown-linux-gnu-as  |  1 +
 .../usr/bin/x86_64-unknown-linux-gnu-ld  |  1 +
 .../usr/bin/x86_64-unknown-linux-gnu-ld.bfd  |  1 +
 .../usr/bin/x86_64-unknown-linux-gnu-ld.gold |  1 +
 .../usr/i386-unknown-linux-gnu/bin/as|  1 +
 .../usr/i386-unknown-linux-gnu/bin/ld|  1 +
 .../usr/i386-unknown-linux-gnu/bin/ld.bfd|  1 +
 .../usr/i386-unknown-linux-gnu/bin/ld.gold   |  1 +
 .../usr/i386-unknown-linux-gnu/lib/.keep |  0
 .../usr/x86_64-unknown-linux-gnu/bin/as  |  1 +
 .../usr/x86_64-unknown-linux-gnu/bin/ld  |  1 +
 .../usr/x86_64-unknown-linux-gnu/bin/ld.bfd  |  1 +
 .../usr/x86_64-unknown-linux-gnu/bin/ld.gold |  1 +
 .../usr/x86_64-unknown-linux-gnu/bin/ld.lld  |  0
 .../usr/x86_64-unknown-linux-gnu/lib/.keep   |  0
 flang/test/Driver/gcc-install-dir.f90| 16 
 flang/test/Driver/gcc-toolchain.f90  | 16 
 22 files changed, 50 insertions(+)
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-as
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld.bfd
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld.gold
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-as
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld.bfd
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld.gold
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/as
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld.bfd
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld.gold
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/lib/.keep
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/as
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.bfd
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.gold
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.lld
 create mode 100644 
flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/lib/.keep
 create mode 100644 flang/test/Driver/gcc-install-dir.f90
 create mode 100644 flang/test/Driver/gcc-toolchain.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f5289fb00c895e..c3feff826d0036 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -802,9 +802,11 @@ def B : JoinedOrSeparate<["-"], "B">, 
MetaVarName<"">,
 HelpText<"Search $prefix$file for executables, libraries, and data files. "
 "If $prefix is a directory, search $prefix/$file">;
 def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Use GCC installation in the specified directory. The directory 
ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
   "Note: executables (e.g. ld) used by the compiler are not overridden by the 
selected GCC installation">;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify a directory whe

[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)

2024-03-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/84322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)

2024-03-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/84322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)

2024-03-07 Thread Michael Kruse via cfe-commits


@@ -410,7 +410,10 @@ fatbinary(ArrayRef> 
InputFiles,
 Targets.push_back(Saver.save("hipv4-amdgcn-amd-amdhsa--" + Arch));
   CmdArgs.push_back(Saver.save(llvm::join(Targets, ",")));
 
-  CmdArgs.push_back("-input=/dev/null");
+  if (Triple.isOSWindows())

Meinersbur wrote:

This does not depend on the target platform, but the host OS that runs 
clang-linker-wrapper (`#ifdef _WIN32`)

https://github.com/llvm/llvm-project/pull/84322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)

2024-03-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur approved this pull request.

The change works, as I managed to compile a single file.

However, the resulting executable segfaults for me on Windows and I get a link 
error when compiling multiple HIP files. Those are unrelated.

https://github.com/llvm/llvm-project/pull/84322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [polly] [clang-tools-extra] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)

2024-02-01 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/78549
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [polly] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)

2024-02-01 Thread Michael Kruse via cfe-commits


@@ -0,0 +1,32 @@
+//===-PollyDebug.inc -Provide support for debugging Polly passes-*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Functions to aid printing Debug Info of all polly passes.
+//
+//===--===//
+
+#ifndef POLLY_DEBUG_H
+#define POLLY_DEBUG_H
+
+#include "llvm/Support/Debug.h"
+namespace polly {
+using namespace llvm;
+bool getPollyDebugFlag();
+#ifndef NDEBUG
+#undef LLVM_DEBUG
+#define LLVM_DEBUG(X)  
\

Meinersbur wrote:

This conflicts with an existing symbol in LLVM itself. I don't think it's a 
good idea to overload it for polly. 

You could call it `POLLY_DEBUG`. This will require a search&replace, but IMHO 
highly preferably over a a header include fiasco.

https://github.com/llvm/llvm-project/pull/78549
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [polly] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)

2024-02-01 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/78549
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [polly] [clang] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)

2024-02-01 Thread Michael Kruse via cfe-commits


@@ -0,0 +1,32 @@
+//===-PollyDebug.inc -Provide support for debugging Polly passes-*- C++ 
-*-===//

Meinersbur wrote:

Please use a `.h` extension for this file, it's a normal header file

https://github.com/llvm/llvm-project/pull/78549
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 24ab9b5 - Generalize the pass registration mechanism used by Polly to any third-party tool

2020-01-08 Thread Michael Kruse via cfe-commits
Am Di., 7. Jan. 2020 um 18:57 Uhr schrieb Eric Christopher via
cfe-commits :
>> Is there anything I should have done? Probably reaching llvm-dev before
>> commiting. Reaching the right reviewers has always been a challenge to me, I 
>> had
>> hoped that the mail to llvm-dev would trigger some subscription :-)
>
>
> Hrm. Probably finding some different reviewers, but I can't fault your 
> attempts here. Usually you can look at the last few people to make 
> substantial work in an area and loop them in via git log. :)

In my experience adding more reviewers usually rarely to more people
looking into the patch. Especially the people that make substantial
work in an area and/or are code owners are added as reviewers to very
many commits and cannot look into all of them.
Note that in the patch in question, there are comments from people not
in the reviewer list. For example, Mehdi with whom I also talked about
this patch at the last LLVM DevMtg.

We also have a policy that allows post-commit reviews and reverts.
Therefore I think we should not put that bar for allowing to commit
too high.


>> >  ; CHECK-EP-VECTORIZER-START-NEXT: Running pass: NoOpFunctionPass
>> > +; CHECK-EXT: Running pass: {{.*}}::Bye on foo
>> >
>> > Why is this running on every test of the pass manager? It should be an 
>> > example
>> > run in the examples directory and not on by default? Same for every other 
>> > PM
>> > test. This seems like a bug?
>>
>> It's not. When the examples are active and if the appropriate cmake flag is 
>> set
>> (which is not the case by default), the pass is linked in statically, and is 
>> run
>> in the default pipeline. The CHECK-EXT prefix is disabled otherwise. That's 
>> one
>> of the configuration I did test :-)
>>
>
> I really don't think this is ideal. The examples directory shouldn't affect 
> tests being run or not or in what way. Can we back this part out and talk 
> about it a bit more? I don't think we should need to do this to test the 
> functionality.

In a previous discussion [1] we discussed adding tutorial code to
repository which naturally should also be tested to avoid bit-rot. How
do you suggest to testing of examples should work? Note that LLVMHello
is also tested, but not in the example directory.

For this patch I suggested in the review to add another flag to the
Bye example and only if set the the Bye pass is added to the pass
manager (but in a different context: to avoid shell expansion hack
that would not run on Windows anyway). This would stop the pass
pipeline pass to fail because of a new pass in there and can be tested
separately. At the end I had no preference of how it should be tested.

[1] http://lists.llvm.org/pipermail/llvm-dev/2019-October/136159.html
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 24ab9b5 - Generalize the pass registration mechanism used by Polly to any third-party tool

2020-01-09 Thread Michael Kruse via cfe-commits
Am Mi., 8. Jan. 2020 um 17:20 Uhr schrieb Eric Christopher :
>
>
>
> On Wed, Jan 8, 2020 at 3:07 PM Michael Kruse  
> wrote:
>>
>> Am Di., 7. Jan. 2020 um 18:57 Uhr schrieb Eric Christopher via
>> cfe-commits :
>> >> Is there anything I should have done? Probably reaching llvm-dev before
>> >> commiting. Reaching the right reviewers has always been a challenge to 
>> >> me, I had
>> >> hoped that the mail to llvm-dev would trigger some subscription :-)
>> >
>> >
>> > Hrm. Probably finding some different reviewers, but I can't fault your 
>> > attempts here. Usually you can look at the last few people to make 
>> > substantial work in an area and loop them in via git log. :)
>>
>> In my experience adding more reviewers usually rarely to more people
>> looking into the patch. Especially the people that make substantial
>> work in an area and/or are code owners are added as reviewers to very
>> many commits and cannot look into all of them.
>
>
> As one of those added to a lot of patches I have a lot of sympathy here. The 
> answer isn't to avoid adding people with expertise in an area and no one on 
> the approval list had expertise or had recently hacked on the code.

For some parts you won't find people that recently worked on the code
other than refactoring, such as the legacy pass manager. Together with
Tobias Grosser, I worked out the mechanism that statically linked
Polly into tools which was generalized in this patch. I am not sure
what else would be required to approve this patch.


>
>>
>> Note that in the patch in question, there are comments from people not
>> in the reviewer list. For example, Mehdi with whom I also talked about
>> this patch at the last LLVM DevMtg.
>>
>
> Yes, but none of them ack'd it.

Mehdi did in the comments (and personally at the DevMtg). He just did
not approve the patch because I still had concerns. By coding policy,
only one approval is required.



>> >> >  ; CHECK-EP-VECTORIZER-START-NEXT: Running pass: NoOpFunctionPass
>> >> > +; CHECK-EXT: Running pass: {{.*}}::Bye on foo
>> >> >
>> >> > Why is this running on every test of the pass manager? It should be an 
>> >> > example
>> >> > run in the examples directory and not on by default? Same for every 
>> >> > other PM
>> >> > test. This seems like a bug?
>> >>
>> >> It's not. When the examples are active and if the appropriate cmake flag 
>> >> is set
>> >> (which is not the case by default), the pass is linked in statically, and 
>> >> is run
>> >> in the default pipeline. The CHECK-EXT prefix is disabled otherwise. 
>> >> That's one
>> >> of the configuration I did test :-)
>> >>
>> >
>> > I really don't think this is ideal. The examples directory shouldn't 
>> > affect tests being run or not or in what way. Can we back this part out 
>> > and talk about it a bit more? I don't think we should need to do this to 
>> > test the functionality.
>>
>> In a previous discussion [1] we discussed adding tutorial code to
>> repository which naturally should also be tested to avoid bit-rot. How
>> do you suggest to testing of examples should work? Note that LLVMHello
>> is also tested, but not in the example directory.
>
>
> llvm/tests/examples?

The point is, we don't have an established pattern of how to test
examples yet, and I would also like that we develop one. I also think
this was not in the scope of this patch.


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


[clang] e5dba2d - [OMPIRBuilder] Start 'Create' methods with lower case. NFC.

2020-11-09 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2020-11-09T19:35:11-06:00
New Revision: e5dba2d7e5a6ab8266954e13844355d795c8c88b

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

LOG: [OMPIRBuilder] Start 'Create' methods with lower case. NFC.

For consistency with the IRBuilder, OpenMPIRBuilder has method names starting 
with 'Create'. However, the LLVM coding style has methods names starting with 
lower case letters, as all other OpenMPIRBuilder already methods do. The 
clang-tidy configuration used by Phabricator also warns about the naming 
violation, adding noise to the reviews.

This patch renames all `OpenMPIRBuilder::CreateXYZ` methods to 
`OpenMPIRBuilder::createXYZ`, and updates all in-tree callers.

I tested check-llvm, check-clang, check-mlir and check-flang to ensure that I 
did not miss a caller.

Reviewed By: mehdi_amini, fghanim

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 017e8f2e3472..3713c672b053 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2260,7 +2260,7 @@ void CGOpenMPRuntime::emitTaskyieldCall(CodeGenFunction 
&CGF,
   if (!CGF.HaveInsertPoint())
 return;
   if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
-OMPBuilder.CreateTaskyield(CGF.Builder);
+OMPBuilder.createTaskyield(CGF.Builder);
   } else {
 // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
 llvm::Value *Args[] = {
@@ -2515,7 +2515,7 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction 
&CGF, SourceLocation Loc,
   auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo);
   if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
-CGF.Builder.restoreIP(OMPBuilder.CreateBarrier(
+CGF.Builder.restoreIP(OMPBuilder.createBarrier(
 CGF.Builder, Kind, ForceSimpleCall, EmitChecks));
 return;
   }
@@ -2877,7 +2877,7 @@ void CGOpenMPRuntime::emitProcBindClause(CodeGenFunction 
&CGF,
 void CGOpenMPRuntime::emitFlush(CodeGenFunction &CGF, ArrayRef,
 SourceLocation Loc, llvm::AtomicOrdering AO) {
   if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
-OMPBuilder.CreateFlush(CGF.Builder);
+OMPBuilder.createFlush(CGF.Builder);
   } else {
 if (!CGF.HaveInsertPoint())
   return;
@@ -6187,7 +6187,7 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF,
 return;
 
   if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
-OMPBuilder.CreateTaskwait(CGF.Builder);
+OMPBuilder.createTaskwait(CGF.Builder);
   } else {
 // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
 // global_tid);

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 5884dfd2bc3f..2fb4144930df 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1614,11 +1614,11 @@ Address 
CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(
 Allocator = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Allocator,
 CGM.VoidPtrTy);
 
-  llvm::Value *Addr = OMPBuilder.CreateOMPAlloc(
+  llvm::Value *Addr = OMPBuilder.createOMPAlloc(
   CGF.Builder, Size, Allocator,
   getNameWithSeparators({CVD->getName(), ".void.addr"}, ".", "."));
   llvm::CallInst *FreeCI =
-  OMPBuilder.CreateOMPFree(CGF.Builder, Addr, Allocator);
+  OMPBuilder.createOMPFree(CGF.Builder, Addr, Allocator);
 
   CGF.EHStack.pushCleanup(NormalAndEHCleanup, FreeCI);
   Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
@@ -1646,7 +1646,7 @@ Address 
CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
   llvm::Twine CacheName = Twine(CGM.getMangledName(VD)).concat(Suffix);
 
   llvm::CallInst *ThreadPrivateCacheCall =
-  OMPBuilder.CreateCachedThreadPrivate(CGF.Builder, Data, Size, CacheName);
+  OMPBuilder.createCachedThreadPrivate(CGF.Builder, Data, Size, CacheName);
 
   return Address(ThreadPrivateCacheCall, VDAddr.getAlignment());
 }
@@ -1718,7 +1718,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective &S) {
 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
 AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
 Builder.restoreIP(
-OMPBuilder.CreateParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
+OMPBuilder.createParal

[clang] 83ff0ff - [Clang][OpenMP] Allow unified_shared_memory for Pascal-generation GPUs.

2021-05-13 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-05-13T17:15:34-05:00
New Revision: 83ff0ff46337422171fb36f934bd56c2bc1be15c

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

LOG: [Clang][OpenMP] Allow unified_shared_memory for Pascal-generation GPUs.

The Pascal architecture supports the page migration engine required for
unified_shared_memory, as indicated by NVIDIA:
 * https://developer.nvidia.com/blog/unified-memory-cuda-beginners/
 * 
https://developer.nvidia.com/blog/beyond-gpu-memory-limits-unified-memory-pascal/
 * 
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-requirements

The limitation was introduced in D54493 which justified the cut-off by
the requirement for unified addressing. However, Unified Virtual
Addressing (UVA) is already available with sm20 (Fermi, Kepler,
Maxwell):
 * 
https://docs.nvidia.com/cuda/gpudirect-rdma/index.html#basics-of-uva-cuda-memory-management

Unified shared memory might even be possible with these, but with
migration of entire allocations on kernel startup.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/test/OpenMP/requires_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index fd492eaf705d0..2ceb3a4cd5ab6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -4441,10 +4441,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::SM_37:
   case CudaArch::SM_50:
   case CudaArch::SM_52:
-  case CudaArch::SM_53:
-  case CudaArch::SM_60:
-  case CudaArch::SM_61:
-  case CudaArch::SM_62: {
+  case CudaArch::SM_53: {
 SmallString<256> Buffer;
 llvm::raw_svector_ostream Out(Buffer);
 Out << "Target architecture " << CudaArchToString(Arch)
@@ -4452,6 +4449,9 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
 CGM.Error(Clause->getBeginLoc(), Out.str());
 return;
   }
+  case CudaArch::SM_60:
+  case CudaArch::SM_61:
+  case CudaArch::SM_62:
   case CudaArch::SM_70:
   case CudaArch::SM_72:
   case CudaArch::SM_75:

diff  --git a/clang/test/OpenMP/requires_codegen.cpp 
b/clang/test/OpenMP/requires_codegen.cpp
index 84821e89ed24f..1029a865b92a2 100644
--- a/clang/test/OpenMP/requires_codegen.cpp
+++ b/clang/test/OpenMP/requires_codegen.cpp
@@ -8,9 +8,9 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_50 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_52 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_53 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_70 -emit-llvm %s 
-fope

[clang] 07a6beb - [Clang][OpenMP] Emit dependent PreInits before directive.

2021-06-02 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-06-02T16:59:35-05:00
New Revision: 07a6beb402150d25ec7c93a5747520ac2804731d

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

LOG: [Clang][OpenMP] Emit dependent PreInits before directive.

The PreInits of a loop transformation (atm moment only tile) include the 
computation of the trip count. The trip count is needed by any loop-associated 
directives that consumes the transformation-generated loop. Hence, we must 
ensure that the PreInits of consumed loop transformations are emitted with the 
consuming directive.

This is done by addinging the inner loop transformation's PreInits to the outer 
loop-directive's PreInits. The outer loop-directive will consume the de-sugared 
AST such that the inner PreInits are not emitted twice. The PreInits of a loop 
transformation are still emitted directly if its generated loop(s) are not 
associated with another loop-associated directive.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/tile_codegen_for_dependent.cpp
clang/test/OpenMP/tile_codegen_tile_for.cpp

Modified: 
clang/include/clang/AST/StmtOpenMP.h
clang/lib/AST/StmtOpenMP.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/tile_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 4d14848830fa7..4d6774c1ad280 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -882,17 +882,45 @@ class OMPLoopBasedDirective : public 
OMPExecutableDirective {
   TryImperfectlyNestedLoops);
   }
 
+  /// Calls the specified callback function for all the loops in \p CurStmt,
+  /// from the outermost to the innermost.
+  static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,
+llvm::function_ref 
Callback,
+llvm::function_ref
+OnTransformationCallback);
+  static bool
+  doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,
+llvm::function_ref Callback,
+llvm::function_ref
+OnTransformationCallback) {
+auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
+  return Callback(Cnt, CurStmt);
+};
+auto &&NewTransformCb =
+[OnTransformationCallback](OMPLoopBasedDirective *A) {
+  OnTransformationCallback(A);
+};
+return doForAllLoops(const_cast(CurStmt), 
TryImperfectlyNestedLoops,
+ NumLoops, NewCallback, NewTransformCb);
+  }
+
   /// Calls the specified callback function for all the loops in \p CurStmt,
   /// from the outermost to the innermost.
   static bool
   doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
 unsigned NumLoops,
-llvm::function_ref Callback);
+llvm::function_ref Callback) {
+auto &&TransformCb = [](OMPLoopBasedDirective *) {};
+return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, 
Callback,
+ TransformCb);
+  }
   static bool
   doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
 unsigned NumLoops,
 llvm::function_ref Callback) {
-auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
+auto &&NewCallback = [Callback](unsigned Cnt, const Stmt *CurStmt) {
   return Callback(Cnt, CurStmt);
 };
 return doForAllLoops(const_cast(CurStmt), 
TryImperfectlyNestedLoops,

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index a9905949d7afa..dbb11e77ac51e 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -124,11 +124,15 @@ OMPLoopBasedDirective::tryToFindNextInnerLoop(Stmt 
*CurStmt,
 
 bool OMPLoopBasedDirective::doForAllLoops(
 Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
-llvm::function_ref Callback) {
+llvm::function_ref Callback,
+llvm::function_ref
+OnTransformationCallback) {
   CurStmt = CurStmt->IgnoreContainers();
   for (unsigned Cnt = 0; Cnt < NumLoops; ++Cnt) {
-if (auto *Dir = dyn_cast(CurStmt))
+while (auto *Dir = dyn_cast(CurStmt)) {
+  OnTransformationCallback(Dir);
   CurStmt = Dir->getTransformedStmt();
+}
 if (auto *CanonLoop = dyn_cast(CurStmt))
   CurStmt = CanonLoop->getLoopStmt();
 if (Callback(Cnt, CurStmt))

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 344fa90253ec3..a03cbffc8e8f1 100644
--- a/clang/li

[clang] 64e5a3b - [clang] Fix fail of OpenMP/tile_codegen_tile_for.cpp.

2021-06-02 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-06-02T21:02:05-05:00
New Revision: 64e5a3bbdde25af0fd9f2b9b8539e23f36c80601

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

LOG: [clang] Fix fail of OpenMP/tile_codegen_tile_for.cpp.

Clang's version string can be customized using CLANG_VENDOR which the
test did not consider. Change the test to accept any version string.

Added: 


Modified: 
clang/test/OpenMP/tile_codegen_tile_for.cpp

Removed: 




diff  --git a/clang/test/OpenMP/tile_codegen_tile_for.cpp 
b/clang/test/OpenMP/tile_codegen_tile_for.cpp
index 314446ca203bf..e4e5548b2f933 100644
--- a/clang/test/OpenMP/tile_codegen_tile_for.cpp
+++ b/clang/test/OpenMP/tile_codegen_tile_for.cpp
@@ -247,7 +247,7 @@ extern "C" void func(int start, int end, int step) {
 
 #endif /* HEADER */
 // IR: ![[META0:[0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-// IR: ![[META1:[0-9]+]] = !{!"clang version {{[^"]*}}"}
+// IR: ![[META1:[0-9]+]] = !{!"{{[^"]*}}"}
 // IR: ![[LOOP2]] = distinct !{![[LOOP2]], ![[LOOPPROP3:[0-9]+]]}
 // IR: ![[LOOPPROP3]] = !{!"llvm.loop.mustprogress"}
 // IR: ![[LOOP4]] = distinct !{![[LOOP4]], ![[LOOPPROP3]]}



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


[clang] 74ddacd - [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

2021-02-13 Thread Michael Kruse via cfe-commits

Author: Malhar
Date: 2021-02-13T17:35:54-06:00
New Revision: 74ddacd30de54e19b28218bc8563bd0f34f32cad

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

LOG: [Clang] Ensure vector predication loop metadata is always emitted when 
pragma is specified.

This patch ensures that vector predication and vectorization width
pragmas work together correctly/as expected. Specifically, this patch
fixes the issue that when vectorization_width > 1, the vector
predication behaviour (this would matter if it has NOT been disabled
explicitly by a pragma) was getting ignored, which was incorrect.

The fix here removes the dependence of vector predication on the
vectorization width. The loop metadata corresponding to clang loop
pragma vectorize_predicate is always emitted, if the pragma is
specified, even if vectorization is disabled by vectorize_width(1)
or vectorize(disable) since the option is also used for interleaving
by the LoopVectorize pass.

Reviewed By: dmgreen, Meinersbur

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

Added: 


Modified: 
clang/lib/CodeGen/CGLoopInfo.cpp
clang/test/CodeGenCXX/pragma-loop-predicate.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGLoopInfo.cpp 
b/clang/lib/CodeGen/CGLoopInfo.cpp
index 8ba40599cfaf..12a6cd8da603 100644
--- a/clang/lib/CodeGen/CGLoopInfo.cpp
+++ b/clang/lib/CodeGen/CGLoopInfo.cpp
@@ -250,12 +250,10 @@ LoopInfo::createLoopVectorizeMetadata(const 
LoopAttributes &Attrs,
   Args.push_back(nullptr);
   Args.append(LoopProperties.begin(), LoopProperties.end());
 
-  // Setting vectorize.predicate
+  // Setting vectorize.predicate when it has been specified and vectorization
+  // has not been disabled.
   bool IsVectorPredicateEnabled = false;
-  if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
-  Attrs.VectorizeEnable != LoopAttributes::Disable &&
-  Attrs.VectorizeWidth < 1) {
-
+  if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified) {
 IsVectorPredicateEnabled =
 (Attrs.VectorizePredicateEnable == LoopAttributes::Enable);
 
@@ -303,7 +301,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes 
&Attrs,
   //explicitly requested fixed-width vectorization, i.e.
   //vectorize.scalable.enable is false.
   if (Attrs.VectorizeEnable != LoopAttributes::Unspecified ||
-  IsVectorPredicateEnabled || Attrs.VectorizeWidth > 1 ||
+  (IsVectorPredicateEnabled && Attrs.VectorizeWidth != 1) ||
+  Attrs.VectorizeWidth > 1 ||
   Attrs.VectorizeScalable == LoopAttributes::Enable ||
   (Attrs.VectorizeScalable == LoopAttributes::Disable &&
Attrs.VectorizeWidth != 1)) {

diff  --git a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp 
b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp
index ec8f82ef9b9e..8a25ed8de623 100644
--- a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp
+++ b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp
@@ -58,6 +58,49 @@ void test5(int *List, int Length) {
 List[i] = i * 2;
 }
 
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test6(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test6{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test7(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test7{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test8(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test8{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]]
+
+#pragma clang loop vectorize_predicate(enable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test9(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test9{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]]
+
+#pragma clang loop vectorize_predicate(enable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
 // CHECK:  ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], 
[[GEN3:![0-9]+]]}
 // CHECK:  [[MP]] = !{!"llvm.loop.mustprogress"}
 // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true}
@@ -73,4 +116,14 @@ void test5(int *List, int Length) {
 // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]}
 // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1}
 
-// CHECK-NEXT: ![

[clang] d466ca0 - [Clang][OpenMP] Add static version of getSingleClause. NFC.

2021-06-06 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-06-06T09:17:42-05:00
New Revision: d466ca087aae958d1c0a965c561be07d2cb3e7e2

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

LOG: [Clang][OpenMP] Add static version of getSingleClause. NFC.

The current method getSingleClause requires an instance of 
OMPExecutableDirective to be called. Introduce a static version taking a list 
of clauses as argument instead that can be used during parsing/Sema before any 
OMPExecutableDirective has been created.

This is the same approach as taken for getClausesOfKind for getting more more 
than a single clause of a type which also has a method and static version. NFC 
patch extracted out of D99459 by request.

Reviewed By: ABataev

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 4d6774c1ad280..67ba77a5d1b06 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -460,17 +460,22 @@ class OMPExecutableDirective : public Stmt {
   /// directive). Returns nullptr if no clause of this kind is associated with
   /// the directive.
   template 
-  const SpecificClause *getSingleClause() const {
-auto Clauses = getClausesOfKind();
+  static const SpecificClause *getSingleClause(ArrayRef Clauses) {
+auto ClausesOfKind = getClausesOfKind(Clauses);
 
-if (Clauses.begin() != Clauses.end()) {
-  assert(std::next(Clauses.begin()) == Clauses.end() &&
+if (ClausesOfKind.begin() != ClausesOfKind.end()) {
+  assert(std::next(ClausesOfKind.begin()) == ClausesOfKind.end() &&
  "There are at least 2 clauses of the specified kind");
-  return *Clauses.begin();
+  return *ClausesOfKind.begin();
 }
 return nullptr;
   }
 
+  template 
+  const SpecificClause *getSingleClause() const {
+return getSingleClause(clauses());
+  }
+
   /// Returns true if the current directive has one or more clauses of a
   /// specific kind.
   template 



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


[clang] c41a8fb - [Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.

2021-06-06 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-06-06T09:49:46-05:00
New Revision: c41a8fbfbb096995367947e5ef7d36501b04d493

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

LOG: [Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.

Multiple clauses are mutually exclusive. This patch refactors the functions 
that check for pairs of mutually exclusive clauses into a generalized function 
which also also accepts a list of clause types if which at most one can appear.

NFC patch extracted out of D99459 by request.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 514b3b9ed05fe..aae84bf3b35c3 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -10121,14 +10121,14 @@ 
Sema::ActOnOpenMPParallelSectionsDirective(ArrayRef Clauses,
   DSAStack->getTaskgroupReductionRef(), DSAStack->isCancelRegion());
 }
 
-/// detach and mergeable clauses are mutially exclusive, check for it.
-static bool checkDetachMergeableClauses(Sema &S,
-ArrayRef Clauses) {
+/// Find and diagnose mutually exclusive clause kinds.
+static bool checkMutuallyExclusiveClauses(
+Sema &S, ArrayRef Clauses,
+ArrayRef MutuallyExclusiveClauses) {
   const OMPClause *PrevClause = nullptr;
   bool ErrorFound = false;
   for (const OMPClause *C : Clauses) {
-if (C->getClauseKind() == OMPC_detach ||
-C->getClauseKind() == OMPC_mergeable) {
+if (llvm::is_contained(MutuallyExclusiveClauses, C->getClauseKind())) {
   if (!PrevClause) {
 PrevClause = C;
   } else if (PrevClause->getClauseKind() != C->getClauseKind()) {
@@ -10153,7 +10153,8 @@ StmtResult 
Sema::ActOnOpenMPTaskDirective(ArrayRef Clauses,
   // OpenMP 5.0, 2.10.1 task Construct
   // If a detach clause appears on the directive, then a mergeable clause 
cannot
   // appear on the same directive.
-  if (checkDetachMergeableClauses(*this, Clauses))
+  if (checkMutuallyExclusiveClauses(*this, Clauses,
+{OMPC_detach, OMPC_mergeable}))
 return StmtError();
 
   auto *CS = cast(AStmt);
@@ -11457,28 +11458,6 @@ StmtResult 
Sema::ActOnOpenMPCancelDirective(ArrayRef Clauses,
 CancelRegion);
 }
 
-static bool checkGrainsizeNumTasksClauses(Sema &S,
-  ArrayRef Clauses) {
-  const OMPClause *PrevClause = nullptr;
-  bool ErrorFound = false;
-  for (const OMPClause *C : Clauses) {
-if (C->getClauseKind() == OMPC_grainsize ||
-C->getClauseKind() == OMPC_num_tasks) {
-  if (!PrevClause)
-PrevClause = C;
-  else if (PrevClause->getClauseKind() != C->getClauseKind()) {
-S.Diag(C->getBeginLoc(), diag::err_omp_clauses_mutually_exclusive)
-<< getOpenMPClauseName(C->getClauseKind())
-<< getOpenMPClauseName(PrevClause->getClauseKind());
-S.Diag(PrevClause->getBeginLoc(), diag::note_omp_previous_clause)
-<< getOpenMPClauseName(PrevClause->getClauseKind());
-ErrorFound = true;
-  }
-}
-  }
-  return ErrorFound;
-}
-
 static bool checkReductionClauseWithNogroup(Sema &S,
 ArrayRef Clauses) {
   const OMPClause *ReductionClause = nullptr;
@@ -11529,7 +11508,8 @@ StmtResult Sema::ActOnOpenMPTaskLoopDirective(
   // OpenMP, [2.9.2 taskloop Construct, Restrictions]
   // The grainsize clause and num_tasks clause are mutually exclusive and may
   // not appear on the same taskloop directive.
-  if (checkGrainsizeNumTasksClauses(*this, Clauses))
+  if (checkMutuallyExclusiveClauses(*this, Clauses,
+{OMPC_grainsize, OMPC_num_tasks}))
 return StmtError();
   // OpenMP, [2.9.2 taskloop Construct, Restrictions]
   // If a reduction clause is present on the taskloop directive, the nogroup
@@ -11577,7 +11557,8 @@ StmtResult Sema::ActOnOpenMPTaskLoopSimdDirective(
   // OpenMP, [2.9.2 taskloop Construct, Restrictions]
   // The grainsize clause and num_tasks clause are mutually exclusive and may
   // not appear on the same taskloop directive.
-  if (checkGrainsizeNumTasksClauses(*this, Clauses))
+  if (checkMutuallyExclusiveClauses(*this, Clauses,
+{OMPC_grainsize, OMPC_num_tasks}))
 return StmtError();
   // OpenMP, [2.9.2 taskloop Construct, Restrictions]
   // If a reduction clause is present on the taskloop directive, the nogroup
@@ -11615,7 +11596,8 @@ StmtResult Sema::ActOnOpenMPMasterTaskLoopDirective(
   // OpenMP, [2.9.2 taskloop Construct, Restrictions]
   // The grainsize claus

[clang] 0e25867 - [Preprocessor] Ensure newline after #pragma introduced by -fms-extensions.

2021-08-01 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-08-01T19:08:13-05:00
New Revision: 0e2586779ca6606a3df085f253a31b89b8ad8508

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

LOG: [Preprocessor] Ensure newline after #pragma introduced by -fms-extensions.

The -fms-extensions converts __pragma (and _Pragma) into a #pragma that
has to occur at the beginning of a line and end with a newline. This
patch ensures that the newline after the #pragma is added even if
Token::isAtStartOfLine() indicated that we should not start a newline.

Committing relying post-commit review since the change is small, some
downstream uses might be blocked without this fix, and to make clear the
decision of the new -fminimize-whitespace feature (fix on main, revert
on clang-13.x branch) suggested by @aaron.ballman in D104601.

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

Added: 
clang/test/Preprocessor/whitespace-ms-extensions.c

Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 1759485de24db..1a820ad985a4c 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -646,7 +646,9 @@ void 
PrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(const Token &Tok,
!Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end)))
 return;
 
-  if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) {
+  // EmittedDirectiveOnThisLine takes priority over RequireSameLine.
+  if ((!RequireSameLine || EmittedDirectiveOnThisLine) &&
+  MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) {
 if (MinimizeWhitespace) {
   // Avoid interpreting hash as a directive under -fpreprocessed.
   if (Tok.is(tok::hash))

diff  --git a/clang/test/Preprocessor/whitespace-ms-extensions.c 
b/clang/test/Preprocessor/whitespace-ms-extensions.c
new file mode 100644
index 0..5fd34fbc6a819
--- /dev/null
+++ b/clang/test/Preprocessor/whitespace-ms-extensions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s 
--check-prefix=MSEXT
+
+// -fms-extensions changes __pragma into #pragma
+// Ensure that there is a newline after the #pragma line.
+
+#define MACRO\
+text \
+__pragma(PRAGMA) \
+after
+
+before MACRO text
+
+
+// CHECK:  before text __pragma(PRAGMA) after text
+
+// MSEXT:  before text
+// MSEXT-NEXT: #pragma PRAGMA
+// MSEXT-NEXT: after text



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


[clang] ba2be8d - [clang/OpenMP][docs] Update OpenMP support list for unroll.

2021-08-03 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-08-03T18:11:17-05:00
New Revision: ba2be8deba79f1aa64a86019e78bcd2536b14eb5

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

LOG: [clang/OpenMP][docs] Update OpenMP support list for unroll.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 88d3107c21e7..7291a5cfc5a0 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -302,7 +302,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :good:`done` | D76342  
  |
 
+--+--+--+---+
-| loop extension   | Loop unrolling transformation 
   | :none:`worked on`| 
  |
+| loop extension   | Loop unrolling transformation 
   | :good:`done` | D99459  
  |
 
+--+--+--+---+
 | loop extension   | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :none:`unclaimed`|   
|
 
+--+--+--+---+



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


[clang] b1de32d - [OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.

2021-08-12 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-08-12T21:02:19-05:00
New Revision: b1de32d6ddd90046171ecee0047fbf448a97e16f

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

LOG: [OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.

Add in-source documentation on how CanonicalLoopInfo is intended to be used. In 
particular, clarify what parts of a CanonicalLoopInfo is considered part of the 
loop, that those parts must be side-effect free, and that InsertPoints to 
instructions outside those parts can be expected to be preserved after method 
calls implementing loop-associated directives.

CanonicalLoopInfo are now invalidated after it does not describe canonical loop 
anymore and asserts when trying to use it afterwards.

In addition, rename `createXYZWorkshareLoop` to `applyXYZWorkshareLoop` and 
remove the update location to avoid that the impression that they insert 
something from scratch at that location where in reality its InsertPoint is 
ignored. createStaticWorkshareLoop does not return a CanonicalLoopInfo anymore. 
First, it was not a canonical loop in the clarified sense (containing 
side-effects in form of calls to the OpenMP runtime). Second, it is ambiguous 
which of the two possible canonical loops it should actually return. It will 
not be needed before a feature expected to be introduced in OpenMP 6.0

Also see discussion in D105706.

Reviewed By: ftynse

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index f71f7b24a36ae..2328dd8198426 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3621,7 +3621,8 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.createWorkshareLoop(Builder, CLI, AllocaIP, NeedsBarrier);
+  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
+AllocaIP, NeedsBarrier);
   return;
 }
 

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index ef4e387ec8edc..9e242b04cc6a5 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -257,18 +257,17 @@ class OpenMPIRBuilder {
   ///
   ///  * Sign of the step and the comparison operator might disagree:
   ///
-  ///  for (int i = 0; i < 42; --i)
+  ///  for (int i = 0; i < 42; i -= 1u)
   ///
   //
   /// \param Loc   The insert and source location description.
   /// \param BodyGenCB Callback that will generate the loop body code.
   /// \param Start Value of the loop counter for the first iterations.
-  /// \param Stop  Loop counter values past this will stop the the
-  ///  iterations.
+  /// \param Stop  Loop counter values past this will stop the loop.
   /// \param Step  Loop counter increment after each iteration; negative
-  ///  means counting down. \param IsSigned  Whether Start, 
Stop
-  ///  and Stop are signed integers.
-  /// \param InclusiveStop Whether  \p Stop itself is a valid value for the 
loop
+  ///  means counting down.
+  /// \param IsSigned  Whether Start, Stop and Step are signed integers.
+  /// \param InclusiveStop Whether \p Stop itself is a valid value for the loop
   ///  counter.
   /// \param ComputeIP Insertion point for instructions computing the trip
   ///  count. Can be used to ensure the trip count is available
@@ -335,7 +334,7 @@ class OpenMPIRBuilder {
   ///has a trip count of 0). This is permitted by the OpenMP specification.
   ///
   /// \param DLDebug location for instructions added for collapsing,
-  ///  such as instructions to compute derive the input loop's
+  ///  such as instructions to compute/derive the input loop's
   ///  induction variables.
   /// \param Loops Loops in the loop nest to collapse. Loops are specified
   ///  from outermost-to-innermost and every control flow of a
@@ -358,8 +357,16 @@ class OpenMPIRBuilder {
   /// the current thread, updates the relevant instructions in the canonical
   /// loop and calls to an OpenM

[clang] 8f099d1 - [Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.

2021-11-04 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-11-05T00:43:40-05:00
New Revision: 8f099d17a1bee857ada3c5af032cfcb559252024

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

LOG: [Preprocessor] Fix warning: left and right subexpressions are identical. 
NFCI.

This is reported by msvc as
warning C6287: redundant code: the left and right subexpressions are identical

EmittedDirectiveOnThisLine implies EmittedTokensOnThisLine
making this an NFC change. To be on the safe side and because both of
them are checked at other places as well, we continue to check both.

Compiler warning reported here:
https://reviews.llvm.org/D104601#2957333

Added: 


Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 360fa1448b128..fadf0c054310d 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -700,7 +700,7 @@ void 
PrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(const Token &Tok,
 // - The whitespace is necessary to keep the tokens apart and there is not
 //   already a newline between them
 if (RequireSpace || (!MinimizeWhitespace && Tok.hasLeadingSpace()) ||
-((EmittedTokensOnThisLine || EmittedTokensOnThisLine) &&
+((EmittedTokensOnThisLine || EmittedDirectiveOnThisLine) &&
  AvoidConcat(PrevPrevTok, PrevTok, Tok)))
   OS << ' ';
   }



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


[clang] 1606022 - [Preprocessor] Fix newline before/after _Pragma.

2021-11-04 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-11-05T00:43:40-05:00
New Revision: 1606022fab2d90ed8ee6d15800ec1c2c293db20e

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

LOG: [Preprocessor] Fix newline before/after _Pragma.

The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
SourceLocation to its callback, hence PrintPreprocessedOutput does not
know how many lines to insert between the previous token and the
pragma and does nothing.

With this patch we instead assume that the unknown token is on the same
line as the previous such that we can call the procedure that also emits
semantically significant whitespace.

Fixes bug reported here: https://reviews.llvm.org/D104601#3105044

Added: 
clang/test/Preprocessor/_Pragma-newline.c

Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index fadf0c054310d..45df86ef91cdb 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -188,19 +188,17 @@ class PrintPPOutputPPCallbacks : public PPCallbacks {
   /// @return Whether column adjustments are necessary.
   bool MoveToLine(const Token &Tok, bool RequireStartOfLine) {
 PresumedLoc PLoc = SM.getPresumedLoc(Tok.getLocation());
-if (PLoc.isInvalid())
-  return false;
+unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine;
 bool IsFirstInFile = Tok.isAtStartOfLine() && PLoc.getLine() == 1;
-return MoveToLine(PLoc.getLine(), RequireStartOfLine) || IsFirstInFile;
+return MoveToLine(TargetLine, RequireStartOfLine) || IsFirstInFile;
   }
 
   /// Move to the line of the provided source location. Returns true if a new
   /// line was inserted.
   bool MoveToLine(SourceLocation Loc, bool RequireStartOfLine) {
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);
-if (PLoc.isInvalid())
-  return false;
-return MoveToLine(PLoc.getLine(), RequireStartOfLine);
+unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine;
+return MoveToLine(TargetLine, RequireStartOfLine);
   }
   bool MoveToLine(unsigned LineNo, bool RequireStartOfLine);
 

diff  --git a/clang/test/Preprocessor/_Pragma-newline.c 
b/clang/test/Preprocessor/_Pragma-newline.c
new file mode 100644
index 0..43628eaef4674
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-newline.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -E -o - %s | FileCheck %s
+// RUN: %clang_cc1 -E -P -o - %s | FileCheck %s
+// RUN: %clang_cc1 -E -fminimize-whitespace -o - %s | FileCheck %s
+// RUN: %clang_cc1 -E -fminimize-whitespace -P -o - %s | FileCheck %s
+
+// The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
+// SourceLocation when inside a _Pragma. Ensure we still emit semantic
+// newlines.
+// See report at https://reviews.llvm.org/D104601#3105044
+
+_Pragma("clang assume_nonnull begin") test _Pragma("clang assume_nonnull end")
+
+// CHECK: {{^}}#pragma clang assume_nonnull begin{{$}}
+// CHECK: test
+// CHECK: {{^}}#pragma clang assume_nonnull end{{$}}



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


[clang] bc172e5 - [clang][StaticAnalyzer] Compilation fix.

2021-03-04 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-03-04T23:23:58-06:00
New Revision: bc172e532a89754d47fef1306064a26a4dc0a76b

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

LOG: [clang][StaticAnalyzer] Compilation fix.

An enum was unhandled after landing of D94973. Add the new
OMPCanonicalLoopClass to the list of unhandled cases.

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 465af24b2899..a388fc9e6e26 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1238,6 +1238,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 case Stmt::SEHExceptStmtClass:
 case Stmt::SEHLeaveStmtClass:
 case Stmt::SEHFinallyStmtClass:
+case Stmt::OMPCanonicalLoopClass:
 case Stmt::OMPParallelDirectiveClass:
 case Stmt::OMPSimdDirectiveClass:
 case Stmt::OMPForDirectiveClass:



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


[clang] 4b15b2d - [clang][OpenMP][docs] Update loop transformation status.

2021-03-05 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-03-05T17:26:55-06:00
New Revision: 4b15b2df23389be567814cedcfddc8008c354b3d

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

LOG: [clang][OpenMP][docs] Update loop transformation status.

Mark tiling as done and unrolling as being worked on.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index f0d8e8741304..e66d9a64a93f 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -298,9 +298,9 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | assorted routines for querying interoperable 
properties  | :none:`unclaimed`|
   |
 
+--+--+--+---+
-| loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
+| loop extension   | Loop tiling transformation
   | :good:`done` | D76342  
  |
 
+--+--+--+---+
-| loop extension   | Loop unrolling transformation 
   | :none:`unclaimed`| 
  |
+| loop extension   | Loop unrolling transformation 
   | :none:`worked on`| 
  |
 
+--+--+--+---+
 | loop extension   | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :none:`unclaimed`|   
|
 
+--+--+--+---+



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


Re: Buildbot cleaning for zorg upgrade

2020-02-25 Thread Michael Kruse via cfe-commits
Looking forward to the upgrade. Thanks for investing the time.

I am trying to re-add buildbots for polly-x86_64
(https://reviews.llvm.org/D75127) and I am not use whether you
received my messages about it. In any case, would you prefer to wait
until the new instance of buildbot-master is available?

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


Re: [PATCH] D69897: Add #pragma clang loop vectorize_assume_alignment(n)

2019-11-20 Thread Michael Kruse via cfe-commits
Am Mi., 20. Nov. 2019 um 10:21 Uhr schrieb HAPPY Mahto
:
>> #pragma clang loop vectorize_assume_alignment(32)
>> for(int i = 0;i < n; i++){
>> a[i] = b[i] + i*i;
>> }
>
>  for this all-access inside the loop will be aligned to 32bit,
> ex  IR
>>
>> for.cond: ; preds = %for.inc, %entry
>>   %5 = load i32, i32* %i, align 32, !llvm.access.group !2
>>   %6 = load i32, i32* %n, align 32, !llvm.access.group !2
>>   %cmp = icmp slt i32 %5, %6
>>   br i1 %cmp, label %for.body, label %for.end
>>
>> for.body: ; preds = %for.cond
>>   %7 = load i32, i32* %i, align 32, !llvm.access.group !2
>>   %8 = load i32, i32* %i, align 32, !llvm.access.group !2
>>   %idxprom = sext i32 %8 to i64
>>   %arrayidx = getelementptr inbounds i32, i32* %vla1, i64 %idxprom
>>   store i32 %7, i32* %arrayidx, align 32, !llvm.access.group !2
>>   br label %for.inc
>>
>> for.inc:  ; preds = %for.body
>>   %9 = load i32, i32* %i, align 32, !llvm.access.group !2
>>   %inc = add nsw i32 %9, 1
>>   store i32 %inc, i32* %i, align 32, !llvm.access.group !2
>>   br label %for.cond, !llvm.loop !3
>
> You will not need to create pointers for every array(or operand you want to 
> perform the operation on).

IMHO it is better if the programmer has to. It is not always obvious
which arrays are used in the loop. Also, the information can be used
by other optimzations that the vectorizer.


>>
>> void mult(float* x, int size, float factor){
>>   float* ax = (float*)__builtin_assume_aligned(x, 64);
>>   for (int i = 0; i < size; ++i)
>>  ax[i] *= factor;
>> }

https://godbolt.org/z/Fd6HMe

> the alignment is assumed whereas in #pragma it is set to the number specified.

Semantically, it is the same.

I wonder how you expect the assembly output to change? The
__builtin_assume_aligned, will be picked up by the backend and result
in movaps to be used instead of movups.


> it'll be easier, and having a pragma for doing this will help as it's 
> provided in OMP and intel compilers.

This is a compiler-specific extension. It does not have an influence
on what other compilers do. Even with clang, if you try to do

#pragma clang loop vectorize_assume_alignment(32)
#pragma omp simd
for (int i = 0; i < size; ++i)

clang will silently swallow the vectorize_assume_alignment.


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


[clang] 2a789dd - [OpenMP][Docs] Claim loop tiling.

2019-12-13 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2019-12-13T18:42:52-06:00
New Revision: 2a789dd0ad884cbd73b962b6b07cf48e2178d2c9

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

LOG: [OpenMP][Docs] Claim loop tiling.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 7a70d05ec7ff..faeb831cf10c 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -250,3 +250,5 @@ want to help with the implementation.
 
+==+==+==+===+
 | misc extension   | user-defined function variants with #ifdef 
protection| :part:`worked on`| D71179   
 |
 
+--+--+--+---+
+| loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
++--+--+--+---+



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


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-07-08 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

Using git bisect, I tracked down Flang not working anymore on Windows to this 
PR:

```
> flang-new hello.f90 -o hello
flang-new version 19.0.0git
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\meinersbur\build\llvm-project\release\bin
Build config: +assertions
 "C:\\Users\\meinersbur\\build\\llvm-project\\release\\bin\\flang-new" -fc1 
-triple x86_64-pc-windows-msvc19.40.33811 -emit-obj -fcolor-diagnostics 
-mrelocation-model pic -pic-level 2 -target-cpu x86-64 
--dependent-lib=clang_rt.builtins-x86_64.lib -D_MT --dependent-lib=libcmt 
--dependent-lib=Fortran_main.static.lib 
--dependent-lib=FortranRuntime.static.lib 
--dependent-lib=FortranDecimal.static.lib -D_MSC_VER=1940 
-D_MSC_FULL_VER=194033811 -D_WIN32 -D_M_X64=100 -mframe-pointer=none -o 
"C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o" -x f95-cpp-input 
hello.f90
 "C:\\Program Files\\Microsoft Visual 
Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.40.33807\\bin\\Hostx64\\x64\\link.exe"
 -out:hello "-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib" 
/WHOLEARCHIVE:Fortran_main.static.lib /subsystem:console 
"-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib\\clang\\19\\lib\\windows"
 -nologo "C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o"
LINK : fatal error LNK1104: cannot open file 'clang_rt.builtins.lib'
flang-new: error: linker command failed with exit code 1104 (use -v to see 
invocation)
```

Before this commit, `/DEFAULTLIB:clang_rt.builtins-x86_64.lib` the linking 
directive, now it is `/DEFAULTLIB:clang_rt.builtins-x86_64.lib`. Turns out, 
`clang_rt.builtins-x86_64.lib` is actually shipped with the MSVC compiler 
(`C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\\lib\x64`, possibly for Sanitizer 
support in MSVC), which makes the former work, but not the latter.

With `-DLLVM_ENABLE_PROJECTS=compiler-rt`, the resource-dir 
`build\llvm-project\release\lib\clang\19\lib\windows` is filled with 
`clang_rt.builtins-x86_64.lib` et.al., but also changes it back to 
`/DEFAULTLIB:clang_rt.builtins-x86_64.lib`, and it works again.





https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-07-08 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@dpalermo I added fix as PR #98072

https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Add emitAtomicCompareExchangeBuiltin helper function (PR #101966)

2024-08-12 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

`TargetLibraryInfoImpl` is not contained in the backends, but implemented 
entirely in 
[`TargetLibraryInfo.cpp`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/TargetLibraryInfo.cpp).
 

`TargetLowering` is implemented in the backend, but is also optional. If not 
provided, the max size of atomic operations is assumed to be 16. I think that 
frontends having to resolve the ABI information independently would be worse.

https://github.com/llvm/llvm-project/pull/101966
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] Add --gcc-toolchain and --gcc-install-dir options to flang. (PR #87360)

2024-04-04 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/87360
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur commented:

Not a full a review, but the first notes that I started with

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription &Loc) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder &OMPBuilder,
+ SmallVector &Dependencies) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())

Meinersbur wrote:

```suggestion
  if (Dependencies.empty())
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -2253,7 +2275,8 @@ class OpenMPIRBuilder {
  SmallVectorImpl &Inputs,
  GenMapInfoCallbackTy GenMapInfoCB,
  TargetBodyGenCallbackTy BodyGenCB,
- TargetGenArgAccessorsCallbackTy 
ArgAccessorFuncCB);
+ TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
+ SmallVector Dependencies = {});

Meinersbur wrote:

```suggestion
 ArrayRef Dependencies = {});
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription &Loc) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder &OMPBuilder,
+ SmallVector &Dependencies) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())
+return nullptr;
+
+  IRBuilderBase &Builder = OMPBuilder.Builder;
+  Type *DependInfo = OMPBuilder.DependInfo;
+  Module &M = OMPBuilder.M;
+
+  Value *DepArray = nullptr;
+  if (Dependencies.size()) {
+OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
+Builder.SetInsertPoint(
+&OldIP.getBlock()->getParent()->getEntryBlock().back());
+
+Type *DepArrayTy = ArrayType::get(DependInfo, Dependencies.size());
+DepArray = Builder.CreateAlloca(DepArrayTy, nullptr, ".dep.arr.addr");
+
+unsigned P = 0;
+for (const OpenMPIRBuilder::DependData &Dep : Dependencies) {
+  Value *Base =
+  Builder.CreateConstInBoundsGEP2_64(DepArrayTy, DepArray, 0, P);
+  // Store the pointer to the variable
+  Value *Addr = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::BaseAddr));
+  Value *DepValPtr =
+  Builder.CreatePtrToInt(Dep.DepVal, Builder.getInt64Ty());
+  Builder.CreateStore(DepValPtr, Addr);
+  // Store the size of the variable
+  Value *Size = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::Len));
+  Builder.CreateStore(Builder.getInt64(M.getDataLayout().getTypeStoreSize(
+  Dep.DepValueType)),
+  Size);
+  // Store the dependency kind
+  Value *Flags = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::Flags));
+  Builder.CreateStore(
+  ConstantInt::get(Builder.getInt8Ty(),
+   static_cast(Dep.DepKind)),
+  Flags);

Meinersbur wrote:

Consider adding a comment with a mock source of what is generate here:
```
DepArray[P].BaseAddre = ...
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription &Loc) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder &OMPBuilder,
+ SmallVector &Dependencies) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())
+return nullptr;
+
+  IRBuilderBase &Builder = OMPBuilder.Builder;
+  Type *DependInfo = OMPBuilder.DependInfo;
+  Module &M = OMPBuilder.M;
+
+  Value *DepArray = nullptr;
+  if (Dependencies.size()) {
+OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
+Builder.SetInsertPoint(
+&OldIP.getBlock()->getParent()->getEntryBlock().back());

Meinersbur wrote:

```suggestion
Builder.SetInsertPoint(
&OldIP.getBlock()->getParent()->getEntryBlock().getTerminator());
```
just makes it more explicit. 
Did you consider explicitly passing the AllocaIP, could be needed with combined 
constructs.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1762,6 +1762,26 @@ class OpenMPIRBuilder {
   EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args,
   Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP);
 
+  /// Generate a target-task for the target construct
+  ///
+  /// \param OutlinedFn The outlined device/target kernel function.
+  /// \param OutlinedFnID The ooulined function ID.
+  /// \param EmitTargetCallFallbackCB Call back function to generate host
+  ///fallback code.
+  /// \param Args Data structure holding information about the kernel 
arguments.
+  /// \param DeviceID Identifier for the device via the 'device' clause.
+  /// \param RTLoc Source location identifier
+  /// \param AllocaIP The insertion point to be used for alloca instructions.
+  /// \param Dependencies Vector of DependData objects holding information of
+  ///dependencies as specified by the 'depend' clause.
+  /// \param HasNoWait True if the target construct had 'nowait' on it, false
+  ///otherwise
+  InsertPointTy emitTargetTask(
+  Function *OutlinedFn, Value *OutlinedFnID,
+  EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args,
+  Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP,
+  SmallVector &Dependencies, bool HasNoWait);

Meinersbur wrote:

```suggestion
  ArrayRef Dependencies, bool HasNoWait);
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector &Dependencies,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,

Meinersbur wrote:

[nit] line break

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur commented:

Conceptually, looks quite good. Just some style comments.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.
+static Function *emitProxyTaskFunction(OpenMPIRBuilder &OMPBuilder,
+   IRBuilderBase &Builder,
+   CallInst *StaleCI) {
+  Module &M = OMPBuilder.M;
+  // CalledFunction is the target launch function, i.e.
+  // the function that sets up kernel arguments and calls
+  // __tgt_target_kernel to launch the kernel on the device.
+  Function *CalledFunction = StaleCI->getCalledFunction();
+  OpenMPIRBuilder::InsertPointTy IP(StaleCI->getParent(),
+StaleCI->getIterator());
+  LLVMContext &Ctx = StaleCI->getParent()->getContext();
+  Type *ThreadIDTy = Type::getInt32Ty(Ctx);
+  Type *TaskPtrTy = OMPBuilder.TaskPtr;
+  Type *TaskTy = OMPBuilder.Task;
+  auto ProxyFnTy =
+  FunctionType::get(Builder.getVoidTy(), {ThreadIDTy, TaskPtrTy},
+/* isVarArg */ false);
+  auto ProxyFn = Function::Create(ProxyFnTy, GlobalValue::InternalLinkage,
+  ".omp_target_task_proxy_func",
+  Builder.GetInsertBlock()->getModule());
+
+  BasicBlock *EntryBB =
+  BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
+  Builder.SetInsertPoint(EntryBB);
+
+  bool HasShareds = StaleCI->arg_size() > 1;

Meinersbur wrote:

What is "Shareds"?

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.
+static Function *emitProxyTaskFunction(OpenMPIRBuilder &OMPBuilder,
+   IRBuilderBase &Builder,
+   CallInst *StaleCI) {
+  Module &M = OMPBuilder.M;
+  // CalledFunction is the target launch function, i.e.
+  // the function that sets up kernel arguments and calls
+  // __tgt_target_kernel to launch the kernel on the device.
+  Function *CalledFunction = StaleCI->getCalledFunction();
+  OpenMPIRBuilder::InsertPointTy IP(StaleCI->getParent(),
+StaleCI->getIterator());
+  LLVMContext &Ctx = StaleCI->getParent()->getContext();
+  Type *ThreadIDTy = Type::getInt32Ty(Ctx);
+  Type *TaskPtrTy = OMPBuilder.TaskPtr;
+  Type *TaskTy = OMPBuilder.Task;
+  auto ProxyFnTy =
+  FunctionType::get(Builder.getVoidTy(), {ThreadIDTy, TaskPtrTy},
+/* isVarArg */ false);
+  auto ProxyFn = Function::Create(ProxyFnTy, GlobalValue::InternalLinkage,
+  ".omp_target_task_proxy_func",
+  Builder.GetInsertBlock()->getModule());
+
+  BasicBlock *EntryBB =
+  BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
+  Builder.SetInsertPoint(EntryBB);
+
+  bool HasShareds = StaleCI->arg_size() > 1;
+  // TODO: This is a temporary assert to prove to ourselves that
+  // the outlined target launch function is always going to have
+  // atmost two arguments if there is any data shared between
+  // host and device.
+  assert((!HasShareds || (StaleCI->arg_size() == 2)) &&
+ "StaleCI with shareds should have exactly two arguments.");
+  if (HasShareds) {
+AllocaInst *ArgStructAlloca =
+dyn_cast(StaleCI->getArgOperand(1));
+assert(ArgStructAlloca &&
+   "Unable to find the alloca instruction corresponding to arguments "
+   "for extracted function");
+StructType *ArgStructType =
+dyn_cast(ArgStructAlloca->getAllocatedType());
+LLVM_DEBUG(dbgs() << "ArgStructType = " << *ArgStructType << "\n");
+
+AllocaInst *NewArgStructAlloca =
+Builder.CreateAlloca(ArgStructType, nullptr, "structArg");
+Value *TaskT = ProxyFn->getArg(1);
+Value *ThreadId = ProxyFn->getArg(0);
+LLVM_DEBUG(dbgs() << "TaskT = " << *TaskT << "\n");
+Value *SharedsSize =
+Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
+
+Value *Shareds = Builder.CreateStructGEP(TaskTy, TaskT, 0);
+LoadInst *LoadShared =
+Builder.CreateLoad(PointerType::getUnqual(Ctx), Shareds);
+
+// TODO: Are these alignment values correct?

Meinersbur wrote:

I think `NewArgStructAlloca->getAlign()` shold be sufficient. If the 
alloca/load doesn't have the align set explicitly, `memcpy` should apply 
pointer alignment itself.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >