[PATCH] D88491: [ASTContext] Use AllowCXX in all merge*Type methods, strip references

2020-10-05 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D88491#2306099 , @aaron.ballman 
wrote:

> Do you have test cases for this change? I didn't see any relevant ones in 
> D88384 .

In the revert (rG4fc69ab002382675d84f611f22599cb3cb4a0787 
) I noted 
a test broke. I went back and it is 
`clang/test/Headers/nvptx_device_math_complex.cpp` which is already in tree.
I'll try to gracefully accept but reject reference types next. That might work.




Comment at: clang/lib/AST/ASTContext.cpp:9174
 bool ASTContext::typesAreBlockPointerCompatible(QualType LHS, QualType RHS) {
   return !mergeTypes(LHS, RHS, true).isNull();
 }

aaron.ballman wrote:
> It seems possible to call `typesAreBlockPointerCompatible()` in C++ mode 
> (`ASTContext::areCommonBaseCompatible()` calls `sameObjCTypeArgs()` which 
> calls `canAssignObjCObjectTypes()` which calls 
> `ASTContext::typesAreBlockPointerCompatible()`. I'm not certain if the 
> assertion will actually trigger though, so tests would be appreciated.
> 
> Are there other cases where `mergeType()` can be transitively called in C++ 
> mode without having already stripped references?
`AllowCXX` is only used from OpenMP code and probably named badly. The idea is 
that we want to allow roughly matching declarations, so far that meant we don't 
want to be too strict on exception qualifiers.





Comment at: clang/lib/AST/ASTContext.cpp:9430-9433
+  if (const ReferenceType *lRT = LHS->getAs())
+LHS = lRT->getPointeeType();
+  if (const ReferenceType *rRT = RHS->getAs())
+RHS = rRT->getPointeeType();

aaron.ballman wrote:
> This will try to merge a `T&` and `T&&` based on `T` alone, is that expected 
> or should this be caring about lvalue vs rvalue reference types?
This is debatable. The standard is all but clear about this and it is not 100% 
clear to me what is reasonable. As noted in the general comment, we might be 
able to get all the functionality we need by gracefully handling this case and 
saying it is not mergable. I'll give that a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88491

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


[PATCH] D88138: [NPM] Add target specific hook to add passes for New Pass Manager

2020-10-05 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Thank you, Ankit!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88138

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


[PATCH] D88477: [analyzer] Overwrite cast type in getBinding only if that was null originally

2020-10-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> i'm pretty worried about our ability to actually achieve that in the near 
> future

This whole cast problem that you're looking into in D85528 
 is definitely a part of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88477

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


[PATCH] D85528: [analyzer] Fix cast evaluation on scoped enums in ExprEngine

2020-10-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

With Z3 //constraint// manager you absolutely want your constraints to be as 
precise as possible. The only reason we don't add these casts is because it 
confuses the constraint manager a lot. With a better constraint manager we 
would have spared ourselves a lot of suffering in this area.

With Z3 //refutation// manager - probably same but not sure, experimental data 
needed. Z3 occasionally refuting correct reports is not that big of a deal; the 
overall picture is still much better than without refutation due to sheer 
numbers of eliminated false positives. Improved cast modeling will also allow 
it to occasionally eliminate more false positives because it's now being fed 
correct formulas. However most of the decisions *during* the path are still 
made with RangeConstraintManager, which includes deciding whether to make a 
state split. RangeConstraintManager fails to solve constraints => double up the 
remaining analysis time. Exponentially with respect to the amount of 
constraints it couldn't solve. We'll have to weigh that performance cost 
against the improved quality.

> We might be able to do that by extending the Equivalence class of the 
> constraint map with the notion of casts of...

In my previous life i once did an experiment with RangeConstraintManager in 
which i added truncating cast symbols but not widening cast symbols. I believe 
it worked fairly well but i'm not sure, i was too young to properly assess the 
situation. So i believe something like this might actually work but there's 
still a high risk of failure (behaving overall worse than before) and it won't 
solve the entirety of the problem anyway (for instance, it won't help us solve 
https://bugs.llvm.org/show_bug.cgi?id=44114 by making our SVals type-correct so 
that extents didn't have to be stored separately - and that's currently one of 
the main sources of false positives we have).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85528

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


Buildbot numbers for the week of 09/20/2020 - 09/26/2020

2020-10-05 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/20/2020 - 09/26/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   |  was_red
-+--
 clang-sphinx-docs   | 124:15:45
 llvm-clang-x86_64-expensive-checks-debian   | 105:33:42
 llvm-clang-x86_64-expensive-checks-ubuntu   | 105:29:51
 clang-ppc64be-linux-multistage  | 43:30:49
 sanitizer-ppc64be-linux | 43:01:03
 clang-ppc64be-linux | 42:19:23
 clang-ppc64be-linux-lnt | 41:53:03
 sanitizer-ppc64le-linux | 35:34:26
 clang-ppc64le-linux-multistage  | 35:21:39
 clang-ppc64le-linux-lnt | 35:14:20
 clang-cmake-x86_64-avx2-linux   | 17:47:28
 clang-cmake-x86_64-sde-avx512-linux | 17:33:29
 clang-cmake-aarch64-full| 16:30:59
 llvm-clang-x86_64-expensive-checks-win  | 14:45:12
 clang-cmake-aarch64-lld | 14:36:40
 clang-ppc64le-linux | 14:14:15
 lldb-x86_64-debian  | 13:56:45
 clang-cmake-aarch64-quick   | 13:33:25
 lldb-arm-ubuntu | 13:22:29
 lldb-aarch64-ubuntu | 13:18:19
 lldb-x64-windows-ninja  | 13:11:29
 clang-cmake-aarch64-global-isel | 12:55:36
 sanitizer-x86_64-linux-fast | 12:41:08
 llvm-clang-win-x-armv7l | 12:05:49
 sanitizer-x86_64-linux-bootstrap-ubsan  | 11:57:22
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17  | 11:17:54
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 11:15:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11  | 11:14:43
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14  | 11:08:58
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11 | 11:08:40
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 11:07:04
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 11:07:00
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 11:01:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03  | 10:59:52
 llvm-clang-win-x-aarch64| 10:45:04
 clang-x64-windows-msvc  | 08:19:50
 clang-cmake-armv8-lld   | 06:59:44
 lld-x86_64-win  | 06:55:56
 fuchsia-x86_64-linux| 06:23:14
 clang-with-lto-ubuntu   | 05:15:49
 clang-with-thin-lto-ubuntu  | 05:03:01
 sanitizer-x86_64-linux-bootstrap| 04:43:27
 clang-s390x-linux-multistage| 04:16:54
 sanitizer-x86_64-linux  | 03:22:20
 aosp-O3-polly-before-vectorizer-unprofitable| 03:17:15
 ppc64le-lld-multistage-test | 03:13:34
 flang-aarch64-ubuntu| 03:13:09
 lld-x86_64-freebsd  | 02:59:56
 llvm-clang-x86_64-win-fast  | 02:56:30
 sanitizer-x86_64-linux-bootstrap-msan   | 02:54:59
 lld-perf-testsuite  | 02:46:56
 lld-x86_64-darwin   | 02:41:28
 clang-ppc64le-rhel  | 02:24:21
 llvm-avr-linux  | 02:18:21
 lld-x86_64-ubuntu-fast  | 02:15:35
 sanitizer-x86_64-linux-android  | 02:11:03
 clang-cmake-armv7-global-isel   | 02:07:50
 clang-cmake-armv7-quick | 02:05:38
 clang-s390x-linux-lnt   | 02:05:23
 llvm-sphinx-docs| 02:03:31
 mlir-nvidia | 02:03:22
 polly-x86_64-linux-test-suite   | 01:56:17
 

Buildbot numbers for the week of 09/13/2020 - 09/19/2020

2020-10-05 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/13/2020 - 09/19/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   | was_red
-+-
 ppc64le-lld-multistage-test | 82:03:54
 clang-with-lto-ubuntu   | 60:31:33
 lld-x86_64-darwin   | 60:30:44
 clang-with-thin-lto-ubuntu  | 57:42:47
 llvm-clang-x86_64-expensive-checks-ubuntu   | 57:06:41
 clang-s390x-linux-lnt   | 55:02:40
 lld-x86_64-win  | 53:15:05
 llvm-clang-x86_64-expensive-checks-win  | 52:47:17
 lld-perf-testsuite  | 48:59:59
 clang-x86_64-linux-abi-test | 48:54:27
 llvm-sphinx-docs| 46:32:42
 llvm-clang-win-x-aarch64| 39:54:36
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 24:18:22
 sanitizer-x86_64-linux-fuzzer   | 22:37:35
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11  | 21:50:45
 clang-native-arm-lnt-perf   | 19:36:29
 aosp-O3-polly-before-vectorizer-unprofitable| 19:21:24
 lld-x86_64-freebsd  | 19:15:49
 llvm-clang-win-x-armv7l | 18:33:30
 clang-x64-windows-msvc  | 15:25:00
 sanitizer-x86_64-linux  | 13:14:10
 sanitizer-x86_64-linux-autoconf | 13:07:55
 llvm-avr-linux  | 13:01:33
 clang-cmake-aarch64-lld | 12:28:41
 sanitizer-windows   | 07:41:33
 clang-s390x-linux-multistage| 07:27:51
 lldb-x86_64-debian  | 07:10:32
 clang-cmake-aarch64-global-isel | 07:06:34
 clang-ppc64le-linux | 06:51:00
 lldb-arm-ubuntu | 06:45:42
 clang-cmake-aarch64-quick   | 06:45:03
 lldb-x64-windows-ninja  | 06:43:36
 lldb-aarch64-ubuntu | 06:41:37
 fuchsia-x86_64-linux| 06:40:21
 clang-s390x-linux   | 06:21:40
 clang-cmake-aarch64-full| 06:09:39
 libcxx-libcxxabi-libunwind-aarch64-linux| 05:30:21
 libcxx-libcxxabi-libunwind-armv8-linux  | 05:22:13
 ppc64le-mlir-rhel-clang | 05:01:37
 sanitizer-ppc64be-linux | 04:34:08
 sanitizer-x86_64-linux-fast | 04:17:11
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 04:16:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 04:09:28
 clang-ppc64le-rhel  | 04:06:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 04:01:42
 lld-x86_64-ubuntu-fast  | 03:55:04
 clang-ppc64le-linux-multistage  | 03:49:18
 clang-cmake-armv8-lld   | 03:47:55
 sanitizer-x86_64-linux-bootstrap| 03:40:40
 polly-x86_64-linux  | 03:25:45
 sanitizer-x86_64-linux-bootstrap-msan   | 03:23:50
 sanitizer-x86_64-linux-bootstrap-ubsan  | 03:13:02
 clang-ppc64be-linux-multistage  | 03:10:43
 llvm-clang-x86_64-expensive-checks-debian   | 03:00:04
 clang-x86_64-debian-new-pass-manager-fast   | 02:54:21
 clang-ppc64le-linux-lnt | 02:50:01
 clang-x86_64-debian-fast| 02:45:46
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 02:43:57
 clang-cmake-armv7-lnt   | 02:36:19
 polly-x86_64-linux-test-suite   | 02:34:38
 flang-aarch64-ubuntu| 02:33:55
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 02:28:46
 

Buildbot numbers for the week of 09/27/2020 - 10/03/2020

2020-10-05 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 09/27/2020 -
10/03/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   |  was_red
-+--
 clang-x64-windows-msvc  | 109:55:08
 clang-ppc64le-rhel  | 94:15:16
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11 | 76:58:22
 sanitizer-x86_64-linux  | 70:38:24
 clang-cmake-aarch64-lld | 60:12:19
 clang-cmake-aarch64-full| 59:32:56
 clang-ppc64le-linux | 58:54:05
 clang-cmake-aarch64-global-isel | 56:45:56
 clang-cmake-aarch64-quick   | 56:06:05
 lldb-x86_64-debian  | 53:36:26
 sanitizer-x86_64-linux-bootstrap| 25:41:38
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11  | 20:41:34
 sanitizer-x86_64-linux-fast | 17:47:55
 clang-s390x-linux-multistage| 15:48:46
 clang-s390x-linux-lnt   | 12:37:42
 clang-sphinx-docs   | 12:20:25
 clang-ppc64be-linux-multistage  | 10:35:38
 clang-s390x-linux   | 10:28:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 10:27:20
 sanitizer-ppc64be-linux | 10:19:43
 clang-ppc64be-linux-lnt | 09:47:16
 lldb-x64-windows-ninja  | 09:32:47
 clang-cmake-armv8-lld   | 09:23:57
 clang-ppc64be-linux | 09:22:57
 aosp-O3-polly-before-vectorizer-unprofitable| 09:22:14
 sanitizer-x86_64-linux-bootstrap-ubsan  | 08:51:45
 sanitizer-x86_64-linux-bootstrap-msan   | 08:46:44
 sanitizer-ppc64le-linux | 08:39:28
 clang-ppc64le-linux-multistage  | 08:38:27
 sanitizer-x86_64-linux-autoconf | 08:37:51
 llvm-avr-linux  | 08:35:54
 sanitizer-windows   | 08:20:07
 sanitizer-x86_64-linux-android  | 08:15:19
 clang-with-lto-ubuntu   | 07:03:20
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 06:57:05
 lldb-aarch64-ubuntu | 05:59:27
 clang-with-thin-lto-ubuntu  | 03:56:21
 sanitizer-x86_64-linux-fuzzer   | 03:18:14
 lld-x86_64-win  | 03:04:03
 clang-cmake-x86_64-avx2-linux   | 02:57:58
 fuchsia-x86_64-linux| 02:39:46
 clang-cmake-armv7-quick | 02:38:38
 llvm-clang-win-x-aarch64| 02:35:32
 clang-ppc64le-linux-lnt | 02:34:53
 clang-cmake-x86_64-sde-avx512-linux | 02:33:37
 clang-x86_64-debian-new-pass-manager-fast   | 02:27:43
 clang-x86_64-debian-fast| 02:26:51
 ppc64le-lld-multistage-test | 02:24:12
 flang-aarch64-ubuntu| 02:07:17
 clang-cmake-armv7-global-isel   | 02:05:12
 clang-x86_64-linux-abi-test | 01:57:57
 flang-aarch64-ubuntu-gcc10  | 01:56:14
 llvm-clang-win-x-armv7l | 01:45:47
 lldb-arm-ubuntu | 01:33:26
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 01:32:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 01:30:16
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17  | 01:29:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 01:29:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 01:27:21
 openmp-clang-x86_64-linux-debian| 01:21:13
 clang-cmake-armv7-lnt   | 01:10:18
 publish-sphinx-docs | 01:00:51
 openmp-gcc-x86_64-linux-debian  | 00:55:53
 lld-x86_64-ubuntu-fast  | 00:53:09
 mlir-nvidia | 00:42:20
 libc-x86_64-debian-dbg  | 00:36:00
 lld-x86_64-darwin   | 00:35:34
 lld-x86_64-freebsd  | 00:32:55
 llvm-clang-x86_64-expensive-checks-ubuntu   | 00:23:25
(69 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status 

[PATCH] D87962: [clang] Change the multi-character character constants from extension to implementation-defined.

2020-10-05 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous added a comment.

In D87962#2312617 , @aaron.ballman 
wrote:

> LGTM! Do you need someone to commit on your behalf?

Yes I need!


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

https://reviews.llvm.org/D87962

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


[PATCH] D88275: [ASTMatchers] Add matcher `hasParentIgnoringImplicit`.

2020-10-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D88275#2305989 , @aaron.ballman 
wrote:

> In D88275#2303283 , @ymandel wrote:
>
>>> I'm not concerned about the basic idea behind the proposed matcher, I'm 
>>> only worried we're making AST matching more confusing by having two 
>>> different ways of inconsistently accomplishing the same-ish thing.
>>
>> Aaron, I appreciate this concern, but I would argue that this matcher isn't 
>> making things any worse. We already have the various `ignoringImplicit` 
>> matchers, and this new one simply parallels those, but for parents. So, it 
>> is in some sense "completing" an existing API, which together is an 
>> alternative to  `traverse`.
>
> I'm not certain I agree with that reasoning because you can extend it to 
> literally any match that may interact with implicit nodes, which is the whole 
> point to the spelled in source traversal mode. I'm not certain it's a good 
> design for us to continue to add one-off ways to ignore implicit nodes.

I appreciate your point, but I'm personally inclined to allow progress while we 
figure these larger issues out.  That said, I'm in no rush and would like a 
solution that we're both happy with. How do you propose we proceed, especially 
given that `traverse` does not currently support this case? It seems that 
progress is in part blocked on hearing back from steveire, but it's been over a 
week since you added him to the review thread. Is there some other way to ping 
him?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88275

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


[clang] ded79be - [c++17] Implement P0145R3 during constant evaluation.

2020-10-05 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-05T19:04:14-07:00
New Revision: ded79be63555f4e5bfdb0db27ef22b71fe568474

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

LOG: [c++17] Implement P0145R3 during constant evaluation.

Ensure that we evaluate assignment and compound-assignment
right-to-left, and array subscripting left-to-right.

Fixes PR47724.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constant-expression-cxx1z.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 4460e3a17e6d..49ad01f27545 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1856,8 +1856,12 @@ void CallStackFrame::describe(raw_ostream ) {
   Out << ", ";
 
 const ParmVarDecl *Param = *I;
-const APValue  = Arguments[ArgIndex];
-Arg.printPretty(Out, Info.Ctx, Param->getType());
+if (Arguments) {
+  const APValue  = Arguments[ArgIndex];
+  Arg.printPretty(Out, Info.Ctx, Param->getType());
+} else {
+  Out << "<...>";
+}
 
 if (ArgIndex == 0 && IsMemberCall)
   Out << "->" << *Callee << '(';
@@ -5792,6 +5796,8 @@ typedef SmallVector ArgVector;
 /// EvaluateArgs - Evaluate the arguments to a function call.
 static bool EvaluateArgs(ArrayRef Args, ArgVector ,
  EvalInfo , const FunctionDecl *Callee) {
+  ArgValues.resize(Args.size());
+
   bool Success = true;
   llvm::SmallBitVector ForbiddenNullArgs;
   if (Callee->hasAttr()) {
@@ -5809,8 +5815,6 @@ static bool EvaluateArgs(ArrayRef Args, 
ArgVector ,
 }
 }
   }
-  // FIXME: This is the wrong evaluation order for an assignment operator
-  // called via operator syntax.
   for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
 if (!Evaluate(ArgValues[Idx], Info, Args[Idx])) {
   // If we're checking for a potential constant expression, evaluate all
@@ -5834,17 +5838,13 @@ static bool EvaluateArgs(ArrayRef Args, 
ArgVector ,
 /// Evaluate a function call.
 static bool HandleFunctionCall(SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
-   ArrayRef Args, const Stmt *Body,
-   EvalInfo , APValue ,
-   const LValue *ResultSlot) {
-  ArgVector ArgValues(Args.size());
-  if (!EvaluateArgs(Args, ArgValues, Info, Callee))
-return false;
-
+   ArrayRef Args, APValue *ArgValues,
+   const Stmt *Body, EvalInfo ,
+   APValue , const LValue *ResultSlot) {
   if (!Info.CheckCallLimit(CallLoc))
 return false;
 
-  CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data());
+  CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues);
 
   // For a trivial copy or move assignment, perform an APValue copy. This is
   // essential for unions, where the operations performed by the assignment
@@ -7293,6 +7293,8 @@ class ExprEvaluatorBase
 auto Args = llvm::makeArrayRef(E->getArgs(), E->getNumArgs());
 bool HasQualifier = false;
 
+ArgVector ArgValues;
+
 // Extract function decl and 'this' pointer from the callee.
 if (CalleeType->isSpecificBuiltinType(BuiltinType::BoundMember)) {
   const CXXMethodDecl *Member = nullptr;
@@ -7341,6 +7343,22 @@ class ExprEvaluatorBase
 return Error(E);
   }
 
+  // For an (overloaded) assignment expression, evaluate the RHS before the
+  // LHS.
+  auto *OCE = dyn_cast(E);
+  if (OCE && OCE->isAssignmentOp()) {
+assert(Args.size() == 2 && "wrong number of arguments in assignment");
+if (isa(FD)) {
+  // Args[0] is the object argument.
+  if (!EvaluateArgs({Args[1]}, ArgValues, Info, FD))
+return false;
+} else {
+  if (!EvaluateArgs({Args[1], Args[0]}, ArgValues, Info, FD))
+return false;
+  std::swap(ArgValues[0], ArgValues[1]);
+}
+  }
+
   // Overloaded operator calls to member functions are represented as 
normal
   // calls with '*this' as the first argument.
   const CXXMethodDecl *MD = dyn_cast(FD);
@@ -7403,6 +7421,11 @@ class ExprEvaluatorBase
 } else
   return Error(E);
 
+// Evaluate the arguments now if we've not already done so.
+if (ArgValues.empty() && !Args.empty() &&
+!EvaluateArgs(Args, ArgValues, Info, FD))
+  return false;
+
 SmallVector CovariantAdjustmentPath;
 if (This) {
   auto *NamedMember = dyn_cast(FD);
@@ -7424,6 +7447,7 @@ class ExprEvaluatorBase
 // Destructor calls are 
diff erent enough that they have their own codepath.
 if (auto *DD = dyn_cast(FD)) 

[PATCH] D88680: Add ability to turn off -fpch-instantiate-templates in clang-cl

2020-10-05 Thread Shivanshu Goyal via Phabricator via cfe-commits
shivanshu3 updated this revision to Diff 296340.
shivanshu3 added a comment.

Address Reid's comments:

- Use hasFlag instead of hasArg
- Add test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88680

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/pch-instantiate-templates.c


Index: clang/test/Driver/pch-instantiate-templates.c
===
--- /dev/null
+++ clang/test/Driver/pch-instantiate-templates.c
@@ -0,0 +1,14 @@
+// CL driver test cases
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj %s 2>&1 | FileCheck 
--check-prefix=CLANG_CL_YC %s
+// RUN: %clang -### --driver-mode=cl /Yc /Fpfoo.pch /Fofoo.obj %s 2>&1 | 
FileCheck --check-prefix=CLANG_CL_YC %s
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj 
-fno-pch-instantiate-templates %s 2>&1 | FileCheck 
--check-prefix=CLANG_CL_YC_DISABLE %s
+
+// CLANG_CL_YC: "-fpch-instantiate-templates"
+// CLANG_CL_YC_DISABLE-NOT: "-fpch-instantiate-templates"
+
+// GCC driver test cases
+// RUN: %clang -### -x c-header %s -o %t/foo.pch 2>&1 | FileCheck 
-check-prefix=GCC_DEFAULT %s
+// RUN: %clang -### -x c-header %s -o %t/foo.pch -fpch-instantiate-templates 
2>&1 | FileCheck -check-prefix=GCC_DEFAULT_ENABLE %s
+
+// GCC_DEFAULT-NOT: "-fpch-instantiate-templates"
+// GCC_DEFAULT_ENABLE: "-fpch-instantiate-templates"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1212,7 +1212,11 @@
 if (YcArg && JA.getKind() >= Action::PrecompileJobClass &&
 JA.getKind() <= Action::AssembleJobClass) {
   CmdArgs.push_back(Args.MakeArgString("-building-pch-with-obj"));
-  CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
+  // -fpch-instantiate-templates is the default when creating
+  // precomp using /Yc
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   options::OPT_fno_pch_instantiate_templates, true))
+CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
 }
 if (YcArg || YuArg) {
   StringRef ThroughHeader = YcArg ? YcArg->getValue() : YuArg->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1475,11 +1475,11 @@
   Group, Flags<[DriverOption]>;
 def fpch_instantiate_templates:
   Flag <["-"], "fpch-instantiate-templates">,
-  Group, Flags<[CC1Option]>,
+  Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Instantiate templates already while building a PCH">;
 def fno_pch_instantiate_templates:
   Flag <["-"], "fno-pch-instantiate-templates">,
-  Group, Flags<[CC1Option]>;
+  Group, Flags<[CC1Option, CoreOption]>;
 defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
   "code for uses of this PCH that assumes an explicit object file will be 
built for the PCH">;
 defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate 
",


Index: clang/test/Driver/pch-instantiate-templates.c
===
--- /dev/null
+++ clang/test/Driver/pch-instantiate-templates.c
@@ -0,0 +1,14 @@
+// CL driver test cases
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj %s 2>&1 | FileCheck --check-prefix=CLANG_CL_YC %s
+// RUN: %clang -### --driver-mode=cl /Yc /Fpfoo.pch /Fofoo.obj %s 2>&1 | FileCheck --check-prefix=CLANG_CL_YC %s
+// RUN: %clang_cl -### /Yc /Fpfoo.pch /Fofoo.obj -fno-pch-instantiate-templates %s 2>&1 | FileCheck --check-prefix=CLANG_CL_YC_DISABLE %s
+
+// CLANG_CL_YC: "-fpch-instantiate-templates"
+// CLANG_CL_YC_DISABLE-NOT: "-fpch-instantiate-templates"
+
+// GCC driver test cases
+// RUN: %clang -### -x c-header %s -o %t/foo.pch 2>&1 | FileCheck -check-prefix=GCC_DEFAULT %s
+// RUN: %clang -### -x c-header %s -o %t/foo.pch -fpch-instantiate-templates 2>&1 | FileCheck -check-prefix=GCC_DEFAULT_ENABLE %s
+
+// GCC_DEFAULT-NOT: "-fpch-instantiate-templates"
+// GCC_DEFAULT_ENABLE: "-fpch-instantiate-templates"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1212,7 +1212,11 @@
 if (YcArg && JA.getKind() >= Action::PrecompileJobClass &&
 JA.getKind() <= Action::AssembleJobClass) {
   CmdArgs.push_back(Args.MakeArgString("-building-pch-with-obj"));
-  CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates"));
+  // -fpch-instantiate-templates is the default when creating
+  // precomp using /Yc
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   

[PATCH] D88759: [RISCV] Add SiFive cores to the CPU option

2020-10-05 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D88759#2313236 , @thakis wrote:

> This seems to break tests: http://45.33.8.238/linux/29545/step_7.txt
>
> Can you take a look and revert for now if it takes a while to fix?

I see it should already have been fixed in 
a48d480e1f7ebc5d5f93507fe1f519496621e259 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88759

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


[PATCH] D88863: [docs] Fix vector literal examples that don't compile

2020-10-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak planned changes to this revision.
ahatanak added a comment.

The parenthesis initialization does not work as documented for GCC or OpenCL 
vectors, so that has to be fixed too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88863

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


[clang] a48d480 - [RISCV] Fix broken test

2020-10-05 Thread Evandro Menezes via cfe-commits

Author: Evandro Menezes
Date: 2020-10-05T19:28:31-05:00
New Revision: a48d480e1f7ebc5d5f93507fe1f519496621e259

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

LOG: [RISCV] Fix broken test

Fix test for the SiFive E76 core.

This patch fixes the issue introduced by the commit 5d6d8a2769.

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
llvm/include/llvm/Support/RISCVTargetParser.def

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 2bd0b26f3caf..d551529f7827 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -31,9 +31,9 @@
 // mcpu with default march
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-e76 | FileCheck 
-check-prefix=MCPU-SIFIVE-E76 %s
 // MCPU-SIFIVE-E76: "-nostdsysteminc" "-target-cpu" "sifive-e76"
-// MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f"
 // MCPU-SIFIVE-E76: "-target-feature" "+c"
-// MCPU-SIFIVE-E76: "-target-abi" "lp64d"
+// MCPU-SIFIVE-E76: "-target-abi" "ilp32"
 
 // mcpu with mabi option
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | 
FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s

diff  --git a/llvm/include/llvm/Support/RISCVTargetParser.def 
b/llvm/include/llvm/Support/RISCVTargetParser.def
index a63874fa5dd0..53eebcf328d3 100644
--- a/llvm/include/llvm/Support/RISCVTargetParser.def
+++ b/llvm/include/llvm/Support/RISCVTargetParser.def
@@ -7,8 +7,8 @@ PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
 PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
 PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
 PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
-PROC(BULLET_RV32, {"sifive-7-rv32"}, FK_NONE, {""})
-PROC(BULLET_RV64, {"sifive-7-rv64"}, FK_64BIT, {""})
+PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""})
+PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""})
 PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})



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


[PATCH] D88759: [RISCV] Add SiFive cores to the CPU option

2020-10-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests: http://45.33.8.238/linux/29545/step_7.txt

Can you take a look and revert for now if it takes a while to fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88759

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


[PATCH] D88863: [docs] Fix vector literal examples that don't compile

2020-10-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: nemanjai, ayartsev.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.
ahatanak requested review of this revision.

Guard the AltiVec vector variables with `#ifdef __VEC__` and remove the last 
line, which doesn't compile.

rdar://problem/34411929


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88863

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -452,12 +452,13 @@
 
   v4si vsi = (v4si){1, 2, 3, 4};
   float4 vf = (float4)(1.0f, 2.0f, 3.0f, 4.0f);
+  #ifdef __VEC__
   vector int vi1 = (vector int)(1);// vi1 will be (1, 1, 1, 1).
   vector int vi2 = (vector int){1};// vi2 will be (1, 0, 0, 0).
   vector int vi3 = (vector int)(1, 2); // error
   vector int vi4 = (vector int){1, 2}; // vi4 will be (1, 2, 0, 0).
   vector int vi5 = (vector int)(1, 2, 3, 4);
-  float4 vf = (float4)((float2)(1.0f, 2.0f), (float2)(3.0f, 4.0f));
+  #endif
 
 Vector Operations
 -


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -452,12 +452,13 @@
 
   v4si vsi = (v4si){1, 2, 3, 4};
   float4 vf = (float4)(1.0f, 2.0f, 3.0f, 4.0f);
+  #ifdef __VEC__
   vector int vi1 = (vector int)(1);// vi1 will be (1, 1, 1, 1).
   vector int vi2 = (vector int){1};// vi2 will be (1, 0, 0, 0).
   vector int vi3 = (vector int)(1, 2); // error
   vector int vi4 = (vector int){1, 2}; // vi4 will be (1, 2, 0, 0).
   vector int vi5 = (vector int)(1, 2, 3, 4);
-  float4 vf = (float4)((float2)(1.0f, 2.0f), (float2)(3.0f, 4.0f));
+  #endif
 
 Vector Operations
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88859: APINotes: add APINotesYAMLCompiler

2020-10-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: gribozavr2, MForster.
Herald added subscribers: jfb, mgorny.
Herald added a project: clang.
compnerd requested review of this revision.

This adds the skeleton of the YAML Compiler for APINotes.  This change
only adds the YAML IO model for the API Notes along with a new testing
tool `apinotes-test` which can be used to verify that can round trip the
YAML content properly.  It provides the basis for the future work which
will add a binary serialization and deserialization format to the data
model.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88859

Files:
  clang/include/clang/APINotes/APINotesYAMLCompiler.h
  clang/include/clang/APINotes/Types.h
  clang/lib/APINotes/APINotesYAMLCompiler.cpp
  clang/lib/APINotes/CMakeLists.txt
  clang/lib/CMakeLists.txt
  clang/test/APINotes/Inputs/Frameworks/Simple.framework/Headers/Simple.apinotes
  clang/test/APINotes/Inputs/Frameworks/Simple.framework/Headers/Simple.h
  clang/test/APINotes/yaml-roundtrip.test
  clang/test/CMakeLists.txt
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/apinotes-test/APINotesTest.cpp
  clang/tools/apinotes-test/CMakeLists.txt

Index: clang/tools/apinotes-test/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/apinotes-test/CMakeLists.txt
@@ -0,0 +1,6 @@
+set(LLVM_LINK_COMPONENTS
+  Support)
+add_clang_executable(apinotes-test
+  APINotesTest.cpp)
+clang_target_link_libraries(apinotes-test PRIVATE
+  clangAPINotes)
Index: clang/tools/apinotes-test/APINotesTest.cpp
===
--- /dev/null
+++ clang/tools/apinotes-test/APINotesTest.cpp
@@ -0,0 +1,34 @@
+//===-- APINotesTest.cpp - API Notes Testing Tool -- C++ --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/APINotes/APINotesYAMLCompiler.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
+
+static llvm::cl::list
+APINotes(llvm::cl::Positional, llvm::cl::desc("[ ...]"),
+ llvm::cl::Required);
+
+int main(int argc, const char **argv) {
+  const bool DisableCrashReporting = true;
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0], DisableCrashReporting);
+  llvm::cl::ParseCommandLineOptions(argc, argv);
+
+  for (const auto  : APINotes) {
+llvm::ErrorOr> NotesOrError =
+llvm::MemoryBuffer::getFileOrSTDIN(Notes);
+if (std::error_code EC = NotesOrError.getError()) {
+  llvm::errs() << EC.message() << '\n';
+  return 1;
+}
+
+clang::api_notes::parseAndDumpAPINotes((*NotesOrError)->getBuffer());
+  }
+
+  return 0;
+}
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(apinotes-test)
 add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -63,7 +63,8 @@
 tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
 tools = [
-'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'opt', 'llvm-ifs',
+'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format',
+'clang-tblgen', 'opt', 'llvm-ifs',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
 ]
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -58,6 +58,7 @@
 endif ()
 
 list(APPEND CLANG_TEST_DEPS
+  apinotes-test
   c-index-test
   clang
   clang-resource-headers
Index: clang/test/APINotes/yaml-roundtrip.test
===
--- /dev/null
+++ clang/test/APINotes/yaml-roundtrip.test
@@ -0,0 +1,26 @@
+RUN: apinotes-test %S/Inputs/Frameworks/Simple.framework/Headers/Simple.apinotes > %t.result
+RUN: not diff %S/Inputs/Frameworks/Simple.framework/Headers/Simple.apinotes %t.result | FileCheck %s
+
+We expect only the nullability to be different as it is canonicalized during the
+roudtrip.
+
+CHECK:  7c8
+CHECK-NEXT: < Nullability: N
+CHECK-NEXT: ---
+CHECK-NEXT: > Nullability: Nonnull
+CHECK-NEXT: 13c14
+CHECK-NEXT: < Nullability: O
+CHECK-NEXT: ---
+CHECK-NEXT: > Nullability: Optional
+CHECK-NEXT: 19c20
+CHECK-NEXT: < Nullability: U
+CHECK-NEXT: ---

[PATCH] D84962: [PowerPC] Correct cpsgn's behaviour on PowerPC to match that of the ABI

2020-10-05 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil accepted this revision.
bsaleil added a comment.

LGTM, please fix the unrelated change when committing.




Comment at: clang/test/CodeGen/builtins-ppc-vsx.c:1
-// REQUIRES: powerpc-registered-target
+// requires: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple 
powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s

Unrelated change ?


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

https://reviews.llvm.org/D84962

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


[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This ended up having a rather large impact...

Compile-time: 
https://llvm-compile-time-tracker.com/compare.php?from=567462b48eba1c2d286ce97117994463f4535d2e=e00f189d392dd9bf95f6a98f05f2d341d06cd65c=instructions
Code size: 
https://llvm-compile-time-tracker.com/compare.php?from=567462b48eba1c2d286ce97117994463f4535d2e=e00f189d392dd9bf95f6a98f05f2d341d06cd65c=size-text
Largest code size impact is CMakeFiles/pairlocalalign.dir/constants.c.o with a 
code-size reduction of ~6%.

Always happy about compile-time improvements, but the large code size changes 
indicate that this has a pretty significant impact on optimization, and as 
usual it's hard to tell whether it's a good or a bad one :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

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


[PATCH] D88786: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

This patch may break some existing HIP applications.

For rdc mode, device vars are merged. Host shadow vars should also be in comdat 
and merged. HIP runtime just ignores the same shadow var registered with the 
same device var, everything should work.

For nordc mode, device vars are in different fat binaries. If shadow vars are 
not in comdat and not merged, they can be registered with device vars in 
different fat binaries. Things would still work.

I think inline variable and static constexpr member are very useful features. 
Disabling them for device variable is a big limitation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88786

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


[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

One request though: can you add a release note about the removal with a brief 
explanation of why it was removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[clang] e00f189 - [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-10-06T00:00:30+03:00
New Revision: e00f189d392dd9bf95f6a98f05f2d341d06cd65c

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

LOG: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads 
which are only ever stored to always use a legal integer type if one is 
available." (PR47592)

(it was introduced in 
https://lists.llvm.org/pipermail/llvm-dev/2015-January/080956.html)

This canonicalization seems dubious.

Most importantly, while it does not create `inttoptr` casts by itself,
it may cause them to appear later, see e.g. D88788.

I think it's pretty obvious that it is an undesirable outcome,
by now we've established that seemingly no-op `inttoptr`/`ptrtoint` casts
are not no-op, and are no longer eager to look past them.
Which e.g. means that given
```
%a = load i32
%b = inttoptr %a
%c = inttoptr %a
```
we likely won't be able to tell that `%b` and `%c` is the same thing.

As we can see in D88789 / D88788 / D88806 / D75505,
we can't really teach SCEV about this (not without the 
https://bugs.llvm.org/show_bug.cgi?id=47592 at least)
And we can't recover the situation post-inlining in instcombine.

So it really does look like this fold is actively breaking
otherwise-good IR, in a way that is not recoverable.
And that means, this fold isn't helpful in exposing the passes
that are otherwise unaware of these patterns it produces.

Thusly, i propose to simply not perform such a canonicalization.
The original motivational RFC does not state what larger problem
that canonicalization was trying to solve, so i'm not sure
how this plays out in the larger picture.

On vanilla llvm test-suite + RawSpeed, this results in
increase of asm instructions and final object size by ~+0.05%
decreases final count of bitcasts by -4.79% (-28990),
ptrtoint casts by -15.41% (-3423),
and of inttoptr casts by -25.59% (-6919, *sic*).
Overall, there's -0.04% less IR blocks, -0.39% instructions.

See https://bugs.llvm.org/show_bug.cgi?id=47592

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

Added: 


Modified: 
clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/atomic.ll
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/loadstore-metadata.ll
llvm/test/Transforms/InstCombine/non-integral-pointers.ll
llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll

Removed: 




diff  --git a/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c 
b/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
index 3a5628d7f57e..5df1e83b13bf 100644
--- a/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
+++ b/clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
@@ -255,22 +255,20 @@ svbool_t read_bool(struct struct_bool *s) {
 // CHECK-256-NEXT:  entry:
 // CHECK-256-NEXT:[[X_ADDR:%.*]] = alloca , align 16
 // CHECK-256-NEXT:store  [[X:%.*]], * 
[[X_ADDR]], align 16, [[TBAA15:!tbaa !.*]]
-// CHECK-256-NEXT:[[TMP0:%.*]] = bitcast * [[X_ADDR]] to 
i32*
-// CHECK-256-NEXT:[[TMP1:%.*]] = load i32, i32* [[TMP0]], align 16, 
[[TBAA6]]
-// CHECK-256-NEXT:[[Y:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_BOOL:%.*]], %struct.struct_bool* [[S:%.*]], i64 0, i32 1
-// CHECK-256-NEXT:[[TMP2:%.*]] = bitcast [3 x <4 x i8>]* [[Y]] to i32*
-// CHECK-256-NEXT:store i32 [[TMP1]], i32* [[TMP2]], align 2, [[TBAA6]]
+// CHECK-256-NEXT:[[TMP0:%.*]] = bitcast * [[X_ADDR]] to 
<4 x i8>*
+// CHECK-256-NEXT:[[TMP1:%.*]] = load <4 x i8>, <4 x i8>* [[TMP0]], align 
16, [[TBAA6]]
+// CHECK-256-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_BOOL:%.*]], %struct.struct_bool* [[S:%.*]], i64 0, i32 1, i64 0
+// CHECK-256-NEXT:store <4 x i8> [[TMP1]], <4 x i8>* [[ARRAYIDX]], align 
2, [[TBAA6]]
 // CHECK-256-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_bool(
 // CHECK-512-NEXT:  entry:
 // CHECK-512-NEXT:[[X_ADDR:%.*]] = alloca , align 16
 // CHECK-512-NEXT:store  [[X:%.*]], * 
[[X_ADDR]], align 16, [[TBAA15:!tbaa !.*]]
-// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast * [[X_ADDR]] to 
i64*
-// CHECK-512-NEXT:[[TMP1:%.*]] = load i64, i64* [[TMP0]], align 16, 
[[TBAA6]]
-// CHECK-512-NEXT:[[Y:%.*]] = getelementptr inbounds 
[[STRUCT_STRUCT_BOOL:%.*]], %struct.struct_bool* [[S:%.*]], i64 0, i32 1
-// CHECK-512-NEXT:[[TMP2:%.*]] = bitcast [3 x <8 x i8>]* [[Y]] to i64*
-// CHECK-512-NEXT:store i64 [[TMP1]], i64* [[TMP2]], align 2, [[TBAA6]]
+// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast * [[X_ADDR]] to 

[clang] 5d6d8a2 - [RISCV] Add SiFive cores to the CPU option

2020-10-05 Thread Evandro Menezes via cfe-commits

Author: Evandro Menezes
Date: 2020-10-05T15:50:57-05:00
New Revision: 5d6d8a2769b3a91fd65b125c2cda64ea27a894bf

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

LOG: [RISCV] Add SiFive cores to the CPU option

Add the SiFive cores E76 and U74 using the SiFive 7 series microarchitecture.

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

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/Support/RISCVTargetParser.def
llvm/lib/Target/RISCV/RISCV.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 15cd212e4fb4..2bd0b26f3caf 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -7,12 +7,12 @@
 // MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64"
 // MCPU-ROCKET64: "-target-feature" "+64bit"
 
-// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=bullet-rv32 | FileCheck 
-check-prefix=MCPU-BULLET32 %s
-// MCPU-BULLET32: "-nostdsysteminc" "-target-cpu" "bullet-rv32"
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-7-rv32 | FileCheck 
-check-prefix=MCPU-SIFIVE7-32 %s
+// MCPU-SIFIVE7-32: "-nostdsysteminc" "-target-cpu" "sifive-7-rv32"
 
-// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=bullet-rv64 | FileCheck 
-check-prefix=MCPU-BULLET64 %s
-// MCPU-BULLET64: "-nostdsysteminc" "-target-cpu" "bullet-rv64"
-// MCPU-BULLET64: "-target-feature" "+64bit"
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-7-rv64 | FileCheck 
-check-prefix=MCPU-SIFIVE7-64 %s
+// MCPU-SIFIVE7-64: "-nostdsysteminc" "-target-cpu" "sifive-7-rv64"
+// MCPU-SIFIVE7-64: "-target-feature" "+64bit"
 
 // mcpu with default march
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck 
-check-prefix=MCPU-SIFIVE-U54 %s
@@ -28,6 +28,20 @@
 // MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit"
 // MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64"
 
+// mcpu with default march
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-e76 | FileCheck 
-check-prefix=MCPU-SIFIVE-E76 %s
+// MCPU-SIFIVE-E76: "-nostdsysteminc" "-target-cpu" "sifive-e76"
+// MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-E76: "-target-feature" "+c"
+// MCPU-SIFIVE-E76: "-target-abi" "lp64d"
+
+// mcpu with mabi option
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | 
FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s
+// MCPU-ABI-SIFIVE-U74: "-nostdsysteminc" "-target-cpu" "sifive-u74"
+// MCPU-ABI-SIFIVE-U74: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-ABI-SIFIVE-U74: "-target-feature" "+c" "-target-feature" "+64bit"
+// MCPU-ABI-SIFIVE-U74: "-target-abi" "lp64"
+
 // march overwrite mcpu's default march
 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc 
| FileCheck -check-prefix=MCPU-MARCH %s
 // MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" 
"+m" "-target-feature" "+c"

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index efcecbbc4726..309cb637c0c5 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -191,8 +191,8 @@
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, 
bullet-rv32, sifive-e31
+// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-7-rv32, sifive-e31, sifive-e76
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
bullet-rv64, sifive-u54
+// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-7-rv64, sifive-u54, sifive-u74

diff  --git a/llvm/include/llvm/Support/RISCVTargetParser.def 
b/llvm/include/llvm/Support/RISCVTargetParser.def
index e6003a4fdebb..a63874fa5dd0 100644
--- a/llvm/include/llvm/Support/RISCVTargetParser.def
+++ b/llvm/include/llvm/Support/RISCVTargetParser.def
@@ -7,9 +7,11 @@ PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
 PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
 PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
 PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
-PROC(BULLET_RV32, {"bullet-rv32"}, FK_NONE, {""})
-PROC(BULLET_RV64, {"bullet-rv64"}, FK_64BIT, {""})
+PROC(BULLET_RV32, 

[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Roman Lebedev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe00f189d392d: [InstCombine] Revert rL226781 Teach 
InstCombine to canonicalize loads which… (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

Files:
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/loadstore-metadata.ll
  llvm/test/Transforms/InstCombine/non-integral-pointers.ll
  llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll

Index: llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
===
--- llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
+++ llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
@@ -50,10 +50,10 @@
 define dso_local void @_Z3gen1S(%0* noalias sret align 8 %arg, %0* byval(%0) align 8 %arg1) {
 ; CHECK-LABEL: @_Z3gen1S(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast %0* [[ARG1:%.*]] to i64*
-; CHECK-NEXT:[[I21:%.*]] = load i64, i64* [[TMP0]], align 8
-; CHECK-NEXT:[[TMP1:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:store i64 [[I21]], i64* [[TMP1]], align 8
+; CHECK-NEXT:[[I:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG1:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I2:%.*]] = load i32*, i32** [[I]], align 8
+; CHECK-NEXT:[[I3:%.*]] = getelementptr inbounds [[TMP0]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:store i32* [[I2]], i32** [[I3]], align 8
 ; CHECK-NEXT:ret void
 ;
 bb:
@@ -68,13 +68,12 @@
 ; CHECK-LABEL: @_Z3foo1S(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:[[I2:%.*]] = alloca [[TMP0:%.*]], align 8
-; CHECK-NEXT:[[I1_SROA_0_0_I5_SROA_CAST:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i64, i64* [[I1_SROA_0_0_I5_SROA_CAST]], align 8
-; CHECK-NEXT:[[I_SROA_0_0_I6_SROA_CAST:%.*]] = bitcast %0* [[I2]] to i64*
-; CHECK-NEXT:store i64 [[I1_SROA_0_0_COPYLOAD]], i64* [[I_SROA_0_0_I6_SROA_CAST]], align 8
+; CHECK-NEXT:[[I1_SROA_0_0_I5_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I5_SROA_IDX]], align 8
+; CHECK-NEXT:[[I_SROA_0_0_I6_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[I2]], i64 0, i32 0
+; CHECK-NEXT:store i32* [[I1_SROA_0_0_COPYLOAD]], i32** [[I_SROA_0_0_I6_SROA_IDX]], align 8
 ; CHECK-NEXT:tail call void @_Z7escape01S(%0* nonnull byval(%0) align 8 [[I2]])
-; CHECK-NEXT:[[TMP0]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:ret i32* [[TMP0]]
+; CHECK-NEXT:ret i32* [[I1_SROA_0_0_COPYLOAD]]
 ;
 bb:
   %i = alloca %0, align 8
@@ -108,24 +107,21 @@
 define dso_local i32* @_Z3bar1S(%0* byval(%0) align 8 %arg) {
 ; CHECK-LABEL: @_Z3bar1S(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:[[I1_SROA_0_0_I4_SROA_CAST:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i64, i64* [[I1_SROA_0_0_I4_SROA_CAST]], align 8
+; CHECK-NEXT:[[I1_SROA_0_0_I4_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I4_SROA_IDX]], align 8
 ; CHECK-NEXT:[[I5:%.*]] = tail call i32 @_Z4condv()
 ; CHECK-NEXT:[[I6_NOT:%.*]] = icmp eq i32 [[I5]], 0
 ; CHECK-NEXT:br i1 [[I6_NOT]], label [[BB10:%.*]], label [[BB7:%.*]]
 ; CHECK:   bb7:
 ; CHECK-NEXT:tail call void @_Z5sync0v()
-; CHECK-NEXT:[[TMP0:%.*]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:tail call void @_Z7escape0Pi(i32* [[TMP0]])
+; CHECK-NEXT:tail call void @_Z7escape0Pi(i32* [[I1_SROA_0_0_COPYLOAD]])
 ; CHECK-NEXT:br label [[BB13:%.*]]
 ; CHECK:   bb10:
 ; CHECK-NEXT:tail call void @_Z5sync1v()
-; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:tail call void @_Z7escape1Pi(i32* [[TMP1]])
+; CHECK-NEXT:tail call void @_Z7escape1Pi(i32* [[I1_SROA_0_0_COPYLOAD]])
 ; CHECK-NEXT:br label [[BB13]]
 ; CHECK:   bb13:
-; CHECK-NEXT:[[DOTPRE_PHI:%.*]] = phi i32* [ [[TMP1]], [[BB10]] ], [ [[TMP0]], [[BB7]] ]
-; CHECK-NEXT:ret i32* [[DOTPRE_PHI]]
+; CHECK-NEXT:ret i32* [[I1_SROA_0_0_COPYLOAD]]
 ;
 bb:
   %i = alloca %0, align 8
Index: llvm/test/Transforms/InstCombine/non-integral-pointers.ll
===
--- llvm/test/Transforms/InstCombine/non-integral-pointers.ll
+++ 

[PATCH] D88759: [RISCV] Add SiFive cores to the CPU option

2020-10-05 Thread Evandro Menezes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d6d8a2769b3: [RISCV] Add SiFive cores to the CPU option 
(authored by evandro).
Herald added subscribers: cfe-commits, jrtc27.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D88759?vs=295917=296290#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88759

Files:
  clang/test/Driver/riscv-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/lib/Target/RISCV/RISCV.td

Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -228,8 +228,8 @@
 def : ProcessorModel<"rocket-rv32", RocketModel, []>;
 def : ProcessorModel<"rocket-rv64", RocketModel, [Feature64Bit]>;
 
-def : ProcessorModel<"bullet-rv32", BulletModel, []>;
-def : ProcessorModel<"bullet-rv64", BulletModel, [Feature64Bit]>;
+def : ProcessorModel<"sifive-7-rv32", BulletModel, []>;
+def : ProcessorModel<"sifive-7-rv64", BulletModel, [Feature64Bit]>;
 
 def : ProcessorModel<"sifive-e31", RocketModel, [FeatureStdExtM,
  FeatureStdExtA,
@@ -242,6 +242,18 @@
  FeatureStdExtD,
  FeatureStdExtC]>;
 
+def : ProcessorModel<"sifive-e76", BulletModel, [FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtF,
+ FeatureStdExtC]>;
+
+def : ProcessorModel<"sifive-u74", BulletModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtF,
+ FeatureStdExtD,
+ FeatureStdExtC]>;
+
 //===--===//
 // Define the RISC-V target.
 //===--===//
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- llvm/include/llvm/Support/RISCVTargetParser.def
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -7,9 +7,11 @@
 PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
 PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
 PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
-PROC(BULLET_RV32, {"bullet-rv32"}, FK_NONE, {""})
-PROC(BULLET_RV64, {"bullet-rv64"}, FK_64BIT, {""})
+PROC(BULLET_RV32, {"sifive-7-rv32"}, FK_NONE, {""})
+PROC(BULLET_RV64, {"sifive-7-rv64"}, FK_64BIT, {""})
 PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
+PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
+PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
 
 #undef PROC
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -191,8 +191,8 @@
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, bullet-rv32, sifive-e31
+// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-7-rv32, sifive-e31, sifive-e76
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, bullet-rv64, sifive-u54
+// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-u54, sifive-u74
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -7,12 +7,12 @@
 // MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64"
 // MCPU-ROCKET64: "-target-feature" "+64bit"
 
-// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=bullet-rv32 | FileCheck -check-prefix=MCPU-BULLET32 %s
-// MCPU-BULLET32: "-nostdsysteminc" "-target-cpu" "bullet-rv32"
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-7-rv32 | FileCheck -check-prefix=MCPU-SIFIVE7-32 %s
+// MCPU-SIFIVE7-32: "-nostdsysteminc" "-target-cpu" "sifive-7-rv32"
 
-// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=bullet-rv64 | FileCheck -check-prefix=MCPU-BULLET64 %s
-// 

[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-05 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:16447
+
+bool AIXBitfieldViolation = false;
+if (const BuiltinType *BTy = FieldTy.getTypePtr()->getAs()) {

sfertile wrote:
> Can  this change can be split out into its own patch? If it can i would 
> suggest doing so.
I was expecting our buildbot can pick up all bitfield related changes at one 
time. Also if we split this out, that means we either need to wait for this 
second part to land first or need to add more LIT to oversized long long to the 
first part, which then needs to be removed whenever this second part land. It 
seems we are complicating the patch. Can you give me your rationale about why 
we want to split out this part?


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

https://reviews.llvm.org/D87029

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


[PATCH] D88349: Fix inconsistent flag for disabling Dead Virtual Function Elimination

2020-10-05 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88349

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


[PATCH] D88737: [AIX] Turn -fdata-sections on by default in Clang

2020-10-05 Thread Digger via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:46
  ///< aliases to base ctors when possible.
-CODEGENOPT(DataSections  , 1, 0) ///< Set when -fdata-sections is enabled.
+CODEGENOPT(DataSections  , 1, 0) ///< Set by default, or when 
-f[no-]data-sections.
+CODEGENOPT(HasExplicitDataSections, 1, 0) ///< Set when -f[no-]data-sections 
is set.

DiggerLin wrote:
> turn on by default , it should be changed to CODEGENOPT(DataSections  , 
> 1, 1) ?
> 
please  ignore above comment.  DataSection is set by default only on AIX OS . 
the comment maybe need to be modified?


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

https://reviews.llvm.org/D88737

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


[PATCH] D88786: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 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 rGa2cc8833683d: [CUDA] Dont call __cudaRegisterVariable 
on C++17 inline variables (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88786

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-stub.cu


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -29,6 +29,10 @@
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
 // RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \
+// RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
+// RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW,LNX_17
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN
@@ -91,9 +95,18 @@
 // WIN-DAG: @"?ext_constant_var_def@@3HA" = internal global i32 undef
 __constant__ int ext_constant_var_def = 2;
 
+#if __cplusplus > 201402L
+/// FIXME: Reject __device__ constexpr and inline variables in Sema.
+// LNX_17: @inline_var = internal global i32 undef, comdat, align 4{{$}}
+// LNX_17: @_ZN1C17member_inline_varE = internal constant i32 undef, comdat, 
align 4{{$}}
+__device__ inline int inline_var = 3;
+struct C {
+  __device__ static constexpr int member_inline_var = 4;
+};
+#endif
 
 void use_pointers() {
-  int *p;
+  const int *p;
   p = _var;
   p = _var;
   p = _var;
@@ -101,6 +114,10 @@
   p = _device_var;
   p = _constant_var;
   p = _host_var;
+#if __cplusplus > 201402L
+  p = _var;
+  p = ::member_inline_var;
+#endif
 }
 
 // Make sure that all parts of GPU code init/cleanup are there:
@@ -185,6 +202,7 @@
 // ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, {{i32|i64}} 4, i32 1, 
i32 0
 // ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, {{i32|i64}} 4, i32 
0, i32 0
 // ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, {{i32|i64}} 4, 
i32 1, i32 0
+// LNX_17-NOT: [[PREFIX]]RegisterVar(i8** %0, {{.*}}inline_var
 // ALL: ret void
 
 // Test that we've built a constructor.
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4129,7 +4129,12 @@
 // Shadow variables and their properties must be registered with CUDA
 // runtime. Skip Extern global variables, which will be registered in
 // the TU where they are defined.
-if (!D->hasExternalStorage())
+//
+// Don't register a C++17 inline variable. The local symbol can be
+// discarded and referencing a discarded local symbol from outside the
+// comdat (__cuda_register_globals) is disallowed by the ELF spec.
+// TODO: Reject __device__ constexpr and __device__ inline in Sema.
+if (!D->hasExternalStorage() && !D->isInline())
   getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
  D->hasAttr());
   } else if (D->hasAttr()) {


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -29,6 +29,10 @@
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
 // RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \
+// RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW,LNX_17
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN
@@ -91,9 +95,18 @@
 // WIN-DAG: @"?ext_constant_var_def@@3HA" = internal global i32 undef
 __constant__ int ext_constant_var_def = 2;
 
+#if __cplusplus > 201402L
+/// FIXME: Reject __device__ constexpr and inline variables in Sema.
+// LNX_17: @inline_var = internal global i32 undef, comdat, 

[PATCH] D87962: [clang] Change the multi-character character constants from extension to implementation-defined.

2020-10-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM! Do you need someone to commit on your behalf?


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

https://reviews.llvm.org/D87962

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


[clang] a2cc883 - [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-10-05T12:53:59-07:00
New Revision: a2cc8833683dd124cf2ee96f6d17f7f835da1fc8

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

LOG: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

D17779: host-side shadow variables of external declarations of device-side
global variables have internal linkage and are referenced by
`__cuda_register_globals`.

nvcc from CUDA 11 does not allow `__device__ inline` or `__device__ constexpr`
(C++17 inline variables) but clang has incorrectly supported them for a while:

```
error: A __device__ variable cannot be marked constexpr
error: An inline __device__/__constant__/__managed__ variable must have 
internal linkage when the program is compiled in whole program mode (-rdc=false)
```

If such a variable (which has a comdat group) is discarded (a copy from another
translation unit is prevailing and selected), accessing the variable from
outside the section group (`__cuda_register_globals`) is a violation of the ELF
specification and will be rejected by linkers:

> A symbol table entry with STB_LOCAL binding that is defined relative to one 
> of a group's sections, and that is contained in a symbol table section that 
> is not part of the group, must be discarded if the group members are 
> discarded. References to this symbol table entry from outside the group are 
> not allowed.

As a workaround, don't register such inline variables for now.
(If we register the variables in all TUs, we will keep multiple instances of 
the shadow and break the C++ semantics for inline variables).
We should reject such variables in Sema but our internal users need some time 
to migrate.

Reviewed By: tra

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/device-stub.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c3457865c0b0..93b49ec981e8 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4129,7 +4129,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const 
VarDecl *D,
 // Shadow variables and their properties must be registered with CUDA
 // runtime. Skip Extern global variables, which will be registered in
 // the TU where they are defined.
-if (!D->hasExternalStorage())
+//
+// Don't register a C++17 inline variable. The local symbol can be
+// discarded and referencing a discarded local symbol from outside the
+// comdat (__cuda_register_globals) is disallowed by the ELF spec.
+// TODO: Reject __device__ constexpr and __device__ inline in Sema.
+if (!D->hasExternalStorage() && !D->isInline())
   getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
  D->hasAttr());
   } else if (D->hasAttr()) {

diff  --git a/clang/test/CodeGenCUDA/device-stub.cu 
b/clang/test/CodeGenCUDA/device-stub.cu
index ca21116fc989..16bbef6cfad5 100644
--- a/clang/test/CodeGenCUDA/device-stub.cu
+++ b/clang/test/CodeGenCUDA/device-stub.cu
@@ -29,6 +29,10 @@
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
 // RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \
+// RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
+// RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW,LNX_17
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN
@@ -91,9 +95,18 @@ __device__ int ext_device_var_def = 1;
 // WIN-DAG: @"?ext_constant_var_def@@3HA" = internal global i32 undef
 __constant__ int ext_constant_var_def = 2;
 
+#if __cplusplus > 201402L
+/// FIXME: Reject __device__ constexpr and inline variables in Sema.
+// LNX_17: @inline_var = internal global i32 undef, comdat, align 4{{$}}
+// LNX_17: @_ZN1C17member_inline_varE = internal constant i32 undef, comdat, 
align 4{{$}}
+__device__ inline int inline_var = 3;
+struct C {
+  __device__ static constexpr int member_inline_var = 4;
+};
+#endif
 
 void use_pointers() {
-  int *p;
+  const int *p;
   p = _var;
   p = _var;
   p = _var;
@@ -101,6 +114,10 @@ void use_pointers() {
   p = _device_var;
   p = _constant_var;
   p = _host_var;
+#if __cplusplus > 201402L
+  p = _var;
+  p = ::member_inline_var;
+#endif
 }
 
 // Make sure that all parts of GPU code init/cleanup are 

[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM to remove rather than move into `readability` unless someone has a good 
argument as to why it belongs there. I don't think this pattern makes code more 
readable in general as it recommends using a more verbose syntax (pointers, 
which require dereferencing) over a safer, concise syntax (references, which 
carry semantic information about nullness).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[PATCH] D88845: [SystemZ][z/OS] Set default alignment rules for z/OS target

2020-10-05 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 296269.
fanbo-meng added a comment.

fix no newline at end of file


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

https://reviews.llvm.org/D88845

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/zos-alignment.c

Index: clang/test/CodeGen/zos-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/zos-alignment.c
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos -fdump-record-layouts %s -o - | FileCheck %s
+
+struct s0 {
+  short a:3;
+  long b:5;
+  int c:1;
+  long d:10;
+  char e:5;
+} S0;
+// CHECK:  0 | struct s0
+// CHECK-NEXT: 0:0-2 |   short a
+// CHECK-NEXT: 0:3-7 |   long b
+// CHECK-NEXT: 1:0-0 |   int c
+// CHECK-NEXT:1:1-10 |   long d
+// CHECK-NEXT: 2:3-7 |   char e
+// CHECK-NEXT:   | [sizeof=3, align=1]
+
+struct s1 {
+  char a:7;
+  long b:27;
+  int c:2;
+} S1;
+// CHECK:  0 | struct s1
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:0:7-33 |   long b
+// CHECK-NEXT: 4:2-3 |   int c
+// CHECK-NEXT:   | [sizeof=5, align=1]
+
+struct s2 {
+  char a:7;
+  char  :0;
+  short :0;
+  short :0;
+} S2;
+// CHECK:  0 | struct s2
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:   4:- |   char
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+struct s3 {
+  int a;
+  int b:16;
+  char  :0;
+  char c:1;
+} S3;
+// CHECK:  0 | struct s3
+// CHECK-NEXT: 0 |   int a
+// CHECK-NEXT:4:0-15 |   int b
+// CHECK-NEXT:   8:- |   char
+// CHECK-NEXT: 8:0-0 |   char c
+// CHECK-NEXT:   | [sizeof=12, align=4]
+
+struct s4 {
+ unsigned int __attribute__((aligned(32))) a;
+} S4;
+// CHECK:  0 | struct s4
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=32, align=32]
+
+struct s5 {
+  char a;
+  int  b:19 __attribute__((aligned(4)));
+  int  c:22 __attribute__((aligned(8)));
+  int  :0;
+  int  d:10;
+} S5;
+// CHECK:  0 | struct s5
+// CHECK-NEXT: 0 |   char a
+// CHECK-NEXT:4:0-18 |   int b
+// CHECK-NEXT:8:0-21 |   int c
+// CHECK-NEXT:  12:- |   int
+// CHECK-NEXT:12:0-9 |   int d
+// CHECK-NEXT:   | [sizeof=16, align=8]
+
+struct s6 {
+  char * a;
+  char * b[];
+} S6;
+// CHECK:  0 | struct s6
+// CHECK-NEXT: 0 |   char * a
+// CHECK-NEXT: 8 |   char *[] b
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+struct s10 {
+ unsigned int __attribute__((aligned)) a;
+} S10;
+// CHECK:  0 | struct s10
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=16, align=16]
+
+union u0 {
+  unsigned short d1 __attribute__((packed));
+  intd2:10;
+  long   d3;
+} U0 __attribute__((aligned(8)));
+// CHECK:  0 | union u0
+// CHECK-NEXT: 0 |   unsigned short d1
+// CHECK-NEXT: 0:0-9 |   int d2
+// CHECK-NEXT: 0 |   long d3
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u1 {
+  unsigned int:0;
+  short   a;
+} U1;
+// CHECK:  0 | union u1
+// CHECK-NEXT:   0:- |   unsigned int
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+union u2 {
+  long  :0;
+  short  a;
+} U2;
+// CHECK:  0 | union u2
+// CHECK-NEXT:   0:- |   long
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u3 {
+  unsigned char :0;
+  unsigned short :0;
+} U3;
+// CHECK:  0 | union u3
+// CHECK-NEXT:   0:- |   unsigned char
+// CHECK-NEXT:   0:- |   unsigned short
+// CHECK-NEXT:   | [sizeof=0, align=4]
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -779,6 +779,11 @@
   ZOSTargetInfo(const llvm::Triple , const TargetOptions )
   : OSTargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedInt;
+this->UseBitFieldTypeAlignment = false;
+this->UseZeroLengthBitfieldAlignment = true;
+this->ZeroLengthBitfieldBoundary = 32;
+this->MinGlobalAlign = 0;
+this->DefaultAlignForAttributeAligned = 128;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87451: add new option ignore-xcoff-visibility

2020-10-05 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 296267.
DiggerLin marked 3 inline comments as done.
DiggerLin added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/Driver/ignore-xcoff-visibility.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll

Index: llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll
@@ -0,0 +1,48 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec  < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+
+@foo_p = global void ()* @zoo_extern_h, align 4
+@b = protected global i32 0, align 4
+
+define hidden void @foo_h(i32* %p) {
+entry:
+  %p.addr = alloca i32*, align 4
+  store i32* %p, i32** %p.addr, align 4
+  %0 = load i32*, i32** %p.addr, align 4
+  %1 = load i32, i32* %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %0, align 4
+  ret void
+}
+
+declare hidden void @zoo_extern_h()
+
+define protected void @bar() {
+entry:
+  call void @foo_h(i32* @b)
+  %0 = load void ()*, void ()** @foo_p, align 4
+  call void %0()
+  ret void
+}
+
+; VISIBILITY-ASM: .globl  foo_h[DS],hidden
+; VISIBILITY-ASM: .globl  .foo_h,hidden
+; VISIBILITY-ASM: .globl  bar[DS],protected
+; VISIBILITY-ASM: .globl  .bar,protected
+; VISIBILITY-ASM: .globl  b,protected
+
+; IGNOREVISIBILITY-ASM: .globl  foo_h[DS]
+; IGNOREVISIBILITY-ASM: .globl  .foo_h
+; IGNOREVISIBILITY-ASM: .globl  bar[DS]
+; IGNOREVISIBILITY-ASM: .globl  .bar
+; IGNOREVISIBILITY-ASM: .globl  b
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1702,17 +1702,19 @@
   assert(LinkageAttr != MCSA_Invalid && "LinkageAttr should not MCSA_Invalid.");
 
   MCSymbolAttr VisibilityAttr = MCSA_Invalid;
-  switch (GV->getVisibility()) {
+  if (!TM.getIgnoreXCOFFVisibility()) {
+switch (GV->getVisibility()) {
 
-  // TODO: "exported" and "internal" Visibility needs to go here.
-  case GlobalValue::DefaultVisibility:
-break;
-  case GlobalValue::HiddenVisibility:
-VisibilityAttr = MAI->getHiddenVisibilityAttr();
-break;
-  case GlobalValue::ProtectedVisibility:
-VisibilityAttr = MAI->getProtectedVisibilityAttr();
-break;
+// TODO: "exported" and "internal" Visibility needs to go here.
+case GlobalValue::DefaultVisibility:
+  break;
+case GlobalValue::HiddenVisibility:
+  VisibilityAttr = MAI->getHiddenVisibilityAttr();
+  break;
+case GlobalValue::ProtectedVisibility:
+  VisibilityAttr = MAI->getProtectedVisibilityAttr();
+  break;
+}
   }
 
   OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -74,6 +74,7 @@
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
+CGOPT(bool, IgnoreXCOFFVisibility)
 CGOPT(std::string, BBSections)
 CGOPT(unsigned, TLSSize)
 CGOPT(bool, EmulatedTLS)
@@ -333,6 +334,13 @@
   cl::init(false));
   CGBINDOPT(FunctionSections);
 
+  static cl::opt IgnoreXCOFFVisibility(
+  "ignore-xcoff-visibility",
+  cl::desc("Not emit the visibility attribute for asm in AIX OS or give "
+   "all symbols 'unspecified' visibility in xcoff object file"),
+  cl::init(false));
+  CGBINDOPT(IgnoreXCOFFVisibility);
+
   static cl::opt BBSections(
   "basic-block-sections",
   cl::desc("Emit basic blocks into separate 

[PATCH] D87451: add new option ignore-xcoff-visibility

2020-10-05 Thread Digger via Phabricator via cfe-commits
DiggerLin marked 7 inline comments as done.
DiggerLin added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2622
+
+Do not emit any visibility attribute for asm on AIX or give all symbols 
'unspecified' visibility in xcoff object file(XCOFF only)
+

daltenty wrote:
> daltenty wrote:
> > nit: add a space before parens
> I don't think the object file writing case was handled yet? This makes it 
> sound like it is.
yes, we do not implement the visibility of the object file in the 
XCoffObjectWriter.cpp



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5242
 
+  if (const Arg *A = Args.getLastArg(options::OPT_mignore_xcoff_visibility)) {
+if (Triple.isOSAIX())

daltenty wrote:
> Use `Args.hasFlag` instead, since this option doesn't have a value we need to 
> check.
we need to get the value here 
 D.Diag(diag::err_drv_unsupported_opt_for_target)
  << A->getAsString(Args) << TripleStr;



Comment at: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp:72
+
+// ERROR: unsupported option '-mignore-xcoff-visibility' for target 
'powerpc-unknown-linux'
+

daltenty wrote:
> This isn't being checked anymore, also probably belongs in the other file
thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D88845: [SystemZ][z/OS] Set default alignment rules for z/OS target

2020-10-05 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
fanbo-meng added reviewers: abhina.sreeskantharajan, hubert.reinterpretcast, 
Kai, uweigand.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
fanbo-meng requested review of this revision.

Set the default alignment control variables for z/OS target and add test case 
for alignment rules on z/OS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88845

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/zos-alignment.c

Index: clang/test/CodeGen/zos-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/zos-alignment.c
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos -fdump-record-layouts %s -o - | FileCheck %s
+
+struct s0 {
+  short a:3;
+  long b:5;
+  int c:1;
+  long d:10;
+  char e:5;
+} S0;
+// CHECK:  0 | struct s0
+// CHECK-NEXT: 0:0-2 |   short a
+// CHECK-NEXT: 0:3-7 |   long b
+// CHECK-NEXT: 1:0-0 |   int c
+// CHECK-NEXT:1:1-10 |   long d
+// CHECK-NEXT: 2:3-7 |   char e
+// CHECK-NEXT:   | [sizeof=3, align=1]
+
+struct s1 {
+  char a:7;
+  long b:27;
+  int c:2;
+} S1;
+// CHECK:  0 | struct s1
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:0:7-33 |   long b
+// CHECK-NEXT: 4:2-3 |   int c
+// CHECK-NEXT:   | [sizeof=5, align=1]
+
+struct s2 {
+  char a:7;
+  char  :0;
+  short :0;
+  short :0;
+} S2;
+// CHECK:  0 | struct s2
+// CHECK-NEXT: 0:0-6 |   char a
+// CHECK-NEXT:   4:- |   char
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   4:- |   short
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+struct s3 {
+  int a;
+  int b:16;
+  char  :0;
+  char c:1;
+} S3;
+// CHECK:  0 | struct s3
+// CHECK-NEXT: 0 |   int a
+// CHECK-NEXT:4:0-15 |   int b
+// CHECK-NEXT:   8:- |   char
+// CHECK-NEXT: 8:0-0 |   char c
+// CHECK-NEXT:   | [sizeof=12, align=4]
+
+struct s4 {
+ unsigned int __attribute__((aligned(32))) a;
+} S4;
+// CHECK:  0 | struct s4
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=32, align=32]
+
+struct s5 {
+  char a;
+  int  b:19 __attribute__((aligned(4)));
+  int  c:22 __attribute__((aligned(8)));
+  int  :0;
+  int  d:10;
+} S5;
+// CHECK:  0 | struct s5
+// CHECK-NEXT: 0 |   char a
+// CHECK-NEXT:4:0-18 |   int b
+// CHECK-NEXT:8:0-21 |   int c
+// CHECK-NEXT:  12:- |   int
+// CHECK-NEXT:12:0-9 |   int d
+// CHECK-NEXT:   | [sizeof=16, align=8]
+
+struct s6 {
+  char * a;
+  char * b[];
+} S6;
+// CHECK:  0 | struct s6
+// CHECK-NEXT: 0 |   char * a
+// CHECK-NEXT: 8 |   char *[] b
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+struct s10 {
+ unsigned int __attribute__((aligned)) a;
+} S10;
+// CHECK:  0 | struct s10
+// CHECK-NEXT: 0 |   unsigned int a
+// CHECK-NEXT:   | [sizeof=16, align=16]
+
+union u0 {
+  unsigned short d1 __attribute__((packed));
+  intd2:10;
+  long   d3;
+} U0 __attribute__((aligned(8)));
+// CHECK:  0 | union u0
+// CHECK-NEXT: 0 |   unsigned short d1
+// CHECK-NEXT: 0:0-9 |   int d2
+// CHECK-NEXT: 0 |   long d3
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u1 {
+  unsigned int:0;
+  short   a;
+} U1;
+// CHECK:  0 | union u1
+// CHECK-NEXT:   0:- |   unsigned int
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=4, align=4]
+
+union u2 {
+  long  :0;
+  short  a;
+} U2;
+// CHECK:  0 | union u2
+// CHECK-NEXT:   0:- |   long
+// CHECK-NEXT: 0 |   short a
+// CHECK-NEXT:   | [sizeof=8, align=8]
+
+union u3 {
+  unsigned char :0;
+  unsigned short :0;
+} U3;
+// CHECK:  0 | union u3
+// CHECK-NEXT:   0:- |   unsigned char
+// CHECK-NEXT:   0:- |   unsigned short
+// CHECK-NEXT:   | [sizeof=0, align=4]
\ No newline at end of file
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -779,6 +779,11 @@
   ZOSTargetInfo(const llvm::Triple , const TargetOptions )
   : OSTargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedInt;
+this->UseBitFieldTypeAlignment = false;
+this->UseZeroLengthBitfieldAlignment = true;
+this->ZeroLengthBitfieldBoundary = 32;
+this->MinGlobalAlign = 0;
+this->DefaultAlignForAttributeAligned = 128;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88844: [clangd] Add `score` extension to workspace/symbol response.

2020-10-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

The protocol doesn't really incorporate ranking.
As with code completion, most clients respect what the server sends, but
VSCode re-ranks items, with predictable results.
See https://github.com/clangd/vscode-clangd/issues/81

There's no filterText field so we may be unable to construct a good workaround.
But expose the score so we may be able to do this on the client in future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88844

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/symbols.test

Index: clang-tools-extra/clangd/test/symbols.test
===
--- clang-tools-extra/clangd/test/symbols.test
+++ clang-tools-extra/clangd/test/symbols.test
@@ -23,7 +23,8 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "uri": "file://{{.*}}/vector.h"
 # CHECK-NEXT:},
-# CHECK-NEXT:"name": "vector"
+# CHECK-NEXT:"name": "vector",
+# CHECK-NEXT:"score": {{.*}}
 # CHECK-NEXT:  }
 # CHECK-NEXT:]
 # CHECK-NEXT:}
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1015,6 +1015,14 @@
 
   /// The name of the symbol containing this symbol.
   std::string containerName;
+
+  /// The score that clangd calculates to rank the returned symbols.
+  /// This excludes the fuzzy-matching score between `name` and the query.
+  /// (Specifically, the last ::-separated component).
+  /// This can be used to re-rank results as the user types, using client-side
+  /// fuzzy-matching (that score should be multiplied with this one).
+  /// This is a clangd extension, set only for workspace/symbol responses.
+  llvm::Optional score;
 };
 llvm::json::Value toJSON(const SymbolInformation &);
 llvm::raw_ostream <<(llvm::raw_ostream &, const SymbolInformation &);
@@ -1175,11 +1183,11 @@
   /// Indicates if this item is deprecated.
   bool deprecated = false;
 
-  /// This is Clangd extension.
-  /// The score that Clangd calculates to rank completion items. This score can
-  /// be used to adjust the ranking on the client side.
-  /// NOTE: This excludes fuzzy matching score which is typically calculated on
-  /// the client side.
+  /// The score that clangd calculates to rank the returned completions.
+  /// This excludes the fuzzy-match between `filterText` and the partial word.
+  /// This can be used to re-rank results as the user types, using client-side
+  /// fuzzy-matching (that score should be multiplied with this one).
+  /// This is a clangd extension.
   float score = 0.f;
 
   // TODO: Add custom commitCharacters for some of the completion items. For
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -662,12 +662,15 @@
 }
 
 llvm::json::Value toJSON(const SymbolInformation ) {
-  return llvm::json::Object{
+  llvm::json::Object O{
   {"name", P.name},
   {"kind", static_cast(P.kind)},
   {"location", P.location},
   {"containerName", P.containerName},
   };
+  if (P.score)
+O["score"] = *P.score;
+  return std::move(O);
 }
 
 llvm::raw_ostream <<(llvm::raw_ostream ,
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -96,12 +96,13 @@
   return;
 }
 
-SymbolKind SK = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
-std::string Scope = std::string(Sym.Scope);
-llvm::StringRef ScopeRef = Scope;
-ScopeRef.consume_back("::");
-SymbolInformation Info = {(Sym.Name + Sym.TemplateSpecializationArgs).str(),
-  SK, *Loc, std::string(ScopeRef)};
+llvm::StringRef Scope = Sym.Scope;
+Scope.consume_back("::");
+SymbolInformation Info;
+Info.name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
+Info.kind = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
+Info.location = *Loc;
+Info.containerName = Scope.str();
 
 SymbolQualitySignals Quality;
 Quality.merge(Sym);
@@ -121,6 +122,7 @@
 dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
  Quality, Relevance);
 
+Info.score = Score / Relevance.NameMatch;
 Top.push({Score, std::move(Info)});
   });
   for (auto  : std::move(Top).items())
___
cfe-commits mailing list

[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-05 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/test/Layout/aix-bitfield-alignment.cpp:118
+
+typedef __attribute__((aligned(32))) short mySHORT;
+struct D {

We should have a similar test for an overaligned long or long long.


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

https://reviews.llvm.org/D87029

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


[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D88789#2312510 , @lebedev.ri wrote:

> So, we can't really teach SCEV about this: D88788 
>  (not without the 
> https://bugs.llvm.org/show_bug.cgi?id=47592 at least)
> And we can't recover the situation post-inlining in instcombine: D88842 
> .
>
> It really does look like this fold is actively breaking
> otherwise-good IR, in a way that is not recoverable.
> And that means, this fold isn't helpful in exposing the passes
> that are otherwise unaware of these patterns it produces.
>
> I'm proceeding with this patch.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

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


[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

So, we can't really teach SCEV about this: D88788 
 (not without the 
https://bugs.llvm.org/show_bug.cgi?id=47592 at lease)
And we can't recover the situation post-inlining in instcombine: D88842 
.

It really does look like this fold is actively breaking
otherwise-good IR, in a way that is not recoverable.
And that means, this fold isn't helpful in exposing the passes
that are otherwise unaware of these patterns it produces.

I'm proceeding with this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

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


[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Keeping loads and stores of pointers as pointers to the extent possible 
> doesn't seem like a bad idea, but I'm worried people will feel like this 
> gives a *semantic* guarantee that isn't really there. Fundamentally, LLVM 
> still doesn't currently have typed memory. All of the optimizer is built upon 
> this assumption.

LLVM currently isn't internally consistent.  See 
https://bugs.llvm.org/show_bug.cgi?id=34548 .  I should probably make a LangRef 
patch so the "pointer aliasing" section indicates there's an issue here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

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


[PATCH] D88786: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D88786#2312365 , @MaskRay wrote:

>> Could you provide an example where this is causing an issue?
>
> If the C++17 inline variable appears in two TUs. They have the same comdat 
> group. The first comdat group is prevailing and the second one is disarded. 
> `__cudaRegisterVar(...)` in the second TU references a local symbol in a 
> discarded section.

So, if I understand you correctly, it's the *host* side which ends up dropping 
it in one of TUs. It is a bit of a problem, considering that both of those TUs 
will need their own register call for their own GPU-side counterpart of the 
variable.

  a.h:
__device__ inline int foo;
  a1.cu: #inlcude "a.h"
a1.o/host : inline int foo; // 'shadow' variable. 
register(foo, gpu-side-foo) // tell runtime that when we use 
host-side foo we want to access device-side foo.
a1/GPU: int foo; // the only device-side instance. It's always there.
  a2.cu: #inlcude "a.h"
a2.o/host : inline int foo; // 'shadow' variable. 
register(foo, gpu-side-foo) // tell runtime that when we use 
host-side foo we want to access device-side foo.
a2/GPU: int foo; // the only device-side instance. It's always there.
  
  host_exe: a1.o, a2.o
only one instance of inline int foo survives and we lose ability to tell 
which GPU-side `foo` we want to access when we use host-side foo shadow.

Not allowing inline/constexpr variables seems to be the only choice here. 
Otherwise we's have to keep multiple instances of the shadow and that would 
break the C++ semantics for `inline` and `constexpr`

> The previous revision (https://reviews.llvm.org/D88786?id=295997 ) drops the 
> comdat, but I think it is inferior to this one.

Silently dropping variable registration shifts the problem from link time to 
runtime. It may be OK as a temporary workaround for the build issues and only 
fraction of those will run into it at runtime, so it's technically an 
improvement, but we will need to catch it in Sema ASAP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88786

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


[clang-tools-extra] 95262ee - [clangd] Describe non-handling of most IWYU pragmas. NFC

2020-10-05 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-05T20:50:26+02:00
New Revision: 95262ee2be75daffd05e9a8a985ca2c8e34c9af7

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

LOG: [clangd] Describe non-handling of most IWYU pragmas. NFC

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

Added: 


Modified: 
clang-tools-extra/clangd/index/CanonicalIncludes.h

Removed: 




diff  --git a/clang-tools-extra/clangd/index/CanonicalIncludes.h 
b/clang-tools-extra/clangd/index/CanonicalIncludes.h
index aabfabc75368..da7dc46db778 100644
--- a/clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ b/clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -71,6 +71,21 @@ class CanonicalIncludes {
 ///
 /// Currently it only supports IWYU private pragma:
 /// 
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private
+///
+/// We ignore other pragmas:
+/// - keep: this is common but irrelevant: we do not currently remove includes
+/// - export: this is common and potentially interesting, there are three 
cases:
+///* Points to a public header (common): we can suppress include2 if you
+///  already have include1. Only marginally useful.
+///* Points to a private header annotated with `private` (somewhat 
commmon):
+///  Not incrementally useful as we support private.
+///* Points to a private header without pragmas (rare). This is a reversed
+///  private pragma, and is valuable but too rare to be worthwhile.
+/// - no_include: this is about as common as private, but only affects the
+///   current file, so the value is smaller. We could add support.
+/// - friend: this is less common than private, has implementation 
diff iculties,
+///   and affects behavior in a limited scope.
+/// - associated: extremely rare
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 



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


[PATCH] D88822: [clangd] Describe non-handling of most IWYU pragmas. NFC

2020-10-05 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95262ee2be75: [clangd] Describe non-handling of most IWYU 
pragmas. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88822

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.h


Index: clang-tools-extra/clangd/index/CanonicalIncludes.h
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -71,6 +71,21 @@
 ///
 /// Currently it only supports IWYU private pragma:
 /// 
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private
+///
+/// We ignore other pragmas:
+/// - keep: this is common but irrelevant: we do not currently remove includes
+/// - export: this is common and potentially interesting, there are three 
cases:
+///* Points to a public header (common): we can suppress include2 if you
+///  already have include1. Only marginally useful.
+///* Points to a private header annotated with `private` (somewhat 
commmon):
+///  Not incrementally useful as we support private.
+///* Points to a private header without pragmas (rare). This is a reversed
+///  private pragma, and is valuable but too rare to be worthwhile.
+/// - no_include: this is about as common as private, but only affects the
+///   current file, so the value is smaller. We could add support.
+/// - friend: this is less common than private, has implementation 
difficulties,
+///   and affects behavior in a limited scope.
+/// - associated: extremely rare
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 


Index: clang-tools-extra/clangd/index/CanonicalIncludes.h
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -71,6 +71,21 @@
 ///
 /// Currently it only supports IWYU private pragma:
 /// https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private
+///
+/// We ignore other pragmas:
+/// - keep: this is common but irrelevant: we do not currently remove includes
+/// - export: this is common and potentially interesting, there are three cases:
+///* Points to a public header (common): we can suppress include2 if you
+///  already have include1. Only marginally useful.
+///* Points to a private header annotated with `private` (somewhat commmon):
+///  Not incrementally useful as we support private.
+///* Points to a private header without pragmas (rare). This is a reversed
+///  private pragma, and is valuable but too rare to be worthwhile.
+/// - no_include: this is about as common as private, but only affects the
+///   current file, so the value is smaller. We could add support.
+/// - friend: this is less common than private, has implementation difficulties,
+///   and affects behavior in a limited scope.
+/// - associated: extremely rare
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84226: [AST][RecoveryExpr] Part1: Support dependent binary operator in C for error recovery.

2020-10-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14381
+  OpLoc, CurFPFeatureOverrides());
+switch (Opc) {
+case BO_Assign:

now the only thing that differs between the cases is the type. You could 
consider putting the type in a variable, and factoring the Create after the 
switch.



Comment at: clang/lib/Sema/SemaExpr.cpp:14393
+case BO_NE:
+
+case BO_LAnd:

(why the line break here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226

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


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-05 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1643
+  } else {
+// Handle AIX oversized Long Long bitfield under 32 bit compile mode.
+if (StorageUnitSize > 32 &&

I get different results for using a long long bitfield, and using an enum with 
an underlying long long type:


```
struct S {
unsigned long long  field : 32;
};

extern "C" int printf(const char*, ...);

int main(void) {
printf("%lu %lu\n", sizeof(struct S), alignof(struct S));
}

```
```
*** Dumping AST Record Layout
 0 | struct S
0:0-31 |   unsigned long long field
   | [sizeof=4, dsize=4, align=4, preferredalign=4,
   |  nvsize=4, nvalign=4, preferrednvalign=4]
```
__

```
enum e : unsigned long long { E = 1 };

struct S {
enum e field : 32;
};

extern "C" int printf(const char*, ...);

int main(void) {
printf("%lu %lu\n", sizeof(struct S), alignof(struct S));
}
```

```
*** Dumping AST Record Layout
 0 | struct S
0:0-31 |   enum e field
   | [sizeof=8, dsize=8, align=8, preferredalign=8,
   |  nvsize=8, nvalign=8, preferrednvalign=8]
```
Shouldn't we be truncating the size/align of the enum typed bitfield as well?


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

https://reviews.llvm.org/D87029

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


[PATCH] D88786: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D88786#2312329 , @tra wrote:

>> If such a variable (which has a comdat group) is discarded (a copy from 
>> another
>> translation unit is prevailing and selected), accessing the variable from
>> outside the section group (__cuda_register_globals) is a violation of the ELF
>> specification and will be rejected by linkers:
>
> Every TU  is the whole program on the GPU side, provided we compile w/o 
> `-frdc`, so there's no other TU to prevail.
> I don't have a good idea yet what's the best way to handle this in CUDA, but 
> not registering the variables will likely to create other issues, only 
> visible at runtime. E.g. some host-side code will attempt to use cudaMemcpy() 
> on the symbol and will fail, because it's not been registered, even though we 
> do have all other glue in place.
>
> Could you provide an example where this is causing an issue?

If the C++17 inline variable appears in two TUs. They have the same comdat 
group. The first comdat group is prevailing and the second one is disarded. 
`__cudaRegisterVar(...)` in the second TU references a local symbol in a 
discarded section.

The previous revision (https://reviews.llvm.org/D88786?id=295997 ) drops the 
comdat, but I think it is inferior to this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88786

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


[PATCH] D88446: docs: add documentation describing API Notes

2020-10-05 Thread Saleem Abdulrasool 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 rG85d506400081: docs: add documentation describing API Notes 
(authored by compnerd).

Changed prior to commit:
  https://reviews.llvm.org/D88446?vs=295924=296243#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88446

Files:
  clang/docs/APINotes.rst
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
  clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes

Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes
@@ -0,0 +1,15 @@
+Name: SomeKit
+Classes:
+  - Name: A
+Methods:
+  - Selector: "privateTransform:input:"
+MethodKind:  Instance
+NullabilityOfRet: N
+Nullability:  [ N, S ]
+Properties:
+  - Name: internalProperty
+Nullability: N
+Protocols:
+  - Name: InternalProtocol
+Availability: none
+AvailabilityMsg: "not for you"
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
@@ -0,0 +1,4 @@
+@interface A(ExplicitNullabilityProperties)
+@property (nonatomic, readwrite, retain, nonnull) A *explicitNonnullInstance;
+@property (nonatomic, readwrite, retain, nullable) A *explicitNullableInstance;
+@end
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
@@ -0,0 +1,60 @@
+#ifndef SOMEKIT_H
+#define SOMEKIT_H
+
+__attribute__((objc_root_class))
+@interface A
+-(A*)transform:(A*)input;
+-(A*)transform:(A*)input integer:(int)integer;
+
+@property (nonatomic, readonly, retain) A* someA;
+@property (nonatomic, retain) A* someOtherA;
+
+@property (nonatomic) int intValue;
+@end
+
+@interface B : A
+@end
+
+@interface C : A
+- (instancetype)init;
+- (instancetype)initWithA:(A*)a;
+@end
+
+@interface ProcessInfo : A
++(instancetype)processInfo;
+@end
+
+@interface A(NonNullProperties)
+@property (nonatomic, readwrite, retain) A *nonnullAInstance;
+@property (class, nonatomic, readwrite, retain) A *nonnullAInstance;
+
+@property (nonatomic, readwrite, retain) A *nonnullAClass;
+@property (class, nonatomic, readwrite, retain) A *nonnullAClass;
+
+@property (nonatomic, readwrite, retain) A *nonnullABoth;
+@property (class, nonatomic, readwrite, retain) A *nonnullABoth;
+@end
+
+#import 
+
+extern int *global_int_ptr;
+
+int *global_int_fun(int *ptr, int *ptr2);
+
+#define SOMEKIT_DOUBLE double
+
+__attribute__((objc_root_class))
+@interface OverriddenTypes
+-(int *)methodToMangle:(int *)ptr1 second:(int *)ptr2;
+@property int *intPropertyToMangle;
+@end
+
+@interface A(ImplicitGetterSetters)
+@property (nonatomic, readonly, retain) A *implicitGetOnlyInstance;
+@property (class, nonatomic, readonly, retain) A *implicitGetOnlyClass;
+
+@property (nonatomic, readwrite, retain) A *implicitGetSetInstance;
+@property (class, nonatomic, readwrite, retain) A *implicitGetSetClass;
+@end
+
+#endif
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
@@ -0,0 +1,98 @@
+Name: SomeKit
+Classes:
+  - Name: A
+Methods:
+  - Selector:"transform:"
+MethodKind:  Instance
+Availability:none
+AvailabilityMsg: "anything but this"
+  - Selector: "transform:integer:"
+MethodKind:  Instance
+NullabilityOfRet: N
+Nullability:  [ N, S ]
+  - Selector: "implicitGetOnlyInstance"
+MethodKind:  Instance
+Availability:none
+AvailabilityMsg: "getter gone"
+  - Selector: "implicitGetOnlyClass"
+MethodKind:  Class
+Availability:none
+AvailabilityMsg: "getter gone"
+  - Selector: "implicitGetSetInstance"
+MethodKind:  Instance
+Availability:none
+AvailabilityMsg: "getter gone"
+  - Selector: "implicitGetSetClass"
+MethodKind:  Class
+Availability:none
+AvailabilityMsg: "getter gone"

[clang] 85d5064 - docs: add documentation describing API Notes

2020-10-05 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-10-05T18:29:13Z
New Revision: 85d506400081e121ef876a4c66fb337b050dcae6

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

LOG: docs: add documentation describing API Notes

API Notes are a feature which allows annotation of headers by an
auxiliary file that contains metadata for declarations pertaining to the
associated module.  This enables adding attributes to declarations
without requiring modification of the headers, enabling finer grained
control for library headers for consumers without having to modify
external headers.

Differential Revision: https://reviews.llvm.org/D88446
Reviewed By: Richard Smith, Marcel Hlopko

Added: 
clang/docs/APINotes.rst

clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h

clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h

clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes

Modified: 


Removed: 




diff  --git a/clang/docs/APINotes.rst b/clang/docs/APINotes.rst
new file mode 100644
index ..4ac4c01cdefb
--- /dev/null
+++ b/clang/docs/APINotes.rst
@@ -0,0 +1,363 @@
+
+API Notes: Annotations Without Modifying Headers
+
+
+**The Problem:** You have headers you want to use, but you also want to add
+extra information to the API. You don't want to put that information in the
+headers themselves --- perhaps because you want to keep them clean for other
+clients, or perhaps because they're from some open source project and you don't
+want to modify them at all.
+
+**Incomplete solution:** Redeclare all the interesting parts of the API in your
+own header and add the attributes you want. Unfortunately, this:
+
+* doesn't work with attributes that must be present on a definition
+* doesn't allow changing the definition in other ways
+* requires your header to be included in any client code to take effect
+
+**Better solution:** Provide a "sidecar" file with the information you want to
+add, and have that automatically get picked up by the module-building logic in
+the compiler.
+
+That's API notes.
+
+API notes use a YAML-based file format. YAML is a format best explained by
+example, so here is a `small example`__ from the compiler test suite of API
+notes for a hypothetical "SomeKit" framework.
+
+__ test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
+
+
+Usage
+=
+
+API notes files are found relative to the module map that defines a module,
+under the name "SomeKit.apinotes" for a module named "SomeKit". Additionally, a
+file named "SomeKit_private.apinotes" will also be picked up to go with a
+private module map. For bare modules these two files will be in the same
+directory as the corresponding module map; for framework modules, they should
+be placed in the Headers and PrivateHeaders directories, respectively. The
+module map for a private top-level framework module should be placed in the
+PrivateHeaders directory as well, though it does not need an additional
+"_private" suffix on its name.
+
+Clang will search for API notes files next to module maps only when passed the
+``-fapi-notes-modules`` option.
+
+
+Limitations
+===
+
+- Since they're identified by module name, API notes cannot be used to modify
+  arbitrary textual headers.
+
+
+"Versioned" API Notes
+=
+
+Many API notes affect how a C API is imported into Swift. In order to change
+that behavior while still remaining backwards-compatible, API notes can be
+selectively applied based on the Swift compatibility version provided to the
+compiler (e.g. ``-fapi-notes-swift-version=5``). The rule is that an
+explicitly-versioned API note applies to that version *and all earlier
+versions,* and any applicable explicitly-versioned API note takes precedence
+over an unversioned API note.
+
+
+Reference
+=
+
+An API notes file contains a YAML dictionary with the following top-level
+entries:
+
+:Name:
+
+  The name of the module (the framework name, for frameworks). Note that this
+  is always the name of a top-level module, even within a private API notes
+  file.
+
+  ::
+
+Name: MyFramework
+
+:Classes, Protocols, Tags, Typedefs, Globals, Enumerators, Functions:
+
+  Arrays of top-level declarations. Each entry in the array must have a
+  'Name' key with its Objective-C name. "Tags" refers to structs, enums, and
+  unions; "Enumerators" refers to enum cases.
+
+  ::
+
+Classes:
+- Name: MyController
+  …
+- Name: MyView
+  …
+
+:SwiftVersions:
+
+  Contains 

[PATCH] D88786: [CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

2020-10-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> If such a variable (which has a comdat group) is discarded (a copy from 
> another
> translation unit is prevailing and selected), accessing the variable from
> outside the section group (__cuda_register_globals) is a violation of the ELF
> specification and will be rejected by linkers:

Every TU  is the whole program on the GPU side, provided we compile w/o 
`-frdc`, so there's no other TU to prevail.
I don't have a good idea yet what's the best way to handle this in CUDA, but 
not registering the variables will likely to create other issues, only visible 
at runtime. E.g. some host-side code will attempt to use cudaMemcpy() on the 
symbol and will fail, because it's not been registered, even though we do have 
all other glue in place.

Could you provide an example where this is causing an issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88786

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


[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-10-05 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Hi @gribozavr do you think we can do something about this test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485

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


[PATCH] D88013: [AArch64] Correct parameter type for unsigned Neon scalar shift intrinsics

2020-10-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D88013/new/

https://reviews.llvm.org/D88013

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


[PATCH] D88659: [FE]Split SuitableAlign into two parts

2020-10-05 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

In D88659#2306403 , @jyknight wrote:

> Hm, to start with, the current state of this confuses me.
>
> In GCC, the preprocessor macro `__BIGGEST_ALIGNMENT__` was supposed to expose 
> the alignment used by `__attribute__((aligned))` (no arg specified), as well 
> the alignment used for alloca. However, this is no longer the case on x86: 
> `BIGGEST_ALIGNMENT` is 512bits with avx-512 enabled, 256bits with avx 
> enabled, and otherwise 128bits. Alloca follows this too. But, 
> `__attribute__((aligned))` was fixed at 128bit alignment, regardless of AVX 
> being enabled, in order to not break ABI compatibility with structs using 
> that. On other architectures, the 3 values seem to be always the same.
>
> In clang, we similarly have (before this patch) both 
> DefaultAlignForAttributeAligned (used for ``attribute((aligned))`), and 
> SuitableAlign (used for the predefined `__BIGGEST_ALIGNMENT__` and alignment 
> for alloca). But these values are different on very many 
> architectures...which I think is probably wrong. Furthermore, SuitableAlign 
> isn't being adjusted to be suitable for vectors, like it is in gcc, which 
> _also_ seems wrong. Looks like there's actually an earlier patch to fix that 
> which was never merged: https://reviews.llvm.org/D39313
>
> So, anyways -- back to this patch: On AIX PPC, you want alloca to align to 
> 128bits, `__attribute__((aligned))` to align to 128bits (aka 8 bytes), but 
> `__BIGGEST_ALIGNMENT__` to only be 4?
>
> That seems pretty weird, and probably wrong?

As you mentioned, without this patch, `SuitableAlign` is used for the 
predefined `__BIGGEST_ALIGNMENT__` and alignment for alloca. But on AIX, the 
__BIGGEST_ALIGNMENT__ should be 8bytes,  alloca and `__attribute__((aligned))`  
should align to 16bytes considering vector types which have to be aligned to 
16bytes, that's why we want to split `SuitableAlign`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88659

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-05 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

For the LIT test clang/test/AST/const-fpfeatures.cpp, currently failing in this 
patch, the variables V1 and others are initialized via call to "global var 
init" which performs the rounding at execution time, I think that's correct not 
certain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-05 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 296221.
mibintc added a comment.

In the previous version of this patch, I enabled FENV_ACCESS if frounding-math, 
but @sepavloff commented that this deduction is not correct.  I changed the 
logic to check for the "ffp-model=strict" settings, and if those settings are 
in effect from the command line, then I also enable fenv_access.  To repeat 
what I've said elsewhere, this is the documented behavior of the "/fp:strict" 
Microsoft command line option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/const-fpfeatures-diag.c
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/pragma-fenv_access.c
  clang/test/Parser/fp-floatcontrol-syntax.cpp
  clang/test/Parser/pragma-fenv_access.c
  clang/test/Preprocessor/pragma_unknown.c

Index: clang/test/Preprocessor/pragma_unknown.c
===
--- clang/test/Preprocessor/pragma_unknown.c
+++ clang/test/Preprocessor/pragma_unknown.c
@@ -16,15 +16,6 @@
 // CHECK: {{^}}#pragma STDC FP_CONTRACT DEFAULT{{$}}
 // CHECK: {{^}}#pragma STDC FP_CONTRACT IN_BETWEEN{{$}}
 
-#pragma STDC FENV_ACCESS ON  // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS OFF
-#pragma STDC FENV_ACCESS DEFAULT
-#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS ON{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS OFF{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS DEFAULT{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS IN_BETWEEN{{$}}
-
 #pragma STDC CX_LIMITED_RANGE ON
 #pragma STDC CX_LIMITED_RANGE OFF
 #pragma STDC CX_LIMITED_RANGE DEFAULT 
Index: clang/test/Parser/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fenv_access.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ffp-exception-behavior=strict -DSTRICT -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -DCPP -DSTRICT -ffp-exception-behavior=strict -fsyntax-only -verify %s
+#ifdef CPP
+#define CONST constexpr
+#else
+#define CONST const
+#endif
+
+#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(int x, float y) {
+  if (x)
+return y + 2;
+  #pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of a compound statement}}
+  return x + y;
+}
+
+#pragma STDC FENV_ACCESS ON
+int main() {
+  CONST float one = 1.0F ;
+  CONST float three = 3.0F ;
+  CONST float four = 4.0F ;
+  CONST float frac_ok = one/four;
+#if defined(CPP) & defined(STRICT)
+//expected-error@+3 {{constexpr variable 'frac' must be initialized by a constant expression}}
+//expected-note@+2 {{compile time floating point arithmetic suppressed in strict evaluation modes}}
+#endif
+  CONST float frac = one/three; // rounding
+  CONST double d = one;
+  CONST int not_too_big = 255;
+  CONST float fnot_too_big = not_too_big;
+  CONST int too_big = 0x7ff0;
+#if defined(CPP) & defined(STRICT)
+//expected-error@+6 {{constexpr variable 'fbig' must be initialized by a constant expression}}
+//expected-note@+5 {{compile time floating point arithmetic suppressed in strict evaluation modes}}
+#endif
+#if defined(CPP)
+//expected-warning@+2{{implicit conversion}}
+#endif
+  CONST float fbig = too_big; // inexact
+  if (one <= four)  return 0;
+  return -1;
+}
Index: clang/test/Parser/fp-floatcontrol-syntax.cpp
===
--- clang/test/Parser/fp-floatcontrol-syntax.cpp
+++ clang/test/Parser/fp-floatcontrol-syntax.cpp
@@ -26,19 +26,13 @@
 double a = 0.0;
 double b = 1.0;
 
-//FIXME At some point this warning will be removed, until then
-//  document the warning
-#ifdef FAST
-// expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS ON
-#else
-#pragma STDC FENV_ACCESS ON // expected-warning{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#endif
 #ifdef STRICT
 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
 #else
-// Currently FENV_ACCESS cannot be enabled by 

[PATCH] D84226: [AST][RecoveryExpr] Part1: Support dependent binary operator in C for error recovery.

2020-10-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14365
+   "Should only occur in error-recovery path.");
+if (BinaryOperator::isCompoundAssignmentOp(Opc))
+  return CompoundAssignOperator::Create(

sammccall wrote:
> isAssignmentOp instead? including = itself
Simple assignment `=` doesn't belong to `CompoundAssignOperator`, it should be 
`BinaryOperator`.

Added the handling logic in the switch-case below.



Comment at: clang/test/AST/ast-dump-recovery.c:45
   int* ptr;
-  // FIXME: the top-level expr should be a binary operator.
-  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
-  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
-  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
-  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
-  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK: BinaryOperator {{.*}} contains-errors '='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'

sammccall wrote:
> `'int *' lvalue contains-errors '='`
oh, this spots a bug in our code -- unlike C++, it should not be a lvalue.

From  C [6.15.16] p3:
> An assignment expression has the value of the left operand after the 
> assignment, but is not an lvalue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226

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


[PATCH] D84226: [AST][RecoveryExpr] Part1: Support dependent binary operator in C for error recovery.

2020-10-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 296218.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/Sema/error-dependence.c

Index: clang/test/Sema/error-dependence.c
===
--- /dev/null
+++ clang/test/Sema/error-dependence.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type %s
+
+int call(int); // expected-note {{'call' declared here}}
+
+void test1(int s) {
+  // verify "assigning to 'int' from incompatible type ''" is
+  // not emitted.
+  s = call(); // expected-error {{too few arguments to function call}}
+}
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -42,11 +42,33 @@
 
 void test2() {
   int* ptr;
-  // FIXME: the top-level expr should be a binary operator.
-  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
-  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
-  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
-  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
-  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK: BinaryOperator {{.*}} 'int *' contains-errors '='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}}
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   ptr = some_func(); // should not crash
+
+  int compoundOp;
+  // CHECK: CompoundAssignOperator {{.*}} 'int' contains-errors '+='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'compoundOp'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  compoundOp += some_func();
+
+  // CHECK: BinaryOperator {{.*}} 'int' contains-errors '||'
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func() || 1;
+
+  // CHECK: BinaryOperator {{.*}} '' contains-errors ','
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-RecoveryExpr {{.*}}
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  1, some_func();
+  // CHECK: BinaryOperator {{.*}} 'int' contains-errors ','
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} ''
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func(), 1;
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/Builtins.h"
@@ -13683,7 +13684,7 @@
 CorrectDelayedTyposInBinOp(Sema , BinaryOperatorKind Opc, Expr *LHSExpr,
Expr *RHSExpr) {
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
-  if (!S.getLangOpts().CPlusPlus) {
+  if (!S.Context.isDependenceAllowed()) {
 // C cannot handle TypoExpr nodes on either side of a binop because it
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.
@@ -14364,6 +14365,49 @@
   return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
   }
 
+  if (getLangOpts().RecoveryAST &&
+  (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent())) {
+assert(!getLangOpts().CPlusPlus);
+assert((LHSExpr->containsErrors() || RHSExpr->containsErrors()) &&
+   "Should only occur in error-recovery path.");
+if (BinaryOperator::isCompoundAssignmentOp(Opc))
+  // C [6.15.16] p3:
+  // An assignment expression has the value of the left operand after the
+  // assignment, but is not an lvalue.
+  return CompoundAssignOperator::Create(
+  Context, LHSExpr, RHSExpr, Opc,
+  LHSExpr->getType().getUnqualifiedType(), VK_RValue, OK_Ordinary,
+  OpLoc, CurFPFeatureOverrides());
+switch (Opc) {
+case BO_Assign:
+  return BinaryOperator::Create(Context, LHSExpr, RHSExpr, Opc,
+LHSExpr->getType().getUnqualifiedType(),
+VK_RValue, OK_Ordinary, OpLoc,
+CurFPFeatureOverrides());
+case BO_LT:
+case BO_GT:
+case BO_LE:
+case BO_GE:
+case BO_EQ:
+case BO_NE:
+
+case BO_LAnd:
+case BO_LOr:
+  // These operators have a fixed result type regardless of operands.
+  return 

[PATCH] D88363: [CodeGen] Improve likelihood attribute branch weights

2020-10-05 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

Hi -- We (Sony) are running into a bit of difficulty with the test for this 
change, as it relies on the configuration of the -O1 optimisation pipeline. 
Would it be possible to reduce down to a frontend test, and then tests for 
whatever passes are to interpret the IR produced by clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88363

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


[clang] 8d51d37 - [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-10-05 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2020-10-05T17:46:44+01:00
New Revision: 8d51d37e0628bde3eb5a3200507ba7135dfc2751

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

LOG: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

Currently Flang uses TextDiagnostic, TextDiagnosticPrinter &
TestDiagnosticBuffer classes from Clang (more specifically, from
libclangFrontend). This patch introduces simplified equivalents of these
classes in Flang (i.e. it removes the dependency on libclangFrontend).

Flang only needs these diagnostics classes for the compiler driver
diagnostics. This is unlike in Clang in which similar diagnostic classes
are used for e.g. Lexing/Parsing/Sema diagnostics. For this reason, the
implementations introduced here are relatively basic. We can extend them
in the future if this is required.

This patch also enhances how the diagnostics are printed. In particular,
this is the diagnostic that you'd get _before_  the changes introduced here
(no text formatting):

```
$ bin/flang-new
error: no input files
```

This is the diagnostic that you get _after_ the changes introduced here
(in terminals that support it, the text is formatted - bold + red):

```
$ bin/flang-new
flang-new: error: no input files
```

Tests are updated accordingly and options related to enabling/disabling
color diagnostics are flagged as supported by Flang.

Reviewed By: sameeranjoshi, CarolineConcatto

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

Added: 
flang/include/flang/Frontend/TextDiagnostic.h
flang/include/flang/Frontend/TextDiagnosticBuffer.h
flang/include/flang/Frontend/TextDiagnosticPrinter.h
flang/lib/Frontend/TextDiagnostic.cpp
flang/lib/Frontend/TextDiagnosticBuffer.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp

Modified: 
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/CompilerInvocation.h
flang/lib/Frontend/CMakeLists.txt
flang/lib/Frontend/CompilerInstance.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Flang-Driver/driver-error-cc1.c
flang/test/Flang-Driver/driver-error-cc1.cpp
flang/test/Flang-Driver/driver-help.f90
flang/test/Flang-Driver/driver-version.f90
flang/test/Flang-Driver/missing-input.f90
flang/tools/flang-driver/driver.cpp
flang/tools/flang-driver/fc1_main.cpp
flang/unittests/Frontend/CompilerInstanceTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 18a123476253..e65a68c0deaa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -876,7 +876,8 @@ def fclang_abi_compat_EQ : Joined<["-"], 
"fclang-abi-compat=">, Group, MetaVarName<"">, 
Values<".,latest">,
   HelpText<"Attempt to match the ABI of Clang ">;
 def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group;
-defm color_diagnostics : OptInFFlag<"color-diagnostics", "Enable", "Disable", 
" colors in diagnostics", [CoreOption]>;
+defm color_diagnostics : OptInFFlag<"color-diagnostics", "Enable", "Disable", 
" colors in diagnostics",
+  [CoreOption, FlangOption]>;
 def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group,
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group;

diff  --git a/flang/include/flang/Frontend/CompilerInvocation.h 
b/flang/include/flang/Frontend/CompilerInvocation.h
index 0fa169fd1620..05f93293d0a5 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -11,8 +11,17 @@
 #include "flang/Frontend/FrontendOptions.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "llvm/Option/ArgList.h"
 
 namespace Fortran::frontend {
+
+/// Fill out Opts based on the options given in Args.
+///
+/// When errors are encountered, return false and, if Diags is non-null,
+/// report the error(s).
+bool ParseDiagnosticArgs(clang::DiagnosticOptions ,
+llvm::opt::ArgList , bool defaultDiagColor = true);
+
 class CompilerInvocationBase {
 public:
   /// Options controlling the diagnostic engine.$

diff  --git a/flang/include/flang/Frontend/TextDiagnostic.h 
b/flang/include/flang/Frontend/TextDiagnostic.h
new file mode 100644
index ..f803058c88c5
--- /dev/null
+++ b/flang/include/flang/Frontend/TextDiagnostic.h
@@ -0,0 +1,70 @@
+//===--- TextDiagnostic.h - Text Diagnostic Pretty-Printing -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//

[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-10-05 Thread Andrzej Warzynski 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 rG8d51d37e0628: [flang] Introduce DiagnosticConsumer classes 
in libflangFrontend (authored by awarzynski).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/TextDiagnostic.h
  flang/include/flang/Frontend/TextDiagnosticBuffer.h
  flang/include/flang/Frontend/TextDiagnosticPrinter.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/TextDiagnostic.cpp
  flang/lib/Frontend/TextDiagnosticBuffer.cpp
  flang/lib/Frontend/TextDiagnosticPrinter.cpp
  flang/test/Flang-Driver/driver-error-cc1.c
  flang/test/Flang-Driver/driver-error-cc1.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/driver-version.f90
  flang/test/Flang-Driver/missing-input.f90
  flang/tools/flang-driver/driver.cpp
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CompilerInstanceTest.cpp

Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -7,8 +7,8 @@
 //===--===//
 
 #include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "gtest/gtest.h"
 
@@ -21,7 +21,7 @@
   // 1. Set-up a basic DiagnosticConsumer
   std::string diagnosticOutput;
   llvm::raw_string_ostream diagnosticsOS(diagnosticOutput);
-  auto diagPrinter = std::make_unique(
+  auto diagPrinter = std::make_unique(
   diagnosticsOS, new clang::DiagnosticOptions());
 
   // 2. Create a CompilerInstance (to manage a DiagnosticEngine)
Index: flang/tools/flang-driver/fc1_main.cpp
===
--- flang/tools/flang-driver/fc1_main.cpp
+++ flang/tools/flang-driver/fc1_main.cpp
@@ -14,9 +14,9 @@
 
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticBuffer.h"
 #include "flang/FrontendTool/Utils.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
@@ -34,18 +34,22 @@
   if (!flang->HasDiagnostics())
 return 1;
 
+  // We will buffer diagnostics from argument parsing so that we can output
+  // them using a well formed diagnostic object.
+  TextDiagnosticBuffer *diagsBuffer = new TextDiagnosticBuffer;
+
   // Create CompilerInvocation - use a dedicated instance of DiagnosticsEngine
   // for parsing the arguments
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   llvm::IntrusiveRefCntPtr diagOpts =
   new clang::DiagnosticOptions();
-  clang::TextDiagnosticBuffer *diagsBuffer = new clang::TextDiagnosticBuffer;
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagsBuffer);
   bool success =
   CompilerInvocation::CreateFromArgs(flang->GetInvocation(), argv, diags);
 
   diagsBuffer->FlushDiagnostics(flang->getDiagnostics());
+
   if (!success)
 return 1;
 
Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -11,11 +11,12 @@
 //
 //===--===//
 #include "clang/Driver/Driver.h"
+#include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Option/ArgList.h"
@@ -23,6 +24,8 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
+using llvm::StringRef;
+
 // main frontend method. Lives inside fc1_main.cpp
 extern int fc1_main(llvm::ArrayRef argv, const char *argv0);
 
@@ -37,6 +40,17 @@
 static clang::DiagnosticOptions *CreateAndPopulateDiagOpts(
 llvm::ArrayRef argv) {
   auto *diagOpts = new clang::DiagnosticOptions;
+
+  // Ignore missingArgCount and the return value of ParseDiagnosticArgs.
+  // Any errors that would be diagnosed here will also be diagnosed later,
+  // when the DiagnosticsEngine actually exists.
+  unsigned 

[PATCH] D88594: [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

2020-10-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 296204.
jhuber6 added a comment.

Changing method of determining architecture.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88594

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/target_incompatible_architecture_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -456,6 +456,8 @@
   self.make_itanium_abi_triple(self.config.target_triple)))
 self.config.substitutions.append(('%ms_abi_triple',
   self.make_msabi_triple(self.config.target_triple)))
+self.config.substitutions.append(('%omp_powerpc_triple',
+  'powerpc' + str(64 if sys.maxsize > 2**32 else 32) + 'le-ibm-linux-gnu'))
 self.config.substitutions.append(
 ('%resource_dir', builtin_include_dir))
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP50
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP50
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=%omp_powerpc_triple -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 

[PATCH] D88754: [clang] Add a test for CGDebugInfo treatment of blocks

2020-10-05 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I think that this should either hardcode a 64-bit architecture or it shouldn't 
test for explicit offsets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88754

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


[clang] 1dce692 - Revert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload"

2020-10-05 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2020-10-05T12:35:39-04:00
New Revision: 1dce692de1896412693f25a3afb4818883a611e7

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

LOG: Revert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for 
Target Offload"

Reverting because detecting architecture size doesn't work on all
platforms.

This reverts commit eaf73293cb6b8d45dd85ffced57aea7ad4177754.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
llvm/utils/lit/lit/llvm/config.py

Removed: 
clang/test/OpenMP/target_incompatible_architecture_messages.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 29bc19e5a84e..3bf1bb19b7ae 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -253,7 +253,6 @@ def err_drv_optimization_remark_format : Error<
   "unknown remark serializer format: '%0'">;
 def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, 
please use [no]simd instead">;
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
-def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' 
pointer size is incompatible with host '%1'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index bbdf0e3be7ae..b402f53cc765 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3206,14 +3206,6 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
 TT.getArch() == llvm::Triple::x86 ||
 TT.getArch() == llvm::Triple::x86_64))
 Diags.Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
-  else if ((T.isArch64Bit() && TT.isArch32Bit()) ||
-   (T.isArch64Bit() && TT.isArch16Bit()) ||
-   (T.isArch32Bit() && TT.isArch64Bit()) ||
-   (T.isArch32Bit() && TT.isArch16Bit()) ||
-   (T.isArch16Bit() && TT.isArch32Bit()) ||
-   (T.isArch16Bit() && TT.isArch64Bit()))
-Diags.Report(diag::err_drv_incompatible_omp_arch)
-<< A->getValue(i) << T.str();
   else
 Opts.OMPTargetTriples.push_back(TT);
 }

diff  --git a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp 
b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
index 2b766f136d1d..c62832a2705f 100644
--- a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
@@ -1,19 +1,19 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=%omp_powerpc_triple -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 
-fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: 

[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

Google C++ style guide does not have this rule anymore. Thanks for the cleanup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-05 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:410-411
 setRoundingMode(LO.getFPRoundingMode());
+// FENV access is true if rounding math is enabled.
+setAllowFEnvAccess((getRoundingMode() == llvm::RoundingMode::Dynamic));
 setFPExceptionMode(LO.getFPExceptionMode());

sepavloff wrote:
> 
> I don't think this deduction is correct.
> 
> `AllowFEnvAccess` implies that user can access FP environment in a way 
> unknown to the compiler, for example by calling external functions or by 
> using inline assembler. So if `AllowFEnvAccess` is set, the compiler must 
> assume that rounding mode is dynamic, as user can set it to any value unknown 
> to the compiler. Similarly, `FPExceptionMode` must be set to strict as user 
> may read/write exception bits in any way or may associate them with traps. 
> These deductions are valid and compiler must apply them.
> 
> The reverse is not valid. `AllowFEnvAccess` is a very coarse instrument to 
> manipulate FP environment, it prevents from many optimization techniques. In 
> contrast, setting `RoundingMode` to dynamic means only that rounding mode may 
> be different from the default value. If a user changes rounding mode by calls 
> to external functions like `fesetmode` or by using some intrinsic, the 
> compiler still can, for example, reorder FP operations, if `FPExceptionMode` 
> is `ignore`. Impact of performance in this case can be minimized.
> 
> 
Thanks @sepavloff I'll make the change you recommend


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-05 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I neglected to hit the "submit" button last week, these are the inline 
questions I have.

Also in addition to the comments above, check-clang is showing 1 LIT test 
failing AST/const-fpfeatures.cpp
I believe the clang constant folder is returning False for the expression, and 
the constant folding is being done by the LLVM constant folder
llvm-project/clang/test/AST/const-fpfeatures.cpp:21:11: error: CHECK: expected 
string not found in input
// CHECK: @V1 = {{.*}} float 1.00e+00

  ^

:1:1: note: scanning from here
; ModuleID = 
'/export/iusers/mblower/sandbox/llorg/llvm-project/clang/test/AST/const-fpfeatures.cpp'
^
:24:1: note: possible intended match here
@V1 = global float 0.00e+00, align 4

The reason i think clang constant folder/my patch/ isn't to blame for faulty 
logic is because if I change the test to make V1 constexpr, there is an error 
message "not constant". So i'm not sure if the bug is in clang or the test case 
needs to be fixed?




Comment at: clang/lib/AST/ExprConstant.cpp:2734
   if (LHS.isNaN()) {
-Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN();
+Info.FFDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN();
 return Info.noteUndefinedBehavior();

This should be FFDiag?



Comment at: clang/lib/AST/ExprConstant.cpp:12302
+E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).isFPConstrained()) {
+  // Note: Compares may raise invalid in some cases involving NaN or sNaN.
+  Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);

My scribbled notes say "ISO 10967 LIA-1 
Equality returns invalid if either operand is signaling NaN
Other comparisons < <= >= > return invalid if either operand is NaN".  I'm not 
putting my hands on the exact reference. 



Comment at: clang/test/CodeGen/pragma-fenv_access.c:9
+// CHECK-LABEL: @func_01
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, 
float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+

sepavloff wrote:
> Shall the rounding mode be `dynamic` rather than `tonearest`? If `#pragma 
> STDC FENV_ACCESS ON` is specified, it means FP environment may be changed in 
> arbitrary way and we cannot expect any particular rounding mode. Probably the 
> environment was changed in the caller of `func_01`.
Yes thanks @sepavloff !  i made this change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

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


Re: [PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2020-10-05 Thread Breno Guimarães via cfe-commits
Nice! I'm glad to see the patch being revived.
Thanks for that :)

Em seg, 5 de out de 2020 10:48, fiesh via Phabricator <
revi...@reviews.llvm.org> escreveu:

> fiesh added a comment.
>
> Continued in https://reviews.llvm.org/D88833
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D31130/new/
>
> https://reviews.llvm.org/D31130
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88594: [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

2020-10-05 Thread Joseph Huber 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 rGeaf73293cb6b: [OpenMP] Add Error Handling for Conflicting 
Pointer Sizes for Target Offload (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88594

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/target_incompatible_architecture_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -456,6 +456,8 @@
   self.make_itanium_abi_triple(self.config.target_triple)))
 self.config.substitutions.append(('%ms_abi_triple',
   self.make_msabi_triple(self.config.target_triple)))
+self.config.substitutions.append(('%omp_powerpc_triple',
+  'powerpc' + str(sys.hash_info.width) + 'le-ibm-linux-gnu'))
 self.config.substitutions.append(
 ('%resource_dir', builtin_include_dir))
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP50
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP50
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=%omp_powerpc_triple -x 

[clang] eaf7329 - [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

2020-10-05 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2020-10-05T11:02:13-04:00
New Revision: eaf73293cb6b8d45dd85ffced57aea7ad4177754

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

LOG: [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target 
Offload

Summary:
This patch adds an error to Clang that detects if OpenMP offloading is
used between two architectures with incompatible pointer sizes. This
ensures that the data mapping can be done correctly and solves an issue
in code generation generating the wrong size pointer. This patch adds a
new lit substitution, %omp_powerpc_triple that, if the system is 32-bit or
64-bit, sets the powerpc triple accordingly. This was required to fix
some OpenMP tests that automatically populated the target architecture.

Reviewers: jdoerfert

Subscribers: cfe-commits guansong sstefan1 yaxunl delcypher

Tags: OpenMP clang LLVM

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

Added: 
clang/test/OpenMP/target_incompatible_architecture_messages.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3bf1bb19b7ae..29bc19e5a84e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -253,6 +253,7 @@ def err_drv_optimization_remark_format : Error<
   "unknown remark serializer format: '%0'">;
 def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, 
please use [no]simd instead">;
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
+def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' 
pointer size is incompatible with host '%1'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b402f53cc765..bbdf0e3be7ae 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3206,6 +3206,14 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
 TT.getArch() == llvm::Triple::x86 ||
 TT.getArch() == llvm::Triple::x86_64))
 Diags.Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
+  else if ((T.isArch64Bit() && TT.isArch32Bit()) ||
+   (T.isArch64Bit() && TT.isArch16Bit()) ||
+   (T.isArch32Bit() && TT.isArch64Bit()) ||
+   (T.isArch32Bit() && TT.isArch16Bit()) ||
+   (T.isArch16Bit() && TT.isArch32Bit()) ||
+   (T.isArch16Bit() && TT.isArch64Bit()))
+Diags.Report(diag::err_drv_incompatible_omp_arch)
+<< A->getValue(i) << T.str();
   else
 Opts.OMPTargetTriples.push_back(TT);
 }

diff  --git a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp 
b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
index c62832a2705f..2b766f136d1d 100644
--- a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
@@ -1,19 +1,19 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=%omp_powerpc_triple -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp 

[PATCH] D88737: [AIX] Turn -fdata-sections on by default in Clang

2020-10-05 Thread Digger via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:46
  ///< aliases to base ctors when possible.
-CODEGENOPT(DataSections  , 1, 0) ///< Set when -fdata-sections is enabled.
+CODEGENOPT(DataSections  , 1, 0) ///< Set by default, or when 
-f[no-]data-sections.
+CODEGENOPT(HasExplicitDataSections, 1, 0) ///< Set when -f[no-]data-sections 
is set.

turn on by default , it should be changed to CODEGENOPT(DataSections  , 1, 
1) ?



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

https://reviews.llvm.org/D88737

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


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-05 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:16447
+
+bool AIXBitfieldViolation = false;
+if (const BuiltinType *BTy = FieldTy.getTypePtr()->getAs()) {

Can  this change can be split out into its own patch? If it can i would suggest 
doing so.



Comment at: clang/test/Layout/aix-oversized-bitfield.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify %s
+

Is it possible to run this test as both C and C++?


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

https://reviews.llvm.org/D87029

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


[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:74
 
   auto Names = splitQualifiedName(Query);
 

Add a comment here (or elsewhere, I guess) about how qualified names are 
handled.

- exact namespace: boosted on the index side
- approximate namespace (e.g. substring): included using "all scopes" logic
- non-matching namespace (no subtring match): filtered out from index-provided 
results



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:83
+  // Boost symbols from desired namespace.
+  if (!Req.AnyScope || !Names.first.empty())
 Req.Scopes = {std::string(Names.first)};

This expression doesn't make sense (except in context of the above code). 
Variables are cheap!

```
LeadingColons = consume_front("::");
Req.AnyScope = !LeadingColons
if (LeadingColons || !Names.first.empty())
  ...
```



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:86
   if (Limit)
 Req.Limit = Limit;
   TopN Top(

Given the dynamic filter, we should request a greater multiple here (this time 
if anyscope && Names.first.empty is the right logic!)

This gives us a second class of regression :-) but we can tune the multiple to 
control it. I'd suggest 5 or so



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:93
+llvm::StringRef ScopeRef = Scope;
+// Fuzzfind might return symbols from irrelevant namespaces if query was 
not
+// fully-qualified, drop those.

nit: fuzzyfind



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:95
+// fully-qualified, drop those.
+if (!ScopeRef.contains(Names.first))
+  return;

Pull out a `approximateScopeMatch(scope, query)` or so function?

Substring isn't quite right - fine for now with a fixme, but might as well pull 
out the function now so we don't make a mess when the code grows.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:111
 Quality.merge(Sym);
 SymbolRelevanceSignals Relevance;
 Relevance.Name = Sym.Name;

Would be nice to incorporate exact vs approximate scope match here: people 
complain a lot when an exact string match ranks below an approximate one.

I don't think ScopeDistance works as-is, because it assumes the reference point 
(query) is absolute.
You could consider NeedsFixIts or applying a multiplier to NameMatch (0.3?) or 
InBaseClass (all of these are a stretch I guess)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

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


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-10-05 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: jyknight.
jdoerfert added a comment.

One minor nit from me.

@jyknight @aaron.ballman @rjmccall any more thoughts?




Comment at: clang/lib/CodeGen/CGStmt.cpp:801
+ getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 ||
+ getLangOpts().CPlusPlus17 || getLangOpts().C2x) {
+LoopMustProgress = true;

atmnpatel wrote:
> aqjune wrote:
> > A silly question: does old C/C++ not guarantee that loops should make 
> > forward progress?
> Nope, it was introduced explicitly simultaneously in C11 (6.8.5p6) and C++11 
> has it implicitly through [intro.progress].
Move this condition into a helper function somewhere with documentation. If we 
use another (similar) condition the same. This has to be updated over time and 
that way makes it much easier (also to read).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

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


[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-10-05 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi accepted this revision.
sameeranjoshi added a comment.

Thanks for patch.
Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

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


[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D88831#2311802 , @lebedev.ri wrote:

> In D88831#2311800 , @Eugene.Zelenko 
> wrote:
>
>> Does this check make sense in content of other style guides?
>
> I'd +1 to moving it to `readability`.

IMHO this check never made any sense. There **was** a //Google//-specific rule 
for this, that is why it was placed in `google` not in `readability`. 
Generally, forcing programmers not to use non-const reference parameters and 
force them the old //C// way (pointers) does not make any sense. I wonder why 
this rule was there in //Google//, but outside of it I never saw such a rule. I 
would surely not place such check into `readability` because following such 
rule reduces the readability instead of improving it. However, the main point 
is that even for //Google// there is no such rule anymore thus I see no point 
to keep this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[PATCH] D88594: [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

2020-10-05 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM, a new triple makes sense here, we don't support arbitrary combinations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88594

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


[PATCH] D88829: [OpenMP][RTL] Remove dead code

2020-10-05 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.

Thanks guys, will remember that as the local convention on rolling whitespace 
changes into other stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88829

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


[PATCH] D88829: [OpenMP][RTL] Remove dead code

2020-10-05 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for removing dead code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88829

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


[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D88831#2311800 , @Eugene.Zelenko 
wrote:

> Does this check make sense in content of other style guides?

I'd +1 to moving it to `readability`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Does this check make sense in content of other style guides?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88831

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


[PATCH] D88789: [InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

2020-10-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 296173.
lebedev.ri added a comment.

NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88789

Files:
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/loadstore-metadata.ll
  llvm/test/Transforms/InstCombine/non-integral-pointers.ll
  llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll

Index: llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
===
--- llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
+++ llvm/test/Transforms/PhaseOrdering/instcombine-sroa-inttoptr.ll
@@ -50,10 +50,10 @@
 define dso_local void @_Z3gen1S(%0* noalias sret align 8 %arg, %0* byval(%0) align 8 %arg1) {
 ; CHECK-LABEL: @_Z3gen1S(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast %0* [[ARG1:%.*]] to i64*
-; CHECK-NEXT:[[I21:%.*]] = load i64, i64* [[TMP0]], align 8
-; CHECK-NEXT:[[TMP1:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:store i64 [[I21]], i64* [[TMP1]], align 8
+; CHECK-NEXT:[[I:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG1:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I2:%.*]] = load i32*, i32** [[I]], align 8
+; CHECK-NEXT:[[I3:%.*]] = getelementptr inbounds [[TMP0]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:store i32* [[I2]], i32** [[I3]], align 8
 ; CHECK-NEXT:ret void
 ;
 bb:
@@ -68,13 +68,12 @@
 ; CHECK-LABEL: @_Z3foo1S(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:[[I2:%.*]] = alloca [[TMP0:%.*]], align 8
-; CHECK-NEXT:[[I1_SROA_0_0_I5_SROA_CAST:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i64, i64* [[I1_SROA_0_0_I5_SROA_CAST]], align 8
-; CHECK-NEXT:[[I_SROA_0_0_I6_SROA_CAST:%.*]] = bitcast %0* [[I2]] to i64*
-; CHECK-NEXT:store i64 [[I1_SROA_0_0_COPYLOAD]], i64* [[I_SROA_0_0_I6_SROA_CAST]], align 8
+; CHECK-NEXT:[[I1_SROA_0_0_I5_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I5_SROA_IDX]], align 8
+; CHECK-NEXT:[[I_SROA_0_0_I6_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0]], %0* [[I2]], i64 0, i32 0
+; CHECK-NEXT:store i32* [[I1_SROA_0_0_COPYLOAD]], i32** [[I_SROA_0_0_I6_SROA_IDX]], align 8
 ; CHECK-NEXT:tail call void @_Z7escape01S(%0* nonnull byval(%0) align 8 [[I2]])
-; CHECK-NEXT:[[TMP0]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:ret i32* [[TMP0]]
+; CHECK-NEXT:ret i32* [[I1_SROA_0_0_COPYLOAD]]
 ;
 bb:
   %i = alloca %0, align 8
@@ -108,24 +107,21 @@
 define dso_local i32* @_Z3bar1S(%0* byval(%0) align 8 %arg) {
 ; CHECK-LABEL: @_Z3bar1S(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:[[I1_SROA_0_0_I4_SROA_CAST:%.*]] = bitcast %0* [[ARG:%.*]] to i64*
-; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i64, i64* [[I1_SROA_0_0_I4_SROA_CAST]], align 8
+; CHECK-NEXT:[[I1_SROA_0_0_I4_SROA_IDX:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG:%.*]], i64 0, i32 0
+; CHECK-NEXT:[[I1_SROA_0_0_COPYLOAD:%.*]] = load i32*, i32** [[I1_SROA_0_0_I4_SROA_IDX]], align 8
 ; CHECK-NEXT:[[I5:%.*]] = tail call i32 @_Z4condv()
 ; CHECK-NEXT:[[I6_NOT:%.*]] = icmp eq i32 [[I5]], 0
 ; CHECK-NEXT:br i1 [[I6_NOT]], label [[BB10:%.*]], label [[BB7:%.*]]
 ; CHECK:   bb7:
 ; CHECK-NEXT:tail call void @_Z5sync0v()
-; CHECK-NEXT:[[TMP0:%.*]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:tail call void @_Z7escape0Pi(i32* [[TMP0]])
+; CHECK-NEXT:tail call void @_Z7escape0Pi(i32* [[I1_SROA_0_0_COPYLOAD]])
 ; CHECK-NEXT:br label [[BB13:%.*]]
 ; CHECK:   bb10:
 ; CHECK-NEXT:tail call void @_Z5sync1v()
-; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i64 [[I1_SROA_0_0_COPYLOAD]] to i32*
-; CHECK-NEXT:tail call void @_Z7escape1Pi(i32* [[TMP1]])
+; CHECK-NEXT:tail call void @_Z7escape1Pi(i32* [[I1_SROA_0_0_COPYLOAD]])
 ; CHECK-NEXT:br label [[BB13]]
 ; CHECK:   bb13:
-; CHECK-NEXT:[[DOTPRE_PHI:%.*]] = phi i32* [ [[TMP1]], [[BB10]] ], [ [[TMP0]], [[BB7]] ]
-; CHECK-NEXT:ret i32* [[DOTPRE_PHI]]
+; CHECK-NEXT:ret i32* [[I1_SROA_0_0_COPYLOAD]]
 ;
 bb:
   %i = alloca %0, align 8
Index: llvm/test/Transforms/InstCombine/non-integral-pointers.ll
===
--- llvm/test/Transforms/InstCombine/non-integral-pointers.ll
+++ llvm/test/Transforms/InstCombine/non-integral-pointers.ll
@@ -41,10 +41,8 @@
 ; integers, since pointers in address space 3 are integral.
 ; CHECK-LABEL: 

[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2020-10-05 Thread fiesh via Phabricator via cfe-commits
fiesh added a comment.

Continued in https://reviews.llvm.org/D88833


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

https://reviews.llvm.org/D31130

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


[PATCH] D88833: Do not warn on pointer decays in system macros

2020-10-05 Thread fiesh via Phabricator via cfe-commits
fiesh created this revision.
fiesh added a reviewer: aaron.ballman.
fiesh added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, kbarton, nemanjai.
Herald added a project: clang.
fiesh requested review of this revision.

As system headers are in general out of reach, it makes no sense to warn on 
pointer decays happening in them.

This is a reboot of https://reviews.llvm.org/D31130
It is essentially unchanged, only updated to the new repository as well as 
minor API changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88833

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/cppcoreguidelines-pro-bounds-array-to-pointer-decay/macro.h
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-array-to-pointer-decay %t -- -- -isystem%S/Inputs/cppcoreguidelines-pro-bounds-array-to-pointer-decay
+
+#include 
 #include 
 
 namespace gsl {
@@ -8,7 +10,7 @@
   template 
   array_view(U ()[N]);
 };
-}
+} // namespace gsl
 
 void pointerfun(int *p);
 void arrayfun(int p[]);
@@ -29,9 +31,9 @@
   gsl::array_view av(a);
   arrayviewfun(av); // OK
 
-  int i = a[0];  // OK
-  int j = a[(1 + 2)];// OK
-  pointerfun([0]); // OK
+  int i = a[0];   // OK
+  int j = a[(1 + 2)]; // OK
+  pointerfun([0]);  // OK
 
   for (auto  : a) // OK, iteration internally decays array to pointer
 e = 1;
@@ -41,11 +43,53 @@
   return "clang"; // OK, decay string literal to pointer
 }
 const char *g2() {
-return ("clang"); // OK, ParenExpr hides the literal-pointer decay
+  return ("clang"); // OK, ParenExpr hides the literal-pointer decay
 }
 
 void f2(void *const *);
 void bug25362() {
   void *a[2];
-  f2(static_cast(a)); // OK, explicit cast
+  f2(static_cast(a)); // OK, explicit cast
+}
+
+void user_fn_decay_str(const char *);
+void user_fn_decay_int_array(const int *);
+void bug32239() {
+  sys_macro_with_pretty_function_string_decay; // Ok
+  sys_macro_with_sys_string_decay; // Ok
+  sys_macro_with_sys_int_array_decay;  // Ok
+
+  sys_fn_decay_str(__PRETTY_FUNCTION__); // Ok
+
+  sys_fn_decay_str(SYS_STRING); // Not Ok - should it be ok?
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  sys_fn_decay_int_array(SYS_INT_ARRAY); // Not Ok
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  user_code_in_sys_macro(sys_fn_decay_str(__PRETTY_FUNCTION__)); // Ok
+
+  user_code_in_sys_macro(sys_fn_decay_str(SYS_STRING)); // Not Ok - should it be ok?
+  // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  user_code_in_sys_macro(sys_fn_decay_int_array(SYS_INT_ARRAY)); // Not Ok
+  // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  const char UserString[1] = "";
+  decay_to_char_pointer_in_macro(UserString); // Not Ok
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  decay_to_char_pointer_in_macro(__PRETTY_FUNCTION__); // Ok
+
+  int a[5];
+  decay_to_int_pointer_in_macro(a); // Not Ok
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  user_fn_decay_str(__PRETTY_FUNCTION__); // Ok
+
+  user_fn_decay_str(SYS_STRING); // Not Ok - should it be ok?
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+
+  user_fn_decay_int_array(SYS_INT_ARRAY); // Not ok
+  // CHECK-MESSAGES: 

[PATCH] D88829: [OpenMP][RTL] Remove dead code

2020-10-05 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

In D88829#2311768 , @JonChesterfield 
wrote:

> Rolling the reduction in leading whitespace in 
> nvptx_target_parallel_reduction_codegen.cpp in with the patch might be 
> contentious, added a couple more reviewers to see if other people would 
> prefer that part split out. I'll accept in a day or so if there are no 
> comments on the whitespace.

Fine by me, I don't think it's worth uploading an extra patch just for this 
minor formatting detail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88829

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


[PATCH] D88829: [OpenMP][RTL] Remove dead code

2020-10-05 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Change looks great to me.

Rolling the reduction in leading whitespace in 
nvptx_target_parallel_reduction_codegen.cpp in with the patch might be 
contentious, added a couple more reviewers to see if other people would prefer 
that part split out. I'll accept in a day or so if there are no comments on the 
whitespace.

Thanks!




Comment at: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu:135
 "%d threads\n",
 (int)newTaskDescr->ThreadId(), (int)ThreadLimit);
 }

This is interesting. This turns out to be the only call to RootS(), and that 
cascades through a bunch of other code removed in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88829

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


[PATCH] D88831: [clang-tidy] Remove obsolete checker google-runtime-references

2020-10-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: alexfh, gribozavr2, aaron.ballman.
baloghadamsoftware added a project: clang-tools-extra.
Herald added subscribers: martong, Charusso, gamesh411, Szelethus, dkrupp, 
rnkovacs, xazax.hun, whisperity, mgorny.
Herald added a project: clang.
baloghadamsoftware requested review of this revision.

The rules which is the base of this checker is removed from the //Google C++ 
Style Guide// in May: Update C++ styleguide 
. Now this checker became 
obsolete.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88831

Files:
  clang-tools-extra/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/clang-tidy/google/NonConstReferences.cpp
  clang-tools-extra/clang-tidy/google/NonConstReferences.h
  clang-tools-extra/docs/clang-tidy/checks/google-runtime-references.rst
  clang-tools-extra/test/clang-tidy/checkers/google-runtime-references.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/google-runtime-references.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-runtime-references.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-// RUN: %check_clang_tidy %s google-runtime-references %t -- \
-// RUN:   -config="{CheckOptions: \
-// RUN: [{key: google-runtime-references.IncludedTypes, \
-// RUN:   value: 'included::A; included::B'}]}"
-
-int a;
-int  = a;
-int *c;
-void f1(int a);
-void f2(int *b);
-void f3(const int );
-void f4(int const );
-
-// Don't warn on implicit operator= in c++11 mode.
-class A {
-  virtual void f() {}
-};
-// Don't warn on rvalue-references.
-struct A2 {
-  A2(A2&&) = default;
-  void f(A2&&) {}
-};
-
-// Don't warn on iostream parameters.
-namespace xxx {
-class istream { };
-class ostringstream { };
-}
-void g1(xxx::istream );
-void g1(xxx::ostringstream );
-
-void g1(int );
-// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', make it const or use a pointer [google-runtime-references]
-
-struct s {};
-void g2(int a, int b, s c, s );
-// CHECK-MESSAGES: [[@LINE-1]]:31: warning: non-const reference parameter 'd', {{.*}}
-
-typedef int 
-void g3(ref a);
-// CHECK-MESSAGES: [[@LINE-1]]:13: warning: non-const reference {{.*}}
-
-void g4(int , int , int &);
-// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', {{.*}}
-// CHECK-MESSAGES: [[@LINE-2]]:22: warning: non-const reference parameter 'b', {{.*}}
-// CHECK-MESSAGES: [[@LINE-3]]:30: warning: non-const reference parameter at index 2, {{.*}}
-
-class B {
-  B(B& a) {}
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: non-const reference {{.*}}
-  virtual void f(int ) {}
-// CHECK-MESSAGES: [[@LINE-1]]:23: warning: non-const reference {{.*}}
-  void g(int );
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: non-const reference {{.*}}
-
-  // Don't warn on the parameter of stream extractors defined as members.
-  B& operator>>(int& val) { return *this; }
-};
-
-// Only warn on the first declaration of each function to reduce duplicate
-// warnings.
-void B::g(int ) {}
-
-// Don't warn on the first parameter of stream inserters.
-A& operator<<(A& s, int&) { return s; }
-// CHECK-MESSAGES: [[@LINE-1]]:25: warning: non-const reference parameter at index 1, {{.*}}
-
-// Don't warn on either parameter of stream extractors. Both need to be
-// non-const references by convention.
-A& operator>>(A& input, int& val) { return input; }
-
-// Don't warn on lambdas.
-auto lambda = [] (int&) {};
-
-// Don't warn on typedefs, as we'll warn on the function itself.
-typedef int (*fp)(int &);
-
-// Don't warn on function references.
-typedef void F();
-void g5(const F& func) {}
-void g6(F& func) {}
-
-template
-void g7(const T& t) {}
-
-template
-void g8(T t) {}
-
-void f5() {
-  g5(f5);
-  g6(f5);
-  g7(f5);
-  g7(f5);
-  g8(f5);
-  g8(f5);
-}
-
-// Don't warn on dependent types.
-template
-void g9(T& t) {}
-template
-void g10(T t) {}
-
-void f6() {
-  int i;
-  float f;
-  g9(i);
-  g9(i);
-  g9(i);
-  g10(i);
-  g10(f);
-}
-
-// Warn only on the overridden methods from the base class, as the child class
-// only implements the interface.
-class C : public B {
-  C();
-  virtual void f(int ) {}
-};
-
-// Don't warn on operator<< with streams-like interface.
-A& operator<<(A& s, int) { return s; }
-
-// Don't warn on swap().
-void swap(C& c1, C& c2) {}
-
-// Don't warn on standalone operator++, operator--, operator+=, operator-=,
-// operator*=, etc. that all need non-const references to be functional.
-A& operator++(A& a) { return a; }
-A operator++(A& a, int) { return a; }
-A& operator--(A& a) { return a; }
-A operator--(A& a, int) { return a; }
-A& operator+=(A& a, const A& b) { return a; }
-A& operator-=(A& a, const A& b) { return a; }
-A& operator*=(A& a, const A& b) { return a; }
-A& operator/=(A& a, const A& b) { return a; }
-A& 

[clang] 7a932f4 - [Parser] ParseMicrosoftAsmStatement - Replace bit '|' operator with logical '||' operator. (PR47071)

2020-10-05 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-05T14:23:28+01:00
New Revision: 7a932f4f4ccbc0c4294c6911d404f74529f3259b

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

LOG: [Parser] ParseMicrosoftAsmStatement - Replace bit '|' operator with 
logical '||' operator. (PR47071)

Fixes static analysis warning.

Added: 


Modified: 
clang/lib/Parse/ParseStmtAsm.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseStmtAsm.cpp 
b/clang/lib/Parse/ParseStmtAsm.cpp
index 7d0818840a4f..bdf40c291cb6 100644
--- a/clang/lib/Parse/ParseStmtAsm.cpp
+++ b/clang/lib/Parse/ParseStmtAsm.cpp
@@ -581,7 +581,7 @@ StmtResult 
Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
   std::unique_ptr STI(
   TheTarget->createMCSubtargetInfo(TT, TO.CPU, FeaturesStr));
   // Target MCTargetDesc may not be linked in clang-based tools.
-  if (!MAI || !MII | !MOFI || !STI) {
+  if (!MAI || !MII || !MOFI || !STI) {
 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
 << "target MC unavailable";
 return EmptyStmt();



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


[PATCH] D88810: [clangd] Add isKeyword function.

2020-10-05 Thread Haojian Wu 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 rG1425c7223676: [clangd] Add isKeyword function. (authored by 
hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88810

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -789,6 +789,19 @@
   EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
 }
 
+TEST(SourceCodeTests, isKeywords) {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus20 = true;
+  EXPECT_TRUE(isKeyword("int", LangOpts));
+  EXPECT_TRUE(isKeyword("return", LangOpts));
+  EXPECT_TRUE(isKeyword("co_await", LangOpts));
+
+  // these are identifiers (not keywords!) with special meaning in some
+  // contexts.
+  EXPECT_FALSE(isKeyword("final", LangOpts));
+  EXPECT_FALSE(isKeyword("override", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -248,6 +248,10 @@
   const LangOptions );
 };
 
+/// Return true if the \p TokenName is in the list of reversed keywords of the
+/// language.
+bool isKeyword(llvm::StringRef TokenName, const LangOptions );
+
 /// Heuristically determine namespaces visible at a point, without parsing 
Code.
 /// This considers using-directives and enclosing namespace-declarations that
 /// are visible (and not obfuscated) in the file itself (not headers).
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -633,6 +633,12 @@
   return Ranges;
 }
 
+bool isKeyword(llvm::StringRef NewName, const LangOptions ) {
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();
+}
+
 namespace {
 struct NamespaceEvent {
   enum {


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -789,6 +789,19 @@
   EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
 }
 
+TEST(SourceCodeTests, isKeywords) {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus20 = true;
+  EXPECT_TRUE(isKeyword("int", LangOpts));
+  EXPECT_TRUE(isKeyword("return", LangOpts));
+  EXPECT_TRUE(isKeyword("co_await", LangOpts));
+
+  // these are identifiers (not keywords!) with special meaning in some
+  // contexts.
+  EXPECT_FALSE(isKeyword("final", LangOpts));
+  EXPECT_FALSE(isKeyword("override", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -248,6 +248,10 @@
   const LangOptions );
 };
 
+/// Return true if the \p TokenName is in the list of reversed keywords of the
+/// language.
+bool isKeyword(llvm::StringRef TokenName, const LangOptions );
+
 /// Heuristically determine namespaces visible at a point, without parsing Code.
 /// This considers using-directives and enclosing namespace-declarations that
 /// are visible (and not obfuscated) in the file itself (not headers).
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -633,6 +633,12 @@
   return Ranges;
 }
 
+bool isKeyword(llvm::StringRef NewName, const LangOptions ) {
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();
+}
+
 namespace {
 struct NamespaceEvent {
   enum {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 1425c72 - [clangd] Add isKeyword function.

2020-10-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-05T15:11:24+02:00
New Revision: 1425c72236766ad9107d86cb645ee8c6a3ee0eb1

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

LOG: [clangd] Add isKeyword function.

This will be used in rename for doing basic name validation.

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

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 0432097b4348..c6279177eba9 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -633,6 +633,12 @@ std::vector collectIdentifierRanges(llvm::StringRef 
Identifier,
   return Ranges;
 }
 
+bool isKeyword(llvm::StringRef NewName, const LangOptions ) {
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();
+}
+
 namespace {
 struct NamespaceEvent {
   enum {

diff  --git a/clang-tools-extra/clangd/SourceCode.h 
b/clang-tools-extra/clangd/SourceCode.h
index 128f985a5266..be78e2f86436 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -248,6 +248,10 @@ struct SpelledWord {
   const LangOptions );
 };
 
+/// Return true if the \p TokenName is in the list of reversed keywords of the
+/// language.
+bool isKeyword(llvm::StringRef TokenName, const LangOptions );
+
 /// Heuristically determine namespaces visible at a point, without parsing 
Code.
 /// This considers using-directives and enclosing namespace-declarations that
 /// are visible (and not obfuscated) in the file itself (not headers).

diff  --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 9c3ae4df51ff..c05515f2c094 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -789,6 +789,19 @@ TEST(SourceCodeTests, isHeaderFile) {
   EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
 }
 
+TEST(SourceCodeTests, isKeywords) {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus20 = true;
+  EXPECT_TRUE(isKeyword("int", LangOpts));
+  EXPECT_TRUE(isKeyword("return", LangOpts));
+  EXPECT_TRUE(isKeyword("co_await", LangOpts));
+
+  // these are identifiers (not keywords!) with special meaning in some
+  // contexts.
+  EXPECT_FALSE(isKeyword("final", LangOpts));
+  EXPECT_FALSE(isKeyword("override", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D88810: [clangd] Add isKeyword function.

2020-10-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:638
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();

sammccall wrote:
> this builds a pretty decent sized hashtable for each call, because LangOpts 
> isn't constant.
> 
> We could consider exposing getKeywordStatus from IdentifierTable.h, then we 
> could build a StringMap (once, statically) and then call 
> getKeywordStatus to apply the per-langopts logic.
> In fact that StringMap might also be generally nice to expose in 
> TokenKinds.h... as long as there are no conflicts.
> 
> Or we could have cache map from LangOpts to IdentifierTable, since we won't 
> see many sets in practice.
> 
> Or maybe it doesn't matter, I suppose!
> Or maybe it doesn't matter, I suppose!
this is my impression as well, there are ~120 keywords for C++, I think the 
number is not too big.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88810

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


[PATCH] D88810: [clangd] Add isKeyword function.

2020-10-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 296168.
hokein marked an inline comment as done.
hokein added a comment.

address code comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88810

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -789,6 +789,19 @@
   EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
 }
 
+TEST(SourceCodeTests, isKeywords) {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus20 = true;
+  EXPECT_TRUE(isKeyword("int", LangOpts));
+  EXPECT_TRUE(isKeyword("return", LangOpts));
+  EXPECT_TRUE(isKeyword("co_await", LangOpts));
+
+  // these are identifiers (not keywords!) with special meaning in some
+  // contexts.
+  EXPECT_FALSE(isKeyword("final", LangOpts));
+  EXPECT_FALSE(isKeyword("override", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -248,6 +248,10 @@
   const LangOptions );
 };
 
+/// Return true if the \p TokenName is in the list of reversed keywords of the
+/// language.
+bool isKeyword(llvm::StringRef TokenName, const LangOptions );
+
 /// Heuristically determine namespaces visible at a point, without parsing 
Code.
 /// This considers using-directives and enclosing namespace-declarations that
 /// are visible (and not obfuscated) in the file itself (not headers).
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -633,6 +633,12 @@
   return Ranges;
 }
 
+bool isKeyword(llvm::StringRef NewName, const LangOptions ) {
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();
+}
+
 namespace {
 struct NamespaceEvent {
   enum {


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -789,6 +789,19 @@
   EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
 }
 
+TEST(SourceCodeTests, isKeywords) {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus20 = true;
+  EXPECT_TRUE(isKeyword("int", LangOpts));
+  EXPECT_TRUE(isKeyword("return", LangOpts));
+  EXPECT_TRUE(isKeyword("co_await", LangOpts));
+
+  // these are identifiers (not keywords!) with special meaning in some
+  // contexts.
+  EXPECT_FALSE(isKeyword("final", LangOpts));
+  EXPECT_FALSE(isKeyword("override", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -248,6 +248,10 @@
   const LangOptions );
 };
 
+/// Return true if the \p TokenName is in the list of reversed keywords of the
+/// language.
+bool isKeyword(llvm::StringRef TokenName, const LangOptions );
+
 /// Heuristically determine namespaces visible at a point, without parsing Code.
 /// This considers using-directives and enclosing namespace-declarations that
 /// are visible (and not obfuscated) in the file itself (not headers).
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -633,6 +633,12 @@
   return Ranges;
 }
 
+bool isKeyword(llvm::StringRef NewName, const LangOptions ) {
+  // Keywords are initialized in constructor.
+  clang::IdentifierTable KeywordsTable(LangOpts);
+  return KeywordsTable.find(NewName) != KeywordsTable.end();
+}
+
 namespace {
 struct NamespaceEvent {
   enum {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84226: [AST][RecoveryExpr] Part1: Support dependent binary operator in C for error recovery.

2020-10-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/ASTContext.h:668
 
+  // clang's C-only codepath doesn't support dependent types yet, it is used to
+  // perform early typo correction for C.

This is a bit hard to follow.
I think it's two separate sentences, and the second is something like
"If this condition is false, typo correction must be performed eagerly rather 
than delayed in many places, as it makes use of dependent types".



Comment at: clang/lib/Sema/SemaExpr.cpp:14365
+   "Should only occur in error-recovery path.");
+if (BinaryOperator::isCompoundAssignmentOp(Opc))
+  return CompoundAssignOperator::Create(

isAssignmentOp instead? including = itself



Comment at: clang/lib/Sema/SemaExpr.cpp:14383
+Context.IntTy, VK_RValue, OK_Ordinary,
+OpLoc, CurFPFeatureOverrides());
+default:

comma could get the RHS :-)
May get some mileage for comma operators in macros, not sure though.

(Other aspect is value category: fortunately *in C* comma is an rvalue)



Comment at: clang/test/AST/ast-dump-recovery.c:45
   int* ptr;
-  // FIXME: the top-level expr should be a binary operator.
-  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
-  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
-  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
-  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
-  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK: BinaryOperator {{.*}} contains-errors '='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'

`'int *' lvalue contains-errors '='`



Comment at: clang/test/AST/ast-dump-recovery.c:52
+  int compoundOp;
+  // CHECK: CompoundAssignOperator {{.*}} '+='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'compoundOp'

`'int' lvalue contains-errors '+='`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226

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


[PATCH] D88828: [clangd] Verify the diagnostic code in include-fixer diagnostic tests, NFC.

2020-10-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, but can you add some description about why you've decided to do it now :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88828

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


[PATCH] D88828: [clangd] Verify the diagnostic code in include-fixer diagnostic tests, NFC.

2020-10-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88828

Files:
  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
@@ -720,13 +720,16 @@
   UnorderedElementsAre(
   AllOf(Diag(Test.range("nested"),
  "incomplete type 'ns::X' named in nested name specifier"),
+DiagName("incomplete_nested_name_spec"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
   AllOf(Diag(Test.range("base"), "base class has incomplete type"),
+DiagName("incomplete_base_class"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
   AllOf(Diag(Test.range("access"),
  "member access into incomplete type 'ns::X'"),
+DiagName("incomplete_member_access"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X");
 }
@@ -789,19 +792,23 @@
   TU.build().getDiagnostics(),
   UnorderedElementsAre(
   AllOf(Diag(Test.range("unqualified1"), "unknown type name 'X'"),
+DiagName("unknown_typename"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
   Diag(Test.range("unqualified2"), "use of undeclared identifier 'X'"),
   AllOf(Diag(Test.range("qualified1"),
  "no type named 'X' in namespace 'ns'"),
+DiagName("typename_nested_not_found"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
   AllOf(Diag(Test.range("qualified2"),
  "no member named 'X' in namespace 'ns'"),
+DiagName("no_member"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
   AllOf(Diag(Test.range("global"),
  "no type named 'Global' in the global namespace"),
+DiagName("typename_nested_not_found"),
 WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
 "Add include \"global.h\" for symbol Global");
 }
@@ -825,6 +832,7 @@
   EXPECT_THAT(TU.build().getDiagnostics(),
   UnorderedElementsAre(AllOf(
   Diag(Test.range("unqualified"), "unknown type name 'X'"),
+  DiagName("unknown_typename"),
   WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
   "Add include \"a.h\" for symbol na::X"),
   Fix(Test.range("insert"), "#include \"b.h\"\n",
@@ -905,6 +913,7 @@
   TU.build().getDiagnostics(),
   UnorderedElementsAre(AllOf(
   Diag(Test.range(), "no member named 'scope' in namespace 'ns'"),
+  DiagName("no_member"),
   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
   "Add include \"x.h\" for symbol ns::scope::X_Y");
 }
@@ -934,22 +943,26 @@
   AllOf(
   Diag(Test.range("q1"), "use of undeclared identifier 'clangd'; "
  "did you mean 'clang'?"),
+  DiagName("undeclared_var_use_suggest"),
   WithFix(_, // change clangd to clang
   Fix(Test.range("insert"), "#include \"x.h\"\n",
   "Add include \"x.h\" for symbol clang::clangd::X"))),
   AllOf(
   Diag(Test.range("x"), "no type named 'X' in namespace 'clang'"),
+  DiagName("typename_nested_not_found"),
   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
   "Add include \"x.h\" for symbol clang::clangd::X"))),
   AllOf(
   Diag(Test.range("q2"), "use of undeclared identifier 'clangd'; "
  "did you mean 'clang'?"),
+  DiagName("undeclared_var_use_suggest"),
   WithFix(
-  _, // change clangd to clangd
+  _, // change clangd to clang
   Fix(Test.range("insert"), "#include \"y.h\"\n",
   "Add include \"y.h\" for symbol 

[clang] 007dd12 - [ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl

2020-10-05 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-10-05T14:06:09+02:00
New Revision: 007dd12d546814977519b33ca38b1cc8b31fee26

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

LOG: [ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl

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

Added: 


Modified: 
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/test/ASTMerge/struct/test.c
clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 98e1b7eeb8c4..2bc5f39b817e 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1256,48 +1256,9 @@ static bool 
IsStructurallyEquivalent(StructuralEquivalenceContext ,
 return false;
   }
 
-  if (Field1->isBitField() != Field2->isBitField()) {
-if (Context.Complain) {
-  Context.Diag2(
-  Owner2->getLocation(),
-  Context.getApplicableDiagnostic(diag::err_odr_tag_type_inconsistent))
-  << Context.ToCtx.getTypeDeclType(Owner2);
-  if (Field1->isBitField()) {
-Context.Diag1(Field1->getLocation(), diag::note_odr_bit_field)
-<< Field1->getDeclName() << Field1->getType()
-<< Field1->getBitWidthValue(Context.FromCtx);
-Context.Diag2(Field2->getLocation(), diag::note_odr_not_bit_field)
-<< Field2->getDeclName();
-  } else {
-Context.Diag2(Field2->getLocation(), diag::note_odr_bit_field)
-<< Field2->getDeclName() << Field2->getType()
-<< Field2->getBitWidthValue(Context.ToCtx);
-Context.Diag1(Field1->getLocation(), diag::note_odr_not_bit_field)
-<< Field1->getDeclName();
-  }
-}
-return false;
-  }
-
-  if (Field1->isBitField()) {
-// Make sure that the bit-fields are the same length.
-unsigned Bits1 = Field1->getBitWidthValue(Context.FromCtx);
-unsigned Bits2 = Field2->getBitWidthValue(Context.ToCtx);
-
-if (Bits1 != Bits2) {
-  if (Context.Complain) {
-Context.Diag2(Owner2->getLocation(),
-  Context.getApplicableDiagnostic(
-  diag::err_odr_tag_type_inconsistent))
-<< Context.ToCtx.getTypeDeclType(Owner2);
-Context.Diag2(Field2->getLocation(), diag::note_odr_bit_field)
-<< Field2->getDeclName() << Field2->getType() << Bits2;
-Context.Diag1(Field1->getLocation(), diag::note_odr_bit_field)
-<< Field1->getDeclName() << Field1->getType() << Bits1;
-  }
-  return false;
-}
-  }
+  if (Field1->isBitField())
+return IsStructurallyEquivalent(Context, Field1->getBitWidth(),
+Field2->getBitWidth());
 
   return true;
 }

diff  --git a/clang/test/ASTMerge/struct/test.c 
b/clang/test/ASTMerge/struct/test.c
index 9ac66d17f60e..3e11dd9e07a8 100644
--- a/clang/test/ASTMerge/struct/test.c
+++ b/clang/test/ASTMerge/struct/test.c
@@ -21,16 +21,6 @@
 // CHECK: struct1.c:27:8: note: no corresponding field here
 // CHECK: struct2.c:24:31: warning: external variable 'x4' declared with 
incompatible types in 
diff erent translation units ('struct S4' vs. 'struct S4')
 // CHECK: struct1.c:27:22: note: declared here with type 'struct S4'
-// CHECK: struct1.c:33:8: warning: type 'struct S6' has incompatible 
definitions in 
diff erent translation units
-// CHECK: struct1.c:33:33: note: bit-field 'j' with type 'unsigned int' and 
length 8 here
-// CHECK: struct2.c:30:33: note: field 'j' is not a bit-field
-// CHECK: struct2.c:30:38: warning: external variable 'x6' declared with 
incompatible types in 
diff erent translation units ('struct S6' vs. 'struct S6')
-// CHECK: struct1.c:33:42: note: declared here with type 'struct S6'
-// CHECK: struct1.c:36:8: warning: type 'struct S7' has incompatible 
definitions in 
diff erent translation units
-// CHECK: struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and 
length 8 here
-// CHECK: struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and 
length 16 here
-// CHECK: struct2.c:33:43: warning: external variable 'x7' declared with 
incompatible types in 
diff erent translation units ('struct S7' vs. 'struct S7')
-// CHECK: struct1.c:36:42: note: declared here with type 'struct S7'
 // CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible 
definitions in 
diff erent translation units
 // CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
 // CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
@@ -52,4 +42,4 @@
 // CHECK: struct2.c:129:9: note: field 'S' has type 'struct (anonymous struct 
at [[PATH_TO_INPUTS]]struct2.c:127:7)' here
 // CHECK: 

[PATCH] D88745: [clangd][WIP] Add new code completion signals to improve MRR by 3%.

2020-10-05 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 296159.
usaxena95 edited the summary of this revision.
usaxena95 added a comment.

Updated the references to old signals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88745

Files:
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  
clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json

Index: clang-tools-extra/clangd/quality/model/features.json
===
--- clang-tools-extra/clangd/quality/model/features.json
+++ clang-tools-extra/clangd/quality/model/features.json
@@ -20,7 +20,7 @@
 "kind": "NUMBER"
 },
 {
-"name": "IsNameInContext",
+"name": "NumNameInContext",
 "kind": "NUMBER"
 },
 {
@@ -63,6 +63,10 @@
 "name": "TypeMatchesPreferred",
 "kind": "NUMBER"
 },
+{
+"name": "SemaPriority",
+"kind": "NUMBER"
+},
 {
 "name": "SymbolCategory",
 "kind": "ENUM",
@@ -81,4 +85,4 @@
 "type": "clang::clangd::SymbolRelevanceSignals::AccessibleScope",
 "header": "Quality.h"
 }
-]
\ No newline at end of file
+]
Index: clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
===
--- clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
+++ clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
@@ -39,7 +39,7 @@
 E.setNumReferences(RandInt(1)); // Can be large integer.
 E.setSymbolCategory(RandInt(10));   // 10 Symbol Category.
 
-E.setIsNameInContext(FlipCoin(0.5)); // Boolean.
+E.setNumNameInContext(RandInt(5));   // Boolean.
 E.setIsForbidden(FlipCoin(0.1)); // Boolean.
 E.setIsInBaseClass(FlipCoin(0.3));   // Boolean.
 E.setFileProximityDistance(
@@ -57,6 +57,7 @@
 E.setHadSymbolType(FlipCoin(0.6));// Boolean.
 E.setTypeMatchesPreferred(FlipCoin(0.5)); // Boolean.
 E.setFilterLength(RandInt(15));
+E.setSemaPriority(RandInt(100));
 Examples.push_back(E);
   }
   return Examples;
Index: clang-tools-extra/clangd/Quality.h
===
--- clang-tools-extra/clangd/Quality.h
+++ clang-tools-extra/clangd/Quality.h
@@ -140,11 +140,14 @@
   /// CompletionPrefix.
   unsigned FilterLength = 0;
 
+  /// Priority of the completion item as computed by Sema.
+  unsigned SemaPriority = 0;
+
   /// Set of derived signals computed by calculateDerivedSignals(). Must not be
   /// set explicitly.
   struct DerivedSignals {
-/// Whether Name contains some word from context.
-bool NameMatchesContext = false;
+/// Number of words in Context that matches Name.
+unsigned NumNameInContext = 0;
 /// Min distance between SymbolURI and all the headers included by the TU.
 unsigned FileProximityDistance = FileDistance::Unreachable;
 /// Min distance between SymbolScope and all the available scopes.
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -300,6 +300,8 @@
   SemaCCResult.Availability == CXAvailability_NotAccessible)
 Forbidden = true;
 
+  SemaPriority = SemaCCResult.Priority;
+
   if (SemaCCResult.Declaration) {
 SemaSaysInScope = true;
 // We boost things that have decls in the main file. We give a fixed score
@@ -352,7 +354,12 @@
 SymbolRelevanceSignals::DerivedSignals
 SymbolRelevanceSignals::calculateDerivedSignals() const {
   DerivedSignals Derived;
-  Derived.NameMatchesContext = wordMatching(Name, ContextWords).hasValue();
+  int NumNameInContext = 0;
+  if (ContextWords)
+for (const auto  : ContextWords->keys())
+  if (Name.contains_lower(Word))
+NumNameInContext++;
+  Derived.NumNameInContext = NumNameInContext;
   Derived.FileProximityDistance = !FileProximityMatch || SymbolURI.empty()
   ? FileDistance::Unreachable
   : FileProximityMatch->distance(SymbolURI);
@@ -387,7 +394,7 @@
  ? 2.0
  : scopeProximityScore(Derived.ScopeProximityDistance);
 
-  if (Derived.NameMatchesContext)
+  if (Derived.NumNameInContext > 0)
 Score *= 1.5;
 
   // Symbols like local variables may only be referenced within their scope.
@@ -498,7 +505,7 @@
 
   SymbolRelevanceSignals::DerivedSignals Derived =
   Relevance.calculateDerivedSignals();
-  E.setIsNameInContext(Derived.NameMatchesContext);
+  E.setNumNameInContext(Derived.NumNameInContext);
   E.setIsForbidden(Relevance.Forbidden);
   

[PATCH] D88665: [ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl

2020-10-05 Thread Gabor Marton 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 rG007dd12d5468: [ASTImporter][AST] Fix structural equivalency 
crash on dependent FieldDecl (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88665

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/test/ASTMerge/struct/test.c
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -976,6 +976,39 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceTemplateTest, BitFieldDecl) {
+  const char *Code = "class foo { int a : 2; };";
+  auto t = makeNamedDecls(Code, Code, Lang_CXX03);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, BitFieldDeclDifferentWidth) {
+  auto t = makeNamedDecls("class foo { int a : 2; };",
+  "class foo { int a : 4; };", Lang_CXX03);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DependentBitFieldDecl) {
+  const char *Code = "template  class foo { int a : sizeof(T); };";
+  auto t = makeNamedDecls(Code, Code, Lang_CXX03);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DependentBitFieldDeclDifferentVal) {
+  auto t = makeNamedDecls(
+  "template  class foo { int a : sizeof(A); };",
+  "template  class foo { int a : sizeof(B); };",
+  Lang_CXX03);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DependentBitFieldDeclDifferentVal2) {
+  auto t = makeNamedDecls(
+  "template  class foo { int a : sizeof(A); };",
+  "template  class foo { int a : sizeof(A) + 1; };", Lang_CXX03);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolSame) {
   auto Decls = makeNamedDecls(
   "template  struct foo {explicit(b) foo(int);};",
Index: clang/test/ASTMerge/struct/test.c
===
--- clang/test/ASTMerge/struct/test.c
+++ clang/test/ASTMerge/struct/test.c
@@ -21,16 +21,6 @@
 // CHECK: struct1.c:27:8: note: no corresponding field here
 // CHECK: struct2.c:24:31: warning: external variable 'x4' declared with incompatible types in different translation units ('struct S4' vs. 'struct S4')
 // CHECK: struct1.c:27:22: note: declared here with type 'struct S4'
-// CHECK: struct1.c:33:8: warning: type 'struct S6' has incompatible definitions in different translation units
-// CHECK: struct1.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
-// CHECK: struct2.c:30:33: note: field 'j' is not a bit-field
-// CHECK: struct2.c:30:38: warning: external variable 'x6' declared with incompatible types in different translation units ('struct S6' vs. 'struct S6')
-// CHECK: struct1.c:33:42: note: declared here with type 'struct S6'
-// CHECK: struct1.c:36:8: warning: type 'struct S7' has incompatible definitions in different translation units
-// CHECK: struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
-// CHECK: struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
-// CHECK: struct2.c:33:43: warning: external variable 'x7' declared with incompatible types in different translation units ('struct S7' vs. 'struct S7')
-// CHECK: struct1.c:36:42: note: declared here with type 'struct S7'
 // CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible definitions in different translation units
 // CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
 // CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
@@ -52,4 +42,4 @@
 // CHECK: struct2.c:129:9: note: field 'S' has type 'struct (anonymous struct at [[PATH_TO_INPUTS]]struct2.c:127:7)' here
 // CHECK: struct2.c:138:3: warning: external variable 'x16' declared with incompatible types in different translation units ('struct DeepUnnamedError' vs. 'struct DeepUnnamedError')
 // CHECK: struct1.c:141:3: note: declared here with type 'struct DeepUnnamedError'
-// CHECK: 20 warnings generated
+// CHECK: 17 warnings generated
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1256,48 +1256,9 @@
 return false;
   }
 
-  if (Field1->isBitField() != Field2->isBitField()) {
-if (Context.Complain) {
-  Context.Diag2(
-  Owner2->getLocation(),
-  Context.getApplicableDiagnostic(diag::err_odr_tag_type_inconsistent))
-  << 

[PATCH] D88665: [ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl

2020-10-05 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Currently, we are totally inconsistent about the diagnostics. Either we 
> should emit a diagnostic before all return false or we should not ever emit 
> any diags. The diagnostics in their current form are misleading, because 
> there could be many notes missing. I am not sure how much do you guys value 
> these diags in LLDB, but in CTU we simply don't care about them. I'd rather 
> remove these diags from the equivalency check code, because they are causing 
> only confusion. (Or we should properly implement and test all aspects of the 
> diags.)



In D88665#2311344 , @teemperor wrote:

> LGTM, thanks!

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88665

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


[PATCH] D78902: [Driver] Add output file to properties of Command

2020-10-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:135
+ Bundler, BundlerArgs, Inputs,
+ InputInfo(, Output.c_str(;
 }

I would suggest to use `Args.MakeArgString(OutputFileName)` instead of 
`Output.c_str()` to make sure it persists through the whole compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78902

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


[PATCH] D88680: Add ability to turn off -fpch-instantiate-templates in clang-cl

2020-10-05 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D88680#2308601 , @zahen wrote:

> This patch doesn't need a test case outside of the one that @rnk requested to 
> make sure that the flag flows from the clang-cl driver appropriately.  
> `pch-instantiate-templates` as authored doesn't match cl.exe behavior and 
> being unable to turn it off will prevent our adoption of clang 11.  This is a 
> release blocking issue at least for 11.1 if not 11.0 (I leave it to @hans to 
> make the decision).  I suspect there are other users that will run into the 
> same problem we have.
>
> Of course we'll continue to work on a reduced repro to understand where the 
> feature and msvc diverge but that will be a follow up patch or new bug.

It's very late in the process for 11, but since this is just a flags change 
which seems safe, I'll consider it if we'll do another release candidate. Of 
course the patch has to land first :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88680

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


  1   2   >