[PATCH] D100501: [cland] Dont emit missing newline warnings when building preamble

2021-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 339901.
kadircet marked an inline comment as done.
kadircet added a comment.
Herald added a subscriber: cfe-commits.

- Handle cxx98 and extension versions of the warning too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100501

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1373,6 +1373,25 @@
   EXPECT_THAT(*AST.getDiagnostics(),
   testing::Contains(Diag(Code.range(), KDiagMsg.str(;
 }
+
+TEST(Preamble, EndsOnNonEmptyLine) {
+  TestTU TU;
+  TU.ExtraArgs = {"-Wnewline-eof"};
+
+  {
+TU.Code = "#define FOO\n  void bar();\n";
+auto AST = TU.build();
+EXPECT_THAT(*AST.getDiagnostics(), IsEmpty());
+  }
+  {
+Annotations Code("#define FOO[[]]");
+TU.Code = Code.code().str();
+auto AST = TU.build();
+EXPECT_THAT(
+*AST.getDiagnostics(),
+testing::Contains(Diag(Code.range(), "no newline at end of file")));
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -15,6 +15,7 @@
 #include "support/Trace.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -341,6 +342,20 @@
   llvm::IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(&CI.getDiagnosticOpts(),
   &PreambleDiagnostics, false);
+  PreambleDiagnostics.setLevelAdjuster(
+  [&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) {
+switch (Info.getID()) {
+case diag::warn_no_newline_eof:
+case diag::warn_cxx98_compat_no_newline_eof:
+case diag::ext_no_newline_eof:
+  // If the preamble doesn't span the whole file, drop the no newline 
at
+  // eof warnings.
+  return Bounds.Size != ContentsBuffer->getBufferSize()
+ ? DiagnosticsEngine::Level::Ignored
+ : DiagLevel;
+}
+return DiagLevel;
+  });
 
   // Skip function bodies when building the preamble to speed up building
   // the preamble and make it smaller.


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1373,6 +1373,25 @@
   EXPECT_THAT(*AST.getDiagnostics(),
   testing::Contains(Diag(Code.range(), KDiagMsg.str(;
 }
+
+TEST(Preamble, EndsOnNonEmptyLine) {
+  TestTU TU;
+  TU.ExtraArgs = {"-Wnewline-eof"};
+
+  {
+TU.Code = "#define FOO\n  void bar();\n";
+auto AST = TU.build();
+EXPECT_THAT(*AST.getDiagnostics(), IsEmpty());
+  }
+  {
+Annotations Code("#define FOO[[]]");
+TU.Code = Code.code().str();
+auto AST = TU.build();
+EXPECT_THAT(
+*AST.getDiagnostics(),
+testing::Contains(Diag(Code.range(), "no newline at end of file")));
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -15,6 +15,7 @@
 #include "support/Trace.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -341,6 +342,20 @@
   llvm::IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(&CI.getDiagnosticOpts(),
   &PreambleDiagnostics, false);
+  PreambleDiagnostics.setLevelAdjuster(
+  [&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) {
+switch (Info.getID()) {
+case diag::warn_no_newline_eof:
+case diag::warn_cxx98_compat_no_newline_eof:
+case diag::ext_no_newline_eof:
+  // If the preamble doesn't span the whole file, drop the no newline at
+  // eof warnings.
+  return Bounds.Size != ContentsBuffer->getBufferSize()
+ ? DiagnosticsEngine::Level::Ignored
+ : DiagLevel;
+}
+return DiagL

[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D100739#2711181 , @rjmccall wrote:

> What is the purpose of the builtin?  Where is it being used?  Typically you 
> *can't* change the signature of a builtin because the builtin is itself a 
> language feature that's documented to have a particular signature.  If you've 
> made a builtin purely for use in generated AST, that's pretty unfortunate, 
> and you should consider whether you actually have to do that instead of e.g. 
> synthesizing a call to an allocation function the same way that we do in 
> `new` expressions.

Well, the intention was not *only* use it in AST, it could be used by clients 
to ask LLVM to handle overaligned frame. I'm not sure how many use cases that 
could have, so in the updated patch, I've removed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

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


[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D100739#2706973 , @lxfind wrote:

> Thanks for working on this.
> I am still having a bit hard time understanding the solution.
> A few questions:
>
> 1. I assume this patch is to solve the problem where the promise object is 
> not aligned according to its alignof annotation, right? The title/wording is 
> a bit misleading. Usually "handling XXX" means XXX is a situation/problem 
> that wasn't handle properly before, and it's being handled here. I don't 
> really understand what "handle overaligned frame allocation" means. Isn't 
> frame allocation under-aligned being the problem?

Sorry for the confusion. I think either overaligned or under-aligned could be 
used here to describe the problem: either "Handle overaligned frame" or "Fix 
under-aligned frame". Since c++ spec defines the former but not the later 
(https://en.cppreference.com/w/cpp/language/object#Alignment), my first 
intuition was to use the term "overalign". Under-aligned is the undesired 
outcome that should be fixed (probably too late to handle I assume). Also the 
overaligned is a static property whereas 'under-aligned" is a runtime property. 
From the compiler's perspective, I think overaligned should be preferred. With 
that said, I don't feel strongly about this. I could switch to use 
"overaligned" if that feels more intuitive.

> 2. What is the purpose of coro.align intrinsic?

To communicate frame alignment to the frontend. It shouldn't be needed for this 
patch, so I've removed it.

> 3. Could you provide some examples of what the IR might look like after this 
> patch? Either that or a more detailed explanation of how this works in the 
> summary.

Yep, please see the updated description. And a new test is added.

> 4. Do you think it might be cleaner to introduce a new variant of coro.size 
> instead of adding arguments to it? For example, coro.size.aligned(). This 
> way, you can avoid changing any test file for non-switch-lowering test files, 
> but focus on all switch-lowering tests.

Agree, I've thought about variadic intrinsic and this new intrinsic, I think 
using new intrinsic is more flexible and avoids test fixup.

> 5. Typically, coro.free is used by a comparison with nullptr. This is to 
> enable CoroElide. See: 
> https://llvm.org/docs/Coroutines.html#llvm-coro-free-intrinsic. So I don't 
> think you can load from it directly.

Agree, I've changed to do it in `coro::replaceCoroFree`.

@ChuanqiXu @lxfind  Thanks a lot for the feedback. I've updated the description 
and addressed the existing comments. Please take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

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


[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 339900.
ychen edited the summary of this revision.
ychen added a comment.

- Address feebacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-builtins.c
  clang/test/CodeGenCoroutines/coro-gro.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Coroutines/CoroInstr.h
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/test/Transforms/Coroutines/coro-overalign.ll

Index: llvm/test/Transforms/Coroutines/coro-overalign.ll
===
--- /dev/null
+++ llvm/test/Transforms/Coroutines/coro-overalign.ll
@@ -0,0 +1,81 @@
+; Check that we will emit extra code to handle overaligned frame.
+; RUN: opt < %s -coro-split -S | FileCheck %s
+; RUN: opt < %s -passes=coro-split -S | FileCheck %s
+
+%PackedStruct = type <{ i64 }>
+
+declare void @consume(%PackedStruct*)
+
+define i8* @f() "coroutine.presplit"="1" {
+entry:
+  %data = alloca %PackedStruct, align 32
+  %id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* null)
+  %size = call i32 @llvm.coro.size.alloc.i32()
+  %alloc = call i8* @malloc(i32 %size)
+  %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
+  call void @consume(%PackedStruct* %data)
+  %0 = call i8 @llvm.coro.suspend(token none, i1 false)
+  switch i8 %0, label %suspend [i8 0, label %resume
+i8 1, label %cleanup]
+resume:
+  call void @consume(%PackedStruct* %data)
+  br label %cleanup
+
+cleanup:
+  %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
+  call void @free(i8* %mem)
+  br label %suspend
+suspend:
+  call i1 @llvm.coro.end(i8* %hdl, i1 0)
+  ret i8* %hdl
+}
+
+; See if the frame pointer was inserted.
+; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i8*, i1, [7 x i8], %PackedStruct }
+
+; See if we over-allocate, adjust frame ptr start address and use a alloca to
+; save the raw frame pointer.
+; CHECK-LABEL: @f(
+;CHECK:  %alloc.frame.ptr = alloca i8*, align 8
+;CHECK:  %id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* bitcast ([3 x void (%f.Frame*)*]* @f.resumers to i8*))
+;CHECK:  %alloc = call i8* @malloc(i32 56)
+;CHECK:  store i8* %alloc, i8** %alloc.frame.ptr, align 8
+;CHECK:  %intptr = ptrtoint i8* %alloc to i64
+;CHECK:  %over_boundary = add i64 %intptr, 31
+;CHECK:  %aligned_intptr = and i64 %over_boundary, -32
+;CHECK:  %diff = sub i64 %aligned_intptr, %intptr
+;CHECK:  %aligned_result = getelementptr i8, i8* %alloc, i64 %diff
+;CHECK:  call void @llvm.assume(i1 true) [ "align"(i8* %aligned_result, i64 32) ]
+;CHECK:  %hdl = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %aligned_result)
+
+; See if we emit correct deallocation code.
+
+; CHECK-LABEL: @f.resume(
+; CHECK:  %0 = getelementptr %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
+; CHECK-NEXT: %raw.frame.ptr = load i8*, i8** %0, align 8
+; CHECK-NEXT: call void @free(i8* %raw.frame.ptr)
+; CHECK-NEXT: ret void
+
+; CHECK-LABEL: @f.destroy(
+; CHECK:  %0 = getelementptr %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
+; CHECK-NEXT: %raw.frame.ptr = load i8*, i8** %0, align 8
+; CHECK-NEXT: call void @free(i8* %raw.frame.ptr)
+; CHECK-NEXT: ret void
+
+; CHECK-LABEL: @f.cleanup(
+; CHECK:  call void @free(i8* null)
+; CHECK-NEXT: ret void
+
+declare i8* @llvm.coro.free(token, i8*)
+declare i32 @llvm.coro.size.alloc.i32()
+declare i8  @llvm.coro.suspend(token, i1)
+declare void @llvm.coro.resume(i8*)
+declare void @llvm.coro.destroy(i8*)
+
+declare token @llvm.coro.id(i32, i8*, i8*, i8*)
+declare i1 @llvm.coro.alloc(token)
+declare i8* @llvm.coro.begin(token, i8*)
+declare i1 @llvm.coro.end(i8*, i1)
+
+declare noalias i8* @malloc(i32)
+declare void @free(i8*)
Index: llvm/lib/Transforms/Coroutines/Coroutines.cpp
===
--- llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -22,6 +22,7 @@
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InstIterator.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
@@ -171,7 +172,7 @@
 
 // Replace all coro.frees associated with the provided CoroId either with 'null'
 // if Elide is true and with its frame parameter otherwise.
-void coro::replaceCoroFree(CoroIdInst *CoroId, bool Elide) {
+void coro::replaceCoroFree(CoroIdInst *CoroId, bool Elide, Shape *Shape) {
   SmallVector CoroFrees;
   for (User *U : CoroId->users())
 if (auto CF = dyn_cast(U))
@@ -180,9 +181,25 @@
   if

[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

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

What is the purpose of the builtin?  Where is it being used?  Typically you 
*can't* change the signature of a builtin because the builtin is itself a 
language feature that's documented to have a particular signature.  If you've 
made a builtin purely for use in generated AST, that's pretty unfortunate, and 
you should consider whether you actually have to do that instead of e.g. 
synthesizing a call to an allocation function the same way that we do in `new` 
expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

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


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-04-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added subscribers: akyrtzi, benlangmuir.
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:131
+Float128,
+Ibm128
   };

This is necessary because it's possible to derive this type from a mode 
attribute?



Comment at: clang/include/clang/Basic/TargetInfo.h:680
+  /// Return the mangled code of __ibm128.
+  virtual const char *getIbm128Mangling() const { return "g"; }
+

nemanjai wrote:
> The same mangling for both of these types seems incorrect as Steven pointed 
> out. Why not do something similar to what was done for `bfloat16` (i.e. an 
> `llvm_unreachable`) and override it for PowerPC?
Why are these manglings abstracted into TargetInfo in the first place?  Are 
there targets that are going to use a different mangling for `__ibm128`?



Comment at: clang/lib/AST/ASTContext.cpp:6274
+/// __float128 and __ibm128)
+bool ASTContext::areUnorderedFloatingTypes(QualType LHS, QualType RHS) const {
+  auto *LHSComplex = LHS->getAs();

Is it language semantics that these are unordered or just an implementation 
limitation?  I know WG14 is working on a draft for extended types that allows 
pairs to not be ordered, but IIRC that's supposed to be based on whether types 
have a subset relationship.  I believe the only FP formats that pairwise don't 
have subset relationships are `bfloat`/`half` and `ibm128`/`fp80`, and we don't 
support `ibm128` on any x86 targets so the latter is impossible in practice.  
The reason we have this restriction on converting between `ibm128` and 
`float128` is just that we haven't implemented the conversion in the backend / 
compiler-rt.  I don't think we should lock that limitation in as an actual 
unordered-type relationship.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:5159
 BT->getKind() == BuiltinType::LongDouble ||
+BT->getKind() == BuiltinType::Ibm128 ||
 (getContext().getTargetInfo().hasFloat128Type() &&

I hesitate to ask this, but does `__ibm128` form homogeneous aggregates with 
`double`s?



Comment at: clang/lib/Index/USRGeneration.cpp:708
   c = 'd'; break;
+case BuiltinType::Ibm128: // FIXME: Need separate tag
 case BuiltinType::LongDouble:

@akyrtzi @benlangmuir We can just add new USR codes for new types, right?



Comment at: clang/lib/Sema/Sema.cpp:1842
+LongDoubleMismatched = true;
+}
+

I think this needs a comment explaining what you're checking for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-22 Thread Kevin Athey via Phabricator via cfe-commits
kda added a comment.

I'm new here.
I was told to take small steps.
This will eventually effect compiler-rt and llvm.
I took the smallest possible step.

What I had previously: https://reviews.llvm.org/D99630
And was told it was too large.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D101017: [NewPM] Make GlobalsAA available earlier in the pipeline

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

Actually, the InstCombine transform allows LoopFullUnrollPass to unroll the 
copy loop which results in a bunch of stores. Previously during 
LoopFullUnrollPass we wouldn't see the global within the loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101017

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


[PATCH] D100823: [RISCV] Implement the pseudo compare builtin.

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

Update test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100823

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsgt.c

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


[PATCH] D100823: [RISCV] Implement the pseudo compare builtin.

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

Use new defined intrinsics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100823

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsgt.c

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


[PATCH] D100821: [RISCV] Implement the vmmv.m/vmnot.m builtin.

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

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100821

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmnot.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
@@ -0,0 +1,107 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -target-feature +m -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+
+// ASM-NOT: warning
+#include 
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv64i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv64i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool1_t test_vmnot_m_b1 (vbool1_t op1, size_t vl) {
+  return vmnot_m_b1(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv32i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv32i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool2_t test_vmnot_m_b2 (vbool2_t op1, size_t vl) {
+  return vmnot_m_b2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv16i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv16i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmnot_m_b4 (vbool4_t op1, size_t vl) {
+  return vmnot_m_b4(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv8i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv8i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool8_t test_vmnot_m_b8 (vbool8_t op1, size_t vl) {
+  return vmnot_m_b8(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b16(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv4i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b16(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv4i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool16_t test_vmnot_m_b16 (vbool16_t op1, size_t vl) {
+  return vmnot_m_b16(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b32(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv2i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b32(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv2i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool32_t test_vmnot_m_b32 (vbool32_t op1, size_t vl) {
+  return vmnot_m_b32(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b64(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv1i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b64(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv1i1.i64( [[OP1:%.*]],  [[O

[PATCH] D101097: [Sema] Don't set BlockDecl's DoesNotEscape bit If the block is being passed to a function taking a reference parameter

2021-04-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:5917
 if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
   BE->getBlockDecl()->setDoesNotEscape();
 

We need to be checking that the parameter type is a block pointer type.  A 
parameter of a type like `id` or `void*` does not have the enhanced semantics 
of `noescape` for blocks.

The inevitable weird C++ test case is:

```
struct NoescapeCtor {
  NoescapeCtor(__attribute__((noescape)) void (^)());
};
struct EscapeCtor {
  EscapeCtor(void (^)());
};

void helper1(NoescapeCtor a);
void test1() { helper1(^{}); } // <- should be noescape

void helper2(NoescapeCtor &&a);
void test2() { helper2(^{}); } // <- should be noescape

void helper3(__attribute__((noescape)) EscapeCtor &&a);
void test3() { helper3(^{}); } // <- should not be noescape
```

You should probably also test that calls to function templates behave according 
to the instantiated type of the parameter.  I expect that that should just fall 
out from this implementation, which I think only triggers on non-dependent 
calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101097

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


[PATCH] D101017: [NewPM] Make GlobalsAA available earlier in the pipeline

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

Looking at one of the examples in llvm-test-suite that regressed, this seems to 
be regressing some very simple code:

  void f(double *a) {
double c[20] = {
0.1051, 0.0157, 0.0185, 0.0089, 0.0219, 0.0141, 0.0097,
0.0758, 0.0168, 0.1188, 0.1635, 0.0112, 0.0333, 0.0777,
0.0260, 0.0568, 0.0523, 0.0223, 0.0324, 0.1195,
};
  
for (int i = 0; i < 20; i++)
  a[i] = c[i];
  }

Before, it would just turn it into a memcpy.
With this change, it becomes a bunch of individual stores.

Looks like [1] is to blame. The extra AA causes it to fire and introduce the 
individual stores.

[1]: 
https://github.com/llvm/llvm-project/blob/53673fd1bf6f2dd94d8bb6ced49cc54ec5fc866b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp#L422


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101017

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


[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

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

Test looks good, thanks.




Comment at: clang/lib/CodeGen/CGCall.cpp:2060
+case Builtin::BIstrndup:
+  RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
+Context.getTargetInfo().getCharWidth());

xbolva00 wrote:
> lebedev.ri wrote:
> > malloc != new
> But the comment for the implementation of this value points on eg. gcc's docs:
> 
> https://clang.llvm.org/doxygen/Basic_2TargetInfo_8cpp_source.html line 67
> 
>// From the glibc documentation, on GNU systems, malloc guarantees 16-byte
>// alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
>// https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
>// This alignment guarantee also applies to Windows and Android. On Darwin,
>// the alignment is 16 bytes on both 64-bit and 32-bit systems.
> 
> So this value is correct to be used for malloc and friends IMHO.
There's no immediate reason to have two different methods, but we should at 
least update the comment on `getNewAlign` to document that we're assuming it 
describes both `operator new` and `malloc`.


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

https://reviews.llvm.org/D100879

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


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-22 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8bce8399631: [X86] Enable compilation of user interrupt 
handlers. (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99708

Files:
  clang/lib/Headers/uintrintrin.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll

Index: llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
@@ -0,0 +1,171 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no_x86_scrub_sp --no_x86_scrub_rip
+; RUN: llc < %s | FileCheck %s -check-prefixes=CHECK-USER
+; RUN: llc -O0 < %s | FileCheck %s -check-prefixes=CHECK0-USER
+; RUN: llc -code-model=kernel < %s | FileCheck %s -check-prefixes=CHECK-KERNEL
+; RUN: llc -O0 -code-model=kernel < %s | FileCheck %s -check-prefixes=CHECK0-KERNEL
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.__uintr_frame = type { i64, i64, i64 }
+
+; #include 
+;
+; void
+; __attribute__ ((interrupt))
+; test_uintr_isr_cc_empty(struct __uintr_frame *frame, unsigned long long uirrv)
+; {
+; }
+
+define dso_local x86_intrcc void @test_uintr_isr_cc_empty(%struct.__uintr_frame* nocapture byval(%struct.__uintr_frame) %frame, i64 %uirrv) #0 {
+; CHECK-USER-LABEL: test_uintr_isr_cc_empty:
+; CHECK-USER:   # %bb.0: # %entry
+; CHECK-USER-NEXT:pushq %rax
+; CHECK-USER-NEXT:cld
+; CHECK-USER-NEXT:addq $16, %rsp
+; CHECK-USER-NEXT:uiret
+;
+; CHECK0-USER-LABEL: test_uintr_isr_cc_empty:
+; CHECK0-USER:   # %bb.0: # %entry
+; CHECK0-USER-NEXT:pushq %rax
+; CHECK0-USER-NEXT:cld
+; CHECK0-USER-NEXT:addq $16, %rsp
+; CHECK0-USER-NEXT:uiret
+;
+; CHECK-KERNEL-LABEL: test_uintr_isr_cc_empty:
+; CHECK-KERNEL:   # %bb.0: # %entry
+; CHECK-KERNEL-NEXT:pushq %rax
+; CHECK-KERNEL-NEXT:cld
+; CHECK-KERNEL-NEXT:addq $16, %rsp
+; CHECK-KERNEL-NEXT:iretq
+;
+; CHECK0-KERNEL-LABEL: test_uintr_isr_cc_empty:
+; CHECK0-KERNEL:   # %bb.0: # %entry
+; CHECK0-KERNEL-NEXT:pushq %rax
+; CHECK0-KERNEL-NEXT:cld
+; CHECK0-KERNEL-NEXT:addq $16, %rsp
+; CHECK0-KERNEL-NEXT:iretq
+entry:
+  ret void
+}
+
+; unsigned long long g_rip;
+; unsigned long long g_rflags;
+; unsigned long long g_rsp;
+; unsigned long long g_uirrv;
+;
+; void
+; __attribute__((interrupt))
+; test_uintr_isr_cc_args(struct __uintr_frame *frame, unsigned long long uirrv)
+; {
+;   g_rip = frame->rip;
+;   g_rflags = frame->rflags;
+;   g_rsp = frame->rsp;
+;   g_uirrv = uirrv;
+; }
+@g_rip = dso_local local_unnamed_addr global i64 0, align 8
+@g_rflags = dso_local local_unnamed_addr global i64 0, align 8
+@g_rsp = dso_local local_unnamed_addr global i64 0, align 8
+@g_uirrv = dso_local local_unnamed_addr global i64 0, align 8
+
+define dso_local x86_intrcc void @test_uintr_isr_cc_args(%struct.__uintr_frame* nocapture readonly byval(%struct.__uintr_frame) %frame, i64 %uirrv) #0 {
+; CHECK-USER-LABEL: test_uintr_isr_cc_args:
+; CHECK-USER:   # %bb.0: # %entry
+; CHECK-USER-NEXT:pushq %rax
+; CHECK-USER-NEXT:pushq %rax
+; CHECK-USER-NEXT:pushq %rdx
+; CHECK-USER-NEXT:pushq %rcx
+; CHECK-USER-NEXT:cld
+; CHECK-USER-NEXT:movq 32(%rsp), %rax
+; CHECK-USER-NEXT:movq 40(%rsp), %rcx
+; CHECK-USER-NEXT:movq 48(%rsp), %rdx
+; CHECK-USER-NEXT:movq %rcx, g_rip(%rip)
+; CHECK-USER-NEXT:movq %rdx, g_rflags(%rip)
+; CHECK-USER-NEXT:movq 56(%rsp), %rcx
+; CHECK-USER-NEXT:movq %rcx, g_rsp(%rip)
+; CHECK-USER-NEXT:movq %rax, g_uirrv(%rip)
+; CHECK-USER-NEXT:popq %rcx
+; CHECK-USER-NEXT:popq %rdx
+; CHECK-USER-NEXT:popq %rax
+; CHECK-USER-NEXT:addq $16, %rsp
+; CHECK-USER-NEXT:uiret
+;
+; CHECK0-USER-LABEL: test_uintr_isr_cc_args:
+; CHECK0-USER:   # %bb.0: # %entry
+; CHECK0-USER-NEXT:pushq %rax
+; CHECK0-USER-NEXT:pushq %rax
+; CHECK0-USER-NEXT:pushq %rdx
+; CHECK0-USER-NEXT:pushq %rcx
+; CHECK0-USER-NEXT:cld
+; CHECK0-USER-NEXT:movq 32(%rsp), %rax
+; CHECK0-USER-NEXT:leaq 40(%rsp), %rcx
+; CHECK0-USER-NEXT:movq (%rcx), %rdx
+; CHECK0-USER-NEXT:movq %rdx, g_rip(%rip)
+; CHECK0-USER-NEXT:movq 8(%rcx), %rdx
+; CHECK0-USER-NEXT:movq %rdx, g_rflags(%rip)
+; CHECK0-USER-NEXT:movq 16(%rcx), %rcx
+; CHECK0-USER-NEXT:movq %rcx, g_rsp(%rip)
+; CHECK0-USER-NEXT:movq %rax, g_uirrv(%rip)
+; CHECK0-USER-NEXT:popq %rcx
+; CHECK0-USER-NEXT:popq %rdx
+; CHECK0-USER-NEXT:popq %rax
+; CHECK0-USER-NEXT:addq $16, %rsp
+; CHECK0-USER-NEXT:uiret
+;
+; CHECK-KERNEL-LABEL: test_uintr_isr_cc_args:
+; CHECK-KERNEL:   # %bb.0: # %entry
+

[clang] e8bce83 - [X86] Enable compilation of user interrupt handlers.

2021-04-22 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2021-04-23T11:43:57+08:00
New Revision: e8bce83996313ed3f4f5fce43107530d49fc3b64

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

LOG: [X86] Enable compilation of user interrupt handlers.

Add __uintr_frame structure and use UIRET instruction for functions with
x86 interrupt calling convention when UINTR is present.

Reviewed By: LuoYuanke

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

Added: 
llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll

Modified: 
clang/lib/Headers/uintrintrin.h
llvm/lib/Target/X86/X86ExpandPseudo.cpp

Removed: 




diff  --git a/clang/lib/Headers/uintrintrin.h b/clang/lib/Headers/uintrintrin.h
index 78aa8779c325..e3839dcebe1e 100644
--- a/clang/lib/Headers/uintrintrin.h
+++ b/clang/lib/Headers/uintrintrin.h
@@ -20,6 +20,13 @@
 
 #ifdef __x86_64__
 
+struct __uintr_frame
+{
+  unsigned long long rip;
+  unsigned long long rflags;
+  unsigned long long rsp;
+};
+
 /// Clears the user interrupt flag (UIF). Its effect takes place immediately: a
 ///user interrupt cannot be delivered on the instruction boundary following
 ///CLUI. Can be executed only if CR4.UINT = 1, the logical processor is in

diff  --git a/llvm/lib/Target/X86/X86ExpandPseudo.cpp 
b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
index e0875fb6432d..29a7b9840f44 100644
--- a/llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -23,6 +23,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/Passes.h" // For IDs of passes that are preserved.
 #include "llvm/IR/GlobalValue.h"
+#include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
 #define DEBUG_TYPE "x86-pseudo"
@@ -315,8 +316,12 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
 int64_t StackAdj = MBBI->getOperand(0).getImm();
 X86FL->emitSPUpdate(MBB, MBBI, DL, StackAdj, true);
 // Replace pseudo with machine iret
-BuildMI(MBB, MBBI, DL,
-TII->get(STI->is64Bit() ? X86::IRET64 : X86::IRET32));
+unsigned RetOp = STI->is64Bit() ? X86::IRET64 : X86::IRET32;
+// Use UIRET if UINTR is present (except for building kernel)
+if (STI->is64Bit() && STI->hasUINTR() &&
+MBB.getParent()->getTarget().getCodeModel() != CodeModel::Kernel)
+  RetOp = X86::UIRET;
+BuildMI(MBB, MBBI, DL, TII->get(RetOp));
 MBB.erase(MBBI);
 return true;
   }

diff  --git a/llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll 
b/llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
new file mode 100644
index ..837b0782004c
--- /dev/null
+++ b/llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
@@ -0,0 +1,171 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --no_x86_scrub_sp --no_x86_scrub_rip
+; RUN: llc < %s | FileCheck %s -check-prefixes=CHECK-USER
+; RUN: llc -O0 < %s | FileCheck %s -check-prefixes=CHECK0-USER
+; RUN: llc -code-model=kernel < %s | FileCheck %s -check-prefixes=CHECK-KERNEL
+; RUN: llc -O0 -code-model=kernel < %s | FileCheck %s 
-check-prefixes=CHECK0-KERNEL
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.__uintr_frame = type { i64, i64, i64 }
+
+; #include 
+;
+; void
+; __attribute__ ((interrupt))
+; test_uintr_isr_cc_empty(struct __uintr_frame *frame, unsigned long long 
uirrv)
+; {
+; }
+
+define dso_local x86_intrcc void 
@test_uintr_isr_cc_empty(%struct.__uintr_frame* nocapture 
byval(%struct.__uintr_frame) %frame, i64 %uirrv) #0 {
+; CHECK-USER-LABEL: test_uintr_isr_cc_empty:
+; CHECK-USER:   # %bb.0: # %entry
+; CHECK-USER-NEXT:pushq %rax
+; CHECK-USER-NEXT:cld
+; CHECK-USER-NEXT:addq $16, %rsp
+; CHECK-USER-NEXT:uiret
+;
+; CHECK0-USER-LABEL: test_uintr_isr_cc_empty:
+; CHECK0-USER:   # %bb.0: # %entry
+; CHECK0-USER-NEXT:pushq %rax
+; CHECK0-USER-NEXT:cld
+; CHECK0-USER-NEXT:addq $16, %rsp
+; CHECK0-USER-NEXT:uiret
+;
+; CHECK-KERNEL-LABEL: test_uintr_isr_cc_empty:
+; CHECK-KERNEL:   # %bb.0: # %entry
+; CHECK-KERNEL-NEXT:pushq %rax
+; CHECK-KERNEL-NEXT:cld
+; CHECK-KERNEL-NEXT:addq $16, %rsp
+; CHECK-KERNEL-NEXT:iretq
+;
+; CHECK0-KERNEL-LABEL: test_uintr_isr_cc_empty:
+; CHECK0-KERNEL:   # %bb.0: # %entry
+; CHECK0-KERNEL-NEXT:pushq %rax
+; CHECK0-KERNEL-NEXT:cld
+; CHECK0-KERNEL-NEXT:addq $16, %rsp
+; CHECK0-KERNEL-NEXT:iretq
+entry:
+  ret void
+}
+
+; unsigned long long g_rip;
+; unsigned long long g_rflags;
+; unsigned long long g_rsp;
+; unsigned long long g_uirrv;
+;
+; void
+; __attribute__((interrupt))
+; test_uintr_isr_cc_args(struct __uintr_frame *frame, unsigned long long uirrv)
+; {
+;   g_rip = frame->rip;
+;   g_rflags = frame->rflags;
+;   g_rsp 

[PATCH] D101130: [PowerPC] Provide XL-compatible builtins in altivec.h

2021-04-22 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: cebowleratibm, hubert.reinterpretcast, bmahjour, 
PowerPC.
Herald added subscribers: shchenz, kbarton.
nemanjai requested review of this revision.
Herald added a project: clang.

There are some interfaces in altivec.h that are not compatible between Clang 
and XL (although Clang is compatible with GCC). Currently, we have found 3 but 
there may be others.

Clang/GCC signatures:

  vector double vec_ctf(vector signed long long)
  vector double vec_ctf(vector unsigned long long)
  vector signed long long vec_cts(vector double)
  vector unsigned long long vec_ctu(vector double)

XL signatures:

  vector float vec_ctf(vector signed long long)
  vector float vec_ctf(vector unsigned long long)
  vector signed int vec_cts(vector double)
  vector unsigned int vec_ctu(vector double)

This patch provides the XL behaviour under the `__XL_COMPAT_ALTIVEC__` macro 
for users that rely on XL behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101130

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-xlcompat.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat.c
@@ -0,0 +1,41 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+  // RUN:   -triple powerpc64-unknown-unknown -emit-llvm %s -o - \
+// RUN:   -D__XL_COMPAT_ALTIVEC__ | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+  // RUN:   -triple powerpc64le-unknown-unknown -emit-llvm %s -o - \
+// RUN:   -D__XL_COMPAT_ALTIVEC__ | FileCheck %s
+#include 
+vector double vd = { 3.4e22, 1.8e-3 };
+vector signed long long vsll = { -12345678999ll, 12345678999 };
+vector unsigned long long vull = { 11547229456923630743llu, 18014402265226391llu };
+vector float res_vf;
+vector signed int res_vsi;
+vector unsigned int res_vui;
+
+void test() {
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-LE-LABEL: @test(
+// CHECK-LE-NEXT:  entry:
+
+  res_vf = vec_ctf(vsll, 4);
+// CHECK: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* @vsll, align 16
+// CHECK-NEXT:[[TMP1:%.*]] = call <4 x float> @llvm.ppc.vsx.xvcvsxdsp(<2 x i64> [[TMP0]])
+// CHECK-NEXT:fmul <4 x float> [[TMP1]], 
+
+  res_vf = vec_ctf(vull, 4);
+// CHECK: [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* @vull, align 16
+// CHECK-NEXT:[[TMP3:%.*]] = call <4 x float> @llvm.ppc.vsx.xvcvuxdsp(<2 x i64> [[TMP2]])
+// CHECK-NEXT:fmul <4 x float> [[TMP3]], 
+
+  res_vsi = vec_cts(vd, 4);
+// CHECK: [[TMP4:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
+// CHECK-NEXT:fmul <2 x double> [[TMP4]], 
+// CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpsxws(<2 x double>
+
+  res_vui = vec_ctu(vd, 4);
+// CHECK: [[TMP8:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
+// CHECK-NEXT:fmul <2 x double> [[TMP8]], 
+// CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpuxws(<2 x double>
+}
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -3052,6 +3052,31 @@
 }
 #endif
 
+#ifdef __XL_COMPAT_ALTIVEC__
+/* vec_ctf */
+
+#ifdef __VSX__
+#define vec_ctf(__a, __b)  \
+  _Generic((__a), vector int   \
+   : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)),  \
+ vector unsigned int   \
+   : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
+   (__b)), \
+ vector unsigned long long \
+   : (__builtin_vsx_xvcvuxdsp((vector unsigned long long)(__a)) *  \
+  (vector float)(vector unsigned)((0x7f - (__b)) << 23)),  \
+ vector signed long long   \
+   : (__builtin_vsx_xvcvsxdsp((vector signed long long)(__a)) *\
+  (vector float)(vector unsigned)((0x7f - (__b)) << 23)))
+#else
+#define vec_ctf(__a, __b)  \
+  _Generic((__a), vector int   \
+   : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)),  \
+ vector unsigned int   \
+   : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
+   (__b)))
+#endif
+#else // __XL_COMPAT_ALTIVEC__
 /* vec_ctf */
 
 #ifdef __VSX__
@@ -3079,6 +3104,7 @@
: (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
  

[PATCH] D100819: [RISCV] Implement the vneg.v builtin.

2021-04-22 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
HsiangKai marked an inline comment as done.
Closed by commit rG14cc1cb22230: [RISCV] Implement the vneg.v builtin. 
(authored by HsiangKai).

Changed prior to commit:
  https://reviews.llvm.org/D100819?vs=339452&id=339860#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100819

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vneg.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -1055,8 +1055,7 @@
   for (auto &Def : Defs) {
 StringRef CurIRName = Def->getIRName();
 if (CurIRName != PrevDef->getIRName() ||
-(CurIRName.empty() &&
- Def->getManualCodegen() != PrevDef->getManualCodegen())) {
+(Def->getManualCodegen() != PrevDef->getManualCodegen())) {
   PrevDef->emitCodeGenSwitchBody(OS);
 }
 PrevDef = Def.get();
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vneg.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vneg.c
@@ -0,0 +1,625 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv1i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv1i8.i8.i64( [[OP1:%.*]], i8 0, i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf8_t test_vneg_v_i8mf8 (vint8mf8_t op1, size_t vl) {
+  return vneg_v_i8mf8(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv2i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv2i8.i8.i64( [[OP1:%.*]], i8 0, i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf4_t test_vneg_v_i8mf4 (vint8mf4_t op1, size_t vl) {
+  return vneg_v_i8mf4(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv4i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv4i8.i8.i64( [[OP1:%.*]], i8 0, i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf2_t test_vneg_v_i8mf2 (vint8mf2_t op1, size_t vl) {
+  return vneg_v_i8mf2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8m1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv8i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv8i8.i8.i64( [[OP1:%.*]], i8 0, i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m1_t test_vneg_v_i8m1 (vint8m1_t op1, size_t vl) {
+  return vneg_v_i8m1(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8m2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv16i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8m2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv16i8.i8.i64( [[OP1:%.*]], i8 0, i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m2_t test_vneg_v_i8m2 (vint8m2_t op1, size_t vl) {
+  return vneg_v_i8m2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8m4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vrsub.nxv32i8.i8.i32( [[OP1:%.*]], i8 0, i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8m4(
+// CHECK-RV

[clang] 14cc1cb - [RISCV] Implement the vneg.v builtin.

2021-04-22 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-04-23T11:40:18+08:00
New Revision: 14cc1cb22230de433bb9eb35624355a6d0bef2d2

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

LOG: [RISCV] Implement the vneg.v builtin.

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vneg.c

Modified: 
clang/include/clang/Basic/riscv_vector.td
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 6132dc956d7bb..d68855318da18 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -785,6 +785,34 @@ multiclass RVVAMOBuiltinSet {
+  let Name = NAME,
+  IRName = IR,
+  IRNameMask = IR # "_mask",
+  ManualCodegen = [{
+  {
+// op1, vl
+IntrinsicTypes = {ResultType,
+  cast(ResultType)->getElementType(),
+  Ops[1]->getType()};
+Ops.insert(Ops.begin() + 1, 
llvm::Constant::getNullValue(IntrinsicTypes[1]));
+break;
+  }
+  }],
+  ManualCodegenMask = [{
+  {
+// maskedoff, op1, mask, vl
+IntrinsicTypes = {ResultType,
+  cast(ResultType)->getElementType(),
+  Ops[3]->getType()};
+Ops.insert(Ops.begin() + 2, 
llvm::Constant::getNullValue(IntrinsicTypes[1]));
+break;
+  }
+  }] in {
+def : RVVBuiltin<"v", "vv", type_range>;
+  }
+}
+
 // 6. Configuration-Setting Instructions
 // 6.1. vsetvli/vsetvl instructions
 let HasVL = false,
@@ -915,6 +943,7 @@ defm vsub : RVVIntBinBuiltinSet;
 defm vrsub : RVVOutOp1BuiltinSet<"vrsub", "csil",
  [["vx", "v", "vve"],
   ["vx", "Uv", "UvUvUe"]]>;
+defm vneg_v : RVVPseudoUnaryBuiltin<"vrsub", "csil">;
 
 // 12.2. Vector Widening Integer Add/Subtract
 // Widening unsigned integer add/subtract, 2*SEW = SEW +/- SEW

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c
new file mode 100644
index 0..6b7955deb377e
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vneg.c
@@ -0,0 +1,625 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv1i8.i8.i32( [[OP1:%.*]], i8 0, i32 
[[VL:%.*]]) #[[ATTR8:[0-9]+]]
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv1i8.i8.i64( [[OP1:%.*]], i8 0, i64 
[[VL:%.*]]) #[[ATTR8:[0-9]+]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf8_t test_vneg_v_i8mf8 (vint8mf8_t op1, size_t vl) {
+  return vneg(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv2i8.i8.i32( [[OP1:%.*]], i8 0, i32 
[[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv2i8.i8.i64( [[OP1:%.*]], i8 0, i64 
[[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf4_t test_vneg_v_i8mf4 (vint8mf4_t op1, size_t vl) {
+  return vneg(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8mf2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv4i8.i8.i32( [[OP1:%.*]], i8 0, i32 
[[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vneg_v_i8mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv4i8.i8.i64( [[OP1:%.*]], i8 0, i64 
[[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf2_t test_vneg_v_i8mf2 (vint8mf2_t op1, size_t vl) {
+  return vneg(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vneg_v_i8m1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vrsub.nxv8i8.i8.i32( [[OP1:%.*]], i8 0, i32 
[[VL:%.*]]) #[[

[PATCH] D100776: [clang/Basic] Make TargetInfo.h not use DataLayout again

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

ping?


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

https://reviews.llvm.org/D100776

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


[PATCH] D100821: [RISCV] Implement the vmmv.m/vmnot.m builtin.

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

In D100821#2707667 , @rogfer01 wrote:

> I can reproduce the crash above in my computer, so something is definitely 
> off.
>
> Looks like we emit this
>
>   case RISCV::BI__builtin_rvv_vmmv_m_b8:
>   case RISCV::BI__builtin_rvv_vmmv_m_b4:
>   case RISCV::BI__builtin_rvv_vmmv_m_b2:
>   case RISCV::BI__builtin_rvv_vmmv_m_b1:
>   case RISCV::BI__builtin_rvv_vmmv_m_b16:   
>   case RISCV::BI__builtin_rvv_vmmv_m_b32:   
>   case RISCV::BI__builtin_rvv_vmmv_m_b64:   
>   case RISCV::BI__builtin_rvv_vmand_mm_b8:  
>   case RISCV::BI__builtin_rvv_vmand_mm_b4:  
>   case RISCV::BI__builtin_rvv_vmand_mm_b2:  
>   case RISCV::BI__builtin_rvv_vmand_mm_b1:  
>   case RISCV::BI__builtin_rvv_vmand_mm_b16: 
>   case RISCV::BI__builtin_rvv_vmand_mm_b32: 
>   case RISCV::BI__builtin_rvv_vmand_mm_b64: 
> ID = Intrinsic::riscv_vmand;
> IntrinsicTypes = {ResultType, Ops[2]->getType()};   
> break;  
>
> But `Ops` has size 2 so this is accessing past the end. I observed the crash 
> with `clang::RISCV::BI__builtin_rvv_vmmv_m_b1` but I assume it happens with 
> the other ones as well.
>
> I think the description of the builtin should be `def : RVVBuiltin<"m", "m", 
> type_range>;` as these are like unary operations, aren't they?

The fix is put in https://reviews.llvm.org/D100819#inline-952584. I will land 
D100819  today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100821

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


[PATCH] D100611: [Clang] Add clang attribute `clang_builtin_alias`.

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

@aaron.ballman, could you help me to review it again? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

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


[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2786e673c7d6: [IR][sanitizer] Add module flag 
"frame-pointer" and set it for cc1 -mframe… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/asan-frame-pointer.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
  llvm/test/Instrumentation/AddressSanitizer/uwtable.ll

Index: llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
+++ llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
@@ -10,12 +10,15 @@
   ret i32 %tmp
 }
 
-!llvm.module.flags = !{!0}
+!llvm.module.flags = !{!0, !1}
 
 ;; Due to -fasynchronous-unwind-tables.
 !0 = !{i32 7, !"uwtable", i32 1}
 
+;; Due to -fno-omit-frame-pointer.
+!1 = !{i32 7, !"frame-pointer", i32 2}
+
 ;; Set the uwtable attribute on ctor/dtor.
 ; CHECK: define internal void @asan.module_ctor() #[[#ATTR:]]
 ; CHECK: define internal void @asan.module_dtor() #[[#ATTR]]
-; CHECK: attributes #[[#ATTR]] = { nounwind uwtable }
+; CHECK: attributes #[[#ATTR]] = { nounwind uwtable "frame-pointer"="all" }
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -676,6 +676,16 @@
 
 void Module::setUwtable() { addModuleFlag(ModFlagBehavior::Max, "uwtable", 1); }
 
+FramePointerKind Module::getFramePointer() const {
+  auto *Val = cast_or_null(getModuleFlag("frame-pointer"));
+  return static_cast(
+  Val ? cast(Val->getValue())->getZExtValue() : 0);
+}
+
+void Module::setFramePointer(FramePointerKind Kind) {
+  addModuleFlag(ModFlagBehavior::Max, "frame-pointer", static_cast(Kind));
+}
+
 void Module::setSDKVersion(const VersionTuple &V) {
   SmallVector Entries;
   Entries.push_back(V.getMajor());
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -335,8 +335,21 @@
   unsigned AddrSpace, const Twine &N,
   Module *M) {
   auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
+  AttrBuilder B;
   if (M->getUwtable())
-F->addAttribute(AttributeList::FunctionIndex, Attribute::UWTable);
+B.addAttribute(Attribute::UWTable);
+  switch (M->getFramePointer()) {
+  case FramePointerKind::None:
+// 0 ("none") is the default.
+break;
+  case FramePointerKind::NonLeaf:
+B.addAttribute("frame-pointer", "non-leaf");
+break;
+  case FramePointerKind::All:
+B.addAttribute("frame-pointer", "all");
+break;
+  }
+  F->addAttributes(AttributeList::FunctionIndex, B);
   return F;
 }
 
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -53,7 +53,7 @@
 CGOPT_EXP(CodeModel::Model, CodeModel)
 CGOPT(ExceptionHandling, ExceptionModel)
 CGOPT_EXP(CodeGenFileType, FileType)
-CGOPT(FramePointer::FP, FramePointerUsage)
+CGOPT(FramePointerKind, FramePointerUsage)
 CGOPT(bool, EnableUnsafeFPMath)
 CGOPT(bool, EnableNoInfsFPMath)
 CGOPT(bool, EnableNoNaNsFPMath)
@@ -183,16 +183,16 @@
  "Emit nothing, for performance testing")));
   CGBINDOPT(FileType);
 
-  static cl::opt FramePointerUsage(
+  static cl::opt FramePointerUsage(
   "frame-pointer",
   cl::desc("Specify frame pointer elimination optimization"),
-  cl::init(FramePointer::None),
+  cl::init(FramePointerKind::None),
   cl::values(
-  clEnumValN(FramePointer::All, "all",
+  clEnumValN(FramePointerKind::All, "all",
  "Disable frame pointer elimination"),
-  clEnumValN(FramePointer::NonLeaf, "non-leaf",
+  clEnumValN(FramePointerKind::NonLeaf, "non-leaf",
  "Disable frame pointer elimination for non-leaf frame"),
-  clEnumValN(FramePointer::None, "none",
+  clEnumValN(FramePointerKind::None, "none",
  "Enable frame pointer elimination")));
   CGBINDOPT(FramePointerUsage);
 
@@ -662,11 +662,11 @@
   }
   if (FramePointerUsageView->getNumOccurrences() > 0 &&
   !F.hasFnAttribute("frame-pointer")) {
-if (getFramePointerUsage() == FramePointer::All)
+if (getFramePointerUsage() == FramePointerKind::All)
   NewAttrs.addAttribute("frame-pointer", "all")

[clang] 2786e67 - [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-04-22T18:07:30-07:00
New Revision: 2786e673c7d67ffca531ef38d679620ee3048a1e

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

LOG: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 
-mframe-pointer={non-leaf,all}

The Linux kernel objtool diagnostic `call without frame pointer save/setup`
arise in multiple instrumentation passes (asan/tsan/gcov). With the mechanism
introduced in D100251, it's trivial to respect the command line
-m[no-]omit-leaf-frame-pointer/-f[no-]omit-frame-pointer, so let's do it.

Fix: https://github.com/ClangBuiltLinux/linux/issues/1236 (tsan)
Fix: https://github.com/ClangBuiltLinux/linux/issues/1238 (asan)

Also document the function attribute "frame-pointer" which is long overdue.

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

Added: 
clang/test/CodeGen/asan-frame-pointer.cpp
llvm/test/Instrumentation/AddressSanitizer/module-flags.ll

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
llvm/docs/LangRef.rst
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/Support/CodeGen.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Module.cpp

Removed: 
llvm/test/Instrumentation/AddressSanitizer/uwtable.ll



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6b966e7ca1338..fd5975b4f545a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -744,6 +744,18 @@ void CodeGenModule::Release() {
   if (CodeGenOpts.UnwindTables)
 getModule().setUwtable();
 
+  switch (CodeGenOpts.getFramePointer()) {
+  case CodeGenOptions::FramePointerKind::None:
+// 0 ("none") is the default.
+break;
+  case CodeGenOptions::FramePointerKind::NonLeaf:
+getModule().setFramePointer(llvm::FramePointerKind::NonLeaf);
+break;
+  case CodeGenOptions::FramePointerKind::All:
+getModule().setFramePointer(llvm::FramePointerKind::All);
+break;
+  }
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)

diff  --git a/clang/test/CodeGen/asan-frame-pointer.cpp 
b/clang/test/CodeGen/asan-frame-pointer.cpp
new file mode 100644
index 0..ed3624f3146eb
--- /dev/null
+++ b/clang/test/CodeGen/asan-frame-pointer.cpp
@@ -0,0 +1,19 @@
+/// -mframe-pointer=none sets the module flag "frame-pointer" (merge behavior: 
max).
+/// asan synthesized ctor/dtor get the "frame-pointer" function attribute if 
not zero (default).
+// RUN: %clang_cc1 -emit-llvm -fsanitize=address -mframe-pointer=none %s -o - 
| FileCheck %s --check-prefix=NONE
+// RUN: %clang_cc1 -emit-llvm -fsanitize=address -mframe-pointer=non-leaf %s 
-o - | FileCheck %s --check-prefix=NONLEAF
+// RUN: %clang_cc1 -emit-llvm -fsanitize=address -mframe-pointer=all %s -o - | 
FileCheck %s --check-prefix=ALL
+
+int global;
+
+// NONE: define internal void @asan.module_ctor() #[[#ATTR:]] {
+// NONE: define internal void @asan.module_dtor() #[[#ATTR]] {
+// NONE: attributes #[[#ATTR]] = { nounwind }
+
+// NONLEAF: define internal void @asan.module_ctor() #[[#ATTR:]] {
+// NONLEAF: define internal void @asan.module_dtor() #[[#ATTR]] {
+// NONLEAF: attributes #[[#ATTR]] = { nounwind "frame-pointer"="non-leaf" }
+
+// ALL: define internal void @asan.module_ctor() #[[#ATTR:]] {
+// ALL: define internal void @asan.module_dtor() #[[#ATTR]] {
+// ALL: attributes #[[#ATTR]] = { nounwind "frame-pointer"="all" }

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index e6760f847d9f1..6770ad8b78c54 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1529,6 +1529,16 @@ example:
 can prove that the function does not execute any convergent operations.
 Similarly, the optimizer may remove ``convergent`` on calls/invokes when it
 can prove that the call/invoke cannot call a convergent function.
+``"frame-pointer"``
+This attribute tells the code generator whether the function
+should keep the frame pointer. The code generator may emit the frame 
pointer
+even if this attribute says the frame pointer can be eliminated.
+The allowed string values are:
+
+ * ``"none"`` (default) - the frame pointer can be eliminated.
+ * ``"non-leaf"`` - the frame pointer should be kept if the function calls
+   other functions.
+ * ``"all"`` - the frame pointer should be kept.
 ``hot``
 This attribute indicates that this function is a hot spot of the program
 execution. The function will be optimized more aggressively and will be
@@ -6994,6 +7004,24 @@ An example of module flags:
contain a flag with the ID ``!"foo"`` that has the value '1' after linking 
is
performed.
 
+Synthesized Functions Module Flags Metadata
+

[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 339833.
MaskRay added a comment.

improve doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/asan-frame-pointer.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
  llvm/test/Instrumentation/AddressSanitizer/uwtable.ll

Index: llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
+++ llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
@@ -10,12 +10,15 @@
   ret i32 %tmp
 }
 
-!llvm.module.flags = !{!0}
+!llvm.module.flags = !{!0, !1}
 
 ;; Due to -fasynchronous-unwind-tables.
 !0 = !{i32 7, !"uwtable", i32 1}
 
+;; Due to -fno-omit-frame-pointer.
+!1 = !{i32 7, !"frame-pointer", i32 2}
+
 ;; Set the uwtable attribute on ctor/dtor.
 ; CHECK: define internal void @asan.module_ctor() #[[#ATTR:]]
 ; CHECK: define internal void @asan.module_dtor() #[[#ATTR]]
-; CHECK: attributes #[[#ATTR]] = { nounwind uwtable }
+; CHECK: attributes #[[#ATTR]] = { nounwind uwtable "frame-pointer"="all" }
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -676,6 +676,16 @@
 
 void Module::setUwtable() { addModuleFlag(ModFlagBehavior::Max, "uwtable", 1); }
 
+FramePointerKind Module::getFramePointer() const {
+  auto *Val = cast_or_null(getModuleFlag("frame-pointer"));
+  return static_cast(
+  Val ? cast(Val->getValue())->getZExtValue() : 0);
+}
+
+void Module::setFramePointer(FramePointerKind Kind) {
+  addModuleFlag(ModFlagBehavior::Max, "frame-pointer", static_cast(Kind));
+}
+
 void Module::setSDKVersion(const VersionTuple &V) {
   SmallVector Entries;
   Entries.push_back(V.getMajor());
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -335,8 +335,21 @@
   unsigned AddrSpace, const Twine &N,
   Module *M) {
   auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
+  AttrBuilder B;
   if (M->getUwtable())
-F->addAttribute(AttributeList::FunctionIndex, Attribute::UWTable);
+B.addAttribute(Attribute::UWTable);
+  switch (M->getFramePointer()) {
+  case FramePointerKind::None:
+// 0 ("none") is the default.
+break;
+  case FramePointerKind::NonLeaf:
+B.addAttribute("frame-pointer", "non-leaf");
+break;
+  case FramePointerKind::All:
+B.addAttribute("frame-pointer", "all");
+break;
+  }
+  F->addAttributes(AttributeList::FunctionIndex, B);
   return F;
 }
 
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -53,7 +53,7 @@
 CGOPT_EXP(CodeModel::Model, CodeModel)
 CGOPT(ExceptionHandling, ExceptionModel)
 CGOPT_EXP(CodeGenFileType, FileType)
-CGOPT(FramePointer::FP, FramePointerUsage)
+CGOPT(FramePointerKind, FramePointerUsage)
 CGOPT(bool, EnableUnsafeFPMath)
 CGOPT(bool, EnableNoInfsFPMath)
 CGOPT(bool, EnableNoNaNsFPMath)
@@ -183,16 +183,16 @@
  "Emit nothing, for performance testing")));
   CGBINDOPT(FileType);
 
-  static cl::opt FramePointerUsage(
+  static cl::opt FramePointerUsage(
   "frame-pointer",
   cl::desc("Specify frame pointer elimination optimization"),
-  cl::init(FramePointer::None),
+  cl::init(FramePointerKind::None),
   cl::values(
-  clEnumValN(FramePointer::All, "all",
+  clEnumValN(FramePointerKind::All, "all",
  "Disable frame pointer elimination"),
-  clEnumValN(FramePointer::NonLeaf, "non-leaf",
+  clEnumValN(FramePointerKind::NonLeaf, "non-leaf",
  "Disable frame pointer elimination for non-leaf frame"),
-  clEnumValN(FramePointer::None, "none",
+  clEnumValN(FramePointerKind::None, "none",
  "Enable frame pointer elimination")));
   CGBINDOPT(FramePointerUsage);
 
@@ -662,11 +662,11 @@
   }
   if (FramePointerUsageView->getNumOccurrences() > 0 &&
   !F.hasFnAttribute("frame-pointer")) {
-if (getFramePointerUsage() == FramePointer::All)
+if (getFramePointerUsage() == FramePointerKind::All)
   NewAttrs.addAttribute("frame-pointer", "all");
-else if (getFramePointerUsage() == FramePointer::NonLeaf)
+else if (getFramePointerUsage() == FramePointerKind::NonLeaf)
   NewAttrs.addAttribute("frame-pointer", 

[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Chatted offline, vitalybuka said I can go ahead with existing ack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-22 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

This review doesn't make sense to me. Why add a flag that isn't affecting 
anything? Why add a flag that isn't even tested?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-22 Thread Kevin Athey via Phabricator via cfe-commits
kda created this revision.
kda added a reviewer: vitalybuka.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
kda requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No 
functional change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101122

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Modes of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnMode {
+  Always,  ///< Always detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Never,   ///< Never detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_mode_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return-mode=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in 
AddressSanitizer">,
+  Group,
+  Values<"always,runtime,never">,
+  NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
+  NormalizedValues<["Always", "Runtime", "Never"]>,
+  
MarshallingInfoEnum,
 "Runtime">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -222,6 +222,10 @@
 ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturnMode,
+llvm::AsanDetectStackUseAfterReturnMode, 2,
+llvm::AsanDetectStackUseAfterReturnMode::Runtime
+) ///< Set detection mode for stack-use-after-return.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Modes of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnMode {
+  Always,  ///< Always detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+   ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Never,   ///< Never detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+def sanitize_address_detect_stack_use_after_return_mode_EQ
+: Joined<["-"], "fsanitize-address-detect-stack-use-after-return-mode=">,
+  MetaVarName<"">,
+  Flags<[CC1Option]>,
+  HelpText<"Select the enabling method of detect-stack-use-after-return in AddressSanitizer">,
+  Group,
+  Values<"always,runtime,never">,
+  

[PATCH] D101112: [WebAssembly] Finalize wasm_simd128.h intrinsics

2021-04-22 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

General question about SIMD intrinsics: So we make dedicated wasm intrinsics 
only for the cases there are not general intrinsics people can use instead?




Comment at: clang/lib/Headers/wasm_simd128.h:171
+
+#define wasm_v128_load8_lane(__ptr, __vec, __i)
\
+  ((v128_t)__builtin_wasm_load8_lane((signed char *)(__ptr), (__i8x16)(__vec), 
\

dschuff wrote:
> out of curiosity, why are these macros, while all the rest (including ones 
> that don't need declarations such as `wasm_i64x2_eq`) seem to be inline 
> functions?
I was also curious about this too.



Comment at: clang/lib/Headers/wasm_simd128.h:648
+static __inline__ bool __DEFAULT_FN_ATTRS wasm_v128_any_true(v128_t __a) {
+  return __builtin_wasm_any_true_i8x16((__i8x16)__a);
+}

Do we not rename the builtin to `v128` as well?



Comment at: clang/lib/Headers/wasm_simd128.h:969
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ceil(v128_t __a) {
+  return (v128_t)__builtin_wasm_ceil_f32x4((__f32x4)__a);
+}

Sometimes builtin names seem slightly different from intrinsic names like this 
case: the intrinsic name is `f32x4_ceil` while the builtin name is 
`ceil_f32x4`. Is that intentional?



Comment at: clang/lib/Headers/wasm_simd128.h:1389
+
+// Old intrinsic names supported to ease transitioning to the stand names. Do
+// not use these; they will be removed in the near future.





Comment at: clang/lib/Headers/wasm_simd128.h:1398
+
+#ifdef __DEPRECATED
+#define __DEPRECATED_WASM_MACRO(__name, __replacement) 
\

What does this macro do?



Comment at: clang/lib/Headers/wasm_simd128.h:1547
+static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_extend_low_u8x16")
+wasm_i16x8_widen_low_u8x16(v128_t __a) {
+  return wasm_u16x8_extend_low_u8x16(__a);

The deprecated function name and the new intrinsic say `u`. Should this be `u` 
too? I haven't checked every single entry, but there seem to be multiple 
instances like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101112

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


[PATCH] D101112: [WebAssembly] Finalize wasm_simd128.h intrinsics

2021-04-22 Thread Petr Penzin via Phabricator via cfe-commits
penzn accepted this revision.
penzn added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101112

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


[PATCH] D101095: [clang][amdgpu] Use implicit code object version

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 339824.
JonChesterfield added a comment.

- simplify


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101095

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -34,7 +34,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -46,7 +46,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -66,7 +66,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -76,7 +76,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -28,7 +28,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -38,7 +38,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -56,7 +56,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -66,7 +66,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -12,7 +12,7 @@
 // RUN:   %S/Inputs/hip_multiple_input

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

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

Live again as of 15be0c41d2e5 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[clang] 15be0c4 - Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

2021-04-22 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-04-23T01:07:16+01:00
New Revision: 15be0c41d2e59fb4599c9aebf21ede498c61f51d

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

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

This reverts commit 24c1ed3b34f7602b955e52cd8a362f4e27eb5f20.

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

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

Removed: 




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

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

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index c0b2b78a1b4b2..4da1239dce84e 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -12,9 +12,16 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+#define AMDGPU_ARCH_PROGRAM_NAME "amdgpu-arch"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -715,6 +722,78 @@ void AMDGPUToolChain::checkTargetID(
   }
 }
 
+llvm::Error
+AMDGPUToolChain::detectSystemGPUs(const ArgList &Args,
+  SmallVector &GPUArchs) const 
{
+  std::string Program;
+  if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
+Program = A->getValue();
+  else
+Program = GetProgramPath(AMDGPU_ARCH_PROGRAM_NAME);
+  llvm::SmallString<64> OutputFile;
+  llvm::sys::fs::createTemporaryFile("print-system-gpus", "" /* No Suffix */,
+ OutputFile);
+  llvm::FileRemover OutputRemover(OutputFile.c_str());
+  llvm::Optional Redirects[] = {
+  {""},
+  StringRef(OutputFile),
+  {""},
+  };
+
+  std::string ErrorMessage;
+  if (int Result = llvm::sys::ExecuteAndWait(
+  Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
+  /*MemoryLimit*/ 0, &ErrorMessage)) {
+if (Result > 0) {
+  ErrorMessage = "Exited with error code " + std::to_string(Result);
+} else if (Result == -1) {
+  ErrorMessage = "Execute failed: " + ErrorMessage;
+} else {
+  ErrorMessage = "Crashed: " + ErrorMessage;
+}
+
+return llvm::createStringError(std::error_code(),
+   Program + ": "

[PATCH] D99903: [Clang][Sema] better -Wcast-function-type diagnose for pointer parameters and parameters with cv-qualifiers

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99903

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


[PATCH] D101095: [clang][amdgpu] Use implicit code object version

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 339820.
JonChesterfield added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101095

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -34,7 +34,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -46,7 +46,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -66,7 +66,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -76,7 +76,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -28,7 +28,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -38,7 +38,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -56,7 +56,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -66,7 +66,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -12,7 +12,7 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/

[clang] 40beb1f - CWG2076: Permit implicit conversions within a single level of braces

2021-04-22 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-04-22T16:49:39-07:00
New Revision: 40beb1f84a3d72ea39fcee1dcb66c3cefb5d5644

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

LOG: CWG2076: Permit implicit conversions within a single level of braces
during overload resolution, even when calling a copy constructor.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/drs/dr14xx.cpp
clang/test/CXX/drs/dr20xx.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index feef15689fafd..179da2ac26d77 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3346,10 +3346,7 @@ IsInitializerListConstructorConversion(Sema &S, Expr 
*From, QualType ToType,
 bool Usable = !Info.Constructor->isInvalidDecl() &&
   S.isInitListConstructor(Info.Constructor);
 if (Usable) {
-  // If the first argument is (a reference to) the target type,
-  // suppress conversions.
-  bool SuppressUserConversions = isFirstArgumentCompatibleWithType(
-  S.Context, Info.Constructor, ToType);
+  bool SuppressUserConversions = false;
   if (Info.ConstructorTmpl)
 S.AddTemplateOverloadCandidate(Info.ConstructorTmpl, Info.FoundDecl,
/*ExplicitArgs*/ nullptr, From,
@@ -3473,14 +3470,18 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType 
ToType,
  /*AllowExplicit*/ true);
 if (Usable) {
   bool SuppressUserConversions = !ConstructorsOnly;
+  // C++20 [over.best.ics.general]/4.5:
+  //   if the target is the first parameter of a constructor [of class
+  //   X] and the constructor [...] is a candidate by [...] the second
+  //   phase of [over.match.list] when the initializer list has exactly
+  //   one element that is itself an initializer list, [...] and the
+  //   conversion is to X or reference to cv X, user-defined conversion
+  //   sequences are not cnosidered.
   if (SuppressUserConversions && ListInitializing) {
-SuppressUserConversions = false;
-if (NumArgs == 1) {
-  // If the first argument is (a reference to) the target type,
-  // suppress conversions.
-  SuppressUserConversions = isFirstArgumentCompatibleWithType(
-  S.Context, Info.Constructor, ToType);
-}
+SuppressUserConversions =
+NumArgs == 1 && isa(Args[0]) &&
+isFirstArgumentCompatibleWithType(S.Context, Info.Constructor,
+  ToType);
   }
   if (Info.ConstructorTmpl)
 S.AddTemplateOverloadCandidate(

diff  --git a/clang/test/CXX/drs/dr14xx.cpp b/clang/test/CXX/drs/dr14xx.cpp
index 866f2fe0bf85a..70bf1ea70e38e 100644
--- a/clang/test/CXX/drs/dr14xx.cpp
+++ b/clang/test/CXX/drs/dr14xx.cpp
@@ -296,6 +296,9 @@ namespace std {
 } // std
 
 namespace dr1467 {  // dr1467: 3.7 c++11
+  // Note that the change to [over.best.ics] was partially undone by DR2076;
+  // the resulting rule is tested with the tests for that change.
+
   // List-initialization of aggregate from same-type object
 
   namespace basic0 {
@@ -419,7 +422,7 @@ namespace dr1467 {  // dr1467: 3.7 c++11
 void f() { Value{{{1,2},{3,4}}}; }
   }
   namespace NonAmbiguous {
-  // The original implementation made this case ambigious due to the special
+  // The original implementation made this case ambiguous due to the special
   // handling of one element initialization lists.
   void f(int(&&)[1]);
   void f(unsigned(&&)[1]);

diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 56cc1161a00c8..9a0c772973eca 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -49,6 +49,47 @@ namespace dr2026 { // dr2026: 11
   }
 }
 
+namespace dr2076 { // dr2076: 13
+#if __cplusplus >= 201103L
+  namespace std_example {
+struct A { A(int); };
+struct B { B(A); };
+B b{{0}};
+
+struct Params { int a; int b; };
+struct Foo {
+  Foo(Params);
+};
+Foo foo{{1, 2}};
+  }
+
+  struct string_view {
+string_view(int); // not an aggregate
+  };
+  struct string {
+string(int); // not an aggregate
+operator string_view() const;
+  };
+
+  void foo(const string &); // expected-note {{cannot convert initializer 
list}}
+  void bar(string_view); // expected-note 2{{cannot convert initializer list}}
+
+  void func(const string &arg) {
+// An argument in one set of braces is subject to user-defined conversions;
+// an argument in two sets of braces is not, but an identity conversion is
+// still OK.
+fo

[PATCH] D100819: [RISCV] Implement the vneg.v builtin.

2021-04-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100819

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


[PATCH] D100830: [RISCV] [1/2] Add IR intrinsic for Zbp extension

2021-04-22 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb49337bbb9de: [RISCV] [1/2] Add IR intrinsic for Zbp 
extension (authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D100830?vs=339150&id=339818#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100830

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbp.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbp.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbp-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
  llvm/test/MC/RISCV/rv32b-aliases-valid.s
  llvm/test/MC/RISCV/rv64b-aliases-valid.s

Index: llvm/test/MC/RISCV/rv64b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv64b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv64b-aliases-valid.s
@@ -338,3 +338,27 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: greviw t0, t1, 13
+# CHECK-S-OBJ: greviw t0, t1, 13
+grevw x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorciw t0, t1, 13
+# CHECK-S-OBJ: gorciw t0, t1, 13
+gorcw x5, x6, 13
Index: llvm/test/MC/RISCV/rv32b-aliases-valid.s
===
--- llvm/test/MC/RISCV/rv32b-aliases-valid.s
+++ llvm/test/MC/RISCV/rv32b-aliases-valid.s
@@ -242,3 +242,19 @@
 # CHECK-S-OBJ-NOALIAS: bexti t0, t1, 8
 # CHECK-S-OBJ: bexti t0, t1, 8
 bext x5, x6, 8
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 13
+# CHECK-S-OBJ: grevi t0, t1, 13
+grev x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: gorci t0, t1, 13
+# CHECK-S-OBJ: gorci t0, t1, 13
+gorc x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 13
+# CHECK-S-OBJ: shfli t0, t1, 13
+shfl x5, x6, 13
+
+# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 13
+# CHECK-S-OBJ: unshfli t0, t1, 13
+unshfl x5, x6, 13
Index: llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll
@@ -0,0 +1,325 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbp -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBP
+
+declare i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+
+define signext i32 @grev32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: grev32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:grevw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grev32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:grevw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.grevi.i32(i32 %a)
+
+define signext i32 @grevi32(i32 signext %a) nounwind {
+; RV64IB-LABEL: grevi32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:greviw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: grevi32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:greviw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.grev.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+
+define signext i32 @gorc32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: gorc32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorcw a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorc32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorcw a0, a0, a1
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.gorci.i32(i32 %a)
+
+define signext i32 @gorci32(i32 signext %a) nounwind {
+; RV64IB-LABEL: gorci32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:gorciw a0, a0, 13
+; RV64IB-NEXT:ret
+;
+; RV64IBP-LABEL: gorci32:
+; RV64IBP:   # %bb.0:
+; RV64IBP-NEXT:gorciw a0, a0, 13
+; RV64IBP-NEXT:ret
+  %tmp = call i32 @llvm.riscv.gorc.i32(i32 %a, i32 13)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.shfl.i32(i32 %a, i32 %b)
+
+define signext i32 @shfl32(i32 signext %a, i32 signext %b) nounwind {
+; RV64IB-LABEL: shfl32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:shflw a0, a0, a1
+; RV64IB-NEXT: 

[clang] b49337b - [RISCV] [1/2] Add IR intrinsic for Zbp extension

2021-04-22 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-22T16:34:51-07:00
New Revision: b49337bbb9de63e4696cb1fc1d2809d2823ab460

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

LOG: [RISCV] [1/2] Add IR intrinsic for Zbp extension

RV32/64:
grev
grevi
gorc
gorci
shfl
shfli
unshfl
unshfli

RV64 ONLY:
grevw
greviw
gorcw
gorciw
shflw
shfli (For non-existing shfliw)
unshfli   (For non-existing unshfliw)

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbp.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbp.c
llvm/test/CodeGen/RISCV/rv32zbp-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbp-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/MC/RISCV/rv32b-aliases-valid.s
llvm/test/MC/RISCV/rv64b-aliases-valid.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 8105263ca3ca6..baf710a6071fc 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -26,6 +26,20 @@ TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", 
"experimental-zbc")
 TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "experimental-zbc")
 TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "experimental-zbc")
 
+// Zbp extension
+TARGET_BUILTIN(__builtin_riscv_grev_32, "ZiZiZi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_grev_64, "WiWiWi", "nc", 
"experimental-zbp,64bit")
+TARGET_BUILTIN(__builtin_riscv_gorc_32, "ZiZiZi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_gorc_64, "WiWiWi", "nc", 
"experimental-zbp,64bit")
+TARGET_BUILTIN(__builtin_riscv_shfl_32, "ZiZiZi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_shfl_64, "WiWiWi", "nc", 
"experimental-zbp,64bit")
+TARGET_BUILTIN(__builtin_riscv_unshfl_32, "ZiZiZi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_unshfl_64, "WiWiWi", "nc", 
"experimental-zbp,64bit")
+TARGET_BUILTIN(__builtin_riscv_xperm_n, "LiLiLi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_xperm_b, "LiLiLi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_xperm_h, "LiLiLi", "nc", "experimental-zbp")
+TARGET_BUILTIN(__builtin_riscv_xperm_w, "WiWiWi", "nc", 
"experimental-zbp,64bit")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7e19532322536..431929d49da82 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17849,6 +17849,18 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
+  case RISCV::BI__builtin_riscv_grev_32:
+  case RISCV::BI__builtin_riscv_grev_64:
+  case RISCV::BI__builtin_riscv_gorc_32:
+  case RISCV::BI__builtin_riscv_gorc_64:
+  case RISCV::BI__builtin_riscv_shfl_32:
+  case RISCV::BI__builtin_riscv_shfl_64:
+  case RISCV::BI__builtin_riscv_unshfl_32:
+  case RISCV::BI__builtin_riscv_unshfl_64:
+  case RISCV::BI__builtin_riscv_xperm_n:
+  case RISCV::BI__builtin_riscv_xperm_b:
+  case RISCV::BI__builtin_riscv_xperm_h:
+  case RISCV::BI__builtin_riscv_xperm_w:
   case RISCV::BI__builtin_riscv_crc32_b:
   case RISCV::BI__builtin_riscv_crc32_h:
   case RISCV::BI__builtin_riscv_crc32_w:
@@ -17876,6 +17888,36 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   ID = Intrinsic::riscv_clmulr;
   break;
 
+// Zbp
+case RISCV::BI__builtin_riscv_grev_32:
+case RISCV::BI__builtin_riscv_grev_64:
+  ID = Intrinsic::riscv_grev;
+  break;
+case RISCV::BI__builtin_riscv_gorc_32:
+case RISCV::BI__builtin_riscv_gorc_64:
+  ID = Intrinsic::riscv_gorc;
+  break;
+case RISCV::BI__builtin_riscv_shfl_32:
+case RISCV::BI__builtin_riscv_shfl_64:
+  ID = Intrinsic::riscv_shfl;
+  break;
+case RISCV::BI__builtin_riscv_unshfl_32:
+case RISCV::BI__builtin_riscv_unshfl_64:
+  ID = Intrinsic::riscv_unshfl;
+  break;
+case RISCV::BI__builtin_riscv_xperm_n:
+  ID = Intrinsic::riscv_xperm_n;
+  break;
+case RISCV::BI__builtin_riscv_xperm_b:
+  ID = Intrinsic::riscv_xperm_b;
+  break;
+case RISCV::BI__builtin_riscv_xperm_h:
+

[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cdb9873b210: [clang][nfc] Split 
getOrCheckAMDGPUCodeObjectVersion (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,29 +1573,46 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy,
+ options::OPT_mcode_object_version_EQ);
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
+
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+}
   }
+}
 
-  // The last of -mcode-object-v3, -mno-code-object-v3 and
-  // -mcode-object-version= wins.
-  if (auto *CodeObjArg =
-  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
-  options::OPT_mno_code_object_v3_legacy,
-  options::OPT_mcode_object_version_EQ)) {
+unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
+

[clang] 2cdb987 - [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-04-23T00:24:42+01:00
New Revision: 2cdb9873b2105eb07ce323edbe6c431a6c79e523

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

LOG: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

[clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

Separates detection of deprecated or invalid code object version from
returning the version. Written to avoid any behaviour change.

Precursor to a revision of D98746.

Reviewed By: yaxunl

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/HIP.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index dc9c9751c851..c0b2b78a1b4b 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -568,7 +568,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const 
llvm::Triple &Triple,
   // and errors for the last invalid code object version options.
   // It is done here to avoid repeated warning or error messages for
   // each tool invocation.
-  (void)getOrCheckAMDGPUCodeObjectVersion(D, Args, /*Diagnose=*/true);
+  checkAMDGPUCodeObjectVersion(D, Args);
 }
 
 Tool *AMDGPUToolChain::buildLinker() const {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7755e9f61e70..801fa1b0cead 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1114,7 +1114,7 @@ static const char *RelocationModelName(llvm::Reloc::Model 
Model) {
 static void handleAMDGPUCodeObjectVersionOptions(const Driver &D,
  const ArgList &Args,
  ArgStringList &CmdArgs) {
-  unsigned CodeObjVer = getOrCheckAMDGPUCodeObjectVersion(D, Args);
+  unsigned CodeObjVer = getAMDGPUCodeObjectVersion(D, Args);
   CmdArgs.insert(CmdArgs.begin() + 1,
  Args.MakeArgString(Twine("--amdhsa-code-object-version=") +
 Twine(CodeObjVer)));

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 10d61ae9828f..7c496270276c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,29 +1573,46 @@ void tools::addX86AlignBranchArgs(const Driver &D, 
const ArgList &Args,
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy,
+ options::OPT_mcode_object_version_EQ);
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
+
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  

[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG8baba6890de7: [HIP] Support overloaded math functions for 
hipRTC (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D100794?vs=339773&id=339812#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100794

Files:
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Headers/hip-header.hip

Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -10,18 +10,54 @@
 // RUN:   -internal-isystem %S/Inputs/include \
 // RUN:   -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown \
 // RUN:   -target-cpu gfx906 -emit-llvm %s -fcuda-is-device -o - \
-// RUN:   -D__HIPCC_RTC__ -std=c++14 | FileCheck %s
-
+// RUN:   -D__HIPCC_RTC__ -std=c++14 | FileCheck -check-prefixes=CHECK,CXX14 %s
 
 // expected-no-diagnostics
 
+struct Number {
+  __device__ Number(float _x) : x(_x) {}
+  float x;
+};
+
+#if __cplusplus >= 201103L
+// Check __hip::__numeric_type can be used with a class without default ctor.
+__device__ void test_numeric_type() {
+  int x = __hip::__numeric_type::value;
+}
+
+// ToDo: Fix __clang_hip_cmake.h to specialize __hip::is_arithmetic<_Float16>
+// to resolve fma(_Float16, _Float16, int) to fma(double, double, double)
+// instead of fma(_Float16, _Float16, _Float16).
+
+// CXX14-LABEL: define{{.*}}@_Z8test_fma
+// CXX14: call {{.*}}@__ocml_fma_f16
+__device__ double test_fma(_Float16 h, int i) {
+  return fma(h, h, i);
+}
+
+#endif
+
 // CHECK-LABEL: amdgpu_kernel void @_Z4kernPff
 __global__ void kern(float *x, float y) {
   *x = sin(y);
 }
 
 // CHECK-LABEL: define{{.*}} i64 @_Z11test_size_tv
-// CHEC: ret i64 8
+// CHECK: ret i64 8
 __device__ size_t test_size_t() {
   return sizeof(size_t);
 }
+
+// Check there is no ambiguity when calling overloaded math functions.
+
+// CHECK-LABEL: define{{.*}}@_Z10test_floorv
+// CHECK: call {{.*}}double @__ocml_floor_f64(double
+__device__ float test_floor() {
+  return floor(5);
+}
+
+// CHECK-LABEL: define{{.*}}@_Z8test_maxv
+// CHECK: call {{.*}}double @__ocml_fmax_f64(double {{.*}}, double
+__device__ float test_max() {
+  return max(5, 6.0);
+}
Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -72,12 +72,13 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !defined(__HIPCC_RTC__)
 #if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
+#if defined(__HIPCC_RTC__)
+#include <__clang_hip_cmath.h>
+#else
 #include <__clang_cuda_math_forward_declares.h>
 #include <__clang_hip_cmath.h>
 #include <__clang_cuda_complex_builtins.h>
-
 #include 
 #include 
 #include 
Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -22,7 +22,7 @@
 #endif
 #include 
 #include 
-#endif // __HIPCC_RTC__
+#endif // !defined(__HIPCC_RTC__)
 
 #pragma push_macro("__DEVICE__")
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -36,6 +36,9 @@
 __DEVICE__ float fma(float __x, float __y, float __z) {
   return ::fmaf(__x, __y, __z);
 }
+#if !defined(__HIPCC_RTC__)
+// The value returned by fpclassify is platform dependent, therefore it is not
+// supported by hipRTC.
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -44,6 +47,8 @@
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
+#endif // !defined(__HIPCC_RTC__)
+
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
@@ -209,11 +214,117 @@
 
 template  struct __hip_enable_if { typedef __T type; };
 
+namespace __hip {
+template  struct is_integral {
+  enum { value = 0 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+temp

[clang] 8baba68 - [HIP] Support overloaded math functions for hipRTC

2021-04-22 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-04-22T19:06:51-04:00
New Revision: 8baba6890de74d33beb75646ebcbf168e949d578

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

LOG: [HIP] Support overloaded math functions for hipRTC

Remove the dependence on standard C++ header
for overloaded math functions in HIP header
since standard C++ header is not available for hipRTC.

Reviewed by: Artem Belevich, Justin Lebar

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

Added: 


Modified: 
clang/lib/Headers/__clang_hip_cmath.h
clang/lib/Headers/__clang_hip_runtime_wrapper.h
clang/test/Headers/hip-header.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_cmath.h 
b/clang/lib/Headers/__clang_hip_cmath.h
index 632d46e47f8b9..5d7b75ffdcc0f 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -22,7 +22,7 @@
 #endif
 #include 
 #include 
-#endif // __HIPCC_RTC__
+#endif // !defined(__HIPCC_RTC__)
 
 #pragma push_macro("__DEVICE__")
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -36,6 +36,9 @@ __DEVICE__ long abs(long __n) { return ::labs(__n); }
 __DEVICE__ float fma(float __x, float __y, float __z) {
   return ::fmaf(__x, __y, __z);
 }
+#if !defined(__HIPCC_RTC__)
+// The value returned by fpclassify is platform dependent, therefore it is not
+// supported by hipRTC.
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -44,6 +47,8 @@ __DEVICE__ int fpclassify(double __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
+#endif // !defined(__HIPCC_RTC__)
+
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
@@ -209,11 +214,117 @@ template  struct 
__hip_enable_if {};
 
 template  struct __hip_enable_if { typedef __T type; };
 
+namespace __hip {
+template  struct is_integral {
+  enum { value = 0 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+
+// ToDo: specializes is_arithmetic<_Float16>
+template  struct is_arithmetic {
+  enum { value = 0 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+template <> struct is_arithmetic {
+  enum { value = 1 };
+};
+
+struct true_type {
+  static const __constant__ bool value = true;
+};
+struct false_type {
+  static const __constant__ bool value = false;
+};
+
+template  struct is_same : public false_type {};
+template  struct is_same<__T, __T> : public true_type {};
+
+template  struct add_rvalue_reference { typedef __T &&type; };
+
+template  typename add_rvalue_reference<__T>::type declval();
+
 // decltype is only available in C++11 and above.
 #if __cplusplus >= 201103L
 // __hip_promote
-namespace __hip {
-
 template  struct __numeric_type {
   static void __test(...);
   static _Float16 __test(_Float16);
@@ -229,8 +340,8 @@ template  struct __numeric_type {
   // No support for long double, use double instead.
   static double __test(long double);
 
-  typedef decltype(__test(std::declval<_Tp>())) type;
-  static const bool value = !std::is_same::value;
+  typedef dec

[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

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



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1576
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {

The logic to pick which of multiple arguments wins seems an important thing to 
keep in one place. I think this is an improvement on the first draft and on 
D101117


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 339810.
JonChesterfield added a comment.

- whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,29 +1573,46 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy,
+ options::OPT_mcode_object_version_EQ);
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
+
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+}
   }
+}
 
-  // The last of -mcode-object-v3, -mno-code-object-v3 and
-  // -mcode-object-version= wins.
-  if (auto *CodeObjArg =
-  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
-  options::OPT_mno_code_object_v3_legacy,
-  options::OPT_mcode_object_version_EQ)) {
+unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
+   const llvm::opt::ArgList &Args) {
+  unsigned CodeObjVer = 4; // default
+  if (auto *CodeObjArg = getAMDGPUCod

[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 339807.
JonChesterfield added a comment.

- factor out last arg wins


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,29 +1573,48 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
+
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy,
+ options::OPT_mcode_object_version_EQ);
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
+
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+}
   }
+}
 
-  // The last of -mcode-object-v3, -mno-code-object-v3 and
-  // -mcode-object-version= wins.
-  if (auto *CodeObjArg =
-  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
-  options::OPT_mno_code_object_v3_legacy,
-  options::OPT_mcode_object_version_EQ)) {
+unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
+   const llvm::opt::ArgList &Args) {
+  unsigned CodeObjVer = 4; // default
+
+  if (auto *CodeObj

[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 339806.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

- factor out last arg wins


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101117

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,29 +1573,48 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+static llvm::opt::Arg *
+getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
+
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+ options::OPT_mno_code_object_v3_legacy,
+ options::OPT_mcode_object_version_EQ);
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
+
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+}
   }
+}
 
-  // The last of -mcode-object-v3, -mno-code-object-v3 and
-  // -mcode-object-version= wins.
-  if (auto *CodeObjArg =
-  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
-  options::OPT_mno_code_object_v3_legacy,
-  options::OPT_mcode_object_version_EQ)) {
+unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
+   const llvm::opt::ArgList &Args) {
+  unsigned 

[clang] af91065 - Revert "[AST] Enable AST node introspection on Apple"

2021-04-22 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-22T23:54:16+01:00
New Revision: af91065ce5e6fd3069029ba9d077f2b21bacb545

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

LOG: Revert "[AST] Enable AST node introspection on Apple"

This reverts commit 907409a536cd66a09a91ee28e1f6f8bcc7127bc7.

This caused a failure

  
http://green.lab.llvm.org/green//job/lldb-cmake-standalone/2827/consoleFull#-210109660a1ca8a51-895e-46c6-af87-ce24fa4cd561

Assertion failed: (!CodeSynthesisContexts.empty() && "Cannot perform an
instantiation without some context on the " "instantiation stack"),
function SubstType, file
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp,
line 2071.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index 053caa319466..8d77b233233d 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@ string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} ${PATH_LIB_END} 
-1 PATH_TAIL)
 string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL})
 
 if (NOT Python3_EXECUTABLE
+OR APPLE
 OR CMAKE_CROSSCOMPILING
 OR GENERATOR_IS_MULTI_CONFIG
 OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD



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


[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield abandoned this revision.
JonChesterfield added a comment.

Abandoning this. Unacceptably ugly, will revise D101077 
 in a slightly different direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101117

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


[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D101117#2710368 , @JonChesterfield 
wrote:

> I'm not very pleased with this. There's too much state to move around when 
> representing the failure and the control flow is probably harder to read than 
> it was in the original. May take another pass at it.

I am OK with this. If you would like to try more pls go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101117

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


[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

nice. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101117

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


[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

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

I'm not very pleased with this. There's too much state to move around when 
representing the failure and the control flow is probably harder to read than 
it was in the original. May take another pass at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101117

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


[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

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



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1626
 } else {
-  auto Remnant =
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Diagnose &&
-  (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > 
MaxCodeObjVer))
-D.Diag(diag::err_drv_invalid_int_value)
-<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
 }

JonChesterfield wrote:
> yaxunl wrote:
> > JonChesterfield wrote:
> > > getAsInteger writes to CodeObjVer.
> > can we return Optional and return None if there is a remnant? 
> > Then we can call this function in checkAMDGPUCodeObjectVersion
> We could. It would spawn handling of the Optional<> at all the call sites 
> though. I'll see if I can pull the search logic into a local helper.
Implemented in D101117.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


[PATCH] D101117: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added a reviewer: yaxunl.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, jvesely, 
kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

[clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

Separates detection of deprecated or invalid code object version from
returning the version. Alternative to D101077 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101117

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,22 +1573,10 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
-  const unsigned MinCodeObjVer = 2;
-  const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
-
-  // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+static const unsigned AMDGPUCodeObjectVersionDefault = 4;
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
-  }
+static std::pair, llvm::opt::Arg *>
+tryGetAMDGPUCodeObjectVersion(const Driver &D, const llvm::opt::ArgList &Args) {
 
   // The last of -mcode-object-v3, -mno-code-object-v3 and
   // -mcode-object-version= wins.
@@ -1598,20 +1586,57 @@
   options::OPT_mcode_object_version_EQ)) {
 if (CodeObjArg->getOption().getID() ==
 options::OPT_mno_code_object_v3_legacy) {
-  CodeObjVer = 2;
+  return {2, nullptr};
 } else if (CodeObjArg->getOption().getID() ==
options::OPT_mcode_object_v3_legacy) {
-  CodeObjVer = 3;
+  return {3, nullptr};
 } else {
+  unsigned CodeObjVer;
   auto Remnant =
   StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Diagnose &&
-  (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer))
-D.Diag(diag::err_drv_invalid_int_value)
-<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  if (Remnant) {
+return {{}, CodeObjArg};
+  } else {
+return {CodeObjVer, CodeObjArg};
+  }
 }
   }
-  return CodeObjVer;
+
+  return {AMDGPUCodeObjectVersionDefault, nullptr};
+}
+
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
+  const unsigned MinCodeObjVer = 2;
+  const unsigned MaxCodeObjVer = 4;
+
+  // Emit warnings for legacy options even if they are overridden.
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-co

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

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

In D99949#2710273 , @davezarzycki 
wrote:

> I removed all HSA/ROCM via the package manager and everything is fine now. 
> Have you considered using __has_include() instead of CMake? It seems to be 
> supported by all contemporary compilers, even MSVC.

To confirm, you can build the pre-revert version of this patch after that 
adjustment? If so I'll give this another try.

I have indeed considered something along the lines of

  #if __has_include
  #if __has_include("hsa.h")
  #include "hsa.h"
  #elif __has_include("hsa/hsa.h")
  #include "hsa/hsa.h"
  #endif
  #else
  #include "hsa.h"
  #endif

It's tempting to forward declare the few pieces used instead. Hopefully the 
cmake find_package stuff will be robust enough to avoid such things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


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

2021-04-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

I think this is good to go. Later anybody can build improvements on top of this 
patch and maybe work on some more powerful “dead stores” warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


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

2021-04-22 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

I removed all HSA/ROCM via the package manager and everything is fine now. Have 
you considered using __has_include() instead of CMake? It seems to be supported 
by all contemporary compilers, even MSVC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D101112: [WebAssembly] Finalize wasm_simd128.h intrinsics

2021-04-22 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added inline comments.



Comment at: clang/lib/Headers/wasm_simd128.h:171
+
+#define wasm_v128_load8_lane(__ptr, __vec, __i)
\
+  ((v128_t)__builtin_wasm_load8_lane((signed char *)(__ptr), (__i8x16)(__vec), 
\

out of curiosity, why are these macros, while all the rest (including ones that 
don't need declarations such as `wasm_i64x2_eq`) seem to be inline functions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101112

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


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

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

Looks good in terms of false positives on Chrome. This did uncover a lot of 
issues, although many of them are due to only using some variable in some 
config with `#ifdef`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101049: [AST] Add DeclarationNameInfo to node introspection

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

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101049

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/lib/Tooling/EmptyNodeIntrospection.inc.in
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -216,6 +216,9 @@
 STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getEndLoc()),
@@ -305,6 +308,7 @@
 llvm::makeArrayRef(ExpectedRanges),
   (ArrayRef>{
 STRING_LOCATION_STDPAIR(MethodDecl, getExceptionSpecSourceRange()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getParametersSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalSourceRange()),
@@ -1401,3 +1405,148 @@
   TL, getAs().getParensRange(;
 }
 #endif
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_Dtor) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  ~Foo() {}
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxDestructorDecl(hasName("~Foo")).bind("dtor"))), TU,
+  Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Dtor = BoundNodes[0].getNodeAs("dtor");
+  auto NI = Dtor->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  // clang-format off
+  EXPECT_EQ(
+  llvm::makeArrayRef(ExpectedLocations),
+  (ArrayRef>{
+  STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getLoc()),
+  STRING_LOCATION_STDPAIR((&NI),
+getNamedTypeInfo()->getTypeLoc().getAs().getNameLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getBeginLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getEndLoc())}));
+  // clang-format on
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getLocalSourceRange()),
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getSourceRange()),
+  STRING_LOCATION_PAIR((&NI), getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_ConvOp) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  bool operator==(const Foo&) const { return false; }
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxMethodDecl().bind("opeq"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Opeq = BoundNodes[0].getNodeAs("opeq");
+  auto NI = Opeq->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(llvm::makeArrayRef(ExpectedLocations),
+(ArrayRef>{
+STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+STRING_LOCATION_STDPAIR((&NI), getLoc())}));
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(ExpectedRanges,
+  UnorderedElementsAre(
+   

[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-22 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:586-587
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #endif
 

Nit: I'd add `// ` here for consistency.


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

https://reviews.llvm.org/D100794

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


[PATCH] D101112: [WebAssembly] Finalize wasm_simd128.h intrinsics

2021-04-22 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds new intrinsics for instructions that are in the final SIMD spec but did not
previously have intrinsics. Also updates the names of existing intrinsics to
reflect the final names of the underlying instructions in the spec. Keeps the
old names as deprecated functions to ease the transition to the new names.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101112

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -42,6 +42,19 @@
   wasm_v32x4_shuffle(v, v, 0, 1, 2, 3);
   wasm_v64x2_shuffle(v, v, 0, 1);
 
+  uint8_t lane8 = 0;
+  uint16_t lane16 = 0;
+  uint32_t lane32 = 0;
+  uint64_t lane64 = 0;
+  v = wasm_v128_load8_lane(&lane8, v, 0);
+  v = wasm_v128_load16_lane(&lane16, v, 0);
+  v = wasm_v128_load32_lane(&lane32, v, 0);
+  v = wasm_v128_load64_lane(&lane64, v, 0);
+  wasm_v128_store8_lane(&lane8, v, 15);
+  wasm_v128_store16_lane(&lane16, v, 7);
+  wasm_v128_store32_lane(&lane32, v, 3);
+  wasm_v128_store64_lane(&lane64, v, 1);
+
   return 0;
 }
 
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -400,6 +400,12 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i64x2 abs_i64x2(i64x2 v) {
+  return __builtin_wasm_abs_i64x2(v);
+  // WEBASSEMBLY: call <2 x i64> @llvm.abs.v2i64(<2 x i64> %v, i1 false)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_min_s_i8x16(x, y);
   // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y
@@ -928,13 +934,13 @@
   // WEBASSEMBLY: ret
 }
 
-i8x16 swizzle_v8x16(i8x16 x, i8x16 y) {
-  return __builtin_wasm_swizzle_v8x16(x, y);
+i8x16 swizzle_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_swizzle_i8x16(x, y);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %x, <16 x i8> %y)
 }
 
 i8x16 shuffle(i8x16 x, i8x16 y) {
-  return __builtin_wasm_shuffle_v8x16(x, y, 0, 1, 2, 3, 4, 5, 6, 7,
+  return __builtin_wasm_shuffle_i8x16(x, y, 0, 1, 2, 3, 4, 5, 6, 7,
   8, 9, 10, 11, 12, 13, 14, 15);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.shuffle(<16 x i8> %x, <16 x i8> %y,
   // WEBASSEMBLY-SAME: i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7,
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -40,6 +40,9 @@
 typedef short __i16x4 __attribute__((__vector_size__(8), __aligned__(8)));
 typedef unsigned short __u16x4
 __attribute__((__vector_size__(8), __aligned__(8)));
+typedef int __i32x2 __attribute__((__vector_size__(8), __aligned__(8)));
+typedef unsigned int __u32x2
+__attribute__((__vector_size__(8), __aligned__(8)));
 
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__, __target__("simd128"),\
@@ -57,102 +60,129 @@
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
-wasm_v8x16_load_splat(const void *__mem) {
-  struct __wasm_v8x16_load_splat_struct {
+wasm_v128_load8_splat(const void *__mem) {
+  struct __wasm_v128_load8_splat_struct {
 uint8_t __v;
   } __attribute__((__packed__, __may_alias__));
-  uint8_t __v = ((const struct __wasm_v8x16_load_splat_struct *)__mem)->__v;
+  uint8_t __v = ((const struct __wasm_v128_load8_splat_struct *)__mem)->__v;
   return (v128_t)(__u8x16){__v, __v, __v, __v, __v, __v, __v, __v,
__v, __v, __v, __v, __v, __v, __v, __v};
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
-wasm_v16x8_load_splat(const void *__mem) {
-  struct __wasm_v16x8_load_splat_struct {
+wasm_v128_load16_splat(const void *__mem) {
+  struct __wasm_v128_load16_splat_struct {
 uint16_t __v;
   } __attribute__((__packed__, __may_alias__));
-  uint16_t __v = ((const struct __wasm_v16x8_load_splat_struct *)__mem)->__v;
+  uint16_t __v = ((const struct __wasm_v128_load16_splat_struct *)__mem)->__v;
   return (v128_t)(__u16x8){__v, __v, __v, __v, __v, __v, __v, __v};
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
-wasm_v32x4_load_splat(const void *__mem) {
-  struct __wasm_v32x4_load_splat_struct {
+wasm_v128_load32_splat(const void *__mem) {
+  struct __wasm_v128_load32_splat_struct {
 uint32_t __v;
   } __attribute__((__packed__, __may_alias__));
-  uint32_t __v = ((const struct __wasm_v32x4_load_spla

[PATCH] D101017: [NewPM] Make GlobalsAA available earlier in the pipeline

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

That sounds like less powerful optimizations due to the GlobalsAA movement. If 
adding a GlobalsAA plus D100917  is a win 
overall, that should work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101017

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


[clang] 907409a - [AST] Enable AST node introspection on Apple

2021-04-22 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-22T22:19:21+01:00
New Revision: 907409a536cd66a09a91ee28e1f6f8bcc7127bc7

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

LOG: [AST] Enable AST node introspection on Apple

This was previously excluded due to possible buildbot failures.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index 8d77b233233d..053caa319466 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -24,7 +24,6 @@ string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} ${PATH_LIB_END} 
-1 PATH_TAIL)
 string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL})
 
 if (NOT Python3_EXECUTABLE
-OR APPLE
 OR CMAKE_CROSSCOMPILING
 OR GENERATOR_IS_MULTI_CONFIG
 OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD



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


[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-04-22 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 339782.
aeubanks added a comment.
Herald added subscribers: cfe-commits, steven_wu.
Herald added a project: clang.

add test
use CFGAnalyses
uncovered another place in updateCGAndAnalysisManager() to change

depends on D101017 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/analysis-invalidation.ll
  llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll

Index: llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
===
--- llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
+++ llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
@@ -9,11 +9,11 @@
 ; CHECK-LABEL: Starting llvm::Module pass manager run.
 ; CHECK: Running pass: InlinerPass on (test1_f, test1_g, test1_h)
 ; CHECK: Running analysis: DominatorTreeAnalysis on test1_f
-; CHECK: Running analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: DominatorTreeAnalysis on test1_f
 ; CHECK: Invalidating analysis: LoopAnalysis on test1_f
 ; CHECK: Invalidating analysis: BranchProbabilityAnalysis on test1_f
 ; CHECK: Invalidating analysis: BlockFrequencyAnalysis on test1_f
+; CHECK: Running analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: LoopAnalysis on test1_g
 ; CHECK: Invalidating analysis: BranchProbabilityAnalysis on test1_g
@@ -34,7 +34,6 @@
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-NOT: Invalidating analysis:
 ; CHECK: Running pass: DominatorTreeVerifierPass on test1_f
-; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on test1_f
 
 ; An external function used to control branches.
 declare i1 @flag()
Index: llvm/test/Transforms/Inline/analysis-invalidation.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/analysis-invalidation.ll
@@ -0,0 +1,17 @@
+; RUN: opt -passes=inliner-wrapper < %s -disable-output -debug-pass-manager 2>&1 | FileCheck %s
+
+; We shouldn't invalidate any function analyses on g since it's never modified.
+
+; CHECK-NOT: Invalidating{{.*}} on g
+; CHECK: Invalidating{{.*}} on f
+; CHECK-NOT: Invalidating{{.*}} on g
+
+define void @f() {
+  call void @g()
+  ret void
+}
+
+define void @g() alwaysinline {
+  call void @f()
+  ret void
+}
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -951,6 +951,10 @@
   UR.InlinedInternalEdges.insert({&N, OldC});
 }
 InlinedCallees.clear();
+
+// Invalidate analyses for this function now so that we don't have to
+// invalidate analyses for all functions in this SCC later.
+FAM.invalidate(F, PreservedAnalyses::none());
   }
 
   // Now that we've finished inlining all of the calls across this SCC, delete
@@ -990,10 +994,12 @@
   if (!Changed)
 return PreservedAnalyses::all();
 
+  PreservedAnalyses PA;
   // Even if we change the IR, we update the core CGSCC data structures and so
   // can preserve the proxy to the function analysis manager.
-  PreservedAnalyses PA;
   PA.preserve();
+  // We have already invalidated all analyses on modified functions.
+  PA.preserveSet>();
   return PA;
 }
 
Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -240,7 +240,8 @@
 
 /// Deduce readonly/readnone attributes for the SCC.
 template 
-static bool addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter) {
+static void addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
+ SmallSetVector &Changed) {
   // Check if any of the functions in the SCC read or write memory.  If they
   // write memory then they can't be marked readnone or readonly.
   bool ReadsMemory = false;
@@ -255,7 +256,7 @@
 switch (checkFunctionMemoryAccess(*F, F->hasExactDefinition(),
   AAR, SCCNodes)) {
 case MAK_MayWrite:
-  return false;
+  return;
 case MAK_ReadOnly:
   ReadsMemory = true;
   break;
@@ -271,11 +272,10 @@
   // If the SCC contains both functions that read and functions that write, then
   // we cannot add readonly attributes.
   if (ReadsMemory && WritesMemory)
-return false;
+return;
 
   // Success!  Functions in this SCC do not access memory, or only read memory.
 

[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

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



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1626
 } else {
-  auto Remnant =
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Diagnose &&
-  (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > 
MaxCodeObjVer))
-D.Diag(diag::err_drv_invalid_int_value)
-<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
 }

yaxunl wrote:
> JonChesterfield wrote:
> > getAsInteger writes to CodeObjVer.
> can we return Optional and return None if there is a remnant? Then 
> we can call this function in checkAMDGPUCodeObjectVersion
We could. It would spawn handling of the Optional<> at all the call sites 
though. I'll see if I can pull the search logic into a local helper.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


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

2021-04-22 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 339778.
mbenfield added a comment.

Fix test warning-wall.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/X86/x86_32-xsave.c
  clang/test/CodeGen/X86/x86_64-xsave.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-riscv.c
  clang/test/FixIt/fixit.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/shift.c
  clang/test/Sema/vector-gcc-compat.c
  clang/test/Sema/warn-unused-but-set-parameters.c
  clang/test/Sema/warn-unused-but-set-variables.c
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/shift.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
  clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
  clang/test/SemaObjC/foreach.m

Index: clang/test/SemaObjC/foreach.m
===
--- clang/test/SemaObjC/foreach.m
+++ clang/test/SemaObjC/foreach.m
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 -Wall -fsyntax-only -verify -std=c89 -pedantic %s
+/* RUN: %clang_cc1 -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -fsyntax-only -verify -std=c89 -pedantic %s
  */
 
 @class NSArray;
Index: clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
+
+struct S {
+  int i;
+};
+
+int f0() {
+  int y; // expected-warning{{variable 'y' set but not used}}
+  y = 0;
+
+  int z __attribute__((unused));
+  z = 0;
+
+  // In C++, don't warn for structs. (following gcc's behavior)
+  struct S s;
+  struct S t;
+  s = t;
+
+  int x;
+  x = 0;
+  return x + 5;
+}
+
+void f1(void) {
+  (void)^() {
+int y; // expected-warning{{variable 'y' set but not used}}
+y = 0;
+
+int x;
+x = 0;
+return x;
+  };
+}
+
+void f2() {
+  // Don't warn for either of these cases.
+  constexpr int x = 2;
+  const int y = 1;
+  char a[x];
+  char b[y];
+}
Index: clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-parameter -verify %s
+
+int f0(int x,
+   int y, // expected-warning{{parameter 'y' set but not used}}
+   int z __attribute__((unused))) {
+  y = 0;
+  return x;
+}
+
+void f1(void) {
+  (void)^(int x,
+  int y, // expected-warning{{parameter 'y' set but not used}}
+  int z __attribute__((unused))) {
+y = 0;
+return x;
+  };
+}
+
+struct S {
+  int i;
+};
+
+// In C++, don't warn for a struct (following gcc).
+void f3(struct S s) {
+  struct S t;
+  s = t;
+}
+
+// Make sure this doesn't warn.
+struct A {
+  int i;
+  A(int j) : i(j) {}
+};
Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
 
 namespace std {
 struct type_info;
Index: clang/test/SemaCXX/shift.cpp
==

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

2021-04-22 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield marked 4 inline comments as done.
mbenfield added a comment.

In D100581#2705780 , @xbolva00 wrote:

> Meanwhile I collected some interesting testcases from gcc bugzilla (reported 
> as false positives), please try:
> https://godbolt.org/z/747ndKEvd - No "unused-but-set" warnings expected.

FWIW, neither of these "unused-but-set" warnings were triggered on any of that 
code (although some other warnings were).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[clang] d5f433d - Revert "Re-land "[Driver] Support default libc++ library location on Darwin""

2021-04-22 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-04-22T14:04:24-07:00
New Revision: d5f433d3302eedd455889d581d8312715289b582

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

LOG: Revert "Re-land "[Driver] Support default libc++ library location on 
Darwin""

This reverts commit 6331680ad2ad000fdaf7e72f3c1880c7908ffa25 because
this breaks the compiler-rt build.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 06d4f2f4df0b..bc59b6beafc7 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -615,8 +615,6 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
-  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
-
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
   // Build the input file for -filelist (list of linker input files) in case we
   // need it later
@@ -804,7 +802,6 @@ MachO::MachO(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
-  getFilePaths().push_back(getDriver().Dir + "/../lib");
 }
 
 /// Darwin - Darwin tool chain for i386 and x86_64.

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 9fe68f1821c9..15e5d100afcb 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -365,7 +365,3 @@
 // RUN: FileCheck -check-prefix=MNO_OUTLINE %s < %t.log
 // MNO_OUTLINE: {{ld(.exe)?"}}
 // MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never"
-
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=INSTALL-DIR %s < %t.log
-// INSTALL-DIR: "-L{{.*}}{{/|}}..{{/|}}lib"



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


[PATCH] D101017: [NewPM] Make GlobalsAA available earlier in the pipeline

2021-04-22 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@aeubanks It seems like this has non-trivial impact on code size 
(http://llvm-compile-time-tracker.com/compare.php?from=a62cbd9a0211d08bace8794b435996890feb44d4&to=7805d7f72c337bfcc2fbc2dc9d2b9ac23474d5d9&stat=size-text),
 so probably the compile-time change is a side-effect of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101017

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


[PATCH] D101108: [PR49761] Fix variadic arg handling in matcher

2021-04-22 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx created this revision.
chrish_ericsson_atx requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Mishandling of variadic arguments in a function call caused a crash
(runtime assert fail) in bugprone-infinite-loop tidy checker.  Fix
is to limit argument matching to the lesser of the number of variadic
params in the prototype or the number of actual args in the call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101108

Files:
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4757,8 +4757,12 @@
 
   int ParamIndex = 0;
   bool Matched = false;
+  unsigned numArgs = Node.getNumArgs();
+  if (FProto && FProto->isVariadic() && FProto->getNumParams() < numArgs) {
+numArgs = FProto->getNumParams();
+  }
 
-  for (; ArgIndex < Node.getNumArgs(); ++ArgIndex, ++ParamIndex) {
+  for (; ArgIndex < numArgs; ++ArgIndex, ++ParamIndex) {
 BoundNodesTreeBuilder ArgMatches(*Builder);
 if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), 
Finder,
&ArgMatches)) {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -386,3 +386,18 @@
   do {
   } while (false && CondVar);
 }
+
+struct logger {
+  void (*debug)(struct logger *, const char *, ...);
+};
+
+int foo(void) {
+  struct logger *pl = 0;
+  int iterator = 0;
+  while (iterator < 10) {
+char *l_tmp_msg = 0;
+pl->debug(pl, "%d: %s\n", iterator, l_tmp_msg);
+iterator++;
+  }
+  return 0;
+}


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4757,8 +4757,12 @@
 
   int ParamIndex = 0;
   bool Matched = false;
+  unsigned numArgs = Node.getNumArgs();
+  if (FProto && FProto->isVariadic() && FProto->getNumParams() < numArgs) {
+numArgs = FProto->getNumParams();
+  }
 
-  for (; ArgIndex < Node.getNumArgs(); ++ArgIndex, ++ParamIndex) {
+  for (; ArgIndex < numArgs; ++ArgIndex, ++ParamIndex) {
 BoundNodesTreeBuilder ArgMatches(*Builder);
 if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder,
&ArgMatches)) {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -386,3 +386,18 @@
   do {
   } while (false && CondVar);
 }
+
+struct logger {
+  void (*debug)(struct logger *, const char *, ...);
+};
+
+int foo(void) {
+  struct logger *pl = 0;
+  int iterator = 0;
+  while (iterator < 10) {
+char *l_tmp_msg = 0;
+pl->debug(pl, "%d: %s\n", iterator, l_tmp_msg);
+iterator++;
+  }
+  return 0;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101106: [HIP] Fix overloaded function for _Float16

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

Specializes `__hip::is_arithmetic<_Float16>` so that
overloaded functions with `_Float16` arguments resolve
properly in a similar way as standard C++ header.


https://reviews.llvm.org/D101106

Files:
  clang/lib/Headers/__clang_hip_cmath.h
  clang/test/Headers/hip-header.hip


Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -25,12 +25,11 @@
   int x = __hip::__numeric_type::value;
 }
 
-// ToDo: Fix __clang_hip_cmake.h to specialize __hip::is_arithmetic<_Float16>
-// to resolve fma(_Float16, _Float16, int) to fma(double, double, double)
+// Check fma(_Float16, _Float16, int) is resolved to fma(double, double, 
double)
 // instead of fma(_Float16, _Float16, _Float16).
 
 // CXX14-LABEL: define{{.*}}@_Z8test_fma
-// CXX14: call {{.*}}@__ocml_fma_f16
+// CXX14: call {{.*}}@__ocml_fma_f64
 __device__ double test_fma(_Float16 h, int i) {
   return fma(h, h, i);
 }
Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -258,7 +258,6 @@
   enum { value = 1 };
 };
 
-// ToDo: specializes is_arithmetic<_Float16>
 template  struct is_arithmetic {
   enum { value = 0 };
 };
@@ -307,6 +306,9 @@
 template <> struct is_arithmetic {
   enum { value = 1 };
 };
+template <> struct is_arithmetic<_Float16> {
+  enum { value = 1 };
+};
 
 struct true_type {
   static const __constant__ bool value = true;


Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -25,12 +25,11 @@
   int x = __hip::__numeric_type::value;
 }
 
-// ToDo: Fix __clang_hip_cmake.h to specialize __hip::is_arithmetic<_Float16>
-// to resolve fma(_Float16, _Float16, int) to fma(double, double, double)
+// Check fma(_Float16, _Float16, int) is resolved to fma(double, double, double)
 // instead of fma(_Float16, _Float16, _Float16).
 
 // CXX14-LABEL: define{{.*}}@_Z8test_fma
-// CXX14: call {{.*}}@__ocml_fma_f16
+// CXX14: call {{.*}}@__ocml_fma_f64
 __device__ double test_fma(_Float16 h, int i) {
   return fma(h, h, i);
 }
Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -258,7 +258,6 @@
   enum { value = 1 };
 };
 
-// ToDo: specializes is_arithmetic<_Float16>
 template  struct is_arithmetic {
   enum { value = 0 };
 };
@@ -307,6 +306,9 @@
 template <> struct is_arithmetic {
   enum { value = 1 };
 };
+template <> struct is_arithmetic<_Float16> {
+  enum { value = 1 };
+};
 
 struct true_type {
   static const __constant__ bool value = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 339773.
yaxunl added a comment.

make it NFC for non-hipRTC


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

https://reviews.llvm.org/D100794

Files:
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Headers/hip-header.hip

Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -10,18 +10,54 @@
 // RUN:   -internal-isystem %S/Inputs/include \
 // RUN:   -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown \
 // RUN:   -target-cpu gfx906 -emit-llvm %s -fcuda-is-device -o - \
-// RUN:   -D__HIPCC_RTC__ -std=c++14 | FileCheck %s
-
+// RUN:   -D__HIPCC_RTC__ -std=c++14 | FileCheck -check-prefixes=CHECK,CXX14 %s
 
 // expected-no-diagnostics
 
+struct Number {
+  __device__ Number(float _x) : x(_x) {}
+  float x;
+};
+
+#if __cplusplus >= 201103L
+// Check __hip::__numeric_type can be used with a class without default ctor.
+__device__ void test_numeric_type() {
+  int x = __hip::__numeric_type::value;
+}
+
+// ToDo: Fix __clang_hip_cmake.h to specialize __hip::is_arithmetic<_Float16>
+// to resolve fma(_Float16, _Float16, int) to fma(double, double, double)
+// instead of fma(_Float16, _Float16, _Float16).
+
+// CXX14-LABEL: define{{.*}}@_Z8test_fma
+// CXX14: call {{.*}}@__ocml_fma_f16
+__device__ double test_fma(_Float16 h, int i) {
+  return fma(h, h, i);
+}
+
+#endif
+
 // CHECK-LABEL: amdgpu_kernel void @_Z4kernPff
 __global__ void kern(float *x, float y) {
   *x = sin(y);
 }
 
 // CHECK-LABEL: define{{.*}} i64 @_Z11test_size_tv
-// CHEC: ret i64 8
+// CHECK: ret i64 8
 __device__ size_t test_size_t() {
   return sizeof(size_t);
 }
+
+// Check there is no ambiguity when calling overloaded math functions.
+
+// CHECK-LABEL: define{{.*}}@_Z10test_floorv
+// CHECK: call {{.*}}double @__ocml_floor_f64(double
+__device__ float test_floor() {
+  return floor(5);
+}
+
+// CHECK-LABEL: define{{.*}}@_Z8test_maxv
+// CHECK: call {{.*}}double @__ocml_fmax_f64(double {{.*}}, double
+__device__ float test_max() {
+  return max(5, 6.0);
+}
Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -72,12 +72,13 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !defined(__HIPCC_RTC__)
 #if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
+#if defined(__HIPCC_RTC__)
+#include <__clang_hip_cmath.h>
+#else
 #include <__clang_cuda_math_forward_declares.h>
 #include <__clang_hip_cmath.h>
 #include <__clang_cuda_complex_builtins.h>
-
 #include 
 #include 
 #include 
Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -22,7 +22,7 @@
 #endif
 #include 
 #include 
-#endif // __HIPCC_RTC__
+#endif // !defined(__HIPCC_RTC__)
 
 #pragma push_macro("__DEVICE__")
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -36,6 +36,9 @@
 __DEVICE__ float fma(float __x, float __y, float __z) {
   return ::fmaf(__x, __y, __z);
 }
+#if !defined(__HIPCC_RTC__)
+// The value returned by fpclassify is platform dependent, therefore it is not
+// supported by hipRTC.
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -44,6 +47,8 @@
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
+#endif // !defined(__HIPCC_RTC__)
+
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
@@ -209,11 +214,117 @@
 
 template  struct __hip_enable_if { typedef __T type; };
 
+namespace __hip {
+template  struct is_integral {
+  enum { value = 0 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+template <> struct is_integral {
+  enum { value = 1 };
+};
+
+// ToDo: specializes is_arithmetic<_Float16>
+template  struct is_arithmetic {
+  enum { value = 0

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-22 Thread Luis Penagos via Phabricator via cfe-commits
penagos added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:125
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;

krasimir wrote:
> penagos wrote:
> > MyDeveloperDay wrote:
> > > I don't really understand what we are saying here? 
> > Effectively we are checking that, barring intervening whitespace, we are 
> > analyzing 2 consecutive '>' tokens. If so, we treat such sequence as a 
> > binary op in lieu of a closing template angle bracket. If there's another 
> > more straightforward way of accomplishing this check, I'm open to that, but 
> > this seemed to be the most straightforward way at the time.
> I'm worried that this may regress template code. How does this account for 
> cases where two consecutive `>`-s are really two closing template brackets, 
> e.g.,
> `std::vector> v;`?
> 
> In particular, one added test case is ambiguous: `>>` could really be two 
> closing template brackets:
> https://godbolt.org/z/v19hj9vKn
> 
> I have to say that my general feeling about trying to disambiguate between 
> bitshifts and template closers is: don't try too hard inside clang-format as 
> the heuristics are generally quite brittle and make the code harder to 
> maintain; in cases where clang-format wrongly detects bitshift as templates, 
> users should add parens around the bitshift, which IMO improves readability.
As this patch currently stands, it does not disambiguate between bitshift '>>' 
operators and 2 closing template brackets, so in your snippet, we would no 
longer insert a space between the '>' characters (despite arguably being the 
better formatting decision in this case).

I agree with your feeling that user guided disambiguation between bitshift 
operators and template closing brackets via parens is the ideal solution and 
also improves readability, but IMO the approach taken by clang-format to format 
the '>' token should be conservative in that any change made should be 
non-semantic altering, which is not presently the case. While the case you 
mentioned would regress, we would no longer potentially alter program 
semantics. Thinking about this more, would it make sense to modify the actual 
white-space change generation later on in the analysis to not break up >> 
sequences of characters in lieu of annotating the tokens differently as the 
proposed patch is currently doing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

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


[PATCH] D101017: [NewPM] Make GlobalsAA available earlier in the pipeline

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

this seems to have some compile time improvements?
http://llvm-compile-time-tracker.com/compare.php?from=a62cbd9a0211d08bace8794b435996890feb44d4&to=7805d7f72c337bfcc2fbc2dc9d2b9ac23474d5d9&stat=instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101017

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


[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1592-1598
+  if (auto *CodeObjArg =
+  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+  options::OPT_mno_code_object_v3_legacy,
+  options::OPT_mcode_object_version_EQ)) {
+
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {

can we just call getAMDGPUCodeObjectVersion here instead of duplicating the 
logic?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1626
 } else {
-  auto Remnant =
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Diagnose &&
-  (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > 
MaxCodeObjVer))
-D.Diag(diag::err_drv_invalid_int_value)
-<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
 }

JonChesterfield wrote:
> getAsInteger writes to CodeObjVer.
can we return Optional and return None if there is a remnant? Then we 
can call this function in checkAMDGPUCodeObjectVersion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

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


[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/docs/LangRef.rst:7019
+  function will get the ``uwtable`` function attribute.
+
 Objective-C Garbage Collection Module Flags Metadata

I'll add:

These metadata correspond to a few function attributes with significant code 
generation behaviors. Function attributes with just optimization purposes 
should not be listed because the performance impact of these synthesized 
functions is small.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

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


[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: llvm/lib/IR/Function.cpp:333
 
 Function *Function::createWithDefaultAttr(FunctionType *Ty,
   LinkageTypes Linkage,

nickdesaulniers wrote:
> we should call this from gcov too to solve 
> https://github.com/ClangBuiltLinux/linux/issues/955.
Exactly:) Planned to do it after this patch 
https://github.com/ClangBuiltLinux/linux/issues/1238#issuecomment-824517092



Comment at: llvm/lib/IR/Function.cpp:346
+  case 1:
+B.addAttribute("frame-pointer", "non-leaf");
+break;

vitalybuka wrote:
> Should these be added into Attribute:: ?
The function attribute "frame-pointer" is already used, with a string value. A 
regular attribute cannot have a string value so it was created as the string 
form...

The documentation is long overdue, though. I have added a bit documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

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


[PATCH] D101016: [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 339760.
MaskRay marked an inline comment as done.
MaskRay added a comment.
Herald added a subscriber: jdoerfert.

use enum.
add doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101016

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/asan-frame-pointer.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
  llvm/test/Instrumentation/AddressSanitizer/uwtable.ll

Index: llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
+++ llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
@@ -10,12 +10,15 @@
   ret i32 %tmp
 }
 
-!llvm.module.flags = !{!0}
+!llvm.module.flags = !{!0, !1}
 
 ;; Due to -fasynchronous-unwind-tables.
 !0 = !{i32 7, !"uwtable", i32 1}
 
+;; Due to -fno-omit-frame-pointer.
+!1 = !{i32 7, !"frame-pointer", i32 2}
+
 ;; Set the uwtable attribute on ctor/dtor.
 ; CHECK: define internal void @asan.module_ctor() #[[#ATTR:]]
 ; CHECK: define internal void @asan.module_dtor() #[[#ATTR]]
-; CHECK: attributes #[[#ATTR]] = { nounwind uwtable }
+; CHECK: attributes #[[#ATTR]] = { nounwind uwtable "frame-pointer"="all" }
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -676,6 +676,16 @@
 
 void Module::setUwtable() { addModuleFlag(ModFlagBehavior::Max, "uwtable", 1); }
 
+FramePointerKind Module::getFramePointer() const {
+  auto *Val = cast_or_null(getModuleFlag("frame-pointer"));
+  return static_cast(
+  Val ? cast(Val->getValue())->getZExtValue() : 0);
+}
+
+void Module::setFramePointer(FramePointerKind Kind) {
+  addModuleFlag(ModFlagBehavior::Max, "frame-pointer", static_cast(Kind));
+}
+
 void Module::setSDKVersion(const VersionTuple &V) {
   SmallVector Entries;
   Entries.push_back(V.getMajor());
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -335,8 +335,21 @@
   unsigned AddrSpace, const Twine &N,
   Module *M) {
   auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
+  AttrBuilder B;
   if (M->getUwtable())
-F->addAttribute(AttributeList::FunctionIndex, Attribute::UWTable);
+B.addAttribute(Attribute::UWTable);
+  switch (M->getFramePointer()) {
+  case FramePointerKind::None:
+// 0 ("none") is the default.
+break;
+  case FramePointerKind::NonLeaf:
+B.addAttribute("frame-pointer", "non-leaf");
+break;
+  case FramePointerKind::All:
+B.addAttribute("frame-pointer", "all");
+break;
+  }
+  F->addAttributes(AttributeList::FunctionIndex, B);
   return F;
 }
 
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -53,7 +53,7 @@
 CGOPT_EXP(CodeModel::Model, CodeModel)
 CGOPT(ExceptionHandling, ExceptionModel)
 CGOPT_EXP(CodeGenFileType, FileType)
-CGOPT(FramePointer::FP, FramePointerUsage)
+CGOPT(FramePointerKind, FramePointerUsage)
 CGOPT(bool, EnableUnsafeFPMath)
 CGOPT(bool, EnableNoInfsFPMath)
 CGOPT(bool, EnableNoNaNsFPMath)
@@ -183,16 +183,16 @@
  "Emit nothing, for performance testing")));
   CGBINDOPT(FileType);
 
-  static cl::opt FramePointerUsage(
+  static cl::opt FramePointerUsage(
   "frame-pointer",
   cl::desc("Specify frame pointer elimination optimization"),
-  cl::init(FramePointer::None),
+  cl::init(FramePointerKind::None),
   cl::values(
-  clEnumValN(FramePointer::All, "all",
+  clEnumValN(FramePointerKind::All, "all",
  "Disable frame pointer elimination"),
-  clEnumValN(FramePointer::NonLeaf, "non-leaf",
+  clEnumValN(FramePointerKind::NonLeaf, "non-leaf",
  "Disable frame pointer elimination for non-leaf frame"),
-  clEnumValN(FramePointer::None, "none",
+  clEnumValN(FramePointerKind::None, "none",
  "Enable frame pointer elimination")));
   CGBINDOPT(FramePointerUsage);
 
@@ -662,11 +662,11 @@
   }
   if (FramePointerUsageView->getNumOccurrences() > 0 &&
   !F.hasFnAttribute("frame-pointer")) {
-if (getFramePointerUsage() == FramePointer::All)
+if (getFramePointerUsage() == FramePointerKind::All)
   NewAttrs.addAttribute("frame-pointer", "all");
-else if (getFramePointerUsage() == FramePointer::NonLeaf)
+else if (getFramePoin

[PATCH] D100756: [llvm-rc] [4/4] Add a GNU windres-like frontend to llvm-rc

2021-04-22 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo marked an inline comment as done.
mstorsjo added a comment.

Any further comments on this one, or is tolerable in this form? I'd prefer to 
not move the unescaping to shared code for now (as the exact definition of what 
it should do is a bit open).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100756

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


[PATCH] D100794: [HIP] Support overloaded math functions for hipRTC

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Headers/__clang_hip_cmath.h:309
+};
+template <> struct is_arithmetic<_Float16> {
+  enum { value = 1 };

This changes the overloading behavior of math functions with _Float16 arguments 
since previously we use std::numeric_limits::is_specialized to determine 
whether a type is an arithmetic, which is not specialized for _Float16.

To make this patch NFC for non-hipRTC, I would like to split this part to 
another patch. This facilitates debugging if issues arise


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

https://reviews.llvm.org/D100794

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


[PATCH] D100388: [BROKEN][clang] Try to fix thunk function types

2021-04-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 339757.
lebedev.ri added a comment.

@rsmith i was able to make some forward progress here.
What do you think about this?

(I haven't updated all tests because i don't want to waste hours doing that if 
this is still wrong)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100388

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/ABI.h
  clang/include/clang/Basic/Thunk.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGen/available-externally-hidden.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
  clang/test/CodeGenCXX/thunk-returning-memptr.cpp
  clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
  clang/test/CodeGenCXX/thunk-wrong-this.cpp
  clang/test/CodeGenCXX/thunks.cpp

Index: clang/test/CodeGenCXX/thunks.cpp
===
--- clang/test/CodeGenCXX/thunks.cpp
+++ clang/test/CodeGenCXX/thunks.cpp
@@ -410,7 +410,7 @@
   // CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -32
   // CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -24
   // CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 8
-  // CHECK: ret %"struct.Test13::D"*
+  // CHECK: ret %"struct.Test13::B1"*
 
   // WIN64-LABEL: define weak_odr dso_local nonnull align 8 dereferenceable(8) %"struct.Test13::D"* @"?foo1@D@Test13@@$4PPPE@A@EAAAEAUB1@2@XZ"(
   //This adjustment.
Index: clang/test/CodeGenCXX/thunk-wrong-this.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunk-wrong-this.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+class Base1 {
+  virtual void Foo1();
+};
+
+class Base2 {
+  virtual void Foo2();
+};
+
+class alignas(16) Obj : public Base1, public Base2 {
+  void Foo1() override;
+  void Foo2() override;
+  ~Obj();
+};
+
+void Obj::Foo1() {}
+void Obj::Foo2() {}
+
+// CHECK: define dso_local void @_ZThn8_N3Obj4Foo2Ev(%class.Base2.2* nonnull dereferenceable(8) %this) #1 align 2 {
+// CHECK: tail call void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull dereferenceable(16) %3)
Index: clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+struct A {};
+struct alignas(32) B : virtual A {
+  char c[32];
+};
+struct Pad {
+  char c[7];
+};
+struct C : B, Pad, virtual A {};
+
+struct X {
+  virtual A &f();
+};
+struct U {
+  virtual ~U();
+};
+C c;
+struct Y : U, X {
+  virtual B &f() override { return c; }
+};
+
+Y y;
+
+// CHECK: define linkonce_odr nonnull align 1 dereferenceable(1) %struct.A.8* @_ZTchn8_v0_n24_N1Y1fEv(%struct.X.7* nonnull dereferenceable(8) %this.coerce) #1 comdat align 2 {
Index: clang/test/CodeGenCXX/thunk-returning-memptr.cpp
===
--- clang/test/CodeGenCXX/thunk-returning-memptr.cpp
+++ clang/test/CodeGenCXX/thunk-returning-memptr.cpp
@@ -23,5 +23,5 @@
 // Because of the tail call, the return value cannot be copied into a local
 // alloca. (PR39901)
 
-// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret({ i32, i32 }) align 4 %agg.result, %struct.C* {{[^,]*}} %this)
+// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret({ i32, i32 }) align 4 %agg.result, %struct.B* {{[^,]*}} %this.coerce)
 // CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret({ i32, i32 }) align 4 %agg.result
Index: clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
===
--- clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
+++ clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
@@ -29,5 +29,5 @@
 
 // Thunks should be marked as "linkonce ODR" not "weak".
 //
-// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
 // CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1C1fEv
+// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
Index: clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
@@ -9,7 +9,7 @@
 // VTable for C contains 2 sub-vtables (represented as 2 structs). The first contains the components for B and the second contains the components for C. The

[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D85802#2707677 , @jansvoboda11 
wrote:

> The fact that tests pass in assert builds without the argument generation 
> suggests the feature doesn't have sufficient test coverage. Currently, the 
> flag will be dropped during `CompilerInvocation` command-line round-trip and 
> won't have any effect.
>
> The test in `clang/test/Frontend/invalid-cxx-abi.cpp` tests only the driver 
> side and I don't think that's good enough. Can you please add a test that 
> actually hits `-cc1` and checks the flag has the desired behavior?
>
> More context: 
> https://lists.llvm.org/pipermail/cfe-dev/2021-February/067714.html

I added `cc1` invocations to the test and an extra one to assert that the flag 
is actually making it to codegen. I'm still unsure though how 
`GenerateLangArgs` should work though. Prior to this, I was still able to 
assert through both a driver and cc1 invocation that I get the desired behavior 
in a debug build with assertions enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


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

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

When find_package can find rocr, but it sets up include paths that don't work 
with it, I think that constitutes a broken rocr install. At least, one that is 
difficult to use from cmake.

The packages are meant to deal with that sort of thing which suggests the 
/usr/include one. If you don't have a symlink in /opt/rocm then the HINTS above 
shouldn't be finding either of those, which also suggests the /usr/include. Can 
I interest you in moving / deleting that copy of hsa, so see if it's a 
machine-local quirk?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 339753.
leonardchan marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cxx-abi-switch.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -0,0 +1,30 @@
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s
+// RUN: %clang -c -fc++-abi=arm %s
+// RUN: %clang -c -fc++-abi=ios %s
+// RUN: %clang -c -fc++-abi=aarch64 %s
+// RUN: %clang -c -fc++-abi=mips %s
+// RUN: %clang -c -fc++-abi=webassembly %s
+// RUN: %clang -c -fc++-abi=fuchsia %s
+// RUN: %clang -c -fc++-abi=xl %s
+// RUN: %clang -c -fc++-abi=microsoft %s
+// RUN: %clang_cc1 -fc++-abi=itanium %s
+// RUN: %clang_cc1 -fc++-abi=arm %s
+// RUN: %clang_cc1 -fc++-abi=ios %s
+// RUN: %clang_cc1 -fc++-abi=aarch64 %s
+// RUN: %clang_cc1 -fc++-abi=mips %s
+// RUN: %clang_cc1 -fc++-abi=webassembly %s
+// RUN: %clang_cc1 -fc++-abi=fuchsia %s
+// RUN: %clang_cc1 -fc++-abi=xl %s
+// RUN: %clang_cc1 -fc++-abi=microsoft %s
+
+// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// INVALID: error: Invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+
+// The flag is propgated from the driver to cc1.
+// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s -check-prefix=CC1-FLAG
+// CC1-FLAG: -fc++-abi=InvalidABI
Index: clang/test/CodeGenCXX/cxx-abi-switch.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx-abi-switch.cpp
@@ -0,0 +1,27 @@
+// Assert that the ABI switch uses the proper codegen. Fuchsia uses the
+// "return this" ABI on constructors and destructors by default, so we can just
+// check that ABI is used regardless of the target.
+//
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-linux-gnu -fc++-abi=fuchsia | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=aarch64-unknown-linux-gnu -fc++-abi=fuchsia | FileCheck %s
+
+class A {
+public:
+  virtual ~A();
+  int x_;
+};
+
+class B : public A {
+public:
+  B(int *i);
+  virtual ~B();
+  int *i_;
+};
+
+B::B(int *i) : i_(i) {}
+B::~B() {}
+
+// CHECK: define{{.*}} %class.B* @_ZN1BC2EPi(%class.B* {{[^,]*}} returned {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} %class.B* @_ZN1BC1EPi(%class.B* {{[^,]*}} returned {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} %class.B* @_ZN1BD2Ev(%class.B* {{[^,]*}} returned {{[^,]*}} %this)
+// CHECK: define{{.*}} %class.B* @_ZN1BD1Ev(%class.B* {{[^,]*}} returned {{[^,]*}} %this)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3506,6 +3506,10 @@
   if (Opts.getSignReturnAddressKey() ==
   LangOptions::SignReturnAddressKeyKind::BKey)
 GenerateArg(Args, OPT_msign_return_address_key_EQ, "b_key", SA);
+
+  if (Opts.CXXABI)
+GenerateArg(Args, OPT_fcxx_abi_EQ, TargetCXXABI::getSpelling(*Opts.CXXABI),
+SA);
 }
 
 bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -3989,6 +3993,15 @@
 }
   }
 
+  // The value can be empty, which indicates the system default should be used.
+  StringRef CXXABI = Args.getLastArgValue(OPT_fcxx_abi_EQ);
+  if (!CXXABI.empty()) {
+if (!TargetCXXABI::isABI(CXXABI))
+  Diags.Report(diag::err_invalid_cxx_abi) << CXXABI;
+else
+  Opts.CXXABI = TargetCXXABI::getKind(CXXABI);
+  }
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5307,6 +5307,9 @@
/*Default=*/false))
 Args.AddLastArg(CmdArgs, options::OPT_ffixed_point);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fcxx_abi_EQ))
+A->render(Args, CmdArgs);
+
   // Handle -{std, ansi, tr

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

2021-04-22 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D99949#2709785 , @JonChesterfield 
wrote:

> It's not obvious to me why any of those stages would get a different result 
> for the search for rocr. Do you do things with chroot/jails to ensure 
> isolation for some of them?

Technically? Yes. Practically? No. My setup just remounts a temporary /tmp 
during the build to garbage collect stuff the build puts in /tmp. And the 
second/third stages use the clang built/installed from the first stage but 
otherwise it's not different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


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

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

It's not obvious to me why any of those stages would get a different result for 
the search for rocr. Do you do things with chroot/jails to ensure isolation for 
some of them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D101097: [Sema] Don't set BlockDecl's DoesNotEscape bit If the block is being passed to a function taking a reference parameter

2021-04-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington.
ahatanak added a project: clang.
ahatanak requested review of this revision.

In the following example, the block passed to the function is marked as 
`noescape`, which is incorrect as the `noescape` attribute applies to the 
reference:

  typedef void (^BlockTy)();
   __block S6 b5;
  void noescapeFuncRefParam1(__attribute__((noescape)) BlockTy &&);
  noescapeFuncRefParam1(^{ (void)b5; });

This partially fixes PR50043.

rdar://77030453


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101097

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaObjCXX/noescape.mm


Index: clang/test/SemaObjCXX/noescape.mm
===
--- clang/test/SemaObjCXX/noescape.mm
+++ clang/test/SemaObjCXX/noescape.mm
@@ -131,7 +131,7 @@
 
 struct S6 {
   S6();
-  S6(const S6 &) = delete; // expected-note 3 {{'S6' has been explicitly 
marked deleted here}}
+  S6(const S6 &) = delete; // expected-note 5 {{'S6' has been explicitly 
marked deleted here}}
   int f;
 };
 
@@ -143,6 +143,8 @@
   __block S6 b1; // expected-error {{call to deleted constructor of 'S6'}}
   __block S6 b2; // expected-error {{call to deleted constructor of 'S6'}}
   __block S6 b3; // expected-error {{call to deleted constructor of 'S6'}}
+  __block S6 b4; // expected-error {{call to deleted constructor of 'S6'}}
+  __block S6 b5; // expected-error {{call to deleted constructor of 'S6'}}
 
   noescapeFunc0(a, ^{ (void)b0; });
   escapingFunc0(^{ (void)b1; });
@@ -151,4 +153,14 @@
   }
   noescapeFunc0(a, ^{ escapingFunc0(^{ (void)b2; }); });
   escapingFunc0(^{ noescapeFunc0(a, ^{ (void)b3; }); });
+
+  void noescapeFuncRefParam0(__attribute__((noescape)) const BlockTy &);
+  noescapeFuncRefParam0(^{
+(void)b4;
+  });
+
+  void noescapeFuncRefParam1(__attribute__((noescape)) BlockTy &&);
+  noescapeFuncRefParam1(^{
+(void)b5;
+  });
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5911,7 +5911,8 @@
(!Param || !Param->hasAttr()))
 CFAudited = true;
 
-  if (Proto->getExtParameterInfo(i).isNoEscape())
+  if (Proto->getExtParameterInfo(i).isNoEscape() &&
+  !ProtoArgType->isReferenceType())
 if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
   BE->getBlockDecl()->setDoesNotEscape();
 


Index: clang/test/SemaObjCXX/noescape.mm
===
--- clang/test/SemaObjCXX/noescape.mm
+++ clang/test/SemaObjCXX/noescape.mm
@@ -131,7 +131,7 @@
 
 struct S6 {
   S6();
-  S6(const S6 &) = delete; // expected-note 3 {{'S6' has been explicitly marked deleted here}}
+  S6(const S6 &) = delete; // expected-note 5 {{'S6' has been explicitly marked deleted here}}
   int f;
 };
 
@@ -143,6 +143,8 @@
   __block S6 b1; // expected-error {{call to deleted constructor of 'S6'}}
   __block S6 b2; // expected-error {{call to deleted constructor of 'S6'}}
   __block S6 b3; // expected-error {{call to deleted constructor of 'S6'}}
+  __block S6 b4; // expected-error {{call to deleted constructor of 'S6'}}
+  __block S6 b5; // expected-error {{call to deleted constructor of 'S6'}}
 
   noescapeFunc0(a, ^{ (void)b0; });
   escapingFunc0(^{ (void)b1; });
@@ -151,4 +153,14 @@
   }
   noescapeFunc0(a, ^{ escapingFunc0(^{ (void)b2; }); });
   escapingFunc0(^{ noescapeFunc0(a, ^{ (void)b3; }); });
+
+  void noescapeFuncRefParam0(__attribute__((noescape)) const BlockTy &);
+  noescapeFuncRefParam0(^{
+(void)b4;
+  });
+
+  void noescapeFuncRefParam1(__attribute__((noescape)) BlockTy &&);
+  noescapeFuncRefParam1(^{
+(void)b5;
+  });
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5911,7 +5911,8 @@
(!Param || !Param->hasAttr()))
 CFAudited = true;
 
-  if (Proto->getExtParameterInfo(i).isNoEscape())
+  if (Proto->getExtParameterInfo(i).isNoEscape() &&
+  !ProtoArgType->isReferenceType())
 if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
   BE->getBlockDecl()->setDoesNotEscape();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91054: [Clang][OpenMP] Frontend work for sections - D89671

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

In D91054#2708924 , @AMDChirag wrote:

> In D91054#2708873 , @jdoerfert wrote:
>
>> What is missing or not working in the IRBuilder impl that prevents us from 
>> turning it on by default?
>
> Per the `TODO` in this patch (`CGStmtOpenMP.cpp - 3775`), 
> `PrivatizationCallback` is not working right now.
> I can't think of anything else. The test cases are all working so there's 
> that.

OK, we really need to provide the PrivCB impl so we can start removing clang 
code. 
This is generally fine with me, @fghanim @Meinersbur any concerns?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91054

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


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

2021-04-22 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D99949#2709673 , @JonChesterfield 
wrote:

> That's interesting. The various permutations I have on disk are also all 
> path/include/hsa/hsa.h. The existing in tree use of hsa.h is the amdgpu 
> plugin, which uses `#include "hsa.h"` and `#include `, which seems 
> unlikely to be correct.
>
> I'm going to patch this on the fly to hsa/hsa.h as that looks very likely to 
> be the fix.
>
> edit: or not, the include path cmake summons on my local system is `-isystem 
> $HOME/llvm-install/include/hsa`, so hsa/hsa doesn't work.
>
> Tiresome. Will revert this for now.

Ya, I bet. I also find this interesting because this fails my "three stage" 
test at the third stage which is rare. My stages:

1. build and test llvm+clang (release without asserts) with the system compiler 
release
2. build and test llvm+clang (release with asserts) with the just build compiler
3. build and test llvm+clang (release without assert) with compiler built in 
stage one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


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

2021-04-22 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-04-22T19:39:37+01:00
New Revision: 24c1ed3b34f7602b955e52cd8a362f4e27eb5f20

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

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

This reverts commit 722d4d8e7585457d407d0639a4ae2610157e06a8.

Unclear where hsa.h should be included from, see report in D99949

Added: 


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

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



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

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

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 328753b21f8ea..dc9c9751c851d 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -12,16 +12,9 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
-#include 
-
-#define AMDGPU_ARCH_PROGRAM_NAME "amdgpu-arch"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -722,78 +715,6 @@ void AMDGPUToolChain::checkTargetID(
   }
 }
 
-llvm::Error
-AMDGPUToolChain::detectSystemGPUs(const ArgList &Args,
-  SmallVector &GPUArchs) const 
{
-  std::string Program;
-  if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
-Program = A->getValue();
-  else
-Program = GetProgramPath(AMDGPU_ARCH_PROGRAM_NAME);
-  llvm::SmallString<64> OutputFile;
-  llvm::sys::fs::createTemporaryFile("print-system-gpus", "" /* No Suffix */,
- OutputFile);
-  llvm::FileRemover OutputRemover(OutputFile.c_str());
-  llvm::Optional Redirects[] = {
-  {""},
-  StringRef(OutputFile),
-  {""},
-  };
-
-  std::string ErrorMessage;
-  if (int Result = llvm::sys::ExecuteAndWait(
-  Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
-  /*MemoryLimit*/ 0, &ErrorMessage)) {
-if (Result > 0) {
-  ErrorMessage = "Exited with error code " + std::to_string(Result);
-} else if (Result == -1) {
-  ErrorMessage = "Execute failed: " + ErrorMessage;
-} else {
-  ErrorMessage = "Crashed: " + ErrorMessage;
-}
-
-return llvm::createStringError(std:

[clang] d71ee39 - Add support of the next Ubuntu (Ubuntu 21.10 - Impish Idri)

2021-04-22 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2021-04-22T20:38:28+02:00
New Revision: d71ee3993fe7decab00c3083438e13f81bd49f02

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

LOG: Add support of the next Ubuntu (Ubuntu 21.10 - Impish Idri)

Added: 


Modified: 
clang/include/clang/Driver/Distro.h
clang/lib/Driver/Distro.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Distro.h 
b/clang/include/clang/Driver/Distro.h
index 0e98d00764c13..0d2a0939639ea 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -71,6 +71,7 @@ class Distro {
 UbuntuFocal,
 UbuntuGroovy,
 UbuntuHirsute,
+UbuntuImpish,
 UnknownDistro
   };
 
@@ -122,7 +123,7 @@ class Distro {
   }
 
   bool IsUbuntu() const {
-return DistroVal >= UbuntuHardy && DistroVal <= UbuntuHirsute;
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuImpish;
   }
 
   bool IsAlpineLinux() const { return DistroVal == AlpineLinux; }

diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 9fc790f17d6ce..c4cf4e48b5b8d 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -89,6 +89,7 @@ static Distro::DistroType 
DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
 .Case("focal", Distro::UbuntuFocal)
 .Case("groovy", Distro::UbuntuGroovy)
 .Case("hirsute", Distro::UbuntuHirsute)
+.Case("impish", Distro::UbuntuImpish)
 .Default(Distro::UnknownDistro);
   return Version;
 }



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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-04-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabf3ca61e323: [Diagnostics] Restore -Wdeprecated warning 
when user-declared copy assignment… (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
  clang/test/SemaCXX/deprecated-copy.cpp
  clang/test/SemaCXX/deprecated.cpp

Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -83,30 +83,31 @@
 #if __cplusplus >= 201103L
 namespace DeprecatedCopy {
   struct Assign {
-Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}}
+Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-provided copy assignment operator}}
   };
   Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Assign' first required here}}
 
   struct Ctor {
 Ctor();
-Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}}
+Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-provided copy constructor}}
   };
   Ctor b1, b2;
   void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Ctor' first required here}}
 
   struct Dtor {
 ~Dtor();
-// expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}}
-// expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}}
+// expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-provided destructor}}
+// expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-provided destructor}}
   };
   Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Dtor' first required here}}
   void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}}
 
   struct DefaultedDtor {
-~DefaultedDtor() = default;
-  };
-  DefaultedDtor d1, d2(d1);
-  void h() { d1 = d2; }
+~DefaultedDtor() = default; // expected-warning {{definition of implicit copy constructor for 'DefaultedDtor' is deprecated because it has a user-declared destructor}}
+  };// expected-warning@-1 {{definition of implicit copy assignment operator for 'DefaultedDtor' is deprecated because it has a user-declared destructor}}
+  DefaultedDtor d1;
+  DefaultedDtor d2(d1); // expected-note {{in implicit copy constructor for 'DeprecatedCopy::DefaultedDtor' first required here}}
+  void h() { d1 = d2; } // expected-note {{in implicit copy assignment operator for 'DeprecatedCopy::DefaultedDtor' first required here}}
 }
 #endif
 
Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -1,23 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
-// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR -verify
-// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
 
-#ifdef DEPRECATED_COPY_DTOR
 struct A {
-  int *ptr;
-  ~A() { delete ptr; } // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared destructor}}
+A& operator=(const A&) = default; // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared copy assignment operator}}
 };
 
-void foo() {
-  A a{};
-  A b = a; // expected-note {{implicit copy constructor for 'A' first required here}}
-}
-#else
 struct B {
-  B &operator=(const B &); // expected-warning {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}}
+B& operator=(const B&) = delete; // expected-warning {{definition of implici

[clang] abf3ca6 - [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-04-22 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2021-04-22T20:35:41+02:00
New Revision: abf3ca61e3235681f26d0f527b8e2763dd4c0c62

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

LOG: [Diagnostics] Restore -Wdeprecated warning when user-declared copy 
assignment operator is defined as deleted (PR45634)

Solves https://bugs.llvm.org/show_bug.cgi?id=45634
Be more agressive than GCC with -Wdeprecated-copy. Also provide 
-W(no-)deprecated-copy-user-provided-copy/dtor options to on/off this behaviour.

Reviewed By: Quuxplusone

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

Added: 
clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/deprecated-copy.cpp
clang/test/SemaCXX/deprecated.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index e202645d1f2b0..df2a46cecc5d0 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -162,8 +162,12 @@ def CXX11CompatDeprecatedWritableStr :
 def DeprecatedArrayCompare : DiagGroup<"deprecated-array-compare">;
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
-def DeprecatedCopy : DiagGroup<"deprecated-copy">;
-def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
+def DeprecatedCopyWithUserProvidedCopy : 
DiagGroup<"deprecated-copy-with-user-provided-copy">;
+def DeprecatedCopyWithUserProvidedDtor : 
DiagGroup<"deprecated-copy-with-user-provided-dtor">;
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyWithUserProvidedCopy]>;
+def DeprecatedCopyWithDtor : DiagGroup<"deprecated-copy-with-dtor", 
[DeprecatedCopyWithUserProvidedDtor]>;
+// For compatibility with GCC.
+def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -186,7 +190,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedAttributes,
   DeprecatedCommaSubscript,
   DeprecatedCopy,
-  DeprecatedCopyDtor,
+  DeprecatedCopyWithDtor,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedEnumCompare,

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index aeeed560b5145..3a58d3dc5c4a8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -567,15 +567,24 @@ def warn_access_decl_deprecated : Warning<
 def err_access_decl : Error<
   "ISO C++11 does not allow access declarations; "
   "use using declarations instead">;
-def warn_deprecated_copy_operation : Warning<
+def warn_deprecated_copy : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
   "for %0 is deprecated because it has a user-declared copy "
   "%select{assignment operator|constructor}1">,
   InGroup, DefaultIgnore;
-def warn_deprecated_copy_dtor_operation : Warning<
+def warn_deprecated_copy_with_dtor : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
   "for %0 is deprecated because it has a user-declared destructor">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
+def warn_deprecated_copy_with_user_provided_copy: Warning<
+  "definition of implicit copy %select{constructor|assignment operator}1 "
+  "for %0 is deprecated because it has a user-provided copy "
+  "%select{assignment operator|constructor}1">,
+  InGroup, DefaultIgnore;
+def warn_deprecated_copy_with_user_provided_dtor : Warning<
+  "definition of implicit copy %select{constructor|assignment operator}1 "
+  "for %0 is deprecated because it has a user-provided destructor">,
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/c

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

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

That's interesting. The various permutations I have on disk are also all 
path/include/hsa/hsa.h. The existing in tree use of hsa.h is the amdgpu plugin, 
which uses `#include "hsa.h"` and `#include `, which seems unlikely to 
be correct.

I'm going to patch this on the fly to hsa/hsa.h as that looks very likely to be 
the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D101000: Coverage: Document how to collect a profile without a filesystem

2021-04-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
dexonsmith marked an inline comment as done.
Closed by commit rGd4ee603c8f21: Coverage: Document how to collect a profile 
without a filesystem (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101000

Files:
  clang/docs/SourceBasedCodeCoverage.rst


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -346,6 +346,34 @@
 
 In C++ files, declare these as ``extern "C"``.
 
+Using the profiling runtime without a filesystem
+
+
+The profiling runtime also supports freestanding environments that lack a
+filesystem. The runtime ships as a static archive that's structured to make
+dependencies on a hosted environment optional, depending on what features
+the client application uses.
+
+The first step is to export ``__llvm_profile_runtime``, as above, to disable
+the default static initializers. Instead of calling the ``*_file()`` APIs
+described above, use the following to save the profile directly to a buffer
+under your control:
+
+* Forward-declare ``uint64_t __llvm_profile_get_size_for_buffer(void)`` and
+  call it to determine the size of the profile. You'll need to allocate a
+  buffer of this size.
+
+* Forward-declare ``int __llvm_profile_write_buffer(char *Buffer)`` and call it
+  to copy the current counters to ``Buffer``, which is expected to already be
+  allocated and big enough for the profile.
+
+* Optionally, forward-declare ``void __llvm_profile_reset_counters(void)`` and
+  call it to reset the counters before entering a specific section to be
+  profiled. This is only useful if there is some setup that should be excluded
+  from the profile.
+
+In C++ files, declare these as ``extern "C"``.
+
 Collecting coverage reports for the llvm project
 
 


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -346,6 +346,34 @@
 
 In C++ files, declare these as ``extern "C"``.
 
+Using the profiling runtime without a filesystem
+
+
+The profiling runtime also supports freestanding environments that lack a
+filesystem. The runtime ships as a static archive that's structured to make
+dependencies on a hosted environment optional, depending on what features
+the client application uses.
+
+The first step is to export ``__llvm_profile_runtime``, as above, to disable
+the default static initializers. Instead of calling the ``*_file()`` APIs
+described above, use the following to save the profile directly to a buffer
+under your control:
+
+* Forward-declare ``uint64_t __llvm_profile_get_size_for_buffer(void)`` and
+  call it to determine the size of the profile. You'll need to allocate a
+  buffer of this size.
+
+* Forward-declare ``int __llvm_profile_write_buffer(char *Buffer)`` and call it
+  to copy the current counters to ``Buffer``, which is expected to already be
+  allocated and big enough for the profile.
+
+* Optionally, forward-declare ``void __llvm_profile_reset_counters(void)`` and
+  call it to reset the counters before entering a specific section to be
+  profiled. This is only useful if there is some setup that should be excluded
+  from the profile.
+
+In C++ files, declare these as ``extern "C"``.
+
 Collecting coverage reports for the llvm project
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d4ee603 - Coverage: Document how to collect a profile without a filesystem

2021-04-22 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-04-22T11:29:39-07:00
New Revision: d4ee603c8f21b4ae722c2a34d4dfa54b7abeeb16

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

LOG: Coverage: Document how to collect a profile without a filesystem

The profiling runtime was designed to work without static initializers
or a a filesystem (see 117cf2bd1ff585f9754b5f30f5a4cfd65b230bbf and
others). The no-static-initializers part was already documented but this
part got missed before.

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

Added: 


Modified: 
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index a54bba94eb98..5f4bcf8e0ff0 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -346,6 +346,34 @@ without using static initializers, do this manually:
 
 In C++ files, declare these as ``extern "C"``.
 
+Using the profiling runtime without a filesystem
+
+
+The profiling runtime also supports freestanding environments that lack a
+filesystem. The runtime ships as a static archive that's structured to make
+dependencies on a hosted environment optional, depending on what features
+the client application uses.
+
+The first step is to export ``__llvm_profile_runtime``, as above, to disable
+the default static initializers. Instead of calling the ``*_file()`` APIs
+described above, use the following to save the profile directly to a buffer
+under your control:
+
+* Forward-declare ``uint64_t __llvm_profile_get_size_for_buffer(void)`` and
+  call it to determine the size of the profile. You'll need to allocate a
+  buffer of this size.
+
+* Forward-declare ``int __llvm_profile_write_buffer(char *Buffer)`` and call it
+  to copy the current counters to ``Buffer``, which is expected to already be
+  allocated and big enough for the profile.
+
+* Optionally, forward-declare ``void __llvm_profile_reset_counters(void)`` and
+  call it to reset the counters before entering a specific section to be
+  profiled. This is only useful if there is some setup that should be excluded
+  from the profile.
+
+In C++ files, declare these as ``extern "C"``.
+
 Collecting coverage reports for the llvm project
 
 



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


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-22 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

What matter isn't "convergent" in itself, it is how it restricts 
transformations: if you know that all the control flow is always uniform, are 
there still restriction on any transformation in presence of convergent 
instructions?

If not, then the "target approach" seems nice: as @foad and @sameerds noted we 
just need to have a guarantee on these targets about the uniformity of the 
branches, it does not require to change the convergent semantics on a target 
basis I think.


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

https://reviews.llvm.org/D69498

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


  1   2   3   >