r365258 - [Rewrite] Extend to further accept CharSourceRange

2019-07-05 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Jul  5 19:55:06 2019
New Revision: 365258

URL: http://llvm.org/viewvc/llvm-project?rev=365258&view=rev
Log:
[Rewrite] Extend to further accept CharSourceRange

Some Rewrite functions are already overloaded to accept
CharSourceRange, and this extends others in the same manner.  I'm
calling these in code that's not ready to upstream, but I figure they
might be useful to others in the meantime.

Reviewed By: jdoerfert

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

Added:
cfe/trunk/unittests/Rewrite/RewriterTest.cpp
Modified:
cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
cfe/trunk/lib/Rewrite/Rewriter.cpp
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Core/Rewriter.h?rev=365258&r1=365257&r2=365258&view=diff
==
--- cfe/trunk/include/clang/Rewrite/Core/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Core/Rewriter.h Fri Jul  5 19:55:06 2019
@@ -84,7 +84,16 @@ public:
   /// in different buffers, this returns an empty string.
   ///
   /// Note that this method is not particularly efficient.
-  std::string getRewrittenText(SourceRange Range) const;
+  std::string getRewrittenText(CharSourceRange Range) const;
+
+  /// getRewrittenText - Return the rewritten form of the text in the specified
+  /// range.  If the start or end of the range was unrewritable or if they are
+  /// in different buffers, this returns an empty string.
+  ///
+  /// Note that this method is not particularly efficient.
+  std::string getRewrittenText(SourceRange Range) const {
+return getRewrittenText(CharSourceRange::getTokenRange(Range));
+  }
 
   /// InsertText - Insert the specified string at the specified location in the
   /// original buffer.  This method returns true (and does nothing) if the 
input
@@ -140,6 +149,13 @@ public:
 
   /// ReplaceText - This method replaces a range of characters in the input
   /// buffer with a new string.  This is effectively a combined "remove/insert"
+  /// operation.
+  bool ReplaceText(CharSourceRange range, StringRef NewStr) {
+return ReplaceText(range.getBegin(), getRangeSize(range), NewStr);
+  }
+
+  /// ReplaceText - This method replaces a range of characters in the input
+  /// buffer with a new string.  This is effectively a combined "remove/insert"
   /// operation.
   bool ReplaceText(SourceRange range, StringRef NewStr) {
 return ReplaceText(range.getBegin(), getRangeSize(range), NewStr);

Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=365258&r1=365257&r2=365258&view=diff
==
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Fri Jul  5 19:55:06 2019
@@ -170,7 +170,7 @@ int Rewriter::getRangeSize(SourceRange R
 /// in different buffers, this returns an empty string.
 ///
 /// Note that this method is not particularly efficient.
-std::string Rewriter::getRewrittenText(SourceRange Range) const {
+std::string Rewriter::getRewrittenText(CharSourceRange Range) const {
   if (!isRewritable(Range.getBegin()) ||
   !isRewritable(Range.getEnd()))
 return {};
@@ -193,7 +193,9 @@ std::string Rewriter::getRewrittenText(S
 
 // Adjust the end offset to the end of the last token, instead of being the
 // start of the last token.
-EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
+if (Range.isTokenRange())
+  EndOff +=
+  Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
 return std::string(Ptr, Ptr+EndOff-StartOff);
   }
 
@@ -203,7 +205,8 @@ std::string Rewriter::getRewrittenText(S
 
   // Adjust the end offset to the end of the last token, instead of being the
   // start of the last token.
-  EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
+  if (Range.isTokenRange())
+EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
 
   // Advance the iterators to the right spot, yay for linear time algorithms.
   RewriteBuffer::iterator Start = RB.begin();

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365258&r1=365257&r2=365258&view=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Fri Jul  5 19:55:06 2019
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(RewriteTests
   RewriteBufferTest.cpp
+  RewriterTest.cpp
   )
 clang_target_link_libraries(RewriteTests
   PRIVATE
   clangRewrite
+  clangTooling
   )

Added: cfe/trunk/unittests/Rewrite/RewriterTest.cpp
URL: 

r365263 - [Rewrite] Try to fix buildbot link fail caused by r365258

2019-07-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Sat Jul  6 06:44:57 2019
New Revision: 365263

URL: http://llvm.org/viewvc/llvm-project?rev=365263&view=rev
Log:
[Rewrite] Try to fix buildbot link fail caused by r365258

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10270

Modified:
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365263&r1=365262&r2=365263&view=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Sat Jul  6 06:44:57 2019
@@ -8,6 +8,7 @@ add_clang_unittest(RewriteTests
   )
 clang_target_link_libraries(RewriteTests
   PRIVATE
+  clangFrontend
   clangRewrite
   clangTooling
   )


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


r365264 - [Rewrite] Try to fix buildbot link fail left by r365263

2019-07-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Sat Jul  6 09:28:32 2019
New Revision: 365264

URL: http://llvm.org/viewvc/llvm-project?rev=365264&view=rev
Log:
[Rewrite] Try to fix buildbot link fail left by r365263

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10272

Modified:
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365264&r1=365263&r2=365264&view=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Sat Jul  6 09:28:32 2019
@@ -10,5 +10,6 @@ clang_target_link_libraries(RewriteTests
   PRIVATE
   clangFrontend
   clangRewrite
+  clangSerialization
   clangTooling
   )


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


r369049 - [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

2019-08-15 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Aug 15 14:17:48 2019
New Revision: 369049

URL: http://llvm.org/viewvc/llvm-project?rev=369049&view=rev
Log:
[Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

I'd like to add these comments to warn others of problems I
encountered when trying to use `RemoveLineIfEmpty`.  I originally
tried to fix the problem, but I realized I could implement the
functionality more easily and efficiently in my calling code where I
can make the simplifying assumption that there are no prior edits to
the line from which text is being removed.  While I've lost the
motivation to write a fix, which doesn't look easy, I figure a warning
to others is better than silence.

I've added a unit test to demonstrate the problem.  I don't know how
to mark it as an expected failure, so I just marked it disabled.

Reviewed By: jkorous

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

Modified:
cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
cfe/trunk/lib/Rewrite/Rewriter.cpp
cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp

Modified: cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Core/Rewriter.h?rev=369049&r1=369048&r2=369049&view=diff
==
--- cfe/trunk/include/clang/Rewrite/Core/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Core/Rewriter.h Thu Aug 15 14:17:48 2019
@@ -46,6 +46,17 @@ public:
 
 /// If true and removing some text leaves a blank line
 /// also remove the empty line (false by default).
+///
+/// FIXME: This sometimes corrupts the file's rewrite buffer due to
+/// incorrect indexing in the implementation (see the FIXME in
+/// clang::RewriteBuffer::RemoveText).  Moreover, it's inefficient because
+/// it must scan the buffer from the beginning to find the start of the
+/// line.  When feasible, it's better for the caller to check for a blank
+/// line and then, if found, expand the removal range to include it.
+/// Checking for a blank line is easy if, for example, the caller can
+/// guarantee this is the first edit of a line.  In that case, it can just
+/// scan before and after the removal range until the next newline or
+/// begin/end of the input.
 bool RemoveLineIfEmpty = false;
 
 RewriteOptions() {}

Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=369049&r1=369048&r2=369049&view=diff
==
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Thu Aug 15 14:17:48 2019
@@ -96,6 +96,17 @@ void RewriteBuffer::RemoveText(unsigned
 }
 if (posI != end() && *posI == '\n') {
   Buffer.erase(curLineStartOffs, lineSize + 1/* + '\n'*/);
+  // FIXME: Here, the offset of the start of the line is supposed to be
+  // expressed in terms of the original input not the "real" rewrite
+  // buffer.  How do we compute that reliably?  It might be tempting to use
+  // curLineStartOffs + OrigOffset - RealOffset, but that assumes the
+  // difference between the original and real offset is the same at the
+  // removed text and at the start of the line, but that's not true if
+  // edits were previously made earlier on the line.  This bug is also
+  // documented by a FIXME on the definition of
+  // clang::Rewriter::RewriteOptions::RemoveLineIfEmpty.  A reproducer for
+  // the implementation below is the test RemoveLineIfEmpty in
+  // clang/unittests/Rewrite/RewriteBufferTest.cpp.
   AddReplaceDelta(curLineStartOffs, -(lineSize + 1/* + '\n'*/));
 }
   }

Modified: cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp?rev=369049&r1=369048&r2=369049&view=diff
==
--- cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp (original)
+++ cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp Thu Aug 15 14:17:48 2019
@@ -14,6 +14,16 @@ using namespace clang;
 
 namespace {
 
+#define EXPECT_OUTPUT(Buf, Output) EXPECT_EQ(Output, writeOutput(Buf))
+
+static std::string writeOutput(const RewriteBuffer &Buf) {
+  std::string Result;
+  raw_string_ostream OS(Result);
+  Buf.write(OS);
+  OS.flush();
+  return Result;
+}
+
 static void tagRange(unsigned Offset, unsigned Len, StringRef tagName,
  RewriteBuffer &Buf) {
   std::string BeginTag;
@@ -40,11 +50,64 @@ TEST(RewriteBuffer, TagRanges) {
   tagRange(Pos, TagStr.size(), "outer", Buf);
   tagRange(Pos, TagStr.size(), "inner", Buf);
 
-  std::string Result;
-  raw_string_ostream OS(Result);
-  Buf.write(OS);
-  OS.flush();
-  EXPECT_EQ(Output, Result);
+  EXPECT_OUTPUT(Buf, Output);
+}
+
+TEST(RewriteBuffer, 

r369619 - [OpenMP] Permit map with DSA on combined directive

2019-08-21 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Aug 21 20:34:30 2019
New Revision: 369619

URL: http://llvm.org/viewvc/llvm-project?rev=369619&view=rev
Log:
[OpenMP] Permit map with DSA on combined directive

For `map`, the following restriction changed in OpenMP 5.0:

* OpenMP 4.5 [2.15.5.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct.

* OpenMP 5.0 [2.19.7.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct unless the construct is a combined construct."

This patch removes this restriction in the case of combined constructs
and OpenMP 5.0, and it updates Sema not to capture a scalar by copy in
the target region when `firstprivate` and `map` appear for that scalar
on a combined target construct.

This patch also adds a fixme to a test that now reveals that a
diagnostic about loop iteration variables is dropped in the case of
OpenMP 5.0.  That bug exists regardless of this patch's changes.

Reviewed By: ABataev, jdoerfert, hfinkel, kkwli0

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

Added:
cfe/trunk/test/OpenMP/target_teams_map_codegen.cpp
Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_private_messages.cpp
cfe/trunk/test/OpenMP/target_teams_map_messages.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=369619&r1=369618&r2=369619&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Wed Aug 21 20:34:30 2019
@@ -756,13 +756,16 @@ public:
   unsigned short CapRegionKind;
 
   unsigned short OpenMPLevel;
+  unsigned short OpenMPCaptureLevel;
 
   CapturedRegionScopeInfo(DiagnosticsEngine &Diag, Scope *S, CapturedDecl *CD,
   RecordDecl *RD, ImplicitParamDecl *Context,
-  CapturedRegionKind K, unsigned OpenMPLevel)
+  CapturedRegionKind K, unsigned OpenMPLevel,
+  unsigned OpenMPCaptureLevel)
   : CapturingScopeInfo(Diag, ImpCap_CapturedRegion),
 TheCapturedDecl(CD), TheRecordDecl(RD), TheScope(S),
-ContextParam(Context), CapRegionKind(K), OpenMPLevel(OpenMPLevel) {
+ContextParam(Context), CapRegionKind(K), OpenMPLevel(OpenMPLevel),
+OpenMPCaptureLevel(OpenMPCaptureLevel) {
 Kind = SK_CapturedRegion;
   }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369619&r1=369618&r2=369619&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug 21 20:34:30 2019
@@ -1421,8 +1421,8 @@ public:
   void RecordParsingTemplateParameterDepth(unsigned Depth);
 
   void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
-   RecordDecl *RD,
-   CapturedRegionKind K);
+   RecordDecl *RD, CapturedRegionKind K,
+   unsigned OpenMPCaptureLevel = 0);
 
   /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
   /// time after they've been popped.
@@ -3979,7 +3979,8 @@ public:
   typedef std::pair CapturedParamNameType;
   void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
 CapturedRegionKind Kind,
-ArrayRef Params);
+ArrayRef Params,
+unsigned OpenMPCaptureLevel = 0);
   StmtResult ActOnCapturedRegionEnd(Stmt *S);
   void ActOnCapturedRegionError();
   RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD,
@@ -9028,7 +9029,9 @@ public:
   /// reference.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.
-  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const;
+  /// \param OpenMPCaptureLevel Capture level within an OpenMP construct.
+  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
+ unsigned OpenMPCaptureLevel) const;
 
   /// Check if the sp

[clang] c85fa79 - [Attr] Fix `-ast-print` for `asm` attribute

2019-11-18 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2019-11-18T11:55:25-05:00
New Revision: c85fa79d3663ecb3117e178b2a79ffa721d18e32

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

LOG: [Attr] Fix `-ast-print` for `asm` attribute

Without this fix, the tests introduced here produce the following
assert fail:

```
clang: /home/jdenny/llvm/clang/include/clang/Basic/AttributeCommonInfo.h:163: 
unsigned int clang::AttributeCommonInfo::getAttributeSpellingListIndex() const: 
Assertion `(isAttributeSpellingListCalculated() || AttrName) && "Spelling 
cannot be found"' failed.
```

The bug was introduced by D67368, which caused `AsmLabelAttr`'s
spelling index to be set to `SpellingNotCalculated`.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-print-attr.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b469217108ce..6d857e832c4b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7019,8 +7019,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   }
 }
 
-NewVD->addAttr(::new (Context) AsmLabelAttr(
-Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
+NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8923,9 +8924,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   if (Expr *E = (Expr*) D.getAsmLabel()) {
 // The parser guarantees this is a string.
 StringLiteral *SE = cast(E);
-NewFD->addAttr(::new (Context)
-   AsmLabelAttr(Context, SE->getStrTokenLoc(0),
-SE->getString(), /*IsLiteralLabel=*/true));
+NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());

diff  --git a/clang/test/AST/ast-print-attr.c b/clang/test/AST/ast-print-attr.c
index 223e27b39790..6448437c5eab 100644
--- a/clang/test/AST/ast-print-attr.c
+++ b/clang/test/AST/ast-print-attr.c
@@ -10,3 +10,8 @@ using B = int ** __ptr32 *[3];
 // FIXME: Too many parens here!
 // CHECK: using C = int ((*))() __attribute__((cdecl));
 using C = int (*)() [[gnu::cdecl]];
+
+// CHECK: int fun_asm() asm("");
+int fun_asm() asm("");
+// CHECK: int var_asm asm("");
+int var_asm asm("");



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


r326332 - Test commit access: apply clang-format suggestion

2018-02-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Feb 28 08:57:33 2018
New Revision: 326332

URL: http://llvm.org/viewvc/llvm-project?rev=326332&view=rev
Log:
Test commit access: apply clang-format suggestion

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=326332&r1=326331&r2=326332&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Feb 28 08:57:33 2018
@@ -3823,8 +3823,8 @@ static void WriteDocumentation(RecordKee
 const Record &Deprecated = *Doc.Documentation->getValueAsDef("Deprecated");
 const StringRef Replacement = Deprecated.getValueAsString("Replacement");
 if (!Replacement.empty())
-  OS << "  This attribute has been superseded by ``"
- << Replacement << "``.";
+  OS << "  This attribute has been superseded by ``" << Replacement
+ << "``.";
 OS << "\n\n";
   }
 


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


r326602 - [Attr] Fix parameter indexing for several attributes

2018-03-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Mar  2 11:03:22 2018
New Revision: 326602

URL: http://llvm.org/viewvc/llvm-project?rev=326602&view=rev
Log:
[Attr] Fix parameter indexing for several attributes

The patch fixes a number of bugs related to parameter indexing in
attributes:

* Parameter indices in some attributes (argument_with_type_tag,
  pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
  and ownership_returns) are specified in source as one-origin
  including any C++ implicit this parameter, were stored as
  zero-origin excluding any this parameter, and were erroneously
  printing (-ast-print) and confusingly dumping (-ast-dump) as the
  stored values.

* For alloc_size, the C++ implicit this parameter was not subtracted
  correctly in Sema, leading to assert failures or to silent failures
  of __builtin_object_size to compute a value.

* For argument_with_type_tag, pointer_with_type_tag, and
  ownership_returns, the C++ implicit this parameter was not added
  back to parameter indices in some diagnostics.

This patch fixes the above bugs and aims to prevent similar bugs in
the future by introducing careful mechanisms for handling parameter
indices in attributes.  ParamIdx stores a parameter index and is
designed to hide the stored encoding while providing accessors that
require each use (such as printing) to make explicit the encoding that
is needed.  Attribute declarations declare parameter index arguments
as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
patch rewrites all attribute arguments that are processed by
checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
argument, which is encoded as a count not an index.

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

Added:
cfe/trunk/test/Sema/attr-ownership.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp
cfe/trunk/test/Sema/error-type-safety.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=326602&r1=326601&r2=326602&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Fri Mar  2 11:03:22 2018
@@ -195,6 +195,120 @@ public:
}
 };
 
+/// A single parameter index whose accessors require each use to make explicit
+/// the parameter index encoding needed.
+class ParamIdx {
+  // Idx is exposed only via accessors that specify specific encodings.
+  unsigned Idx : 30;
+  unsigned HasThis : 1;
+  unsigned IsValid : 1;
+
+  void assertComparable(const ParamIdx &I) const {
+assert(isValid() && I.isValid() &&
+   "ParamIdx must be valid to be compared");
+// It's possible to compare indices from separate functions, but so far
+// it's not proven useful.  Moreover, it might be confusing because a
+// comparison on the results of getASTIndex might be inconsistent with a
+// comparison on the ParamIdx objects themselves.
+assert(HasThis == I.HasThis &&
+   "ParamIdx must be for the same function to be compared");
+  }
+
+public:
+  /// Construct an invalid parameter index (\c isValid returns false and
+  /// accessors fail an assert).
+  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param D is the declaration containing the parameters.  It is used to
+  /// determine if there is a C++ implicit this parameter.
+  ParamIdx(unsigned Idx, const Decl *D)
+  : Idx(Idx), HasThis(false), IsValid(true) {
+if (const auto *FD = dyn_cast(D))
+  HasThis = FD->isCXXInstanceMember();
+  }
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param HasThis specifies whether the function has a C++ implicit this
+  /// parameter.
+  ParamIdx(unsigned Idx, bool HasThis)
+  : Idx(Idx), HasThis(HasThis), IsValid(true) {}
+
+  /// Is this parameter index valid?
+  bool isValid() const { return IsValid; }
+
+  /// Is there a C++ implicit this parameter?
+  bool hasThis() const {
+assert(isValid

r326603 - [Attr] Use -fsyntax-only in test

2018-03-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Mar  2 11:03:27 2018
New Revision: 326603

URL: http://llvm.org/viewvc/llvm-project?rev=326603&view=rev
Log:
[Attr] Use -fsyntax-only in test

Suggested at: https://reviews.llvm.org/D43248

Modified:
cfe/trunk/test/Sema/attr-ownership.c

Modified: cfe/trunk/test/Sema/attr-ownership.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ownership.c?rev=326603&r1=326602&r2=326603&view=diff
==
--- cfe/trunk/test/Sema/attr-ownership.c (original)
+++ cfe/trunk/test/Sema/attr-ownership.c Fri Mar  2 11:03:27 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -fsyntax-only
 
 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error 
{{'ownership_takes' attribute requires parameter 1 to be an identifier}}
 void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 1 argument}}


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


r327405 - Reland "[Attr] Fix parameter indexing for several attributes"

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 07:51:22 2018
New Revision: 327405

URL: http://llvm.org/viewvc/llvm-project?rev=327405&view=rev
Log:
Reland "[Attr] Fix parameter indexing for several attributes"

Relands r326602 (reverted in r326862) with new test and fix for
PR36620.

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

Added:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-ownership.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp
cfe/trunk/test/Sema/error-type-safety.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=327405&r1=327404&r2=327405&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Tue Mar 13 07:51:22 2018
@@ -195,6 +195,128 @@ public:
}
 };
 
+/// A single parameter index whose accessors require each use to make explicit
+/// the parameter index encoding needed.
+class ParamIdx {
+  // Idx is exposed only via accessors that specify specific encodings.
+  unsigned Idx : 30;
+  unsigned HasThis : 1;
+  unsigned IsValid : 1;
+
+  void assertComparable(const ParamIdx &I) const {
+assert(isValid() && I.isValid() &&
+   "ParamIdx must be valid to be compared");
+// It's possible to compare indices from separate functions, but so far
+// it's not proven useful.  Moreover, it might be confusing because a
+// comparison on the results of getASTIndex might be inconsistent with a
+// comparison on the ParamIdx objects themselves.
+assert(HasThis == I.HasThis &&
+   "ParamIdx must be for the same function to be compared");
+  }
+
+public:
+  /// Construct an invalid parameter index (\c isValid returns false and
+  /// accessors fail an assert).
+  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param D is the declaration containing the parameters.  It is used to
+  /// determine if there is a C++ implicit this parameter.
+  ParamIdx(unsigned Idx, const Decl *D)
+  : Idx(Idx), HasThis(false), IsValid(true) {
+assert(Idx >= 1 && "Idx must be one-origin");
+if (const auto *FD = dyn_cast(D))
+  HasThis = FD->isCXXInstanceMember();
+  }
+
+  /// A type into which \c ParamIdx can be serialized.
+  ///
+  /// A static assertion that it's of the correct size follows the \c ParamIdx
+  /// class definition.
+  typedef uint32_t SerialType;
+
+  /// Produce a representation that can later be passed to \c deserialize to
+  /// construct an equivalent \c ParamIdx.
+  SerialType serialize() const {
+return *reinterpret_cast(this);
+  }
+
+  /// Construct from a result from \c serialize.
+  static ParamIdx deserialize(SerialType S) {
+ParamIdx P(*reinterpret_cast(&S));
+assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin");
+return P;
+  }
+
+  /// Is this parameter index valid?
+  bool isValid() const { return IsValid; }
+
+  /// Get the parameter index as it would normally be encoded for attributes at
+  /// the source level of representation: one-origin including any C++ implicit
+  /// this parameter.
+  ///
+  /// This encoding thus makes sense for diagnostics, pretty printing, and
+  /// constructing new attributes from a source-like specification.
+  unsigned getSourceIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+return Idx;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the AST level
+  /// of representation: zero-origin not including any C++ implicit this
+  /// parameter.
+  ///
+  /// This is the encoding primarily used in Sema.  However, in diagnostics,
+  /// Sema uses \c getSourceIndex instead.
+  unsigned getASTIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+assert(Idx >= 1 + HasThis &&
+   "stored index must be base-1 and not specify C++ implicit this");
+return Idx - 1 - HasThis;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the LLVM level
+  /// of representation: zero-origin including any C++ implicit this parameter.
+  ///
+  /// This is the encoding primarily used in CodeGen.
+  unsigned ge

r327456 - [Attr] Merge two dependent tests from different directories

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 15:18:29 2018
New Revision: 327456

URL: http://llvm.org/viewvc/llvm-project?rev=327456&view=rev
Log:
[Attr] Merge two dependent tests from different directories

Suggested at: https://reviews.llvm.org/D43248

Added:
cfe/trunk/test/Misc/attr-print-emit.cpp
  - copied, changed from r327455, cfe/trunk/test/Sema/attr-print.cpp
Removed:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp

Removed: cfe/trunk/test/Frontend/ast-attr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ast-attr.cpp?rev=327455&view=auto
==
--- cfe/trunk/test/Frontend/ast-attr.cpp (original)
+++ cfe/trunk/test/Frontend/ast-attr.cpp (removed)
@@ -1,5 +0,0 @@
-// RUN: %clang -emit-ast -o %t.ast %S/../Sema/attr-print.cpp
-// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %S/../Sema/attr-print.cpp
-
-// %S/../Sema/attr-print.cpp exercises many different attributes, so we reuse
-// it here to check -emit-ast for attributes.

Copied: cfe/trunk/test/Misc/attr-print-emit.cpp (from r327455, 
cfe/trunk/test/Sema/attr-print.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/attr-print-emit.cpp?p2=cfe/trunk/test/Misc/attr-print-emit.cpp&p1=cfe/trunk/test/Sema/attr-print.cpp&r1=327455&r2=327456&rev=327456&view=diff
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Misc/attr-print-emit.cpp Tue Mar 13 15:18:29 2018
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+// RUN: %clang -emit-ast -o %t.ast %s
+// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
 
 // CHECK: void xla(int a) __attribute__((xray_log_args(1)));
 void xla(int a) __attribute__((xray_log_args(1)));

Removed: cfe/trunk/test/Sema/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-print.cpp?rev=327455&view=auto
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Sema/attr-print.cpp (removed)
@@ -1,69 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
-
-// CHECK: void xla(int a) __attribute__((xray_log_args(1)));
-void xla(int a) __attribute__((xray_log_args(1)));
-
-// CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));
-void *as2(int, int) __attribute__((alloc_size(1, 2)));
-// CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));
-void *as1(void *, int) __attribute__((alloc_size(2)));
-
-// CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 
3)));
-void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
-
-// CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));
-char *fmta(int, const char *) __attribute__((format_arg(2)));
-
-// CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));
-void nn(int *, int *) __attribute__((nonnull(1, 2)));
-
-// CHECK: int *aa(int i) __attribute__((alloc_align(1)));
-int *aa(int i) __attribute__((alloc_align(1)));
-
-// CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-// CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-// CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
-void ownr(int) __attribute__((ownership_returns(foo, 1)));
-
-// CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 
3, 2)));
-void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
-// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 
2)));
-void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
-
-class C {
-  // CHECK: void xla(int a) __attribute__((xray_log_args(2)));
-  void xla(int a) __attribute__((xray_log_args(2)));
-
-  // CHECK: void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  // CHECK: void *as1(void *, int) __attribute__((alloc_size(3)));
-  void *as1(void *, int) __attribute__((alloc_size(3)));
-
-  // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 3, 
4)));
-  void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));
-
-  // CHECK: char *fmta(int, const char *) __attribute__((format_arg(3)));
-  char *fmta(int, const char *) __attribute__((format_arg(3)));
-
-  // CHECK: void nn(int *, int *) __attribute__((nonnull(2, 3)));
-  void nn(int *, int *) __attribute__((nonnull(2, 3)));
-
-  // CHECK: int *aa(int i) __attribute__((alloc_align(2)));
-  int *aa(int i) __attribute__((alloc_align(2)));
-
-  // CHECK: void ownt(int *, int *) __attr

[clang] 82e99f5 - [OpenMP] Fix second debug name from map clause

2021-04-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-04-30T16:26:59-04:00
New Revision: 82e99f50351dd83d854f45bab3d91d4e6ad6450e

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

LOG: [OpenMP] Fix second debug name from map clause

This patch fixes a bug from D89802.  For example, without it, Clang
generates x as the debug map name for both x and y in the following
example:

```
 #pragma omp target map(to: x, y)
 x = y = 1;
```

Reviewed By: jhuber6

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_map_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a3c7365fafd87..fce6efe9fee01 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7763,6 +7763,8 @@ class MappableExprsHandler {
   const ValueDecl *MapDecl = (I->getAssociatedDeclaration())
  ? I->getAssociatedDeclaration()
  : BaseDecl;
+  MapExpr = (I->getAssociatedExpression()) ? I->getAssociatedExpression()
+   : MapExpr;
 
   // Get information on whether the element is a pointer. Have to do a
   // special treatment for array sections given that they are built-in

diff  --git a/clang/test/OpenMP/target_map_names.cpp 
b/clang/test/OpenMP/target_map_names.cpp
index c9ca447f18bd9..a96a1e9d87719 100644
--- a/clang/test/OpenMP/target_map_names.cpp
+++ b/clang/test/OpenMP/target_map_names.cpp
@@ -16,7 +16,6 @@
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
-// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->i;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->s.f;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
@@ -25,7 +24,6 @@
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
-// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.p[:33];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->p[:33];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
@@ -181,6 +179,18 @@ void qux() {
 
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.Z[0:64];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 
+// Clang used to mistakenly generate the map name "x" for both x and y on this
+// directive.  Conditions to reproduce the bug: a single map clause has two
+// variables, and at least the second is used in the associated statement.
+//
+// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";x;{{.*}}.cpp;[[@LINE+3]];7;;\00"
+// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";y;{{.*}}.cpp;[[@LINE+2]];10;;\00"
+void secondMapNameInClause() {
+  int x, y;
+  #pragma omp target map(to: x, y)
+  x = y = 1;
+}
+
 // DEBUG: %{{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i8* @{{.+}}, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* 
{{.+}}, i8** getelementptr inbounds ([{{[0-9]+}} x i8*], [{{[0-9]+}} x i8*]* 
@.offload_mapnames{{.*}}, i32 0, i32 0), i8** {{.+}})
 // DEBUG: %{{.+}} = call i32 @__tgt_target_teams_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i8* @{{.+}}, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, 
i64* {{.+}}, i8** getelementptr inbounds ([{{[0-9]+}} x i8*], [{{[0-9]+}} x 
i8*]* @.offload_mapnames{{.*}}, i32 0, i32 0), i8** {{.+}}, i32 {{.+}}, i32 
{{.+}})
 // DEBUG: call void

r332275 - [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 11:41:44 2018
New Revision: 332275

URL: http://llvm.org/viewvc/llvm-project?rev=332275&view=rev
Log:
[AST] Fix -ast-print for _Bool when have diagnostics

For example, given:

  #define bool _Bool
  _Bool i;
  void fn() { 1; }

-ast-print produced:

  tmp.c:3:13: warning: expression result unused
  void fn() { 1; }
  ^
  bool i;
  void fn() {
  1;
  }

That fails to compile because bool is undefined.

Details:

Diagnostics print _Bool as bool when the latter is defined as the
former.  However, diagnostics were altering the printing policy for
-ast-print as well.  The printed source was then invalid because the
preprocessor eats the bool definition.

Problematic diagnostics included suppressed warnings (e.g., add
-Wno-unused-value to the above example), including those that are
suppressed by default.

This patch fixes this bug and cleans up some related comments.

Reviewed by: aaron.ballman, rsmith

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

Added:
cfe/trunk/test/Misc/ast-print-bool.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=332275&r1=332274&r2=332275&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon May 14 11:41:44 2018
@@ -2113,12 +2113,12 @@ public:
   void checkPartialSpecializationVisibility(SourceLocation Loc,
 NamedDecl *Spec);
 
-  /// Retrieve a suitable printing policy.
+  /// Retrieve a suitable printing policy for diagnostics.
   PrintingPolicy getPrintingPolicy() const {
 return getPrintingPolicy(Context, PP);
   }
 
-  /// Retrieve a suitable printing policy.
+  /// Retrieve a suitable printing policy for diagnostics.
   static PrintingPolicy getPrintingPolicy(const ASTContext &Ctx,
   const Preprocessor &PP);
 

Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=332275&r1=332274&r2=332275&view=diff
==
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Mon May 14 11:41:44 2018
@@ -87,9 +87,10 @@ namespace {
 << DC->getPrimaryContext() << "\n";
 } else
   Out << "Not a DeclContext\n";
-  } else if (OutputKind == Print)
-D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
-  else if (OutputKind != None)
+  } else if (OutputKind == Print) {
+PrintingPolicy Policy(D->getASTContext().getLangOpts());
+D->print(Out, Policy, /*Indentation=*/0, /*PrintInstantiation=*/true);
+  } else if (OutputKind != None)
 D->dump(Out, OutputKind == DumpFull);
 }
 

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=332275&r1=332274&r2=332275&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon May 14 11:41:44 2018
@@ -52,8 +52,8 @@ ModuleLoader &Sema::getModuleLoader() co
 PrintingPolicy Sema::getPrintingPolicy(const ASTContext &Context,
const Preprocessor &PP) {
   PrintingPolicy Policy = Context.getPrintingPolicy();
-  // Our printing policy is copied over the ASTContext printing policy whenever
-  // a diagnostic is emitted, so recompute it.
+  // In diagnostics, we print _Bool as bool if the latter is defined as the
+  // former.
   Policy.Bool = Context.getLangOpts().Bool;
   if (!Policy.Bool) {
 if (const MacroInfo *BoolMacro = PP.getMacroInfo(Context.getBoolName())) {
@@ -1287,7 +1287,8 @@ void Sema::EmitCurrentDiagnostic(unsigne
 }
   }
 
-  // Set up the context's printing policy based on our current state.
+  // Copy the diagnostic printing policy over the ASTContext printing policy.
+  // TODO: Stop doing that.  See: https://reviews.llvm.org/D45093#1090292
   Context.setPrintingPolicy(getPrintingPolicy());
 
   // Emit the diagnostic.

Added: cfe/trunk/test/Misc/ast-print-bool.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-bool.c?rev=332275&view=auto
==
--- cfe/trunk/test/Misc/ast-print-bool.c (added)
+++ cfe/trunk/test/Misc/ast-print-bool.c Mon May 14 11:41:44 2018
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL -DDIAG \
+// RUN: | Fi

r332281 - [AST] Print correct tag decl for tag specifier

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 12:36:45 2018
New Revision: 332281

URL: http://llvm.org/viewvc/llvm-project?rev=332281&view=rev
Log:
[AST] Print correct tag decl for tag specifier

For example, given:

  void fn() {
struct T *p0;
struct T { int i; } *p1;
  }

-ast-print produced:

  void fn() {
struct T { int i; } *p0;
struct T { int i; } *p1;
  }

Compiling that fails with a redefinition error.

Given:

  void fn() {
struct T *p0;
struct __attribute__((deprecated)) T *p1;
  }

-ast-print dropped the attribute.

Details:

For a tag specifier (that is, struct/union/class/enum used as a type
specifier in a declaration) that was also a tag declaration (that is,
first occurrence of the tag) or tag redeclaration (that is, later
occurrence that specifies attributes or a member list), clang printed
the tag specifier as either (1) the full tag definition if one
existed, or (2) the first tag declaration otherwise.  Redefinition
errors were sometimes introduced, as in the first example above.  Even
when that was impossible because no member list was ever specified,
attributes were sometimes lost, thus changing semantics and
diagnostics, as in the second example above.

This patch fixes a major culprit for these problems.  It does so by
creating an ElaboratedType with a new OwnedDecl member wherever an
occurrence of a tag type is a (re)declaration of that tag type.
PrintingPolicy's IncludeTagDefinition used to trigger printing of the
member list, attributes, etc. for a tag specifier by using a tag
(re)declaration selected as described above.  Now, it triggers the
same thing except it uses the tag (re)declaration stored in the
OwnedDecl.  Of course, other tooling can now make use of the new
OwnedDecl as well.

Also, to be more faithful to the original source, this patch
suppresses printing of attributes inherited from previous
declarations.

Reviewed by: rsmith, aaron.ballman

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

Added:
cfe/trunk/test/Misc/ast-print-enum-decl.c
cfe/trunk/test/Misc/ast-print-record-decl.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=332281&r1=332280&r2=332281&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon May 14 12:36:45 2018
@@ -1419,8 +1419,8 @@ public:
   QualType getParenType(QualType NamedType) const;
 
   QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
- NestedNameSpecifier *NNS,
- QualType NamedType) const;
+ NestedNameSpecifier *NNS, QualType NamedType,
+ TagDecl *OwnedTagDecl = nullptr) const;
   QualType getDependentNameType(ElaboratedTypeKeyword Keyword,
 NestedNameSpecifier *NNS,
 const IdentifierInfo *Name,

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=332281&r1=332280&r2=332281&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon May 14 12:36:45 2018
@@ -56,6 +56,7 @@ namespace clang {
 
 class ExtQuals;
 class QualType;
+class TagDecl;
 class Type;
 
 enum {
@@ -4865,14 +4866,18 @@ class ElaboratedType : public TypeWithKe
   /// The type that this qualified name refers to.
   QualType NamedType;
 
+  /// The (re)declaration of this tag type owned by this occurrence, or nullptr
+  /// if none.
+  TagDecl *OwnedTagDecl;
+
   ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
- QualType NamedType, QualType CanonType)
+ QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
 : TypeWithKeyword(Keyword, Elaborated, CanonType,
   NamedType->isDependentType(),
   NamedType->isInstantiationDependentType(),
   NamedType->isVariablyModifiedType(),
   NamedType->containsUnexpandedParameterPack()),
-  NNS(NNS), NamedType(NamedType) {
+  NNS(NNS), NamedType(NamedType), OwnedTagDecl(OwnedTagDecl) {
 assert(!(Keyword == ETK_None && NNS == nullptr) &&
"ElaboratedType cannot have elaborated type keyword "
"and name qualifier both null.");
@@ -4893

r332294 - Fix test fail on some buildbots, caused by r332281.

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 14:06:04 2018
New Revision: 332294

URL: http://llvm.org/viewvc/llvm-project?rev=332294&view=rev
Log:
Fix test fail on some buildbots, caused by r332281.

Modified:
cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332294&r1=332293&r2=332294&view=diff
==
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Mon May 14 14:06:04 2018
@@ -2,7 +2,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES= -o - %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=struct -DBASES= -o - %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c
@@ -14,7 +15,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.c
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.c \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
@@ -24,7 +25,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=union -DBASES= -o - %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=union -DBASES= -o - %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=union -DBASES= %s > %t.c
@@ -36,7 +38,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.c
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.c \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
@@ -46,8 +48,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES=' : B' -o - 
\
-//   RUN:-xc++ %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
@@ -60,7 +62,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.cpp \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.cpp \


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


r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 17:44:14 2018
New Revision: 332314

URL: http://llvm.org/viewvc/llvm-project?rev=332314&view=rev
Log:
[AST] Fix printing tag decl groups in decl contexts

For example, given:

  struct T1 {
struct T2 *p0;
  };

-ast-print produced:

  struct T1 {
struct T2;
struct T2 *p0;
  };

Compiling that produces a warning that the first struct T2 declaration
does not declare anything.

Details:

A tag decl group is one or more decls that share a type specifier that
is a tag decl (that is, a struct/union/class/enum decl).  Within
functions, the parser builds such a tag decl group as part of a
DeclStmt.  However, in decl contexts, such as file scope or a member
list, the parser does not group together the members of a tag decl
group.  Previously, detection of tag decl groups during printing was
implemented but only if the tag decl was unnamed.  Otherwise, as in
the above example, the members of the group did not print together and
so sometimes introduced warnings.

This patch extends detection of tag decl groups in decl contexts to
any tag decl that is recorded in the AST as not free-standing.

Reviewed by: rsmith

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-enum-decl.c
cfe/trunk/test/Misc/ast-print-record-decl.c
cfe/trunk/test/Sema/ast-print.c
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332314&r1=332313&r2=332314&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon May 14 17:44:14 2018
@@ -375,21 +375,23 @@ void DeclPrinter::VisitDeclContext(DeclC
   !isa(DC))
 continue;
 
-// The next bits of code handles stuff like "struct {int x;} a,b"; we're
+// The next bits of code handle stuff like "struct {int x;} a,b"; we're
 // forced to merge the declarations because there's no other way to
-// refer to the struct in question.  This limited merging is safe without
-// a bunch of other checks because it only merges declarations directly
-// referring to the tag, not typedefs.
+// refer to the struct in question.  When that struct is named instead, we
+// also need to merge to avoid splitting off a stand-alone struct
+// declaration that produces the warning ext_no_declarators in some
+// contexts.
+//
+// This limited merging is safe without a bunch of other checks because it
+// only merges declarations directly referring to the tag, not typedefs.
 //
 // Check whether the current declaration should be grouped with a previous
-// unnamed struct.
+// non-free-standing tag declaration.
 QualType CurDeclType = getDeclType(*D);
 if (!Decls.empty() && !CurDeclType.isNull()) {
   QualType BaseType = GetBaseType(CurDeclType);
-  if (!BaseType.isNull() && isa(BaseType))
-BaseType = cast(BaseType)->getNamedType();
-  if (!BaseType.isNull() && isa(BaseType) &&
-  cast(BaseType)->getDecl() == Decls[0]) {
+  if (!BaseType.isNull() && isa(BaseType) &&
+  cast(BaseType)->getOwnedTagDecl() == Decls[0]) {
 Decls.push_back(*D);
 continue;
   }
@@ -399,9 +401,9 @@ void DeclPrinter::VisitDeclContext(DeclC
 if (!Decls.empty())
   ProcessDeclGroup(Decls);
 
-// If the current declaration is an unnamed tag type, save it
+// If the current declaration is not a free standing declaration, save it
 // so we can merge it with the subsequent declaration(s) using it.
-if (isa(*D) && !cast(*D)->getIdentifier()) {
+if (isa(*D) && !cast(*D)->isFreeStanding()) {
   Decls.push_back(*D);
   continue;
 }

Modified: cfe/trunk/test/Misc/ast-print-enum-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-enum-decl.c?rev=332314&r1=332313&r2=332314&view=diff
==
--- cfe/trunk/test/Misc/ast-print-enum-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-enum-decl.c Mon May 14 17:44:14 2018
@@ -83,3 +83,23 @@ void declsOnly() {
   // PRINT-NEXT: enum T *p4;
   enum T *p4;
 }
+
+// Check that tag decl groups stay together in decl contexts.
+
+// PRINT-LABEL: enum DeclGroupAtFileScope {
+// PRINT-NEXT:DeclGroupAtFileScope0
+// PRINT-NEXT:  } *DeclGroupAtFileScopePtr;
+enum DeclGroupAtFileScope { DeclGroupAtFileScope0 } *DeclGroupAtFileScopePtr;
+
+// PRINT-LABEL: struct DeclGroupInMemberList
+struct DeclGroupInMemberList {
+  // PRINT-NEXT:  enum T1 {
+  // PRINT-NEXT:T10
+  // PRINT-NEXT:  } *p0;
+  enum T1 { T10 } *p0;
+  // PRINT-NEXT:  enum T2 {
+  // PRINT-NEXT:T20
+  // PRINT-NEXT:  } *p1, *p2;
+  enum T2 { T20 } *p1, *p2;
+  // PRINT-NEXT: };
+};

Modified: cfe/trunk/test/Mis

Re: r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-15 Thread Joel E. Denny via cfe-commits
Hi Hans,

Thanks.  Sorry for the trouble.  I'll look into it.

Joel

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg  wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
>  wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314&view=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> > struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> > struct T2;
> > struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> > cfe/trunk/lib/AST/DeclPrinter.cpp
> > cfe/trunk/test/Misc/ast-print-enum-decl.c
> > cfe/trunk/test/Misc/ast-print-record-decl.c
> > cfe/trunk/test/Sema/ast-print.c
> > cfe/trunk/test/SemaCXX/ast-print.cpp
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-15 Thread Joel E. Denny via cfe-commits
Hi Hans,

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg  wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>

The underlying bug is present at least as far back as 4.0.1.  The bug is
revealed by an earlier patch, r332281, simply because it introduces this
test.

There are two parts to this bug.  First, implicit attributes shouldn't
print as that's not faithful to the original source.  I'm addressing that at

https://reviews.llvm.org/D46894

Second, when this attribute is explicit, the "(1)" shouldn't print as it's
not part of the accepted syntax.  I'll address that in another patch.

Thanks.

Joel



>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
>  wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314&view=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> > struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> > struct T2;
> > struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> > cfe/trunk/lib/AST/DeclPrinter.cpp
> > cfe/trunk/test/Misc/ast-print-enum-decl.c
> > cfe/trunk/test/Misc/ast-print-record-decl.c
> > cfe/trunk/test/Sema/ast-print.c
> > cfe/trunk/test/SemaCXX/ast-print.cpp
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332411 - [Attr] Don't print implicit attributes

2018-05-15 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 15 15:16:47 2018
New Revision: 332411

URL: http://llvm.org/viewvc/llvm-project?rev=332411&view=rev
Log:
[Attr] Don't print implicit attributes

Fixes bug reported at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332411&r1=332410&r2=332411&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue May 15 15:16:47 2018
@@ -215,7 +215,7 @@ void DeclPrinter::prettyPrintAttributes(
   if (D->hasAttrs()) {
 AttrVec &Attrs = D->getAttrs();
 for (auto *A : Attrs) {
-  if (A->isInherited())
+  if (A->isInherited() || A->isImplicit())
 continue;
   switch (A->getKind()) {
 #define ATTR(X)

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332411&r1=332410&r2=332411&view=diff
==
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Tue May 15 15:16:47 2018
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN: -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@ void inInit() {
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };


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


r332474 - [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 07:51:18 2018
New Revision: 332474

URL: http://llvm.org/viewvc/llvm-project?rev=332474&view=rev
Log:
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

https://reviews.llvm.org/D46905

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332474&r1=332473&r2=332474&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 07:51:18 2018
@@ -184,7 +184,8 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2624,7 +2625,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332474&r1=332473&r2=332474&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 07:51:18 2018
@@ -34,3 +34,12 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;


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


r332481 - [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 08:18:30 2018
New Revision: 332481

URL: http://llvm.org/viewvc/llvm-project?rev=332481&view=rev
Log:
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332481&r1=332480&r2=332481&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 08:18:30 2018
@@ -184,7 +184,8 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2624,7 +2625,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332481&r1=332480&r2=332481&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 08:18:30 2018
@@ -34,3 +34,12 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;


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


r332480 - Revert r332474: [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 08:18:27 2018
New Revision: 332480

URL: http://llvm.org/viewvc/llvm-project?rev=332480&view=rev
Log:
Revert r332474: [Attr] Don't print fake MSInheritance argument

I botched the commit log attributes.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332480&r1=332479&r2=332480&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 08:18:27 2018
@@ -184,8 +184,7 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument
-: BoolArgument {
+class DefaultBoolArgument : BoolArgument {
   bit Default = default;
 }
 
@@ -2625,7 +2624,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
+  let Args = [DefaultBoolArgument<"BestCase", 1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332480&r1=332479&r2=332480&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 08:18:27 2018
@@ -34,12 +34,3 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
-
-// CHECK: class __single_inheritance SingleInheritance;
-class __single_inheritance SingleInheritance;
-
-// CHECK: class __multiple_inheritance MultipleInheritance;
-class __multiple_inheritance MultipleInheritance;
-
-// CHECK: class __virtual_inheritance VirtualInheritance;
-class __virtual_inheritance VirtualInheritance;


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


r333574 - [AST] Fix loss of enum forward decl from decl context

2018-05-30 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 30 11:33:53 2018
New Revision: 333574

URL: http://llvm.org/viewvc/llvm-project?rev=333574&view=rev
Log:
[AST] Fix loss of enum forward decl from decl context

For example, given:

  enum __attribute__((deprecated)) T *p;

-ast-print produced:

  enum T *p;

The attribute was lost because the enum forward decl was lost.

Another example is the loss of enum forward decls from C++ namespaces
(in MS compatibility mode).

The trouble was that the EnumDecl node was suppressed, as revealed by
-ast-dump.  The suppression of the EnumDecl was intentional in
r116122, but I don't understand why.  The suppression isn't needed for
the test suite to behave.

Reviewed by: rsmith

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/ast-print.c
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 30 11:33:53 2018
@@ -14287,7 +14287,6 @@ CreateNewDecl:
   // PrevDecl.
   TagDecl *New;
 
-  bool IsForwardReference = false;
   if (Kind == TTK_Enum) {
 // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
 // enum X { A, B, C } D;D should chain to X.
@@ -14317,12 +14316,6 @@ CreateNewDecl:
 else if (getLangOpts().CPlusPlus)
   DiagID = diag::err_forward_ref_enum;
 Diag(Loc, DiagID);
-
-// If this is a forward-declared reference to an enumeration, make a
-// note of it; we won't actually be introducing the declaration into
-// the declaration context.
-if (TUK == TUK_Reference)
-  IsForwardReference = true;
   }
 }
 
@@ -14480,9 +14473,7 @@ CreateNewDecl:
 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
   } else if (Name) {
 S = getNonFieldDeclScope(S);
-PushOnScopeChains(New, S, !IsForwardReference);
-if (IsForwardReference)
-  SearchDC->makeDeclVisibleInContext(New);
+PushOnScopeChains(New, S, true);
   } else {
 CurContext->addDecl(New);
   }

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Wed May 30 11:33:53 2018
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been 
explicitly marked deprecated here}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
@@ -86,8 +88,7 @@ enum EnumWithAttributes { // expected-wa
   // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
-// FIXME: If enum is forward-declared at file scope, attributes are lost.
-// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 
*EnumWithAttributes2Ptr;
 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Wed May 30 11:33:53 2018
@@ -239,6 +239,15 @@ enum ENUM2 {
ENUM2_c = 0x1 // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwa

r330722 - [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Apr 24 07:50:23 2018
New Revision: 330722

URL: http://llvm.org/viewvc/llvm-project?rev=330722&view=rev
Log:
[Attr] Print enum attributes at correct position

For example, given:

  void fn() {
enum __attribute__((deprecated)) T *p;
  }

-ast-print produced:

  void fn() {
enum T __attribute__((deprecated(""))) *p;
  }

-ast-print on that produced:

  void fn() {
enum T *p __attribute__((deprecated("")));
  }

The attribute is on enum T in the first case, but it's on p in the
other cases.

Details:

Within enum declarations, enum attributes were always printed after
the tag and any member list.  When no member list was present but the
enum was a type specifier in a variable declaration, the attribute
then applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.

Reviewed By: rsmith

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Sema/ast-print.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=330722&r1=330721&r2=330722&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 24 07:50:23 2018
@@ -496,14 +496,17 @@ void DeclPrinter::VisitTypeAliasDecl(Typ
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@ void DeclPrinter::VisitEnumDecl(EnumDecl
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=330722&r1=330721&r2=330722&view=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Tue Apr 24 07:50:23 2018
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@ struct pair_t {
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@ void initializers() {
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *E

r331466 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:15:44 2018
New Revision: 331466

URL: http://llvm.org/viewvc/llvm-project?rev=331466&view=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331466&r1=331465&r2=331466&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:15:44 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331466&r1=331465&r2=331466&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:15:44 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {

r331469 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:04 2018
New Revision: 331469

URL: http://llvm.org/viewvc/llvm-project?rev=331469&view=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

Reviewed by: ABataev

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

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331469&r1=331468&r2=331469&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:04 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331469&r1=331468&r2=331469&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:04 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]

r331468 - Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:01 2018
New Revision: 331468

URL: http://llvm.org/viewvc/llvm-project?rev=331468&view=rev
Log:
Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

Sorry, forgot to add commit log attributes.

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331468&r1=331467&r2=331468&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:01 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331468&r1=331467&r2=331468&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:01 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-D

r335907 - [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:46:10 2018
New Revision: 335907

URL: http://llvm.org/viewvc/llvm-project?rev=335907&view=rev
Log:
[OPENMP] Fix incomplete type check for array reductions

A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335907&r1=335906&r2=335907&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:46:10 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, Type,
+if (S.RequireCompleteType(ELoc, D->getType(),
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Added: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335907&view=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (added)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c Thu Jun 28 12:46:10 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
+
+int incomplete[];
+
+void test() {
+#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
+  ;
+}
+
+// complete to suppress an additional warning, but it's too late for pragmas
+int incomplete[3];


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


r335910 - Revert r335907: [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:54:27 2018
New Revision: 335910

URL: http://llvm.org/viewvc/llvm-project?rev=335910&view=rev
Log:
Revert r335907: [OPENMP] Fix incomplete type check for array reductions

Sorry, forgot to add commit log attributes again.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335910&r1=335909&r2=335910&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:54:27 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, D->getType(),
+if (S.RequireCompleteType(ELoc, Type,
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Removed: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335909&view=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (original)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
-
-int incomplete[];
-
-void test() {
-#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
-  ;
-}
-
-// complete to suppress an additional warning, but it's too late for pragmas
-int incomplete[3];


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


r335911 - [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:54:49 2018
New Revision: 335911

URL: http://llvm.org/viewvc/llvm-project?rev=335911&view=rev
Log:
[OPENMP] Fix incomplete type check for array reductions

A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

Reviewed By: ABataev

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

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335911&r1=335910&r2=335911&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:54:49 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, Type,
+if (S.RequireCompleteType(ELoc, D->getType(),
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Added: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335911&view=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (added)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c Thu Jun 28 12:54:49 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
+
+int incomplete[];
+
+void test() {
+#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
+  ;
+}
+
+// complete to suppress an additional warning, but it's too late for pragmas
+int incomplete[3];


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


r329005 - [Attr] [NFC] Revert accidental change from r327405

2018-04-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon Apr  2 12:43:34 2018
New Revision: 329005

URL: http://llvm.org/viewvc/llvm-project?rev=329005&view=rev
Log:
[Attr] [NFC] Revert accidental change from r327405

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=329005&r1=329004&r2=329005&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Mon Apr  2 12:43:34 
2018
@@ -1231,7 +1231,7 @@ MallocChecker::MallocMemReturnsAttr(Chec
   if (Att->getModule() != II_malloc)
 return nullptr;
 
-  ParamIdx *I = Att->args_begin(), *E = Att->args_end();
+  OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
   if (I != E) {
 return MallocMemAux(C, CE, CE->getArg(I->getASTIndex()), UndefinedVal(),
 State);


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


r347350 - [OpenMP] Update CHECK-DAG usage in for_codegen.cpp

2018-11-20 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Nov 20 14:04:45 2018
New Revision: 347350

URL: http://llvm.org/viewvc/llvm-project?rev=347350&view=rev
Log:
[OpenMP] Update CHECK-DAG usage in for_codegen.cpp

This patch adjusts a test not to depend on deprecated FileCheck
behavior that permits overlapping matches within a block of CHECK-DAG
directives.  Thus, this patch also removes uses of FileCheck's
-allow-deprecated-dag-overlap command-line option.

Specifically, the FileCheck variables DBG_LOC_START, DBG_LOC_END, and
DBG_LOC_CANCEL were all set to the same value.  As a result, three
TERM_DEBUG-DAG patterns, one for each variable, all matched the same
text under the old overlapping behavior.  Under the new
non-overlapping behavior, that's not permitted.  This patch's solution
is to replace these variables with one variable and replace these
patterns with one pattern.

Reviewed By: ABataev

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

Modified:
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.cpp?rev=347350&r1=347349&r2=347350&view=diff
==
--- cfe/trunk/test/OpenMP/for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_codegen.cpp Tue Nov 20 14:04:45 2018
@@ -1,14 +1,14 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck -allow-deprecated-dag-overlap %s 
--check-prefix=CHECK --check-prefix=LIFETIME
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck -allow-deprecated-dag-overlap %s --check-prefix=TERM_DEBUG
-// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROF-INSTR-PATH
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
+// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck %s --check-prefix=PROF-INSTR-PATH
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck 
-allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix 
SIMD-ONLY0 %s
-// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck --check-prefix SIMD-ONLY0 %s
 // SI

r347351 - [OpenMP] Update CHECK-DAG usage in target_parallel_codegen.cpp

2018-11-20 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Nov 20 14:05:23 2018
New Revision: 347351

URL: http://llvm.org/viewvc/llvm-project?rev=347351&view=rev
Log:
[OpenMP] Update CHECK-DAG usage in target_parallel_codegen.cpp

This patch adjusts a test not to depend on deprecated FileCheck
behavior that permits overlapping matches within a block of CHECK-DAG
directives.  Thus, this patch also removes uses of FileCheck's
-allow-deprecated-dag-overlap command-line option.

There were two issues in this test:

1. There were sets of patterns for store instructions in which a
pattern X could match a superset of a pattern Y.  While X appeared
before Y, Y's intended match appeared before X's intended match.  The
result was that X matched Y's intended match.  Under the old
overlapping behavior, Y also matched Y's intended match.  Under the
new non-overlapping behavior, Y had nothing left to match.  This patch
fixes this by gathering these sets in one place and putting the most
specific patterns (Y) before the more general patterns (X).

2. The CHECK-DAG patterns involving the variables CBPADDR3 and
CBPADDR4 were the same, but there was only one match in the text, so
CBPADDR4 patterns had nothing to match under the new non-overlapping
behavior.  Moreover, a preceding related series of directives had
variables (SADDR0, BPADDR0, etc.) numbered only 0 through 4, but this
series had variables numbered 0 through 5.  Assuming CBPADDR4's
directives were not intended, this patch removes them.

Reviewed By: ABataev

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

Modified:
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_codegen.cpp?rev=347351&r1=347350&r2=347351&view=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_codegen.cpp Tue Nov 20 14:05:23 2018
@@ -1,37 +1,37 @@
 // Test host codegen.
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefix 
CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
-allow-deprecated-dag-overlap  %s --check-prefix CHECK --check-prefix CHECK-64
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck -allow-deprecated-dag-overlap  %s --check-prefix CHECK --check-prefix 
CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix 
SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
-// RUN: %cl

r348504 - [CUDA] Fix nvidia-cuda-toolkit detection on Ubuntu

2018-12-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Dec  6 09:46:17 2018
New Revision: 348504

URL: http://llvm.org/viewvc/llvm-project?rev=348504&view=rev
Log:
[CUDA] Fix nvidia-cuda-toolkit detection on Ubuntu

This just extends D40453 (r319317) to Ubuntu.

Reviewed By: Hahnfeld, tra

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=348504&r1=348503&r2=348504&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Dec  6 09:46:17 2018
@@ -114,7 +114,7 @@ CudaInstallationDetector::CudaInstallati
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-if (Distro(D.getVFS()).IsDebian())
+if (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");


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


[clang] f250eb3 - [OpenMP][Docs] Update `present` modifier status

2020-07-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-27T19:23:55-04:00
New Revision: f250eb37cd4fabcc9f222ca2da80b62d110d9fff

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

LOG: [OpenMP][Docs] Update `present` modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 26fbfab96bc8..a1d1b120bcec 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
+| device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
++--+--+--+---+
+| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] a3d1f88 - [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: a3d1f88fa7da3dfc0b4319f2e4eb7374fa60b819

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

LOG: [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

`to` and `from` clauses take the same modifiers, which are called
"motion modifiers" in TR8, so implement handling of their modifiers
once not twice.  This will make it easier to implement additional
motion modifiers in the future.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 275c4fcdabb2..04ecbeaaa03e 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -29,11 +29,8 @@
 #ifndef OPENMP_MAP_MODIFIER_KIND
 #define OPENMP_MAP_MODIFIER_KIND(Name)
 #endif
-#ifndef OPENMP_TO_MODIFIER_KIND
-#define OPENMP_TO_MODIFIER_KIND(Name)
-#endif
-#ifndef OPENMP_FROM_MODIFIER_KIND
-#define OPENMP_FROM_MODIFIER_KIND(Name)
+#ifndef OPENMP_MOTION_MODIFIER_KIND
+#define OPENMP_MOTION_MODIFIER_KIND(Name)
 #endif
 #ifndef OPENMP_DIST_SCHEDULE_KIND
 #define OPENMP_DIST_SCHEDULE_KIND(Name)
@@ -126,11 +123,8 @@ OPENMP_MAP_MODIFIER_KIND(close)
 OPENMP_MAP_MODIFIER_KIND(mapper)
 OPENMP_MAP_MODIFIER_KIND(present)
 
-// Modifiers for 'to' clause.
-OPENMP_TO_MODIFIER_KIND(mapper)
-
-// Modifiers for 'from' clause.
-OPENMP_FROM_MODIFIER_KIND(mapper)
+// Modifiers for 'to' or 'from' clause.
+OPENMP_MOTION_MODIFIER_KIND(mapper)
 
 // Static attributes for 'dist_schedule' clause.
 OPENMP_DIST_SCHEDULE_KIND(static)
@@ -163,8 +157,7 @@ OPENMP_REDUCTION_MODIFIER(task)
 #undef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
 #undef OPENMP_MAP_KIND
 #undef OPENMP_MAP_MODIFIER_KIND
-#undef OPENMP_TO_MODIFIER_KIND
-#undef OPENMP_FROM_MODIFIER_KIND
+#undef OPENMP_MOTION_MODIFIER_KIND
 #undef OPENMP_DIST_SCHEDULE_KIND
 #undef OPENMP_DEFAULTMAP_KIND
 #undef OPENMP_DEFAULTMAP_MODIFIER

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index dc6198f93f9d..3e9b5c4a8b14 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -86,20 +86,12 @@ enum OpenMPMapModifierKind {
 static constexpr unsigned NumberOfOMPMapClauseModifiers =
 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
 
-/// OpenMP modifier kind for 'to' clause.
-enum OpenMPToModifierKind {
-#define OPENMP_TO_MODIFIER_KIND(Name) \
-  OMPC_TO_MODIFIER_##Name,
+/// OpenMP modifier kind for 'to' or 'from' clause.
+enum OpenMPMotionModifierKind {
+#define OPENMP_MOTION_MODIFIER_KIND(Name) \
+  OMPC_MOTION_MODIFIER_##Name,
 #include "clang/Basic/OpenMPKinds.def"
-  OMPC_TO_MODIFIER_unknown
-};
-
-/// OpenMP modifier kind for 'from' clause.
-enum OpenMPFromModifierKind {
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  OMPC_FROM_MODIFIER_##Name,
-#include "clang/Basic/OpenMPKinds.def"
-  OMPC_FROM_MODIFIER_unknown
+  OMPC_MOTION_MODIFIER_unknown
 };
 
 /// OpenMP attributes for 'dist_schedule' clause.

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 4807702e896e..da362f99ed29 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -64,17 +64,12 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind 
Kind, StringRef Str,
 return Type;
   }
   case OMPC_to:
-return llvm::StringSwitch(Str)
-#define OPENMP_TO_MODIFIER_KIND(Name)  
\
-  .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
-#include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_TO_MODIFIER_unknown);
   case OMPC_from:
 return llvm::StringSwitch(Str)
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  
\
+  .Case(#Name, static_cast(OMPC_MOTION_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_FROM_MODIFIER_unknown);
+.Default(OMPC_MOTION_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -258,29 +253,18 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 llvm_unreachable("Invalid OpenMP 'map' clause type");
   case OMPC_to:
-switch (Type) {
-case OMPC_TO_MODIFIER_unknown:
-  return "unknown";
-#define OPENMP_TO_MODIFIER_KIND(Name)   

[clang] 3c3faae - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: 3c3faae497046be706df29e16c9fbccb7e1fce09

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c649502f765b..46c26c6c77de 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// 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(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {}
+  &MapperIdInfo) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMoti

[clang] 69fc33f - Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T20:30:05-04:00
New Revision: 69fc33f0cd130b02a38d2fc582afc7b0fcd6458a

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

LOG: Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

This reverts commit 3c3faae497046be706df29e16c9fbccb7e1fce09.

It breaks a number of bots.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 46c26c6c77de..c649502f765b 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,20 +6329,8 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
-  /// Motion-modifiers for the 'to' clause.
-  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
-  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
-
-  /// Location of motion-modifiers for the 'to' clause.
-  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
-
-  /// Colon location.
-  SourceLocation ColonLoc;
-
   /// Build clause with number of variables \a NumVars.
   ///
-  /// \param TheMotionModifiers Motion-modifiers.
-  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6354,24 +6342,13 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// 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(ArrayRef TheMotionModifiers,
-   ArrayRef TheMotionModifiersLoc,
-   NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {
-assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
-   "Unexpected number of motion modifiers.");
-llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
-
-assert(llvm::array_lengthof(MotionModifiersLoc) ==
-   TheMotionModifiersLoc.size() &&
-   "Unexpected number of motion modifier locations.");
-llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
-  }
+  &MapperIdInfo) {}
 
   /// Build an empty clause.
   ///
@@ -6384,29 +6361,6 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
-  /// Set motion-modifier for the clause.
-  ///
-  /// \param I index for motion-modifier.
-  /// \param T motion-modifier for the clause.
-  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Unexpected index to store motion modifier, exceeds array size.");
-MotionModifiers[I] = T;
-  }
-
-  /// Set location for the motion-modifier.
-  ///
-  /// \param I index for motion-modifier location.
-  /// \param TLoc motion-modifier location.
-  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Index to store motion modifier location exceeds array size.");
-MotionModifiersLoc[I] = TLoc;
-  }
-
-  /// Set colon location.
-  void set

[clang] 9f2f3b9 - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-29 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-29T12:18:45-04:00
New Revision: 9f2f3b9de6314a009322b6081c792ebf9a469460

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 4f94aa7074ee..5b588f4b5740 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// 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(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {}
+  &MapperIdInfo) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMoti

[clang] 3d06fc0 - [OpenMP][Docs] Mark `present` motion modifier as done

2020-07-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-30T12:21:37-04:00
New Revision: 3d06fc0049c6bb94e6efd77388453206037f43ad

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

LOG: [OpenMP][Docs] Mark `present` motion modifier as done

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index bda52e934c26..28fbd7baebb2 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -270,5 +270,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+
-| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
+| device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] 03bb545 - [OpenMP][Docs] Mark `present` map type modifier as done

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 03bb545b68c2edb9dc5bd092104bdb83a8e5e347

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

LOG: [OpenMP][Docs] Mark `present` map type modifier as done

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 9bad27ea8817..e63d91586b95 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -270,7 +270,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
+| device extension | 'present' map type modifier   
   | :good:`done` | D83061, D83062, D84422  
  |
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] 002d61d - [OpenMP] Fix `present` for exit from `omp target data`

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 002d61db2b7790dc884953bf9271878bf0af3a8e

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

LOG: [OpenMP] Fix `present` for exit from `omp target data`

Without this patch, the following example fails but shouldn't
according to OpenMP TR8:

```
 #pragma omp target enter data map(alloc:i)
 #pragma omp target data map(present, alloc: i)
 {
   #pragma omp target exit data map(delete:i)
 } // fails presence check here
```

OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 321, L23-26 states:

> If the map clause appears on a target, target data, target enter
> data or target exit data construct with a present map-type-modifier
> then on entry to the region if the corresponding list item does not
> appear in the device data environment an error occurs and the
> program terminates.

There is no corresponding statement about the exit from a region.
Thus, the `present` modifier should:

1. Check for presence upon entry into any region, including a `target
   exit data` region.  This behavior is already implemented correctly.

2. Should not check for presence upon exit from any region, including
   a `target` or `target data` region.  Without this patch, this
   behavior is not implemented correctly, breaking the above example.

In the case of `target data`, this patch fixes the latter behavior by
removing the `present` modifier from the map types Clang generates for
the runtime call at the end of the region.

In the case of `target`, we have not found a valid OpenMP program for
which such a fix would matter.  It appears that, if a program can
guarantee that data is present at the beginning of a `target` region
so that there's no error there, that data is also guaranteed to be
present at the end.  This patch adds a comment to the runtime to
document this case.

Reviewed By: grokos, RaviNarayanaswamy, ABataev

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

Added: 
openmp/libomptarget/test/mapping/present/target_data_at_exit.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/target_data_codegen.cpp
openmp/libomptarget/src/omptarget.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 60c7081b135b..547a9307dce2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8826,6 +8826,30 @@ emitOffloadingArrays(CodeGenFunction &CGF,
 MapTypesArrayGbl->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 Info.MapTypesArray = MapTypesArrayGbl;
 
+// If there's a present map type modifier, it must not be applied to the 
end
+// of a region, so generate a separate map type array in that case.
+if (Info.separateBeginEndCalls()) {
+  bool EndMapTypesDiffer = false;
+  for (uint64_t &Type : Mapping) {
+if (Type & MappableExprsHandler::OMP_MAP_PRESENT) {
+  Type &= ~MappableExprsHandler::OMP_MAP_PRESENT;
+  EndMapTypesDiffer = true;
+}
+  }
+  if (EndMapTypesDiffer) {
+MapTypesArrayInit =
+llvm::ConstantDataArray::get(CGF.Builder.getContext(), Mapping);
+MaptypesName = CGM.getOpenMPRuntime().getName({"offload_maptypes"});
+MapTypesArrayGbl = new llvm::GlobalVariable(
+CGM.getModule(), MapTypesArrayInit->getType(),
+/*isConstant=*/true, llvm::GlobalValue::PrivateLinkage,
+MapTypesArrayInit, MaptypesName);
+MapTypesArrayGbl->setUnnamedAddr(
+llvm::GlobalValue::UnnamedAddr::Global);
+Info.MapTypesArrayEnd = MapTypesArrayGbl;
+  }
+}
+
 for (unsigned I = 0; I < Info.NumberOfPtrs; ++I) {
   llvm::Value *BPVal = *CombinedInfo.BasePointers[I];
   llvm::Value *BP = CGF.Builder.CreateConstInBoundsGEP2_32(
@@ -8878,12 +8902,16 @@ emitOffloadingArrays(CodeGenFunction &CGF,
 }
 
 /// Emit the arguments to be passed to the runtime library based on the
-/// arrays of base pointers, pointers, sizes, map types, and mappers.
+/// arrays of base pointers, pointers, sizes, map types, and mappers.  If
+/// ForEndCall, emit map types to be passed for the end of the region instead 
of
+/// the beginning.
 static void emitOffloadingArraysArgument(
 CodeGenFunction &CGF, llvm::Value *&BasePointersArrayArg,
 llvm::Value *&PointersArrayArg, llvm::Value *&SizesArrayArg,
 llvm::Value *&MapTypesArrayArg, llvm::Value *&MappersArrayArg,
-CGOpenMPRuntime::TargetDataInfo &Info) {
+CGOpenMPRuntime::TargetDataInfo &Info, bool ForEndCall = false) {
+  assert((!ForEndCall || Info.separateBeginEndCalls()) &&
+ "expected region end call to runtime o

[clang] 26cf9c1 - [OpenMP][Docs] Add map clause reordering status as unclaimed

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 26cf9c17044515cdde3e7baeea843001ba33be59

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

LOG: [OpenMP][Docs] Add map clause reordering status as unclaimed

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index af5e538b1435..9bad27ea8817 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -221,6 +221,8 @@ implementation.
 
+--+--+--+---+
 | device extension | pointer attachment
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
+| device extension | map clause reordering based on map types  
   | :none:`unclaimed`| 
  |
++--+--+--+---+
 | atomic extension | hints for the atomic construct
   | :good:`done` | D51233  
  |
 
+--+--+--+---+
 | base language| C11 support   
   | :good:`done` | 
  |
@@ -272,3 +274,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+
+| device extension | map clause reordering reordering based on 
'present' modifier | :none:`unclaimed`| 
  |
++--+--+--+---+



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


[clang] ed39bec - [OpenMP][NFC] Remove hard-coded line numbers from more tests

2020-07-07 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-07T09:48:22-04:00
New Revision: ed39becd274dae5537c24b2107737d718527e718

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

LOG: [OpenMP][NFC] Remove hard-coded line numbers from more tests

This is a continuation of D82224.

Reviewed By: grokos

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

Added: 


Modified: 
clang/test/OpenMP/target_defaultmap_codegen.cpp
clang/test/OpenMP/target_map_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_defaultmap_codegen.cpp 
b/clang/test/OpenMP/target_defaultmap_codegen.cpp
index 140574c18c74..3deff63273d5 100644
--- a/clang/test/OpenMP/target_defaultmap_codegen.cpp
+++ b/clang/test/OpenMP/target_defaultmap_codegen.cpp
@@ -20,7 +20,7 @@
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
-allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY10 %s
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 
-// CK1-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l44.region_id = 
weak constant i8 0
+// CK1-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544
@@ -70,7 +70,7 @@ void implicit_maps_double_complex (int a){
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 #ifdef CK2
 
-// CK2-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l94.region_id = 
weak constant i8 0
+// CK2-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO  | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545
@@ -120,7 +120,7 @@ void implicit_maps_double_complex (int a){
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 #ifdef CK3
 
-// CK3-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l144.region_id = 
weak constant i8 0
+// CK3-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546
@@ -173,7 +173,7 @@ void implicit_maps_double_complex (int a){
 // For a 32-bit targets, the value doesn't fit the size of the pointer,
 // therefore it is passed by reference with a map 'to' specification.
 
-// CK4-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l209.region_id = weak 
constant i8 0
+// CK4-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 
 // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 
800
@@ -242,7 +242,7 @@ void implicit_maps_double (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK5
 
-// CK5-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l266.region_id = weak 
constant i8 0
+// CK5-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK5-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544
@@ -293,7 +293,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK6
 
-// CK6-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l317.region_id = weak 
constant i8 0
+// CK6-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK6-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545
@@ -344,7 +344,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK7
 
-// CK7-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l368.region_id = weak 
constant i8 0
+// CK7-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK7-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546
@@ -395,7 +395,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK8
 
-// CK8-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l419.region_id = weak 
constant i8 0
+// CK8-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK8-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | 

[clang] 3fa666b - [OpenMP][Docs] Mark TR8 `present` as claimed in docs

2020-06-24 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-06-24T14:21:11-04:00
New Revision: 3fa666b883625a678cfcfd9ad96b2daabcef09e8

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

LOG: [OpenMP][Docs] Mark TR8 `present` as claimed in docs

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 0b6a183e5345..000f23141af3 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,3 +268,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
+| device extension | 'present' map type modifier   
   | :part:`claimed`  | 
  |
++--+--+--+---+



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


[clang] 01ddb2a - [OpenMP][NFC] Remove hard-coded line numbers from test

2020-06-24 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-06-24T14:35:01-04:00
New Revision: 01ddb2a7b044f697a15043e47acdb93e2825809a

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

LOG: [OpenMP][NFC] Remove hard-coded line numbers from test

Otherwise, it's painful to insert new code.  There are many existing
examples in the same test file where the line numbers are not
hard-coded.

I intend to do the same for several other OpenMP tests, but I want to
be sure there are no objections before I spend time on it.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/test/OpenMP/target_map_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_map_codegen.cpp 
b/clang/test/OpenMP/target_map_codegen.cpp
index ecfe50c01ea6..7fc4fcb71911 100644
--- a/clang/test/OpenMP/target_map_codegen.cpp
+++ b/clang/test/OpenMP/target_map_codegen.cpp
@@ -1323,173 +1323,173 @@ void implicit_maps_template_type_capture (int a){
 // SIMD-ONLY18-NOT: {{__kmpc|__tgt}}
 #ifdef CK19
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1514.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1535.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1557.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE01:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1576.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE02:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE02:@.+]] = private {{.*}}constant [1 x i64] [i64 34]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1595.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE03:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE03:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1614.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE04:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE04:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1633.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE05:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE05:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1656.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[MTYPE06:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1679.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[MTYPE07:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1698.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE08:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE08:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1719.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64]

[clang] d6e79e3 - [OpenMP][Docs] Update `present` map type modifier status

2020-07-15 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-15T11:17:00-04:00
New Revision: d6e79e3dd6df63425eb098f482be2c9744ad48eb

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

LOG: [OpenMP][Docs] Update `present` map type modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 000f23141af3..26fbfab96bc8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`claimed`  | 
  |
+| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
 
+--+--+--+---+



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


[clang] 9a9a5f9 - [FileCheck] Support comment directives

2020-05-11 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-11T14:53:48-04:00
New Revision: 9a9a5f9893c8db05cebc8818eb8485bff61f7c74

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

LOG: [FileCheck] Support comment directives

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

```
; X32: pinsrd_1:
; X32:pinsrd $1, 4(%esp), %xmm0

; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but
; COM: X64 will have something similar to X32:
; COM:
; COM:   X64: pinsrd_1:
; COM:   X64:pinsrd $1, %edi, %xmm0
```

Without this patch, you need to use some combination of rewording and
directive syntax mangling to prevent FileCheck from recognizing the
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:`
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[clang] d0e7fd6 - Revert "[FileCheck] Support comment directives"

2020-05-11 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-11T19:41:22-04:00
New Revision: d0e7fd6b624b1943f3780a69883690017d2efad2

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

LOG: Revert "[FileCheck] Support comment directives"

This reverts commit 9a9a5f9893c8db05cebc8818eb8485bff61f7c74 to try to
fix a bot:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489

Added: 


Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt



diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 6b3d7bc2e32a..21ba2b3269c2 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// CHECK-LABEL: define i32 @test1()
+// COM-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// CHECK-LABEL: define i32 @test2(i32 %i)
-// CHECK: %[[addr:.*]] = getelementptr
+// COM-LABEL: define i32 @test2(i32 %i)
+// COM: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// CHECK-LABEL: define void @test3()
+// COM-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index e1f3f6fe1419..35cc54c50d6f 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=ALL,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple 
spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR 
%s
 
 typedef int int2 __attribute__((ext_vector_type(2)));
@@ -50,7 +50,7 @@ Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   return out;
 }
 
-// ALL-LABEL: define {{.*}} void @ker
+// COM-LABEL: define {{.*}} void @ker
 // Expect two mem copies: one for the argument "in", and one for
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
@@ -70,7 +70,7 @@ Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) {
   return out;
 }
 
-// ALL-LABEL: define {{.*}} void @ker_large
+// COM-LABEL: define {{.*}} void @ker_large
 // Expect two mem copies: one for the argument "in", and one for
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*

diff  --git a/clang/test/Driver/hip-device-libs.hip 
b/clang/test/Driver/hip-device-libs.hip
index 6afc48e31dd2..cb1747c2d798 100644
--- a/clang/test/Driver/hip-device-libs.hip
+++ b/clang/test/Driver/hip-device-libs.hip
@@ -10,7 +10,7 @@
 // RUN:   --cuda-gpu-arch=gfx803 \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib   \
 // RUN: 

[clang] a1fd188 - [FileCheck] Support comment directives

2020-05-13 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-13T11:29:48-04:00
New Revision: a1fd188223d9c9b404dccd3511fe8b63ef022a13

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

LOG: [FileCheck] Support comment directives

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

```
; X32: pinsrd_1:
; X32:pinsrd $1, 4(%esp), %xmm0

; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but
; COM: X64 will have something similar to X32:
; COM:
; COM:   X64: pinsrd_1:
; COM:   X64:pinsrd $1, %edi, %xmm0
```

Without this patch, you need to use some combination of rewording and
directive syntax mangling to prevent FileCheck from recognizing the
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:`
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[clang-tools-extra] r375058 - [lit] Fix another test case that r374652 missed

2019-10-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Oct 16 16:58:58 2019
New Revision: 375058

URL: http://llvm.org/viewvc/llvm-project?rev=375058&view=rev
Log:
[lit] Fix another test case that r374652 missed

Modified:
clang-tools-extra/trunk/test/clang-include-fixer/merge.test

Modified: clang-tools-extra/trunk/test/clang-include-fixer/merge.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-include-fixer/merge.test?rev=375058&r1=375057&r2=375058&view=diff
==
--- clang-tools-extra/trunk/test/clang-include-fixer/merge.test (original)
+++ clang-tools-extra/trunk/test/clang-include-fixer/merge.test Wed Oct 16 
16:58:58 2019
@@ -1,6 +1,6 @@
 # RUN: find-all-symbols -merge-dir=%S/Inputs/merge %t.merged
 # RUN: sed '/^#/d' %s > %t.golden
-# RUN: diff -u %t.golden %t.merged
+# RUN: diff --strip-trailing-cr -u %t.golden %t.merged
 ---
 Name:bar
 Contexts:


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


r358917 - [VerifyDiagnosticConsumer] Document -verify= in doxygen

2019-04-22 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon Apr 22 13:25:06 2019
New Revision: 358917

URL: http://llvm.org/viewvc/llvm-project?rev=358917&view=rev
Log:
[VerifyDiagnosticConsumer] Document -verify= in doxygen

Previously, it was only documented by `-cc1 -help`, so people weren't
aware of it, as discussed in D60732.

Reviewed By: Charusso, NoQ

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

Modified:
cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h

Modified: cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h?rev=358917&r1=358916&r2=358917&view=diff
==
--- cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h Mon Apr 22 
13:25:06 2019
@@ -33,7 +33,33 @@ class TextDiagnosticBuffer;
 /// markers in the input source to check that all the emitted diagnostics match
 /// those expected.
 ///
-/// USING THE DIAGNOSTIC CHECKER:
+/// INVOKING THE DIAGNOSTIC CHECKER:
+///
+/// VerifyDiagnosticConsumer is typically invoked via the "-verify" option to
+/// "clang -cc1".  "-verify" is equivalent to "-verify=expected", so all
+/// diagnostics are typically specified with the prefix "expected".  For
+/// example:
+///
+/// \code
+///   int A = B; // expected-error {{use of undeclared identifier 'B'}}
+/// \endcode
+///
+/// Custom prefixes can be specified as a comma-separated sequence.  Each
+/// prefix must start with a letter and contain only alphanumeric characters,
+/// hyphens, and underscores.  For example, given just "-verify=foo,bar",
+/// the above diagnostic would be ignored, but the following diagnostics would
+/// be recognized:
+///
+/// \code
+///   int A = B; // foo-error {{use of undeclared identifier 'B'}}
+///   int C = D; // bar-error {{use of undeclared identifier 'D'}}
+/// \endcode
+///
+/// Multiple occurrences accumulate prefixes.  For example,
+/// "-verify -verify=foo,bar -verify=baz" is equivalent to
+/// "-verify=expected,foo,bar,baz".
+///
+/// SPECIFYING DIAGNOSTICS:
 ///
 /// Indicating that a line expects an error or a warning is simple. Put a
 /// comment on the line that has the diagnostic, use:


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


r361335 - [PragmaHandler] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 21 16:51:38 2019
New Revision: 361335

URL: http://llvm.org/viewvc/llvm-project?rev=361335&view=rev
Log:
[PragmaHandler] Expose `#pragma` location

Currently, a pragma AST node's recorded location starts at the
namespace token (such as `omp` in the case of OpenMP) after the
`#pragma` token, and the `#pragma` location isn't available.  However,
the `#pragma` location can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.

This patch makes `#pragma` locations available in any `PragmaHandler`
but it doesn't yet make use of them.

This patch also uses the new `struct PragmaIntroducer` to simplify
`Preprocessor::HandlePragmaDirective`.  It doesn't do the same for
`PPCallbacks::PragmaDirective` because that changes the API documented
in `clang-tools-extra/docs/pp-trace.rst`, and I'm not sure about
backward compatibility guarantees there.

Reviewed By: ABataev, lebedev.ri, aaron.ballman

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

Modified:
cfe/trunk/docs/ClangPlugins.rst
cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp
cfe/trunk/include/clang/Lex/Pragma.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/docs/ClangPlugins.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangPlugins.rst?rev=361335&r1=361334&r2=361335&view=diff
==
--- cfe/trunk/docs/ClangPlugins.rst (original)
+++ cfe/trunk/docs/ClangPlugins.rst Tue May 21 16:51:38 2019
@@ -55,7 +55,7 @@ registering it using ``PragmaHandlerRegi
   class ExamplePragmaHandler : public PragmaHandler {
   public:
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {
   // Handle the pragma
 }

Modified: cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp?rev=361335&r1=361334&r2=361335&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp (original)
+++ cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp Tue May 21 
16:51:38 2019
@@ -58,7 +58,7 @@ class PragmaAnnotateHandler : public Pra
 public:
   PragmaAnnotateHandler() : PragmaHandler("enable_annotate") { }
 
-  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &PragmaTok) override {
 
 Token Tok;

Modified: cfe/trunk/include/clang/Lex/Pragma.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Pragma.h?rev=361335&r1=361334&r2=361335&view=diff
==
--- cfe/trunk/include/clang/Lex/Pragma.h (original)
+++ cfe/trunk/include/clang/Lex/Pragma.h Tue May 21 16:51:38 2019
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_LEX_PRAGMA_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -46,6 +47,12 @@ class Token;
 PIK___pragma
   };
 
+  /// Describes how and where the pragma was introduced.
+  struct PragmaIntroducer {
+PragmaIntroducerKind Kind;
+SourceLocation Loc;
+  };
+
 /// PragmaHandler - Instances of this interface defined to handle the various
 /// pragmas that the language front-end uses.  Each handler optionally has a
 /// name (e.g. "pack") and the HandlePragma method is invoked when a pragma 
with
@@ -64,7 +71,7 @@ public:
   virtual ~PragmaHandler();
 
   StringRef getName() const { return Name; }
-  virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+  virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &FirstToken) = 0;
 
   /// getIfNamespace - If this is a namespace, return it.  This is equivalent 
to
@@ -78,7 +85,7 @@ class EmptyPragmaHandler : public Pragma
 public:
   explicit EmptyPragmaHandler(StringRef Name = StringRef());
 
-  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &FirstToken) override;
 };
 
@@ -111,7 +118,7 @@ public:
 
   bool IsEmpty() const { return Handlers.empty(); }
 
-  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &Tok) override;
 
   PragmaNamespace *getIfNamespace() override { return t

[clang-tools-extra] r361867 - [OpenMP] Set pragma start loc to `#pragma` loc

2019-05-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 28 12:27:19 2019
New Revision: 361867

URL: http://llvm.org/viewvc/llvm-project?rev=361867&view=rev
Log:
[OpenMP] Set pragma start loc to `#pragma` loc

This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp?rev=361867&r1=361866&r2=361867&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp Tue May 
28 12:27:19 2019
@@ -23,7 +23,7 @@ void n0(const int a) {
 void p0_0() {
 #pragma omp parallel
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'parallel' directive can have 'default' clause, and said clause specified,
@@ -38,7 +38,7 @@ void p0_1() {
 void p0_2() {
 #pragma omp parallel default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
   // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified 
here
 }
 
@@ -49,7 +49,7 @@ void p0_2() {
 void p1_0() {
 #pragma omp task
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'task' directive can have 'default' clause, and said clause specified,
@@ -64,7 +64,7 @@ void p1_1() {
 void p1_2() {
 #pragma omp task default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified 
here
 }
 
@@ -76,7 +76,7 @@ void p2_0() {
 #pragma omp target
 #pragma omp teams
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'teams' directive can have 'default' clause, and said clause specified,
@@ -93,7 +93,7 @@ void p2_2() {
 #pragma omp target
 #pragma omp teams default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified 
here
 }
 
@@ -105,7 +105,7 @@ void p3_0(const int a) {
 #pragma omp taskloop
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'taskloop' directive can have 'default' clause, and said clause specified,
@@ -122,7 +122,7 @@ void p3_2(const int a) {
 #pragma omp taskloop default(shared)
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'defaul

r349635 - [OpenMP] Fix data sharing analysis in nested clause

2018-12-19 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Dec 19 07:59:47 2018
New Revision: 349635

URL: http://llvm.org/viewvc/llvm-project?rev=349635&view=rev
Log:
[OpenMP] Fix data sharing analysis in nested clause

Without this patch, clang doesn't complain that X needs explicit data
sharing attributes in the following:

```
 #pragma omp target teams default(none)
 {
   #pragma omp parallel num_threads(X)
 ;
 }
```

However, clang does produce that complaint after the braces are
removed.  With this patch, clang complains in both cases.

Reviewed By: ABataev

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

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=349635&r1=349634&r2=349635&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 19 07:59:47 2018
@@ -2390,13 +2390,9 @@ public:
   void VisitStmt(Stmt *S) {
 for (Stmt *C : S->children()) {
   if (C) {
-if (auto *OED = dyn_cast(C)) {
-  // Check implicitly captured variables in the task-based directives 
to
-  // check if they must be firstprivatized.
-  VisitSubCaptures(OED);
-} else {
-  Visit(C);
-}
+// Check implicitly captured variables in the task-based directives to
+// check if they must be firstprivatized.
+Visit(C);
   }
 }
   }

Modified: cfe/trunk/test/OpenMP/target_teams_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_messages.cpp?rev=349635&r1=349634&r2=349635&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_messages.cpp Wed Dec 19 07:59:47 2018
@@ -50,6 +50,16 @@ int main(int argc, char **argv) {
 #pragma omp target teams default(none)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified 
data sharing attributes}}
 
+#pragma omp target teams default(none)
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' 
must have explicitly specified data sharing attributes}}
+  ;
+
+#pragma omp target teams default(none)
+  {
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' 
must have explicitly specified data sharing attributes}}
+;
+  }
+
   goto L2; // expected-error {{use of undeclared label 'L2'}}
 #pragma omp target teams
   L2:


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


r350441 - [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Jan  4 14:12:13 2019
New Revision: 350441

URL: http://llvm.org/viewvc/llvm-project?rev=350441&view=rev
Log:
[OpenMP] Refactor const restriction for linear

As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/for_linear_messages.cpp
cfe/trunk/test/OpenMP/for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=350441&r1=350440&r2=350441&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jan  4 14:12:13 2019
@@ -11531,20 +11531,12 @@ bool Sema::CheckOpenMPLinearDecl(const V
   }
   Type = Type.getNonReferenceType();
 
-  // A list item must not be const-qualified.
-  if (Type.isConstant(Context)) {
-Diag(ELoc, diag::err_omp_const_variable)
-<< getOpenMPClauseName(OMPC_linear);
-if (D) {
-  bool IsDecl =
-  !VD ||
-  VD->isThisDeclarationADefinition(Context) == 
VarDecl::DeclarationOnly;
-  Diag(D->getLocation(),
-   IsDecl ? diag::note_previous_decl : diag::note_defined_here)
-  << D;
-}
+  // OpenMP 5.0 [2.19.3, List Item Privatization, Restrictions]
+  // A variable that is privatized must not have a const-qualified type
+  // unless it is of class type with a mutable member. This restriction does
+  // not apply to the firstprivate clause.
+  if (rejectConstNotMutableType(*this, D, Type, OMPC_linear, ELoc))
 return true;
-  }
 
   // A list item must be of integral or pointer type.
   Type = Type.getUnqualifiedType().getCanonicalType();

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp?rev=350441&r1=350440&r2=350441&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp Fri 
Jan  4 14:12:13 2019
@@ -189,7 +189,7 @@ template int foomain(I
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}}
+#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -294,7 +294,7 @@ int main(int argc, char **argv) {
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}} expected-error {{incomplete type 'S1' where a 
complete type is required}}
+#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}} expected-error 
{{incomplete type 'S1' where a complete type is required}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target

Modified: cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp?rev=350441&r1=350440&r2=350441&view=diff
==

[clang] 0103d4d - [Clang][OpenMP] Don't overload "extension" in status doc

2022-06-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-06-27T18:41:17-04:00
New Revision: 0103d4da740c9d2688389e2aa5e3c2f3792e6940

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

LOG: [Clang][OpenMP] Don't overload "extension" in status doc

In Clang's OpenMPSupport.rst, "extension" is currently overloaded to
describe both:

1. Standard OpenMP features that appear only in recent versions of the
   OpenMP spec.
2. Non-standard features supported by Clang.  This usage appears in
   the final table on the page.

Last fall, we discussed this issue in the OpenMP in LLVM call and
agreed it should be corrected.  This patch takes the simple approach
of dropping the word "extension" for all occurrences of the first
usage.  The result seems to read well.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 0f306be72ba0..336d8e597522 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -117,19 +117,19 @@ implementation.
 
+--+--+--+---+
 |Category  | Feature   
   | Status   | Reviews 
  |
 
+==+==+==+===+
-| loop extension   | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
+| loop | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
 
+--+--+--+---+
-| loop extension   | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
+| loop | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
 
+--+--+--+---+
-| loop extension   | collapse imperfectly nested loop  
   | :good:`done` | 
  |
+| loop | collapse imperfectly nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | collapse non-rectangular nested loop  
   | :good:`done` | 
  |
+| loop | collapse non-rectangular nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | C++ range-base for loop   
   | :good:`done` | 
  |
+| loop | C++ range-base for loop   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | clause: if for SIMD directives
   | :good:`do

[clang] 2f5b2ea - [UpdateCCTestChecks] Implement --global-value-regex

2021-07-20 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-07-20T11:23:20-04:00
New Revision: 2f5b2ea6cd854edfa2722ae0b5acf604a333e785

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

LOG: [UpdateCCTestChecks] Implement --global-value-regex

`--check-globals` activates checks for all global values, and
`--global-value-regex` filters them.  For example, I'd like to use it
in OpenMP offload codegen tests to check only global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
clang/test/utils/update_cc_test_checks/global-value-regex.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
new file mode 100644
index 0..cacaac63b0368
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+void foo() {
+  static int i, j;
+}
+void bar() {
+  static int i, j;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
new file mode 100644
index 0..b0f74c5381984
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
@@ -0,0 +1,21 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "foo\.."
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+//.
+// CHECK: @foo.i = internal global i32 0, align 4
+// CHECK: @foo.j = internal global i32 0, align 4
+//.
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  static int i, j;
+}
+// CHECK-LABEL: @bar(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void bar() {
+  static int i, j;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/global-value-regex.test 
b/clang/test/utils/update_cc_test_checks/global-value-regex.test
new file mode 100644
index 0..33103e101794d
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/global-value-regex.test
@@ -0,0 +1,18 @@
+RUN: rm -rf %t && mkdir %t
+
+# Check --global-value-regex.
+RUN: cp %S/Inputs/global-value-regex.c %t/test.c
+RUN: %update_cc_test_checks %t/test.c --check-globals \
+RUN:   --global-value-regex "foo\.."
+RUN: 
diff  -u %S/Inputs/global-value-regex.c.expected %t/test.c
+
+# Check that the generated directives actually work correctly.
+RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
+# Show lit failures while avoiding confusing FileCheck input dump nesting.
+RUN: %lit %t
+# Lit was successful.  Sanity-check the results with deterministic test order.
+RUN: rm %t/.lit_test_times.txt
+RUN: %lit %t 2>&1 | FileCheck %s
+
+CHECK: Testing: 1 tests
+CHECK: PASS: {{.*}} test.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index ff48e3b9f678e..29d22401cf73d 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -36,9 +36,12 @@ def parse_commandline_args(parser):
   help='List of regular expressions to replace matching 
value names')
   parser.add_argument('--prefix-filecheck-ir-name', default='',
   help='Add a prefix to FileCheck IR value names to avoid 
conflicts with scripted names')
+  parser.add_argument('--global-value-regex', nargs='+', default=[],
+  help='List of regular expressions that a global value 
declaration must match to generate a check (has no effect if checking globals 
is not enabled)')
   args = parser.parse_args()
-  global _verbose
+  global _verbose, _global_value_regex
   _verbose = args.verbose
+  _global_value_regex = args.global_value_regex
   return args
 
 
@@ -796,13 +799,27 @@ def add_global_checks(glob_val_dict, comment_marker, 
prefix_list, output_lines,
 if not glob_val_dict[checkprefix][nameless_value.check_prefix]:
   continue
 
-output_lines.append(comment_marker + SEPARATOR)
-
+check_lines = []
 global_vars_seen_before = [key for key in global_vars_seen.keys()]
 for line in glob_val_dict[checkprefix][nameless_value.check_prefix]:
+  if _global_value_regex:
+matched = False
+for regex in _global_value_regex:
+  if re.match('^@' + regex + ' = ', line):
+matched =

[clang] 5b0a948 - [UpdateCCTestChecks] Implement --global-hex-value-regex

2021-07-20 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-07-20T11:23:20-04:00
New Revision: 5b0a948a81e695f044e88659be18a28256b1e309

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

LOG: [UpdateCCTestChecks] Implement --global-hex-value-regex

For example, in OpenMP offload codegen tests, global variables like
`.offload_maptypes*` are much easier to read in hex.

Reviewed By: jdoerfert

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c

clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
clang/test/utils/update_cc_test_checks/global-hex-value-regex.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c
new file mode 100644
index 0..ad4c109c45ec5
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+void foo() {
+  static int hex = 0x10;
+  static int dec = 10;
+}
+void bar() {
+  static int hex = 0x20;
+  static int dec = 20;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
new file mode 100644
index 0..3018d0261adf9
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
@@ -0,0 +1,25 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "foo\..*" "bar\..*" 
--global-hex-value-regex ".*\.hex"
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+//.
+// CHECK: @foo.hex = internal global i32 [[#0x10]], align 4
+// CHECK: @foo.dec = internal global i32 10, align 4
+// CHECK: @bar.hex = internal global i32 [[#0x20]], align 4
+// CHECK: @bar.dec = internal global i32 20, align 4
+//.
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  static int hex = 0x10;
+  static int dec = 10;
+}
+// CHECK-LABEL: @bar(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void bar() {
+  static int hex = 0x20;
+  static int dec = 20;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test 
b/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
new file mode 100644
index 0..6ff06b4028d82
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
@@ -0,0 +1,19 @@
+RUN: rm -rf %t && mkdir %t
+
+# Check --global-hex-value-regex.
+RUN: cp %S/Inputs/global-hex-value-regex.c %t/test.c
+RUN: %update_cc_test_checks %t/test.c --check-globals \
+RUN: --global-value-regex "foo\..*" "bar\..*" \
+RUN: --global-hex-value-regex ".*\.hex"
+RUN: 
diff  -u %S/Inputs/global-hex-value-regex.c.expected %t/test.c
+
+# Check that the generated directives actually work correctly.
+RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
+# Show lit failures while avoiding confusing FileCheck input dump nesting.
+RUN: %lit %t
+# Lit was successful.  Sanity-check the results with deterministic test order.
+RUN: rm %t/.lit_test_times.txt
+RUN: %lit %t 2>&1 | FileCheck %s
+
+CHECK: Testing: 1 tests
+CHECK: PASS: {{.*}} test.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 29d22401cf73d..aa9b845f05fdc 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -38,10 +38,13 @@ def parse_commandline_args(parser):
   help='Add a prefix to FileCheck IR value names to avoid 
conflicts with scripted names')
   parser.add_argument('--global-value-regex', nargs='+', default=[],
   help='List of regular expressions that a global value 
declaration must match to generate a check (has no effect if checking globals 
is not enabled)')
+  parser.add_argument('--global-hex-value-regex', nargs='+', default=[],
+  help='List of regular expressions such that, for 
matching global value declarations, literal integer values should be encoded in 
hex in the associated FileCheck directives')
   args = parser.parse_args()
-  global _verbose, _global_value_regex
+  global _verbose, _global_value_regex, _global_hex_value_regex
   _verbose = args.verbose
   _global_value_regex = args.global_value_regex
+  _global_hex_value_regex = args.global_hex_value_regex
   return args
 
 
@@ -607,6 +610,12 @@ def transform_line_vars(match):
   for i, line in enumerate(lines):

[clang] 2bfe053 - [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines

2021-06-21 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-06-21T17:01:17-04:00
New Revision: 2bfe0536e5143caad80f7a9691fa775cf451317b

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

LOG: [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines

Without this patch, llvm/utils/update_cc_test_checks.py fails to
perform `--replace-value-regex` replacements when two RUN lines
produce the same output and use the same single FileCheck prefix.  The
problem is that replacements in a RUN line's output are not performed
until after comparing against previous RUN lines' output, where
replacements have already been performed.  This patch fixes that.

Reviewed By: MaskRay

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

Added: 

clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c

clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
new file mode 100644
index ..8914a2195371
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+
+void foo(void) {
+  #pragma omp target
+  ;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
new file mode 100644
index ..ea3cc9480f6d
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+"
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_foo_l7() 
#[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret void
+//
+void foo(void) {
+  #pragma omp target
+  ;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test 
b/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test
new file mode 100644
index ..c2fdf6113fc2
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test
@@ -0,0 +1,7 @@
+# Test that --replace-value-regex is applied correctly when multiple RUN lines
+# use the same FileCheck prefix and have the same output.
+
+RUN: cp %S/Inputs/replace-value-regex-across-runs.c %t.c
+RUN: %update_cc_test_checks %t.c \
+RUN: --replace-value-regex '__omp_offloading_[0-9a-z]+_[0-9a-z]+'
+RUN: 
diff  -u %S/Inputs/replace-value-regex-across-runs.c.expected %t.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 80b0c847080c..3f3682c5b9de 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -351,27 +351,6 @@ def process_run_line(self, function_re, scrubber, 
raw_tool_output, prefixes):
 for l in scrubbed_body.splitlines():
   print('  ' + l, file=sys.stderr)
   for prefix in prefixes:
-if func in self._func_dict[prefix]:
-  if (self._func_dict[prefix][func] is None or
-  str(self._func_dict[prefix][func]) != scrubbed_body or
-  self._func_dict[prefix][func].args_and_sig != args_and_sig or
-  self._func_dict[prefix][func].attrs != attrs):
-if (self._func_dict[prefix][func] is not None and
-self._func_dict[prefix][func].is_same_except_arg_names(
-scrubbed_extra,
-args_and_sig,
-attrs)):
-  self._func_dict[prefix][func].scrub = scrubbed_extra
-  self._func_dict[prefix][func].args_and_sig = args_and_sig
-  continue
-else:
-  # This means a previous RUN line produced a body for this 
function
-  # that is 
diff erent from the one produced by this current RUN line,
-  # so the body can't be common accross RUN lines. We use None to
-  

[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl created 
https://github.com/llvm/llvm-project/pull/102483

Make it possible to do things like the following, regardless of whether 
`$GPU_ARCH` is for nvptx or amdgpu:

```
$ clang -O1 -g -fopenmp -fopenmp-targets=$GPU_ARCH test.c  \
-Xoffload-linker -mllvm=-pass-remarks=inline   \
-Xoffload-linker -mllvm=-force-remove-attribute=g.internalized:noinline\
-Xoffload-linker --lto-newpm-passes='forceattrs,default'   \
-Xoffload-linker --lto-debug-pass-manager  \
-foffload-lto
```

To accomplish that:

- In clang-linker-wrapper, do not forward options via `-Wl` if they might have 
literal commas.  Use `-Xlinker` instead.
- In clang-nvlink-wrapper, accept `--lto-debug-pass-manager` and 
`--lto-newpm-passes`.
- In clang-nvlink-wrapper, drop `-passes` because it's inconsistent with the 
interface of `lld`, which is used instead of clang-nvlink-wrapper when the 
target is amdgpu.  Without this patch, `-passes` is passed to `nvlink`, 
producing an error anyway.

>From 9e8a8e78f3014324d8aa35dd1615b3f5720a5cb4 Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Wed, 7 Aug 2024 19:10:33 -0400
Subject: [PATCH] [Clang] Simplify specifying passes via -Xoffload-linker

Make it possible to do things like the following, regardless of
whether `$GPU_ARCH` is for nvptx or amdgpu:

```
$ clang -O1 -g -fopenmp -fopenmp-targets=$GPU_ARCH test.c  \
-Xoffload-linker -mllvm=-pass-remarks=inline   \
-Xoffload-linker -mllvm=-force-remove-attribute=g.internalized:noinline\
-Xoffload-linker --lto-newpm-passes='forceattrs,default'   \
-Xoffload-linker --lto-debug-pass-manager  \
-foffload-lto
```

To accomplish that:

- In clang-linker-wrapper, do not forward options via `-Wl` if they
  might have literal commas.  Use `-Xlinker` instead.
- In clang-nvlink-wrapper, accept `--lto-debug-pass-manager` and
  `--lto-newpm-passes`.
- In clang-nvlink-wrapper, drop `-passes` because it's inconsistent
  with the interface of `lld`, which is used instead of
  clang-nvlink-wrapper when the target is amdgpu.  Without this patch,
  `-passes` is passed to `nvlink`, producing an error anyway.
---
 clang/test/Driver/linker-wrapper.c | 18 --
 clang/test/Driver/nvlink-wrapper.c |  8 
 .../ClangLinkerWrapper.cpp | 12 
 .../ClangNVLinkWrapper.cpp | 15 ++-
 clang/tools/clang-nvlink-wrapper/NVLinkOpts.td |  8 
 5 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 99cfdb9ebfc7c..e70715d2a9bd7 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -238,9 +238,15 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--offload-opt=-pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
-mllvm -pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-
-// OFFLOAD-OPT: clang{{.*}}-Wl,--plugin-opt=-pass-remarks=foo
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --offload-opt=-pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OFFLOAD-OPT
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   -mllvm -pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=MLLVM
+
+//MLLVM: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//  OFFLOAD-OPT: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//   MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
+//  OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
+// OFFLOAD-OPT-SAME: {{$}}
diff --git a/clang/test/Driver/nvlink-wrapper.c 
b/clang/test/Driver/nvlink-wrapper.c
index 318315ddaca34..5d835d8d6cb2a 100644
--- a/clang/test/Driver/nvlink-wrapper.c
+++ b/clang/test/Driver/nvlink-wrapper.c
@@ -70,3 +70,11 @@ int baz() { return y + x; }
 // RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
 // RUN:   -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s 
--check-prefix=PATH
 // PATH-NOT: --cuda-path=/opt/cuda
+
+//
+// Check that passes can be specified and debugged.
+//
+// RUN: clang-nvlink-wrapper --dry-run %t.o 

[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102483

>From 9e8a8e78f3014324d8aa35dd1615b3f5720a5cb4 Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Wed, 7 Aug 2024 19:10:33 -0400
Subject: [PATCH 1/2] [Clang] Simplify specifying passes via -Xoffload-linker

Make it possible to do things like the following, regardless of
whether `$GPU_ARCH` is for nvptx or amdgpu:

```
$ clang -O1 -g -fopenmp -fopenmp-targets=$GPU_ARCH test.c  \
-Xoffload-linker -mllvm=-pass-remarks=inline   \
-Xoffload-linker -mllvm=-force-remove-attribute=g.internalized:noinline\
-Xoffload-linker --lto-newpm-passes='forceattrs,default'   \
-Xoffload-linker --lto-debug-pass-manager  \
-foffload-lto
```

To accomplish that:

- In clang-linker-wrapper, do not forward options via `-Wl` if they
  might have literal commas.  Use `-Xlinker` instead.
- In clang-nvlink-wrapper, accept `--lto-debug-pass-manager` and
  `--lto-newpm-passes`.
- In clang-nvlink-wrapper, drop `-passes` because it's inconsistent
  with the interface of `lld`, which is used instead of
  clang-nvlink-wrapper when the target is amdgpu.  Without this patch,
  `-passes` is passed to `nvlink`, producing an error anyway.
---
 clang/test/Driver/linker-wrapper.c | 18 --
 clang/test/Driver/nvlink-wrapper.c |  8 
 .../ClangLinkerWrapper.cpp | 12 
 .../ClangNVLinkWrapper.cpp | 15 ++-
 clang/tools/clang-nvlink-wrapper/NVLinkOpts.td |  8 
 5 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 99cfdb9ebfc7cd..e70715d2a9bd7e 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -238,9 +238,15 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--offload-opt=-pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
-mllvm -pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-
-// OFFLOAD-OPT: clang{{.*}}-Wl,--plugin-opt=-pass-remarks=foo
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --offload-opt=-pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OFFLOAD-OPT
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   -mllvm -pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=MLLVM
+
+//MLLVM: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//  OFFLOAD-OPT: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//   MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
+//  OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
+// OFFLOAD-OPT-SAME: {{$}}
diff --git a/clang/test/Driver/nvlink-wrapper.c 
b/clang/test/Driver/nvlink-wrapper.c
index 318315ddaca340..5d835d8d6cb2a2 100644
--- a/clang/test/Driver/nvlink-wrapper.c
+++ b/clang/test/Driver/nvlink-wrapper.c
@@ -70,3 +70,11 @@ int baz() { return y + x; }
 // RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
 // RUN:   -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s 
--check-prefix=PATH
 // PATH-NOT: --cuda-path=/opt/cuda
+
+//
+// Check that passes can be specified and debugged.
+//
+// RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
+// RUN:   --lto-debug-pass-manager --lto-newpm-passes=forceattrs \
+// RUN:   -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=PASSES
+// PASSES: Running pass: ForceFunctionAttrsPass
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 24cc4f0eeadf91..7030556ce01b19 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -527,9 +527,11 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
 
   // Forward all of the `--offload-opt` and similar options to the device.
   if (linkerSupportsLTO(Args)) {
-for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
+for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) {
+  CmdArgs.push_back(Args.MakeArgString("-Xlinker"));
   CmdArgs.push_back(
-  Args.MakeArgString("-Wl,--plugin-opt=" + 
StringRef(Ar

[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-08 Thread Joel E. Denny via cfe-commits


@@ -527,9 +527,11 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
 
   // Forward all of the `--offload-opt` and similar options to the device.
   if (linkerSupportsLTO(Args)) {
-for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
+for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) {
+  CmdArgs.push_back(Args.MakeArgString("-Xlinker"));

jdenny-ornl wrote:

Thanks.  Applied.

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


[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102483

>From 9e8a8e78f3014324d8aa35dd1615b3f5720a5cb4 Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Wed, 7 Aug 2024 19:10:33 -0400
Subject: [PATCH 1/3] [Clang] Simplify specifying passes via -Xoffload-linker

Make it possible to do things like the following, regardless of
whether `$GPU_ARCH` is for nvptx or amdgpu:

```
$ clang -O1 -g -fopenmp -fopenmp-targets=$GPU_ARCH test.c  \
-Xoffload-linker -mllvm=-pass-remarks=inline   \
-Xoffload-linker -mllvm=-force-remove-attribute=g.internalized:noinline\
-Xoffload-linker --lto-newpm-passes='forceattrs,default'   \
-Xoffload-linker --lto-debug-pass-manager  \
-foffload-lto
```

To accomplish that:

- In clang-linker-wrapper, do not forward options via `-Wl` if they
  might have literal commas.  Use `-Xlinker` instead.
- In clang-nvlink-wrapper, accept `--lto-debug-pass-manager` and
  `--lto-newpm-passes`.
- In clang-nvlink-wrapper, drop `-passes` because it's inconsistent
  with the interface of `lld`, which is used instead of
  clang-nvlink-wrapper when the target is amdgpu.  Without this patch,
  `-passes` is passed to `nvlink`, producing an error anyway.
---
 clang/test/Driver/linker-wrapper.c | 18 --
 clang/test/Driver/nvlink-wrapper.c |  8 
 .../ClangLinkerWrapper.cpp | 12 
 .../ClangNVLinkWrapper.cpp | 15 ++-
 clang/tools/clang-nvlink-wrapper/NVLinkOpts.td |  8 
 5 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 99cfdb9ebfc7cd..e70715d2a9bd7e 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -238,9 +238,15 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--offload-opt=-pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
-mllvm -pass-remarks=foo \
-// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=OFFLOAD-OPT
-
-// OFFLOAD-OPT: clang{{.*}}-Wl,--plugin-opt=-pass-remarks=foo
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --offload-opt=-pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OFFLOAD-OPT
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   -mllvm -pass-remarks=foo,bar --linker-path=/usr/bin/ld \
+// RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=MLLVM
+
+//MLLVM: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//  OFFLOAD-OPT: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
+//   MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
+//  OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
+// OFFLOAD-OPT-SAME: {{$}}
diff --git a/clang/test/Driver/nvlink-wrapper.c 
b/clang/test/Driver/nvlink-wrapper.c
index 318315ddaca340..5d835d8d6cb2a2 100644
--- a/clang/test/Driver/nvlink-wrapper.c
+++ b/clang/test/Driver/nvlink-wrapper.c
@@ -70,3 +70,11 @@ int baz() { return y + x; }
 // RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
 // RUN:   -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s 
--check-prefix=PATH
 // PATH-NOT: --cuda-path=/opt/cuda
+
+//
+// Check that passes can be specified and debugged.
+//
+// RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
+// RUN:   --lto-debug-pass-manager --lto-newpm-passes=forceattrs \
+// RUN:   -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=PASSES
+// PASSES: Running pass: ForceFunctionAttrsPass
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 24cc4f0eeadf91..7030556ce01b19 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -527,9 +527,11 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
 
   // Forward all of the `--offload-opt` and similar options to the device.
   if (linkerSupportsLTO(Args)) {
-for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
+for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) {
+  CmdArgs.push_back(Args.MakeArgString("-Xlinker"));
   CmdArgs.push_back(
-  Args.MakeArgString("-Wl,--plugin-opt=" + 
StringRef(Ar

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl created 
https://github.com/llvm/llvm-project/pull/102521

When working on very busy systems, check-offload frequently fails many tests 
with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment variable 
`CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> Maybe we should bump the default time up? I don't know what's reasonable in 
> this area, but the GPU drivers have a bad habit of deadlocking, so this is to 
> prevent that.

I don't know the right value either.  If no one else is complaining, maybe 10s 
is fine under normal circumstances.

> I think you could document the env var in the error message itself, and `-1` 
> should mean effectively infinite.

Sure, I'll work on that.  Maybe <=0 should be no timeout?


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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102521

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH 1/2] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

>From 711cf93741ba618c7ee8051190b18bba938121fa Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 16:21:28 -0400
Subject: [PATCH 2/2] Apply reviewer suggestion

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 ++-
 clang/lib/Driver/ToolChain.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d8240f8357b40..05642f803d07de 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
  

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits


@@ -116,6 +117,15 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+else if (Val <= 0)

jdenny-ornl wrote:

```suggestion
else
```

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102521

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH 1/3] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

>From 711cf93741ba618c7ee8051190b18bba938121fa Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 16:21:28 -0400
Subject: [PATCH 2/3] Apply reviewer suggestion

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 ++-
 clang/lib/Driver/ToolChain.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d8240f8357b40..05642f803d07de 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
  

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> Also, just be aware that if you set this, it will apply to everything. So if 
> you had a particularly long link job, probably would be a good idea to make 
> it wait forever.

Not sure I understand.  grep found 2 uses of executeToolChainProgram: calling 
amdgpu-arch and nvptx-arch.  Did I miss a use?

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102521

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH 1/4] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

>From 711cf93741ba618c7ee8051190b18bba938121fa Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 16:21:28 -0400
Subject: [PATCH 2/4] Apply reviewer suggestion

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 ++-
 clang/lib/Driver/ToolChain.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d8240f8357b40..05642f803d07de 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
  

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits


@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
   "cannot determine %0 architecture: %1; consider passing it via "
-  "'%2'">;
+  "'%2' or increasing the tool timeout using the environment variable "
+  "'CLANG_TOOL_CHAIN_PROGRAM_WAIT' (in secs, <=0 is inifinite)">;

jdenny-ornl wrote:

Applied.

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits


@@ -116,6 +117,15 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+else
+  SecondsToWait = 0; // infinite

jdenny-ornl wrote:

Applied.  Thanks.

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102521

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH 1/5] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

>From 711cf93741ba618c7ee8051190b18bba938121fa Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 16:21:28 -0400
Subject: [PATCH 2/5] Apply reviewer suggestion

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 ++-
 clang/lib/Driver/ToolChain.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d8240f8357b40..05642f803d07de 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
  

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-08 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

FWIW, on one of my test systems that's currently very busy, check-offload 
consistently fails with amdgpu-arch timeouts.  However, the following so far 
makes it consistently succeed:

```
$ CLANG_TOOLCHAIN_PROGRAM_TIMEOUT=60 ninja check-offload
```

Previously, I've decreased lit parallelism to avoid the timeouts, but it hasn't 
worked consistently, and it slows down the test suite.


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


[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-09 Thread Joel E. Denny via cfe-commits

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


[clang] [Clang] Simplify specifying passes via -Xoffload-linker (PR #102483)

2024-08-09 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

Thanks for the review.

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-09 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> Possibly worth increasing it to a minute then,

Should we also land the env var?  If so, I'll just extend this patch.

Either way, any objection to moving `[Default]SecondsToWait`  into 
executeToolChainProgram so we're maintaining it in just one place?

> this is basically just a last ditch effort to prevent builds from hanging 
> forever. I've had it happen personally where either the CUDA or AMDGPU 
> drivers were stuck, and when I tried to rebuild `libc` `ninja` just hung 
> indefinitely and it took me awhile to figure out why.

I'm not sure how often the situation you describe occurs in practice.  
Hopefully a 60-second pause on a simple compilation doesn't prompt the same 
confusion and a premature Ctrl+C.

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-09 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/102521

>From 6546428805b52f1b6f350193ab08ff027892710f Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 15:02:04 -0400
Subject: [PATCH 1/7] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout

When working on very busy systems, check-offload frequently fails many
tests with this diagnostic:

```
clang: error: cannot determine amdgcn architecture: 
/tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via 
'-march'
```

The timeout is 10 seconds.  This patch accepts the environment
variable `CLANG_TOOL_CHAIN_PROGRAM_WAIT` to increase it.

It should be documented somewhere.  Any suggestions on where?
---
 clang/lib/Driver/ToolChain.cpp | 10 +-
 clang/lib/Driver/ToolChains/AMDGPU.cpp |  3 ++-
 clang/lib/Driver/ToolChains/Cuda.cpp   |  3 ++-
 llvm/utils/lit/lit/TestingConfig.py|  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2d50c2cbbc881c..04b281e1bb10cd 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
@@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
 
 llvm::Expected>
 ToolChain::executeToolChainProgram(StringRef Executable,
-   unsigned SecondsToWait) const {
+   unsigned DefaultSecondsToWait) const {
   llvm::SmallString<64> OutputFile;
   llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
   llvm::FileRemover OutputRemover(OutputFile.c_str());
@@ -116,6 +117,13 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = DefaultSecondsToWait;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
+int Val = std::atoi(Str->c_str());
+if (Val > 0)
+  SecondsToWait = Val;
+  }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))
 return llvm::createStringError(std::error_code(),
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index aa8f9197cfabc3..4ed366d21f5c43 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("amdgpu-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 17c952c808f725..104217eaf5d849 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) 
const {
   else
 Program = GetProgramPath("nvptx-arch");
 
-  auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
+  auto StdoutOrErr = executeToolChainProgram(Program,
+ /*DefaultSecondsToWait=*/10);
   if (!StdoutOrErr)
 return StdoutOrErr.takeError();
 
diff --git a/llvm/utils/lit/lit/TestingConfig.py 
b/llvm/utils/lit/lit/TestingConfig.py
index eb9f8de2a7f960..06713429d06b4b 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ def fromdefaults(litConfig):
 "SYSTEMROOT",
 "TERM",
 "CLANG",
+"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
 "LLDB",
 "LD_PRELOAD",
 "LLVM_SYMBOLIZER_PATH",

>From 711cf93741ba618c7ee8051190b18bba938121fa Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 8 Aug 2024 16:21:28 -0400
Subject: [PATCH 2/7] Apply reviewer suggestion

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 ++-
 clang/lib/Driver/ToolChain.cpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d8240f8357b40..05642f803d07de 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
   " use at your own risk">;
 def err_drv_undetermined_gpu_arch : Error<
  

[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-09 Thread Joel E. Denny via cfe-commits

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-09 Thread Joel E. Denny via cfe-commits

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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-08-09 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

Thanks for the review.

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


[clang] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

Seems like it does what it intends to do.  Thanks for working on it.

However, there's a side effect.  Now that -O1 gets passed along, sometimes it 
triggers an assert fail for AMD GPU:

```
ld.lld: /tmp/llvm/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp:151: 
virtual bool llvm::AMDGPUResourceUsageAnalysis::runOnModule(llvm::Module&): 
Assertion `MF && "function must have been generated already"' failed.
```

On my AMD GPU test system, I see new test fails.  They all use -O1 and fail 
that assert:

```
Failed Tests (4):
  libomptarget :: amdgcn-amd-amdhsa :: api/omp_dynamic_shared_memory_amdgpu.c
  libomptarget :: amdgcn-amd-amdhsa :: 
api/omp_dynamic_shared_memory_mixed_amdgpu.c
  libomptarget :: amdgcn-amd-amdhsa :: offloading/bug51781.c
  libomptarget :: amdgcn-amd-amdhsa :: offloading/bug51982.c
```

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


[clang] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I guess I should just manually pass the optimization level at `O2` for now.

Would -O3 still pass through?

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


[clang] [llvm] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> Updated to pass `-O2` instead, this was the actual behavior that passed, so 
> it's mostly not a functional change.

So you just changed the tests not to use -O1?  Doesn't this patch then 
represent a regression in what's supported?

(Rewriting history with force pushes make it harder to quickly spot what's 
changed since I looked before.  Can you not push new commits instead?)

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


[clang] [llvm] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits


@@ -21,7 +21,6 @@
 // RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll \
 // RUN: LIBOMPTARGET_JIT_SKIP_OPT=true   \
 // RUN: %libomptarget-run-generic
-// TODO:

jdenny-ornl wrote:

Unrelated changed?

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


[clang] [llvm] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits

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


[clang] [llvm] [LinkerWrapper] Always pass `-flto` if the linker supports it (PR #102972)

2024-08-13 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> > > Updated to pass `-O2` instead, this was the actual behavior that passed, 
> > > so it's mostly not a functional change.
> > 
> > 
> > So you just changed the tests not to use -O1? Doesn't this patch then 
> > represent a regression in what's supported?
> 
> I wouldn't consider something "supported" if it only worked because we 
> overruled the user's `-O1` flag and replaced it with `-O2`.

Cases that used to compile successfully (even if more optimized than expected) 
will no longer.  Sounds like a regression.

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


[clang] 7c4eb60 - [Clang] Fix CLANG_TOOLCHAIN_PROGRAM_TIMEOUT logic

2024-09-04 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2024-09-04T18:43:54-04:00
New Revision: 7c4eb60c9509c3a750961eac2dbcaad369d911f2

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

LOG: [Clang] Fix CLANG_TOOLCHAIN_PROGRAM_TIMEOUT logic

PR #102521, which landed as 1ea0865dd6fa, implemented
`CLANG_TOOLCHAIN_PROGRAM_TIMEOUT`, but the logic is obviously wrong.
If the user-specified value is negative, it should become zero to mean
infinite.  Otherwise, it should be left as is.  Thus, use `std::max`
not `std::min`.  This obvious fixup doesn't seem worth another pull
request.

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 64f23d43e87ee8..16f9b629fc538c 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -126,7 +126,7 @@ ToolChain::executeToolChainProgram(StringRef Executable) 
const {
  "CLANG_TOOLCHAIN_PROGRAM_TIMEOUT expected 
"
  "an integer, got '" +
  *Str + "'");
-SecondsToWait = std::min(SecondsToWait, 0); // infinite
+SecondsToWait = std::max(SecondsToWait, 0); // infinite
   }
   if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
 /*MemoryLimit=*/0, &ErrorMessage))



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


[clang] [llvm] [Clang] Add env var for nvptx-arch/amdgpu-arch timeout (PR #102521)

2024-09-04 Thread Joel E. Denny via cfe-commits


@@ -116,6 +116,16 @@ ToolChain::executeToolChainProgram(StringRef Executable,
   };
 
   std::string ErrorMessage;
+  int SecondsToWait = 60;
+  if (std::optional Str =
+  llvm::sys::Process::GetEnv("CLANG_TOOLCHAIN_PROGRAM_TIMEOUT")) {
+if (!llvm::to_integer(*Str, SecondsToWait))
+  return llvm::createStringError(std::error_code(),
+ "CLANG_TOOLCHAIN_PROGRAM_TIMEOUT expected 
"
+ "an integer, got '" +
+ *Str + "'");
+SecondsToWait = std::min(SecondsToWait, 0); // infinite

jdenny-ornl wrote:

So that negative becomes 0 to mean infinite, that's obviously supposed to be 
max not min.  Pushed a fix as 7c4eb60c9509c3a750961eac2dbcaad369d911f2.

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


[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl created 
https://github.com/llvm/llvm-project/pull/96704

The goal of this patch is to enable utilizing LLVM plugin passes and remarks 
for GPU offload code at link time.  Specifically, this patch extends 
clang-linker-wrapper's `--offload-opt` (and consequently `-mllvm`) to accept 
the various LLVM pass options that tools like opt usually accept.  Those 
options include `--passes`, `--load-pass-plugin`, and various remarks options.

Unlike many other LLVM options that are inherited from linked code by 
clang-linker-wrapper (e.g., `-pass-remarks` is already implemented in 
`llvm/lib/IR/DiagnosticHandler.cpp`), these options are implemented separately 
as needed by each tool (e.g., opt, llc).  Fortunately, this patch is able to 
handle most of the implementation by passing the option values to `lto::Config`.

For testing plugin support, this patch uses the simple `Bye` plugin from LLVM 
core, but that requires several small Clang test suite config extensions.

>From 98e04dd372b82c2c5309a6148bb49eb1012a97ee Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Tue, 25 Jun 2024 17:29:49 -0400
Subject: [PATCH] [LinkerWrapper] Extend with usual pass options

The goal of this patch is to enable utilizing LLVM plugin passes and
remarks for GPU offload code at link time.  Specifically, this patch
extends clang-linker-wrapper's `--offload-opt` (and consequently
`-mllvm`) to accept the various LLVM pass options that tools like opt
usually accept.  Those options include `--passes`,
`--load-pass-plugin`, and various remarks options.

Unlike many other LLVM options that are inherited from linked code by
clang-linker-wrapper (e.g., `-pass-remarks` is already implemented in
`llvm/lib/IR/DiagnosticHandler.cpp`), these options are implemented
separately as needed by each tool (e.g., opt, llc).  Fortunately, this
patch is able to handle most of the implementation by passing the
option values to `lto::Config`.

For testing plugin support, this patch uses the simple `Bye` plugin
from LLVM core, but that requires several small Clang test suite
config extensions.
---
 clang/test/CMakeLists.txt |  3 +
 clang/test/Driver/linker-wrapper-llvm-help.c  | 10 +++
 clang/test/Driver/linker-wrapper-passes.ll| 86 +++
 clang/test/Driver/lit.local.cfg   |  1 +
 clang/test/lit.cfg.py | 12 +++
 clang/test/lit.site.cfg.py.in |  4 +
 .../tools/clang-linker-wrapper/CMakeLists.txt |  2 +
 .../ClangLinkerWrapper.cpp| 74 
 .../clang-linker-wrapper/LinkerWrapperOpts.td |  8 +-
 9 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/linker-wrapper-llvm-help.c
 create mode 100644 clang/test/Driver/linker-wrapper-passes.ll

diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5fceb1d710334..8303269a9ad07 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -11,6 +11,9 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
   ENABLE_BACKTRACES
+  LLVM_BUILD_EXAMPLES
+  LLVM_BYE_LINK_INTO_TOOLS
+  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_ZSTD
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
diff --git a/clang/test/Driver/linker-wrapper-llvm-help.c 
b/clang/test/Driver/linker-wrapper-llvm-help.c
new file mode 100644
index 0..ffd1cf78bcd9a
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-llvm-help.c
@@ -0,0 +1,10 @@
+// Check that these simple command lines for listing LLVM options are 
supported,
+// as claimed by 'clang-linker-wrapper --help'.
+
+// RUN: clang-linker-wrapper -mllvm --help 2>&1 | FileCheck %s
+// RUN: clang-linker-wrapper --offload-opt=--help 2>&1 | FileCheck %s
+
+// Look for a few options supported only after -mllvm and --offload-opt.
+// CHECK: OPTIONS:
+// CHECK-DAG: --passes=
+// CHECK-DAG: --load-pass-plugin=
diff --git a/clang/test/Driver/linker-wrapper-passes.ll 
b/clang/test/Driver/linker-wrapper-passes.ll
new file mode 100644
index 0..28493b9a88eb1
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-passes.ll
@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang 

[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits


@@ -0,0 +1,10 @@
+// Check that these simple command lines for listing LLVM options are 
supported,

jdenny-ornl wrote:

Grepping for -help in llvm's test suite finds various such tests. The point 
here is to make sure `--offload-opt=--help can list these opt-like options as 
opposed to the normal clang-linker-wrapper options.  Seems like an important 
feature.

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


[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits


@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang -cc1as -o %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: -triple x86_64-unknown-linux-gnu -filetype obj -target-cpu x86-64 \
+; RUN: %t/host-x86_64-unknown-linux-gnu.s
+
+; Check plugin, -passes, and no remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
+
+; Check plugin, -p, and remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-p="function(goodbye),module(inline)" \
+; RUN: --offload-opt=-pass-remarks=inline \
+; RUN: --offload-opt=-pass-remarks-output=%t/remarks.yml \
+; RUN: --offload-opt=-pass-remarks-filter=inline \
+; RUN: --offload-opt=-pass-remarks-format=yaml 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT,REM %s
+; RUN: FileCheck -input-file=%t/remarks.yml -match-full-lines \
+; RUN: -check-prefixes=YML %s
+
+; Check handling of bad plugin.
+; RUN: not clang-linker-wrapper \
+; RUN: --offload-opt=-load-pass-plugin=%t/nonexistent.so 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=BAD-PLUGIN %s
+
+;  OUT-NOT: {{.}}
+;  OUT: Bye: f
+; OUT-NEXT: Bye: test
+; REM-NEXT: remark: {{.*}} 'f' inlined into 'test' {{.*}}
+;  OUT-NOT: {{.}}
+
+;  YML-NOT: {{.}}
+;  YML: --- !Passed
+; YML-NEXT: Pass: inline
+; YML-NEXT: Name: Inlined
+; YML-NEXT: Function: test
+; YML-NEXT: Args:
+;  YML:  - Callee: f
+;  YML:  - Caller: test
+;  YML: ...
+;  YML-NOT: {{.}}
+
+; BAD-PLUGIN-NOT: {{.}}
+; BAD-PLUGIN: {{.*}}Could not load library {{.*}}nonexistent.so{{.*}}
+; BAD-PLUGIN-NOT: {{.}}
+
+;--- host-x86_64-unknown-linux-gnu.ll
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;--- openmp-amdgcn-amd-amdhsa.ll
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
+
+define void @f() {
+entry:
+  ret void
+}
+
+define amdgpu_kernel void @test() {

jdenny-ornl wrote:

That came from clang followed by llvm-reduce.  I'll look into refactoring it.

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


[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/96704

>From 98e04dd372b82c2c5309a6148bb49eb1012a97ee Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Tue, 25 Jun 2024 17:29:49 -0400
Subject: [PATCH 1/2] [LinkerWrapper] Extend with usual pass options

The goal of this patch is to enable utilizing LLVM plugin passes and
remarks for GPU offload code at link time.  Specifically, this patch
extends clang-linker-wrapper's `--offload-opt` (and consequently
`-mllvm`) to accept the various LLVM pass options that tools like opt
usually accept.  Those options include `--passes`,
`--load-pass-plugin`, and various remarks options.

Unlike many other LLVM options that are inherited from linked code by
clang-linker-wrapper (e.g., `-pass-remarks` is already implemented in
`llvm/lib/IR/DiagnosticHandler.cpp`), these options are implemented
separately as needed by each tool (e.g., opt, llc).  Fortunately, this
patch is able to handle most of the implementation by passing the
option values to `lto::Config`.

For testing plugin support, this patch uses the simple `Bye` plugin
from LLVM core, but that requires several small Clang test suite
config extensions.
---
 clang/test/CMakeLists.txt |  3 +
 clang/test/Driver/linker-wrapper-llvm-help.c  | 10 +++
 clang/test/Driver/linker-wrapper-passes.ll| 86 +++
 clang/test/Driver/lit.local.cfg   |  1 +
 clang/test/lit.cfg.py | 12 +++
 clang/test/lit.site.cfg.py.in |  4 +
 .../tools/clang-linker-wrapper/CMakeLists.txt |  2 +
 .../ClangLinkerWrapper.cpp| 74 
 .../clang-linker-wrapper/LinkerWrapperOpts.td |  8 +-
 9 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/linker-wrapper-llvm-help.c
 create mode 100644 clang/test/Driver/linker-wrapper-passes.ll

diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5fceb1d710334..8303269a9ad07 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -11,6 +11,9 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
   ENABLE_BACKTRACES
+  LLVM_BUILD_EXAMPLES
+  LLVM_BYE_LINK_INTO_TOOLS
+  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_ZSTD
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
diff --git a/clang/test/Driver/linker-wrapper-llvm-help.c 
b/clang/test/Driver/linker-wrapper-llvm-help.c
new file mode 100644
index 0..ffd1cf78bcd9a
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-llvm-help.c
@@ -0,0 +1,10 @@
+// Check that these simple command lines for listing LLVM options are 
supported,
+// as claimed by 'clang-linker-wrapper --help'.
+
+// RUN: clang-linker-wrapper -mllvm --help 2>&1 | FileCheck %s
+// RUN: clang-linker-wrapper --offload-opt=--help 2>&1 | FileCheck %s
+
+// Look for a few options supported only after -mllvm and --offload-opt.
+// CHECK: OPTIONS:
+// CHECK-DAG: --passes=
+// CHECK-DAG: --load-pass-plugin=
diff --git a/clang/test/Driver/linker-wrapper-passes.ll 
b/clang/test/Driver/linker-wrapper-passes.ll
new file mode 100644
index 0..28493b9a88eb1
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-passes.ll
@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang -cc1as -o %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: -triple x86_64-unknown-linux-gnu -filetype obj -target-cpu x86-64 \
+; RUN: %t/host-x86_64-unknown-linux-gnu.s
+
+; Check plugin, -passes, and no remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
+
+; Check plugin, -p, and remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-p="function(goodbye),module(inline)" \
+; RUN: --offload-opt=-pass-remarks=inline \
+; RUN: 

[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits


@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang -cc1as -o %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: -triple x86_64-unknown-linux-gnu -filetype obj -target-cpu x86-64 \
+; RUN: %t/host-x86_64-unknown-linux-gnu.s
+
+; Check plugin, -passes, and no remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
+
+; Check plugin, -p, and remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-p="function(goodbye),module(inline)" \
+; RUN: --offload-opt=-pass-remarks=inline \
+; RUN: --offload-opt=-pass-remarks-output=%t/remarks.yml \
+; RUN: --offload-opt=-pass-remarks-filter=inline \
+; RUN: --offload-opt=-pass-remarks-format=yaml 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT,REM %s
+; RUN: FileCheck -input-file=%t/remarks.yml -match-full-lines \
+; RUN: -check-prefixes=YML %s
+
+; Check handling of bad plugin.
+; RUN: not clang-linker-wrapper \
+; RUN: --offload-opt=-load-pass-plugin=%t/nonexistent.so 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=BAD-PLUGIN %s
+
+;  OUT-NOT: {{.}}
+;  OUT: Bye: f
+; OUT-NEXT: Bye: test
+; REM-NEXT: remark: {{.*}} 'f' inlined into 'test' {{.*}}
+;  OUT-NOT: {{.}}
+
+;  YML-NOT: {{.}}
+;  YML: --- !Passed
+; YML-NEXT: Pass: inline
+; YML-NEXT: Name: Inlined
+; YML-NEXT: Function: test
+; YML-NEXT: Args:
+;  YML:  - Callee: f
+;  YML:  - Caller: test
+;  YML: ...
+;  YML-NOT: {{.}}
+
+; BAD-PLUGIN-NOT: {{.}}
+; BAD-PLUGIN: {{.*}}Could not load library {{.*}}nonexistent.so{{.*}}
+; BAD-PLUGIN-NOT: {{.}}
+
+;--- host-x86_64-unknown-linux-gnu.ll
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;--- openmp-amdgcn-amd-amdhsa.ll
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
+
+define void @f() {
+entry:
+  ret void
+}
+
+define amdgpu_kernel void @test() {

jdenny-ornl wrote:

> Is the kernel really necessary?

OK, I removed it and the test still passed.

> Otherwise I'd just compile with `-mtriple=amdgcn--` or something.

Not sure what you're asking for here.  Which command line do you want me to 
change?

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


[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> Makes sense overall. However in the future I'm looking to move away from the 
> home-baked LTO pipeline in favor of giving it to the linker. That allows me 
> to set up libraries as a part of the target toolchain in the driver. I guess 
> for that I'll just need to forward `-mllvm` to the internal clang invocation.

As long as there's some way to inject an LLVM pass plugin at link time (even if 
it requires -flto or -foffload-lto), that's fine.  I don't know that a stable 
command-line interface is critical at this point.  Of course, please ping me if 
it changes.

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


[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/96704

>From 98e04dd372b82c2c5309a6148bb49eb1012a97ee Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Tue, 25 Jun 2024 17:29:49 -0400
Subject: [PATCH 1/3] [LinkerWrapper] Extend with usual pass options

The goal of this patch is to enable utilizing LLVM plugin passes and
remarks for GPU offload code at link time.  Specifically, this patch
extends clang-linker-wrapper's `--offload-opt` (and consequently
`-mllvm`) to accept the various LLVM pass options that tools like opt
usually accept.  Those options include `--passes`,
`--load-pass-plugin`, and various remarks options.

Unlike many other LLVM options that are inherited from linked code by
clang-linker-wrapper (e.g., `-pass-remarks` is already implemented in
`llvm/lib/IR/DiagnosticHandler.cpp`), these options are implemented
separately as needed by each tool (e.g., opt, llc).  Fortunately, this
patch is able to handle most of the implementation by passing the
option values to `lto::Config`.

For testing plugin support, this patch uses the simple `Bye` plugin
from LLVM core, but that requires several small Clang test suite
config extensions.
---
 clang/test/CMakeLists.txt |  3 +
 clang/test/Driver/linker-wrapper-llvm-help.c  | 10 +++
 clang/test/Driver/linker-wrapper-passes.ll| 86 +++
 clang/test/Driver/lit.local.cfg   |  1 +
 clang/test/lit.cfg.py | 12 +++
 clang/test/lit.site.cfg.py.in |  4 +
 .../tools/clang-linker-wrapper/CMakeLists.txt |  2 +
 .../ClangLinkerWrapper.cpp| 74 
 .../clang-linker-wrapper/LinkerWrapperOpts.td |  8 +-
 9 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/linker-wrapper-llvm-help.c
 create mode 100644 clang/test/Driver/linker-wrapper-passes.ll

diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5fceb1d710334..8303269a9ad07 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -11,6 +11,9 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
   ENABLE_BACKTRACES
+  LLVM_BUILD_EXAMPLES
+  LLVM_BYE_LINK_INTO_TOOLS
+  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_ZSTD
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
diff --git a/clang/test/Driver/linker-wrapper-llvm-help.c 
b/clang/test/Driver/linker-wrapper-llvm-help.c
new file mode 100644
index 0..ffd1cf78bcd9a
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-llvm-help.c
@@ -0,0 +1,10 @@
+// Check that these simple command lines for listing LLVM options are 
supported,
+// as claimed by 'clang-linker-wrapper --help'.
+
+// RUN: clang-linker-wrapper -mllvm --help 2>&1 | FileCheck %s
+// RUN: clang-linker-wrapper --offload-opt=--help 2>&1 | FileCheck %s
+
+// Look for a few options supported only after -mllvm and --offload-opt.
+// CHECK: OPTIONS:
+// CHECK-DAG: --passes=
+// CHECK-DAG: --load-pass-plugin=
diff --git a/clang/test/Driver/linker-wrapper-passes.ll 
b/clang/test/Driver/linker-wrapper-passes.ll
new file mode 100644
index 0..28493b9a88eb1
--- /dev/null
+++ b/clang/test/Driver/linker-wrapper-passes.ll
@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang -cc1as -o %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: -triple x86_64-unknown-linux-gnu -filetype obj -target-cpu x86-64 \
+; RUN: %t/host-x86_64-unknown-linux-gnu.s
+
+; Check plugin, -passes, and no remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
+
+; Check plugin, -p, and remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-p="function(goodbye),module(inline)" \
+; RUN: --offload-opt=-pass-remarks=inline \
+; RUN: 

[clang] [LinkerWrapper] Extend with usual pass options (PR #96704)

2024-06-25 Thread Joel E. Denny via cfe-commits


@@ -0,0 +1,86 @@
+; Check various clang-linker-wrapper pass options after -offload-opt.
+
+; REQUIRES: llvm-plugins, llvm-examples
+; REQUIRES: x86-registered-target
+; REQUIRES: amdgpu-registered-target
+
+; Setup.
+; RUN: split-file %s %t
+; RUN: opt -o %t/host-x86_64-unknown-linux-gnu.bc \
+; RUN: %t/host-x86_64-unknown-linux-gnu.ll
+; RUN: opt -o %t/openmp-amdgcn-amd-amdhsa.bc \
+; RUN: %t/openmp-amdgcn-amd-amdhsa.ll
+; RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
+; RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
+; RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+; RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
+; RUN: %t/host-x86_64-unknown-linux-gnu.bc
+; RUN: %clang -cc1as -o %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: -triple x86_64-unknown-linux-gnu -filetype obj -target-cpu x86-64 \
+; RUN: %t/host-x86_64-unknown-linux-gnu.s
+
+; Check plugin, -passes, and no remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
+
+; Check plugin, -p, and remarks.
+; RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+; RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
+; RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
+; RUN: --offload-opt=-p="function(goodbye),module(inline)" \
+; RUN: --offload-opt=-pass-remarks=inline \
+; RUN: --offload-opt=-pass-remarks-output=%t/remarks.yml \
+; RUN: --offload-opt=-pass-remarks-filter=inline \
+; RUN: --offload-opt=-pass-remarks-format=yaml 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=OUT,REM %s
+; RUN: FileCheck -input-file=%t/remarks.yml -match-full-lines \
+; RUN: -check-prefixes=YML %s
+
+; Check handling of bad plugin.
+; RUN: not clang-linker-wrapper \
+; RUN: --offload-opt=-load-pass-plugin=%t/nonexistent.so 2>&1 | \
+; RUN:   FileCheck -match-full-lines -check-prefixes=BAD-PLUGIN %s
+
+;  OUT-NOT: {{.}}
+;  OUT: Bye: f
+; OUT-NEXT: Bye: test
+; REM-NEXT: remark: {{.*}} 'f' inlined into 'test' {{.*}}
+;  OUT-NOT: {{.}}
+
+;  YML-NOT: {{.}}
+;  YML: --- !Passed
+; YML-NEXT: Pass: inline
+; YML-NEXT: Name: Inlined
+; YML-NEXT: Function: test
+; YML-NEXT: Args:
+;  YML:  - Callee: f
+;  YML:  - Caller: test
+;  YML: ...
+;  YML-NOT: {{.}}
+
+; BAD-PLUGIN-NOT: {{.}}
+; BAD-PLUGIN: {{.*}}Could not load library {{.*}}nonexistent.so{{.*}}
+; BAD-PLUGIN-NOT: {{.}}
+
+;--- host-x86_64-unknown-linux-gnu.ll
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;--- openmp-amdgcn-amd-amdhsa.ll
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
+
+define void @f() {
+entry:
+  ret void
+}
+
+define amdgpu_kernel void @test() {

jdenny-ornl wrote:

I pushed another commit.  Let know if that's what you had in mind.

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


  1   2   >